Debian Codegraph @

.github/workflows/ci.yml

raw
1 name: CI
2
3 on:
4 push:
5 branches:
6 - main
7 - dev
8 paths:
9 - "**/*.py"
10 - ".github/workflows/**"
11 - "pyproject.toml"
12 - "setup.cfg"
13 - "requirements*.txt"
14 - "uv.lock"
15 pull_request:
16 paths:
17 - "**/*.py"
18 - "tests/**/*.py"
19 - "pyproject.toml"
20 - "setup.cfg"
21 - "requirements*.txt"
22 - "uv.lock"
23 schedule:
24 - cron: "0 0 * * *"
25
26 concurrency:
27 group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
28 cancel-in-progress: true
29
30 jobs:
31 prepare:
32 name: Preparation
33 runs-on: ubuntu-latest
34
35 permissions:
36 contents: read
37
38 strategy:
39 matrix:
40 python-version: [3.11, 3.12, 3.13]
41 steps:
42 - name: Checkout
43 uses: actions/[email protected]
44
45 - name: Set up UV and Python
46 uses: astral-sh/setup-uv@v7
47 with:
48 python-version: ${{ matrix.python-version }}
49 enable-cache: true
50 cache-dependency-glob: "uv.lock"
51
52 - name: Install the project
53 run: uv sync --all-groups
54
55 ruff-format:
56 name: Ruff Format
57 needs: prepare
58 runs-on: ubuntu-latest
59
60 permissions:
61 contents: read
62
63 steps:
64 - name: Checkout
65 uses: actions/[email protected]
66
67 - name: Set up UV and Python
68 uses: astral-sh/setup-uv@v7
69 with:
70 python-version: 3.13
71 enable-cache: true
72 cache-dependency-glob: "uv.lock"
73
74 - name: Install the project
75 run: uv sync --all-groups
76
77 - name: Run Ruff Format
78 run: uv run pre-commit run --hook-stage manual ruff-format --all-files --show-diff-on-failure
79
80 ruff-check:
81 name: Ruff Check
82 needs: prepare
83 runs-on: ubuntu-latest
84
85 permissions:
86 contents: read
87
88 steps:
89 - name: Checkout
90 uses: actions/[email protected]
91
92 - name: Set up UV and Python
93 uses: astral-sh/setup-uv@v7
94 with:
95 python-version: 3.13
96 enable-cache: true
97 cache-dependency-glob: "uv.lock"
98
99 - name: Install the project
100 run: uv sync --all-groups
101
102 - name: Run Ruff Check
103 run: uv run pre-commit run --hook-stage manual ruff-check --all-files --show-diff-on-failure
104
105 unit-tests:
106 name: Unit Tests
107 needs:
108 - ruff-format
109 - ruff-check
110 runs-on: ubuntu-latest
111
112 permissions:
113 contents: read
114
115 strategy:
116 matrix:
117 python-version: [3.11, 3.12, 3.13]
118 steps:
119 - name: Checkout
120 uses: actions/[email protected]
121
122 - name: Set up UV and Python
123 uses: astral-sh/setup-uv@v7
124 with:
125 python-version: ${{ matrix.python-version }}
126 enable-cache: true
127 cache-dependency-glob: "uv.lock"
128
129 - name: Install the project
130 run: uv sync --all-groups
131
132 - name: Run unit tests
133 run: |
134 uv run pytest --cov=asusrouter --cov-report=xml:unit-tests-cov-${{ matrix.python-version }}.xml -k 'not test_devices'
135
136 - name: Upload coverage to artifacts
137 uses: actions/upload-artifact@v5
138 with:
139 name: unit-tests-cov-${{ matrix.python-version }}
140 path: unit-tests-cov-${{ matrix.python-version }}.xml
141
142 device-tests:
143 name: Device Tests
144 needs:
145 - ruff-format
146 - ruff-check
147 runs-on: ubuntu-latest
148
149 permissions:
150 contents: read
151
152 strategy:
153 matrix:
154 python-version: [3.11, 3.12, 3.13]
155 steps:
156 - name: Checkout
157 uses: actions/[email protected]
158
159 - name: Set up UV and Python
160 uses: astral-sh/setup-uv@v7
161 with:
162 python-version: ${{ matrix.python-version }}
163 enable-cache: true
164 cache-dependency-glob: "uv.lock"
165
166 - name: Install the project
167 run: uv sync --all-groups
168
169 - name: Run real-data tests
170 run: |
171 uv run pytest tests/test_devices.py --cov=asusrouter --cov-report=xml:real-data-tests-cov-${{ matrix.python-version }}.xml --log-cli-level=INFO
172
173 - name: Upload coverage to artifacts
174 uses: actions/upload-artifact@v5
175 with:
176 name: real-data-tests-cov-${{ matrix.python-version }}
177 path: real-data-tests-cov-${{ matrix.python-version }}.xml
178
179 codecov:
180 name: Codecov
181 needs: [unit-tests, device-tests]
182 runs-on: ubuntu-latest
183
184 if: ${{ github.actor != 'dependabot[bot]' }}
185
186 permissions:
187 contents: read
188 checks: write
189
190 strategy:
191 matrix:
192 python-version: [3.11, 3.12, 3.13]
193 steps:
194 - name: Checkout
195 uses: actions/[email protected]
196
197 - name: Download unit-tests coverage from artifacts
198 uses: actions/download-artifact@v6
199 with:
200 name: unit-tests-cov-${{ matrix.python-version }}
201 path: .
202
203 - name: Download real-data-tests coverage from artifacts
204 uses: actions/download-artifact@v6
205 with:
206 name: real-data-tests-cov-${{ matrix.python-version }}
207 path: .
208
209 - name: Upload coverage to Codecov
210 uses: codecov/[email protected]
211 with:
212 token: ${{ secrets.CODECOV_TOKEN }}
213 fail_ci_if_error: true
214 files: unit-tests-cov-${{ matrix.python-version }}.xml,real-data-tests-cov-${{ matrix.python-version }}.xml