Skip to content

Commit

Permalink
ci: run lint / mypy / unit tests / coverage as GH actions (#287)
Browse files Browse the repository at this point in the history
Make GH Action checks required
  • Loading branch information
tseaver committed Dec 8, 2021
1 parent cb091f8 commit 479d6a7
Show file tree
Hide file tree
Showing 3 changed files with 145 additions and 1 deletion.
25 changes: 25 additions & 0 deletions .github/sync-repo-settings.yaml
@@ -1,3 +1,28 @@
# https://github.com/googleapis/repo-automation-bots/tree/main/packages/sync-repo-settings
# Rules for main branch protection
branchProtectionRules:
# Identifies the protection rule pattern. Name of the branch to be protected.
# Defaults to `main`
- pattern: main
requiresCodeOwnerReviews: true
requiresStrictStatusChecks: true
requiredStatusCheckContexts:
- 'cla/google'
# No Kokoro: the following are Github actions
- 'lint-mypy'
- 'unit-3.6'
- 'unit-3.7'
- 'unit-3.8'
- 'unit-3.9'
- 'unit-3.10'
- 'unit_grpc_gcp-3.6'
- 'unit_grpc_gcp-3.7'
- 'unit_grpc_gcp-3.8'
- 'unit_grpc_gcp-3.9'
- 'unit_grpc_gcp-3.10'
- 'unit_wo_grpc-3.6'
- 'unit_wo_grpc-3.10'
- 'cover'
permissionRules:
- team: actools-python
permission: admin
Expand Down
119 changes: 119 additions & 0 deletions .github/workflows/unittest_lint.yml
@@ -0,0 +1,119 @@
name: "Lint / Unit tests / Cover / Mypy"

on:
pull_request:
branches:
- main


jobs:

run-lint-mypy:
name: lint-mypy
runs-on: ubuntu-latest

steps:

- name: Checkout
uses: actions/checkout@v2

- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: "3.10"

- name: Install nox
run: |
python -m pip install --upgrade setuptools pip wheel
python -m pip install nox
- name: Run lint
run: |
nox -s lint
- name: Run lint_setup_py
run: |
nox -s lint_setup_py
- name: Run mypy
run: |
nox -s mypy
run-unittests:
name: unit${{ matrix.option }}-${{ matrix.python }}
runs-on: ubuntu-latest
strategy:
matrix:
option: ["", "_grpc_gcp", "_wo_grpc"]
python:
- "3.6"
- "3.7"
- "3.8"
- "3.9"
- "3.10"
exclude:
- option: "_wo_grpc"
python: 3.7
- option: "_wo_grpc"
python: 3.8
- option: "_wo_grpc"
python: 3.9

steps:

- name: Checkout
uses: actions/checkout@v2

- name: Setup Python
uses: actions/setup-python@v2
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.option }}-${{matrix.python }}
run: |
nox -s unit${{ matrix.option }}-${{ matrix.python }}
- name: Upload coverage results
uses: actions/upload-artifact@v2
with:
name: coverage-artifacts
path: .coverage${{ matrix.option }}-${{ matrix.python }}

report-coverage:
name: cover
runs-on: ubuntu-latest
needs:
- run-unittests

steps:

- name: Checkout
uses: actions/checkout@v2

- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: "3.10"

- 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@v2
with:
name: coverage-artifacts
path: .coverage-results/

- name: Report coverage results
run: |
coverage combine .coverage-results/.coverage*
coverage report --show-missing --fail-under=100
2 changes: 1 addition & 1 deletion noxfile.py
Expand Up @@ -132,7 +132,7 @@ def unit(session):
default(session)


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

0 comments on commit 479d6a7

Please sign in to comment.