-
Notifications
You must be signed in to change notification settings - Fork 1
155 lines (131 loc) · 4.1 KB
/
Copy pathci-dev.yml
File metadata and controls
155 lines (131 loc) · 4.1 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
name: CI - Dev Branch
on:
push:
branches:
- dev
workflow_dispatch:
permissions:
contents: read
concurrency:
group: ci-dev-${{ github.ref }}
cancel-in-progress: true
jobs:
changes:
name: Detect changed paths
runs-on: ubuntu-latest
outputs:
docs: ${{ steps.filter.outputs.docs }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Path filter
id: filter
uses: dorny/paths-filter@v3
with:
filters: |
docs:
- docs/**
- mkdocs.yml
- README.md
- index.html
backend-smoke:
name: Backend smoke checks
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
cache: pip
- name: Install backend dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
- name: Smoke test health and core API
shell: pwsh
run: |
@'
from src.database.database import init_db
from src.api.api_server import create_app
init_db()
app = create_app(None)
client = app.test_client()
health = client.get('/api/health')
assert health.status_code == 200, f"/api/health failed: {health.status_code}"
assert health.get_json().get('status') == 'running', f"Unexpected health payload: {health.get_data(as_text=True)}"
dates = client.get('/api/available-dates')
assert dates.status_code == 200, f"/api/available-dates failed: {dates.status_code}"
print('Backend smoke checks passed.')
'@ | python -
- name: Run backend tests if present
shell: pwsh
run: |
$hasTests = $false
if (Test-Path tests) {
$found = Get-ChildItem tests -Recurse -Include "test_*.py","*_test.py" -ErrorAction SilentlyContinue | Select-Object -First 1
if ($found) { $hasTests = $true }
}
if (-not $hasTests) {
$foundSrc = Get-ChildItem src -Recurse -Include "test_*.py","*_test.py" -ErrorAction SilentlyContinue | Select-Object -First 1
if ($foundSrc) { $hasTests = $true }
}
if ($hasTests) {
python -m pip install pytest
python -m pytest -q
}
else {
Write-Host "No backend tests found. Skipping pytest."
}
frontend-ci:
name: Frontend lint and build
runs-on: windows-latest
defaults:
run:
working-directory: frontend
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: "20"
cache: npm
cache-dependency-path: frontend/package-lock.json
- name: Install frontend dependencies
run: npm ci
- name: Run lint
run: npm run lint
- name: Build frontend
run: npm run build
- name: Run frontend tests if script exists
shell: pwsh
run: |
$pkg = Get-Content package.json | ConvertFrom-Json
$hasTestScript = $pkg.scripts.PSObject.Properties.Name -contains "test"
if ($hasTestScript) {
npm test -- --run
}
else {
Write-Host "No frontend test script found. Skipping frontend tests."
}
docs-build:
name: Docs build (docs changes only)
needs: changes
if: needs.changes.outputs.docs == 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
cache: pip
- name: Install docs dependencies
run: |
python -m pip install --upgrade pip
python -m pip install mkdocs mkdocs-material pymdown-extensions
- name: Build docs
run: python -m mkdocs build --strict --site-dir site