-
-
Notifications
You must be signed in to change notification settings - Fork 130
182 lines (182 loc) · 7.27 KB
/
test.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
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
name: Test
on: push
env:
APP_ENV: test
NODE_ENV: test
jobs:
LINT_PHP:
name: Lint PHP
runs-on: ubuntu-latest
strategy:
matrix:
php_version:
- '8.2'
- '8.3'
fail-fast: false
steps:
- uses: actions/checkout@v2
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php_version }}
tools: composer:v2, phpstan:1
extensions: redis
- name: Install PHP dependencies
run: |
composer install --prefer-dist --no-progress --no-scripts
- name: Run PHPStan
run: phpstan analyse
- name: Clear Symfony cache
run: bin/console cache:clear
- name: Warmup Symfony cache
run: bin/console cache:warmup
LINT_JS:
name: Lint JS
runs-on: ubuntu-latest
env:
CYPRESS_INSTALL_BINARY: '0'
steps:
- uses: actions/checkout@v2
- name: Install JS dependencies
run: npm ci
- name: Run ESLint
run: node_modules/.bin/eslint --quiet js/app/
BASE:
name: Run base tests
runs-on: ubuntu-latest
env:
STRIPE_PUBLISHABLE_KEY: ${{ secrets.STRIPE_PUBLISHABLE_KEY }}
STRIPE_SECRET_KEY: ${{ secrets.STRIPE_SECRET_KEY }}
steps:
- name: Set timezone
uses: szenius/[email protected]
with:
timezoneLinux: "Europe/Paris"
- uses: actions/checkout@v2
- name: Create .env file
run: cp .env.dist .env
- name: Pull Docker images
run: docker compose pull --ignore-pull-failures
- name: Prepare OSRM data
run: |
docker compose run -T --rm osrm wget --no-check-certificate https://coopcycle-assets.sfo2.digitaloceanspaces.com/osm/paris-france.osm.pbf -O /data/data.osm.pbf
docker compose run -T --rm osrm osrm-extract -p /opt/bicycle.lua /data/data.osm.pbf
docker compose run -T --rm osrm osrm-partition /data/data.osrm
docker compose run -T --rm osrm osrm-customize /data/data.osrm
- name: Start Docker containers
run: docker compose up -d
- name: Wait for PHP-FPM
run: until docker inspect --format='{{ .State.Health.Status }}' $(docker compose ps -q php) | grep -wq healthy; do sleep 5; done
timeout-minutes: 2
- name: Wait webpack
run: until [ -f "web/build/entrypoints.json" ]; do sleep 5; done
timeout-minutes: 2
- name: Show PHP logs
if: always()
run: docker compose logs php
- name: Create database
run: docker compose exec -T php bin/console doctrine:schema:create --env=test
- name: Create typesense collections
run: docker compose exec -T php bin/console typesense:create --env=test
- name: Validate database schema
run: docker compose exec -T php bin/console doctrine:schema:validate --env=test --skip-sync
- name: Run PHPUnit
run: |
cp phpunit.xml.dist phpunit.xml
docker compose exec -T php vendor/bin/phpunit
- name: Run Behat
run: docker compose exec -T php vendor/bin/behat -f progress
- name: Show Symfony logs on failure
if: ${{ failure() }}
run: docker compose exec -T php cat var/logs/test-$(date +'%Y-%m-%d').log | grep INFO
- name: Run Jest
run: docker compose exec -T webpack npm run jest
E2E:
name: Run end to end tests with cypress
runs-on: ubuntu-latest
env:
GEOCODE_EARTH_API_KEY: ${{ secrets.GEOCODE_EARTH_API_KEY }}
STRIPE_PUBLISHABLE_KEY: ${{ secrets.STRIPE_PUBLISHABLE_KEY }}
STRIPE_SECRET_KEY: ${{ secrets.STRIPE_SECRET_KEY }}
STRIPE_CONNECT_CLIENT_ID: ${{ secrets.STRIPE_CONNECT_CLIENT_ID }}
AWS_ENDPOINT: ${{ secrets.AWS_ENDPOINT }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
steps:
- name: Set timezone
uses: szenius/[email protected]
with:
timezoneLinux: "Europe/Paris"
- uses: actions/checkout@v2
- name: Create .env file
run: cp .env.dist .env
- name: Pull Docker images
run: docker compose pull --ignore-pull-failures
- name: Prepare OSRM data
run: |
docker compose run -T --rm osrm wget --no-check-certificate https://coopcycle-assets.sfo2.digitaloceanspaces.com/osm/paris-france.osm.pbf -O /data/data.osm.pbf
docker compose run -T --rm osrm osrm-extract -p /opt/bicycle.lua /data/data.osm.pbf
docker compose run -T --rm osrm osrm-partition /data/data.osrm
docker compose run -T --rm osrm osrm-customize /data/data.osrm
# Cypress GitHub Action uses npm ci, and it causes a "permission denied" error,
# because it tries to remove the node_modules/ folder, which is mounted with root:root
# We create the node_modules/ folder *BEFORE* starting the containers,
# so that it can be removed without problems.
- name: Create node_modules directory
run: mkdir node_modules
- name: Start Docker containers
run: docker compose up -d
- name: Wait for PHP-FPM
run: until docker inspect --format='{{ .State.Health.Status }}' $(docker compose ps -q php) | grep -wq healthy; do sleep 5; done
- name: Wait webpack
run: until [ -f "web/build/entrypoints.json" ]; do sleep 5; done
- name: Create database
run: docker compose exec -T php bin/console doctrine:schema:create --env=test
- name: Create typesense collections
run: docker compose exec -T php bin/console typesense:create --env=test
- name: Setup CoopCycle
run: docker compose exec -T php bin/console coopcycle:setup --env=test
- name: Run Cypress
uses: cypress-io/github-action@v6
with:
# Maybe we could run a build step before starting tests
# https://symfony.com/doc/current/frontend/encore/installation.html
# https://github.com/cypress-io/github-action?tab=readme-ov-file#build-app
# build: npm run dev
spec: |
cypress/e2e/**/*.cy.js
# after the test run completes store videos and any screenshots
- name: Upload images for failed tests
uses: actions/upload-artifact@v4
if: failure()
with:
name: cypress-screenshots
path: cypress/screenshots
if-no-files-found: ignore # 'warn' or 'error' are also available, defaults to `warn`
- name: Show Symfony logs on failure
if: failure()
run: docker compose exec -T php cat var/logs/test-$(date +'%Y-%m-%d').log | grep INFO
COMPONENT:
name: Run component tests with Cypress
runs-on: ubuntu-latest
strategy:
matrix:
country: [fr]
env:
GEOCODE_EARTH_API_KEY: ${{ secrets.GEOCODE_EARTH_API_KEY }}
COOPCYCLE_COUNTRY: ${{ matrix.country }}
COOPCYCLE_LOCALE: ${{ matrix.country }}
steps:
- uses: actions/checkout@v2
- name: Run Cypress
uses: cypress-io/github-action@v6
with:
component: true
spec: cypress/component/**/*.cy.js
- name: Upload images for failed tests
uses: actions/upload-artifact@v4
if: failure()
with:
name: cypress-screenshots
path: cypress/screenshots
if-no-files-found: ignore # 'warn' or 'error' are also available, defaults to `warn`