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