Skip to content

Commit

Permalink
Add python code checks and tests to the general CI action
Browse files Browse the repository at this point in the history
  • Loading branch information
iburakov committed Sep 23, 2023
1 parent bceb842 commit 50ab618
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,22 @@ jobs:
- name: Run weeder
run: weeder

- uses: abatilo/actions-poetry@v2
with:
poetry-version: 1.6.1
- uses: actions/setup-python@v4
with:
python-version: 3.11
cache: poetry
- name: Install Python dependencies
working-directory: ./ml/synthesis
run: poetry install --no-root
- name: Run Python tests
working-directory: ./ml/synthesis
run: |
export PYTHONPATH=$(pwd)/src:$PYTHONPATH
poetry run pytest
- name: Copy doc to GH_PAGES_DIR
run: |
mkdir -p "${{ env.GH_PAGES_DIR }}/haddock/"
Expand Down Expand Up @@ -197,3 +213,47 @@ jobs:
with:
files: .
config_file: .markdownlint.yaml

python-checks:
timeout-minutes: 5
runs-on: ubuntu-22.04
name: python-${{ matrix.tool }}
strategy:
fail-fast: false
matrix:
include:
- tool: black
run_cmd: black --check --diff src
- tool: ruff
run_cmd: ruff check --diff src
- tool: mypy
# for mypy we need to install all deps for type hints, type stubs and mypy plugins
setup_cmd: |
poetry install --no-root
- tool: vulture

steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: 3.11
- uses: abatilo/actions-poetry@v2
with:
poetry-version: 1.6.1
- name: Install ${{ matrix.tool }} with a version from poetry.lock
working-directory: ./ml/synthesis
# use system python, we're in an action container
run: |
poetry config virtualenvs.create false
poetry export --only=dev --without-hashes \
| grep ${{ matrix.tool }} \
| pip install -r /dev/stdin
- name: Run a ${{ matrix.tool }}-specific setup command
if: ${{ matrix.setup_cmd }}
working-directory: ./ml/synthesis
run: ${{ matrix.setup_cmd }}
- name: Check Python code with ${{ matrix.tool }}
working-directory: ./ml/synthesis
# run provided run_cmd or just call tool by name with no arguments
run: |
${{ matrix.run_cmd && matrix.run_cmd || matrix.tool }}

0 comments on commit 50ab618

Please sign in to comment.