generated from dunglas/symfony-docker
-
Notifications
You must be signed in to change notification settings - Fork 2
125 lines (122 loc) · 4.73 KB
/
ci.yml
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
name: CI
on:
push:
pull_request:
jobs:
coding-standards:
name: Coding standards
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Cache Composer dependencies
uses: actions/cache@v2
with:
path: /tmp/composer-cache
key: ${{ runner.os }}-${{ hashFiles('**/composer.lock') }}
- name: Install PHP dependencies (composer install)
uses: php-actions/composer@v6
with:
php_version: 8.3
php_extensions: xsl bcmath pcntl
- name: Use Node.js 18.x
uses: actions/setup-node@v1
with:
node-version: 18.x
- name: Install JS dependencies (npm install)
run: npm i --ignore-scripts --production=false
- name: PHP CS Fixer
run: DEV/ci/php-cs-fixer.sh
- name: PHP Stan
run: DEV/ci/phpstan.sh
- name: PHP MD
run: DEV/ci/phpmd.sh
- name: Twigcs
run: DEV/ci/twigcs.sh
- name: CSS stylelint
run: DEV/ci/stylelint.sh
- name: ESLint (JS)
run: DEV/ci/eslint.sh
build:
name: Build and test
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
ini-values: post_max_size=256M, max_execution_time=0
- name: Use Node.js 18.x
uses: actions/setup-node@v1
with:
node-version: 18.x
- name: Pull images
run: docker compose pull
- name: Enable Docker build caching between CI runs
uses: jpribyl/[email protected]
with:
key: docker-layer-cache-{hash}
restore-keys: |
docker-layer-cache-
layer-docker-layer-cache-
continue-on-error: true
- name: Start services
run: docker compose --env-file .env.test up --build -d
- name: Wait for services
run: |
APP_BOOT_TIMEOUT=`expr $(date +%s) + 600`
UNHEALTHY_ALLOWANCE_LEFT=20
while status="$(docker inspect --format="{{if .Config.Healthcheck}}{{print .State.Health.Status}}{{end}}" "$(docker compose ps -q php)")"; do
case $status in
starting)
if [ $APP_BOOT_TIMEOUT -lt $(date +%s) ]; then
echo "System boot timed out - 10 mins elapsed."
docker logs --since="10m" "$(docker compose ps -q php)"
exit 1
fi
UNHEALTHY_ALLOWANCE_LEFT=20
sleep 1;;
healthy)
exit 0;;
unhealthy)
if [ $UNHEALTHY_ALLOWANCE_LEFT -eq 0 ]; then
docker logs --since="10m" "$(docker compose ps -q php)"
exit 1
else
UNHEALTHY_ALLOWANCE_LEFT=$((UNHEALTHY_ALLOWANCE_LEFT - 1))
sleep 3
fi;;
esac
done
exit 1
- name: Check HTTP reachability
run: curl http://localhost
- name: Check HTTPS reachability
run: curl -k https://localhost
- name: Install Playwright dependencies
run: npx [email protected] install-deps
- name: Install JS testing dependencies
run: npm ci
- name: Build JS assets with Webpack Encore
run: NODE_ENV=test npm run encore prod
- name: Install Playwright browsers
run: npx playwright install
- name: Run tests
run: ./DEV/ci/run-tests.php --verbose
- name: Prepare log artifacts (copy from container to host)
if: always()
run: sudo docker cp $(docker compose ps -q php):/srv/app/var/log var
- name: Save log artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: logs
path: var/log
- name: Save testing artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: test-results
path: test-results