-
Notifications
You must be signed in to change notification settings - Fork 0
171 lines (139 loc) · 5.11 KB
/
ci.yaml
File metadata and controls
171 lines (139 loc) · 5.11 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
name: CI
on:
push:
branches:
- master
- main
pull_request:
branches:
- master
- main
workflow_dispatch: ~
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
tests:
name: Tests
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build Docker images
run: docker compose build --no-cache
- name: Start services
run: |
docker compose up -d
echo "Waiting for services to be healthy..."
sleep 10
docker compose ps
- name: Print logs on failure
if: failure()
run: docker compose logs
- name: Install Composer dependencies
run: docker compose exec -T app composer install --no-interaction --no-progress --prefer-dist
- name: Generate JWT keys
run: docker compose exec -T app php bin/console lexik:jwt:generate-keypair --overwrite --no-interaction
- name: Check HTTP reachability
run: |
for i in {1.10}; do
if curl -s -f http://localhost:8000/api/v1 > /dev/null 2>&1; then
echo "App is ready"
break
fi
echo "Waiting for app... ($i/10)"
sleep 2
done
curl -v --fail-with-body http://localhost:8000/api/v1 || true
- name: Create test database
run: docker compose exec -T app php bin/console -e test doctrine:database:create --if-not-exists
- name: Run migrations
run: docker compose exec -T app php bin/console -e test doctrine:migrations:migrate --no-interaction
- name: Run PHPUnit
run: docker compose exec -T app vendor/bin/phpunit
- name: Run PHPUnit with coverage
run: docker compose exec -T -e XDEBUG_MODE=coverage app vendor/bin/phpunit --testsuite=Unit --coverage-clover var/coverage/clover.xml --coverage-text
- name: Check coverage threshold (80%)
run: |
COVERAGE=$(docker compose exec -T app php -r "
\$xml = simplexml_load_file('var/coverage/clover.xml');
\$metrics = \$xml->project->metrics;
\$statements = (int)\$metrics['statements'];
\$covered = (int)\$metrics['coveredstatements'];
echo \$statements > 0 ? round((\$covered / \$statements) * 100, 2) : 0;
")
echo "Line coverage: ${COVERAGE}%"
if [ "$(echo "${COVERAGE} < 80" | bc)" -eq 1 ]; then
echo "::error::Coverage ${COVERAGE}% is below the 80% threshold"
exit 1
fi
- name: Run Behat
run: docker compose exec -T app vendor/bin/behat --no-interaction --colors
- name: Run CS Fixer (dry-run)
run: docker compose exec -T app vendor/bin/php-cs-fixer fix --dry-run --diff
- name: Run PHPStan
run: docker compose exec -T app vendor/bin/phpstan analyse
- name: Run Rector (dry-run)
run: docker compose exec -T app vendor/bin/rector process --dry-run
- name: YAML linter
run: docker compose exec -T app php bin/console lint:yaml config
- name: Doctrine Schema Validator
run: docker compose exec -T app php bin/console -e test doctrine:schema:validate --skip-sync || true
lint:
name: Docker Lint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Lint Dockerfile (dev)
uses: hadolint/hadolint-action@v3.1.0
with:
dockerfile: docker/frankenphp/Dockerfile.dev
failure-threshold: error
- name: Lint Dockerfile (prod)
uses: hadolint/hadolint-action@v3.1.0
with:
dockerfile: docker/frankenphp/Dockerfile
failure-threshold: error
frontend:
name: Frontend
runs-on: ubuntu-latest
defaults:
run:
working-directory: frontend
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Check if frontend exists
id: check_frontend
run: |
if [ -f "package.json" ]; then
echo "exists=true" >> $GITHUB_OUTPUT
else
echo "exists=false" >> $GITHUB_OUTPUT
echo "Frontend not yet implemented, skipping..."
fi
- name: Setup Node.js
if: steps.check_frontend.outputs.exists == 'true'
uses: actions/setup-node@v5
with:
node-version: '24'
cache: 'npm'
cache-dependency-path: frontend/package-lock.json
- name: Install dependencies
if: steps.check_frontend.outputs.exists == 'true'
run: npm ci
- name: Type check
if: steps.check_frontend.outputs.exists == 'true'
run: npm run typecheck || true
- name: Lint
if: steps.check_frontend.outputs.exists == 'true'
run: npm run lint || true
- name: Run tests
if: steps.check_frontend.outputs.exists == 'true'
run: npm test -- --passWithNoTests
- name: Build
if: steps.check_frontend.outputs.exists == 'true'
run: npm run build