diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index b8f1828223..e7e5c8f899 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -342,6 +342,15 @@ jobs: echo "The old one will disappear after 7 days." - name: Integration Tests run: bazel test tests/integration:asset tests/integration:credentials tests/integration:logging tests/integration:redis + - name: Set up Python 3.9 + uses: actions/setup-python@v2 + with: + python-version: 3.9 + - name: Install nox. + run: | + python -m pip install nox + - name: Typecheck the generated output. + run: nox -s goldens_mypy style-check: runs-on: ubuntu-latest steps: diff --git a/noxfile.py b/noxfile.py index a656b2943d..e3538730a3 100644 --- a/noxfile.py +++ b/noxfile.py @@ -294,7 +294,6 @@ def run_showcase_unit_tests(session, fail_under=100): *(session.posargs or [path.join("tests", "unit")]), ) - @nox.session(python=ALL_PYTHON) def showcase_unit( session, templates="DEFAULT", other_opts: typing.Iterable[str] = (), @@ -370,6 +369,22 @@ def showcase_mypy_alternative_templates(session): showcase_mypy(session, templates=ADS_TEMPLATES, other_opts=("old-naming",)) +@nox.session(python=NEWEST_PYTHON) +def goldens_mypy(session): + """Perform typecheck analysis on the golden generated libraries + + This may catch additional issues that are not found in the showcase protos.""" + + session.install("mypy", "types-pkg-resources") + goldens_dir = Path("tests/integration/goldens").absolute() + + for library_dir in goldens_dir.glob("*/"): + session.chdir(library_dir.absolute()) + session.install(".") + + session.run("mypy", "--explicit-package-bases", "google") + + @nox.session(python=NEWEST_PYTHON) def snippetgen(session): # Clone googleapis/api-common-protos which are referenced by the snippet