Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 28 additions & 29 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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<coverage>\n\t\t<include>\n\t\t\t<directory>..\/<\/directory>\n\t\t<\/include>\n\t\t<exclude>\n\t\t\t<directory>..\/tests\/<\/directory>\n\t\t\t<directory>..\/language\/<\/directory>\n\t\t\t<directory>..\/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<coverage>\n\t\t<include>\n\t\t\t<directory>..\/<\/directory>\n\t\t<\/include>\n\t\t<exclude>\n\t\t\t<directory>..\/tests\/<\/directory>\n\t\t\t<directory>..\/language\/<\/directory>\n\t\t\t<directory>..\/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

Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -456,17 +455,17 @@ 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
env:
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

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -597,17 +596,17 @@ 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
env:
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

Expand Down
43 changes: 43 additions & 0 deletions .github/workflows/validate_workflows.yml
Original file line number Diff line number Diff line change
@@ -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
17 changes: 9 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

<img align="left" src="https://raw.githubusercontent.com/phpbb/website-assets/master/images/images/extensions/detective-bertie.png" alt="Detective Bertie running diagnostics" height="200" width="200">

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)
<br clear="both"/>

# How to Use
Expand Down Expand Up @@ -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:

Expand All @@ -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'

Expand Down