-
Notifications
You must be signed in to change notification settings - Fork 40
109 lines (92 loc) · 2.78 KB
/
lint-and-check.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
103
104
105
106
107
108
109
name: format
on:
pull_request:
branches: [main]
jobs:
format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: "3.12"
- name: Install poetry
uses: abatilo/actions-poetry@v2
with:
poetry-version: "1.8.3"
- name: Setup a local virtual environment
run: |
poetry config virtualenvs.create true --local
poetry config virtualenvs.in-project true --local
- uses: actions/cache@v3
name: Define a cache for the virtual environment based on the dependencies lock file
with:
path: ./.venv
key: venv-${{ hashFiles('poetry.lock') }}
- name: Install project dependencies
run: poetry install
# --- Ruff
- name: ruff (lint)
id: ruff_lint
continue-on-error: true
run: |
poetry run ruff --version
poetry run ruff check . --verbose --diff
echo "ruff_lint_failed=$?" >> $GITHUB_ENV
- name: ruff (format)
id: ruff_format
continue-on-error: true
run: |
poetry run ruff --version
poetry run ruff format . --check --verbose --diff
echo "ruff_format_failed=$?" >> $GITHUB_ENV
# --- Pyright
- name: pyright
id: pyright
continue-on-error: true
run: |
poetry run pyright --version
poetry run pyright --project ./pyrightconfig.ci.json
echo "pyright_failed=$?" >> $GITHUB_ENV
# --- Main
- name: Results
if: always()
run: |
# Print out test results
passed=()
failed=()
if [[ "${{ env.ruff_lint_failed }}" != "0" ]]; then
failed+=("ruff_lint")
else
passed+=("ruff_lint")
fi
if [[ "${{ env.ruff_format_failed }}" != "0" ]]; then
failed+=("ruff_format")
else
passed+=("ruff_format")
fi
if [[ "${{ env.pyright_failed }}" != "0" ]]; then
failed+=("pyright")
else
passed+=("pyright")
fi
if [ ${#passed[@]} -ne 0 ]; then
echo "✅ PASSED:"
for check in "${passed[@]}"; do
echo " - $check"
done
fi
echo ""
if [ ${#failed[@]} -ne 0 ]; then
echo "❌ FAILED:"
for check in "${failed[@]}"; do
echo " - $check"
done
else
echo "🚀🚀 ALL FORMATTING & TYPE-CHECKING PASSED 🚀🚀"
fi
echo ""
echo "Click above jobs for details on each success/failure"
if [ ${#failed[@]} -ne 0 ]; then
exit 1
fi