| name: Checks |
| |
| on: |
| push: |
| branches: |
| - main |
| - 2.* |
| pull_request: ~ |
| |
| env: |
| CACHE_VERSION: 27 |
| DEFAULT_PYTHON: "3.10" |
| PRE_COMMIT_CACHE: ~/.cache/pre-commit |
| |
| concurrency: |
| group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} |
| cancel-in-progress: true |
| |
| jobs: |
| prepare-base: |
| name: Prepare base dependencies |
| runs-on: ubuntu-latest |
| timeout-minutes: 10 |
| outputs: |
| python-key: ${{ steps.generate-python-key.outputs.key }} |
| pre-commit-key: ${{ steps.generate-pre-commit-key.outputs.key }} |
| steps: |
| - name: Check out code from GitHub |
| uses: actions/checkout@v3.0.2 |
| - name: Set up Python ${{ env.DEFAULT_PYTHON }} |
| id: python |
| uses: actions/setup-python@v4.2.0 |
| with: |
| python-version: ${{ env.DEFAULT_PYTHON }} |
| - name: Generate partial Python venv restore key |
| id: generate-python-key |
| run: >- |
| echo "::set-output name=key::base-venv-${{ env.CACHE_VERSION }}-${{ |
| hashFiles('setup.cfg', 'requirements_test.txt', 'requirements_test_min.txt') |
| }}" |
| - name: Restore Python virtual environment |
| id: cache-venv |
| uses: actions/cache@v3.0.8 |
| with: |
| path: venv |
| key: >- |
| ${{ runner.os }}-${{ steps.python.outputs.python-version }}-${{ |
| steps.generate-python-key.outputs.key }} |
| restore-keys: | |
| ${{ runner.os }}-${{ steps.python.outputs.python-version }}-base-venv-${{ env.CACHE_VERSION }}- |
| - name: Create Python virtual environment |
| if: steps.cache-venv.outputs.cache-hit != 'true' |
| run: | |
| python -m venv venv |
| . venv/bin/activate |
| python -m pip install -U pip setuptools wheel |
| pip install -U -r requirements_test.txt |
| pip install -U -r doc/requirements.txt |
| - name: Generate pre-commit restore key |
| id: generate-pre-commit-key |
| run: >- |
| echo "::set-output name=key::pre-commit-${{ env.CACHE_VERSION }}-${{ |
| hashFiles('.pre-commit-config.yaml') }}" |
| - name: Restore pre-commit environment |
| id: cache-precommit |
| uses: actions/cache@v3.0.8 |
| with: |
| path: ${{ env.PRE_COMMIT_CACHE }} |
| key: >- |
| ${{ runner.os }}-${{ steps.generate-pre-commit-key.outputs.key }} |
| restore-keys: | |
| ${{ runner.os }}-pre-commit-${{ env.CACHE_VERSION }}- |
| - name: Install pre-commit dependencies |
| if: steps.cache-precommit.outputs.cache-hit != 'true' |
| run: | |
| . venv/bin/activate |
| pre-commit install --install-hooks |
| |
| pylint: |
| name: pylint |
| runs-on: ubuntu-latest |
| timeout-minutes: 10 |
| needs: prepare-base |
| steps: |
| - name: Check out code from GitHub |
| uses: actions/checkout@v3.0.2 |
| - name: Set up Python ${{ env.DEFAULT_PYTHON }} |
| id: python |
| uses: actions/setup-python@v4.2.0 |
| with: |
| python-version: ${{ env.DEFAULT_PYTHON }} |
| - name: Restore Python virtual environment |
| id: cache-venv |
| uses: actions/cache@v3.0.8 |
| with: |
| path: venv |
| key: |
| ${{ runner.os }}-${{ steps.python.outputs.python-version }}-${{ |
| needs.prepare-base.outputs.python-key }} |
| - name: Fail job if Python cache restore failed |
| if: steps.cache-venv.outputs.cache-hit != 'true' |
| run: | |
| echo "Failed to restore Python venv from cache" |
| exit 1 |
| - name: Restore pre-commit environment |
| id: cache-precommit |
| uses: actions/cache@v3.0.8 |
| with: |
| path: ${{ env.PRE_COMMIT_CACHE }} |
| key: ${{ runner.os }}-${{ needs.prepare-base.outputs.pre-commit-key }} |
| - name: Fail job if pre-commit cache restore failed |
| if: steps.cache-precommit.outputs.cache-hit != 'true' |
| run: | |
| echo "Failed to restore pre-commit environment from cache" |
| exit 1 |
| - name: Install enchant and aspell |
| run: | |
| sudo apt-get update |
| sudo apt-get install enchant aspell-en |
| - name: Run pylint checks |
| run: | |
| . venv/bin/activate |
| pip install -e . |
| pre-commit run --hook-stage manual pylint-with-spelling --all-files |
| |
| spelling: |
| name: spelling tests |
| runs-on: ubuntu-latest |
| timeout-minutes: 5 |
| needs: prepare-base |
| steps: |
| - name: Check out code from GitHub |
| uses: actions/checkout@v3.0.2 |
| - name: Set up Python ${{ env.DEFAULT_PYTHON }} |
| id: python |
| uses: actions/setup-python@v4.2.0 |
| with: |
| python-version: ${{ env.DEFAULT_PYTHON }} |
| - name: Restore Python virtual environment |
| id: cache-venv |
| uses: actions/cache@v3.0.8 |
| with: |
| path: venv |
| key: |
| ${{ runner.os }}-${{ steps.python.outputs.python-version }}-${{ |
| needs.prepare-base.outputs.python-key }} |
| - name: Fail job if Python cache restore failed |
| if: steps.cache-venv.outputs.cache-hit != 'true' |
| run: | |
| echo "Failed to restore Python venv from cache" |
| exit 1 |
| - name: Run spelling checks |
| run: | |
| . venv/bin/activate |
| pytest tests/ -k unittest_spelling |
| |
| documentation: |
| name: documentation |
| runs-on: ubuntu-latest |
| timeout-minutes: 10 |
| needs: prepare-base |
| steps: |
| - name: Check out code from GitHub |
| uses: actions/checkout@v3.0.2 |
| - name: Set up Python ${{ env.DEFAULT_PYTHON }} |
| id: python |
| uses: actions/setup-python@v4.2.0 |
| with: |
| python-version: ${{ env.DEFAULT_PYTHON }} |
| - name: Restore Python virtual environment |
| id: cache-venv |
| uses: actions/cache@v3.0.8 |
| with: |
| path: venv |
| key: |
| ${{ runner.os }}-${{ steps.python.outputs.python-version }}-${{ |
| needs.prepare-base.outputs.python-key }} |
| - name: Fail job if Python cache restore failed |
| if: steps.cache-venv.outputs.cache-hit != 'true' |
| run: | |
| echo "Failed to restore Python venv from cache" |
| exit 1 |
| - name: Install tox |
| run: | |
| pip install -U tox |
| - name: Run checks on documentation code examples |
| run: | |
| tox -e test_doc |
| - name: Check documentation build and links |
| run: | |
| . venv/bin/activate |
| cd doc |
| make html |