Skip to content

Commit 479d6a7

Browse files
authored
ci: run lint / mypy / unit tests / coverage as GH actions (#287)
Make GH Action checks required
1 parent cb091f8 commit 479d6a7

File tree

3 files changed

+145
-1
lines changed

3 files changed

+145
-1
lines changed

.github/sync-repo-settings.yaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,28 @@
1+
# https://github.com/googleapis/repo-automation-bots/tree/main/packages/sync-repo-settings
2+
# Rules for main branch protection
3+
branchProtectionRules:
4+
# Identifies the protection rule pattern. Name of the branch to be protected.
5+
# Defaults to `main`
6+
- pattern: main
7+
requiresCodeOwnerReviews: true
8+
requiresStrictStatusChecks: true
9+
requiredStatusCheckContexts:
10+
- 'cla/google'
11+
# No Kokoro: the following are Github actions
12+
- 'lint-mypy'
13+
- 'unit-3.6'
14+
- 'unit-3.7'
15+
- 'unit-3.8'
16+
- 'unit-3.9'
17+
- 'unit-3.10'
18+
- 'unit_grpc_gcp-3.6'
19+
- 'unit_grpc_gcp-3.7'
20+
- 'unit_grpc_gcp-3.8'
21+
- 'unit_grpc_gcp-3.9'
22+
- 'unit_grpc_gcp-3.10'
23+
- 'unit_wo_grpc-3.6'
24+
- 'unit_wo_grpc-3.10'
25+
- 'cover'
126
permissionRules:
227
- team: actools-python
328
permission: admin

.github/workflows/unittest_lint.yml

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
name: "Lint / Unit tests / Cover / Mypy"
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
8+
9+
jobs:
10+
11+
run-lint-mypy:
12+
name: lint-mypy
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
17+
- name: Checkout
18+
uses: actions/checkout@v2
19+
20+
- name: Setup Python
21+
uses: actions/setup-python@v2
22+
with:
23+
python-version: "3.10"
24+
25+
- name: Install nox
26+
run: |
27+
python -m pip install --upgrade setuptools pip wheel
28+
python -m pip install nox
29+
30+
- name: Run lint
31+
run: |
32+
nox -s lint
33+
34+
- name: Run lint_setup_py
35+
run: |
36+
nox -s lint_setup_py
37+
38+
- name: Run mypy
39+
run: |
40+
nox -s mypy
41+
42+
run-unittests:
43+
name: unit${{ matrix.option }}-${{ matrix.python }}
44+
runs-on: ubuntu-latest
45+
strategy:
46+
matrix:
47+
option: ["", "_grpc_gcp", "_wo_grpc"]
48+
python:
49+
- "3.6"
50+
- "3.7"
51+
- "3.8"
52+
- "3.9"
53+
- "3.10"
54+
exclude:
55+
- option: "_wo_grpc"
56+
python: 3.7
57+
- option: "_wo_grpc"
58+
python: 3.8
59+
- option: "_wo_grpc"
60+
python: 3.9
61+
62+
steps:
63+
64+
- name: Checkout
65+
uses: actions/checkout@v2
66+
67+
- name: Setup Python
68+
uses: actions/setup-python@v2
69+
with:
70+
python-version: ${{ matrix.python }}
71+
72+
- name: Install nox
73+
run: |
74+
python -m pip install --upgrade setuptools pip wheel
75+
python -m pip install nox
76+
77+
- name: Run unit tests
78+
env:
79+
COVERAGE_FILE: .coverage${{ matrix.option }}-${{matrix.python }}
80+
run: |
81+
nox -s unit${{ matrix.option }}-${{ matrix.python }}
82+
83+
- name: Upload coverage results
84+
uses: actions/upload-artifact@v2
85+
with:
86+
name: coverage-artifacts
87+
path: .coverage${{ matrix.option }}-${{ matrix.python }}
88+
89+
report-coverage:
90+
name: cover
91+
runs-on: ubuntu-latest
92+
needs:
93+
- run-unittests
94+
95+
steps:
96+
97+
- name: Checkout
98+
uses: actions/checkout@v2
99+
100+
- name: Setup Python
101+
uses: actions/setup-python@v2
102+
with:
103+
python-version: "3.10"
104+
105+
- name: Install coverage
106+
run: |
107+
python -m pip install --upgrade setuptools pip wheel
108+
python -m pip install coverage
109+
110+
- name: Download coverage results
111+
uses: actions/download-artifact@v2
112+
with:
113+
name: coverage-artifacts
114+
path: .coverage-results/
115+
116+
- name: Report coverage results
117+
run: |
118+
coverage combine .coverage-results/.coverage*
119+
coverage report --show-missing --fail-under=100

noxfile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ def unit(session):
132132
default(session)
133133

134134

135-
@nox.session(python=["3.6", "3.7", "3.8", "3.9"])
135+
@nox.session(python=["3.6", "3.7", "3.8", "3.9", "3.10"])
136136
def unit_grpc_gcp(session):
137137
"""Run the unit test suite with grpcio-gcp installed."""
138138
constraints_path = str(

0 commit comments

Comments
 (0)