From 4bc4e5a23fce849af8d50ab6b02658a42761a2e3 Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Thu, 20 Jan 2022 02:34:49 +0000 Subject: [PATCH 1/5] ci(python): run lint / unit tests / docs as GH actions Source-Link: https://github.com/googleapis/synthtool/commit/57be0cdb0b94e1669cee0ca38d790de1dfdbcd44 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:ed1f9983d5a935a89fe8085e8bb97d94e41015252c5b6c9771257cf8624367e6 --- .github/.OwlBot.lock.yaml | 15 ++++++++++++++- .github/workflows/docs.yml | 27 ++++++++++++++++++++------- .github/workflows/lint.yml | 11 +++-------- .github/workflows/unittest.yml | 33 ++++++++------------------------- 4 files changed, 45 insertions(+), 41 deletions(-) diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index eecb84c2..8cb43804 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -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 diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index bd90e5bf..f7b8344c 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -1,12 +1,10 @@ -name: "Docs" - on: pull_request: branches: - main +name: docs jobs: - run-docs: - name: docs + docs: runs-on: ubuntu-latest steps: - name: Checkout @@ -14,12 +12,27 @@ jobs: - 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 diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index c6d94b00..1e8b05c3 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -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 @@ -14,7 +12,7 @@ jobs: - 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 @@ -25,6 +23,3 @@ jobs: - name: Run lint_setup_py run: | nox -s lint_setup_py - - name: Run mypy - run: | - nox -s mypy diff --git a/.github/workflows/unittest.yml b/.github/workflows/unittest.yml index 9ab0c395..074ee250 100644 --- a/.github/workflows/unittest.yml +++ b/.github/workflows/unittest.yml @@ -1,30 +1,14 @@ -name: "Unit tests" - on: pull_request: branches: - main - +name: unittest jobs: - run-unittests: - name: unit${{ matrix.option }}-${{ matrix.python }} + unit: 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 + python: ['3.6', '3.7', '3.8', '3.9', '3.10'] steps: - name: Checkout uses: actions/checkout@v2 @@ -38,20 +22,19 @@ jobs: python -m pip install nox - name: Run unit tests env: - COVERAGE_FILE: .coverage${{ matrix.option }}-${{matrix.python }} + COVERAGE_FILE: .coverage-${{ matrix.python }} run: | - nox -s unit${{ matrix.option }}-${{ matrix.python }} + nox -s unit-${{ matrix.python }} - name: Upload coverage results uses: actions/upload-artifact@v2 with: name: coverage-artifacts - path: .coverage${{ matrix.option }}-${{ matrix.python }} + path: .coverage-${{ matrix.python }} - report-coverage: - name: cover + cover: runs-on: ubuntu-latest needs: - - run-unittests + - unit steps: - name: Checkout uses: actions/checkout@v2 From 70e744b37d76965da854cf1defd64623bd9d682f Mon Sep 17 00:00:00 2001 From: Anthonios Partheniou Date: Sat, 22 Jan 2022 10:46:07 +0000 Subject: [PATCH 2/5] revert changes to unittest gh action --- .github/workflows/unittest.yml | 33 +++++++++++++++++++++++++-------- owlbot.py | 1 + 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/.github/workflows/unittest.yml b/.github/workflows/unittest.yml index 074ee250..9ab0c395 100644 --- a/.github/workflows/unittest.yml +++ b/.github/workflows/unittest.yml @@ -1,14 +1,30 @@ +name: "Unit tests" + on: pull_request: branches: - main -name: unittest + jobs: - unit: + run-unittests: + name: unit${{ matrix.option }}-${{ matrix.python }} runs-on: ubuntu-latest strategy: matrix: - python: ['3.6', '3.7', '3.8', '3.9', '3.10'] + 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 @@ -22,19 +38,20 @@ jobs: python -m pip install nox - name: Run unit tests env: - COVERAGE_FILE: .coverage-${{ matrix.python }} + COVERAGE_FILE: .coverage${{ matrix.option }}-${{matrix.python }} run: | - nox -s unit-${{ matrix.python }} + nox -s unit${{ matrix.option }}-${{ matrix.python }} - name: Upload coverage results uses: actions/upload-artifact@v2 with: name: coverage-artifacts - path: .coverage-${{ matrix.python }} + path: .coverage${{ matrix.option }}-${{ matrix.python }} - cover: + report-coverage: + name: cover runs-on: ubuntu-latest needs: - - unit + - run-unittests steps: - name: Checkout uses: actions/checkout@v2 diff --git a/owlbot.py b/owlbot.py index 451f7c48..01f84995 100644 --- a/owlbot.py +++ b/owlbot.py @@ -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) From 035494fa20ad92cbe0054393d4da921bf4ec7e1c Mon Sep 17 00:00:00 2001 From: Anthonios Partheniou Date: Sat, 22 Jan 2022 10:48:15 +0000 Subject: [PATCH 3/5] move mypy check into separate workflow --- .github/workflows/mypy.yml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 .github/workflows/mypy.yml diff --git a/.github/workflows/mypy.yml b/.github/workflows/mypy.yml new file mode 100644 index 00000000..f3212da7 --- /dev/null +++ b/.github/workflows/mypy.yml @@ -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 From 38d37ec4ac72983e55e9601c1bda0f45038bb5aa Mon Sep 17 00:00:00 2001 From: Anthonios Partheniou Date: Sat, 22 Jan 2022 10:49:47 +0000 Subject: [PATCH 4/5] update .sync-repo-settings to reflect changes to gh checks --- .github/sync-repo-settings.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/sync-repo-settings.yaml b/.github/sync-repo-settings.yaml index db2ddd08..49c96ed4 100644 --- a/.github/sync-repo-settings.yaml +++ b/.github/sync-repo-settings.yaml @@ -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' @@ -24,6 +25,7 @@ branchProtectionRules: - 'unit_wo_grpc-3.10' - 'cover' - 'docs' + - 'docfx' permissionRules: - team: actools-python permission: admin From 5c4a02f63b7584bb8316932ebf4a1cade82dbc40 Mon Sep 17 00:00:00 2001 From: Anthonios Partheniou Date: Sat, 22 Jan 2022 10:54:51 +0000 Subject: [PATCH 5/5] use python 3.7 for lint check --- .github/workflows/lint.yml | 2 +- owlbot.py | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 1e8b05c3..79ef73c2 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -12,7 +12,7 @@ jobs: - name: Setup Python uses: actions/setup-python@v2 with: - python-version: "3.10" + python-version: "3.7" - name: Install nox run: | python -m pip install --upgrade setuptools pip wheel diff --git a/owlbot.py b/owlbot.py index 01f84995..0b7f7d21 100644 --- a/owlbot.py +++ b/owlbot.py @@ -45,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)