From 61458890820142695d9cc0d81993f67537774ad6 Mon Sep 17 00:00:00 2001 From: Sri Harsha CH <57220027+harshachinta@users.noreply.github.com> Date: Sun, 6 Aug 2023 20:57:21 +0530 Subject: [PATCH 1/3] build: add code coverage in GitHub action presubmit --- .github/workflows/unittest.yaml | 57 +++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 .github/workflows/unittest.yaml diff --git a/.github/workflows/unittest.yaml b/.github/workflows/unittest.yaml new file mode 100644 index 0000000000..8057a7691b --- /dev/null +++ b/.github/workflows/unittest.yaml @@ -0,0 +1,57 @@ +on: + pull_request: + branches: + - main +name: unittest +jobs: + unit: + runs-on: ubuntu-latest + strategy: + matrix: + python: ['3.7', '3.8', '3.9', '3.10', '3.11'] + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Setup Python + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python }} + - name: Install nox + run: | + python -m pip install --upgrade setuptools pip wheel + python -m pip install nox + - name: Run unit tests + env: + COVERAGE_FILE: .coverage-${{ matrix.python }} + run: | + nox -s unit-${{ matrix.python }} + - name: Upload coverage results + uses: actions/upload-artifact@v3 + with: + name: coverage-artifacts + path: .coverage-${{ matrix.python }} + + cover: + runs-on: ubuntu-latest + needs: + - unit + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Setup Python + uses: actions/setup-python@v4 + with: + python-version: "3.8" + - name: Install coverage + run: | + python -m pip install --upgrade setuptools pip wheel + python -m pip install coverage + - name: Download coverage results + uses: actions/download-artifact@v3 + with: + name: coverage-artifacts + path: .coverage-results/ + - name: Report coverage results + run: | + coverage combine .coverage-results/.coverage* + coverage report --show-missing --fail-under=100 From 5b44e9c1d6a09c17bfed8350f945c383a3000df5 Mon Sep 17 00:00:00 2001 From: Sri Harsha CH <57220027+harshachinta@users.noreply.github.com> Date: Sun, 6 Aug 2023 21:07:02 +0530 Subject: [PATCH 2/3] build: add emulator --- .github/workflows/unittest.yaml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.github/workflows/unittest.yaml b/.github/workflows/unittest.yaml index 8057a7691b..a66f41587c 100644 --- a/.github/workflows/unittest.yaml +++ b/.github/workflows/unittest.yaml @@ -6,6 +6,12 @@ name: unittest jobs: unit: runs-on: ubuntu-latest + services: + emulator: + image: gcr.io/cloud-spanner-emulator/emulator:latest + ports: + - 9010:9010 + - 9020:9020 strategy: matrix: python: ['3.7', '3.8', '3.9', '3.10', '3.11'] @@ -25,6 +31,10 @@ jobs: COVERAGE_FILE: .coverage-${{ matrix.python }} run: | nox -s unit-${{ matrix.python }} + env: + SPANNER_EMULATOR_HOST: localhost:9010 + GOOGLE_CLOUD_PROJECT: emulator-test-project + GOOGLE_CLOUD_TESTS_CREATE_SPANNER_INSTANCE: true - name: Upload coverage results uses: actions/upload-artifact@v3 with: From 19b0f9116d0cc72f1ff968cb2319358adc7b1651 Mon Sep 17 00:00:00 2001 From: Sri Harsha CH <57220027+harshachinta@users.noreply.github.com> Date: Sun, 6 Aug 2023 21:09:43 +0530 Subject: [PATCH 3/3] build: fix file --- .github/workflows/unittest.yaml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/unittest.yaml b/.github/workflows/unittest.yaml index a66f41587c..cfa30e45ce 100644 --- a/.github/workflows/unittest.yaml +++ b/.github/workflows/unittest.yaml @@ -29,12 +29,11 @@ jobs: - name: Run unit tests env: COVERAGE_FILE: .coverage-${{ matrix.python }} - run: | - nox -s unit-${{ matrix.python }} - env: SPANNER_EMULATOR_HOST: localhost:9010 GOOGLE_CLOUD_PROJECT: emulator-test-project GOOGLE_CLOUD_TESTS_CREATE_SPANNER_INSTANCE: true + run: | + nox -s unit-${{ matrix.python }} - name: Upload coverage results uses: actions/upload-artifact@v3 with: