| name: Validator Unit Tests |
| |
| on: |
| push: |
| pull_request: |
| branches: |
| - main |
| workflow_dispatch: |
| |
| env: |
| PYTHON_VERSION: '3.11' # the python version for running the analyze job with |
| POETRY_VERSION: '2.1.1' |
| |
| jobs: |
| # Build and run tests with a range of python versions. |
| build: |
| runs-on: ubuntu-latest |
| strategy: |
| max-parallel: 4 |
| matrix: |
| python-version: ["3.10", "3.11", "3.12", "3.13"] |
| steps: |
| - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| with: |
| fetch-depth: 0 # need all versions to be able to access server tree commit logs |
| persist-credentials: false |
| - name: Set up Python ${{ matrix.python-version }} |
| uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5.4.0 |
| with: |
| python-version: ${{ matrix.python-version }} |
| - name: Install dependencies |
| run: | |
| sudo apt -y install python3-dev |
| python3 -m pip install --upgrade poetry |
| poetry install |
| - name: Test with pytest |
| run: | |
| poetry run pytest |
| |
| # Run mypy and ruff checks. |
| analyze: |
| runs-on: ubuntu-latest |
| steps: |
| - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| with: |
| persist-credentials: false |
| - uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5.4.0 |
| with: |
| python-version: ${{ env.PYTHON_VERSION }} |
| - uses: snok/install-poetry@76e04a911780d5b312d89783f7b1cd627778900a # v1.4.1 |
| with: |
| virtualenvs-in-project: true |
| version: ${{ env.POETRY_VERSION }} |
| |
| # Cache packages per python version, and reuse until lockfile changes |
| - name: Cache python packages |
| id: cache |
| uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0 |
| with: |
| path: .venv |
| key: venv-${{ env.PYTHON_VERSION }}-${{ hashFiles('poetry.lock') }} |
| - name: Install dependencies |
| #if: steps.cache.outputs.cache-hit != 'true' |
| run: poetry sync -v --with=dev |
| |
| - name: Cache pre-commit data |
| uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0 |
| with: |
| path: ~/.cache/pre-commit |
| key: pre-commit-3|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }} |
| |
| - name: Run pre-commit |
| run: | |
| poetry run pre-commit run --show-diff-on-failure --color=always --all-files |