|
| 1 | +name: Checks |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - master |
| 7 | + pull_request: |
| 8 | + branches: |
| 9 | + - master |
| 10 | + |
| 11 | +env: |
| 12 | + CACHE_VERSION: 1 |
| 13 | + KEY_PREFIX: base-venv |
| 14 | + DEFAULT_PYTHON: "3.11" |
| 15 | + PRE_COMMIT_CACHE: ~/.cache/pre-commit |
| 16 | + |
| 17 | +concurrency: |
| 18 | + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} |
| 19 | + cancel-in-progress: true |
| 20 | + |
| 21 | +permissions: |
| 22 | + contents: read |
| 23 | + |
| 24 | +jobs: |
| 25 | + prepare-base: |
| 26 | + name: Prepare base dependencies |
| 27 | + runs-on: ubuntu-latest |
| 28 | + timeout-minutes: 10 |
| 29 | + outputs: |
| 30 | + python-key: ${{ steps.generate-python-key.outputs.key }} |
| 31 | + pre-commit-key: ${{ steps.generate-pre-commit-key.outputs.key }} |
| 32 | + steps: |
| 33 | + - name: Check out code from GitHub |
| 34 | + |
| 35 | + - name: Set up Python ${{ env.DEFAULT_PYTHON }} |
| 36 | + id: python |
| 37 | + |
| 38 | + with: |
| 39 | + python-version: ${{ env.DEFAULT_PYTHON }} |
| 40 | + check-latest: true |
| 41 | + - name: Generate partial Python venv restore key |
| 42 | + id: generate-python-key |
| 43 | + run: >- |
| 44 | + echo "key=${{ env.KEY_PREFIX }}-${{ env.CACHE_VERSION }}-${{ |
| 45 | + hashFiles('pyproject.toml', 'requirements_test.txt', |
| 46 | + 'requirements_test_min.txt', 'requirements_test_pre_commit.txt') }}" >> |
| 47 | + $GITHUB_OUTPUT |
| 48 | + - name: Restore Python virtual environment |
| 49 | + id: cache-venv |
| 50 | + |
| 51 | + with: |
| 52 | + path: venv |
| 53 | + key: >- |
| 54 | + ${{ runner.os }}-${{ steps.python.outputs.python-version }}-${{ |
| 55 | + steps.generate-python-key.outputs.key }} |
| 56 | + - name: Create Python virtual environment |
| 57 | + if: steps.cache-venv.outputs.cache-hit != 'true' |
| 58 | + run: | |
| 59 | + python -m venv venv |
| 60 | + . venv/bin/activate |
| 61 | + python -m pip install -U pip setuptools wheel |
| 62 | + pip install . |
| 63 | + pip install pre-commit |
| 64 | + - name: Generate pre-commit restore key |
| 65 | + id: generate-pre-commit-key |
| 66 | + run: >- |
| 67 | + echo "key=pre-commit-${{ env.CACHE_VERSION }}-${{ |
| 68 | + hashFiles('.pre-commit-config.yaml') }}" >> $GITHUB_OUTPUT |
| 69 | + - name: Restore pre-commit environment |
| 70 | + id: cache-precommit |
| 71 | + |
| 72 | + with: |
| 73 | + path: ${{ env.PRE_COMMIT_CACHE }} |
| 74 | + key: >- |
| 75 | + ${{ runner.os }}-${{ steps.generate-pre-commit-key.outputs.key }} |
| 76 | + - name: Install pre-commit dependencies |
| 77 | + if: steps.cache-precommit.outputs.cache-hit != 'true' |
| 78 | + run: | |
| 79 | + . venv/bin/activate |
| 80 | + pre-commit install --install-hooks |
| 81 | +
|
| 82 | + pylint: |
| 83 | + name: pylint |
| 84 | + runs-on: ubuntu-latest |
| 85 | + timeout-minutes: 10 |
| 86 | + needs: prepare-base |
| 87 | + steps: |
| 88 | + - name: Check out code from GitHub |
| 89 | + |
| 90 | + - name: Set up Python ${{ env.DEFAULT_PYTHON }} |
| 91 | + id: python |
| 92 | + |
| 93 | + with: |
| 94 | + python-version: ${{ env.DEFAULT_PYTHON }} |
| 95 | + check-latest: true |
| 96 | + - name: Restore Python virtual environment |
| 97 | + id: cache-venv |
| 98 | + |
| 99 | + with: |
| 100 | + path: venv |
| 101 | + fail-on-cache-miss: true |
| 102 | + key: |
| 103 | + ${{ runner.os }}-${{ steps.python.outputs.python-version }}-${{ |
| 104 | + needs.prepare-base.outputs.python-key }} |
| 105 | + - name: Restore pre-commit environment |
| 106 | + id: cache-precommit |
| 107 | + |
| 108 | + with: |
| 109 | + path: ${{ env.PRE_COMMIT_CACHE }} |
| 110 | + fail-on-cache-miss: true |
| 111 | + key: ${{ runner.os }}-${{ needs.prepare-base.outputs.pre-commit-key }} |
| 112 | + - name: Run pylint checks |
| 113 | + run: | |
| 114 | + . venv/bin/activate |
| 115 | + pip install . |
| 116 | + pre-commit run pylint --all-files |
0 commit comments