|
| 1 | +name: Installation Tests |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - trunk |
| 7 | + # Always test the workflow after it's updated. |
| 8 | + paths: |
| 9 | + - '.github/workflows/install-testing.yml' |
| 10 | + pull_request: |
| 11 | + # Always test the workflow when changes are suggested. |
| 12 | + paths: |
| 13 | + - '.github/workflows/install-testing.yml' |
| 14 | + workflow_dispatch: |
| 15 | + inputs: |
| 16 | + wp-version: |
| 17 | + description: 'The version to test installing. Accepts major and minor versions, "latest", or "nightly". Major releases must not end with ".0".' |
| 18 | + type: string |
| 19 | + default: 'latest' |
| 20 | + |
| 21 | +# Cancels all previous workflow runs for pull requests that have not completed. |
| 22 | +concurrency: |
| 23 | + # The concurrency group contains the workflow name and the branch name for pull requests |
| 24 | + # or the commit hash for any other events. |
| 25 | + group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }} |
| 26 | + cancel-in-progress: true |
| 27 | + |
| 28 | +# Disable permissions for all available scopes by default. |
| 29 | +# Any needed permissions should be configured at the job level. |
| 30 | +permissions: {} |
| 31 | + |
| 32 | +jobs: |
| 33 | + # Test the WordPress installation process through WP-CLI. |
| 34 | + # |
| 35 | + # Performs the following steps: |
| 36 | + # - Sets up PHP. |
| 37 | + # - Starts the database server. |
| 38 | + # - Downloads the specified version of WordPress. |
| 39 | + # - Creates a `wp-config.php` file. |
| 40 | + # - Installs WordPress. |
| 41 | + install-tests-mysql: |
| 42 | + name: WP ${{ inputs.new-version || 'latest' }} / PHP ${{ matrix.php }} / ${{ 'mariadb' == matrix.db-type && 'MariaDB' || 'MySQL' }} ${{ matrix.db-version }}${{ matrix.multisite && ' multisite' || '' }} |
| 43 | + permissions: |
| 44 | + contents: read |
| 45 | + runs-on: ubuntu-latest |
| 46 | + timeout-minutes: 10 |
| 47 | + strategy: |
| 48 | + fail-fast: false |
| 49 | + matrix: |
| 50 | + os: [ ubuntu-latest ] |
| 51 | + php: [ '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3' ] |
| 52 | + db-type: [ 'mysql' ] |
| 53 | + db-version: [ '5.7', '8.0' ] |
| 54 | + multisite: [ false, true ] |
| 55 | + |
| 56 | + services: |
| 57 | + database: |
| 58 | + image: ${{ matrix.db-type }}:${{ matrix.db-version }} |
| 59 | + ports: |
| 60 | + - 3306 |
| 61 | + options: --health-cmd="mysqladmin ping" --health-interval=30s --health-timeout=10s --health-retries=5 -e MYSQL_ROOT_PASSWORD=root -e MYSQL_DATABASE=test_db --entrypoint sh ${{ matrix.db-type }}:${{ matrix.db-version }} -c "exec docker-entrypoint.sh mysqld --default-authentication-plugin=mysql_native_password" |
| 62 | + |
| 63 | + steps: |
| 64 | + - name: Set up PHP ${{ matrix.php }} |
| 65 | + uses: shivammathur/setup-php@7fdd3ece872ec7ec4c098ae5ab7637d5e0a96067 # v2.26.0 |
| 66 | + with: |
| 67 | + php-version: '${{ matrix.php }}' |
| 68 | + coverage: none |
| 69 | + tools: wp-cli |
| 70 | + |
| 71 | + - name: Start the database server |
| 72 | + run: | |
| 73 | + sudo systemctl start ${{ matrix.db-type }} |
| 74 | +
|
| 75 | + - name: Download WordPress |
| 76 | + run: wp core download ${{ inputs.wp-version && 'latest' != inputs.wp-version && format( '--version={0}', inputs.wp-version ) || '' }} |
| 77 | + |
| 78 | + - name: Create wp-config.php file |
| 79 | + run: wp config create --dbname=test_db --dbuser=root --dbpass=root --dbhost=127.0.0.1:${{ job.services.database.ports['3306'] }} |
| 80 | + |
| 81 | + - name: Install WordPress |
| 82 | + run: wp core ${{ matrix.multisite && 'multisite-' || '' }}install --url=http://localhost/ --title="Upgrade Test" --admin_user=admin --admin_password=password --admin_email=me@example.org --skip-email |
| 83 | + |
| 84 | + slack-notifications: |
| 85 | + name: Slack Notifications |
| 86 | + uses: WordPress/wordpress-develop/.github/workflows/slack-notifications.yml@trunk |
| 87 | + permissions: |
| 88 | + actions: read |
| 89 | + contents: read |
| 90 | + needs: [ install-tests-mysql ] |
| 91 | + if: ${{ github.repository == 'WordPress/wordpress-develop' && github.event_name != 'pull_request' && always() }} |
| 92 | + with: |
| 93 | + calling_status: ${{ contains( needs.*.result, 'cancelled' ) && 'cancelled' || contains( needs.*.result, 'failure' ) && 'failure' || 'success' }} |
| 94 | + secrets: |
| 95 | + SLACK_GHA_SUCCESS_WEBHOOK: ${{ secrets.SLACK_GHA_SUCCESS_WEBHOOK }} |
| 96 | + SLACK_GHA_CANCELLED_WEBHOOK: ${{ secrets.SLACK_GHA_CANCELLED_WEBHOOK }} |
| 97 | + SLACK_GHA_FIXED_WEBHOOK: ${{ secrets.SLACK_GHA_FIXED_WEBHOOK }} |
| 98 | + SLACK_GHA_FAILURE_WEBHOOK: ${{ secrets.SLACK_GHA_FAILURE_WEBHOOK }} |
| 99 | + |
| 100 | + failed-workflow: |
| 101 | + name: Failed workflow tasks |
| 102 | + runs-on: ubuntu-latest |
| 103 | + permissions: |
| 104 | + actions: write |
| 105 | + needs: [ slack-notifications ] |
| 106 | + if: | |
| 107 | + always() && |
| 108 | + github.repository == 'WordPress/wordpress-develop' && |
| 109 | + github.event_name != 'pull_request' && |
| 110 | + github.run_attempt < 2 && |
| 111 | + ( |
| 112 | + contains( needs.*.result, 'cancelled' ) || |
| 113 | + contains( needs.*.result, 'failure' ) |
| 114 | + ) |
| 115 | +
|
| 116 | + steps: |
| 117 | + - name: Dispatch workflow run |
| 118 | + uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410 # v6.4.1 |
| 119 | + with: |
| 120 | + retries: 2 |
| 121 | + retry-exempt-status-codes: 418 |
| 122 | + script: | |
| 123 | + github.rest.actions.createWorkflowDispatch({ |
| 124 | + owner: context.repo.owner, |
| 125 | + repo: context.repo.repo, |
| 126 | + workflow_id: 'failed-workflow.yml', |
| 127 | + ref: 'trunk', |
| 128 | + inputs: { |
| 129 | + run_id: '${{ github.run_id }}' |
| 130 | + } |
| 131 | + }); |
0 commit comments