diff --git a/.env.oidc b/.env.oidc index dc4d045f2..1c9a94cc6 100644 --- a/.env.oidc +++ b/.env.oidc @@ -7,6 +7,7 @@ PHP_SERVICE_NAME='php7.4-fpm' ###> symfony/framework-bundle ### SYMFONY_DEPRECATIONS_HELPER=999999 APP_ENV=dev +APP_SECRET=ThisTokenIsNotSoSecretChangeIt #TRUSTED_PROXIES=127.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16 #TRUSTED_HOSTS='^(localhost|example\.com)$' ###< symfony/framework-bundle ### diff --git a/.env.oidc.test b/.env.oidc.test new file mode 100644 index 000000000..f9cf7238d --- /dev/null +++ b/.env.oidc.test @@ -0,0 +1,228 @@ +# This is used with the github ci + + +SYMFONY_ENV='test' +APP_SECRET='$ecretf0rt3st' +PHP_USER='www-data' +PHP_IDE_CONFIG='serverName=membres.yourcoop.local' +PHP_MEMORY_LIMIT=512M +PHP_SERVICE_NAME='php7.4-fpm' +###> symfony/framework-bundle ### +SYMFONY_DEPRECATIONS_HELPER=999999 +APP_ENV=test +#TRUSTED_PROXIES=127.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16 +#TRUSTED_HOSTS='^(localhost|example\.com)$' +###< symfony/framework-bundle ### + +###> doctrine/doctrine-bundle ### +DATABASE_URL="mysql://root:secret@127.0.0.1:3306/symfony?serverVersion=5.7&charset=utf8" +###< doctrine/doctrine-bundle ### + +###> symfony/swiftmailer-bundle ### +# For Gmail as a transport, use: "gmail://username:password@localhost" +# For a generic SMTP server, use: "smtp://localhost:25?encryption=&auth_mode=" +# Delivery is disabled by default via "null://localhost" +MAILER_URL=null://localhost +###< symfony/swiftmailer-bundle ### + +# SUPER_ADMIN User +SUPER_ADMIN_USERNAME=admin +SUPER_ADMIN_INITIAL_PASSWORD=password + +# Mailer Configuration +MAILER_TRANSPORT=smtp +MAILER_HOST=mailcatcher +MAILER_PORT=1025 +MAILER_USER=null +MAILER_PASSWORD=null +MAILER_ENCRYPTION=null + +# Transactional Mailer User +TRANSACTIONAL_MAILER_USER=contact@yourcoop.local +TRANSACTIONAL_MAILER_USER_NAME='espace membre' + +# Base Domain for Emails +EMAILS_BASE_DOMAIN=yourcoop.local + +# Email Addresses +EMAILS_CONTACT_NAME='Contact Localcoop' +EMAILS_CONTACT_ADDRESS=contact@yourcoop.local +EMAILS_MEMBER_NAME='Membres Localcoop' +EMAILS_MEMBER_ADDRESS=membres@yourcoop.local +EMAILS_SHIFT_NAME='Créneaux Localcoop' +EMAILS_SHIFT_ADDRESS=creneaux@yourcoop.local +EMAILS_FORMATION_NAME='Formation Localcoop' +EMAILS_FORMATION_ADDRESS=formations@yourcoop.local +EMAILS_ADMIN_NAME='Admin Localcoop' +EMAILS_ADMIN_ADDRESS=admin@yourcoop.local +EMAILS_NOREPLY_NAME='Ne pas répondre' +EMAILS_NOREPLY_ADDRESS=noreply@yourcoop.local + +# Router Configuration +ROUTER_REQUEST_CONTEXT_HOST=membres.yourcoop.local +ROUTER_REQUEST_CONTEXT_SCHEME=https +ROUTER_REQUEST_CONTEXT_BASE_URL= + +# Security: IP check +ENABLE_PLACE_LOCAL_IP_ADDRESS_CHECK=true +PLACE_LOCAL_IP_ADDRESS='127.0.0.1,192.168.0.x' + +# Branding +SITE_NAME="Espace membre @ MyLocalCoop" +PROJECT_NAME="My Local Coop" +PROJECT_URL=https://yourcoop.local/ +PROJECT_URL_DISPLAY=yourcoop.local +MAIN_COLOR=#51CAE9 +LOCAL_CURRENCY_NAME="monnaie locale" + +# Registration +REGISTRATION_DURATION='1 year' +REGISTRATION_EVERY_CIVIL_YEAR=false +REGISTRATION_MANUAL_ENABLED=true +HELLOASSO_REGISTRATION_CAMPAIGN_URL=https://www.helloasso.com/associations/my-local-coop/adhesions/re-adhesion +HELLOASSO_API_KEY= +HELLOASSO_API_PASSWORD= +HELLOASSO_API_BASE_URL=https://api.helloasso.com/v3/ + +# Shifting Configuration +DUE_DURATION_BY_CYCLE=180 +MIN_SHIFT_DURATION=90 +CYCLE_DURATION='28 days' +CYCLE_TYPE=abcd +NEW_USERS_START_AS_BEGINNER=true +ALLOW_EXTRA_SHIFTS=true +MAX_TIME_IN_ADVANCE_TO_BOOK_EXTRA_SHIFTS='3 days' +TIME_AFTER_WHICH_MEMBERS_ARE_LATE_WITH_SHIFTS=-9 +RESERVE_NEW_SHIFT_TO_PRIOR_SHIFTER=true +RESERVE_NEW_SHIFT_TO_PRIOR_SHIFTER_DELAY=7 +FORBID_SHIFT_OVERLAP_TIME=30 +MAX_TIME_AT_END_OF_SHIFT=0 +DISPLAY_NAME_SHIFTERS=false + +# shift fly and fixed +USE_FLY_AND_FIXED=false +FLY_AND_FIXED_ENTITY_FLYING=Beneficiary +FLY_AND_FIXED_ALLOW_FIXED_SHIFT_FREE=false + +# Swipe card +USE_CARD_READER_TO_VALIDATE_SHIFTS=false +SWIPE_CARD_LOGGING=true +SWIPE_CARD_LOGGING_ANONYMOUS=true +DISPLAY_SWIPE_CARDS_SETTINGS=true + +# Shifting: time log saving +USE_TIME_LOG_SAVING=false +TIME_LOG_SAVING_SHIFT_FREE_MIN_TIME_IN_ADVANCE_DAYS=null +TIME_LOG_SAVING_SHIFT_FREE_ALLOW_ONLY_IF_ENOUGH_SAVING=false + +# Profile Configuration +DISPLAY_GAUGE=true +PROFILE_DISPLAY_TASK_LIST=true +PROFILE_DISPLAY_TIME_LOG=true +PROFILE_DISPLAY_SHIFT_FREE_LOG=true +PROFILE_DISPLAY_PERIOD_POSITION_FREE_LOG=true +DISPLAY_FREEZE_ACCOUNT=true +DISPLAY_FREEZE_ACCOUNT_FALSE_MESSAGE="Le gel de compte n'est pas autorisé." +MAX_NB_OF_PAST_CYCLES_TO_DISPLAY=3 + +# User Configuration +USER_ACCOUNT_NOT_ENABLED_MATERIAL_ICON=phonelink_off +USER_ACCOUNT_ENABLED_ICON=☑ +USER_ACCOUNT_ENABLED_MATERIAL_ICON=devices + +# Member Configuration +MAXIMUM_NB_OF_BENEFICIARIES_IN_MEMBERSHIP=2 +MEMBER_WITHDRAWN_ICON=∅ +MEMBER_WITHDRAWN_MATERIAL_ICON=block +MEMBER_WITHDRAWN_BACKGROUND_COLOR='rgba(255, 50, 0, 0.2)' +MEMBER_FROZEN_ICON=❄️ +MEMBER_FROZEN_MATERIAL_ICON=ac_unit +MEMBER_FROZEN_BACKGROUND_COLOR='rgba(0, 138, 255, 0.1)' +MEMBER_EXEMPTED_ICON=☂ +MEMBER_EXEMPTED_MATERIAL_ICON=beach_access +MEMBER_EXEMPTED_BACKGROUND_COLOR='rgb(0, 150, 136, 0.1)' +MEMBER_FLYING_ICON=✈ +MEMBER_FLYING_MATERIAL_ICON=flightsmode +MEMBER_REGISTRATION_MISSING_ICON=$ +MEMBER_REGISTRATION_MISSING_MATERIAL_ICON=attach_money +MEMBER_REGISTRATION_MISSING_BACKGROUND_COLOR='rgb(0, 150, 136, 0.1)' + +# Beneficiary Configuration +BENEFICIARY_MAIN_ICON=⚐ +BENEFICIARY_NEW_ICON=★ +BENEFICIARY_FLYING_ICON=✈ + +# Admin: Member +ADMIN_MEMBER_DISPLAY_SHIFT_FREE_LOG=true +ADMIN_MEMBER_DISPLAY_PERIOD_POSITION_FREE_LOG=true +FORBID_OWN_SHIFT_BOOK_ADMIN=false +FORBID_OWN_SHIFT_FREE_ADMIN=false +FORBID_OWN_SHIFT_VALIDATE_ADMIN=false +FORBID_OWN_TIMELOG_NEW_ADMIN=false + +# Events +MAX_EVENT_PROXY_PER_MEMBER=1 + +# Opening Hours +DISPLAY_OPENING_HOUR_OPEN_CLOSED_HEADER=true +OPENING_HOUR_OPEN_CLOSED_HEADER_OPEN_MESSAGE="Ouvert" +OPENING_HOUR_OPEN_CLOSED_HEADER_CLOSED_MESSAGE="Fermé" + +# Code Generation +CODE_GENERATION_ENABLED=true +DISPLAY_KEYS_SHOP=true +WIKI_KEYS_URL= + +# Logging +LOGGING_MATTERMOST_ENABLED=false +LOGGING_MATTERMOST_LEVEL=critical +LOGGING_MATTERMOST_URL=http://mattermost.yourcoop.local +LOGGING_SWIFTMAILER_ENABLED=false +LOGGING_SWIFTMAILER_LEVEL=critical +LOGGING_SWIFTMAILER_RECIPIENT=email@example.com +LOGGING_MATTERMOST_CHANNEL=elefan + +# Open ID Client +OIDC_ENABLE=true +OIDC_PROFILE_CUSTOM_MESSAGE='vos informations personnelles sont éditables ici ' +OIDC_NO_ACCOUNT_MESSAGE="Vous n\'avez pas de compte. Veuillez contacter le support." +OIDC_ISSUER=http://keycloak:8080/auth +OIDC_REALM=elefan +OIDC_CLIENT_ID=elefan +OIDC_CLIENT_SECRET=secret +OIDC_ROLES_CLAIM=groups + +# OIDC User Attributes Map +OIDC_USER_ATTRIBUTE_FIRSTNAME=firstName +OIDC_USER_ATTRIBUTE_LASTNAME=lastName +OIDC_USER_ATTRIBUTE_MEMBER_NUMBER=member_number +OIDC_USER_ATTRIBUTE_EMAIL=email +OIDC_USER_ATTRIBUTE_PHONE=phone +OIDC_USER_ATTRIBUTE_FLYING=flying +OIDC_USER_ATTRIBUTE_ADDRESS_STREET1=address.street1 +OIDC_USER_ATTRIBUTE_ADDRESS_STREET2=address.street2 +OIDC_USER_ATTRIBUTE_ADDRESS_ZIPCODE=address.zipcode +OIDC_USER_ATTRIBUTE_ADDRESS_CITY=address.city +OIDC_USER_ATTRIBUTE_CO_MEMBER_NUMBER=co_member_number + +# OIDC Roles Map +OIDC_ROLE_USER=/cooperate +OIDC_ROLE_ADMIN_PANEL=/infrastructure/informatique/elefan/admin +OIDC_ROLE_USER_VIEWER=/infrastructure/informatique/elefan/admin +OIDC_ROLE_USER_MANAGER=/infrastructure/informatique/elefan/admin +OIDC_ROLE_SHIFT_MANAGER=/infrastructure/informatique/elefan/admin +OIDC_ROLE_FINANCE_MANAGER=/infrastructure/informatique/elefan/admin +OIDC_ROLE_PROCESS_MANAGER=/infrastructure/informatique/elefan/admin +OIDC_ROLE_ADMIN=/infrastructure/informatique/elefan/admin +OIDC_ROLE_SUPER_ADMIN=/infrastructure/informatique/elefan/super_admin +OIDC_ROLE_OAUTH_LOGIN= + +OIDC_FORMATIONS_CLAIM=groups + +# OIDC Formations Map in JSON +OIDC_FORMATIONS_MAP='{"Accueil magasin": "/infrastructure/informatique/elefan/formations/accueil_magasin", "Caisse": "/infrastructure/informatique/elefan/formations/caisse"}' + +OIDC_COMMISSIONS_CLAIM=groups + +# OIDC Commissions Map in JSON +OIDC_COMMISSIONS_MAP='{"foo": "/grouvernance/foo", "bar": "/grouvernance/bar"}' diff --git a/.env.test b/.env.test index ef4a0afe6..d70e2d911 100644 --- a/.env.test +++ b/.env.test @@ -1,19 +1,21 @@ -SYMFONY_ENV='dev' +# This is used with the github ci + + +APP_ENV=test +SYMFONY_ENV='test' APP_SECRET='$ecretf0rt3st' PHP_USER='www-data' -PHP_IDE_CONFIG='serverName=membres.yourcoop.local' +PHP_IDE_CONFIG='serverName=localhost' PHP_MEMORY_LIMIT=512M PHP_SERVICE_NAME='php7.4-fpm' ###> symfony/framework-bundle ### SYMFONY_DEPRECATIONS_HELPER=999999 -APP_ENV=dev #TRUSTED_PROXIES=127.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16 #TRUSTED_HOSTS='^(localhost|example\.com)$' ###< symfony/framework-bundle ### ###> doctrine/doctrine-bundle ### -DATABASE_URL="mysql://root:secret@database:3306/symfony?serverVersion=5.7&charset=utf8" -DATABASE_TEST_HOST=127.0.0.1 +DATABASE_URL="mysql://root:secret@127.0.0.1:3306/symfony?serverVersion=5.7&charset=utf8" ###< doctrine/doctrine-bundle ### ###> symfony/swiftmailer-bundle ### @@ -57,8 +59,8 @@ EMAILS_NOREPLY_NAME='Ne pas répondre' EMAILS_NOREPLY_ADDRESS=noreply@yourcoop.local # Router Configuration -ROUTER_REQUEST_CONTEXT_HOST=membres.yourcoop.local -ROUTER_REQUEST_CONTEXT_SCHEME=https +ROUTER_REQUEST_CONTEXT_HOST=localhost +ROUTER_REQUEST_CONTEXT_SCHEME=http ROUTER_REQUEST_CONTEXT_BASE_URL= # Security: IP check diff --git a/.github/workflows/ci-test.yaml b/.github/workflows/ci-test.yaml new file mode 100644 index 000000000..1190f7ea9 --- /dev/null +++ b/.github/workflows/ci-test.yaml @@ -0,0 +1,116 @@ +name: Integration and Functional + +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' + + - 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- + + - name: Install Composer dependencies + run: composer install --no-progress --prefer-dist --optimize-autoloader + + # 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 + + # SET ENVIRONMENT VARIABLES ---------------- +# - name: Set up test environment variables +# run: cp .env.test .env + + # START SERVICES ---------------- +# - name: Set up MySQL +# uses: getong/mariadb-action@v1.1 +# 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: Enable verbose npm logging + run: npm config set loglevel verbose + + - name: Install dependencies + run: npm install + + - 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 \ No newline at end of file diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 0b17fad87..c8f1ec503 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -2,26 +2,135 @@ name: Integration and Functional tests on: pull_request: - branches: [ master ] + branches: + - master + - staging + - dev jobs: - symfony: - name: main - # https://hub.docker.com/_/ubuntu/ - runs-on: ubuntu-20.04 + setup: + runs-on: ubuntu-22.04 strategy: fail-fast: true matrix: php-versions: ['7.4'] steps: -# # clean ( for local debug ) -# - name: Remove all mysql containers -# run: docker rm -f $(docker ps -a -q --filter ancestor=mariadb:10.4.10) +# 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@v3 + 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' + + - 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/ + + 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 - # Start database service +# SET ENVIRONMENT VARIABLES ---------------- + - name: Set up test environment variables + run: cp .env.test .env + +# START SERVICES ---------------- - name: Set up MySQL uses: getong/mariadb-action@v1.1 with: @@ -35,10 +144,43 @@ jobs: 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/ + +# INSTALL DEPENDENCIES ---------------- - name: Install MySQL Client run: sudo apt-get update && sudo apt-get install -y mysql-client - # https://github.com/shivammathur/setup-php (community) + - name: Install Cypress dependencies + run: sudo apt-get install -y xvfb libgtk2.0-0 libgtk-3-0 libgbm-dev libnotify-dev libnss3 libxss1 libasound2 libxtst6 xauth + - name: Setup PHP, extensions and composer with shivammathur/setup-php uses: shivammathur/setup-php@verbose with: @@ -46,33 +188,63 @@ jobs: tools: composer:2.2 extensions: mbstring, xml, ctype, iconv, intl, pdo_mysql, dom, filter, gd, iconv, json - # Composer - - name: Get composer cache directory - id: composer-cache - run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_ENV + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '20.11.0' - - name: Cache composer dependencies - uses: actions/cache@v3 + - name: Install Symfony CLI globally + run: | + curl -sS https://get.symfony.com/cli/installer | bash + sudo mv /home/runner/.symfony5/bin/symfony /usr/local/bin/symfony + + +# SET ENVIRONMENT VARIABLES ---------------- + - name: Set up test environment variables + run: cp .env.test .env + +# START SERVICES ---------------- + - name: Set up MySQL + uses: getong/mariadb-action@v1.1 with: - path: | - ${{ env.dir }} - ./vendor - key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} - restore-keys: ${{ runner.os }}-composer- + 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: Install Composer dependencies - run: composer install --no-progress --prefer-dist --optimize-autoloader + - 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 - # PHPStan finds bugs in your code without writing tests - # https://github.com/phpstan/phpstan - - name: Run PHPStan code scan - run: vendor/bin/phpstan analyse src + - name: Start Symfony server + run: symfony server:start --no-tls -d --port=8000 - # Create database +# RUN MIGRATIONS ---------------- - name: Run migrations - run: php bin/console doctrine:migrations:migrate --no-interaction --env=test + run: php bin/console doctrine:migrations:migrate --no-interaction - # Tests - - name: Run unit and functional tests - run: | - php ./vendor/bin/phpunit --configuration phpunit.xml.dist +# 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:test:main \ No newline at end of file diff --git a/config/packages/test/doctrine.yaml b/config/packages/test/doctrine.yaml deleted file mode 100644 index 6dbee844d..000000000 --- a/config/packages/test/doctrine.yaml +++ /dev/null @@ -1,3 +0,0 @@ -doctrine: - dbal: - host: '%env(DATABASE_TEST_HOST)%' \ No newline at end of file diff --git a/config/packages/test/framework.yaml b/config/packages/test/framework.yaml index 2ee7eb4a7..5094c6d28 100644 --- a/config/packages/test/framework.yaml +++ b/config/packages/test/framework.yaml @@ -1,2 +1,4 @@ framework: test: true + session: + cookie_domain: "localhost" diff --git a/config/packages/test/monolog.yaml b/config/packages/test/monolog.yaml index 82548da1e..71cd1ed26 100644 --- a/config/packages/test/monolog.yaml +++ b/config/packages/test/monolog.yaml @@ -5,16 +5,16 @@ monolog: path: '%kernel.logs_dir%/%kernel.environment%.log' level: debug channels: ['!event'] - mattermost: - type: slackwebhook - webhook_url: "%logging.mattermost.url%" - channel: '%logging.mattermost.channel%' - bot_name: 'Monolog' - use_attachment: true, - icon_emoji: '' - use_short_attachment: true - include_extra: true - level: '%logging.mattermost.level%' +# mattermost: +# type: slackwebhook +# webhook_url: "%logging.mattermost.url%" +# channel: '%logging.mattermost.channel%' +# bot_name: 'Monolog' +# use_attachment: true, +# icon_emoji: '' +# use_short_attachment: true +# include_extra: true +# level: '%logging.mattermost.level%' console: type: console process_psr_3_messages: false diff --git a/cypress/e2e/keycloak/admin/admin1_can_login.cy.js b/cypress/e2e/keycloak/admin/admin1_can_login.cy.js index 7f526f03d..a7a5ab867 100644 --- a/cypress/e2e/keycloak/admin/admin1_can_login.cy.js +++ b/cypress/e2e/keycloak/admin/admin1_can_login.cy.js @@ -23,7 +23,7 @@ describe('admin1 can login', function () { cy.get('[data-cy=open_my_informations]').click() cy.log('check if role_admin in the page') - cy.get('[data-cy=user_roles_container]').contains('role_admin') + cy.get('[data-cy=user_roles_container]').contains('ROLE_ADMIN', {timeout: 2000}) }) }) diff --git a/cypress/e2e/login/super_admin/super_admin_can_login.cy.js b/cypress/e2e/login/super_admin/super_admin_can_login.cy.js index 6b8ec0c5b..fa3b84f90 100644 --- a/cypress/e2e/login/super_admin/super_admin_can_login.cy.js +++ b/cypress/e2e/login/super_admin/super_admin_can_login.cy.js @@ -19,7 +19,7 @@ describe('super admin can login', function () { cy.get('[data-cy=open_my_informations]').click() cy.log('check if role_admin in the page') - cy.get('[data-cy=user_roles_container]').contains('role_super_admin') + cy.get('[data-cy=user_roles_container]').contains('ROLE_SUPER_ADMIN', {timeout: 2000}) }) diff --git a/package.json b/package.json index e07b088b8..3e4d840c4 100644 --- a/package.json +++ b/package.json @@ -32,9 +32,10 @@ "dev-server": "encore dev-server --disable-host-check", "dev": "encore dev", "watch": "encore dev --watch", - "build": "encore production --progress", - "cy:run:oidc": "cypress run --env configFile=oidc --spec 'cypress/e2e/oidc/*'", - "cy:run:cookie": "cypress run --env configFile=test --spec 'cypress/e2e/cookie/*'" + "build": "npx encore production --progress", + "cy:open": "cypress open", + "cy:test:oidc": "CYPRESS_BASE_URL=http://127.0.0.1:8000 cypress run --spec 'cypress/e2e/oidc/*'", + "cy:test:main": "CYPRESS_BASE_URL=http://localhost:8000 cypress run --spec 'cypress/e2e/login/**/*'" }, "repository": { "type": "git",