diff --git a/.github/workflows/phpunit-tests.yml b/.github/workflows/phpunit-tests.yml index 3fa1493605e45..53af817942511 100644 --- a/.github/workflows/phpunit-tests.yml +++ b/.github/workflows/phpunit-tests.yml @@ -46,7 +46,7 @@ jobs: fail-fast: false matrix: os: [ ubuntu-latest ] - php: [ '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1' ] + php: [ '5.6', '7.0', '7.4', '8.0', '8.1' ] db-type: [ 'mysql' ] db-version: [ '5.7' ] multisite: [ false, true ] diff --git a/.github/workflows/slack-notifications.yml b/.github/workflows/slack-notifications.yml deleted file mode 100644 index 4d646ac156df2..0000000000000 --- a/.github/workflows/slack-notifications.yml +++ /dev/null @@ -1,217 +0,0 @@ -## -# A reusable workflow for posting messages to the Making WordPress -# Core Slack Instance by submitting data to Slack webhook URLs -# received by Slack Workflows. -## -name: Slack Notifications - -on: - workflow_run: - workflows: - - Code Coverage Report - - Coding Standards - - End-to-end Tests - - JavaScript Tests - - PHP Compatibility - - PHPUnit Tests - - Test NPM - - Test old branches - types: - - completed - branches: - - '[3-4].[0-9]' - - '5.[0-8]' - - workflow_call: - inputs: - calling_status: - description: 'The status of the calling workflow' - type: string - required: true - secrets: - SLACK_GHA_SUCCESS_WEBHOOK: - description: 'The Slack webhook URL for a successful build.' - required: true - SLACK_GHA_CANCELLED_WEBHOOK: - description: 'The Slack webhook URL for a cancelled build.' - required: true - SLACK_GHA_FIXED_WEBHOOK: - description: 'The Slack webhook URL for a fixed build.' - required: true - SLACK_GHA_FAILURE_WEBHOOK: - description: 'The Slack webhook URL for a failed build.' - required: true - -env: - CURRENT_BRANCH: ${{ github.event_name == 'workflow_run' && github.event.workflow_run.head_branch || github.ref_name }} - -jobs: - # Gathers the details needed for Slack notifications. - # - # These details are passed as outputs to the subsequent, dependant jobs that - # submit data to Slack webhook URLs configured to post messages. - # - # Performs the following steps: - # - Retrieves the current workflow run. - # - Determine the conclusion of the previous workflow run or run attempt. - # - Sets the previous conclusion as an output. - # - Prepares the commit message. - # - Constructs and stores a message payload as an output. - prepare: - name: Prepare notifications - runs-on: ubuntu-latest - timeout-minutes: 5 - if: ${{ github.repository == 'WordPress/wordpress-develop' && github.event.workflow_run.event != 'pull_request' }} - outputs: - previous_conclusion: ${{ steps.previous-conclusion.outputs.previous_conclusion }} - payload: ${{ steps.create-payload.outputs.payload }} - - steps: - - name: Determine the status of the previous attempt - id: previous-attempt-result - if: ${{ github.event_name == 'push' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' }} - uses: actions/github-script@9ac08808f993958e9de277fe43a64532a609130e # v6.0.0 - with: - script: | - const workflow_run = await github.rest.actions.getWorkflowRun({ - owner: context.repo.owner, - repo: context.repo.repo, - run_id: ${{ github.run_id }}, - }); - - // When a workflow has been restarted to fix a failure, check the previous run attempt. - if ( workflow_run.data.run_attempt > 1 ) { - const previous_run = await github.rest.actions.getWorkflowRunAttempt({ - owner: context.repo.owner, - repo: context.repo.repo, - run_id: ${{ github.run_id }}, - attempt_number: workflow_run.data.run_attempt - 1 - }); - - return previous_run.data.conclusion; - } - - let workflow_id = ''; - if ( ${{ github.event_name == 'workflow_run' }} ) { - workflow_id = '${{ github.event.workflow_run.workflow_id }}'; - } else { - workflow_id = workflow_run.data.workflow_id; - } - - // Otherwise, check the previous workflow run. - const previous_runs = await github.rest.actions.listWorkflowRuns({ - owner: context.repo.owner, - repo: context.repo.repo, - workflow_id: workflow_id, - branch: '${{ env.CURRENT_BRANCH }}', - exclude_pull_requests: true, - }); - - // This is the first workflow run for this branch or tag. - if ( previous_runs.data.workflow_runs.length == 0 ) { - return 'none'; - } - - // Find the workflow run for the commit that immediately preceded this one. - for ( let i = 0; i < previous_runs.data.workflow_runs.length; i++ ) { - if ( previous_runs.data.workflow_runs[ i ].run_number == workflow_run.data.run_number ) { - return previous_runs.data.workflow_runs[ i + 1 ].conclusion; - } - } - - // Can't determine previous workflow conclusion. - return 'unknown'; - - - name: Store previous conclusion as an output - id: previous-conclusion - run: echo "::set-output name=previous_conclusion::${{ steps.previous-attempt-result.outputs.result }}" - - - name: Get the commit message - id: current-commit-message - uses: actions/github-script@9ac08808f993958e9de277fe43a64532a609130e # v6.0.0 - if: ${{ github.event_name == 'workflow_dispatch' || github.event_name == 'schedule' }} - with: - script: | - const commit_details = await github.rest.repos.getCommit({ - owner: context.repo.owner, - repo: context.repo.repo, - ref: '${{ github.sha }}' - }); - return commit_details.data.commit.message; - - - name: Prepare commit message. - id: commit-message - run: | - COMMIT_MESSAGE=$(cat <<'EOF' | awk 'NR==1' | sed 's/`/\\`/g' | sed 's/\"/\\\\\\"/g' | sed 's/\$/\\$/g' - ${{ github.event_name == 'workflow_run' && github.event.workflow_run.head_commit.message || ( github.event_name == 'workflow_dispatch' || github.event_name == 'schedule' ) && fromJson( steps.current-commit-message.outputs.result ) || github.event.head_commit.message }} - EOF - ) - echo "::set-output name=commit_message_escaped::${COMMIT_MESSAGE}" - - - name: Construct payload and store as an output - id: create-payload - run: echo "::set-output name=payload::{\"workflow_name\":\"${{ github.event_name == 'workflow_run' && github.event.workflow_run.name || github.workflow }}\",\"ref_name\":\"${{ env.CURRENT_BRANCH }}\",\"run_url\":\"https://github.com/WordPress/wordpress-develop/actions/runs/${{ github.event_name == 'workflow_run' && github.event.workflow_run.id || github.run_id }}\",\"commit_message\":\"${{ steps.commit-message.outputs.commit_message_escaped }}\"}" - - # Posts notifications when a workflow fails. - failure: - name: Failure notifications - runs-on: ubuntu-latest - timeout-minutes: 5 - needs: [ prepare ] - if: ${{ github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'failure' || inputs.calling_status == 'failure' || failure() }} - - steps: - - name: Post failure notifications to Slack - uses: slackapi/slack-github-action@16b6c78ee73689a627b65332b34e5d409c7299da # v1.18.0 - with: - payload: ${{ needs.prepare.outputs.payload }} - env: - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_GHA_FAILURE_WEBHOOK }} - - # Posts notifications the first time a workflow run succeeds after previously failing. - fixed: - name: Fixed notifications - runs-on: ubuntu-latest - timeout-minutes: 5 - needs: [ prepare ] - if: ${{ contains( fromJson( '["failure", "cancelled", "none"]' ), needs.prepare.outputs.previous_conclusion ) && ( github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success' || inputs.calling_status == 'success' ) && success() }} - - steps: - - name: Post failure notifications to Slack - uses: slackapi/slack-github-action@16b6c78ee73689a627b65332b34e5d409c7299da # v1.18.0 - with: - payload: ${{ needs.prepare.outputs.payload }} - env: - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_GHA_FIXED_WEBHOOK }} - - # Posts notifications when a workflow is successful. - success: - name: Success notifications - runs-on: ubuntu-latest - timeout-minutes: 5 - needs: [ prepare ] - if: ${{ github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success' || inputs.calling_status == 'success' && success() }} - - steps: - - name: Post success notifications to Slack - uses: slackapi/slack-github-action@16b6c78ee73689a627b65332b34e5d409c7299da # v1.18.0 - with: - payload: ${{ needs.prepare.outputs.payload }} - env: - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_GHA_SUCCESS_WEBHOOK }} - - # Posts notifications when a workflow is cancelled. - cancelled: - name: Cancelled notifications - runs-on: ubuntu-latest - timeout-minutes: 5 - needs: [ prepare ] - if: ${{ github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'cancelled' || inputs.calling_status == 'cancelled' || cancelled() }} - - steps: - - name: Post cancelled notifications to Slack - uses: slackapi/slack-github-action@16b6c78ee73689a627b65332b34e5d409c7299da # v1.18.0 - with: - payload: ${{ needs.prepare.outputs.payload }} - env: - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_GHA_CANCELLED_WEBHOOK }} diff --git a/.github/workflows/test-coverage.yml b/.github/workflows/test-coverage.yml deleted file mode 100644 index 9cb07627001bf..0000000000000 --- a/.github/workflows/test-coverage.yml +++ /dev/null @@ -1,213 +0,0 @@ -name: Code Coverage Report - -on: - # Verify - push: - branches: - - trunk - paths: - - '.github/workflows/test-coverage.yml' - - 'phpunit.xml.dist' - - 'tests/phpunit/multisite.xml' - # Once daily at 00:00 UTC. - schedule: - - cron: '0 0 * * *' - # Allow manually triggering the workflow. - workflow_dispatch: - -env: - PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: ${{ true }} - LOCAL_PHP: '7.4-fpm' - LOCAL_PHP_XDEBUG: true - LOCAL_PHP_MEMCACHED: ${{ false }} - -jobs: - # Sets up WordPress for testing or development use. - # - # Performs the following steps: - # - Set environment variables. - # - Checks out the repository. - # - Checks out the WordPress Importer plugin (needed for the Core PHPUnit tests). - # - Logs debug information about the runner container. - # - Installs NodeJS 14. - # _ Installs NPM dependencies using install-changed to hash the `package.json` file. - # - Logs Docker debug information (about the Docker installation within the runner). - # - Starts the WordPress Docker container. - # - Logs debug general information. - # - Logs the running Docker containers. - # - Logs WordPress Docker container debug information. - # - Logs debug information about what's installed within the WordPress Docker containers. - # - Install WordPress within the Docker container. - # - Run the PHPUnit tests as a single site. - # - Ensures version-controlled files are not modified or deleted. - # - Upload the single site code coverage report to Codecov.io. - # - Run the PHPUnit tests as a multisite. - # - Ensures version-controlled files are not modified or deleted. - # - Upload the multisite code coverage report to Codecov.io. - test-coverage-report: - name: ${{ matrix.multisite && 'Multisite' || 'Single site' }} report - runs-on: ubuntu-latest - timeout-minutes: 120 - if: ${{ github.repository == 'WordPress/wordpress-develop' }} - strategy: - fail-fast: false - matrix: - multisite: [ false, true ] - - steps: - - name: Configure environment variables - run: | - echo "PHP_FPM_UID=$(id -u)" >> $GITHUB_ENV - echo "PHP_FPM_GID=$(id -g)" >> $GITHUB_ENV - - - name: Checkout repository - uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579 # v2.4.0 - - - name: Log debug information - run: | - echo "$GITHUB_REF" - echo "$GITHUB_EVENT_NAME" - npm --version - node --version - curl --version - git --version - svn --version - php --version - php -i - locale -a - - - name: Install NodeJS - uses: actions/setup-node@5b52f097d36d4b0b2f94ed6de710023fbb8b2236 # v3.1.0 - with: - node-version-file: '.nvmrc' - cache: npm - - - name: Install Dependencies - run: npm ci - - # This date is used to ensure that the Composer cache is refreshed at least once every week. - # http://man7.org/linux/man-pages/man1/date.1.html - - name: "Get last Monday's date" - id: get-date - run: echo "date=$(/bin/date -u --date='last Mon' "+%F")" >> $GITHUB_OUTPUT - - - name: Get Composer cache directory - id: composer-cache - run: echo "composer_dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT - - - name: Cache Composer dependencies - uses: actions/cache@136d96b4aee02b1f0de3ba493b1d47135042d9c0 # v3.0.1 - env: - cache-name: cache-composer-dependencies - with: - path: ${{ steps.composer-cache.outputs.composer_dir }} - key: ${{ runner.os }}-php-${{ matrix.php }}-date-${{ steps.get-date.outputs.date }}-composer-${{ hashFiles('**/composer.json') }} - - - name: Install Composer dependencies - run: | - docker-compose run --rm php composer --version - - # Install using `composer update` as there is no `composer.lock` file. - docker-compose run --rm php composer update - - - name: Docker debug information - run: | - docker -v - docker-compose -v - - - name: Start Docker environment - run: | - npm run env:start - - - name: General debug information - run: | - npm --version - node --version - curl --version - git --version - svn --version - - - name: Log running Docker containers - run: docker ps -a - - - name: WordPress Docker container debug information - run: | - docker-compose run --rm mysql mysql --version - docker-compose run --rm php php --version - docker-compose run --rm php php -m - docker-compose run --rm php php -i - docker-compose run --rm php locale -a - - - name: Install WordPress - run: npm run env:install - - - name: Run tests as a single site - if: ${{ ! matrix.multisite }} - run: npm run test:php -- --verbose -c phpunit.xml.dist --coverage-clover wp-code-coverage-single-clover-${{ github.sha }}.xml - - - name: Ensure version-controlled files are not modified during the tests - run: git diff --exit-code - - - name: Upload single site report to Codecov - if: ${{ ! matrix.multisite }} - uses: codecov/codecov-action@e3c560433a6cc60aec8812599b7844a7b4fa0d71 # v3.0.0 - with: - file: wp-code-coverage-single-clover-${{ github.sha }}.xml - flags: single,php - - - name: Run tests as a multisite install - if: ${{ matrix.multisite }} - run: npm run test:php -- --verbose -c tests/phpunit/multisite.xml --coverage-clover wp-code-coverage-multisite-clover-${{ github.sha }}.xml - - - name: Ensure version-controlled files are not modified during the tests - run: git diff --exit-code - - - name: Upload multisite report to Codecov - if: ${{ matrix.multisite }} - uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b # v2.1.0 - with: - file: wp-code-coverage-multisite-clover-${{ github.sha }}.xml - flags: multisite,php - - slack-notifications: - name: Slack Notifications - uses: WordPress/wordpress-develop/.github/workflows/slack-notifications.yml@trunk - needs: [ test-coverage-report ] - if: ${{ github.repository == 'WordPress/wordpress-develop' && github.event_name != 'pull_request' && always() }} - with: - calling_status: ${{ needs.test-coverage-report.result == 'success' && 'success' || needs.test-coverage-report.result == 'cancelled' && 'cancelled' || 'failure' }} - secrets: - SLACK_GHA_SUCCESS_WEBHOOK: ${{ secrets.SLACK_GHA_SUCCESS_WEBHOOK }} - SLACK_GHA_CANCELLED_WEBHOOK: ${{ secrets.SLACK_GHA_CANCELLED_WEBHOOK }} - SLACK_GHA_FIXED_WEBHOOK: ${{ secrets.SLACK_GHA_FIXED_WEBHOOK }} - SLACK_GHA_FAILURE_WEBHOOK: ${{ secrets.SLACK_GHA_FAILURE_WEBHOOK }} - - failed-workflow: - name: Failed workflow tasks - runs-on: ubuntu-latest - needs: [ test-coverage-report, slack-notifications ] - if: | - always() && - github.repository == 'WordPress/wordpress-develop' && - github.event_name != 'pull_request' && - github.run_attempt < 2 && - ( - needs.test-coverage-report.result == 'cancelled' || needs.test-coverage-report.result == 'failure' - ) - - steps: - - name: Dispatch workflow run - uses: actions/github-script@d4560e157075e2d93aa3022b5b51a42a880f1f93 # v6.3.0 - with: - retries: 2 - retry-exempt-status-codes: 418 - script: | - github.rest.actions.createWorkflowDispatch({ - owner: context.repo.owner, - repo: context.repo.repo, - workflow_id: 'failed-workflow.yml', - ref: 'trunk', - inputs: { - run_id: '${{ github.run_id }}' - } - }); diff --git a/.github/workflows/test-old-branches.yml b/.github/workflows/test-old-branches.yml deleted file mode 100644 index 9626a4971df93..0000000000000 --- a/.github/workflows/test-old-branches.yml +++ /dev/null @@ -1,88 +0,0 @@ -name: Test old branches - -on: - # Verify the workflow is successful when this file is updated. - push: - branches: - - trunk - paths: - - '.github/workflows/test-old-branches.yml' - # Run twice a month on the 1st and 15th at 00:00 UTC. - schedule: - - cron: '0 0 1 * *' - - cron: '0 0 15 * *' - -jobs: - dispatch-workflows-for-old-branches: - name: ${{ matrix.workflow }} for ${{ matrix.branch }} - runs-on: ubuntu-latest - timeout-minutes: 20 - if: ${{ github.repository == 'WordPress/wordpress-develop' }} - strategy: - fail-fast: false - matrix: - workflow: [ - 'coding-standards.yml', - 'javascript-tests.yml', - 'phpunit-tests.yml', - 'test-npm.yml' - ] - branch: [ - '5.9', '5.8', '5.7', '5.6', '5.5', '5.4', '5.3', '5.2', '5.1', '5.0', - '4.9', '4.8', '4.7', '4.6', '4.5', '4.4', '4.3', '4.2', '4.1', '4.0', - '3.9', '3.8', '3.7' - ] - include: - # PHP Compatibility testing was introduced in 5.5. - - branch: '5.9' - workflow: 'php-compatibility.yml' - - branch: '5.8' - workflow: 'php-compatibility.yml' - - branch: '5.7' - workflow: 'php-compatibility.yml' - - branch: '5.6' - workflow: 'php-compatibility.yml' - - branch: '5.5' - workflow: 'php-compatibility.yml' - - # End-to-end testing was introduced in 5.3 but was later removed as there were no meaningful assertions. - # Starting in 5.8 with #52905, some additional tests with real assertions were introduced. - # Branches 5.8 and newer should be tested to confirm no regressions are introduced. - - branch: '5.9' - workflow: 'end-to-end-tests.yml' - - branch: '5.8' - workflow: 'end-to-end-tests.yml' - exclude: - # Coding standards and JavaScript testing did not take place in 3.7. - - branch: '3.7' - workflow: 'coding-standards.yml' - - branch: '3.7' - workflow: 'javascript-tests.yml' - - # Run all branches monthly, but only the currently supported one twice per month. - steps: - - name: Dispatch workflow run - uses: actions/github-script@9ac08808f993958e9de277fe43a64532a609130e # v6.0.0 - if: ${{ github.event_name == 'push' || github.event.schedule == '0 0 15 * *' || matrix.branch == '5.9' }} - with: - github-token: ${{ secrets.GHA_OLD_BRANCH_DISPATCH }} - script: | - github.rest.actions.createWorkflowDispatch({ - owner: context.repo.owner, - repo: context.repo.repo, - workflow_id: '${{ matrix.workflow }}', - ref: '${{ matrix.branch }}' - }); - - slack-notifications: - name: Slack Notifications - uses: WordPress/wordpress-develop/.github/workflows/slack-notifications.yml@trunk - needs: [ dispatch-workflows-for-old-branches ] - if: ${{ github.repository == 'WordPress/wordpress-develop' && github.event_name != 'pull_request' && always() }} - with: - calling_status: ${{ needs.dispatch-workflows-for-old-branches.result == 'success' && 'success' || needs.dispatch-workflows-for-old-branches.result == 'cancelled' && 'cancelled' || 'failure' }} - secrets: - SLACK_GHA_SUCCESS_WEBHOOK: ${{ secrets.SLACK_GHA_SUCCESS_WEBHOOK }} - SLACK_GHA_CANCELLED_WEBHOOK: ${{ secrets.SLACK_GHA_CANCELLED_WEBHOOK }} - SLACK_GHA_FIXED_WEBHOOK: ${{ secrets.SLACK_GHA_FIXED_WEBHOOK }} - SLACK_GHA_FAILURE_WEBHOOK: ${{ secrets.SLACK_GHA_FAILURE_WEBHOOK }}