From ba300ed62eb8dec119772305a56c4f2e6401037c Mon Sep 17 00:00:00 2001 From: Christophe Bornet Date: Thu, 14 Mar 2024 12:24:41 +0100 Subject: [PATCH] Run integration tests in CI (#9) --- .github/workflows/_integration_test.yml | 59 +++++++++++++++++++++++++ .github/workflows/check_diffs.yml | 15 ++++++- libs/astradb/pyproject.toml | 2 +- 3 files changed, 74 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/_integration_test.yml diff --git a/.github/workflows/_integration_test.yml b/.github/workflows/_integration_test.yml new file mode 100644 index 0000000..caf1f51 --- /dev/null +++ b/.github/workflows/_integration_test.yml @@ -0,0 +1,59 @@ +name: Integration tests + +on: + workflow_call: + inputs: + working-directory: + required: true + type: string + +env: + POETRY_VERSION: "1.7.1" + +jobs: + build: + defaults: + run: + working-directory: ${{ inputs.working-directory }} + runs-on: ubuntu-latest + strategy: + matrix: + python-version: + # - "3.8" + - "3.11" + name: "make integration_tests #${{ matrix.python-version }}" + steps: + - uses: actions/checkout@v4 + + - name: Set up Python ${{ matrix.python-version }} + Poetry ${{ env.POETRY_VERSION }} + uses: "./.github/actions/poetry_setup" + with: + python-version: ${{ matrix.python-version }} + poetry-version: ${{ env.POETRY_VERSION }} + working-directory: ${{ inputs.working-directory }} + cache-key: core + + - name: Install dependencies + shell: bash + run: poetry install --with test,test_integration + + - name: Run integration tests + shell: bash + env: + ASTRA_DB_API_ENDPOINT: ${{ secrets.ASTRA_DB_API_ENDPOINT }} + ASTRA_DB_APPLICATION_TOKEN: ${{ secrets.ASTRA_DB_APPLICATION_TOKEN }} + ASTRA_DB_KEYSPACE: ${{ secrets.ASTRA_DB_KEYSPACE }} + run: | + make integration_tests + + - name: Ensure the tests did not create any additional files + shell: bash + run: | + set -eu + + STATUS="$(git status)" + echo "$STATUS" + + # grep will exit non-zero if the target message isn't found, + # and `set -e` above will cause the step to fail. + echo "$STATUS" | grep 'nothing to commit, working tree clean' \ No newline at end of file diff --git a/.github/workflows/check_diffs.yml b/.github/workflows/check_diffs.yml index b6f4891..2d8bdc4 100644 --- a/.github/workflows/check_diffs.yml +++ b/.github/workflows/check_diffs.yml @@ -59,6 +59,18 @@ jobs: working-directory: ${{ matrix.working-directory }} secrets: inherit + integration-tests: + name: cd ${{ matrix.working-directory }} + needs: [ build ] + if: ${{ needs.build.outputs.dirs-to-test != '[]' }} + strategy: + matrix: + working-directory: ${{ fromJson(needs.build.outputs.dirs-to-test) }} + uses: ./.github/workflows/_integration_test.yml + with: + working-directory: ${{ matrix.working-directory }} + secrets: inherit + compile-integration-tests: name: cd ${{ matrix.working-directory }} needs: [ build ] @@ -70,9 +82,10 @@ jobs: with: working-directory: ${{ matrix.working-directory }} secrets: inherit + ci_success: name: "CI Success" - needs: [build, lint, test, compile-integration-tests] + needs: [build, lint, test, compile-integration-tests, integration-tests] if: | always() runs-on: ubuntu-latest diff --git a/libs/astradb/pyproject.toml b/libs/astradb/pyproject.toml index 4b9e283..8ee8193 100644 --- a/libs/astradb/pyproject.toml +++ b/libs/astradb/pyproject.toml @@ -82,7 +82,7 @@ build-backend = "poetry.core.masonry.api" # # https://github.com/tophat/syrupy # --snapshot-warn-unused Prints a warning on unused snapshots rather than fail the test suite. -addopts = "--snapshot-warn-unused --strict-markers --strict-config --durations=5" +addopts = "--snapshot-warn-unused --strict-markers --strict-config --durations=5 -vv" # Registering custom markers. # https://docs.pytest.org/en/7.1.x/example/markers.html#registering-markers markers = [