|
| 1 | +name: WordPress PHPUnit tests |
| 2 | + |
| 3 | +on: |
| 4 | + # The workflow should be run on a schedule using the 'schedule' event trigger. |
| 5 | + # |
| 6 | + # For more details on how to configure the schedule event, see https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#onschedule. |
| 7 | + # |
| 8 | + # Below are some options for different schedules. Running the tests every hour is recommended, |
| 9 | + # but every 3-6 hours is also helpful. Times are in UTC. |
| 10 | + schedule: |
| 11 | + # By default, the workflow will run every hour. |
| 12 | + - cron: '0 * * * *' |
| 13 | + # Every 3 hours. |
| 14 | + # - cron: '0 0/3 * * *' |
| 15 | + # Every 6 hours. |
| 16 | + # - cron: '0 0/6 * * *' |
| 17 | + # Every 12 hours. |
| 18 | + # - cron: '0 0/12 * * *' |
| 19 | + # Once per day at 00:00. |
| 20 | + # - cron: '0 0 * * *' |
| 21 | + # Every 30 minutes. |
| 22 | + # - cron: '0/30 * * * *' |
| 23 | + |
| 24 | +# Cancels all previous workflow runs for pull requests that have not completed. |
| 25 | +concurrency: |
| 26 | + # The concurrency group contains the workflow name and the branch name for pull requests |
| 27 | + # or the commit hash for any other events. |
| 28 | + group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }} |
| 29 | + cancel-in-progress: true |
| 30 | + |
| 31 | +jobs: |
| 32 | + # Tests the PHPUnit test runner. |
| 33 | + # |
| 34 | + # Performs the following steps: |
| 35 | + # - Checks out the repository. |
| 36 | + # - Installs PHP. |
| 37 | + # - Installs NodeJS 14 with caching configured. |
| 38 | + # - Prepares the environment for tests. |
| 39 | + # - Runs the tests. |
| 40 | + # - Reports the results. |
| 41 | + # - Cleans up. |
| 42 | + test: |
| 43 | + name: Run Core PHPUnit tests |
| 44 | + runs-on: ubuntu-latest |
| 45 | + |
| 46 | + # Remove this line if Github Actions is your preferred means of running the tests. |
| 47 | + if: never() |
| 48 | + |
| 49 | + env: |
| 50 | + # This is only a subset/example of env vars available. See the `.env.default` file for a full list. |
| 51 | + WPT_PREPARE_DIR: ${{ secrets.WPT_PREPARE_DIR }} |
| 52 | + WPT_TEST_DIR: ${{ secrets.WPT_TEST_DIR }} |
| 53 | + WPT_REPORT_API_KEY: ${{ secrets.WPT_REPORT_API_KEY }} |
| 54 | + WPT_PHP_EXECUTABLE: ${{ secrets.WPT_PHP_EXECUTABLE }} |
| 55 | + # Database settings |
| 56 | + WPT_DB_NAME: ${{ secrets.WPT_DB_NAME }} |
| 57 | + WPT_DB_USER: ${{ secrets.WPT_DB_USER }} |
| 58 | + WPT_DB_PASSWORD: ${{ secrets.WPT_DB_PASSWORD }} |
| 59 | + WPT_DB_HOST: ${{ secrets.WPT_DB_HOST }} |
| 60 | + # SSH settings for connecting to the test environment. |
| 61 | + WPT_SSH_CONNECT: ${{ secrets.WPT_SSH_CONNECT }} |
| 62 | + WPT_SSH_PRIVATE_KEY_BASE64: ${{ secrets.WPT_SSH_PRIVATE_KEY_BASE64 }} |
| 63 | + |
| 64 | + steps: |
| 65 | + - name: Checkout repository |
| 66 | + uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4 |
| 67 | + |
| 68 | + - name: Set up PHP |
| 69 | + uses: shivammathur/setup-php@947009a71769c25ab5292f073f5343624b7c879d # v2.12.0 |
| 70 | + with: |
| 71 | + php-version: '7.4' |
| 72 | + coverage: none |
| 73 | + |
| 74 | + - name: Install NodeJS |
| 75 | + uses: actions/setup-node@25316bbc1f10ac9d8798711f44914b1cf3c4e954 # v2.4.0 |
| 76 | + with: |
| 77 | + node-version: 14 |
| 78 | + |
| 79 | + - name: Prepare environment |
| 80 | + run: php prepare.php |
| 81 | + |
| 82 | + - name: Run unit tests |
| 83 | + run: php test.php |
| 84 | + # Prevent the workflow from stopping if there are test failures. |
| 85 | + continue-on-error: true |
| 86 | + |
| 87 | + - name: Report the results |
| 88 | + run: php report.php |
| 89 | + |
| 90 | + - name: Cleanup |
| 91 | + run: php cleanup.php |
0 commit comments