From 07cb1a7453087c1212771d997729499682b3a8cc Mon Sep 17 00:00:00 2001 From: Ioannis Filippidis Date: Wed, 17 Aug 2022 17:29:03 +0200 Subject: [PATCH] CI: add task `typecheck` that runs `pytype` --- .github/workflows/main.yml | 38 ++++++++++++++++++++++++ .github/workflows/setup_typecheck_env.sh | 25 ++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100755 .github/workflows/setup_typecheck_env.sh diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c7265288..098c135c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -55,3 +55,41 @@ jobs: pushd examples/ python _test_examples.py popd + typecheck: + name: Static analysis of Python code + runs-on: ubuntu-22.04 + strategy: + matrix: + python-version: [ + '3.10', + ] + steps: + - uses: actions/checkout@v3 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + - name: Prepare typechecking environment + run: | + ./.github/workflows/setup_typecheck_env.sh + - name: Statically analyze `dd` + run: | + pytype -k \ + dd/*.py \ + -x dd/__init__.py + - name: Statically analyze setup files + run: | + pip install -U \ + cython \ + gitpython + pytype -k \ + setup.py \ + install.py \ + # download.py + - name: Statically analyze `examples/` + run: | + pip uninstall -y dd + python install.py --yes \ + --ignore-requires-python + pytype -k \ + examples/*.py diff --git a/.github/workflows/setup_typecheck_env.sh b/.github/workflows/setup_typecheck_env.sh new file mode 100755 index 00000000..2586e02e --- /dev/null +++ b/.github/workflows/setup_typecheck_env.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env bash + + +# Prepare for typechecking. + + +set -x +set -e +# upgrade build dependencies +pip install \ + --ignore-installed \ + --upgrade \ + pip \ + setuptools \ + wheel +# install `dd` dependencies +python setup.py sdist +pip install \ + --ignore-requires-python \ + dist/dd-*.tar.gz +pip uninstall --yes dd +# install typechecking tools +pip install \ + --upgrade \ + pytype