CI #746
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: CI | |
on: | |
push: | |
branches: [ develop ] | |
pull_request: | |
branches: [ develop, master ] | |
workflow_dispatch: | |
env: | |
TARGET_PHP: 8.1 | |
TARGET_MYSQL: 8 | |
DB_HOST: mysql-8 | |
DB_PORT: 3306 | |
DB_USERNAME: cmfive_test | |
DB_PASSWORD: cmfive_test | |
DB_DATABASE: cmfive_test | |
PLAYWRIGHT_MODULES: "admin channel form tag report task timelog" | |
jobs: | |
# Lint | |
php-codesniffer74: | |
name: PHP CS 7.4 | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Get phpcs | |
run: wget https://raw.githubusercontent.com/2pisoftware/cmfive-boilerplate/master/phpcs.xml | |
- name: Codesniffer | |
uses: pipeline-components/[email protected] | |
with: | |
options: -s -p --colors --extensions=php --runtime-set testVersion 7.4 | |
php-codesniffer80: | |
name: PHP CS 8.0 | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Get phpcs | |
run: wget https://raw.githubusercontent.com/2pisoftware/cmfive-boilerplate/master/phpcs.xml | |
- name: Codesniffer | |
uses: pipeline-components/[email protected] | |
with: | |
options: -s -p --colors --extensions=php --runtime-set testVersion 8.0 | |
php-codesniffer81: | |
name: PHP CS 8.1 | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Get phpcs | |
run: wget https://raw.githubusercontent.com/2pisoftware/cmfive-boilerplate/master/phpcs.xml | |
- name: Codesniffer | |
uses: pipeline-components/[email protected] | |
with: | |
options: -s -p --colors --extensions=php --runtime-set testVersion 8.1 | |
# Test | |
run_test: | |
# Checkout Boilerplate | |
name: Unit/Acceptance tests | |
runs-on: ubuntu-22.04 | |
needs: [ php-codesniffer74, php-codesniffer80, php-codesniffer81 ] | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
repository: '2pisoftware/cmfive-boilerplate' | |
ref: 'develop' | |
# Pre-requisites Prepare Cmfive Environment | |
- name: Start containers | |
run: | | |
cp .codepipeline/test_agent/configs/test_agent-config.php config.php | |
docker compose -f docker-compose.yml up --build -d --wait --wait-timeout 120 | |
# Pre-requisites Prepare Cmfive Environment | |
- name: Setup cmfive Test Environment | |
run: | | |
echo DBCreate | |
docker exec -t mysql-8 bash -c "mysql -h 127.0.0.1 -u'root' -p'root' --execute \"CREATE DATABASE cmfive_test; CREATE USER cmfive_test@'%' IDENTIFIED BY 'cmfive_test'; GRANT ALL PRIVILEGES ON cmfive_test.* TO cmfive_test@'%'; GRANT PROCESS ON *.* TO cmfive_test@'%'; FLUSH PRIVILEGES;\"" | |
docker exec -t cmfive bash -c "chmod -R 777 ./*" | |
- name: Inject configs into cmfive Test Environment | |
run: | | |
echo "Inheriting test_agent config from PIPELINE" | |
echo 'Config::append("tests", ["testrunner" => "ENABLED"]);' >> config.php | |
- name: Prepare cmfive Test Backend | |
run: | | |
docker exec cmfive bash -c "cd ./test/ && sh ./.install/install.sh && chmod -R 777 /var/www/html/test/Codeception/tests" | |
- name: Prepare cmfive Test DB | |
run: | | |
docker exec -t cmfive bash -c "DB_HOST=mysql-8 DB_USERNAME=cmfive_test DB_PASSWORD=cmfive_test DB_DATABASE=cmfive_test DB_PORT=3306 php cmfive.php testDB setup; exit \$?"; | |
# Build new layout | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 18 | |
# Run Unit Tests | |
- name: "Run unit tests" | |
run: | | |
docker exec cmfive bash -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 \$?" | |
if [ $? -gt 0 ]; then | |
echo "Admin module tests failed" | |
fi | |
# Setup playwright | |
- name: Setup Playwright | |
run: | | |
cd test/playwright | |
npm ci | |
npx playwright install --with-deps | |
# Run Acceptance Tests | |
- name: "Confirm Codeception setup" | |
run: | | |
docker exec cmfive bash -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: | | |
sudo chmod 777 -R system/modules/admin/install/migrations/ | |
cd test/playwright | |
npm run build | |
npm run test --module="admin" --reporter="github" | |
if [ $? -gt 0 ]; then | |
echo "Admin module tests failed" | |
fi | |
- name: "Run channel module tests" | |
run: | | |
cd test/playwright | |
npm run build | |
npm run test --module="channel" --reporter="github" | |
if [ $? -gt 0 ]; then | |
echo "Channel module tests failed" | |
fi | |
- name: "Run form module tests" | |
run: | | |
cd test/playwright | |
npm run build | |
npm run test --module="form" --reporter="github" | |
if [ $? -gt 0 ]; then | |
echo "Form module tests failed" | |
fi | |
- name: "Run report module tests" | |
run: | | |
cd test/playwright | |
npm run build | |
npm run test --module="report" --reporter="github" | |
if [ $? -gt 0 ]; then | |
echo "Report module tests failed" | |
fi | |
- name: "Run tag module tests" | |
run: | | |
cd test/playwright | |
npm run build | |
npm run test --module="tag" --reporter="github" | |
if [ $? -gt 0 ]; then | |
echo "Tag module tests failed" | |
fi | |
- name: "Run task module tests" | |
run: | | |
cd test/playwright | |
npm run build | |
npm run test --module="task" --reporter="github" | |
if [ $? -gt 0 ]; then | |
echo "Task module tests failed" | |
fi | |
- name: "Run timelog module tests" | |
run: | | |
cd test/playwright | |
npm run build | |
npm run test --module="timelog" --reporter="github" | |
if [ $? -gt 0 ]; then | |
echo "Timelog module tests failed" | |
fi | |
- name: Stop containers | |
# the containers should be stopped regardless of | |
# the test result | |
if: always() | |
run: docker-compose down | |
# Store Test Results | |
- name: Test results | |
if: ${{ failure() }} || ${{ success() }} | |
uses: actions/upload-artifact@v4 | |
with: | |
name: test-output | |
path: | | |
test/Codeception/tests/_output/ | |
storage/log/ | |
test/playwright/test-results/ | |
test/playwright/playwright-report/ | |
retention-days: 5 |