From 29dbceadafe73738a58a706ae96fb2f67c426c13 Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Sun, 18 May 2025 08:24:36 -0700 Subject: [PATCH 1/6] lint yaml files --- .github/workflows/validate_workflows.yml | 43 ++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 .github/workflows/validate_workflows.yml diff --git a/.github/workflows/validate_workflows.yml b/.github/workflows/validate_workflows.yml new file mode 100644 index 0000000..18c6d43 --- /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: | + for file in $(find .github/workflows -name "*.y*ml"); do + echo "Validating $file..." + check-jsonschema \ + --schemafile https://json.schemastore.org/github-workflow.json \ + "$file" + done From cae4d9b8d2886e6b19ebf7041cf4c6102b23184f Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Sun, 18 May 2025 08:37:09 -0700 Subject: [PATCH 2/6] Fix yaml --- .github/workflows/tests.yml | 57 ++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 29 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index ef0819b..b968690 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 @@ -138,7 +138,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 @@ -148,7 +148,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 @@ -230,8 +230,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 @@ -245,14 +245,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 @@ -295,11 +295,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\t\n\t\t\t\t..\/tests\/<\/directory>\n\t\t\t\t..\/language\/<\/directory>\n\t\t\t\t..\/migrations\/<\/directory>\n\t\t\t<\/exclude>\n\t\t<\/whitelist>\n\t<\/filter>/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\t\n\t\t\t\t..\/tests\/<\/directory>\n\t\t\t\t..\/language\/<\/directory>\n\t\t\t\t..\/migrations\/<\/directory>\n\t\t\t<\/exclude>\n\t\t<\/whitelist>\n\t<\/filter>/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 @@ -318,10 +317,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 @@ -398,8 +397,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 @@ -413,14 +412,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 @@ -459,7 +458,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 @@ -467,9 +466,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 @@ -533,13 +532,13 @@ jobs: env: MATRIX_DB: ${{ matrix.db }} run: | - if [ $MATRIX_DB == 'mcr.microsoft.com/mssql/server:2022-CU13-ubuntu-22.04' ] || [ $MATRIX_DB == 'mcr.microsoft.com/mssql/server:2019-CU27-ubuntu-20.04' ] + if [ "$MATRIX_DB" == 'mcr.microsoft.com/mssql/server:2022-CU13-ubuntu-22.04' ] || [ "$MATRIX_DB" == 'mcr.microsoft.com/mssql/server:2019-CU27-ubuntu-20.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 @@ -553,14 +552,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 @@ -599,7 +598,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 @@ -607,9 +606,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 From cdf3d3ece4b0bc9f42e92cb272b26e931340775f Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Sun, 18 May 2025 09:24:12 -0700 Subject: [PATCH 3/6] =?UTF-8?q?Update=20linter=E2=80=99s=20yaml=20too?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/validate_workflows.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/validate_workflows.yml b/.github/workflows/validate_workflows.yml index 18c6d43..128fdeb 100644 --- a/.github/workflows/validate_workflows.yml +++ b/.github/workflows/validate_workflows.yml @@ -35,7 +35,7 @@ jobs: # Step 3: Validate each workflow YAML file against schema - name: Validate against GitHub workflow schema run: | - for file in $(find .github/workflows -name "*.y*ml"); do + 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 \ From d6057ef0218d3634d8397f8d2a041e72ddd11a2d Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Sun, 18 May 2025 09:39:32 -0700 Subject: [PATCH 4/6] Readme updates --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index aa7c793..69c68d1 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ jobs: EXTNAME: acme/demo # Your extension vendor/package name ``` -## Branches +## phpBB Branches Use the test-framework branch that matches the phpBB version you're developing for: @@ -67,10 +67,10 @@ call-tests: # 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 '3.3.x', which this framework is designed for. # If using a different branch, ensure it's compatible with 3.3.x. - # To test with phpBB's master branch, refer to the Branches section of this README. + # To test with phpBB's master branch, refer to the phpBB Branches section of this README. # Default: '3.3.x' PHPBB_BRANCH: '3.3.x' From 9dc5b7ee1cf8bdb4fe8edac991c6379f943cbae8 Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Sun, 18 May 2025 10:45:33 -0700 Subject: [PATCH 5/6] Readme updates --- README.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 69c68d1..c582901 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,15 @@ # phpBB Extension Test Framework -Detective Bertie running diagnostics +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. 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,7 +40,7 @@ jobs: name: Extension tests uses: phpbb-extensions/test-framework/.github/workflows/tests.yml@3.3.x with: - EXTNAME: acme/demo # Your extension vendor/package name + EXTNAME: acme/demo # Your extension vendor/package name (required) ``` ## phpBB Branches @@ -62,7 +65,7 @@ call-tests: name: Extension tests uses: phpbb-extensions/test-framework/.github/workflows/tests.yml@3.3.x 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. From ee0a0f370a474b7fe48a416262731cf8296ef1a7 Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Sun, 18 May 2025 10:49:53 -0700 Subject: [PATCH 6/6] Readme fixes --- README.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index c582901..9092575 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,8 @@ # phpBB Extension Test Framework -Detective Bertie running diagnostics +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.