Skip to content

Commit

Permalink
ci: refactor coverage check
Browse files Browse the repository at this point in the history
  • Loading branch information
parthea committed Aug 25, 2023
1 parent 5739e54 commit 3fa8c78
Show file tree
Hide file tree
Showing 3 changed files with 120 additions and 2 deletions.
1 change: 0 additions & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ omit =
*_pb2.py

[report]
fail_under = 100
show_missing = True
exclude_lines =
# Re-enable the standard pragma
Expand Down
3 changes: 3 additions & 0 deletions .github/sync-repo-settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ branchProtectionRules:
- 'showcase-unit (3.10, _mixins)'
- 'showcase-unit (3.11, _mixins)'
- 'showcase-unit-add-iam-methods'
- 'showcase-cover'
- 'integration'
- 'goldens-lint'
- 'style-check'
Expand All @@ -46,6 +47,7 @@ branchProtectionRules:
- 'unit (3.9)'
- 'unit (3.10)'
- 'unit (3.11)'
- 'unit-cover'
- 'fragment (3.7)'
- 'fragment (3.8)'
- 'fragment (3.9)'
Expand All @@ -56,6 +58,7 @@ branchProtectionRules:
- 'fragment (3.9, _alternative_templates)'
- 'fragment (3.10, _alternative_templates)'
- 'fragment (3.11, _alternative_templates)'
- 'fragment-cover'
- 'OwlBot Post Processor'
requiredApprovingReviewCount: 1
requiresCodeOwnerReviews: true
Expand Down
118 changes: 117 additions & 1 deletion .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ jobs:
sudo ln -s /usr/src/protoc/bin/protoc /usr/local/bin/protoc
- name: Run showcase tests.
run: nox -s ${{ matrix.target }}
- name: Install coverage
run: |
python -m pip install coverage
- name: Report coverage results
run: |
coverage report --show-missing --fail-under=100
showcase-mtls:
if: ${{ false }} # TODO(dovs): reenable when #1218 is fixed
strategy:
Expand Down Expand Up @@ -127,6 +133,12 @@ jobs:
cd ..
nox -s ${{ matrix.target }}
- name: Install coverage
run: |
python -m pip install coverage
- name: Report coverage results
run: |
coverage report --show-missing --fail-under=100
# TODO(yon-mg): add compute unit tests
showcase-unit:
strategy:
Expand Down Expand Up @@ -156,7 +168,37 @@ jobs:
- name: Install nox.
run: python -m pip install nox
- name: Run unit tests.
env:
COVERAGE_FILE: .coverage-showcase-unit-${{ matrix.variant }}-${{ matrix.python }}
run: nox -s showcase_unit${{ matrix.variant }}-${{ matrix.python }}
- name: Upload coverage results
uses: actions/upload-artifact@v3
with:
name: coverage-artifacts
path: .coverage-showcase-unit-${{ matrix.variant }}-${{ matrix.python }}
showcase-cover:
runs-on: ubuntu-latest
needs:
- showcase-unit
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v3
with:
python-version: "3.11"
- name: Install coverage
run: |
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-showcase-unit*
coverage report --show-missing --fail-under=100
showcase-unit-add-iam-methods:
runs-on: ubuntu-latest
steps:
Expand All @@ -182,6 +224,12 @@ jobs:
run: python -m pip install nox
- name: Run unit tests.
run: nox -s showcase_unit_add_iam_methods
- name: Install coverage
run: |
python -m pip install coverage
- name: Report coverage results
run: |
coverage report --show-missing --fail-under=100
showcase-mypy:
runs-on: ubuntu-latest
strategy:
Expand Down Expand Up @@ -227,6 +275,12 @@ jobs:
run: python -m pip install nox
- name: Check autogenerated snippets.
run: nox -s snippetgen
- name: Install coverage
run: |
python -m pip install coverage
- name: Report coverage results
run: |
coverage report --show-missing --fail-under=100
unit:
strategy:
matrix:
Expand All @@ -247,7 +301,37 @@ jobs:
run: |
python -m pip install nox
- name: Run unit tests.
env:
COVERAGE_FILE: .coverage-unit-${{ matrix.python }}
run: nox -s unit-${{ matrix.python }}
- name: Upload coverage results
uses: actions/upload-artifact@v3
with:
name: coverage-artifacts
path: .coverage-unit-${{ matrix.python }}
unit-cover:
runs-on: ubuntu-latest
needs:
- unit
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v3
with:
python-version: "3.11"
- name: Install coverage
run: |
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-unit*
coverage report --show-missing --fail-under=100
fragment:
strategy:
matrix:
Expand All @@ -269,7 +353,37 @@ jobs:
run: |
python -m pip install nox
- name: Run fragment tests.
env:
COVERAGE_FILE: .coverage-fragment-${{ matrix.variant }}-${{ matrix.python }}
run: nox -s fragment${{ matrix.variant }}-${{ matrix.python }}
- name: Upload coverage results
uses: actions/upload-artifact@v3
with:
name: coverage-artifacts
path: .coverage-fragment-${{ matrix.python }}
fragment-cover:
runs-on: ubuntu-latest
needs:
- fragment
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v3
with:
python-version: "3.11"
- name: Install coverage
run: |
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-${{ matrix.variant }}-*
coverage report --show-missing --fail-under=100
integration:
runs-on: ubuntu-latest
container: gcr.io/gapic-images/googleapis
Expand Down Expand Up @@ -328,8 +442,10 @@ jobs:
python-version: "3.11"
cache: 'pip'
- name: Install autopep8
# Pin autopep8. Version 2.0.3 has an issue with a missing dependency
# See https://github.com/hhatto/autopep8/issues/702
run: |
python -m pip install autopep8
python -m pip install autopep8==2.0.2
- name: Check diff
run: |
find gapic tests -name "*.py" -not -path 'tests/**/goldens/*' | xargs autopep8 --diff --exit-code

0 comments on commit 3fa8c78

Please sign in to comment.