Ajout de tests cypress #1175
Workflow file for this run
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: Integration and Functional tests | |
on: | |
pull_request: | |
branches: | |
- master | |
- staging | |
- dev | |
jobs: | |
setup: | |
runs-on: ubuntu-22.04 | |
strategy: | |
fail-fast: true | |
matrix: | |
php-versions: ['7.4'] | |
steps: | |
# REMOVE RESIDUAL CONTAINERS ( for local debug with act only ) | |
- name: Remove all mysql containers when working with act | |
if: ${{ env.ACT }} | |
run: | | |
CONTAINERS=$(docker ps -a -q --filter ancestor=mariadb:10.4.10) | |
if [ ! -z "$CONTAINERS" ]; then | |
docker rm -f $CONTAINERS | |
else | |
echo "No containers to remove." | |
fi | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
# INSTALL DEPENDENCIES ---------------- | |
- name: Setup PHP, extensions and composer with shivammathur/setup-php | |
uses: shivammathur/setup-php@verbose | |
with: | |
php-version: ${{ matrix.php-versions }} | |
tools: composer:2.2 | |
extensions: mbstring, xml, ctype, iconv, intl, pdo_mysql, dom, filter, gd, iconv, json | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '20.11.0' | |
npm-version: '10.2.4' | |
- name: Get composer cache directory | |
id: composer-cache | |
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_ENV | |
- name: Cache composer dependencies | |
uses: actions/cache@v4 | |
with: | |
path: | | |
${{ env.dir }} | |
./vendor | |
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} | |
restore-keys: ${{ runner.os }}-composer- | |
# INSTALL PACKAGES ---------------- | |
- name: Clean node_modules | |
run: rm -rf node_modules | |
- name: Install NPM packages | |
run: npm ci | |
- name: Install Composer dependencies | |
run: composer install --no-progress --prefer-dist --optimize-autoloader | |
# UPLOAD CACHED DIRECTORIES ---------------- | |
- name: Upload Vendor Directory as Artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: vendor-dir | |
path: vendor/ | |
- name: Upload Node Modules as Artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: node-modules-dir | |
path: node_modules/ | |
phpStan: | |
needs: setup | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v4 | |
# GET CACHED DIRECTORIES ---------------- | |
- name: Download Vendor Directory | |
uses: actions/download-artifact@v4 | |
with: | |
name: vendor-dir | |
path: vendor/ | |
# INSTALL DEPENDENCIES ---------------- | |
- name: Setup PHP, extensions and composer with shivammathur/setup-php | |
uses: shivammathur/setup-php@verbose | |
with: | |
php-version: ${{ matrix.php-versions }} | |
tools: composer:2.2 | |
extensions: mbstring, xml, ctype, iconv, intl, pdo_mysql, dom, filter, gd, iconv, json | |
- name: Set executable permissions for PHPStan | |
run: chmod +x ./vendor/bin/phpstan | |
# RUN PHPSTAN ---------------- | |
- name: Run PHPStan | |
run: ./vendor/bin/phpstan analyse src | |
symfony-tests: | |
needs: setup | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v4 | |
# GET CACHED DIRECTORIES ---------------- | |
- name: Download Vendor Directory | |
uses: actions/download-artifact@v4 | |
with: | |
name: vendor-dir | |
path: vendor/ | |
# INSTALL DEPENDENCIES ---------------- | |
- name: Install MySQL Client | |
run: sudo apt-get update && sudo apt-get install -y mysql-client | |
- name: Setup PHP, extensions and composer with shivammathur/setup-php | |
uses: shivammathur/setup-php@verbose | |
with: | |
php-version: ${{ matrix.php-versions }} | |
tools: composer:2.2 | |
extensions: mbstring, xml, ctype, iconv, intl, pdo_mysql, dom, filter, gd, iconv, json | |
# SET ENVIRONMENT VARIABLES ---------------- | |
- name: Set up test environment variables | |
run: cp .env.test .env | |
# START SERVICES ---------------- | |
- name: Set up MySQL | |
uses: getong/[email protected] | |
with: | |
host port: 3306 # Optional, default value is 3306. The port of host | |
container port: 3306 # Optional, default value is 3306. The port of container | |
character set server: 'utf8mb4' # Optional, default value is 'utf8mb4'. The '--character-set-server' option for mysqld | |
collation server: 'utf8mb4_general_ci' # Optional, default value is 'utf8mb4_general_ci'. The '--collation-server' option for mysqld | |
mariadb version: '10.4.10' # Optional, default value is "latest". The version of the MySQL | |
mysql database: 'symfony' # Optional, default value is "test". The specified database which will be created | |
mysql root password: 'secret' # Required if "mysql user" is empty, default is empty. The root superuser password | |
mysql user: 'user' # Required if "mysql root password" is empty, default is empty. The superuser for the specified database. Can use secrets, too | |
mysql password: 'password' # Required if "mysql user" exists. The password for the "mysql user" | |
- name: Wait for MySQL to become available | |
run: | | |
until mysql -h 127.0.0.1 -u root -psecret -e "SELECT 1"; do | |
echo 'Waiting for MySQL...' | |
sleep 1 | |
done | |
# RUN MIGRATIONS ---------------- | |
- name: Run migrations | |
run: php bin/console doctrine:migrations:migrate --no-interaction | |
# RUN TESTS ---------------- | |
- name: Run unit and functional tests | |
run: | | |
php ./vendor/bin/phpunit --configuration phpunit.xml.dist | |
cypress-tests: | |
needs: setup | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v4 | |
# GET CACHED DIRECTORIES ---------------- | |
- name: Download Vendor Directory | |
uses: actions/download-artifact@v4 | |
with: | |
name: vendor-dir | |
path: vendor/ | |
# - name: Download Node Modules | |
# uses: actions/download-artifact@v4 | |
# with: | |
# name: node-modules-dir | |
# path: node_modules/ | |
# INSTALL DEPENDENCIES ---------------- | |
- name: Install MySQL Client | |
run: sudo apt-get update && sudo apt-get install -y mysql-client | |
- name: Install Cypress dependencies | |
run: sudo apt-get install -y xvfb | |
- name: Setup PHP, extensions and composer with shivammathur/setup-php | |
uses: shivammathur/setup-php@verbose | |
with: | |
php-version: ${{ matrix.php-versions }} | |
tools: composer:2.2 | |
extensions: mbstring, xml, ctype, iconv, intl, pdo_mysql, dom, filter, gd, iconv, json | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '20.11.0' | |
npm-version: '10.2.4' | |
# - name: Set executable permissions for Encore | |
# run: chmod +x ./node_modules/.bin/encore | |
# SET ENVIRONMENT VARIABLES ---------------- | |
- name: Set up test environment variables | |
run: cp .env.test .env | |
# START SERVICES ---------------- | |
- name: Set up MySQL | |
uses: getong/[email protected] | |
with: | |
host port: 3306 # Optional, default value is 3306. The port of host | |
container port: 3306 # Optional, default value is 3306. The port of container | |
character set server: 'utf8mb4' # Optional, default value is 'utf8mb4'. The '--character-set-server' option for mysqld | |
collation server: 'utf8mb4_general_ci' # Optional, default value is 'utf8mb4_general_ci'. The '--collation-server' option for mysqld | |
mariadb version: '10.4.10' # Optional, default value is "latest". The version of the MySQL | |
mysql database: 'symfony' # Optional, default value is "test". The specified database which will be created | |
mysql root password: 'secret' # Required if "mysql user" is empty, default is empty. The root superuser password | |
mysql user: 'user' # Required if "mysql root password" is empty, default is empty. The superuser for the specified database. Can use secrets, too | |
mysql password: 'password' # Required if "mysql user" exists. The password for the "mysql user" | |
- name: Wait for MySQL to become available | |
run: | | |
until mysql -h 127.0.0.1 -u root -psecret -e "SELECT 1"; do | |
echo 'Waiting for MySQL...' | |
sleep 1 | |
done | |
- name: Start Symfony server | |
run: php -S localhost:8000 -t public &>/dev/null & | |
# RUN MIGRATIONS ---------------- | |
- name: Run migrations | |
run: php bin/console doctrine:migrations:migrate --no-interaction | |
# FILL DATABASE ---------------- | |
- name: Run fixture | |
run: php bin/console doctrine:fixtures:load --no-interaction | |
# BUILD FRONT ---------------- | |
- name : install packages | |
run: npm install | |
- name: Enable verbose npm logging | |
run: npm config set loglevel verbose | |
- name: Build front-end assets | |
run: ./node_modules/.bin/encore production --progress | |
# RUN CYPRESS TESTS ---------------- | |
- name: Run Cypress tests | |
run: npm run cy:run:main |