Skip to content

Commit e042303

Browse files
committed
enable unit tests via github action
1 parent e75cf7b commit e042303

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed

.github/workflows/unittest.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
on:
2+
pull_request:
3+
branches:
4+
- main
5+
name: unittest
6+
jobs:
7+
unit:
8+
# TODO(https://github.com/googleapis/gapic-generator-python/issues/2303): use `ubuntu-latest` once this bug is fixed.
9+
# Use ubuntu-22.04 until Python 3.7 is removed from the test matrix
10+
# https://docs.github.com/en/actions/using-github-hosted-runners/using-github-hosted-runners/about-github-hosted-runners#standard-github-hosted-runners-for-public-repositories
11+
runs-on: ubuntu-22.04
12+
strategy:
13+
matrix:
14+
python: {{unit_test_python_versions}}
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v4
18+
- name: Setup Python
19+
uses: actions/setup-python@v5
20+
with:
21+
python-version: ${{ '{{' }} matrix.python {{ '}}' }}
22+
- name: Install nox
23+
run: |
24+
python -m pip install --upgrade setuptools pip wheel
25+
python -m pip install nox
26+
- name: Run unit tests
27+
env:
28+
COVERAGE_FILE: .coverage-${{ '{{' }} matrix.python {{ '}}' }}
29+
run: |
30+
nox -s unit-${{ '{{' }} matrix.python {{ '}}' }}
31+
- name: Upload coverage results
32+
uses: actions/upload-artifact@v4
33+
with:
34+
name: coverage-artifact-${{ '{{' }} matrix.python {{ '}}' }}
35+
path: .coverage-${{ '{{' }} matrix.python {{ '}}' }}
36+
include-hidden-files: true
37+
38+
cover:
39+
runs-on: ubuntu-latest
40+
needs:
41+
- unit
42+
steps:
43+
- name: Checkout
44+
uses: actions/checkout@v4
45+
- name: Setup Python
46+
uses: actions/setup-python@v5
47+
with:
48+
python-version: "{{ default_python_version }}"
49+
- name: Install coverage
50+
run: |
51+
python -m pip install --upgrade setuptools pip wheel
52+
python -m pip install coverage
53+
- name: Download coverage results
54+
uses: actions/download-artifact@v4
55+
with:
56+
path: .coverage-results/
57+
- name: Report coverage results
58+
run: |
59+
find .coverage-results -type f -name '*.zip' -exec unzip {} \;
60+
coverage combine .coverage-results/**/.coverage*
61+
coverage report --show-missing --fail-under={{ cov_level if cov_level != None else 100 }}

0 commit comments

Comments
 (0)