diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f038f692a..193f05b4f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -86,16 +86,16 @@ jobs: echo "Starting MySQL 8" docker run --name mysql-8 -d -p 3306:3306 \ -e MYSQL_ROOT_PASSWORD=root \ - -e MYSQL_DATABASE=cmfive_test \ - -e MYSQL_USER=cmfive_test \ - -e MYSQL_PASSWORD=cmfive_test \ + -e MYSQL_DATABASE=$DB_DATABASE \ + -e MYSQL_USER=$DB_USERNAME \ + -e MYSQL_PASSWORD=$DB_PASSWORD \ --network=cmfive \ mysql:8 # Wait for MySQL to start echo "Waiting for MySQL to start" time=0 - while ! docker exec mysql-8 mysqladmin ping -ucmfive_test -pcmfive_test --silent; do + while ! docker exec mysql-8 mysqladmin ping -u$DB_USERNAME -p$DB_PASSWORD --silent; do sleep 1 time=$((time+1)) if [ $time -gt 60 ]; then @@ -118,10 +118,11 @@ jobs: -v ${{ github.workspace }}/boilerplate/test:/var/www/html/test:rw \ -v ${{ github.workspace }}/boilerplate/storage:/var/www/html/storage:rw \ -e DB_HOST=mysql-8 \ - -e DB_USERNAME=cmfive_test \ - -e DB_PASSWORD=cmfive_test \ - -e DB_DATABASE=cmfive_test \ + -e DB_USERNAME=$DB_USERNAME \ + -e DB_PASSWORD=$DB_PASSWORD \ + -e DB_DATABASE=$DB_DATABASE \ -e CMFIVE_CORE_BRANCH=$CORE_BRANCH \ + -e ENVIRONMENT=development \ --network=cmfive \ $BOILERPLATE_IMAGE # Note: system is mounted to a volume to avoid conflicts with the symlink @@ -165,28 +166,20 @@ jobs: # Write extra config to cmfive container docker exec -t cmfive sh -c "echo \"$CONFIG\" >> /var/www/html/config.php" - - name: Prepare cmfive Test Backend + - name: Install dev tools + env: + CONTAINER: cmfive run: | - # Install packages required for the tests - docker exec -u root -t cmfive sh -c \ - "apk add --no-cache php81-dom php81-xmlwriter php81-tokenizer php81-ctype mysql-client mariadb-connector-c-dev"; - - # Install phpunit 8 - docker exec -u root cmfive sh -c \ - "cd /usr/local/bin && curl -L https://phar.phpunit.de/phpunit-8.phar -o phpunit && chmod +x phpunit && chmod 777 ."; - - # Change owner of the test directory - docker exec -u root -t cmfive sh -c \ - "chown -R cmfive:cmfive /var/www/html/test"; - - # Install Codeception - docker exec -u cmfive cmfive sh -c \ - "cd /var/www/html/test/ && sh ./.install/install.sh" + if [ -f ./boilerplate/.codepipeline/docker/install_dev_tools.sh ]; then + ./boilerplate/.codepipeline/docker/install_dev_tools.sh + else + echo "⚠️ WARNING: could not find dev tools in boilerplate" + fi - name: Prepare cmfive Test DB run: | - docker exec -t cmfive sh -c "DB_HOST=mysql-8 DB_USERNAME=root DB_PASSWORD=root DB_DATABASE=cmfive_test DB_PORT=3306 php cmfive.php testDB setup; exit \$?"; - + docker exec -t cmfive sh -c "DB_HOST=mysql-8 DB_USERNAME=root DB_PASSWORD=root DB_DATABASE=$DB_DATABASE DB_PORT=3306 php cmfive.php testDB setup; exit \$?"; + # Build new layout - uses: actions/setup-node@v4 with: @@ -196,7 +189,7 @@ jobs: - name: "Run unit tests" run: | docker exec -u root cmfive chmod -R ugo=rwX /var/www/html/test/ - docker exec -u cmfive cmfive sh -c "DB_HOST=mysql-8 DB_USERNAME=cmfive_test DB_PASSWORD=cmfive_test DB_DATABASE=cmfive_test DB_PORT=3306 php cmfive.php tests unit all; exit \$?" + docker exec -u cmfive cmfive sh -c "DB_HOST=mysql-8 DB_USERNAME=$DB_USERNAME DB_PASSWORD=$DB_PASSWORD DB_DATABASE=$DB_DATABASE DB_PORT=3306 php cmfive.php tests unit all; exit \$?" if [ $? -gt 0 ]; then echo "Admin module tests failed" fi @@ -207,10 +200,6 @@ jobs: cd boilerplate/test/playwright npm ci npx playwright install --with-deps - # Run Acceptance Tests - - name: "Confirm Codeception setup" - run: | - docker exec cmfive sh -c "ls -lah -R /var/www/html/test/Codeception/tests && cat /var/www/html/test/Codeception/*.yml && cat /var/www/html/test/Codeception/tests/*.yml" - name: "Run admin module tests" run: | @@ -269,11 +258,11 @@ jobs: if [ $? -gt 0 ]; then echo "Timelog module tests failed" fi - + - name: Get container logs if: ${{ failure() }} || ${{ success() }} run: | - docker logs cmfive | tee container.log + docker logs cmfive | sudo tee cmfive_container.log - name: Stop containers # the containers should be stopped regardless of @@ -295,6 +284,6 @@ jobs: boilerplate/storage/log/ boilerplate/test/playwright/test-results/ boilerplate/test/playwright/playwright-report/ - container.log + cmfive_container.log retention-days: 5