|
| 1 | +# test-framework |
| 2 | + |
| 3 | +Reusable GitHub Actions workflow for testing phpBB extensions across multiple environments. |
| 4 | + |
| 5 | +This repository provides a pre-configured test workflow designed for phpBB extension developers. It runs your extension's tests using various PHP versions and database systems, including **MySQL**, **PostgreSQL**, **SQLite**, and **Microsoft SQL Server**. |
| 6 | + |
| 7 | +## 🚀 Features |
| 8 | + |
| 9 | +- Supports **PHP 7.2+** through **8.x** |
| 10 | +- Tests against multiple database engines |
| 11 | +- Optional checks for: |
| 12 | + - PHP CodeSniffer |
| 13 | + - ICC image profiles |
| 14 | + - EPV (Extension Pre Validator) |
| 15 | + - Executable files |
| 16 | + - Code coverage via Codecov |
| 17 | + |
| 18 | +## 🧪 Branches |
| 19 | + |
| 20 | +- `3.3.x`: Targets the **phpBB 3.3.x** release line. |
| 21 | +- `master`: Targets the latest development version of **phpBB** (`master` branch). |
| 22 | + |
| 23 | +Use the branch that matches the phpBB version you're developing for. |
| 24 | + |
| 25 | +## 📦 How to Use |
| 26 | + |
| 27 | +Add a `tests.yml` file in your extension’s `.github/workflows/` directory. Here's a complete example: |
| 28 | + |
| 29 | +```yaml |
| 30 | +name: Tests |
| 31 | + |
| 32 | +on: |
| 33 | + push: |
| 34 | + branches: # Run tests when commits are pushed to these branches in your repo |
| 35 | + - main |
| 36 | + - master |
| 37 | + - develop |
| 38 | + - dev/* |
| 39 | + pull_request: # Run tests when pull requests are made on these branches in your repo |
| 40 | + branches: |
| 41 | + - main |
| 42 | + - master |
| 43 | + - develop |
| 44 | + - dev/* |
| 45 | + |
| 46 | +jobs: |
| 47 | + call-tests: |
| 48 | + uses: phpbb-extensions/test-framework/.github/workflows/tests.yml@3.3.x # Must match PHPBB_BRANCH |
| 49 | + with: |
| 50 | + EXTNAME: acme/demo # Your extension vendor/package name |
| 51 | + SNIFF: 1 # Run code sniffer on your code? 1 or 0 |
| 52 | + IMAGE_ICC: 1 # Run icc profile sniffer on your images? 1 or 0 |
| 53 | + EPV: 1 # Run EPV (Extension Pre Validator) on your code? 1 or 0 |
| 54 | + EXECUTABLE_FILES: 1 # Run check for executable files? 1 or 0 |
| 55 | + CODECOV: 0 # Run code coverage via codecov? 1 or 0 |
| 56 | + PHPBB_BRANCH: 3.3.x # The phpBB branch to run tests on |
| 57 | + secrets: |
| 58 | + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} # Do not edit this |
| 59 | +``` |
| 60 | +
|
| 61 | +## ✅ Requirements |
| 62 | +
|
| 63 | +- Your extension must follow standard phpBB extension structure. |
| 64 | +- Tests must be defined in your repository using PHPUnit. |
| 65 | +
|
| 66 | +## 📊 Code Coverage with Codecov |
| 67 | +
|
| 68 | +This test framework supports code coverage reporting through [Codecov.io](https://codecov.io). To enable it, follow these steps: |
| 69 | +
|
| 70 | +### 1. Add a `codecov.yml` Path Fix |
| 71 | + |
| 72 | +Codecov may report incorrect file paths if phpBB is cloned into a subdirectory. To fix this, add a `codecov.yml` file to the `.github/` directory of your extension’s repository with the following content: |
| 73 | + |
| 74 | +```yaml |
| 75 | +fixes: |
| 76 | + - "/phpBB3/phpBB/ext/acme/demo/::" |
| 77 | +``` |
| 78 | + |
| 79 | +Make sure to replace `acme/demo` with your actual extension vendor/package name. |
| 80 | + |
| 81 | +### 2. Sign in to Codecov |
| 82 | + |
| 83 | +- Visit [https://codecov.io](https://codecov.io) |
| 84 | +- Log in with your **GitHub** account |
| 85 | + |
| 86 | +### 3. Get Your Codecov Token (if required) |
| 87 | + |
| 88 | +Most public repositories do **not** require a token. |
| 89 | +For private repositories or certain CI setups, you may need a global **Codecov token**: |
| 90 | + |
| 91 | +- Go to your [Codecov account settings](https://app.codecov.io/account/token) |
| 92 | +- Copy the token |
| 93 | + |
| 94 | +Then, in your GitHub repository: |
| 95 | + |
| 96 | +- Navigate to **Settings → Secrets and variables → Actions** |
| 97 | +- Click **"New repository secret"** |
| 98 | +- Name it `CODECOV_TOKEN` and paste your token value |
| 99 | + |
| 100 | +### 4. Enable Codecov in the Workflow |
| 101 | + |
| 102 | +Ensure `CODECOV: 1` is set in your workflow call: |
| 103 | + |
| 104 | +```yaml |
| 105 | +with: |
| 106 | + ... |
| 107 | + CODECOV: 1 |
| 108 | + ... |
| 109 | +``` |
| 110 | + |
| 111 | +Once set up, Codecov will automatically collect and display coverage reports for your extension after each test run. |
| 112 | + |
| 113 | +> 💡 You can view your coverage reports and badges by visiting your extension's page on [Codecov.io](https://codecov.io). |
| 114 | + |
| 115 | +## 📄 License |
| 116 | + |
| 117 | +[GNU General Public License v2](license.txt) |
0 commit comments