-
Notifications
You must be signed in to change notification settings - Fork 0
167 lines (146 loc) ยท 4.37 KB
/
Copy pathci.yml
File metadata and controls
167 lines (146 loc) ยท 4.37 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
160
161
162
163
164
165
166
167
name: CI
on:
push:
branches: [ "main" ]
pull_request:
types: [opened, synchronize, reopened]
permissions:
contents: read
concurrency:
group: ci-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
lint:
if: |
github.event_name != 'push' ||
(
!contains(github.event.head_commit.message, '[skip ci]') &&
!contains(github.event.head_commit.message, '[skip-release]')
)
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
cache: 'pip'
cache-dependency-path: 'requirements.txt'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install ruff
- name: Lint with Ruff
run: |
ruff check . --ignore C901,D417
test:
if: |
github.event_name != 'push' ||
(
!contains(github.event.head_commit.message, '[skip ci]') &&
!contains(github.event.head_commit.message, '[skip-release]')
)
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- lane: fast
marker: "not slow"
timeout: 10
- lane: slow
marker: "slow"
timeout: 10
timeout-minutes: ${{ matrix.timeout }}
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
cache: 'pip'
cache-dependency-path: 'requirements.txt'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
pip install pytest pytest-timeout pytest-cov pytest-xdist
- name: Run ${{ matrix.lane }} tests
run: |
pytest -v --tb=short -m "${{ matrix.marker }}" \
-n auto \
--cov=src --cov-report=xml:coverage-${{ matrix.lane }}.xml \
--cov-report=term-missing
- name: Upload coverage to Codecov
if: always()
uses: codecov/codecov-action@v5
with:
files: coverage-${{ matrix.lane }}.xml
flags: ${{ matrix.lane }}
fail_ci_if_error: false
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
- name: Upload .coverage data
if: always()
uses: actions/upload-artifact@v4
with:
name: coverage-data-${{ matrix.lane }}
path: .coverage
include-hidden-files: true
ci:
runs-on: ubuntu-latest
needs: [lint, test]
if: always()
steps:
- name: Check required jobs
run: |
if [[ "${{ needs.lint.result }}" != "success" || "${{ needs.test.result }}" != "success" ]]; then
echo "Required jobs failed: lint=${{ needs.lint.result }}, test=${{ needs.test.result }}"
exit 1
fi
coverage-badge:
needs: test
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
permissions:
contents: write
timeout-minutes: 5
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install coverage
run: pip install "coverage[toml]"
- name: Download fast coverage data
uses: actions/download-artifact@v4
with:
name: coverage-data-fast
path: cov-fast
- name: Download slow coverage data
uses: actions/download-artifact@v4
with:
name: coverage-data-slow
path: cov-slow
- name: Combine coverage and generate JSON
run: |
cp cov-fast/.coverage .coverage.fast
cp cov-slow/.coverage .coverage.slow
coverage combine .coverage.fast .coverage.slow
coverage json -o coverage.json --include="src/*"
- name: Update coverage.json and push
run: |
if [ -f coverage.json ]; then
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add coverage.json
if git diff --cached --quiet; then
echo "No coverage changes to commit"
else
git commit -m "chore: update coverage.json [skip ci]"
git pull --rebase
git push
fi
fi