-
Notifications
You must be signed in to change notification settings - Fork 70
78 lines (65 loc) · 2.47 KB
/
Copy pathmypy.yml
File metadata and controls
78 lines (65 loc) · 2.47 KB
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
name: mypy
on:
pull_request:
paths:
- '**/*.py' # Watch for changes in any Python files
- 'pyproject.toml' # Watch for changes in the pyproject.toml file
push:
paths:
- '**/*.py' # Watch for changes in any Python files
- 'pyproject.toml' # Watch for changes in the pyproject.toml file
workflow_dispatch:
release:
types: [published]
concurrency:
group: ci-${{github.workflow}}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
mypy:
name: mypy
runs-on: ubuntu-latest
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@5ef0c079ce82195b2a36a210272d6b661572d83e # v2.14.2
with:
egress-policy: audit
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Install dependencies
id: install_deps
continue-on-error: true
run: |
WARNINGS=0
export MYPY_VERSION=$(grep -oP 'mypy==\K[0-9]+(\.[0-9]+)*' pyproject.toml || echo '')
export TYPES_REQUESTS_VERSION=$(grep -oP 'types-requests==\K[0-9]+(\.[0-9]+)*' pyproject.toml || echo '')
if [ -z "$MYPY_VERSION" ]; then
echo "::warning::Could not detect mypy version in pyproject.toml; falling back to latest."
MYPY_INSTALL="mypy"
WARNINGS=1
else
echo "Will install mypy version $MYPY_VERSION."
MYPY_INSTALL="mypy==$MYPY_VERSION"
fi
if [ -z "$TYPES_REQUESTS_VERSION" ]; then
echo "::warning::Could not detect types-requests version in pyproject.toml; falling back to latest."
TYPES_REQUESTS_INSTALL="types-requests"
WARNINGS=1
else
echo "Will install types-requests version $TYPES_REQUESTS_VERSION."
TYPES_REQUESTS_INSTALL="types-requests==$TYPES_REQUESTS_VERSION"
fi
python -m pip install "$MYPY_INSTALL" "$TYPES_REQUESTS_INSTALL"
echo "warnings=$WARNINGS" >> $GITHUB_OUTPUT
if [ "$WARNINGS" -eq 1 ]; then
exit 1
fi
- name: Lint the code with mypy
uses: amilcarlucas/mypy-github-action@fc3d4ef2fe501ec797415a3ed1290e0ae619b5f6 # v2.0.2
with:
checkName: 'mypy' # NOTE: this needs to be the same as the job name
mypyFlags: ''
mypyFiles: ''
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}