Repository navigation
159 lines (139 loc) · 4.91 KB
/
Copy pathmain.yml
File metadata and controls
159 lines (139 loc) · 4.91 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
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
name: RepoPlone QA
on:
push:
workflow_dispatch:
env:
python-version: "3.12"
jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Install the latest version of uv
uses: astral-sh/setup-uv@v7
with:
python-version: ${{ env.python-version }}
cache-python: true
enable-cache: true
cache-suffix: "optional-suffix"
cache-dependency-glob: |
**/uv.lock
- name: Check formatting
if: ${{ success() || failure() }}
id: ruff-format
run: uvx ruff@latest format --diff
- name: Check lint
if: ${{ success() || failure() }}
id: ruff-lint
run: uvx ruff@latest check --diff
- name: Check Package Metadata
if: ${{ success() || failure() }}
id: pyroma
run: uvx pyroma@latest -d .
- name: Check Python Versions
if: ${{ success() || failure() }}
id: py-versions
run: uvx check-python-versions@latest .
- name: Check typing
if: ${{ success() || failure() }}
id: typing
run: |
make install
uv run mypy src
- name: Report
if: ${{ success() || failure() }}
run: |
echo '# Code Analysis' >> $GITHUB_STEP_SUMMARY
echo '| Test | Status |' >> $GITHUB_STEP_SUMMARY
echo '| --- | --- |' >> $GITHUB_STEP_SUMMARY
echo '| Format | ${{ steps.ruff-format.conclusion == 'failure' && '❌' || ' ✅' }} |' >> $GITHUB_STEP_SUMMARY
echo '| Lint | ${{ steps.ruff-lint.conclusion == 'failure' && '❌' || ' ✅' }} |' >> $GITHUB_STEP_SUMMARY
echo '| Package Metadata | ${{ steps.pyroma.conclusion == 'failure' && '❌' || ' ✅' }} |' >> $GITHUB_STEP_SUMMARY
echo '| Python Versions | ${{ steps.py-versions.conclusion == 'failure' && '❌' || ' ✅' }} |' >> $GITHUB_STEP_SUMMARY
echo '| Typing | ${{ steps.typing.conclusion == 'failure' && '❌' || ' ✅' }} |' >> $GITHUB_STEP_SUMMARY
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.14", "3.13", "3.12", "3.11"]
env:
PYTHON_VERSION: ${{ matrix.python-version }}
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Install the latest version of uv
uses: astral-sh/setup-uv@v7
with:
python-version: ${{ env.python-version }}
cache-python: true
enable-cache: true
cache-suffix: "optional-suffix"
cache-dependency-glob: |
**/uv.lock
- name: Run tests
run: |
make test
coverage:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Install the latest version of uv
uses: astral-sh/setup-uv@v7
with:
python-version: ${{ env.python-version }}
enable-cache: false
- name: Restore uv cache
uses: actions/cache@v6
with:
path: /tmp/.uv-cache
key: uv-${{ runner.os }}-${{ env.python-version }}-${{ hashFiles('uv.lock') }}
restore-keys: |
uv-${{ runner.os }}-${{ env.python-version }}-${{ hashFiles('uv.lock') }}
uv-${{ runner.os }}-${{ env.python-version }}
- name: Run tests
run: |
make test-coverage
- name: Report Coverage
run: |
echo "# Coverage Report" >> $GITHUB_STEP_SUMMARY
echo "$(uv run coverage report --format markdown)" >> $GITHUB_STEP_SUMMARY
report:
name: Final result
if: ${{ always() }}
needs:
- lint
- test
- coverage
runs-on: ubuntu-latest
steps:
- name: Report
env:
LINT_RESULT: ${{ needs.lint.result }}
TEST_RESULT: ${{ needs.test.result }}
COVERAGE_RESULT: ${{ needs.coverage.result }}
run: |
icon() {
case "$1" in
success) echo "✅" ;;
skipped) echo "⏭️" ;;
cancelled) echo "🚫" ;;
*) echo "❌" ;;
esac
}
{
echo "# Final result"
echo "| Job | Result |"
echo "| --- | --- |"
echo "| Lint | $(icon "$LINT_RESULT") ${LINT_RESULT} |"
echo "| Tests | $(icon "$TEST_RESULT") ${TEST_RESULT} |"
echo "| Coverage | $(icon "$COVERAGE_RESULT") ${COVERAGE_RESULT} |"
} >> "$GITHUB_STEP_SUMMARY"
for result in "$LINT_RESULT" "$TEST_RESULT" "$COVERAGE_RESULT"; do
if [ "$result" != "success" ]; then
echo "::error::At least one job did not succeed."
exit 1
fi
done