|
| 1 | +name: Checks |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + - "maintenance/**" |
| 8 | + pull_request: |
| 9 | + branches: |
| 10 | + - main |
| 11 | + - "maintenance/**" |
| 12 | + |
| 13 | +env: |
| 14 | + CACHE_VERSION: 1 |
| 15 | + KEY_PREFIX: base-venv |
| 16 | + DEFAULT_PYTHON: "3.11" |
| 17 | + PRE_COMMIT_CACHE: ~/.cache/pre-commit |
| 18 | + |
| 19 | +concurrency: |
| 20 | + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} |
| 21 | + cancel-in-progress: true |
| 22 | + |
| 23 | +permissions: |
| 24 | + contents: read |
| 25 | + |
| 26 | +jobs: |
| 27 | + prepare-base: |
| 28 | + name: Prepare base dependencies |
| 29 | + runs-on: ubuntu-latest |
| 30 | + timeout-minutes: 10 |
| 31 | + outputs: |
| 32 | + python-key: ${{ steps.generate-python-key.outputs.key }} |
| 33 | + pre-commit-key: ${{ steps.generate-pre-commit-key.outputs.key }} |
| 34 | + steps: |
| 35 | + - name: Check out code from GitHub |
| 36 | + uses: actions/checkout@v3.5.2 |
| 37 | + - name: Set up Python ${{ env.DEFAULT_PYTHON }} |
| 38 | + id: python |
| 39 | + uses: actions/setup-python@v4.6.0 |
| 40 | + with: |
| 41 | + python-version: ${{ env.DEFAULT_PYTHON }} |
| 42 | + check-latest: true |
| 43 | + - name: Generate partial Python venv restore key |
| 44 | + id: generate-python-key |
| 45 | + run: >- |
| 46 | + echo "key=${{ env.KEY_PREFIX }}-${{ env.CACHE_VERSION }}-${{ |
| 47 | + hashFiles('pyproject.toml', 'requirements_test.txt', |
| 48 | + 'requirements_test_min.txt', 'requirements_test_pre_commit.txt') }}" >> |
| 49 | + $GITHUB_OUTPUT |
| 50 | + - name: Restore Python virtual environment |
| 51 | + id: cache-venv |
| 52 | + uses: actions/cache@v3.3.1 |
| 53 | + with: |
| 54 | + path: venv |
| 55 | + key: >- |
| 56 | + ${{ runner.os }}-${{ steps.python.outputs.python-version }}-${{ |
| 57 | + steps.generate-python-key.outputs.key }} |
| 58 | + - name: Create Python virtual environment |
| 59 | + if: steps.cache-venv.outputs.cache-hit != 'true' |
| 60 | + run: | |
| 61 | + python -m venv venv |
| 62 | + . venv/bin/activate |
| 63 | + python -m pip install -U pip setuptools wheel |
| 64 | + pip install -U -r requirements_test.txt |
| 65 | + pip install -U -r doc/requirements.txt |
| 66 | + - name: Generate pre-commit restore key |
| 67 | + id: generate-pre-commit-key |
| 68 | + run: >- |
| 69 | + echo "key=pre-commit-${{ env.CACHE_VERSION }}-${{ |
| 70 | + hashFiles('.pre-commit-config.yaml') }}" >> $GITHUB_OUTPUT |
| 71 | + - name: Restore pre-commit environment |
| 72 | + id: cache-precommit |
| 73 | + uses: actions/cache@v3.3.1 |
| 74 | + with: |
| 75 | + path: ${{ env.PRE_COMMIT_CACHE }} |
| 76 | + key: >- |
| 77 | + ${{ runner.os }}-${{ steps.generate-pre-commit-key.outputs.key }} |
| 78 | + - name: Install pre-commit dependencies |
| 79 | + if: steps.cache-precommit.outputs.cache-hit != 'true' |
| 80 | + run: | |
| 81 | + . venv/bin/activate |
| 82 | + pre-commit install --install-hooks |
| 83 | +
|
| 84 | + pylint: |
| 85 | + name: pylint |
| 86 | + runs-on: ubuntu-latest |
| 87 | + timeout-minutes: 10 |
| 88 | + needs: prepare-base |
| 89 | + steps: |
| 90 | + - name: Check out code from GitHub |
| 91 | + uses: actions/checkout@v3.5.2 |
| 92 | + - name: Set up Python ${{ env.DEFAULT_PYTHON }} |
| 93 | + id: python |
| 94 | + uses: actions/setup-python@v4.6.0 |
| 95 | + with: |
| 96 | + python-version: ${{ env.DEFAULT_PYTHON }} |
| 97 | + check-latest: true |
| 98 | + - name: Restore Python virtual environment |
| 99 | + id: cache-venv |
| 100 | + uses: actions/cache@v3.3.1 |
| 101 | + with: |
| 102 | + path: venv |
| 103 | + fail-on-cache-miss: true |
| 104 | + key: |
| 105 | + ${{ runner.os }}-${{ steps.python.outputs.python-version }}-${{ |
| 106 | + needs.prepare-base.outputs.python-key }} |
| 107 | + - name: Restore pre-commit environment |
| 108 | + id: cache-precommit |
| 109 | + uses: actions/cache@v3.3.1 |
| 110 | + with: |
| 111 | + path: ${{ env.PRE_COMMIT_CACHE }} |
| 112 | + fail-on-cache-miss: true |
| 113 | + key: ${{ runner.os }}-${{ needs.prepare-base.outputs.pre-commit-key }} |
| 114 | + - name: Install enchant and aspell |
| 115 | + run: | |
| 116 | + sudo apt-get update |
| 117 | + sudo apt-get install enchant-2 aspell-en |
| 118 | + - name: Run pylint checks |
| 119 | + run: | |
| 120 | + . venv/bin/activate |
| 121 | + pip install -e . |
| 122 | + pip list | grep 'astroid\|pylint' |
| 123 | + pre-commit run --hook-stage manual pylint-with-spelling --all-files |
| 124 | +
|
| 125 | + spelling: |
| 126 | + name: spelling tests |
| 127 | + runs-on: ubuntu-latest |
| 128 | + timeout-minutes: 5 |
| 129 | + needs: prepare-base |
| 130 | + steps: |
| 131 | + - name: Check out code from GitHub |
| 132 | + uses: actions/checkout@v3.5.2 |
| 133 | + - name: Set up Python ${{ env.DEFAULT_PYTHON }} |
| 134 | + id: python |
| 135 | + uses: actions/setup-python@v4.6.0 |
| 136 | + with: |
| 137 | + python-version: ${{ env.DEFAULT_PYTHON }} |
| 138 | + check-latest: true |
| 139 | + - name: Restore Python virtual environment |
| 140 | + id: cache-venv |
| 141 | + uses: actions/cache@v3.3.1 |
| 142 | + with: |
| 143 | + path: venv |
| 144 | + fail-on-cache-miss: true |
| 145 | + key: |
| 146 | + ${{ runner.os }}-${{ steps.python.outputs.python-version }}-${{ |
| 147 | + needs.prepare-base.outputs.python-key }} |
| 148 | + - name: Run spelling checks |
| 149 | + run: | |
| 150 | + . venv/bin/activate |
| 151 | + pytest tests/ -k unittest_spelling |
| 152 | +
|
| 153 | + documentation: |
| 154 | + name: documentation |
| 155 | + runs-on: ubuntu-latest |
| 156 | + timeout-minutes: 20 |
| 157 | + needs: prepare-base |
| 158 | + steps: |
| 159 | + - name: Check out code from GitHub |
| 160 | + uses: actions/checkout@v3.5.2 |
| 161 | + - name: Set up Python ${{ env.DEFAULT_PYTHON }} |
| 162 | + id: python |
| 163 | + uses: actions/setup-python@v4.6.0 |
| 164 | + with: |
| 165 | + python-version: ${{ env.DEFAULT_PYTHON }} |
| 166 | + check-latest: true |
| 167 | + - name: Restore Python virtual environment |
| 168 | + id: cache-venv |
| 169 | + uses: actions/cache@v3.3.1 |
| 170 | + with: |
| 171 | + path: venv |
| 172 | + fail-on-cache-miss: true |
| 173 | + key: |
| 174 | + ${{ runner.os }}-${{ steps.python.outputs.python-version }}-${{ |
| 175 | + needs.prepare-base.outputs.python-key }} |
| 176 | + - name: Install tox |
| 177 | + run: | |
| 178 | + pip install -U tox |
| 179 | + - name: Run checks on documentation code examples |
| 180 | + run: | |
| 181 | + tox -e test_doc |
| 182 | + - name: Check documentation build and links |
| 183 | + run: | |
| 184 | + . venv/bin/activate |
| 185 | + cd doc |
| 186 | + make html |
0 commit comments