-
Notifications
You must be signed in to change notification settings - Fork 0
252 lines (214 loc) · 7.94 KB
/
Copy pathci.yml
File metadata and controls
252 lines (214 loc) · 7.94 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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
# =============================================================================
# VDV463 Validator - GitHub Actions CI Workflow
# =============================================================================
name: CI
on:
push:
branches: [ main, develop ]
paths:
- 'src/**'
- 'tests/**'
- 'schemas/**'
- 'rules/**'
- 'requirements*.txt'
- 'pyproject.toml'
- '.github/workflows/ci.yml'
pull_request:
branches: [ main ]
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
jobs:
# ---------------------------------------------------------------------------
# Lint Job
# ---------------------------------------------------------------------------
lint:
name: Lint & Type Check
runs-on: ubuntu-latest
permissions:
contents: write
steps:
# Checkout mit persist-credentials für Push
- uses: actions/checkout@v5
with:
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0
persist-credentials: true
# Python Setup
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '3.11'
cache: 'pip'
# Dependencies installieren
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install ruff mypy bandit
- name: Run Ruff linter
run: ruff check src/ tests/ --fix
continue-on-error: false
- name: Run Bandit security scan
run: bandit -r src/ -ll
continue-on-error: false
- name: Run Ruff formatter
run: ruff format src/ tests/
- name: Commit Ruff changes
if: github.event_name == 'push'
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add -A
git diff --staged --quiet || git commit -m "style: apply ruff formatting and fixes [skip ci]"
git push || echo "No changes to push"
pip install ruff mypy types-PyYAML
# Ruff Lint + Auto-Fix
- name: Lint + auto-fix with Ruff
run: ruff check src/ tests/ --fix
# Mypy Typprüfung
- name: Type check with mypy
run: mypy src/ --install-types --non-interactive --ignore-missing-imports
continue-on-error: true
# Commit & Push Auto-Fixes auf neuen Branch
- name: Commit fixes
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "auto-fix: ruff"
file_pattern: "." # alle geänderten Dateien
create_branch: true # neuer Branch wird automatisch erstellt
# ---------------------------------------------------------------------------
# Test Job
# ---------------------------------------------------------------------------
test:
name: Test (Python ${{ matrix.python-version }})
runs-on: ubuntu-latest
permissions:
contents: read
checks: write
pull-requests: write
strategy:
fail-fast: false
matrix:
python-version: [ '3.10', '3.11', '3.12' ]
steps:
- uses: actions/checkout@v5
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- name: Install system dependencies for Qt
run: |
sudo apt-get update
sudo apt-get install -y libxkbcommon-x11-0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 libxcb-xinerama0 libxcb-xfixes0 libegl1
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements-dev.txt
- name: Pre-download schemas for tests
run: |
mkdir -p schemas/v1.0 schemas/v1.1 schemas/v2.0
# Run validation for each version to force downloads
# We use --quiet to avoid cluttering logs
python src/vdv463_validator.py tests/fixtures/v1.0/valid/charging_info_minimal.json --schema-version 1.0 --quiet || true
python src/vdv463_validator.py tests/fixtures/v1.1/valid/valid_charging_info.json --schema-version 1.1 --quiet || true
# v2.0 doesn't have a fixture yet, but the directory is there
- name: Run tests
env:
QT_QPA_PLATFORM: offscreen
run: pytest tests/ -v --cov=src --cov-report=xml --junitxml=pytest-results.xml
- name: Upload test results
uses: actions/upload-artifact@v5
if: always()
with:
name: test-results-${{ matrix.python-version }}
path: pytest-results.xml
retention-days: 3
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
if: matrix.python-version == '3.11'
with:
files: coverage.xml
flags: unittests
name: codecov-umbrella
- name: Publish Test Results
uses: dorny/test-reporter@v1
if: always() && matrix.python-version == '3.11'
with:
name: Pytest Results
path: pytest-results.xml
reporter: java-junit
# ---------------------------------------------------------------------------
# Validation Job
# ---------------------------------------------------------------------------
validate:
name: Validate Fixtures
runs-on: ubuntu-latest
permissions:
contents: read
checks: write
pull-requests: write
needs: test
strategy:
matrix:
fail-level: [ ERROR, WARNING ]
fail-fast: false
steps:
- uses: actions/checkout@v5
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '3.11'
cache: 'pip'
- name: Install dependencies
run: pip install -r requirements.txt
- name: Pre-download schemas
run: |
mkdir -p schemas/v1.0 schemas/v1.1 schemas/v2.0
python scripts/update_schemas.py
- name: Validate fixtures (fail-level ${{ matrix.fail-level }})
run: |
mkdir -p reports
# Validate each version separately to ensure correct schema selection
for version in 1.0 1.1; do
if [ -d "tests/fixtures/v$version/valid" ]; then
echo "Validating v$version fixtures..."
python src/vdv463_validator.py tests/fixtures/v$version/valid/*.json \
--quiet \
--schema-version $version \
--junit-xml reports/validation-$version-${{ matrix.fail-level }}.xml \
--fail-level ${{ matrix.fail-level }}
else
# Still create an empty report for versions without fixtures to satisfy the reporter
echo "No fixtures for v$version, creating empty report..."
python src/vdv463_validator.py --quiet --schema-version $version \
--junit-xml reports/validation-$version-${{ matrix.fail-level }}.xml \
--fail-level ${{ matrix.fail-level }}
fi
done
# Combine reports or ensure test-reporter finds them
continue-on-error: ${{ matrix.fail-level == 'WARNING' }}
- name: Publish Validation Results
uses: dorny/test-reporter@v1
if: always()
with:
name: VDV463 Validation (${{ matrix.fail-level }})
path: reports/validation-*-${{ matrix.fail-level }}.xml
reporter: java-junit
# ---------------------------------------------------------------------------
# Build Job
# ---------------------------------------------------------------------------
build:
name: Build Package
runs-on: ubuntu-latest
needs: [ lint, test ]
steps:
- uses: actions/checkout@v5
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '3.11'
cache: 'pip'
- name: Install build tools
run: pip install build
- name: Build package
run: python -m build