diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 45ca7cb..eecf971 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -119,7 +119,7 @@ jobs: DB: ${{ matrix.db }} PHP_VERSION: ${{ matrix.php }} NOTESTS: '1' - run: .github/setup-phpbb.sh $DB $PHP_VERSION $NOTESTS + run: .github/setup-phpbb.sh "$DB" "$PHP_VERSION" "$NOTESTS" working-directory: ./phpBB3 - name: Setup EPV @@ -131,7 +131,7 @@ jobs: if: ${{ env.SNIFF != '0' }} env: NOTESTS: '1' - run: .github/ext-sniff.sh $EXTNAME $NOTESTS + run: .github/ext-sniff.sh "$EXTNAME" "$NOTESTS" working-directory: ./phpBB3 - name: Check image ICC profiles @@ -141,7 +141,7 @@ jobs: - name: Check executable files if: ${{ env.EXECUTABLE_FILES != '0' }} - run: .github/ext-check-executable-files.sh ./ $EXTNAME + run: .github/ext-check-executable-files.sh ./ "$EXTNAME" working-directory: ./phpBB3 - name: Run EPV @@ -225,8 +225,8 @@ jobs: env: MATRIX_DB: ${{ matrix.db }} run: | - db=$(echo "${MATRIX_DB%%:*}") - echo "db=$db" >> $GITHUB_OUTPUT + db="${MATRIX_DB%%:*}" + echo "db=$db" >> "$GITHUB_OUTPUT" - name: Setup PHP uses: shivammathur/setup-php@v2 @@ -240,14 +240,14 @@ jobs: DB: ${{steps.database-type.outputs.db}} PHP_VERSION: ${{ matrix.php }} NOTESTS: '0' - run: .github/setup-phpbb.sh $DB $PHP_VERSION ${NOTESTS:-0} + run: .github/setup-phpbb.sh "$DB" "$PHP_VERSION" "${NOTESTS:-0}" working-directory: ./phpBB3 - name: Setup database env: DB: ${{steps.database-type.outputs.db}} MYISAM: ${{ matrix.MYISAM != 1 && '0' || '1' }} - run: .github/setup-database.sh $DB $MYISAM + run: .github/setup-database.sh "$DB" "$MYISAM" working-directory: ./phpBB3 - name: Set up Node.js @@ -290,11 +290,10 @@ jobs: DB: ${{steps.database-type.outputs.db}} COVERAGE: ${{ matrix.COVERAGE == '1' && '1' || '0' }} run: | - if [ $COVERAGE == '1' ] - then - sed -n '1h;1!H;${;g;s/<\/php>/<\/php>\n\t\n\t\t\n\t\t\t..\/<\/directory>\n\t\t<\/include>\n\t\t\n\t\t\t..\/tests\/<\/directory>\n\t\t\t..\/language\/<\/directory>\n\t\t\t..\/migrations\/<\/directory>\n\t\t<\/exclude>\n\t<\/coverage>/g;p;}' .github/phpunit-$DB-github.xml &> phpBB/ext/$EXTNAME/.github/phpunit-$DB-github.xml + if [ "$COVERAGE" == '1' ]; then + sed -n '1h;1!H;${;g;s/<\/php>/<\/php>\n\t\n\t\t\n\t\t\t..\/<\/directory>\n\t\t<\/include>\n\t\t\n\t\t\t..\/tests\/<\/directory>\n\t\t\t..\/language\/<\/directory>\n\t\t\t..\/migrations\/<\/directory>\n\t\t<\/exclude>\n\t<\/coverage>/g;p;}' ".github/phpunit-$DB-github.xml" &> "phpBB/ext/$EXTNAME/.github/phpunit-$DB-github.xml" else - mkdir -p phpBB/ext/$EXTNAME/.github && cp .github/phpunit* $_ + mkdir -p "phpBB/ext/$EXTNAME/.github" && cp .github/phpunit* "$_" fi working-directory: ./phpBB3 @@ -313,10 +312,10 @@ jobs: COVERAGE: ${{ matrix.COVERAGE == '1' && '1' || '0' }} run: | phpBB/vendor/bin/phpunit \ - --configuration phpBB/ext/$EXTNAME/.github/phpunit-$DB-github.xml \ + --configuration "phpBB/ext/$EXTNAME/.github/phpunit-$DB-github.xml" \ --bootstrap ./tests/bootstrap.php \ - $([[ "$COVERAGE" == "1" ]] && echo "--coverage-clover build/logs/clover.xml") \ - $([[ "$FUNCTIONAL_TESTS" == "0" ]] && echo "--exclude-group functional") + "$( [[ "$COVERAGE" == "1" ]] && echo "--coverage-clover build/logs/clover.xml" )" \ + "$( [[ "$FUNCTIONAL_TESTS" == "0" ]] && echo "--exclude-group functional" )" working-directory: ./phpBB3 - name: Send code coverage @@ -395,8 +394,8 @@ jobs: env: MATRIX_DB: ${{ matrix.db }} run: | - db=$(echo "${MATRIX_DB%%:*}") - echo "db=$db" >> $GITHUB_OUTPUT + db="${MATRIX_DB%%:*}" + echo "db=$db" >> "$GITHUB_OUTPUT" - name: Setup PHP uses: shivammathur/setup-php@v2 @@ -410,14 +409,14 @@ jobs: DB: ${{steps.database-type.outputs.db}} PHP_VERSION: ${{ matrix.php }} NOTESTS: '0' - run: .github/setup-phpbb.sh $DB $PHP_VERSION ${NOTESTS:-0} + run: .github/setup-phpbb.sh "$DB" "$PHP_VERSION" "${NOTESTS:-0}" working-directory: ./phpBB3 - name: Setup database env: DB: ${{steps.database-type.outputs.db}} MYISAM: '0' - run: .github/setup-database.sh $DB $MYISAM + run: .github/setup-database.sh "$DB" "$MYISAM" working-directory: ./phpBB3 - name: Set up Node.js @@ -456,7 +455,7 @@ jobs: working-directory: ./phpBB3/phpBB/ext/${{ env.EXTNAME }} - name: Setup PHPUnit files - run: mkdir -p phpBB/ext/$EXTNAME/.github && cp .github/phpunit* $_ + run: mkdir -p "phpBB/ext/$EXTNAME/.github" && cp .github/phpunit* "$_" working-directory: ./phpBB3 - name: Run unit tests @@ -464,9 +463,9 @@ jobs: DB: ${{steps.database-type.outputs.db}} run: | phpBB/vendor/bin/phpunit \ - --configuration phpBB/ext/$EXTNAME/.github/phpunit-$DB-github.xml \ + --configuration "phpBB/ext/$EXTNAME/.github/phpunit-$DB-github.xml" \ --bootstrap ./tests/bootstrap.php \ - $([[ "$FUNCTIONAL_TESTS" == "0" ]] && echo "--exclude-group functional") + "$( [[ "$FUNCTIONAL_TESTS" == "0" ]] && echo "--exclude-group functional" )" working-directory: ./phpBB3 # END PostgreSQL Job @@ -531,13 +530,13 @@ jobs: env: MATRIX_DB: ${{ matrix.db }} run: | - if [ $MATRIX_DB == 'mcr.microsoft.com/mssql/server:2019-CU27-ubuntu-20.04' ] || [ $MATRIX_DB == 'mcr.microsoft.com/mssql/server:2022-CU13-ubuntu-22.04' ] + if [ "$MATRIX_DB" == 'mcr.microsoft.com/mssql/server:2019-CU27-ubuntu-20.04' ] || [ "$MATRIX_DB" == 'mcr.microsoft.com/mssql/server:2022-CU13-ubuntu-22.04' ] then db='mssql' else - db=$(echo "${MATRIX_DB%%:*}") + db="${MATRIX_DB%%:*}" fi - echo "db=$db" >> $GITHUB_OUTPUT + echo "db=$db" >> "$GITHUB_OUTPUT" - name: Setup PHP uses: shivammathur/setup-php@v2 @@ -551,14 +550,14 @@ jobs: DB: ${{steps.database-type.outputs.db}} PHP_VERSION: ${{ matrix.php }} NOTESTS: '0' - run: .github/setup-phpbb.sh $DB $PHP_VERSION ${NOTESTS:-0} + run: .github/setup-phpbb.sh "$DB" "$PHP_VERSION" "${NOTESTS:-0}" working-directory: ./phpBB3 - name: Setup database env: DB: ${{steps.database-type.outputs.db}} MYISAM: '0' - run: .github/setup-database.sh $DB $MYISAM + run: .github/setup-database.sh "$DB" "$MYISAM" working-directory: ./phpBB3 - name: Set up Node.js @@ -597,7 +596,7 @@ jobs: working-directory: ./phpBB3/phpBB/ext/${{ env.EXTNAME }} - name: Setup PHPUnit files - run: mkdir -p phpBB/ext/$EXTNAME/.github && cp .github/phpunit* $_ + run: mkdir -p "phpBB/ext/$EXTNAME/.github" && cp .github/phpunit* "$_" working-directory: ./phpBB3 - name: Run unit tests @@ -605,9 +604,9 @@ jobs: DB: ${{steps.database-type.outputs.db}} run: | phpBB/vendor/bin/phpunit \ - --configuration phpBB/ext/$EXTNAME/.github/phpunit-$DB-github.xml \ + --configuration "phpBB/ext/$EXTNAME/.github/phpunit-$DB-github.xml" \ --bootstrap ./tests/bootstrap.php \ - $([[ "$FUNCTIONAL_TESTS" == "0" ]] && echo "--exclude-group functional") + "$( [[ "$FUNCTIONAL_TESTS" == "0" ]] && echo "--exclude-group functional" )" working-directory: ./phpBB3 # END Other Tests Job diff --git a/.github/workflows/validate_workflows.yml b/.github/workflows/validate_workflows.yml new file mode 100644 index 0000000..128fdeb --- /dev/null +++ b/.github/workflows/validate_workflows.yml @@ -0,0 +1,43 @@ +name: Validate Workflows + +on: + push: + paths: + - ".github/workflows/**/*.yml" + - ".github/workflows/**/*.yaml" + pull_request: + paths: + - ".github/workflows/**/*.yml" + - ".github/workflows/**/*.yaml" + +jobs: + validate: + name: Lint & Schema Validate Workflows + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + # Step 1: Run actionlint for logic/deprecation checks + - name: Run actionlint + uses: raven-actions/actionlint@v1 + + # Step 2: Set up Python for schema validation + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.x" + + - name: Install check-jsonschema + run: pip install check-jsonschema + + # Step 3: Validate each workflow YAML file against schema + - name: Validate against GitHub workflow schema + run: | + find .github/workflows -name "*.y*ml" -print0 | while IFS= read -r -d '' file; do + echo "Validating $file..." + check-jsonschema \ + --schemafile https://json.schemastore.org/github-workflow.json \ + "$file" + done diff --git a/README.md b/README.md index e89987c..d7e1999 100644 --- a/README.md +++ b/README.md @@ -2,11 +2,12 @@ Detective Bertie running diagnostics -This repository provides a reusable GitHub Actions workflow for phpBB extension developers. - -It supports testing phpBB extensions across multiple PHP versions and database engines including MySQL, PostgreSQL, SQLite, and Microsoft SQL Server. +This repository provides a reusable GitHub Actions workflow for phpBB extension developers. It supports testing phpBB extensions across multiple PHP versions and database engines including MySQL, PostgreSQL, SQLite, and Microsoft SQL Server. Additional checks include PHP CodeSniffer, Extension Pre Validator (EPV), executable file detection, image ICC profile removal, and code coverage reporting via Codecov. + +[![Build](https://github.com/phpbb-extensions/test-framework/actions/workflows/validate_workflows.yml/badge.svg)](https://github.com/phpbb-extensions/test-framework/actions/workflows/validate_workflows.yml) +[![Tests](https://github.com/phpbb/phpbb-ext-acme-demo/actions/workflows/tests.yml/badge.svg)](https://github.com/phpbb/phpbb-ext-acme-demo/actions/workflows/tests.yml)
# How to Use @@ -37,10 +38,10 @@ jobs: name: Extension tests uses: phpbb-extensions/test-framework/.github/workflows/tests.yml@master with: - EXTNAME: acme/demo # Your extension vendor/package name + EXTNAME: acme/demo # Your extension vendor/package name (required) ``` -## Branches +## phpBB Branches Use the test-framework branch that matches the phpBB version you're developing for: @@ -62,15 +63,15 @@ call-tests: name: Extension tests uses: phpbb-extensions/test-framework/.github/workflows/tests.yml@master with: - EXTNAME: acme/demo # Your extension vendor/package name + EXTNAME: acme/demo # Your extension vendor/package name (required) # OPTIONAL CONFIGURATIONS BELOW # The following arguments are optional and can be omitted if not needed. - # The phpBB branch to use when running tests. + # The phpBB repository's branch to use when running tests. # Default is 'master', which this framework is designed for. # If using a different branch, ensure it's compatible with master. - # To test with phpBB's 3.3.x branch, refer to the Branches section of this README. + # To test with phpBB's 3.3.x branch, refer to the phpBB Branches section of this README. # Default: 'master' PHPBB_BRANCH: 'master'