|
9 | 9 | pull_request:
|
10 | 10 | workflow_dispatch:
|
11 | 11 |
|
| 12 | +env: |
| 13 | + DEFAULT_PYTHON: "3.10" |
| 14 | + |
12 | 15 | jobs:
|
13 |
| - precommit: |
14 |
| - name: ${{ matrix.name }} |
| 16 | + codespell: |
| 17 | + name: codespell |
15 | 18 | runs-on: ubuntu-latest
|
16 |
| - strategy: |
17 |
| - matrix: |
18 |
| - include: |
19 |
| - - id: bandit |
20 |
| - name: Check with bandit |
21 |
| - - id: black |
22 |
| - name: Check code style |
23 |
| - - id: blacken-docs |
24 |
| - name: Check code style in documentation |
25 |
| - - id: check-ast |
26 |
| - name: Check Python AST |
27 |
| - - id: check-case-conflict |
28 |
| - name: Check for case conflicts |
29 |
| - - id: check-docstring-first |
30 |
| - name: Check docstring is first |
31 |
| - - id: check-executables-have-shebangs |
32 |
| - name: Check that executables have shebangs |
33 |
| - - id: check-json |
34 |
| - name: Check JSON files |
35 |
| - - id: check-merge-conflict |
36 |
| - name: Check for merge conflicts |
37 |
| - - id: check-symlinks |
38 |
| - name: Check for broken symlinks |
39 |
| - - id: check-toml |
40 |
| - name: Check TOML files |
41 |
| - - id: check-yaml |
42 |
| - name: Check YAML files |
43 |
| - - id: codespell |
44 |
| - name: Check code for common misspellings |
45 |
| - - id: debug-statements |
46 |
| - name: Debug Statements and imports (Python) |
47 |
| - - id: detect-private-key |
48 |
| - name: Detect Private Keys |
49 |
| - - id: end-of-file-fixer |
50 |
| - name: Check End of Files |
51 |
| - - id: fix-byte-order-marker |
52 |
| - name: Check UTF-8 byte order marker |
53 |
| - - id: flake8 |
54 |
| - name: Enforcing style guide with flake8 |
55 |
| - - id: isort |
56 |
| - name: Check imports are sorted |
57 |
| - - id: poetry |
58 |
| - name: Check pyproject file |
59 |
| - - id: prettier |
60 |
| - name: Check if code is prettier |
61 |
| - - id: pylint |
62 |
| - name: Check with pylint |
63 |
| - - id: pyupgrade |
64 |
| - name: Check for upgradable syntax |
65 |
| - - id: trailing-whitespace |
66 |
| - name: Trim Trailing Whitespace |
67 |
| - - id: vulture |
68 |
| - name: Check for unused Python code |
69 |
| - - id: yamllint |
70 |
| - name: Check YAML style |
71 | 19 | steps:
|
72 | 20 | - name: Check out code from GitHub
|
73 |
| - uses: actions/checkout@v3 |
74 |
| - - name: Set up Python 3.9 |
| 21 | + |
| 22 | + - name: Set up Poetry |
| 23 | + run: pipx install poetry |
| 24 | + - name: Set up Python ${{ env.DEFAULT_PYTHON }} |
75 | 25 | id: python
|
76 |
| - uses: actions/setup-python@v4 |
| 26 | + uses: actions/setup-python@v4.6.1 |
77 | 27 | with:
|
78 |
| - python-version: 3.9 |
79 |
| - - name: Read .nvmrc |
80 |
| - if: ${{ matrix.id == 'prettier' }} |
81 |
| - id: nvm |
82 |
| - run: echo "##[set-output name=nvmrc;]$(cat .nvmrc)" |
83 |
| - - name: Set up Node.js ${{ steps.nvm.outputs.nvmrc }} |
84 |
| - if: ${{ matrix.id == 'prettier' }} |
85 |
| - uses: actions/setup-node@v3 |
| 28 | + python-version: ${{ env.DEFAULT_PYTHON }} |
| 29 | + cache: "poetry" |
| 30 | + - name: Install workflow dependencies |
| 31 | + run: | |
| 32 | + poetry config virtualenvs.create true |
| 33 | + poetry config virtualenvs.in-project true |
| 34 | + - name: Install Python dependencies |
| 35 | + run: poetry install --no-interaction |
| 36 | + - name: Check code for common misspellings |
| 37 | + run: poetry run pre-commit run codespell --all-files |
| 38 | + |
| 39 | + ruff: |
| 40 | + name: Ruff |
| 41 | + runs-on: ubuntu-latest |
| 42 | + steps: |
| 43 | + - name: Check out code from GitHub |
| 44 | + |
| 45 | + - name: Set up Poetry |
| 46 | + run: pipx install poetry |
| 47 | + - name: Set up Python ${{ env.DEFAULT_PYTHON }} |
| 48 | + id: python |
| 49 | + |
| 50 | + with: |
| 51 | + python-version: ${{ env.DEFAULT_PYTHON }} |
| 52 | + cache: "poetry" |
| 53 | + - name: Install workflow dependencies |
| 54 | + run: | |
| 55 | + poetry config virtualenvs.create true |
| 56 | + poetry config virtualenvs.in-project true |
| 57 | + - name: Install Python dependencies |
| 58 | + run: poetry install --no-interaction |
| 59 | + - name: Run Ruff |
| 60 | + run: poetry run ruff . |
| 61 | + |
| 62 | + black: |
| 63 | + name: black |
| 64 | + runs-on: ubuntu-latest |
| 65 | + steps: |
| 66 | + - name: Check out code from GitHub |
| 67 | + |
| 68 | + - name: Set up Poetry |
| 69 | + run: pipx install poetry |
| 70 | + - name: Set up Python ${{ env.DEFAULT_PYTHON }} |
| 71 | + id: python |
| 72 | + |
| 73 | + with: |
| 74 | + python-version: ${{ env.DEFAULT_PYTHON }} |
| 75 | + cache: "poetry" |
| 76 | + - name: Install workflow dependencies |
| 77 | + run: | |
| 78 | + poetry config virtualenvs.create true |
| 79 | + poetry config virtualenvs.in-project true |
| 80 | + - name: Install Python dependencies |
| 81 | + run: poetry install --no-interaction |
| 82 | + - name: Run black on docs |
| 83 | + run: poetry run blacken-docs |
| 84 | + |
| 85 | + pre-commit-hooks: |
| 86 | + name: pre-commit-hooks |
| 87 | + runs-on: ubuntu-latest |
| 88 | + steps: |
| 89 | + - name: Check out code from GitHub |
| 90 | + |
| 91 | + - name: Set up Poetry |
| 92 | + run: pipx install poetry |
| 93 | + - name: Set up Python ${{ env.DEFAULT_PYTHON }} |
| 94 | + id: python |
| 95 | + |
86 | 96 | with:
|
87 |
| - node-version: "${{ steps.nvm.outputs.nvmrc }}" |
88 |
| - - name: Get pip cache dir |
89 |
| - id: pip-cache |
| 97 | + python-version: ${{ env.DEFAULT_PYTHON }} |
| 98 | + cache: "poetry" |
| 99 | + - name: Install workflow dependencies |
90 | 100 | run: |
|
91 |
| - echo "::set-output name=dir::$(pip cache dir)" |
92 |
| - - name: Restore cached Python PIP packages |
93 |
| - uses: actions/cache@v3 |
| 101 | + poetry config virtualenvs.create true |
| 102 | + poetry config virtualenvs.in-project true |
| 103 | + - name: Install Python dependencies |
| 104 | + run: poetry install --no-interaction |
| 105 | + - name: Check Python AST |
| 106 | + run: poetry run pre-commit run check-ast --all-files |
| 107 | + - name: Check for case conflicts |
| 108 | + run: poetry run pre-commit run check-case-conflict --all-files |
| 109 | + - name: Check docstring is first |
| 110 | + run: poetry run pre-commit run check-docstring-first --all-files |
| 111 | + - name: Check that executables have shebangs |
| 112 | + run: poetry run pre-commit run check-executables-have-shebangs --all-files |
| 113 | + - name: Check JSON files |
| 114 | + run: poetry run pre-commit run check-json --all-files |
| 115 | + - name: Check for merge conflicts |
| 116 | + run: poetry run pre-commit run check-merge-conflict --all-files |
| 117 | + - name: Check for broken symlinks |
| 118 | + run: poetry run pre-commit run check-symlinks --all-files |
| 119 | + - name: Check TOML files |
| 120 | + run: poetry run pre-commit run check-toml --all-files |
| 121 | + - name: Check XML files |
| 122 | + run: poetry run pre-commit run check-xml --all-files |
| 123 | + - name: Check YAML files |
| 124 | + run: poetry run pre-commit run check-yaml --all-files |
| 125 | + - name: Check YAML files |
| 126 | + run: poetry run pre-commit run check-yaml --all-files |
| 127 | + - name: Detect Private Keys |
| 128 | + run: poetry run pre-commit run detect-private-key --all-files |
| 129 | + - name: Check End of Files |
| 130 | + run: poetry run pre-commit run end-of-file-fixer --all-files |
| 131 | + - name: Trim Trailing Whitespace |
| 132 | + run: poetry run pre-commit run trailing-whitespace --all-files |
| 133 | + |
| 134 | + pylint: |
| 135 | + name: pylint |
| 136 | + runs-on: ubuntu-latest |
| 137 | + steps: |
| 138 | + - name: Check out code from GitHub |
| 139 | + |
| 140 | + - name: Set up Poetry |
| 141 | + run: pipx install poetry |
| 142 | + - name: Set up Python ${{ env.DEFAULT_PYTHON }} |
| 143 | + id: python |
| 144 | + |
94 | 145 | with:
|
95 |
| - path: ${{ steps.pip-cache.outputs.dir }} |
96 |
| - key: pip-${{ runner.os }}-${{ steps.python.outputs.python-version }}-${{ hashFiles('.github/workflows/requirements.txt') }} |
97 |
| - restore-keys: | |
98 |
| - pip-${{ runner.os }}-${{ steps.python.outputs.python-version }}- |
| 146 | + python-version: ${{ env.DEFAULT_PYTHON }} |
| 147 | + cache: "poetry" |
99 | 148 | - name: Install workflow dependencies
|
100 | 149 | run: |
|
101 |
| - pip install -r .github/workflows/requirements.txt |
102 | 150 | poetry config virtualenvs.create true
|
103 | 151 | poetry config virtualenvs.in-project true
|
104 |
| - - name: Restore cached Python virtual environment |
105 |
| - id: cached-poetry-dependencies |
106 |
| - uses: actions/cache@v3 |
| 152 | + - name: Install Python dependencies |
| 153 | + run: poetry install --no-interaction |
| 154 | + - name: Run pylint |
| 155 | + run: poetry run pre-commit run pylint --all-files |
| 156 | + |
| 157 | + yamllint: |
| 158 | + name: yamllint |
| 159 | + runs-on: ubuntu-latest |
| 160 | + steps: |
| 161 | + - name: Check out code from GitHub |
| 162 | + |
| 163 | + - name: Set up Poetry |
| 164 | + run: pipx install poetry |
| 165 | + - name: Set up Python ${{ env.DEFAULT_PYTHON }} |
| 166 | + id: python |
| 167 | + |
107 | 168 | with:
|
108 |
| - path: .venv |
109 |
| - key: >- |
110 |
| - venv-${{ runner.os }}-${{ steps.python.outputs.python-version }}-${{ hashFiles('poetry.lock') }} |
111 |
| - venv-${{ runner.os }}-${{ steps.python.outputs.python-version }}- |
| 169 | + python-version: ${{ env.DEFAULT_PYTHON }} |
| 170 | + cache: "poetry" |
| 171 | + - name: Install workflow dependencies |
| 172 | + run: | |
| 173 | + poetry config virtualenvs.create true |
| 174 | + poetry config virtualenvs.in-project true |
112 | 175 | - name: Install Python dependencies
|
113 | 176 | run: poetry install --no-interaction
|
114 |
| - - name: Get npm cache directory |
115 |
| - if: ${{ matrix.id == 'prettier' }} |
116 |
| - id: npm-cache |
| 177 | + - name: Run yamllint |
| 178 | + run: poetry run yamllint . |
| 179 | + |
| 180 | + prettier: |
| 181 | + name: Prettier |
| 182 | + runs-on: ubuntu-latest |
| 183 | + steps: |
| 184 | + - name: Check out code from GitHub |
| 185 | + |
| 186 | + - name: Set up Poetry |
| 187 | + run: pipx install poetry |
| 188 | + - name: Set up Python ${{ env.DEFAULT_PYTHON }} |
| 189 | + id: python |
| 190 | + |
| 191 | + with: |
| 192 | + python-version: ${{ env.DEFAULT_PYTHON }} |
| 193 | + cache: "poetry" |
| 194 | + - name: Install workflow dependencies |
117 | 195 | run: |
|
118 |
| - echo "::set-output name=dir::$(npm config get cache)" |
119 |
| - - name: Restore cached node modules |
120 |
| - if: ${{ matrix.id == 'prettier' }} |
121 |
| - uses: actions/cache@v3 |
| 196 | + poetry config virtualenvs.create true |
| 197 | + poetry config virtualenvs.in-project true |
| 198 | + - name: Install Python dependencies |
| 199 | + run: poetry install --no-interaction |
| 200 | + - name: Set up Node.js |
| 201 | + uses: actions/setup-node@v3 |
122 | 202 | with:
|
123 |
| - path: ${{ steps.npm-cache.outputs.dir }} |
124 |
| - key: node-${{ runner.os }}-${{ steps.nvm.outputs.nvmrc }}-${{ hashFiles('.github/workflows/requirements.txt') }} |
125 |
| - restore-keys: | |
126 |
| - node-${{ runner.os }}-${{ steps.nvm.outputs.nvmrc }}- |
| 203 | + node-version-file: ".nvmrc" |
| 204 | + cache: "npm" |
127 | 205 | - name: Install NPM dependencies
|
128 |
| - if: ${{ matrix.id == 'prettier' }} |
129 | 206 | run: npm install
|
130 |
| - - name: Run pre-commit for ${{ matrix.id }} |
131 |
| - run: poetry run pre-commit run ${{ matrix.id }} --all-files |
| 207 | + - name: Run prettier |
| 208 | + run: poetry run pre-commit run prettier --all-files |
0 commit comments