diff --git a/.github/actions/check-run/action.yml b/.github/actions/check-run/action.yml new file mode 100644 index 0000000000000..03eb444e9eed2 --- /dev/null +++ b/.github/actions/check-run/action.yml @@ -0,0 +1,71 @@ +name: "Check Run" +description: "Create or update a check run" +inputs: + id: + description: "Check run ID to update. If not given, a new run will be created" + sha: + description: "The SHA of the commit." + name: + description: "The name of the check. For example, \"code-coverage\"." + status: + description: "The current status. Can be one of: `queued`, `in_progress`, `completed`" + conclusion: + description: "The final conclusion of the check. Can be one of: `action_required`, `cancelled`, `failure`, `neutral`, `success`, `skipped`, `timed_out`" + title: + description: "Title of the check. Shown in the PR's checks list." + summary: + description: "Summary of the check. Can contain Markdown." + token: + description: "Access token. Defaults to `github.token`." + default: ${{ github.token }} +outputs: + id: + description: "Check run ID." + value: ${{ steps.run.outputs.id }} +runs: + using: composite + steps: + - id: run + shell: bash + env: + ID: ${{ inputs.id }} + SHA: ${{ inputs.sha }} + NAME: ${{ inputs.name }} + STATUS: ${{ inputs.status }} + CONCLUSION: ${{ inputs.conclusion }} + TITLE: ${{ inputs.title }} + SUMMARY: ${{ inputs.summary }} + TOKEN: ${{ inputs.token }} + run: | + if [[ -n "$ID" ]]; then + METHOD=PATCH + URL="${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/check-runs/$ID" + else + METHOD=POST + URL="${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/check-runs" + fi + + DATA="{}" + if [[ -n "$NAME" ]]; then + DATA="$(jq --arg v "$NAME" '.name |= $v' <<<"$DATA")" + fi + if [[ -n "$SHA" ]]; then + DATA="$(jq --arg v "$SHA" '.head_sha |= $v' <<<"$DATA")" + fi + if [[ -n "$STATUS" ]]; then + DATA="$(jq --arg v "$STATUS" '.status |= $v' <<<"$DATA")" + fi + if [[ -n "$CONCLUSION" ]]; then + DATA="$(jq --arg v "$CONCLUSION" '.conclusion |= $v' <<<"$DATA")" + fi + if [[ -n "$TITLE" ]]; then + DATA="$(jq --arg v "$TITLE" '.output.title |= $v' <<<"$DATA")" + fi + if [[ -n "$SUMMARY" ]]; then + DATA="$(jq --arg v "$SUMMARY" '.output.summary |= $v' <<<"$DATA")" + fi + + echo "Data: $DATA" + JSON="$(curl -v -X "$METHOD" --header "authorization: token $TOKEN" --url "$URL" --data "$DATA")" + echo "$JSON" + echo "::set-output name=id::$(jq -r .id <<<"$JSON")" diff --git a/.github/workflows/block-performance.yml b/.github/workflows/block-performance.yml deleted file mode 100644 index 5c2c054079c23..0000000000000 --- a/.github/workflows/block-performance.yml +++ /dev/null @@ -1,102 +0,0 @@ -name: Jetpack block performance - -on: - schedule: - - cron: '0 */12 * * *' - -jobs: - block-performance: - name: "Performance tests" - runs-on: ubuntu-latest - timeout-minutes: 50 # 2021-12-13: Successful runs seem to take 40 minutes - steps: - - uses: actions/checkout@v3 - - - uses: actions/setup-node@v3 - with: - node-version: 14 - - - uses: actions/checkout@v3 - with: - repository: 'WordPress/gutenberg' - path: 'gutenberg' - - - name: Build Gutenberg - working-directory: gutenberg - run: | - npm ci - npm run build - - - uses: actions/cache@v3 - with: - path: ~/.npm - key: ${{ runner.os }}-node-${{ hashFiles('gutenberg/**/package-lock.json') }} - restore-keys: | - ${{ runner.os }}-node- - - - name: Setup tools for J - uses: ./.github/actions/tool-setup - - - name: Build Production Jetpack - run: | - pnpm install - pnpm jetpack build plugins/jetpack -v --production - - - name: Environment set-up - working-directory: tools/e2e-commons - env: - CONFIG_KEY: ${{ secrets.E2E_CONFIG_KEY }} - run: | - # Gutenberg Performance tests require disable-animations.php test plugin to be available on a site. Below we inject the mapping for that plugin into a Docker config file - - echo "e2e:" >> ../docker/jetpack-docker-config.yml - echo " volumeMappings:" >> ../docker/jetpack-docker-config.yml - echo " gutenberg/packages/e2e-tests/plugins/disable-animations.php: /var/www/html/wp-content/plugins/disable-animations.php" >> ../docker/jetpack-docker-config.yml - - mkdir results - pnpm config:decrypt - pnpm env:start - - - name: Run performance tests - working-directory: tools/e2e-commons - run: | - node ./bin/performance.js - - - name: Send Slack notification - if: ${{ failure() }} - working-directory: tools/e2e-commons - env: - GITHUB_CONTEXT: ${{ toJson(github) }} - run: pnpm run slack status "failed" --report "Blocks performance" - - - name: Environment tear-down - if: ${{ always() }} - working-directory: tools/e2e-commons - continue-on-error: true - run: | - pnpm run tunnel:off - # Update permissions to workaround https://github.com/actions/cache/issues/753 - sudo chown -R runner:docker "$GITHUB_WORKSPACE/tools/docker" - - - name: Upload test artifacts - if: ${{ always() }} - continue-on-error: true - uses: actions/upload-artifact@v3 - with: - name: test-output-block-perf - path: tools/e2e-commons/results - - test-reports: - name: "Trigger test report workflow" - runs-on: ubuntu-latest - if: ${{ ! cancelled() }} - needs: block-performance - - steps: - - name: Repository Dispatch - uses: peter-evans/repository-dispatch@v2 - with: - token: ${{ secrets.E2E_TEST_REPORTS_TOKEN }} - repository: automattic/jetpack-e2e-reports - event-type: block-perf - client-payload: '{"run_id": "${{github.run_id}}", "repository": "${{github.repository}}"}' diff --git a/.github/workflows/build-docker.yml b/.github/workflows/build-docker.yml deleted file mode 100644 index 0562499d1d25f..0000000000000 --- a/.github/workflows/build-docker.yml +++ /dev/null @@ -1,100 +0,0 @@ -name: Build Docker -on: - push: - branches: [ 'trunk' ] - paths: - - 'tools/docker/Dockerfile' - - 'tools/docker/bin/run.sh' - - 'tools/docker/config/*' - - '.github/versions.sh' - - '.github/workflows/build-docker.yml' - pull_request: - paths: - - 'tools/docker/Dockerfile' - - 'tools/docker/bin/run.sh' - - 'tools/docker/config/*' - - '.github/versions.sh' - - '.github/workflows/build-docker.yml' -concurrency: - group: build-docker-${{ github.event_name }}-${{ github.ref }} - cancel-in-progress: true - -jobs: - build: - name: Build and publish Jetpack Dev Environment - runs-on: ubuntu-latest - permissions: - packages: write - contents: read - timeout-minutes: 60 # 2021-10-26: Build for arm64 is S-L-O-W. Sigh. - - steps: - - uses: actions/checkout@v3 - - - name: Set up qemu - uses: docker/setup-qemu-action@v2 - with: - platforms: arm64 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - - name: Log in to Docker Hub - uses: docker/login-action@v2 - with: - username: matticbot - password: ${{ secrets.DOCKER_HUB_MATTICBOT_TOKEN }} - - - name: Log in to GitHub Packages - uses: docker/login-action@v2 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Fetch build args - id: buildargs - run: | - source .github/versions.sh - echo "::set-output name=php-version::$PHP_VERSION" - echo "::set-output name=composer-version::$COMPOSER_VERSION" - echo "::set-output name=node-version::$NODE_VERSION" - echo "::set-output name=pnpm-version::$PNPM_VERSION" - - # We're not git-tagging for the env. Just tag all trunk builds as latest. - if [[ "$GITHUB_EVENT_NAME" == "push" ]]; then - echo "::set-output name=tags::type=raw,latest" - echo "::set-output name=images::automattic/jetpack-wordpress-dev%0Aghcr.io/automattic/jetpack-wordpress-dev" - elif [[ "$GITHUB_EVENT_NAME" == "pull_request" ]]; then - echo "::set-output name=tags::type=ref,event=pr" - echo "::set-output name=images::ghcr.io/automattic/jetpack-wordpress-dev" - else - echo "Unknown GITHUB_EVENT_NAME $GITHUB_EVENT_NAME" - exit 1 - fi - - - name: Extract Docker metadata - id: meta - uses: docker/metadata-action@v4 - with: - flavor: latest=false - tags: ${{ steps.buildargs.outputs.tags }} - images: ${{ steps.buildargs.outputs.images }} - labels: | - org.opencontainers.image.title=Jetpack Development Environment - org.opencontainers.image.description=Unified environment for developing in the Jetpack Monorepo using Docker containers. - org.opencontainers.image.documentation=${{ github.server_url }}/${{ github.repository }}/blob/trunk/tools/docker/README.md - - - name: Build and push Docker image - uses: docker/build-push-action@v3 - with: - context: tools/docker - platforms: linux/amd64,linux/arm64 - push: true - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - build-args: | - PHP_VERSION=${{ steps.buildargs.outputs.php-version }} - COMPOSER_VERSION=${{ steps.buildargs.outputs.composer-version }} - NODE_VERSION=${{ steps.buildargs.outputs.node-version }} - PNPM_VERSION=${{ steps.buildargs.outputs.pnpm-version }} diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4da3f0f829b1b..0f24e7af4624a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -128,61 +128,11 @@ jobs: comment_id: +COMMENT_ID, } ); - upgrade_test: - name: Test plugin upgrades - runs-on: ubuntu-latest - needs: build - if: needs.build.outputs.any_plugins == 'true' - timeout-minutes: 10 # 2022-03-04: Successful runs seem to take about 3 minutes, but give some extra time for the downloads. - services: - db: - image: mariadb:latest - env: - MARIADB_ROOT_PASSWORD: wordpress - ports: - - 3306:3306 - options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=5 - container: - image: ghcr.io/automattic/jetpack-wordpress-dev:latest - env: - WP_DOMAIN: localhost - WP_ADMIN_USER: wordpress - WP_ADMIN_EMAIL: wordpress@example.com - WP_ADMIN_PASSWORD: wordpress - WP_TITLE: Hello World - MYSQL_HOST: db:3306 - MYSQL_DATABASE: wordpress - MYSQL_USER: root - MYSQL_PASSWORD: wordpress - HOST_PORT: 80 - ports: - - 80:80 - steps: - - uses: actions/checkout@v3 - with: - path: monorepo - - - name: Download build artifact - uses: actions/download-artifact@v3 - with: - name: jetpack-build - - name: Extract build archive - run: tar --xz -xvvf build.tar.xz - - - name: Setup WordPress - run: monorepo/.github/files/test-plugin-update/setup.sh - - - name: Prepare plugin zips - run: monorepo/.github/files/test-plugin-update/prepare-zips.sh - - - name: Test upgrades - run: monorepo/.github/files/test-plugin-update/test.sh - jetpack_beta: name: Create artifact for Jetpack Beta plugin runs-on: ubuntu-latest needs: build - if: ( github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == 'Automattic/jetpack' ) && needs.build.outputs.any_plugins == 'true' + if: ( github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == 'anomiex/jetpack' ) && needs.build.outputs.any_plugins == 'true' timeout-minutes: 10 # 2021-06-24: Successful runs should take just a few seconds now. But sometimes the upload is slow. steps: - uses: actions/checkout@v3 @@ -266,51 +216,51 @@ jobs: # Only need to retain for a day since the beta builder slurps it up to distribute. retention-days: 1 - - name: Inform Beta Download webhook - if: steps.prepare.outputs.plugin-data != '{}' - env: - SECRET: ${{ secrets.JPBETA_SECRET }} - PLUGIN_DATA: ${{ steps.prepare.outputs.plugin-data }} - PR: ${{ github.event.number }} - run: | - curl -v --fail -L \ - --url "https://betadownload.jetpack.me/gh-action.php?run_id=$GITHUB_RUN_ID&pr=$PR&commit=$GITHUB_SHA" \ - --form-string "repo=$GITHUB_REPOSITORY" \ - --form-string "branch=${GITHUB_REF#refs/heads/}" \ - --form-string "plugins=$PLUGIN_DATA" \ - --form-string "secret=$SECRET" - - update_mirrors: - name: Push to mirror repos - runs-on: ubuntu-latest - needs: build - - if: github.event_name == 'push' && github.repository == 'Automattic/jetpack' - - # Not setting a job-level timeout because it would be kind of pointless with the blocking step. Set a step timeout for all other steps instead. - steps: - - uses: actions/checkout@v3 - with: - path: monorepo - timeout-minutes: 1 # 2021-01-18: Successful runs seem to take a few seconds - - - name: Download build artifact - uses: actions/download-artifact@v3 - with: - name: jetpack-build - timeout-minutes: 2 # 2022-03-15: Successful runs normally take a few seconds, but on occasion they've been taking 60+ recently. - - name: Extract build archive - run: tar --xz -xvvf build.tar.xz - timeout-minutes: 1 # 2021-01-18: Successful runs seem to take a few seconds - - - name: Wait for prior instances of the workflow to finish - uses: ./monorepo/.github/actions/turnstile - - - name: Push changed projects - uses: ./monorepo/projects/github-actions/push-to-mirrors - with: - source-directory: ${{ github.workspace }}/monorepo - token: ${{ secrets.API_TOKEN_GITHUB }} - username: matticbot - working-directory: ${{ github.workspace }}/build - timeout-minutes: 5 # 2021-01-18: Successful runs seem to take about half a minute. +# - name: Inform Beta Download webhook +# if: steps.prepare.outputs.plugin-data != '{}' +# env: +# SECRET: ${{ secrets.JPBETA_SECRET }} +# PLUGIN_DATA: ${{ steps.prepare.outputs.plugin-data }} +# PR: ${{ github.event.number }} +# run: | +# curl -v --fail -L \ +# --url "https://betadownload.jetpack.me/gh-action.php?run_id=$GITHUB_RUN_ID&pr=$PR&commit=$GITHUB_SHA" \ +# --form-string "repo=$GITHUB_REPOSITORY" \ +# --form-string "branch=${GITHUB_REF#refs/heads/}" \ +# --form-string "plugins=$PLUGIN_DATA" \ +# --form-string "secret=$SECRET" + +# update_mirrors: +# name: Push to mirror repos +# runs-on: ubuntu-latest +# needs: build +# +# if: github.event_name == 'push' && github.repository == 'Automattic/jetpack' +# +# # Not setting a job-level timeout because it would be kind of pointless with the blocking step. Set a step timeout for all other steps instead. +# steps: +# - uses: actions/checkout@v3 +# with: +# path: monorepo +# timeout-minutes: 1 # 2021-01-18: Successful runs seem to take a few seconds +# +# - name: Download build artifact +# uses: actions/download-artifact@v3 +# with: +# name: jetpack-build +# timeout-minutes: 2 # 2022-03-15: Successful runs normally take a few seconds, but on occasion they've been taking 60+ recently. +# - name: Extract build archive +# run: tar --xz -xvvf build.tar.xz +# timeout-minutes: 1 # 2021-01-18: Successful runs seem to take a few seconds +# +# - name: Wait for prior instances of the workflow to finish +# uses: ./monorepo/.github/actions/turnstile +# +# - name: Push changed projects +# uses: ./monorepo/projects/github-actions/push-to-mirrors +# with: +# source-directory: ${{ github.workspace }}/monorepo +# token: ${{ secrets.API_TOKEN_GITHUB }} +# username: matticbot +# working-directory: ${{ github.workspace }}/build +# timeout-minutes: 5 # 2021-01-18: Successful runs seem to take about half a minute. diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml deleted file mode 100644 index 74c392e7c3f1a..0000000000000 --- a/.github/workflows/codeql-analysis.yml +++ /dev/null @@ -1,39 +0,0 @@ -name: "CodeQL Code Scanning Analysis" - -on: - push: - branches: [ trunk ] - pull_request: - branches: [ trunk ] - schedule: - - cron: '0 19 * * 0' -concurrency: - group: codeql-analysis-${{ github.event_name }}-${{ github.ref }} - cancel-in-progress: true - -jobs: - analyze: - name: Analyze - runs-on: ubuntu-latest - timeout-minutes: 7 # 2021-01-18: Successful runs seem to take 3-5 minutes - - strategy: - fail-fast: false - matrix: - language: ['javascript'] - - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - # Initializes the CodeQL tools for scanning. - - name: Initialize CodeQL - uses: github/codeql-action/init@v2 - with: - languages: ${{ matrix.language }} - - - name: Autobuild - uses: github/codeql-action/autobuild@v2 - - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml deleted file mode 100644 index af1636d9f9c08..0000000000000 --- a/.github/workflows/e2e-tests.yml +++ /dev/null @@ -1,200 +0,0 @@ -name: E2E Tests - -on: - pull_request: - paths-ignore: - - '**.md' - push: - branches: [ trunk ] - paths-ignore: - - '**.md' - schedule: - - cron: '0 */12 * * *' # gutenberg run, every 12 hours - if you update this, also update it in .github/files/create-e2e-projects-matrix.sh - - cron: '30 */4 * * *' # atomic run, every 4 hours - if you update this, also update it in .github/files/create-e2e-projects-matrix.sh - -concurrency: - group: e2e-tests-${{ github.event_name }}-${{ github.ref }} - cancel-in-progress: true - -jobs: - create-test-matrix: - name: "Determine tests matrix" - runs-on: ubuntu-latest - timeout-minutes: 3 - outputs: - matrix: ${{ steps.evaluate.outputs.matrix }} - runName: ${{ steps.evaluate.outputs.runName }} - steps: - - uses: actions/checkout@v3 - - # For pull requests, list-changed-projects.sh needs the merge base. - - name: Deepen to merge base - if: github.event_name == 'pull_request' - uses: ./.github/actions/deepen-to-merge-base - - - name: Setup tools - uses: ./.github/actions/tool-setup - - # Required for list-changed-projects.sh - - name: Install monorepo - run: | - pnpm install - - - name: Create test plan - id: evaluate - env: - CRON: ${{ github.event.schedule }} - run: | - TEST_PLAN="$(.github/files/create-e2e-projects-matrix.sh)" - echo "$TEST_PLAN" - - MATRIX=$(jq -r -c ".matrix" <<<"$TEST_PLAN") - echo "$MATRIX" - echo "::set-output name=matrix::$MATRIX" - - RUN_NAME=$(jq -r -c ".run" <<<"$TEST_PLAN") - echo "$RUN_NAME" - echo "::set-output name=runName::$RUN_NAME" - - e2e-tests: - name: "${{ matrix.project }} e2e tests" - runs-on: ubuntu-latest - needs: create-test-matrix - timeout-minutes: 25 - strategy: - fail-fast: false - matrix: - include: ${{ fromJson( needs.create-test-matrix.outputs.matrix ) }} - if: github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name - - steps: - - uses: actions/checkout@v3 - - - name: Setup tools - uses: ./.github/actions/tool-setup - - - name: Install monorepo - run: | - pnpm install - - - name: Test environment set-up - working-directory: ${{ matrix.path }} - env: - CONFIG_KEY: ${{ secrets.E2E_CONFIG_KEY }} - COMPOSER_ROOT_VERSION: "dev-trunk" - RUN_NAME: ${{ needs.create-test-matrix.outputs.runName }} - PROJECT_NAME: ${{ matrix.project }} - run: | - echo "::group::Decrypt config" - pnpm run config:decrypt - echo "::endgroup::" - - if [ "${RUN_NAME}" != atomic ]; then - echo "::group::Build plugin(s)" - pnpm run build - echo "::endgroup::" - - echo "::group::Start docker environment" - pnpm run env:up - echo "::endgroup::" - - echo "::group::Create tunnel" - pnpm run tunnel:up - echo "::endgroup::" - else - echo "TEST_SITE=atomic" >> $GITHUB_ENV - fi - - if [ "${RUN_NAME}" == gutenberg ]; then - echo "::group::Setting up Gutenberg" - pnpm e2e-env gb-setup - echo "::endgroup::" - fi - - if [ "${PROJECT_NAME}" == "Jetpack update" ]; then - echo "SKIP_ENV_CLEAN=true" >> $GITHUB_ENV - fi - - - name: Run ${{ matrix.project }} tests - working-directory: ${{ matrix.path }} - env: - JSON_ARGS: ${{ toJSON(matrix.testArgs) }} - run: | - mapfile -t TEST_ARGS < <(jq -r '.[]' <<<"$JSON_ARGS") - pnpm run test:run "${TEST_ARGS[@]}" - - - name: Send Slack notification - if: ${{ failure() && ! cancelled() }} - env: - GITHUB_CONTEXT: ${{ toJson(github) }} - SUITE: ${{ matrix.project }} - JSON_ARGS: ${{ toJSON(matrix.slackArgs) }} - working-directory: ${{ matrix.path }} - run: | - mapfile -t ARGS < <(jq -r '.[]' <<<"$JSON_ARGS") - pnpm run slack suite "$SUITE" "${ARGS[@]}" - - - name: Test environment tear-down - if: ${{ always() }} - working-directory: ${{ matrix.path }} - continue-on-error: true - run: | - pnpm run tunnel:down - # Update permissions to workaround https://github.com/actions/cache/issues/753 - sudo chown -R runner:docker "$GITHUB_WORKSPACE/tools/docker" - - - name: Upload test artifacts - if: ${{ always() }} - continue-on-error: true - uses: actions/upload-artifact@v3 - with: - name: test-output-${{ matrix.project }} - path: ${{ matrix.path }}/output - - test-report: - name: "Test report" - runs-on: ubuntu-latest - if: ${{ ! cancelled() }} - needs: [create-test-matrix, e2e-tests] - - steps: - - uses: actions/checkout@v3 - - - name: Trigger test report workflow - uses: ./.github/actions/test-report-dispatch - with: - token: ${{ secrets.E2E_TEST_REPORTS_TOKEN }} - event_type: e2e - report_name: ${{needs.create-test-matrix.outputs.runName}} - - slack-notification: - name: "Slack notification" - runs-on: ubuntu-latest - if: ${{ ! cancelled() }} # need to run on failure and also on success, so it can send notifications when tests passed on re-runs - needs: [create-test-matrix, e2e-tests] - - steps: - - uses: actions/checkout@v3 - - - name: Set up tools - uses: ./.github/actions/tool-setup - - - name: Build action - env: - COMPOSER_ROOT_VERSION: dev-trunk - run: | - pnpm install - composer install - composer build-development - working-directory: ./projects/github-actions/test-results-to-slack - - - name: "Send notification" - uses: ./projects/github-actions/test-results-to-slack - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - slack_token: ${{ secrets.SLACK_TOKEN }} - slack_channel: ${{ secrets.SLACK_E2E_CHANNEL }} - slack_icon_emoji: ":jetpack:" - suite_name: ${{needs.create-test-matrix.outputs.runName}} - - diff --git a/.github/workflows/gardening.yml b/.github/workflows/gardening.yml deleted file mode 100644 index 934537c66c037..0000000000000 --- a/.github/workflows/gardening.yml +++ /dev/null @@ -1,80 +0,0 @@ -name: Gardening -on: - pull_request_target: # When a PR is opened, edited, updated, closed, or a label is added. - types: [opened, reopened, synchronize, edited, labeled, closed ] - issues: # For auto-triage of issues. - types: [opened, reopened, edited, closed] - issue_comment: # To gather support references in issue comments. - types: [created] - push: - branches: - - trunk # Every time a PR is merged to trunk. -concurrency: - # For pull_request_target, cancel any concurrent jobs with the same type (e.g. "opened", "labeled") and branch. - # Don't cancel any for other events, accomplished by grouping on the unique run_id. - group: gardening-${{ github.event_name }}-${{ github.event.action }}-${{ github.event_name == 'pull_request_target' && github.event.pull_request.head.ref || github.run_id }} - cancel-in-progress: true - -jobs: - # review-crew-afk: - # name: "Review check" - # runs-on: ubuntu-latest - # if: github.event_name == 'pull_request_target' && github.event.action == 'labeled' && github.event.label.name == '[Status] Needs Review' - # timeout-minutes: 1 # 2021-01-18: Successful runs probably take a few seconds - # steps: - # - name: Comment - # uses: actions/github-script@0.8.0 - # with: - # github-token: ${{ secrets.GITHUB_TOKEN }} - # script: | - # github.issues.createComment({ - # issue_number: context.issue.number, - # owner: context.repo.owner, - # repo: context.repo.repo, - # body: 'Howdy! The Jetpack team has disappeared for a few days to a secret island lair to concoct new ways to make Jetpack one hundred billion percent better. As a result, your Pull Request may not be reviewed right away. Do not worry, we will be back next week to look at your work! Thank you for your understanding.' - # }) - repo-gardening: - name: "Manage labels and assignees" - runs-on: ubuntu-latest - if: github.event_name == 'pull_request_target' || github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name - timeout-minutes: 10 # 2021-03-12: Successful runs seem to take a few seconds, but can sometimes take a lot longer since we wait for previous runs to complete. - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Setup tools - uses: ./.github/actions/tool-setup - - - name: Building Action - env: - COMPOSER_ROOT_VERSION: dev-trunk - run: | - pnpm install - composer install - composer build-development - working-directory: ./projects/github-actions/repo-gardening - - - name: Checkout the PR - if: github.event_name == 'pull_request_target' && github.event.action != 'closed' - uses: actions/checkout@v3 - with: - ref: ${{ github.event.pull_request.head.ref }} - repository: ${{ github.event.pull_request.head.repo.full_name }} - # DO NOT run any code in this checkout. Not even an `npm install`. - path: ./pr-checkout - - - name: Wait for prior instances of the workflow to finish - uses: ./.github/actions/turnstile - - - name: "Run the action (assign, manage milestones, for issues and PRs)" - uses: ./projects/github-actions/repo-gardening - env: - PR_WORKSPACE: ${{ github.workspace }}${{ github.event_name == 'pull_request_target' && '/pr-checkout' || '' }} - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - slack_token: ${{ secrets.SLACK_TOKEN }} - slack_team_channel: ${{ secrets.SLACK_TEAM_CHANNEL }} - slack_design_channel: ${{ secrets.SLACK_DESIGN_CHANNEL }} - slack_editorial_channel: ${{ secrets.SLACK_EDITORIAL_CHANNEL }} - slack_he_triage_channel: ${{ secrets.SLACK_HE_TRIAGE_CHANNEL }} - slack_quality_channel: ${{ secrets.SLACK_QUALITY_CHANNEL }} diff --git a/.github/workflows/issues-to-projects.yml b/.github/workflows/issues-to-projects.yml deleted file mode 100644 index d721794989fc7..0000000000000 --- a/.github/workflows/issues-to-projects.yml +++ /dev/null @@ -1,49 +0,0 @@ -# Add issues and PRs to Organization Project Board(s), -# based on labels and/or requested reviewers. - -# -# Requires a Personal Access Token with the following permissions in a secret PUSH_ISSUES_TO_PROJECTS: -# - repo -# - write:org -# - read:org -# - -name: Add issues and PRs to Organization Project Boards - -on: - issues: - types: [ opened, edited, reopened, labeled ] - pull_request_target: - types: [ review_requested ] - -# map fields with customized labels -env: - pending_review: 👀 Pending review - -jobs: - assign_boost_issues: - name: Assign Boost issues to Boost board. - runs-on: ubuntu-latest - if: github.event_name == 'issues' - steps: - # Jetpack Boost: Push to Boost Maintenance Board if labelled "[Plugin] Boost" - - uses: leonsteinhaeuser/project-beta-automations@v1.2.1 - if: contains(github.event.issue.labels.*.name, '[Plugin] Boost') - with: - gh_token: ${{ secrets.PUSH_ISSUES_TO_PROJECT_TOKEN }} - organization: 'automattic' - project_id: 322 - resource_node_id: ${{ github.event.issue.node_id }} - assign_jarvis_review_prs: - name: Assign PRs where JARVIS is requested as reviewer to the JARVIS board. - runs-on: ubuntu-latest - if: github.event_name == 'pull_request_target' && github.event.action == 'review_requested' - steps: - - uses: leonsteinhaeuser/project-beta-automations@v1.2.1 - if: contains(github.event.pull_request.requested_teams, 'Automattic/jarvis-jetpack-quality') - with: - gh_token: ${{ secrets.PUSH_ISSUES_TO_PROJECT_TOKEN }} - organization: 'automattic' - project_id: 424 - resource_node_id: ${{ github.event.pull_request.node_id }} - status_value: ${{ env.pending_review }} diff --git a/.github/workflows/linting.yml b/.github/workflows/linting.yml deleted file mode 100644 index f9191beecf6a2..0000000000000 --- a/.github/workflows/linting.yml +++ /dev/null @@ -1,487 +0,0 @@ -# This workflow holds jobs for linting, currently PHP and JavaScript. -# -# The jobs are all set up to only run if appropriate files have changed; the -# `changed_files` job is used to determine whether files have changed in -# various categories so the rest of the jobs can know whether to run or not. - -name: Linting - -on: pull_request -concurrency: - group: linting-${{ github.event_name }}-${{ github.ref }} - cancel-in-progress: true - -env: - COMPOSER_ROOT_VERSION: "dev-trunk" - -jobs: - - ### Job to categorize changed files. Other jobs depend on this to know when they should run. - changed_files: - name: detect changed files - runs-on: ubuntu-latest - timeout-minutes: 1 # 2021-01-18: Successful runs seem to take a few seconds - outputs: - # Whether any PHP files have changed. - php: ${{ steps.filter.outputs.php }} - - # Whether any JavaScript files have changed. - js: ${{ steps.filter.outputs.js }} - - # Whether any lock files have changed. - lockfiles: ${{ steps.filter.outputs.lockfiles }} - - # Whether any GitHub Actions yaml files have changed. - ghactionsfiles: ${{ steps.filter.outputs.ghactionsfiles }} - - # Whether any miscellaneous files related to linting have changed. - misc: ${{ steps.filter.outputs.misc }} - - # Whether any miscellaneous files related to PHP linting have changed. - misc_php: ${{ steps.filter.outputs.misc == 'true' || steps.filter.outputs.misc_php == 'true' }} - - # Whether any miscellaneous files related to JS linting have changed. - misc_js: ${{ steps.filter.outputs.misc == 'true' || steps.filter.outputs.misc_js == 'true' }} - - # JSON string holding an array of files in phpcs-excludelist.json that have changed. - php_excluded_files: ${{ steps.filterPHP.outputs.php_excluded_files }} - - # JSON string holding an array of files in eslint-excludelist.json that have changed. - js_excluded_files: ${{ steps.filterJS.outputs.js_excluded_files }} - - # Whether any excluded files were modified or deleted. - excludelist: ${{ steps.filterExcludeList.outputs.excluded_files != '[]' || steps.filter.outputs.misc == 'true' || steps.filter.outputs.misc_php == 'true' || steps.filter.outputs.misc_js == 'true' || steps.filter.outputs.misc_excludelist == 'true' }} - - steps: - - uses: actions/checkout@v3 - - - uses: dorny/paths-filter@v2 - id: filter - with: - list-files: json - filters: | - php: - # If any PHP file changed, they need checking. - - added|modified: - - '**.php' - js: - # If any JS file changed, they need checking. - - added|modified: - - '**.cjs' - - '**.js' - - '**.jsx' - - '**.mjs' - - '**.ts' - - '**.tsx' - - '**.svelte' - excludelist: - # If any PHP or JS file changed or was deleted, we need to check the excludelist. - - modified|deleted: - - '**.php' - - '**.js' - - '**.jsx' - - '**.ts' - lockfiles: - - 'composer.json' - - 'composer.lock' - - 'package.json' - - 'pnpm-lock.yaml' - - '**/composer.json' - - '**/composer.lock' - - '**/package.json' - ghactionsfiles: - - '.github/workflows/*.{yml,yaml}' - - '.github/actions/*/action.{yml,yaml}' - - 'projects/github-actions/*/action.{yml,yaml}' - misc_php: - # If composer, phpcs config, or the codesniffer package itself changed, there may be a new standard. - - 'composer.json' - - 'composer.lock' - - '.phpcs.config.xml' - - '.phpcs.xml.dist' - - '.phpcsignore' - - '**/.phpcs.dir.xml' - - '**/.phpcsignore' - - 'projects/packages/codesniffer/**' - # If the excludelist changed, run to ensure newly non-excluded files pass. - - 'tools/phpcs-excludelist.json' - # If other files used by this workflow changed, run it to test those changes. - - 'tools/parallel-lint.sh' - - '.github/files/php-linting-phpcs.xml' - - '.github/matchers/phpcs-problem-matcher.json' - - '.github/matchers/php-lint-problem-matcher.json' - misc_js: - # If package or eslint config changed, there may be new checks. - - 'package.json' - - 'tools/js-tools/package.json' - - 'pnpm-lock.yaml' - - '.eslintignore' - - '.eslintignore.root' - - '.eslintrc.*' - - '**/.eslintignore' - - '**/.eslintrc.*' - # If the excludelist changed, run to ensure newly non-excluded files pass. - - 'tools/eslint-excludelist.json' - misc_excludelist: - - 'tools/cleanup-excludelists.sh' - - 'tools/js-tools/check-excludelist-diff.js' - misc: - # If the workflow itself changed, everything should re-run. - - '.github/workflows/linting.yml' - - - id: filterPHP - shell: bash - env: - PHP_FILES: ${{ steps.filter.outputs.php_files }} - run: | - EXCLUDED_FILES=$(jq --argjson files "$PHP_FILES" --slurpfile excludes tools/phpcs-excludelist.json -nc '$files - ($files - $excludes[0])') - echo "::set-output name=php_excluded_files::$EXCLUDED_FILES" - echo "Excluded files:" - jq --argjson files "$EXCLUDED_FILES" -nr '" - " + $files[]' - - - id: filterJS - shell: bash - env: - JS_FILES: ${{ steps.filter.outputs.js_files }} - run: | - EXCLUDED_FILES=$(jq --argjson files "$JS_FILES" --slurpfile excludes tools/eslint-excludelist.json -nc '$files - ($files - $excludes[0])') - echo "::set-output name=js_excluded_files::$EXCLUDED_FILES" - echo "Excluded files:" - jq --argjson files "$EXCLUDED_FILES" -nr '" - " + $files[]' - - - id: filterExcludeList - shell: bash - env: - FILES: ${{ steps.filter.outputs.excludelist_files }} - run: | - EXCLUDED_FILES=$(jq --argjson files "$FILES" --slurpfile phpexcludes tools/phpcs-excludelist.json --slurpfile jsexcludes tools/eslint-excludelist.json -nc '$files - ($files - $phpexcludes[0] - $jsexcludes[0])') - echo "::set-output name=excluded_files::$EXCLUDED_FILES" - echo "Excluded files:" - jq --argjson files "$EXCLUDED_FILES" -nr '" - " + $files[]' - - ### Runs `php -l` over all PHP files, in all relevant PHP versions - # Local equivalent: `composer php:lint` - php_lint: - name: PHP lint (${{ matrix.php-versions }}) - runs-on: ubuntu-latest - needs: changed_files - continue-on-error: ${{ matrix.experimental }} - timeout-minutes: 3 # 2021-01-18: Successful runs seem to take ~1 minute - - strategy: - fail-fast: false - matrix: - php-versions: [ '5.6', '7.0', '7.4', '8.0', '8.1' ] - experimental: [ false ] - - steps: - - uses: actions/checkout@v3 - - - name: Setup tools - uses: ./.github/actions/tool-setup - with: - php: ${{ matrix.php-versions }} - node: false - - - name: Install dependencies - run: | - # Install stuff ignoring platform reqs. - composer install --ignore-platform-reqs - # Remove stuff we don't need here that fails some platform reqs. - # This will complain if we missed any. - composer remove --dev sirbrillig/phpcs-changed automattic/jetpack-codesniffer - - - name: Run linter - run: | - echo "::add-matcher::.github/matchers/php-lint-problem-matcher.json" - composer php:lint -- --checkstyle - echo "::remove-matcher owner=php-lint" - - ### Runs phpcs on all PHP files not listed in phpcs-excludelist.json. - # Local equivalent: `composer phpcs:lint:required` - phpcs: - name: PHP Code Sniffer (non-excluded files only) - runs-on: ubuntu-latest - needs: changed_files - if: needs.changed_files.outputs.php == 'true' || needs.changed_files.outputs.misc_php == 'true' - timeout-minutes: 5 # 2021-01-18: Successful runs seem to take ~1 minute. Leaving some extra for future expansion. - - steps: - - uses: actions/checkout@v3 - - - name: Setup tools - uses: ./.github/actions/tool-setup - with: - node: false - - - name: Install dependencies - run: composer install - - - name: Run phpcs - run: | - echo "::add-matcher::.github/matchers/phpcs-problem-matcher.json" - composer phpcs:lint:required -- --report=emacs --standard=.github/files/php-linting-phpcs.xml - echo "::remove-matcher owner=phpcs" - - ### Runs PHPCompatibility over all PHP files. - # Local equivalent: `composer phpcs:compatibility` - phpcompatibility: - name: PHP Compatibility - runs-on: ubuntu-latest - needs: changed_files - if: needs.changed_files.outputs.php == 'true' || needs.changed_files.outputs.misc_php == 'true' - timeout-minutes: 5 # 2021-01-18: Successful runs seem to take ~1 minute. Leaving some extra for future expansion. - - steps: - - uses: actions/checkout@v3 - - - name: Setup tools - uses: ./.github/actions/tool-setup - with: - node: false - - - name: Install dependencies - run: composer install - - - name: Run phpcs for PHPCompatibility - run: | - echo "::add-matcher::.github/matchers/phpcs-problem-matcher.json" - composer phpcs:compatibility -- --report=emacs . - echo "::remove-matcher owner=phpcs" - - ### Runs phpcs-changed on PHP files listed in phpcs-excludelist.json. - # Local equivalent: `composer phpcs:changed -- --git-base= ` - # `` is the branch this PR is to be merged into, probably `origin/trunk`. - # - # Pre-commit, you might also `git add` the relevant files and run `composer phpcs:changed` - phpcs_changed: - name: PHP Code Sniffer (changes to excluded files only) - runs-on: ubuntu-latest - needs: changed_files - if: needs.changed_files.outputs.php_excluded_files != '[]' - continue-on-error: true - timeout-minutes: 5 # 2021-01-18: Successful runs seem to take ~1 minute. Leaving some extra for future expansion. - - steps: - # We don't need full git history, but phpcs-changed does need everything up to the merge-base. - - uses: actions/checkout@v3 - with: - ref: ${{ github.event.pull_request.head.sha }} - fetch-depth: 10 - - uses: ./.github/actions/deepen-to-merge-base - - - name: Setup tools - uses: ./.github/actions/tool-setup - with: - node: false - - - name: Install dependencies - run: composer install - - - name: Run phpcs-changed - shell: bash - env: - SHA: ${{ github.event.pull_request.base.sha }} - FILES: ${{ needs.changed_files.outputs.php_excluded_files }} - run: | - echo "::add-matcher::.github/matchers/phpcs-problem-matcher.json" - composer phpcs:changed -- --report=json --standard=.github/files/php-linting-phpcs.xml --git-base=$SHA $(jq -rn --argjson files "$FILES" '$files[]') | - jq -r '.files | to_entries | .[] | .key as $key | .value.messages[] | [ $key, ":", .line, ":", .column, ": ", .type, " - ", .message, " (", .source, ")" ] | map(tostring) | join("")' - echo "::remove-matcher owner=phpcs" - - ### Runs eslint on JS files not listed in eslint-excludelist.json - # Local equivalent: `pnpm run lint-required` - eslint: - name: ESLint (non-excluded files only) - runs-on: ubuntu-latest - needs: changed_files - if: needs.changed_files.outputs.js == 'true' || needs.changed_files.outputs.misc_js == 'true' - timeout-minutes: 10 # 2021-03-05: Runs now take ~5 minutes due to now installing all php/js deps to ensure valid linting. - - steps: - - uses: actions/checkout@v3 - - - name: Setup tools - uses: ./.github/actions/tool-setup - - - name: Monorepo pnpm install - run: pnpm install - - run: pnpm run lint-required - - ### Runs eslint-changed on JS files listed in eslint-excludelist.json. - # Local equivalent: `pnpm run lint-changed --git-base=` - # `` is the branch this PR is to be merged into, probably `origin/trunk`. - # - # Pre-commit, you might also `git add` the relevant files and run `pnpm run lint-changed` - eslint_changed: - name: ESLint (changes to excluded files only) - runs-on: ubuntu-latest - needs: changed_files - if: needs.changed_files.outputs.js_excluded_files != '[]' - continue-on-error: true - timeout-minutes: 10 # 2021-03-05: Taking ~4:30 now due to now installing all php/js deps to ensure valid linting. - - steps: - # We don't need full git history, but eslint-changed does need everything up to the merge-base. - - uses: actions/checkout@v3 - with: - ref: ${{ github.event.pull_request.head.sha }} - fetch-depth: 10 - - uses: ./.github/actions/deepen-to-merge-base - - - name: Setup tools - uses: ./.github/actions/tool-setup - - - name: Monorepo pnpm install - run: pnpm install - - name: Run eslint-changed - env: - SHA: ${{ github.event.pull_request.base.sha }} - FILES: ${{ needs.changed_files.outputs.js_excluded_files }} - run: pnpm run lint-changed --git-base=$SHA $(jq -rn --argjson files "$FILES" '$files[]') - - ### Lints GitHub Actions yaml files. - # Local equivalent: `./tools/js-tools/lint-gh-actions.js ` - lint_gh_actions: - name: Lint GitHub Actions yaml files - runs-on: ubuntu-latest - needs: changed_files - if: needs.changed_files.outputs.ghactionsfiles == 'true' || needs.changed_files.outputs.misc == 'true' - timeout-minutes: 5 # 2021-03-24: Pnpm stuff takes about a minute. - steps: - - uses: actions/checkout@v3 - - - name: Setup tools - uses: ./.github/actions/tool-setup - with: - php: false - - - run: pnpm install - - name: Run lint - run: ./tools/js-tools/lint-gh-actions.js -v '.github/workflows/*.{yml,yaml}' '.github/actions/*/action.{yml,yaml}' 'projects/github-actions/*/action.{yml,yaml}' - - ### Checks that copied files (e.g. readme, license) are in sync - # Local equivalent: `./tools/check-copied-files.sh` - copied_files: - name: Copied files are in sync - runs-on: ubuntu-latest - timeout-minutes: 1 # 2021-01-18: Successful runs seem to take a few seconds. - - steps: - - uses: actions/checkout@v3 - - run: ./tools/check-copied-files.sh - - ### Runs tools/cleanup-excludelists.sh and checks for any changes - # Local equivalent: `tools/cleanup-excludelists.sh` - check_excludelists: - name: Check linter exclude lists - runs-on: ubuntu-latest - needs: changed_files - if: needs.changed_files.outputs.excludelist == 'true' - timeout-minutes: 10 # 2022-05-11: The check itself takes 4 minutes. - steps: - - uses: actions/checkout@v3 - - - name: Setup tools - uses: ./.github/actions/tool-setup - - - run: composer install - - name: Monorepo pnpm install - run: pnpm install - - - name: Cleanup excludelists - run: tools/cleanup-excludelists.sh - - name: Check for changes to exclude lists - run: tools/js-tools/check-excludelist-diff.js - - ### Checks that changelogger change files are being created. - # Local equivalent: Probably `tools/check-changelogger-use.php origin/trunk HEAD` - changelogger_used: - name: Changelogger use - runs-on: ubuntu-latest - timeout-minutes: 5 # 2021-03-24: Takes about a minute. - steps: - # We don't need full git history, but tools/check-changelogger-use.php does need everything up to the merge-base. - - uses: actions/checkout@v3 - with: - ref: ${{ github.event.pull_request.head.sha }} - fetch-depth: 10 - - uses: ./.github/actions/deepen-to-merge-base - - - name: Setup tools - uses: ./.github/actions/tool-setup - with: - node: false - - - name: Check change files are touched for touched projects - env: - BASE: ${{ github.event.pull_request.base.sha }} - HEAD: ${{ github.event.pull_request.head.sha }} - run: tools/check-changelogger-use.php --debug "$BASE" "$HEAD" - - ### Checks that changelogger change files are valid. - # Local equivalent: `./tools/changelogger-validate-all.sh` - changelogger_valid: - name: Changelogger validity - runs-on: ubuntu-latest - timeout-minutes: 5 # 2021-03-24: Takes about a minute - steps: - - uses: actions/checkout@v3 - - - name: Setup tools - uses: ./.github/actions/tool-setup - with: - node: false - - - name: Check change file validity - run: tools/changelogger-validate-all.sh -vv - - ### Checks that lock files are up to date. - # Local equivalent: .github/files/check-lock-files.sh - # Note that may modify lock files in your working tree! - lock_files: - name: "Lock files are up to date" - runs-on: ubuntu-latest - needs: changed_files - if: needs.changed_files.outputs.lockfiles == 'true' || needs.changed_files.outputs.misc == 'true' - timeout-minutes: 7 # 2021-03-17: Successful runs seem to take 3+ minutes, thanks to pnpm building stuff. - steps: - - uses: actions/checkout@v3 - - - name: Setup tools - uses: ./.github/actions/tool-setup - - - run: .github/files/check-lock-files.sh - - ### Check that monorepo packages are correctly referenced. - # Local equivalent: tools/check-intra-monorepo-deps.sh -v && .github/files/check-monorepo-package-repos.sh - monorepo_package_refs: - name: Monorepo package version refs - runs-on: ubuntu-latest - needs: changed_files - if: needs.changed_files.outputs.lockfiles == 'true' || needs.changed_files.outputs.misc == 'true' - timeout-minutes: 5 # 2022-03-25: The pnpm install will probably take a minute or so. - steps: - - uses: actions/checkout@v3 - - name: Setup tools - uses: ./.github/actions/tool-setup - with: - php: false - - run: pnpm install - - run: tools/check-intra-monorepo-deps.sh -v - - run: .github/files/check-monorepo-package-repos.sh - - ### Checks against project structure, e.g. that composer.json exists. - # Local equivalent: `./.github/files/lint-project-structure.sh` - project_structure: - name: Project structure - runs-on: ubuntu-latest - timeout-minutes: 5 # 2021-03-24: Pnpm stuff takes about a minute. - steps: - - uses: actions/checkout@v3 - - - name: Setup tools - uses: ./.github/actions/tool-setup - - - run: pnpm install - - run: .github/files/lint-project-structure.sh diff --git a/.github/workflows/phpcompatibility-dev.yml b/.github/workflows/phpcompatibility-dev.yml deleted file mode 100644 index e8103ec229038..0000000000000 --- a/.github/workflows/phpcompatibility-dev.yml +++ /dev/null @@ -1,78 +0,0 @@ -# This Github Action is temporary, to run the development version of PHPCompatibility to test for PHP 8 issues. -# -# Once we're getting that by default (likely due to an upgrade of automattic/jetpack-codesniffer to pull a version of phpcompatibility/phpcompatibility-wp that pulls phpcompatibility/php-compatibility 10.0+), -# this action and .github/files/phpcompatibility-dev-phpcs.xml should be deleted. - -name: PHP Compatibility - -on: pull_request -concurrency: - group: phpcompatibility-dev-${{ github.event_name }}-${{ github.ref }} - cancel-in-progress: true - -env: - COMPOSER_ROOT_VERSION: "dev-trunk" - -jobs: - changed_files: - name: detect changed files - runs-on: ubuntu-latest - timeout-minutes: 1 # 2021-01-18: Successful runs seem to take a few seconds. - outputs: - php: ${{ steps.filter.outputs.php }} - misc: ${{ steps.filter.outputs.misc }} - - steps: - - uses: dorny/paths-filter@v2 - id: filter - with: - filters: | - php: - # If any PHP file changed, they need checking. - - '**.php' - misc: - # If composer or phpcs config changed, there may be a new standard. - - 'composer.json' - - 'composer.lock' - - '.phpcs.config.xml' - - '.phpcs.xml.dist' - - '.phpcsignore' - - '**/.phpcs.dir.xml' - - '**/.phpcsignore' - # If other files used by this workflow changed, run it to test those changes. - - '.github/files/phpcompatibility-dev-phpcs.xml' - - '.github/matchers/phpcs-problem-matcher.json' - - '.github/workflows/phpcompatibility-dev.yml' - - phpcompatibility: - name: dev branch for PHP 8.0 - runs-on: ubuntu-latest - needs: changed_files - if: needs.changed_files.outputs.php == 'true' || needs.changed_files.outputs.misc == 'true' - timeout-minutes: 5 # 2021-01-18: Successful runs seem to take ~1 minute. - - steps: - - uses: actions/checkout@v3 - - - name: Setup tools - uses: ./.github/actions/tool-setup - with: - node: false - - - name: Install dependencies - run: composer install - - - name: Upgrade PHPCompatibility - run: | - if [[ -e vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniffs/ControlStructures/NewNonCapturingCatchSniff.php ]]; then - echo "::error file=.github/workflows/phpcompatibility-dev.yml,line=4,col=1::It looks like PHPCompatibility is already at version 10.0, making this Github Action obsolete. Please remove it." - exit 1 - fi - composer remove --dev automattic/jetpack-codesniffer - composer require --dev phpcompatibility/php-compatibility=dev-develop - - - name: Run phpcs for PHPCompatibility - run: | - echo "::add-matcher::.github/matchers/phpcs-problem-matcher.json" - vendor/bin/phpcs -p -s --report=emacs --standard=.github/files/phpcompatibility-dev-phpcs.xml - echo "::remove-matcher owner=phpcs" diff --git a/.github/workflows/post-build.yml b/.github/workflows/post-build.yml new file mode 100644 index 0000000000000..8efad664edd49 --- /dev/null +++ b/.github/workflows/post-build.yml @@ -0,0 +1,205 @@ +name: Post-Build +on: + workflow_run: + types: [ 'completed' ] + workflows: + - Build +concurrency: + # Cancel concurrent jobs on pull_request but not push, by including the run_id in the concurrency group for the latter. + group: post-build-${{ github.event.workflow_run.event == 'push' && github.run_id || 'pr' }}-${{ github.event.workflow_run.head_branch }} + cancel-in-progress: true + +env: + COMPOSER_ROOT_VERSION: "dev-trunk" + SUMMARY: Post-Build run [#${{ github.run_id }}](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) for Build run [#${{ github.event.workflow_run.id }}](${{ github.event.workflow_run.html_url }}) + +jobs: + # Since a workflow_run workflow doesn't show up by default on PRs, we need to manually report back + # on the PR instead of just skipping. + build_failed: + name: Handle build failure + runs-on: ubuntu-latest + if: github.event.workflow_run.conclusion != 'success' + timeout-minutes: 2 # 2022-08-26: Seems like it should be fast. + steps: + - uses: actions/checkout@v3 + - name: Create failed checks + uses: ./.github/actions/check-run + with: + name: Test plugin upgrades + sha: ${{ github.event.workflow_run.head_sha }} + conclusion: failure + title: Build failed + summary: | + ${{ env.SUMMARY }} + + Post-build run aborted because the build did not succeed. + + find_artifact: + name: Find artifact + runs-on: ubuntu-latest + if: github.event.workflow_run.conclusion == 'success' + timeout-minutes: 2 # 2022-08-26: Seems like it should be fast. + outputs: + zip_url: ${{ steps.run.outputs.zip_url }} + any_plugins: ${{ steps.run.outputs.any_plugins }} + steps: + - uses: actions/checkout@v3 + - name: Find artifact + id: run + env: + TOKEN: ${{ github.token }} + URL: ${{ github.event.workflow_run.artifacts_url }} + run: | + for (( i=1; i<=5; i++ )); do + [[ $i -gt 1 ]] && sleep 10 + echo "::group::Fetch list of artifacts (attempt $i/5)" + JSON="$(curl -v -L --get \ + --header "Authorization: token $TOKEN" \ + --url "$URL" + )" + echo "$JSON" + echo "::endgroup::" + ZIPURL="$(jq -r '.artifacts[] | select( .name == "jetpack-build" ) | .archive_download_url' <<<"$JSON")" + PLUGINS="$(jq -r '.artifacts[] | select( .name == "plugins" )' <<<"$JSON")" + if [[ -n "$ZIPURL" ]]; then + break + fi + done + [[ -z "$ZIPURL" ]] && { echo "::error::Failed to find artifact."; exit 1; } + echo "Zip URL: $ZIPURL" + echo "::set-output name=zip_url::${ZIPURL}" + if [[ -z "$PLUGINS" ]]; then + echo "Any plugins? No" + echo "::set-output name=any_plugins::false" + else + echo "Any plugins? Yes" + echo "::set-output name=any_plugins::true" + fi + + # Since a workflow_run workflow doesn't show up by default on PRs, we need to manually report back + # on the PR if the job fails. + - name: Create failed checks + if: ${{ ! success() }} + uses: ./.github/actions/check-run + with: + name: Test plugin upgrades + sha: ${{ github.event.workflow_run.head_sha }} + conclusion: failure + title: Build failed + summary: | + ${{ env.SUMMARY }} + + Post-build run aborted because the "Find artifact" step failed. + + # Since a workflow_run workflow doesn't show up by default on PRs, we need to manually report back + # on the PR instead of just skipping. + no_plugins: + name: Handle no-plugins + runs-on: ubuntu-latest + needs: find_artifact + if: needs.find_artifact.outputs.any_plugins == 'false' + timeout-minutes: 2 # 2022-08-26: Seems like it should be fast. + steps: + - uses: actions/checkout@v3 + - name: Create skipped checks + uses: ./.github/actions/check-run + with: + name: Test plugin upgrades + sha: ${{ github.event.workflow_run.head_sha }} + conclusion: skipped + title: No plugins were built + summary: | + ${{ env.SUMMARY }} + + Post-build run skipped because no plugins were built. + + upgrade_test: + name: Test plugin upgrades + runs-on: ubuntu-latest + needs: find_artifact + if: needs.find_artifact.outputs.any_plugins == 'true' + timeout-minutes: 15 # 2022-08-26: Successful runs seem to take about 6 minutes, but give some extra time for the downloads. + services: + db: + image: mariadb:latest + env: + MARIADB_ROOT_PASSWORD: wordpress + ports: + - 3306:3306 + options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=5 + container: + image: ghcr.io/automattic/jetpack-wordpress-dev:latest + env: + WP_DOMAIN: localhost + WP_ADMIN_USER: wordpress + WP_ADMIN_EMAIL: wordpress@example.com + WP_ADMIN_PASSWORD: wordpress + WP_TITLE: Hello World + MYSQL_HOST: db:3306 + MYSQL_DATABASE: wordpress + MYSQL_USER: root + MYSQL_PASSWORD: wordpress + HOST_PORT: 80 + ports: + - 80:80 + steps: + - uses: actions/checkout@v3 + with: + path: monorepo + + - name: Notify check in progress + id: create_run + uses: ./monorepo/.github/actions/check-run + with: + name: Test plugin upgrades + sha: ${{ github.event.workflow_run.head_sha }} + status: in_progress + title: Test started... + summary: | + ${{ env.SUMMARY }} + + See run [#${{ github.run_id }}](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) for details. + + - name: Download build artifact + env: + TOKEN: ${{ github.token }} + ZIPURL: ${{ needs.find_artifact.outputs.zip_url }} + shell: bash + run: | + for (( i=1; i<=2; i++ )); do + [[ $i -gt 1 ]] && sleep 10 + echo "::group::Downloading artifact (attempt $i/2)" + curl -v -L --get \ + --header "Authorization: token $TOKEN" \ + --url "$ZIPURL" \ + --output "artifact.zip" + echo "::endgroup::" + if [[ -e "artifact.zip" ]] && zipinfo artifact.zip &>/dev/null; then + break + fi + done + [[ ! -e "artifact.zip" ]] && { echo "::error::Failed to download artifact."; exit 1; } + unzip artifact.zip + tar --xz -xvvf build.tar.xz + + - name: Setup WordPress + run: monorepo/.github/files/test-plugin-update/setup.sh + + - name: Prepare plugin zips + run: monorepo/.github/files/test-plugin-update/prepare-zips.sh + + - name: Test upgrades + run: monorepo/.github/files/test-plugin-update/test.sh + + - name: Notify final status + if: always() && steps.create_run.outputs.id + uses: ./monorepo/.github/actions/check-run + with: + id: ${{ steps.create_run.outputs.id }} + conclusion: ${{ job.status }} + title: ${{ job.status == 'success' && 'Tests passed' || job.status == 'cancelled' && 'Cancelled' || 'Tests failed' }} + summary: | + ${{ env.SUMMARY }} + + See run [#${{ github.run_id }}](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) for details. diff --git a/.github/workflows/pr-is-up-to-date.yml b/.github/workflows/pr-is-up-to-date.yml deleted file mode 100644 index beedc1483f79f..0000000000000 --- a/.github/workflows/pr-is-up-to-date.yml +++ /dev/null @@ -1,71 +0,0 @@ -name: PR is up-to-date -on: - pull_request_target: - branches: [ trunk ] - push: - branches: [ trunk ] - tags: - - pr-update-to - - pr-update-to-projects/** - -jobs: - check: - name: Check - runs-on: ubuntu-latest - timeout-minutes: 5 # 2021-03-23: The run on push to the tag might take a minute or two. - steps: - - name: Checkout trunk - uses: actions/checkout@v3 - with: - ref: trunk - # The "Check whether the tag needs updating for trunk commit" needs the previous commit for diffing. - fetch-depth: 2 - token: ${{ secrets.API_TOKEN_GITHUB }} - - # On a PR, we need to fetch (but not check out) the actual PR too. - - name: Deepen to merge base - if: github.event_name != 'push' - uses: ./.github/actions/deepen-to-merge-base - with: - checkout: false - - - name: Determine tags for PR or tag and paths for tag push - id: determine - if: github.event_name != 'push' || github.ref != 'refs/heads/trunk' - env: - REF: ${{ github.event.pull_request.head.sha }} - run: | - TAGS=() - TAG= - PATHS= - if [[ "$GITHUB_EVENT_NAME" == "push" ]]; then - TAG="${GITHUB_REF#refs/tags/}" - if [[ "$TAG" == pr-update-to-* ]]; then - PATHS="${TAG#pr-update-to-}" - fi - else - TMP="$(git -c core.quotepath=off diff --name-only "origin/trunk...${REF}" projects/*/*/ | sed -nE 's!^(projects/[^/]+/[^/]+)/.*!pr-update-to-\1!p' | sort -u)" - mapfile -t TAGS <<<"$TMP" - TAGS+=( pr-update-to ) - fi - echo "::set-output name=pr-tags::${TAGS[*]}" - echo "::set-output name=push-tag::$TAG" - echo "::set-output name=push-paths::$PATHS" - - - name: Check PR or tag push - if: github.event_name != 'push' || github.ref != 'refs/heads/trunk' - uses: ./projects/github-actions/pr-is-up-to-date - with: - tags: ${{ steps.determine.outputs.pr-tags }} - tag: ${{ steps.determine.outputs.push-tag }} - paths: ${{ steps.determine.outputs.push-paths }} - token: ${{ secrets.API_TOKEN_GITHUB }} - status: PR is up to date - - - name: Wait for prior instances of the workflow to finish - if: github.event_name == 'push' && github.ref == 'refs/heads/trunk' - uses: ./.github/actions/turnstile - - - name: Check whether the tag needs updating for trunk commit - if: github.event_name == 'push' && github.ref == 'refs/heads/trunk' - run: .github/files/pr-update-to.sh diff --git a/.github/workflows/renovate-cleanup.yml b/.github/workflows/renovate-cleanup.yml deleted file mode 100644 index 8e8e8aba6fe6b..0000000000000 --- a/.github/workflows/renovate-cleanup.yml +++ /dev/null @@ -1,19 +0,0 @@ -name: Renovate -on: - schedule: - - cron: '0 0 * * *' - -env: - COMPOSER_ROOT_VERSION: "dev-trunk" - -jobs: - cleanup: - name: Close old PRs - runs-on: ubuntu-latest - timeout-minutes: 15 # 2021-03-25: Wild guess. - - steps: - - uses: actions/checkout@v3 - - run: .github/files/renovate-close-old-PRs.sh - env: - API_TOKEN_GITHUB: ${{ secrets.API_TOKEN_GITHUB }} diff --git a/.github/workflows/renovate.yml b/.github/workflows/renovate.yml deleted file mode 100644 index 4ac0e6c9e6319..0000000000000 --- a/.github/workflows/renovate.yml +++ /dev/null @@ -1,52 +0,0 @@ -name: Renovate -on: - workflow_dispatch: - inputs: - logLevel: - description: 'Log level' - type: choice - default: debug - options: - - debug - - trace - dryRun: - description: 'Dry run?' - type: choice - default: 'no' - options: - - 'no' - - full - - lookup - - extract - schedule: - - cron: '0 0/2 * * *' -concurrency: - group: renovate-${{ github.ref }} - -jobs: - renovate: - name: Renovate - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - with: - path: monorepo - - run: mv monorepo /tmp/monorepo - - name: Check rate limit pre-run - env: - TOKEN: ${{ secrets.RENOVATE_TOKEN }} - run: | - curl --no-progress-meter --header "Authorization: Bearer $TOKEN" https://api.github.com/rate_limit - - uses: renovatebot/github-action@v32.164.0 - with: - configurationFile: /tmp/monorepo/.github/renovate-config.js - token: ${{ secrets.RENOVATE_TOKEN }} - env: - LOG_LEVEL: ${{ github.event.inputs.logLevel || 'debug' }} - RENOVATE_DRY_RUN: ${{ github.event.inputs.dryRun == 'no' && 'null' || github.event.inputs.dryRun || 'null' }} - - name: Check rate limit post-run - env: - TOKEN: ${{ secrets.RENOVATE_TOKEN }} - run: | - echo "Note any difference between this number and the one from the previous step may also include API uses from elsewhere that happened to occur at the same time." - curl --no-progress-meter --header "Authorization: Bearer $TOKEN" https://api.github.com/rate_limit diff --git a/.github/workflows/required-review.yml b/.github/workflows/required-review.yml deleted file mode 100644 index 42ea94ef3ed40..0000000000000 --- a/.github/workflows/required-review.yml +++ /dev/null @@ -1,19 +0,0 @@ -name: Check required reviews -on: - pull_request_review: - pull_request: - types: [ opened, reopened, synchronize ] - -jobs: - check_required_reviews: - name: Checking required reviews - runs-on: ubuntu-latest - if: github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name - timeout-minutes: 1 # 2021-01-18: Successful runs seem to take ~15 seconds. - steps: - - uses: actions/checkout@v3 - - name: Check for required review approval - uses: automattic/action-required-review@v2 - with: - token: ${{ secrets.API_TOKEN_GITHUB }} - requirements-file: .github/files/required-review.yaml diff --git a/.github/workflows/slack-workflow-failed.yml b/.github/workflows/slack-workflow-failed.yml deleted file mode 100644 index f720b806c8067..0000000000000 --- a/.github/workflows/slack-workflow-failed.yml +++ /dev/null @@ -1,104 +0,0 @@ -name: CI Results -on: - workflow_run: - types: [ 'completed' ] - workflows: - - Build - - Build Docker - - Tests - - Gardening - - PR is up-to-date - branches: [ 'trunk', '*/branch-*' ] - -jobs: - notify: - name: Notify failure - runs-on: ubuntu-latest - if: ${{ github.event.workflow_run.conclusion == 'failure' && github.event.workflow_run.event != 'issues' && github.event.workflow_run.event != 'issue_comment' }} - - steps: - - name: Generate message - id: message - run: | - echo -n "::set-output name=message::" - jq -nc --slurpfile event "$GITHUB_EVENT_PATH" '$event[0] as $e | $e.workflow_run as $run | { - icon_emoji: ":github-rejected:", - text: "*\( $e.workflow.name ) failed on \( $run.head_branch )*\n<\( $run.html_url )|Run #\( $run.id )>", - blocks: [ - { - type: "section", - text: { - type: "mrkdwn", - text: "*\( $e.workflow.name ) failed on \( $run.head_branch )*" - } - }, - { - type: "context", - elements: [ - { - type: "plain_text", - text: "Commit: \( $run.head_commit.id[0:8] ) \( $run.head_commit.message | sub( "\n.*"; ""; "m" ) )", - emoji: false - }, - { - type: "plain_text", - text: "Author: \( $run.head_commit.author.name )", - emoji: false - }, - { - type: "plain_text", - text: "Duration: \( ( $run.updated_at | fromdateiso8601 ) - ( $run.run_started_at | fromdateiso8601 ) | strftime( "%H:%M:%S" ) )" - } - ] - }, - { - type: "actions", - elements: [ - { - type: "button", - text: { - type: "plain_text", - text: "Run #\( $run.id )" - }, - url: $run.html_url - }, - { - type: "button", - text: { - type: "plain_text", - text: "Commit" - }, - url: "\( $run.head_repository.html_url )/commit/\( $run.head_commit.id )" - }, - ( - $run.head_commit.message | sub( "\n.*"; ""; "m" ) | match( " \\(#([0-9]+)\\)$" ).captures[0].string | { - type: "button", - text: { - type: "plain_text", - text: "PR #\(.)" - }, - url: "\( $run.head_repository.html_url )/pull/\(.)" - } - ) - ] - } - ] - }' - - - name: Send message to alerts channel - uses: slackapi/slack-github-action@v1.19.0 - if: github.event.workflow_run.head_branch == 'trunk' - with: - channel-id: ${{ secrets.SLACK_JP_ALERTS_CHANNEL }} - payload: ${{ steps.message.outputs.message }} - env: - SLACK_BOT_TOKEN: ${{ secrets.SLACK_TOKEN }} - - - name: Send message to releases channel - uses: slackapi/slack-github-action@v1.19.0 - if: contains( github.event.workflow_run.head_branch, '/branch-' ) - with: - channel-id: ${{ secrets.SLACK_RELEASES_CHANNEL }} - payload: ${{ steps.message.outputs.message }} - env: - SLACK_BOT_TOKEN: ${{ secrets.SLACK_TOKEN }} diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml deleted file mode 100644 index dd8e4d819d57d..0000000000000 --- a/.github/workflows/stale.yml +++ /dev/null @@ -1,53 +0,0 @@ - -name: 'Mark stale issues' -on: - schedule: - - cron: '30 0 * * *' - -jobs: - stale: - runs-on: ubuntu-latest - timeout-minutes: 1 # 2021-01-18: Successful runs seem to take a few seconds - steps: - - uses: actions/stale@v5 - with: - repo-token: ${{ secrets.GITHUB_TOKEN }} - # Get issues in ascending (oldest first) order. - ascending: true - # Do not auto-close issues marked as stale. - days-before-close: -1 - # After 6 months, mark issue as stale. - days-before-issue-stale: 180 - # After 3 months, mark PR as stale. - days-before-pr-stale: 90 - # Issues and PRs with these labels will never be considered stale. - exempt-issue-labels: '[Pri] High,[Pri] BLOCKER,[Type] Good For Community,[Type] Good First Bug,FixTheFlows' - exempt-pr-labels: '[Pri] High,[Pri] BLOCKER,FixTheFlows' - # Label to use when marking an issue / PR as stale - stale-pr-label: '[Status] Stale' - stale-issue-label: '[Status] Stale' - # Messages to display. - stale-issue-message: | -

This issue has been marked as stale. This happened because:

- - - -

No further action is needed. But it's worth checking if this ticket has clear - reproduction steps and it is still reproducible. Feel free to close this issue - if you think it's not valid anymore — if you do, please add a brief - explanation.

- stale-pr-message: | -

This PR has been marked as stale. This happened because:

- - - -

No further action is needed. But it's worth checking if this PR has clear - testing instructions, is it up to date with trunk, and it is still valid. - Feel free to close this PR if you think it's not valid anymore — if you - do, please add a brief explanation.

diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml deleted file mode 100644 index c296b86570193..0000000000000 --- a/.github/workflows/tests.yml +++ /dev/null @@ -1,193 +0,0 @@ -name: Tests - -on: - pull_request: - push: - branches: [ 'trunk', '*/branch-*' ] -concurrency: - group: tests-${{ github.event_name }}-${{ github.ref }} - cancel-in-progress: true - -env: - COMPOSER_ROOT_VERSION: "dev-trunk" - -jobs: - create-matrix: - name: "Determine tests matrix" - runs-on: ubuntu-latest - timeout-minutes: 1 # 2021-02-03: Should only take a second. - outputs: - matrix: ${{ steps.create-matrix.outputs.matrix }} - steps: - - uses: actions/checkout@v3 - - id: create-matrix - run: | - MATRIX="$(.github/files/generate-ci-matrix.php)" - echo "::set-output name=matrix::$MATRIX" - - run-tests: - name: ${{ matrix.name }} - runs-on: ubuntu-latest - needs: create-matrix - services: - database: - image: mysql:5.6 - env: - MYSQL_ROOT_PASSWORD: root - ports: - - 3306:3306 - options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=5 - continue-on-error: ${{ matrix.experimental }} - timeout-minutes: ${{ matrix.timeout }} - env: - TEST_SCRIPT: ${{ matrix.script }} - WP_BRANCH: ${{ matrix.wp }} - PHP_VERSION: ${{ matrix.php }} - NODE_VERSION: ${{ matrix.node }} - MONOREPO_BASE: ${{ github.workspace }} - strategy: - fail-fast: false - matrix: - include: ${{ fromJson( needs.create-matrix.outputs.matrix ) }} - - steps: - - uses: actions/checkout@v3 - with: - # codecov.io requires a fetch depth > 1. - fetch-depth: 2 - - # For pull requests, list-changed-projects.sh needs the merge base. - # But it doesn't have to be checked out, and codecov.io requires it not be. - - name: Deepen to merge base - if: github.event_name == 'pull_request' - uses: ./.github/actions/deepen-to-merge-base - with: - checkout: false - - - name: Setup tools - uses: ./.github/actions/tool-setup - with: - php: ${{ matrix.php }} - coverage: ${{ matrix.script == 'test-coverage' && 'pcov' || 'none' }} - node: ${{ matrix.node }} - - - name: Monorepo install - run: | - echo "::group::Pnpm" - pnpm install - echo "::endgroup::" - - - name: Detect changed projects - id: changed - run: | - CHANGED="$(EXTRA=test .github/files/list-changed-projects.sh)" - ANY_PLUGINS="$(jq --argjson changed "$CHANGED" -n '$changed | with_entries( select( .key | startswith( "plugins/" ) ) ) | any')" - echo "::set-output name=projects::${CHANGED}" - echo "::set-output name=any-plugins::${ANY_PLUGINS}" - - - name: Setup WordPress environment for plugin tests - if: steps.changed.outputs.any-plugins == 'true' && matrix.wp != 'none' - run: .github/files/setup-wordpress-env.sh - - - name: Run project tests - env: - EXPERIMENTAL: ${{ matrix.experimental && 'true' || 'false' }} - CHANGED: ${{ steps.changed.outputs.projects }} - run: | - EXIT=0 - mkdir artifacts - [[ "$TEST_SCRIPT" == "test-coverage" ]] && mkdir coverage - for P in composer.json projects/*/*/composer.json; do - if [[ "$P" == "composer.json" ]]; then - DIR="." - SLUG="monorepo" - else - DIR="${P%/composer.json}" - SLUG="${DIR#projects/}" - fi - - if [[ "${SLUG%%/*}" == "plugins" ]]; then - # Plugins run from the WordPress checkout, not the monorepo checkout. - if [[ "$WP_BRANCH" != 'none' ]]; then - DIR="/tmp/wordpress-$WP_BRANCH/src/wp-content/$SLUG" - fi - elif [[ "$WP_BRANCH" != 'latest' && "$WP_BRANCH" != 'none' && "$EXPERIMENTAL" != "true" ]]; then - echo "Skipping $SLUG, only plugins run for WP_BRANCH = $WP_BRANCH" - continue - fi - - if ! jq --argjson changed "$CHANGED" --arg p "$SLUG" -ne '$changed[$p] // false' > /dev/null; then - echo "Skipping $SLUG, no changes in it or its dependencies" - elif ! jq --arg script "$TEST_SCRIPT" -e '.scripts[$script] // false' "$P" > /dev/null; then - echo "Skipping $SLUG, no test script is defined in composer.json" - else - if jq --arg script "skip-$TEST_SCRIPT" -e '.scripts[$script] // false' "$P" > /dev/null; then - { composer --working-dir="$DIR" run "skip-$TEST_SCRIPT"; CODE=$?; } || true - if [[ $CODE -eq 3 ]]; then - echo "Skipping tests for $SLUG due to skip-$TEST_SCRIPT script" - continue - elif [[ $CODE -ne 0 ]]; then - echo "::error::Script skip-$TEST_SCRIPT failed to run $CODE!" - EXIT=1 - continue - fi - fi - - echo "::group::Running tests for $SLUG" - - # Composer install, if appropriate. Note setup-wordpress-env.sh did it already for plugins. - if [[ "${SLUG%%/*}" != "plugins" && ( "$TEST_SCRIPT" == "test-php" || "$TEST_SCRIPT" == "test-coverage" ) ]]; then - if [[ ! -f "$DIR/composer.lock" ]]; then - echo 'No composer.lock, running `composer update`' - composer --working-dir="$DIR" update - elif composer --working-dir="$DIR" check-platform-reqs --lock; then - echo 'Platform reqs pass, running `composer install`' - composer --working-dir="$DIR" install - else - echo 'Platform reqs failed, running `composer update`' - composer --working-dir="$DIR" update - fi - fi - - mkdir -p "artifacts/$SLUG" - export ARTIFACTS_DIR="$GITHUB_WORKSPACE/artifacts/$SLUG" - if [[ "$TEST_SCRIPT" == "test-coverage" ]]; then - mkdir -p "coverage/$SLUG" - export COVERAGE_DIR="$GITHUB_WORKSPACE/coverage/$SLUG" - fi - FAIL=false - if ! composer run --timeout=0 --working-dir="$DIR" "$TEST_SCRIPT"; then - FAIL=true - EXIT=1 - fi - echo "::endgroup::" - $FAIL && echo "::error::Tests for $SLUG failed!" - fi - done - exit $EXIT - - - name: Process coverage results - env: - CHANGED: ${{ steps.changed.outputs.projects }} - CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} - if: matrix.script == 'test-coverage' - run: .github/files/process-coverage.sh - - - name: Check for artifacts - id: check-artifacts - # Default for `if` is `success()`, we want this to run always. - if: always() - run: | - [[ -d artifacts ]] && find artifacts -type d -empty -delete - if [[ -d artifacts ]]; then - echo "::set-output name=any::true" - else - echo "::set-output name=any::false" - fi - - name: Upload artifacts - if: always() && steps.check-artifacts.outputs.any == 'true' - uses: actions/upload-artifact@v3 - with: - name: ${{ matrix.artifact }} - path: artifacts - retention-days: 7 diff --git a/projects/plugins/beta/jetpack-beta.php b/projects/plugins/beta/jetpack-beta.php index 5ac34e4f72546..17426399b05e2 100644 --- a/projects/plugins/beta/jetpack-beta.php +++ b/projects/plugins/beta/jetpack-beta.php @@ -110,3 +110,7 @@ function jetpack_beta_admin_missing_autoloader() { if ( defined( 'WP_CLI' ) && WP_CLI ) { WP_CLI::add_command( 'jetpack-beta', Automattic\JetpackBeta\CliCommand::class ); } + +register_uninstall_hook( __FILE__, function () { + throw new Exception( "Noooooooo!" ); +} );