Skip to content

Commit

Permalink
ci(python): run lint / unit tests / docs as GH actions (#336)
Browse files Browse the repository at this point in the history
* ci(python): run lint / unit tests / docs as GH actions

Source-Link: googleapis/synthtool@57be0cd
Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:ed1f9983d5a935a89fe8085e8bb97d94e41015252c5b6c9771257cf8624367e6

* revert changes to unittest gh action

* move mypy check into separate workflow

* update .sync-repo-settings to reflect changes to gh checks

* use python 3.7 for lint check

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Co-authored-by: Anthonios Partheniou <partheniou@google.com>
  • Loading branch information
3 people committed Jan 22, 2022
1 parent 5e5ad37 commit 95e41ff
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 16 deletions.
15 changes: 14 additions & 1 deletion .github/.OwlBot.lock.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
# Copyright 2022 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
docker:
image: gcr.io/cloud-devrel-public-resources/owlbot-python:latest
digest: sha256:ae600f36b6bc972b368367b6f83a1d91ec2c82a4a116b383d67d547c56fe6de3
digest: sha256:ed1f9983d5a935a89fe8085e8bb97d94e41015252c5b6c9771257cf8624367e6
4 changes: 3 additions & 1 deletion .github/sync-repo-settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ branchProtectionRules:
requiredStatusCheckContexts:
- 'cla/google'
# No Kokoro: the following are Github actions
- 'lint-mypy'
- 'lint'
- 'mypy'
- 'unit-3.6'
- 'unit-3.7'
- 'unit-3.8'
Expand All @@ -24,6 +25,7 @@ branchProtectionRules:
- 'unit_wo_grpc-3.10'
- 'cover'
- 'docs'
- 'docfx'
permissionRules:
- team: actools-python
permission: admin
Expand Down
27 changes: 20 additions & 7 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,38 @@
name: "Docs"

on:
pull_request:
branches:
- main
name: docs
jobs:
run-docs:
name: docs
docs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: "3.7"
python-version: "3.10"
- name: Install nox
run: |
python -m pip install --upgrade setuptools pip wheel
python -m pip install nox
- name: Run docs
run: |
nox -s docs docfx
nox -s docs
docfx:
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 docfx
run: |
nox -s docfx
9 changes: 2 additions & 7 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
name: "Lint"

on:
pull_request:
branches:
- main
name: lint
jobs:
run-lint-mypy:
name: lint-mypy
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -25,6 +23,3 @@ jobs:
- name: Run lint_setup_py
run: |
nox -s lint_setup_py
- name: Run mypy
run: |
nox -s mypy
22 changes: 22 additions & 0 deletions .github/workflows/mypy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
on:
pull_request:
branches:
- main
name: mypy
jobs:
mypy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: "3.7"
- name: Install nox
run: |
python -m pip install --upgrade setuptools pip wheel
python -m pip install nox
- name: Run mypy
run: |
nox -s mypy
4 changes: 4 additions & 0 deletions owlbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
".flake8", # flake8-import-order, layout
".coveragerc", # layout
"CONTRIBUTING.rst", # no systests
".github/workflows/unittest.yml", # exclude unittest gh action
]
templated_files = common.py_library(microgenerator=True, cov_level=100)
s.move(templated_files, excludes=excludes)
Expand All @@ -44,4 +45,7 @@
""",
)

s.replace(".github/workflows/lint.yml", "python-version: \"3.10\"", "python-version: \"3.7\"")


s.shell.run(["nox", "-s", "blacken"], hide_output=False)

0 comments on commit 95e41ff

Please sign in to comment.