WIP #9032
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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` |