From 00c8e9140fab4701e446f45af6ad2660412f97d1 Mon Sep 17 00:00:00 2001 From: Bas Zoetekouw Date: Wed, 11 Jun 2025 16:28:19 +0200 Subject: [PATCH 01/25] indentation & quotes --- app/config/parameters.yml.dist | 2 +- tests/behat-ci.yml | 6 +++--- tests/behat.yml | 7 +++---- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/app/config/parameters.yml.dist b/app/config/parameters.yml.dist index 5604e6fd1..a152b599e 100644 --- a/app/config/parameters.yml.dist +++ b/app/config/parameters.yml.dist @@ -36,7 +36,7 @@ parameters: ## * How attributes are displayed in Profile and Consent ## * How attributes are Normalized and Denormalized ## * How attributes are validated - attribute_definition_file_path: %kernel.project_dir%/application/configs/attributes.json + attribute_definition_file_path: "%kernel.project_dir%/application/configs/attributes.json" ## The Signing / Encryption keys used for the SAML2 authentication and metadata ## When EngineBlock signs responses (when it acts as an Idp) diff --git a/tests/behat-ci.yml b/tests/behat-ci.yml index 551a4c081..daf274dcd 100644 --- a/tests/behat-ci.yml +++ b/tests/behat-ci.yml @@ -58,9 +58,9 @@ default: paths: - '%paths.base%/../src/OpenConext/EngineBlockFunctionalTestingBundle/Features' formatter: - name: pretty - parameters: - verbose: true + name: pretty + parameters: + verbose: true filters: tags: "@WIP&&~@SKIP&&~@selenium" contexts: *defaultContexts diff --git a/tests/behat.yml b/tests/behat.yml index cfa9d6fc8..f4006a77e 100644 --- a/tests/behat.yml +++ b/tests/behat.yml @@ -58,9 +58,9 @@ default: paths: - '%paths.base%/../src/OpenConext/EngineBlockFunctionalTestingBundle/Features' formatter: - name: pretty - parameters: - verbose: true + name: pretty + parameters: + verbose: true filters: tags: "@WIP&&~@SKIP&&~@selenium" contexts: *defaultContexts @@ -90,4 +90,3 @@ default: kernel: env: ci debug: true - From 3c17ce9edd5cfa7a49f0f217b04800155115127f Mon Sep 17 00:00:00 2001 From: Bas Zoetekouw Date: Wed, 11 Jun 2025 16:28:56 +0200 Subject: [PATCH 02/25] Improve error message --- src/OpenConext/EngineBlock/Stepup/StepupEndpoint.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OpenConext/EngineBlock/Stepup/StepupEndpoint.php b/src/OpenConext/EngineBlock/Stepup/StepupEndpoint.php index 3a3154f22..74bacb88b 100644 --- a/src/OpenConext/EngineBlock/Stepup/StepupEndpoint.php +++ b/src/OpenConext/EngineBlock/Stepup/StepupEndpoint.php @@ -91,7 +91,7 @@ private function validate() : void Assertion::string($this->entityId, 'stepup.gateway.sfo.entity_id should be a string'); Assertion::string($this->ssoLocation, 'stepup.gateway.sfo.sso_location should be a string'); Assertion::string($this->keyFile, 'stepup.gateway.sfo.key_file should be a string'); - Assertion::file($this->keyFile, 'stepup.gateway.sfo.key_file should be a valid file'); + Assertion::file($this->keyFile, "stepup.gateway.sfo.key_file should be a valid file, not '$this->keyFile'"); } catch (AssertionFailedException $e) { throw new InvalidStepupConfigurationException(sprintf('Invalid stepup endpoint configuration: %s', $e->getMessage())); } From 6fb504d77beba4b5224520bbe4a0cd32753f264b Mon Sep 17 00:00:00 2001 From: Bas Zoetekouw Date: Wed, 11 Jun 2025 16:30:08 +0200 Subject: [PATCH 03/25] Include phpcbf in phpcs.sh ci job --- ci/qa/phpcbf.sh | 10 ---------- ci/qa/phpcs.sh | 2 ++ 2 files changed, 2 insertions(+), 10 deletions(-) delete mode 100755 ci/qa/phpcbf.sh diff --git a/ci/qa/phpcbf.sh b/ci/qa/phpcbf.sh deleted file mode 100755 index dbd0c88c0..000000000 --- a/ci/qa/phpcbf.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env bash -set -e - -cd $(dirname $0)/../../ - -echo -e "\nPHP CodeSniffer\n" -./vendor/bin/phpcbf --standard=ci/qa-config/phpcs.xml src - -echo -e "\nPHP CodeSniffer (legacy code)\n" -./vendor/bin/phpcs --standard=ci/qa-config/phpcs-legacy.xml library diff --git a/ci/qa/phpcs.sh b/ci/qa/phpcs.sh index e3888468d..804ebd974 100755 --- a/ci/qa/phpcs.sh +++ b/ci/qa/phpcs.sh @@ -8,3 +8,5 @@ echo -e "\nPHP CodeSniffer\n" echo -e "\nPHP CodeSniffer (legacy code)\n" ./vendor/bin/phpcs --standard=ci/qa-config/phpcs-legacy.xml --warning-severity=0 --extensions=php -s library +echo "PHP CodeBeautifier" +./vendor/bin/phpcbf -p --standard=ci/qa-config/phpcs.xml src From d10a0f1ddedeecc55c40b5d58b6f6044104214f1 Mon Sep 17 00:00:00 2001 From: Bas Zoetekouw Date: Wed, 11 Jun 2025 16:30:59 +0200 Subject: [PATCH 04/25] Nice heading in qa scripts --- ci/README | 4 +++- ci/qa/behat.sh | 13 ++++++++++--- ci/qa/docheader.sh | 5 ++++- ci/qa/phpcs.sh | 18 ++++++++++++++---- ci/qa/phpmd.sh | 15 +++++++++++++-- ci/qa/phpunit.sh | 28 +++++++++++++++++++++++----- 6 files changed, 67 insertions(+), 16 deletions(-) diff --git a/ci/README b/ci/README index 36eec5757..6e285969d 100644 --- a/ci/README +++ b/ci/README @@ -1,3 +1,5 @@ Directory with helper files for our ci builds. -cpd.xsl -> makes nice html output of cpd +cpd.xsl -> makes nice html output of cpd dependencies.html -> html wrapper for pdepend output svgs + +To run all tests on local code, run ./qa/all.sh diff --git a/ci/qa/behat.sh b/ci/qa/behat.sh index d542fa36b..adcf73531 100755 --- a/ci/qa/behat.sh +++ b/ci/qa/behat.sh @@ -12,18 +12,25 @@ then exit 1 fi -echo -e "\nInstalling database fixtures...\n" +echo "=====================================================" +echo "Installing database fixtures..." +echo "=====================================================" ./app/console doctrine:schema:drop --force --env=ci ./app/console doctrine:schema:create --env=ci -echo -e "\nPreparing frontend assets\n" +echo "=====================================================" +echo "Preparing frontend assets" +echo "=====================================================" EB_THEME=skeune ./theme/scripts/prepare-test.js > /dev/null chown -R www-data app/cache/ chmod -R 0777 /tmp/eb-fixtures -echo -e "\nRun the Behat tests\n" +echo "=====================================================" +echo "Run the Behat tests" +echo "=====================================================" ./vendor/bin/behat -c ./tests/behat-ci.yml --suite default -vv --format progress --strict $@ +# TODO! #echo -e "\nBehat tests (with selenium and headless Chrome)\n" #./vendor/bin/behat -c ./tests/behat-ci.yml --suite selenium -vv --format progress --strict diff --git a/ci/qa/docheader.sh b/ci/qa/docheader.sh index 2c1958759..2a7ce6d00 100755 --- a/ci/qa/docheader.sh +++ b/ci/qa/docheader.sh @@ -3,5 +3,8 @@ set -e cd $(dirname $0)/../../ -echo -e "\nDoc header check\n" +echo "=====================================================" +echo "Doc header check" +echo "=====================================================" ./vendor/bin/docheader check src/ tests/ library/ --exclude-dir resources --exclude-dir languages +echo diff --git a/ci/qa/phpcs.sh b/ci/qa/phpcs.sh index 804ebd974..498b80a1d 100755 --- a/ci/qa/phpcs.sh +++ b/ci/qa/phpcs.sh @@ -3,10 +3,20 @@ set -e cd $(dirname $0)/../../ -echo -e "\nPHP CodeSniffer\n" -./vendor/bin/phpcs --report=full --standard=ci/qa-config/phpcs.xml --warning-severity=0 --extensions=php src +echo "=====================================================" +echo "PHP CodeSniffer" +echo "=====================================================" -echo -e "\nPHP CodeSniffer (legacy code)\n" -./vendor/bin/phpcs --standard=ci/qa-config/phpcs-legacy.xml --warning-severity=0 --extensions=php -s library +./vendor/bin/phpcs -p --report=full --standard=ci/qa-config/phpcs.xml --warning-severity=0 --extensions=php src + +echo +echo "=====================================================" +echo "PHP CodeSniffer (legacy code)" +echo "=====================================================" +./vendor/bin/phpcs -p --standard=ci/qa-config/phpcs-legacy.xml --warning-severity=0 --extensions=php -s library + +echo +echo "=====================================================" echo "PHP CodeBeautifier" +echo "=====================================================" ./vendor/bin/phpcbf -p --standard=ci/qa-config/phpcs.xml src diff --git a/ci/qa/phpmd.sh b/ci/qa/phpmd.sh index 0e78c37c2..4c68492ab 100755 --- a/ci/qa/phpmd.sh +++ b/ci/qa/phpmd.sh @@ -3,5 +3,16 @@ set -e cd $(dirname $0)/../../ -echo -e "\nPHP Mess Detector\n" -./vendor/bin/phpmd src text ci/qa-config/phpmd.xml --exclude */Tests/* +echo "=====================================================" +echo "PHP Mess Detector" +echo "=====================================================" +cmd=(./vendor/bin/phpmd src text ci/qa-config/phpmd.xml --exclude '*/Tests/*') +if "${cmd[@]}" +then + echo "No issues found" + echo + exit 0 +else + echo + exit 2 +fi diff --git a/ci/qa/phpunit.sh b/ci/qa/phpunit.sh index 9865233c2..61d0c4cf4 100755 --- a/ci/qa/phpunit.sh +++ b/ci/qa/phpunit.sh @@ -4,20 +4,38 @@ set -e cd $(dirname $0)/../../ chown -R www-data app/cache/ +mkdir -p /tmp/eb-fixtures chmod -R 0777 /tmp/eb-fixtures -echo -e "\nInstalling database fixtures...\n" +echo "=====================================================" +echo "Installing database fixtures..." +echo "=====================================================" ./app/console doctrine:schema:drop --force --env=ci ./app/console doctrine:schema:create --env=ci -echo -e "\nPHPUnit legacy tests\n" +echo +echo "=====================================================" +echo "PHPUnit legacy tests" +echo "=====================================================" ./vendor/bin/phpunit --configuration=./tests/phpunit.xml --testsuite=eb4 --coverage-text -echo -e "\nPHPUnit unit tests\n" +echo +echo "=====================================================" +echo "PHPUnit unit tests" +echo "=====================================================" ./vendor/bin/phpunit --configuration=./tests/phpunit.xml --testsuite=unit --coverage-text -echo -e "\nPHPUnit API acceptance tests\n" +echo +echo "=====================================================" +echo "PHPUnit API acceptance tests" +echo "=====================================================" APP_ENV=ci ./vendor/bin/phpunit --configuration=./tests/phpunit.xml --testsuite=functional --coverage-text -echo -e "\nPHPUnit integration tests\n" +echo +echo "=====================================================" +echo -e "PHPUnit integration tests" +echo "=====================================================" ./vendor/bin/phpunit --configuration=./tests/phpunit.xml --testsuite=integration --coverage-text +echo + + From 9bf51d7d50738a429853ba98023376e80fda9b88 Mon Sep 17 00:00:00 2001 From: Bas Zoetekouw Date: Wed, 11 Jun 2025 16:33:13 +0200 Subject: [PATCH 05/25] Fix docker scripts and allow running of integration tests in containers --- .gitignore | 1 + ci/README | 1 + docker/.env | 3 -- docker/README | 3 ++ docker/docker-compose-php72.yml | 5 ++- docker/docker-compose-php82.yml | 5 ++- docker/docker-compose.yml | 45 ++++++++++++++---------- docker/docker-runtests.sh | 23 ++++++++++++ docker/docker-setup.sh | 62 +++++++++++++++++++++++++++++++++ docker/init.sh | 5 --- 10 files changed, 120 insertions(+), 33 deletions(-) delete mode 100644 docker/.env create mode 100644 docker/README create mode 100755 docker/docker-runtests.sh create mode 100755 docker/docker-setup.sh delete mode 100755 docker/init.sh diff --git a/.gitignore b/.gitignore index 3a30032dc..d1a235725 100644 --- a/.gitignore +++ b/.gitignore @@ -27,3 +27,4 @@ local-php-security-checker /theme/**/visual-regression/screenshots/* !/theme/**/visual-regression/screenshots/.gitkeep /theme/**/__image_snapshots__ +.env diff --git a/ci/README b/ci/README index 6e285969d..ad48ced20 100644 --- a/ci/README +++ b/ci/README @@ -3,3 +3,4 @@ cpd.xsl -> makes nice html output of cpd dependencies.html -> html wrapper for pdepend output svgs To run all tests on local code, run ./qa/all.sh +To run all tests in a container, run ../docker/docker-runtests.sh diff --git a/docker/.env b/docker/.env deleted file mode 100644 index c51a1b6d6..000000000 --- a/docker/.env +++ /dev/null @@ -1,3 +0,0 @@ -UID=1000 -GID=1000 -COMPOSE_PROJECT_NAME=eb diff --git a/docker/README b/docker/README new file mode 100644 index 000000000..5dd022da3 --- /dev/null +++ b/docker/README @@ -0,0 +1,3 @@ +To start Enginblock in docker, run ./docker-setup.sh + +To run the integration tests in the container, run ./docker-runtests.sh diff --git a/docker/docker-compose-php72.yml b/docker/docker-compose-php72.yml index 9257fdf3d..eed27fce7 100644 --- a/docker/docker-compose-php72.yml +++ b/docker/docker-compose-php72.yml @@ -1,6 +1,5 @@ -version: '2.4' - +--- services: - engine.dev.openconext.local: + engine: build: dockerfile: docker/ci/Dockerfile-php72 diff --git a/docker/docker-compose-php82.yml b/docker/docker-compose-php82.yml index e5457a8d5..1317ec659 100644 --- a/docker/docker-compose-php82.yml +++ b/docker/docker-compose-php82.yml @@ -1,6 +1,5 @@ -version: '2.4' - +--- services: - engine.dev.openconext.local: + engine: build: dockerfile: docker/ci/Dockerfile-php82 diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 93270ca47..654583c8c 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -1,9 +1,8 @@ -version: '2.4' - +--- services: mariadb: - image: mariadb:10.2 + image: mariadb:10.7 restart: always container_name: eb-db-test environment: @@ -15,36 +14,43 @@ services: volumes: - eb-mysql-test-data:/var/lib/mysql healthcheck: - test: ["CMD", "mysqladmin" ,"ping", "-h", "localhost"] + test: ["CMD-SHELL", "mysqladmin --user=root --password=$${MYSQL_ROOT_PASSWORD} ping"] timeout: 2s retries: 20 interval: 2s - engine.dev.openconext.local: + engine: build: context: ../ # override this in a dedicated dockerfile per php version # dockerfile: docker/ci/Dockerfile - container_name: eb-phpfpm - volumes: - - ../:/var/www/html - - ../ci/qa-config/files/engine.dev.openconext.local.crt:/config/engine/engineblock.crt - - ../ci/qa-config/files/engine.dev.openconext.local.key:/config/engine/engineblock.pem + hostname: engine.dev.openconext.local depends_on: mariadb: condition: service_healthy environment: - APP_ENV: ci - SYMFONY_ENV: ci + APP_ENV: ci + SYMFONY_ENV: ci + APACHE_UID: "#${APACHE_UID}" + APACHE_GUID: "#${APACHE_GID}" + volumes: + - ../:/var/www/html + - ../ci/qa-config/files/engine.dev.openconext.local.crt:/config/engine/engineblock.crt + - ../ci/qa-config/files/engine.dev.openconext.local.key:/config/engine/engineblock.pem + healthcheck: + test: ["CMD-SHELL", "curl -sI http://localhost/| grep '^Server: Apache'"] + timeout: 2s + retries: 20 + interval: 5s - selenium.dev.openconext.local: + selenium: image: selenium/standalone-chrome:2.53.1 - container_name: eb-selenium - user: "${UID}:${GID}" - environment: - START_XVFB: "false" - volumes: - - /dev/shm:/dev/shm + hostname: selenium.dev.openconext.local + # NB: Selenium2 is OLD and doesn't have arm64 images; to run this on arm64, you need Rosetta enabled + platform: amd64 + shm_size: 2gb +# environment: +# START_XVFB: "false" healthcheck: test: ["CMD", "/opt/bin/check-grid.sh:", "--host", "0.0.0.0", "--port", "4444"] timeout: 30s @@ -64,3 +70,4 @@ services: volumes: eb-mysql-data: eb-mysql-test-data: + eb-engine-vendor: diff --git a/docker/docker-runtests.sh b/docker/docker-runtests.sh new file mode 100755 index 000000000..7b16931ee --- /dev/null +++ b/docker/docker-runtests.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash +set -e + +dir=$(dirname "$0") +cd "$dir" + +PHPVERSION=${PRODPHP:-72} + +docker compose \ + -f docker-compose.yml \ + -f docker-compose-php${PHPVERSION}.yml \ + up -d +echo + +if [[ $( docker compose exec -T engine \ + bash -c 'test -e /setup.txt && cat /setup.txt || echo ""' + ) != 'done' ]] +then + echo "setup.txt not found or not done. Please run $dir/docker-setup.sh" + exit 1 +fi + +docker compose exec -T engine ./ci/qa/all.sh diff --git a/docker/docker-setup.sh b/docker/docker-setup.sh new file mode 100755 index 000000000..fe8d2a7c0 --- /dev/null +++ b/docker/docker-setup.sh @@ -0,0 +1,62 @@ +#!/usr/bin/env bash +set -e + +PHPVERSION=${PRODPHP:-72} +#export COMPOSE_BAKE=true + +cd "$(dirname "$0")" + +rm -f .env +{ + echo "export APACHE_UID=$(id -u)"; + echo "export APACHE_GID=$(id -g)"; + echo "export COMPOSE_PROJECT_NAME=eb"; +} >> .env + +docker compose \ + -f docker-compose.yml \ + -f docker-compose-php${PHPVERSION}.yml \ + build --pull + +docker compose \ + -f docker-compose.yml \ + -f docker-compose-php${PHPVERSION}.yml \ + up -d + +docker compose exec -T engine bash -c ' + mkdir -p tmp vendor + git config --global --add safe.directory /var/www/html +' + +if [[ $( docker compose exec -T engine bash -c ' + test -e /setup.txt && cat /setup.txt || echo "" + ') == 'done' ]] +then + echo "setup has already run; nothing to do here" + exit 0 +fi + + +docker compose exec -T engine bash -c ' + export SYMFONY_ENV=ci + test -e ./app/config/parameters.yml && rm -v ./app/config/parameters.yml + composer install --prefer-dist -n -o --ignore-platform-reqs +' + +docker compose exec -T engine bash -c ' + ./app/console cache:clear --env=ci +' + +docker compose exec -T engine bash -c ' + cd theme + export CYPRESS_INSTALL_BINARY=0 + export EB_THEME=skeune + yarn install --frozen-lockfile + yarn build +' + +docker compose exec -T engine bash -c ' + echo done > /setup.txt +' + +exit 0 diff --git a/docker/init.sh b/docker/init.sh deleted file mode 100755 index f22bc5589..000000000 --- a/docker/init.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash -uid=33 -gid=33 - -printf "UID=${uid}\nGID=${gid}\nCOMPOSE_PROJECT_NAME=eb" >.env From 8ca646808fe8e467c8b92dce40251ee1deb8ad4d Mon Sep 17 00:00:00 2001 From: Bas Zoetekouw Date: Wed, 11 Jun 2025 16:33:41 +0200 Subject: [PATCH 06/25] Use exiting test scripts in CI runs instead of duplicating code --- .github/workflows/test-integration.yml | 85 +++----------------------- 1 file changed, 9 insertions(+), 76 deletions(-) diff --git a/.github/workflows/test-integration.yml b/.github/workflows/test-integration.yml index 16c36de77..9221beb44 100644 --- a/.github/workflows/test-integration.yml +++ b/.github/workflows/test-integration.yml @@ -1,8 +1,6 @@ name: test-integration on: push: - branches: - - main pull_request: # run at 6 hour UTC schedule: @@ -16,89 +14,24 @@ jobs: # php82 is ready to run alongside the 72, but is not enabled now as the code is not 82 compatible yet php: [ php72 ] env: - PROD_PHP: php72 - DOCKER_COMPOSE: docker compose -f docker-compose.yml -f docker-compose-${{matrix.php}}.yml + PROD_PHP: "${{matrix.php}}" steps: - name: Checkout uses: actions/checkout@master - - name: chown some dirs - run: | - mkdir tmp vendor && sudo chown -R 33 app/ theme/ web/ tmp/ vendor/ + - name: Build Docker environmnent - if: always() - run: | - cd docker && - ${DOCKER_COMPOSE} up -d --build && - docker compose exec -T --user www-data engine.dev.openconext.local bash -c ' - SYMFONY_ENV=ci composer install --prefer-dist -n -o --ignore-platform-reqs && \ - ./app/console cache:clear --env=ci && \ - cd theme && CYPRESS_INSTALL_BINARY=0 yarn install --frozen-lockfile && EB_THEME=skeune yarn build - ' - - name: Run code quality tests - if: always() - run: | - cd docker && docker compose exec -T --user www-data engine.dev.openconext.local bash -c ' - echo -e "\nPHP Mess Detector\n" && \ - ./vendor/bin/phpmd src text ci/qa-config/phpmd.xml --exclude */Tests/* && \ - echo -e "\nPHP CodeSniffer\n" && \ - ./vendor/bin/phpcs --report=full --standard=ci/qa-config/phpcs.xml --warning-severity=0 --extensions=php src && \ - echo -e "\nPHP CodeSniffer (legacy code)\n" && \ - ./vendor/bin/phpcs --standard=ci/qa-config/phpcs-legacy.xml --warning-severity=0 --extensions=php -s library && \ - echo -e "\nDoc header check\n" && \ - ./vendor/bin/docheader check src/ tests/ library/ --exclude-dir resources --exclude-dir languages - ' - env: - SYMFONY_ENV: ci - - name: Run unit tests - if: always() run: | - cd docker && APP_ENV=ci SYMFONY_ENV=ci docker compose exec -T --user www-data engine.dev.openconext.local bash -c ' - echo -e "\nInstalling database fixtures...\n" && \ - ./app/console doctrine:schema:drop --force --env=ci && \ - ./app/console doctrine:schema:create --env=ci && \ - echo -e "\nPHPUnit legacy tests\n" && \ - ./vendor/bin/phpunit --configuration=./tests/phpunit.xml --testsuite=eb4 --coverage-text && \ - echo -e "\nPHPUnit unit tests\n" && \ - ./vendor/bin/phpunit --configuration=./tests/phpunit.xml --testsuite=unit --coverage-text && \ - echo -e "\nPHPUnit API acceptance tests\n" && \ - APP_ENV=ci ./vendor/bin/phpunit --configuration=./tests/phpunit.xml --testsuite=functional --coverage-text && \ - echo -e "\nPHPUnit integration tests\n" && \ - ./vendor/bin/phpunit --configuration=./tests/phpunit.xml --testsuite=integration --coverage-text - ' - env: - SYMFONY_ENV: ci - - name: Run acceptance tests - if: always() - run: | - cd docker && docker compose exec -T --user www-data engine.dev.openconext.local bash -c ' - echo -e "\nInstalling database fixtures...\n" && \ - ./app/console doctrine:schema:drop --force --env=ci && \ - ./app/console doctrine:schema:create --env=ci && \ - echo -e "\nPreparing frontend assets\n" && \ - EB_THEME=skeune ./theme/scripts/prepare-test.js > /dev/null && \ - echo -e "\nRun the Behat tests\n" && \ - ./vendor/bin/behat -c ./tests/behat-ci.yml --suite default -vv --format progress --strict && \ - echo -e "\nBehat tests (with selenium and headless Chrome)\n" && \ - ./vendor/bin/behat -c ./tests/behat-ci.yml --suite selenium -vv --format progress --strict - ' - env: - SYMFONY_ENV: ci - - name: Run linting tests - if: always() + cd docker && ./docker-setup.sh + + - name: Run tests run: | - cd docker && docker compose exec -T --user www-data engine.dev.openconext.local bash -c ' - echo -e "\nTwig lint\n" && \ - app/console lint:twig theme/ && \ - cd theme && \ - echo -e "\nLint frontend assets\n" && \ - yarn lint - ' - env: - SYMFONY_ENV: ci + cd docker && ./docker-runtests.sh + - name: Show log on failure if: failure() run: | - cd docker && docker compose exec -T engine.dev.openconext.local cat /var/www/html/app/logs/ci/ci.log + cd docker && docker compose exec -T engine cat /var/www/html/app/logs/ci/ci.log + - name: Send notification on production build nightly build failure uses: sonots/slack-notice-action@v3 with: From 3fe0988b370f3e4023d70b76ebfc3433f1f0df5f Mon Sep 17 00:00:00 2001 From: Bas Zoetekouw Date: Wed, 11 Jun 2025 16:48:23 +0200 Subject: [PATCH 07/25] debug --- .github/workflows/test-integration.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/test-integration.yml b/.github/workflows/test-integration.yml index 9221beb44..51866156f 100644 --- a/.github/workflows/test-integration.yml +++ b/.github/workflows/test-integration.yml @@ -23,6 +23,12 @@ jobs: run: | cd docker && ./docker-setup.sh + - name: debug + run: | + docker inspect eb-engine-1 + ps aux + ls -laR app + - name: Run tests run: | cd docker && ./docker-runtests.sh From 6f7548cbe99ad43c9188c5363e2a7424f31193e9 Mon Sep 17 00:00:00 2001 From: Bas Zoetekouw Date: Thu, 12 Jun 2025 08:58:17 +0200 Subject: [PATCH 08/25] directory permissions --- docker/docker-setup.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docker/docker-setup.sh b/docker/docker-setup.sh index fe8d2a7c0..0478c22a5 100755 --- a/docker/docker-setup.sh +++ b/docker/docker-setup.sh @@ -55,6 +55,11 @@ docker compose exec -T engine bash -c ' yarn build ' +docker compose exec -T engine bash -c ' + chmod 1777 app/cache app/cache/* + chmod 1777 app/logs app/logs/* +' + docker compose exec -T engine bash -c ' echo done > /setup.txt ' From bed0639898209012082daaeb9b65207fdb790c41 Mon Sep 17 00:00:00 2001 From: Bas Zoetekouw Date: Thu, 12 Jun 2025 09:15:40 +0200 Subject: [PATCH 09/25] recursive chmod --- docker/docker-setup.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker/docker-setup.sh b/docker/docker-setup.sh index 0478c22a5..fd0c5a7b7 100755 --- a/docker/docker-setup.sh +++ b/docker/docker-setup.sh @@ -56,8 +56,8 @@ docker compose exec -T engine bash -c ' ' docker compose exec -T engine bash -c ' - chmod 1777 app/cache app/cache/* - chmod 1777 app/logs app/logs/* + chmod -R og=rwX app/cache app/cache/* + chmod -R og=rwX app/logs app/logs/* ' docker compose exec -T engine bash -c ' From aec9ea8bae4f265ee1921fab969ee4acee5a4c67 Mon Sep 17 00:00:00 2001 From: Bas Zoetekouw Date: Thu, 12 Jun 2025 09:15:45 +0200 Subject: [PATCH 10/25] debug --- .github/workflows/test-integration.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/test-integration.yml b/.github/workflows/test-integration.yml index 51866156f..40cb26521 100644 --- a/.github/workflows/test-integration.yml +++ b/.github/workflows/test-integration.yml @@ -36,6 +36,9 @@ jobs: - name: Show log on failure if: failure() run: | + docker inspect eb-engine-1 + ps aux + ls -laR app cd docker && docker compose exec -T engine cat /var/www/html/app/logs/ci/ci.log - name: Send notification on production build nightly build failure From 5d87aa3078ab832c8a6542dd20cf516db8b16e01 Mon Sep 17 00:00:00 2001 From: Bas Zoetekouw Date: Thu, 12 Jun 2025 09:49:54 +0200 Subject: [PATCH 11/25] debug --- ci/qa/phpunit.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ci/qa/phpunit.sh b/ci/qa/phpunit.sh index 61d0c4cf4..51cc752cd 100755 --- a/ci/qa/phpunit.sh +++ b/ci/qa/phpunit.sh @@ -7,12 +7,16 @@ chown -R www-data app/cache/ mkdir -p /tmp/eb-fixtures chmod -R 0777 /tmp/eb-fixtures +ls -la app/cache/ci + echo "=====================================================" echo "Installing database fixtures..." echo "=====================================================" ./app/console doctrine:schema:drop --force --env=ci ./app/console doctrine:schema:create --env=ci +ls -la app/cache/ci + echo echo "=====================================================" echo "PHPUnit legacy tests" From 992ae1bf28759b529f79ff3fd2d178d53cb1f54a Mon Sep 17 00:00:00 2001 From: Bas Zoetekouw Date: Thu, 12 Jun 2025 09:55:58 +0200 Subject: [PATCH 12/25] debug --- ci/qa/behat.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ci/qa/behat.sh b/ci/qa/behat.sh index adcf73531..89c237e3d 100755 --- a/ci/qa/behat.sh +++ b/ci/qa/behat.sh @@ -26,6 +26,9 @@ EB_THEME=skeune ./theme/scripts/prepare-test.js > /dev/null chown -R www-data app/cache/ chmod -R 0777 /tmp/eb-fixtures +ls -laR app/cache + + echo "=====================================================" echo "Run the Behat tests" echo "=====================================================" From e53c435ae871692c53cbe6eaeedc2c6b6c6230df Mon Sep 17 00:00:00 2001 From: Bas Zoetekouw Date: Thu, 12 Jun 2025 09:56:30 +0200 Subject: [PATCH 13/25] debug --- ci/qa/behat.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/ci/qa/behat.sh b/ci/qa/behat.sh index 89c237e3d..f4d2f7c92 100755 --- a/ci/qa/behat.sh +++ b/ci/qa/behat.sh @@ -26,6 +26,7 @@ EB_THEME=skeune ./theme/scripts/prepare-test.js > /dev/null chown -R www-data app/cache/ chmod -R 0777 /tmp/eb-fixtures +env ls -laR app/cache From baa9cfa771ff598bcc341e7c27d35a618ae2484c Mon Sep 17 00:00:00 2001 From: Bas Zoetekouw Date: Thu, 12 Jun 2025 12:56:51 +0200 Subject: [PATCH 14/25] Fix quotes --- ci/qa/all.sh | 2 +- ci/qa/behat.sh | 4 ++-- ci/qa/docheader.sh | 2 +- ci/qa/lint.sh | 2 +- ci/qa/phpcs.sh | 2 +- ci/qa/phpmd.sh | 2 +- ci/qa/phpunit.sh | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/ci/qa/all.sh b/ci/qa/all.sh index 972f99043..80004fe4e 100755 --- a/ci/qa/all.sh +++ b/ci/qa/all.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash set -e -cd $(dirname $0)/../../ +cd "$(dirname "$0")/../../" ./ci/qa/phpmd.sh ./ci/qa/phpcs.sh diff --git a/ci/qa/behat.sh b/ci/qa/behat.sh index f4d2f7c92..75d787ec6 100755 --- a/ci/qa/behat.sh +++ b/ci/qa/behat.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash set -e -cd $(dirname $0)/../../ +cd "$(dirname "$0")/../../" CURRENT_ENV="${SYMFONY_ENV:-dev}" @@ -33,7 +33,7 @@ ls -laR app/cache echo "=====================================================" echo "Run the Behat tests" echo "=====================================================" -./vendor/bin/behat -c ./tests/behat-ci.yml --suite default -vv --format progress --strict $@ +./vendor/bin/behat -c ./tests/behat-ci.yml --suite default -vv --format progress --strict "$@" # TODO! #echo -e "\nBehat tests (with selenium and headless Chrome)\n" diff --git a/ci/qa/docheader.sh b/ci/qa/docheader.sh index 2a7ce6d00..79eb113d9 100755 --- a/ci/qa/docheader.sh +++ b/ci/qa/docheader.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash set -e -cd $(dirname $0)/../../ +cd "$(dirname "$0")/../../" echo "=====================================================" echo "Doc header check" diff --git a/ci/qa/lint.sh b/ci/qa/lint.sh index f1f6ec23f..272961092 100755 --- a/ci/qa/lint.sh +++ b/ci/qa/lint.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash set -e -cd $(dirname $0)/../../ +cd "$(dirname "$0")/../../" echo -e "\nTwig lint\n" app/console lint:twig theme/ diff --git a/ci/qa/phpcs.sh b/ci/qa/phpcs.sh index 498b80a1d..eb42794bd 100755 --- a/ci/qa/phpcs.sh +++ b/ci/qa/phpcs.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash set -e -cd $(dirname $0)/../../ +cd "$(dirname "$0")/../../" echo "=====================================================" echo "PHP CodeSniffer" diff --git a/ci/qa/phpmd.sh b/ci/qa/phpmd.sh index 4c68492ab..2a65eb14c 100755 --- a/ci/qa/phpmd.sh +++ b/ci/qa/phpmd.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash set -e -cd $(dirname $0)/../../ +cd "$(dirname "$0")/../../" echo "=====================================================" echo "PHP Mess Detector" diff --git a/ci/qa/phpunit.sh b/ci/qa/phpunit.sh index 51cc752cd..2e3783496 100755 --- a/ci/qa/phpunit.sh +++ b/ci/qa/phpunit.sh @@ -1,13 +1,13 @@ #!/usr/bin/env bash set -e -cd $(dirname $0)/../../ chown -R www-data app/cache/ mkdir -p /tmp/eb-fixtures chmod -R 0777 /tmp/eb-fixtures ls -la app/cache/ci +cd "$(dirname "$0")/../../" echo "=====================================================" echo "Installing database fixtures..." From 9af133599602cee8a83f7664da4b1a109eb8449e Mon Sep 17 00:00:00 2001 From: Bas Zoetekouw Date: Thu, 12 Jun 2025 12:57:15 +0200 Subject: [PATCH 15/25] use long options --- docker/docker-setup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/docker-setup.sh b/docker/docker-setup.sh index fd0c5a7b7..6dcd547bb 100755 --- a/docker/docker-setup.sh +++ b/docker/docker-setup.sh @@ -40,7 +40,7 @@ fi docker compose exec -T engine bash -c ' export SYMFONY_ENV=ci test -e ./app/config/parameters.yml && rm -v ./app/config/parameters.yml - composer install --prefer-dist -n -o --ignore-platform-reqs + composer install --prefer-dist --no-interaction --optimize-autoloader --ignore-platform-reqs ' docker compose exec -T engine bash -c ' From 4c30c848ddf8114a715176f58ac6ccf4040a3631 Mon Sep 17 00:00:00 2001 From: Bas Zoetekouw Date: Thu, 12 Jun 2025 12:58:27 +0200 Subject: [PATCH 16/25] Fix permissions and users when running tests in container --- ci/qa/behat.sh | 19 +++++++++++++------ ci/qa/phpunit.sh | 8 -------- docker/docker-compose.yml | 10 ++++++++++ docker/docker-runtests.sh | 2 +- docker/docker-setup.sh | 10 ++-------- 5 files changed, 26 insertions(+), 23 deletions(-) diff --git a/ci/qa/behat.sh b/ci/qa/behat.sh index 75d787ec6..4370ccf44 100755 --- a/ci/qa/behat.sh +++ b/ci/qa/behat.sh @@ -23,12 +23,19 @@ echo "Preparing frontend assets" echo "=====================================================" EB_THEME=skeune ./theme/scripts/prepare-test.js > /dev/null -chown -R www-data app/cache/ -chmod -R 0777 /tmp/eb-fixtures - -env -ls -laR app/cache - +echo "=====================================================" +echo "Fixing file permissions" +echo "=====================================================" +# handle the case that we run this in docker +if [[ -v APACHE_UID ]] +then + # permissions handled in Dockerfile.prod + mkdir -p /tmp/eb-fixtures +else + # local use + chown -R www-data app/cache/ + chmod -R 0777 /tmp/eb-fixtures +fi echo "=====================================================" echo "Run the Behat tests" diff --git a/ci/qa/phpunit.sh b/ci/qa/phpunit.sh index 2e3783496..06d8f5ac2 100755 --- a/ci/qa/phpunit.sh +++ b/ci/qa/phpunit.sh @@ -1,12 +1,6 @@ #!/usr/bin/env bash set -e - -chown -R www-data app/cache/ -mkdir -p /tmp/eb-fixtures -chmod -R 0777 /tmp/eb-fixtures - -ls -la app/cache/ci cd "$(dirname "$0")/../../" echo "=====================================================" @@ -15,8 +9,6 @@ echo "=====================================================" ./app/console doctrine:schema:drop --force --env=ci ./app/console doctrine:schema:create --env=ci -ls -la app/cache/ci - echo echo "=====================================================" echo "PHPUnit legacy tests" diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 654583c8c..5dbd4adb9 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -37,6 +37,16 @@ services: - ../:/var/www/html - ../ci/qa-config/files/engine.dev.openconext.local.crt:/config/engine/engineblock.crt - ../ci/qa-config/files/engine.dev.openconext.local.key:/config/engine/engineblock.pem + # NB: we can't use bind mounts for these dirs, as they need to be chowned to the openconext user + - type: tmpfs + target: /var/www/html/app/cache + tmpfs: {size: "128M"} + - type: tmpfs + target: /var/www/html/app/logs + tmpfs: {size: "128M"} + - type: tmpfs + target: /tmp/ + tmpfs: {size: "128M"} healthcheck: test: ["CMD-SHELL", "curl -sI http://localhost/| grep '^Server: Apache'"] timeout: 2s diff --git a/docker/docker-runtests.sh b/docker/docker-runtests.sh index 7b16931ee..33cc9d0ea 100755 --- a/docker/docker-runtests.sh +++ b/docker/docker-runtests.sh @@ -20,4 +20,4 @@ then exit 1 fi -docker compose exec -T engine ./ci/qa/all.sh +docker compose exec -T engine su -c openconext ./ci/qa/all.sh diff --git a/docker/docker-setup.sh b/docker/docker-setup.sh index 6dcd547bb..a4f5e6a63 100755 --- a/docker/docker-setup.sh +++ b/docker/docker-setup.sh @@ -36,14 +36,13 @@ then exit 0 fi - -docker compose exec -T engine bash -c ' +docker compose exec -T engine su openconext -c ' export SYMFONY_ENV=ci test -e ./app/config/parameters.yml && rm -v ./app/config/parameters.yml composer install --prefer-dist --no-interaction --optimize-autoloader --ignore-platform-reqs ' -docker compose exec -T engine bash -c ' +docker compose exec -T engine su openconext -c ' ./app/console cache:clear --env=ci ' @@ -55,11 +54,6 @@ docker compose exec -T engine bash -c ' yarn build ' -docker compose exec -T engine bash -c ' - chmod -R og=rwX app/cache app/cache/* - chmod -R og=rwX app/logs app/logs/* -' - docker compose exec -T engine bash -c ' echo done > /setup.txt ' From a9b606c1af2f9e8467fd0f758e1ef03ba77bcb52 Mon Sep 17 00:00:00 2001 From: Bas Zoetekouw Date: Thu, 12 Jun 2025 12:58:56 +0200 Subject: [PATCH 17/25] remove unused volumes --- docker/docker-compose.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 5dbd4adb9..b310c22d1 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -78,6 +78,4 @@ services: - ../theme:/theme volumes: - eb-mysql-data: eb-mysql-test-data: - eb-engine-vendor: From cf4e564cfceb6bdfd4540894704b2818133c55a7 Mon Sep 17 00:00:00 2001 From: Bas Zoetekouw Date: Thu, 12 Jun 2025 13:02:19 +0200 Subject: [PATCH 18/25] indentation --- docker/docker-compose.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index b310c22d1..56f210927 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -38,15 +38,15 @@ services: - ../ci/qa-config/files/engine.dev.openconext.local.crt:/config/engine/engineblock.crt - ../ci/qa-config/files/engine.dev.openconext.local.key:/config/engine/engineblock.pem # NB: we can't use bind mounts for these dirs, as they need to be chowned to the openconext user - - type: tmpfs - target: /var/www/html/app/cache - tmpfs: {size: "128M"} - - type: tmpfs - target: /var/www/html/app/logs - tmpfs: {size: "128M"} - - type: tmpfs - target: /tmp/ - tmpfs: {size: "128M"} + - type: tmpfs + target: /var/www/html/app/cache + tmpfs: {size: "128M"} + - type: tmpfs + target: /var/www/html/app/logs + tmpfs: {size: "128M"} + - type: tmpfs + target: /tmp/ + tmpfs: {size: "128M"} healthcheck: test: ["CMD-SHELL", "curl -sI http://localhost/| grep '^Server: Apache'"] timeout: 2s From f44ab33ec709b7bdde6f2c1095a9ecbd537a7786 Mon Sep 17 00:00:00 2001 From: Bas Zoetekouw Date: Thu, 12 Jun 2025 13:12:05 +0200 Subject: [PATCH 19/25] small fixes --- docker/docker-runtests.sh | 4 ++-- docker/docker-setup.sh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docker/docker-runtests.sh b/docker/docker-runtests.sh index 33cc9d0ea..a7f472b04 100755 --- a/docker/docker-runtests.sh +++ b/docker/docker-runtests.sh @@ -12,7 +12,7 @@ docker compose \ up -d echo -if [[ $( docker compose exec -T engine \ +if [[ $( docker compose exec engine \ bash -c 'test -e /setup.txt && cat /setup.txt || echo ""' ) != 'done' ]] then @@ -20,4 +20,4 @@ then exit 1 fi -docker compose exec -T engine su -c openconext ./ci/qa/all.sh +docker compose exec -T engine su openconext -c ./ci/qa/all.sh diff --git a/docker/docker-setup.sh b/docker/docker-setup.sh index a4f5e6a63..56153efdf 100755 --- a/docker/docker-setup.sh +++ b/docker/docker-setup.sh @@ -54,7 +54,7 @@ docker compose exec -T engine bash -c ' yarn build ' -docker compose exec -T engine bash -c ' +docker compose exec engine bash -c ' echo done > /setup.txt ' From e1382706c8d440bcf8ecf488a419b1b1df94f1a2 Mon Sep 17 00:00:00 2001 From: Bas Zoetekouw Date: Thu, 12 Jun 2025 14:18:22 +0200 Subject: [PATCH 20/25] fix dir --- docker/docker-setup.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/docker/docker-setup.sh b/docker/docker-setup.sh index 56153efdf..c13d2f4e0 100755 --- a/docker/docker-setup.sh +++ b/docker/docker-setup.sh @@ -25,6 +25,7 @@ docker compose \ docker compose exec -T engine bash -c ' mkdir -p tmp vendor + install -d --owner=openconext --group=openconext --mode=0755 /home/openconext git config --global --add safe.directory /var/www/html ' From 57e7cab4afeb392dcabb2dd95e8ffdff0cff7dd8 Mon Sep 17 00:00:00 2001 From: Bas Zoetekouw Date: Thu, 12 Jun 2025 14:45:22 +0200 Subject: [PATCH 21/25] permissions on vendor dir in the container --- docker/docker-setup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/docker-setup.sh b/docker/docker-setup.sh index c13d2f4e0..731af0eb1 100755 --- a/docker/docker-setup.sh +++ b/docker/docker-setup.sh @@ -24,7 +24,7 @@ docker compose \ up -d docker compose exec -T engine bash -c ' - mkdir -p tmp vendor + install -d --owner=openconext --group=openconext --mode=0755 vendor install -d --owner=openconext --group=openconext --mode=0755 /home/openconext git config --global --add safe.directory /var/www/html ' From 1ab9413bba3d00d344c0a0149580ed6ae5be8c72 Mon Sep 17 00:00:00 2001 From: Bas Zoetekouw Date: Thu, 12 Jun 2025 14:51:09 +0200 Subject: [PATCH 22/25] remove debugging --- .github/workflows/test-integration.yml | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/.github/workflows/test-integration.yml b/.github/workflows/test-integration.yml index 40cb26521..570556f85 100644 --- a/.github/workflows/test-integration.yml +++ b/.github/workflows/test-integration.yml @@ -23,12 +23,6 @@ jobs: run: | cd docker && ./docker-setup.sh - - name: debug - run: | - docker inspect eb-engine-1 - ps aux - ls -laR app - - name: Run tests run: | cd docker && ./docker-runtests.sh @@ -37,8 +31,7 @@ jobs: if: failure() run: | docker inspect eb-engine-1 - ps aux - ls -laR app + compose exec -T engine ps aux cd docker && docker compose exec -T engine cat /var/www/html/app/logs/ci/ci.log - name: Send notification on production build nightly build failure From 8b131ec6cec9dbbe8750f5382cd7a94ca8f2626d Mon Sep 17 00:00:00 2001 From: Bas Zoetekouw Date: Mon, 16 Jun 2025 14:38:40 +0200 Subject: [PATCH 23/25] Cypress verscripting --- .editorconfig | 7 +++++- .github/workflows/run-cypress.yml | 31 ++++------------------- .gitignore | 2 ++ docker/docker-compose.yml | 5 ++-- docker/docker-runcypress.sh | 41 +++++++++++++++++++++++++++++++ tests/e2e/cypress.config.js | 3 ++- theme/scripts/prepare-test.js | 2 +- 7 files changed, 60 insertions(+), 31 deletions(-) create mode 100755 docker/docker-runcypress.sh diff --git a/.editorconfig b/.editorconfig index ed13b1f7c..6559c6c8e 100644 --- a/.editorconfig +++ b/.editorconfig @@ -12,4 +12,9 @@ indent_size=4 indent_style=tab [*.feature] -indent_size=2 +indent_size = 2 +tab_width = 2 + +[*.js] +indent_size = 2 +tab_width = 2 diff --git a/.github/workflows/run-cypress.yml b/.github/workflows/run-cypress.yml index 063aaada7..7aed68de4 100644 --- a/.github/workflows/run-cypress.yml +++ b/.github/workflows/run-cypress.yml @@ -21,32 +21,11 @@ jobs: steps: - name: Checkout uses: actions/checkout@master - - name: chown some dirs - run: | - mkdir tmp vendor && sudo chown -R 33 app/ theme/ web/ tmp/ vendor/ + - name: Build Docker environmnent - if: always() run: | - cd docker && - ${DOCKER_COMPOSE} up -d --build && - docker compose exec -T --user www-data engine.dev.openconext.local bash -c ' - SYMFONY_ENV=ci composer install --prefer-dist -n -o --ignore-platform-reqs && \ - ./app/console cache:clear --env=ci && \ - cd theme && CYPRESS_INSTALL_BINARY=0 yarn install --frozen-lockfile && EB_THEME=skeune yarn build - ' - - name: Run Cypress integration tests - if: always() + cd docker && ./docker-setup.sh + + - name: Build Docker environmnent run: | - cd docker && \ - docker compose exec -T --user www-data engine.dev.openconext.local bash -c ' - EB_THEME=skeune ./theme/scripts/prepare-test.js - ' && \ - docker compose exec -T cypress bash -c ' - cd e2e && yarn install && cypress run --spec cypress/integration/skeune/**/*.spec.js,cypress/integration/shared/*.spec.js --browser=chrome --headless - ' && \ - docker compose exec -T --user www-data engine.dev.openconext.local bash -c ' - EB_THEME=openconext ./theme/scripts/prepare-test.js - ' && \ - docker compose exec -T cypress bash -c ' - cd e2e && cypress run --spec cypress/integration/openconext/**/*.spec.js --browser=chrome --headless - ' + cd docker && ./docker-runcypress.sh diff --git a/.gitignore b/.gitignore index d1a235725..c0b3be489 100644 --- a/.gitignore +++ b/.gitignore @@ -27,4 +27,6 @@ local-php-security-checker /theme/**/visual-regression/screenshots/* !/theme/**/visual-regression/screenshots/.gitkeep /theme/**/__image_snapshots__ +/tests/e2e/screenshots/ .env +.DS_Store diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 56f210927..7f6950d32 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -45,8 +45,8 @@ services: target: /var/www/html/app/logs tmpfs: {size: "128M"} - type: tmpfs - target: /tmp/ - tmpfs: {size: "128M"} + target: /tmp + tmpfs: {size: "1024M"} healthcheck: test: ["CMD-SHELL", "curl -sI http://localhost/| grep '^Server: Apache'"] timeout: 2s @@ -69,6 +69,7 @@ services: cypress: image: "cypress/included:13.1.0" + platform: amd64 environment: - CYPRESS_baseUrl=https://engine.dev.openconext.local working_dir: /e2e diff --git a/docker/docker-runcypress.sh b/docker/docker-runcypress.sh new file mode 100755 index 000000000..dd8fcff7c --- /dev/null +++ b/docker/docker-runcypress.sh @@ -0,0 +1,41 @@ +#!/usr/bin/env bash +set -e + +dir=$(dirname "$0") +cd "$dir" + +PHPVERSION=${PRODPHP:-72} + +docker compose \ + -f docker-compose.yml \ + -f docker-compose-php${PHPVERSION}.yml \ + up -d +echo + +if [[ $( docker compose exec engine \ + bash -c 'test -e /setup.txt && cat /setup.txt || echo ""' + ) != 'done' ]] +then + echo "setup.txt not found or not done. Please run $dir/docker-setup.sh" + exit 1 +fi + +docker compose exec -T engine su openconext -c ' + export EB_THEME=skeune + ./theme/scripts/prepare-test.js +' + +docker compose exec -T cypress bash -c ' + cd /e2e/e2e + cypress run --browser=chrome --headless --spec "cypress/integration/skeune/**/*.spec.js,cypress/integration/shared/*.spec.js" +' + +docker compose exec -T engine su openconext -c ' + export EB_THEME=openconext + ./theme/scripts/prepare-test.js +' + +docker compose exec -T cypress bash -c ' + cd /e2e/e2e + cypress run --browser=chrome --headless --spec "cypress/integration/openconext/**/*.spec.js" +' diff --git a/tests/e2e/cypress.config.js b/tests/e2e/cypress.config.js index c3d1079b7..2ed634363 100644 --- a/tests/e2e/cypress.config.js +++ b/tests/e2e/cypress.config.js @@ -8,7 +8,8 @@ module.exports = defineConfig({ "**/__image_snapshots__/*", "**/unit-tests/**" ], - screenshotOnRunFailure: false, + screenshotOnRunFailure: true, + screenshotsFolder: "./screenshots/", setupNodeEvents: function (on, config) { const htmlvalidate = require('cypress-html-validate/plugin'); diff --git a/theme/scripts/prepare-test.js b/theme/scripts/prepare-test.js index da46d32e1..f4b25bab6 100755 --- a/theme/scripts/prepare-test.js +++ b/theme/scripts/prepare-test.js @@ -22,7 +22,7 @@ if (process.env.EB_THEME === undefined) { } try { - console.log('Running Cypress tests.\n'); + console.log('Preparing theme...\n'); const fileContents = fs.readFileSync(config, 'utf8'); const parameters = yaml.loadAll(fileContents); From c611b19011d959fd2317ea63c140c80ed53736a9 Mon Sep 17 00:00:00 2001 From: Bas Zoetekouw Date: Mon, 16 Jun 2025 15:33:12 +0200 Subject: [PATCH 24/25] permissions --- .github/workflows/run-cypress.yml | 2 +- docker/docker-setup.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/run-cypress.yml b/.github/workflows/run-cypress.yml index 7aed68de4..0b923ec7c 100644 --- a/.github/workflows/run-cypress.yml +++ b/.github/workflows/run-cypress.yml @@ -26,6 +26,6 @@ jobs: run: | cd docker && ./docker-setup.sh - - name: Build Docker environmnent + - name: Run Cypress integration tests run: | cd docker && ./docker-runcypress.sh diff --git a/docker/docker-setup.sh b/docker/docker-setup.sh index 731af0eb1..1289ba3dc 100755 --- a/docker/docker-setup.sh +++ b/docker/docker-setup.sh @@ -47,7 +47,7 @@ docker compose exec -T engine su openconext -c ' ./app/console cache:clear --env=ci ' -docker compose exec -T engine bash -c ' +docker compose exec -T engine su openconext -c ' cd theme export CYPRESS_INSTALL_BINARY=0 export EB_THEME=skeune From e05ada2365e42884df2ae368081352a19f061065 Mon Sep 17 00:00:00 2001 From: Bas Zoetekouw Date: Mon, 16 Jun 2025 15:55:15 +0200 Subject: [PATCH 25/25] Install cypress yarn stuff --- docker/docker-setup.sh | 46 ++++++++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 20 deletions(-) diff --git a/docker/docker-setup.sh b/docker/docker-setup.sh index 1289ba3dc..d4a9d6758 100755 --- a/docker/docker-setup.sh +++ b/docker/docker-setup.sh @@ -33,30 +33,36 @@ if [[ $( docker compose exec -T engine bash -c ' test -e /setup.txt && cat /setup.txt || echo "" ') == 'done' ]] then - echo "setup has already run; nothing to do here" - exit 0 -fi + echo "engine: setup has already run; nothing to do here" +else -docker compose exec -T engine su openconext -c ' - export SYMFONY_ENV=ci - test -e ./app/config/parameters.yml && rm -v ./app/config/parameters.yml - composer install --prefer-dist --no-interaction --optimize-autoloader --ignore-platform-reqs -' + docker compose exec -T engine su openconext -c ' + export SYMFONY_ENV=ci + test -e ./app/config/parameters.yml && rm -v ./app/config/parameters.yml + composer install --prefer-dist --no-interaction --optimize-autoloader --ignore-platform-reqs + ' -docker compose exec -T engine su openconext -c ' - ./app/console cache:clear --env=ci -' + docker compose exec -T engine su openconext -c ' + ./app/console cache:clear --env=ci + ' -docker compose exec -T engine su openconext -c ' - cd theme - export CYPRESS_INSTALL_BINARY=0 - export EB_THEME=skeune - yarn install --frozen-lockfile - yarn build -' + docker compose exec -T engine su openconext -c ' + cd theme + export CYPRESS_INSTALL_BINARY=0 + export EB_THEME=skeune + yarn install --frozen-lockfile + yarn build + ' -docker compose exec engine bash -c ' - echo done > /setup.txt + docker compose exec engine bash -c ' + echo done > /setup.txt + ' +fi + +docker compose exec -T cypress bash -c ' + cd e2e + yarn install ' + exit 0