From ea7a1fe8e013ba20bd2d7d2b1feb7c3be2bb77de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dr=2E=20Patrick=20Urbanke=20=28=E5=8A=89=E8=87=AA=E6=88=90?= =?UTF-8?q?=29?= Date: Thu, 22 May 2025 08:44:59 +0200 Subject: [PATCH] Added a Github Actions pipeline for Windows (#5) --- .github/workflows/windows-postgres-cxx20.yaml | 36 +++++++++++++++++++ .github/workflows/windows-sqlite-cxx20.yaml | 36 +++++++++++++++++++ src/sqlgen/postgres/Connection.cpp | 1 + tests/postgres/test_insert_and_read.cpp | 4 +++ .../test_insert_and_read_two_tables.cpp | 4 +++ tests/postgres/test_transaction.cpp | 8 +++-- 6 files changed, 87 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/windows-postgres-cxx20.yaml create mode 100644 .github/workflows/windows-sqlite-cxx20.yaml diff --git a/.github/workflows/windows-postgres-cxx20.yaml b/.github/workflows/windows-postgres-cxx20.yaml new file mode 100644 index 0000000..25a41b1 --- /dev/null +++ b/.github/workflows/windows-postgres-cxx20.yaml @@ -0,0 +1,36 @@ +name: windows-postgres-cxx20 + +on: + pull_request: + types: [opened, synchronize, reopened, closed] + push: + branches: + - master + +env: + VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite" + +jobs: + windows-msvc: + runs-on: windows-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + submodules: recursive + fetch-depth: 0 + - name: Export GitHub Actions cache environment variables + uses: actions/github-script@v7 + with: + script: | + core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || ''); + core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || ''); + - uses: ilammy/msvc-dev-cmd@v1 + - uses: lukka/run-vcpkg@v11 + - name: Compile + run: | + cmake -S . -B build -G Ninja -DCMAKE_CXX_STANDARD=20 -DSQLGEN_BUILD_TESTS=ON -DSQLGEN_SQLITE3=OFF -DSQLGEN_BUILD_DRY_TESTS_ONLY=ON + cmake --build build --config Release -j4 + - name: Run tests + run: | + ctest --test-dir build --output-on-failure diff --git a/.github/workflows/windows-sqlite-cxx20.yaml b/.github/workflows/windows-sqlite-cxx20.yaml new file mode 100644 index 0000000..90fda0d --- /dev/null +++ b/.github/workflows/windows-sqlite-cxx20.yaml @@ -0,0 +1,36 @@ +name: windows-sqlite-cxx20 + +on: + pull_request: + types: [opened, synchronize, reopened, closed] + push: + branches: + - master + +env: + VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite" + +jobs: + windows-msvc: + runs-on: windows-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + submodules: recursive + fetch-depth: 0 + - name: Export GitHub Actions cache environment variables + uses: actions/github-script@v7 + with: + script: | + core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || ''); + core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || ''); + - uses: ilammy/msvc-dev-cmd@v1 + - uses: lukka/run-vcpkg@v11 + - name: Compile + run: | + cmake -S . -B build -G Ninja -DCMAKE_CXX_STANDARD=20 -DSQLGEN_BUILD_TESTS=ON -DSQLGEN_POSTGRES=OFF + cmake --build build --config Release -j4 + - name: Run tests + run: | + ctest --test-dir build --output-on-failure diff --git a/src/sqlgen/postgres/Connection.cpp b/src/sqlgen/postgres/Connection.cpp index 7200137..4428d0c 100644 --- a/src/sqlgen/postgres/Connection.cpp +++ b/src/sqlgen/postgres/Connection.cpp @@ -76,6 +76,7 @@ Result Connection::insert( const auto& d = _data[i]; if (d.size() != current_row.size()) { + execute("DEALLOCATE sqlgen_insert_into_table;"); return error("Error in entry " + std::to_string(i) + ": Expected " + std::to_string(current_row.size()) + " entries, got " + std::to_string(d.size())); diff --git a/tests/postgres/test_insert_and_read.cpp b/tests/postgres/test_insert_and_read.cpp index 129064b..380178a 100644 --- a/tests/postgres/test_insert_and_read.cpp +++ b/tests/postgres/test_insert_and_read.cpp @@ -1,3 +1,5 @@ +#ifndef SQLGEN_BUILD_DRY_TESTS_ONLY + #include #include @@ -47,3 +49,5 @@ TEST(postgres, test_insert_and_read) { } } // namespace test_insert_and_read + +#endif diff --git a/tests/postgres/test_insert_and_read_two_tables.cpp b/tests/postgres/test_insert_and_read_two_tables.cpp index 9cda938..cc453ce 100644 --- a/tests/postgres/test_insert_and_read_two_tables.cpp +++ b/tests/postgres/test_insert_and_read_two_tables.cpp @@ -1,3 +1,5 @@ +#ifndef SQLGEN_BUILD_DRY_TESTS_ONLY + #include #include @@ -60,3 +62,5 @@ TEST(postgres, test_insert_and_read_two_tables) { } } // namespace test_insert_and_read_two_tables + +#endif diff --git a/tests/postgres/test_transaction.cpp b/tests/postgres/test_transaction.cpp index 8e76cc0..8eef514 100644 --- a/tests/postgres/test_transaction.cpp +++ b/tests/postgres/test_transaction.cpp @@ -1,3 +1,5 @@ +#ifndef SQLGEN_BUILD_DRY_TESTS_ONLY + #include #include @@ -6,7 +8,7 @@ #include #include -namespace test_update { +namespace test_transaction { struct Person { sqlgen::PrimaryKey id; @@ -59,4 +61,6 @@ TEST(postgres, test_transaction) { EXPECT_EQ(rfl::json::write(people2), expected); } -} // namespace test_update +} // namespace test_transaction + +#endif