Debian Codegraph @

.github/workflows/reusable-linters.yml

raw
1 ---
2 name: 🚨linters
3
4 on: # yamllint disable-line rule:truthy
5 workflow_call:
6
7 jobs:
8 linters:
9 name: >-
10 ${{ matrix.toxenv }} @ py${{ matrix.python-version }}
11 runs-on: ${{ matrix.os }}
12 strategy:
13 fail-fast: false
14 matrix:
15 python-version:
16 # - ~3.12.0-0
17 - 3.11
18 - >-
19 3.10
20 - 3.9
21 - 3.8
22 os:
23 - ubuntu-latest
24 toxenv:
25 - lint
26 - build-dists
27
28 env:
29 PY_COLORS: 1
30 TOX_PARALLEL_NO_SPINNER: 1
31 TOXENV: ${{ matrix.toxenv }}
32
33 steps:
34 - uses: actions/checkout@v3
35 - name: Set up Python ${{ matrix.python-version }}
36 uses: actions/setup-python@v4
37 with:
38 python-version: ${{ matrix.python-version }}
39 - name: >-
40 Calculate Python interpreter version hash value
41 for use in the cache key
42 id: calc_cache_key_py
43 run: |
44 from hashlib import sha512
45 from os import environ
46 from pathlib import Path
47 from sys import version
48
49 FILE_APPEND_MODE = 'a'
50
51 hash = sha512(version.encode()).hexdigest()
52
53 with Path(environ['GITHUB_OUTPUT']).open(
54 mode=FILE_APPEND_MODE,
55 ) as outputs_file:
56 print(f'py_hash_key={hash}', file=outputs_file)
57 shell: python
58 - name: Set up pip cache
59 uses: actions/cache@v3
60 with:
61 path: ~/.cache/pip
62 key: >-
63 ${{ runner.os }}-pip-${{
64 steps.calc_cache_key_py.outputs.py_hash_key }}-${{
65 hashFiles('setup.cfg') }}-${{
66 hashFiles('tox.ini') }}-${{
67 hashFiles('pyproject.toml') }}-${{
68 hashFiles('.pre-commit-config.yaml') }}
69 restore-keys: |
70 ${{ runner.os }}-pip-${{
71 steps.calc_cache_key_py.outputs.py_hash_key
72 }}-
73 ${{ runner.os }}-pip-
74 ${{ runner.os }}-
75 - name: Set up pre-commit cache
76 uses: actions/cache@v3
77 with:
78 path: ~/.cache/pre-commit
79 key: >-
80 ${{ runner.os }}-pre-commit-${{
81 steps.calc_cache_key_py.outputs.py_hash_key }}-${{
82 hashFiles('setup.cfg') }}-${{
83 hashFiles('tox.ini') }}-${{
84 hashFiles('pyproject.toml') }}-${{
85 hashFiles('.pre-commit-config.yaml') }}
86 - name: Install tox
87 run: |
88 python -m pip install --upgrade tox
89 - name: Log installed dists
90 run: |
91 python -m pip freeze --all
92 - name: Initialize tox envs
93 run: |
94 python -m tox --parallel auto --parallel-live --notest
95 - name: Initialize pre-commit envs if needed
96 run: >-
97 test -d .tox/lint
98 && .tox/lint/bin/python -m pre_commit install-hooks
99 || :
100 - name: Test with tox
101 run: |
102 python -m tox --parallel auto --parallel-live
103 ...