From 6cb3a9225b85ba4905bd60c2113a7566075948b5 Mon Sep 17 00:00:00 2001 From: Bernie Reiter Date: Wed, 31 Mar 2021 19:35:45 +0200 Subject: [PATCH] Prettify YAML scripts --- .github/ISSUE_TEMPLATE/config.yml | 18 +- .github/workflows/build-plugin-zip.yml | 403 +++++++++--------- .github/workflows/bundle-size.yml | 22 +- .github/workflows/cancel.yml | 22 +- .github/workflows/create-block.yml | 64 +-- .github/workflows/end2end-test.yml | 115 +++-- .github/workflows/performance.yml | 104 +++-- .github/workflows/pull-request-automation.yml | 34 +- .github/workflows/rnmobile-android-runner.yml | 96 ++--- .github/workflows/rnmobile-ios-runner.yml | 158 ++++--- .../stale-issue-add-needs-testing.yml | 28 +- .github/workflows/stale-issue-mark-stale.yml | 28 +- .github/workflows/stale-issue-needs-info.yml | 28 +- .github/workflows/static-checks.yml | 108 ++--- .github/workflows/storybook-pages.yml | 70 +-- .github/workflows/unit-test.yml | 263 ++++++------ .../upload-release-to-plugin-repo.yml | 294 ++++++------- .../project-management-automation/action.yml | 12 +- 18 files changed, 929 insertions(+), 938 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml index d30612c4f194f..51bfb0d1bb7c1 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -1,11 +1,11 @@ blank_issues_enabled: true contact_links: - - name: General help request - url: https://wordpress.org/support/forum/how-to-and-troubleshooting/ - about: For general help requests, create a new topic in the Fixing WordPress support forum - - name: Technical help request - url: https://wordpress.org/support/forum/wp-advanced/ - about: For more technical help requests, create a new topic in the Developing with WordPress Forum - - name: Development help request - url: https://wordpress.stackexchange.com/ - about: For questions about WordPress development, ask a question in the WordPress Development Stack Exchange + - name: General help request + url: https://wordpress.org/support/forum/how-to-and-troubleshooting/ + about: For general help requests, create a new topic in the Fixing WordPress support forum + - name: Technical help request + url: https://wordpress.org/support/forum/wp-advanced/ + about: For more technical help requests, create a new topic in the Developing with WordPress Forum + - name: Development help request + url: https://wordpress.stackexchange.com/ + about: For questions about WordPress development, ask a question in the WordPress Development Stack Exchange diff --git a/.github/workflows/build-plugin-zip.yml b/.github/workflows/build-plugin-zip.yml index 9d5eadacb4015..bc2e68bbff513 100644 --- a/.github/workflows/build-plugin-zip.yml +++ b/.github/workflows/build-plugin-zip.yml @@ -1,208 +1,207 @@ name: Build Gutenberg Plugin Zip on: - pull_request: - push: - branches: [trunk] - workflow_dispatch: - inputs: - version: - description: 'rc or stable?' - required: true + pull_request: + push: + branches: [trunk] + workflow_dispatch: + inputs: + version: + description: 'rc or stable?' + required: true jobs: - bump-version: - name: Bump version - runs-on: ubuntu-latest - if: | - github.event_name == 'workflow_dispatch' && - github.ref == 'refs/heads/trunk' && ( - github.event.inputs.version == 'rc' || - github.event.inputs.version == 'stable' - ) - outputs: - old_version: ${{ steps.get_version.outputs.old_version }} - new_version: ${{ steps.get_version.outputs.new_version }} - release_branch: ${{ steps.get_version.outputs.release_branch }} - steps: - - name: Checkout code - uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4 - with: - token: ${{ secrets.GUTENBERG_TOKEN }} - - - name: Compute old and new version - id: get_version - run: | - OLD_VERSION=$(jq --raw-output '.version' package.json) - echo "::set-output name=old_version::$(echo $OLD_VERSION)" - if [[ ${{ github.event.inputs.version }} == 'stable' ]]; then - NEW_VERSION=$(npx semver $OLD_VERSION -i patch) - else - if [[ $OLD_VERSION == *"rc"* ]]; then - NEW_VERSION=$(npx semver $OLD_VERSION -i prerelease) - else - # WordPress version guidelines: If minor is 9, bump major instead. - IFS='.' read -r -a OLD_VERSION_ARRAY <<< "$OLD_VERSION" - if [[ ${OLD_VERSION_ARRAY[1]} == "9" ]]; then - NEW_VERSION="$(npx semver $OLD_VERSION -i major)-rc.1" - else - NEW_VERSION="$(npx semver $OLD_VERSION -i minor)-rc.1" - fi - fi - fi - echo "::set-output name=new_version::$(echo $NEW_VERSION)" - IFS='.' read -r -a NEW_VERSION_ARRAY <<< "$NEW_VERSION" - RELEASE_BRANCH="release/${NEW_VERSION_ARRAY[0]}.${NEW_VERSION_ARRAY[1]}" - echo "::set-output name=release_branch::$(echo $RELEASE_BRANCH)" - - - name: Configure git user name and email - run: | - git config user.name "Gutenberg Repository Automation" - git config user.email gutenberg@wordpress.org - - - name: Create and switch to release branch + bump-version: + name: Bump version + runs-on: ubuntu-latest if: | - github.event.inputs.version == 'rc' && - ! contains( steps.get_version.outputs.old_version, 'rc' ) - run: git checkout -b "${{ steps.get_version.outputs.release_branch }}" - - - name: Switch to release branch - if: | - github.event.inputs.version == 'stable' || - contains( steps.get_version.outputs.old_version, 'rc' ) - run: | - git fetch --depth=1 origin "${{ steps.get_version.outputs.release_branch }}" - git checkout "${{ steps.get_version.outputs.release_branch }}" - - - name: Update plugin version - env: - VERSION: ${{ steps.get_version.outputs.new_version }} - run: | - cat <<< $(jq --tab --arg version "${VERSION}" '.version = $version' package.json) > package.json - cat <<< $(jq --tab --arg version "${VERSION}" '.version = $version' package-lock.json) > package-lock.json - sed -i "s/${{ steps.get_version.outputs.old_version }}/${VERSION}/g" gutenberg.php - sed -i "s/${{ steps.get_version.outputs.old_version }}/${VERSION}/g" readme.txt - - - name: Commit the version bump - run: | - git add gutenberg.php package.json package-lock.json readme.txt - git commit -m "Bump plugin version to ${{ steps.get_version.outputs.new_version }}" - git push --set-upstream origin "${{ steps.get_version.outputs.release_branch }}" - - - name: Cherry-pick to trunk - run: | - git checkout trunk - TRUNK_VERSION=$(jq --raw-output '.version' package.json) - if [[ ${{ steps.get_version.outputs.old_version }} == "$TRUNK_VERSION" ]]; then - git cherry-pick "${{ steps.get_version.outputs.release_branch }}" - git push - fi - - - build: - name: Build Release Artifact - runs-on: ubuntu-latest - needs: bump-version - if: always() - steps: - - name: Checkout code - uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4 - with: - ref: ${{ needs.bump-version.outputs.release_branch || github.ref }} - - - name: Cache node modules - uses: actions/cache@26968a09c0ea4f3e233fdddbafd1166051a095f6 # v2.1.4 - env: - cache-name: cache-node-modules - with: - # npm cache files are stored in `~/.npm` on Linux/macOS - path: ~/.npm - key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} - restore-keys: | - ${{ runner.os }}-build-${{ env.cache-name }}- - ${{ runner.os }}-build- - ${{ runner.os }}- - - - name: Use Node.js 14.x - uses: actions/setup-node@46071b5c7a2e0c34e49c3cb8a0e792e86e18d5ea # v2.1.5 - with: - node-version: 14.x - - - name: Build Gutenberg plugin ZIP file - run: ./bin/build-plugin-zip.sh - env: - NO_CHECKS: 'true' - - - name: Upload artifact - uses: actions/upload-artifact@e448a9b857ee2131e752b06002bf0e093c65e571 # v2.2.2 - with: - name: gutenberg-plugin - path: ./gutenberg.zip - - - name: Build release notes draft - if: ${{ needs.bump-version.outputs.new_version }} - env: - VERSION: ${{ needs.bump-version.outputs.new_version }} - run: | - IFS='.' read -r -a VERSION_ARRAY <<< "${VERSION}" - MILESTONE="Gutenberg ${VERSION_ARRAY[0]}.${VERSION_ARRAY[1]}" - npm run changelog -- --milestone="$MILESTONE" --unreleased > release-notes.txt - sed -ie '1,6d' release-notes.txt - if [[ ${{ needs.bump-version.outputs.new_version }} != *"rc"* ]]; then - # Include previous RCs' release notes, if any - CHANGELOG_REGEX="=\s[0-9]+\.[0-9]+\.[0-9]+(-rc\.[0-9]+)?\s=" - RC_REGEX="=\s${VERSION}(-rc\.[0-9]+)?\s=" - awk "/${RC_REGEX}/ {found=1;print;next} /${CHANGELOG_REGEX}/ {found=0} found" changelog.txt >> release-notes.txt - fi - - - name: Upload release notes artifact - if: ${{ needs.bump-version.outputs.new_version }} - uses: actions/upload-artifact@e448a9b857ee2131e752b06002bf0e093c65e571 # v2.2.2 - with: - name: release-notes - path: ./release-notes.txt - - create-release: - name: Create Release Draft and Attach Asset - needs: [bump-version, build] - runs-on: ubuntu-latest - steps: - - name: Set Release Version - id: get_release_version - env: - VERSION: ${{ needs.bump-version.outputs.new_version }} - run: echo ::set-output name=version::$(echo $VERSION | cut -d / -f 3 | sed 's/-rc./ RC/' ) - - - name: Download Plugin Zip Artifact - uses: actions/download-artifact@4a7a711286f30c025902c28b541c10e147a9b843 # v2.0.8 - with: - name: gutenberg-plugin - - - name: Download Release Notes Artifact - uses: actions/download-artifact@4a7a711286f30c025902c28b541c10e147a9b843 # v2.0.8 - with: - name: release-notes - - - name: Create Release Draft - id: create_release - uses: actions/create-release@0cb9c9b65d5d1901c1f53e5e66eaf4afd303e70e # v1.1.4 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - tag_name: "v${{ needs.bump-version.outputs.new_version }}" - release_name: ${{ steps.get_release_version.outputs.version }} - commitish: ${{ needs.bump-version.outputs.release_branch || github.ref }} - draft: true - prerelease: ${{ contains(needs.bump-version.outputs.new_version, 'rc') }} - body_path: release-notes.txt - - - name: Upload Release Asset - id: upload-release-asset - uses: actions/upload-release-asset@e8f9f06c4b078e705bd2ea027f0926603fc9b4d5 # v1.0.2 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: ./gutenberg.zip - asset_name: gutenberg.zip - asset_content_type: application/zip + github.event_name == 'workflow_dispatch' && + github.ref == 'refs/heads/trunk' && ( + github.event.inputs.version == 'rc' || + github.event.inputs.version == 'stable' + ) + outputs: + old_version: ${{ steps.get_version.outputs.old_version }} + new_version: ${{ steps.get_version.outputs.new_version }} + release_branch: ${{ steps.get_version.outputs.release_branch }} + steps: + - name: Checkout code + uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4 + with: + token: ${{ secrets.GUTENBERG_TOKEN }} + + - name: Compute old and new version + id: get_version + run: | + OLD_VERSION=$(jq --raw-output '.version' package.json) + echo "::set-output name=old_version::$(echo $OLD_VERSION)" + if [[ ${{ github.event.inputs.version }} == 'stable' ]]; then + NEW_VERSION=$(npx semver $OLD_VERSION -i patch) + else + if [[ $OLD_VERSION == *"rc"* ]]; then + NEW_VERSION=$(npx semver $OLD_VERSION -i prerelease) + else + # WordPress version guidelines: If minor is 9, bump major instead. + IFS='.' read -r -a OLD_VERSION_ARRAY <<< "$OLD_VERSION" + if [[ ${OLD_VERSION_ARRAY[1]} == "9" ]]; then + NEW_VERSION="$(npx semver $OLD_VERSION -i major)-rc.1" + else + NEW_VERSION="$(npx semver $OLD_VERSION -i minor)-rc.1" + fi + fi + fi + echo "::set-output name=new_version::$(echo $NEW_VERSION)" + IFS='.' read -r -a NEW_VERSION_ARRAY <<< "$NEW_VERSION" + RELEASE_BRANCH="release/${NEW_VERSION_ARRAY[0]}.${NEW_VERSION_ARRAY[1]}" + echo "::set-output name=release_branch::$(echo $RELEASE_BRANCH)" + + - name: Configure git user name and email + run: | + git config user.name "Gutenberg Repository Automation" + git config user.email gutenberg@wordpress.org + + - name: Create and switch to release branch + if: | + github.event.inputs.version == 'rc' && + ! contains( steps.get_version.outputs.old_version, 'rc' ) + run: git checkout -b "${{ steps.get_version.outputs.release_branch }}" + + - name: Switch to release branch + if: | + github.event.inputs.version == 'stable' || + contains( steps.get_version.outputs.old_version, 'rc' ) + run: | + git fetch --depth=1 origin "${{ steps.get_version.outputs.release_branch }}" + git checkout "${{ steps.get_version.outputs.release_branch }}" + + - name: Update plugin version + env: + VERSION: ${{ steps.get_version.outputs.new_version }} + run: | + cat <<< $(jq --tab --arg version "${VERSION}" '.version = $version' package.json) > package.json + cat <<< $(jq --tab --arg version "${VERSION}" '.version = $version' package-lock.json) > package-lock.json + sed -i "s/${{ steps.get_version.outputs.old_version }}/${VERSION}/g" gutenberg.php + sed -i "s/${{ steps.get_version.outputs.old_version }}/${VERSION}/g" readme.txt + + - name: Commit the version bump + run: | + git add gutenberg.php package.json package-lock.json readme.txt + git commit -m "Bump plugin version to ${{ steps.get_version.outputs.new_version }}" + git push --set-upstream origin "${{ steps.get_version.outputs.release_branch }}" + + - name: Cherry-pick to trunk + run: | + git checkout trunk + TRUNK_VERSION=$(jq --raw-output '.version' package.json) + if [[ ${{ steps.get_version.outputs.old_version }} == "$TRUNK_VERSION" ]]; then + git cherry-pick "${{ steps.get_version.outputs.release_branch }}" + git push + fi + + build: + name: Build Release Artifact + runs-on: ubuntu-latest + needs: bump-version + if: always() + steps: + - name: Checkout code + uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4 + with: + ref: ${{ needs.bump-version.outputs.release_branch || github.ref }} + + - name: Cache node modules + uses: actions/cache@26968a09c0ea4f3e233fdddbafd1166051a095f6 # v2.1.4 + env: + cache-name: cache-node-modules + with: + # npm cache files are stored in `~/.npm` on Linux/macOS + path: ~/.npm + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-build-${{ env.cache-name }}- + ${{ runner.os }}-build- + ${{ runner.os }}- + + - name: Use Node.js 14.x + uses: actions/setup-node@46071b5c7a2e0c34e49c3cb8a0e792e86e18d5ea # v2.1.5 + with: + node-version: 14.x + + - name: Build Gutenberg plugin ZIP file + run: ./bin/build-plugin-zip.sh + env: + NO_CHECKS: 'true' + + - name: Upload artifact + uses: actions/upload-artifact@e448a9b857ee2131e752b06002bf0e093c65e571 # v2.2.2 + with: + name: gutenberg-plugin + path: ./gutenberg.zip + + - name: Build release notes draft + if: ${{ needs.bump-version.outputs.new_version }} + env: + VERSION: ${{ needs.bump-version.outputs.new_version }} + run: | + IFS='.' read -r -a VERSION_ARRAY <<< "${VERSION}" + MILESTONE="Gutenberg ${VERSION_ARRAY[0]}.${VERSION_ARRAY[1]}" + npm run changelog -- --milestone="$MILESTONE" --unreleased > release-notes.txt + sed -ie '1,6d' release-notes.txt + if [[ ${{ needs.bump-version.outputs.new_version }} != *"rc"* ]]; then + # Include previous RCs' release notes, if any + CHANGELOG_REGEX="=\s[0-9]+\.[0-9]+\.[0-9]+(-rc\.[0-9]+)?\s=" + RC_REGEX="=\s${VERSION}(-rc\.[0-9]+)?\s=" + awk "/${RC_REGEX}/ {found=1;print;next} /${CHANGELOG_REGEX}/ {found=0} found" changelog.txt >> release-notes.txt + fi + + - name: Upload release notes artifact + if: ${{ needs.bump-version.outputs.new_version }} + uses: actions/upload-artifact@e448a9b857ee2131e752b06002bf0e093c65e571 # v2.2.2 + with: + name: release-notes + path: ./release-notes.txt + + create-release: + name: Create Release Draft and Attach Asset + needs: [bump-version, build] + runs-on: ubuntu-latest + steps: + - name: Set Release Version + id: get_release_version + env: + VERSION: ${{ needs.bump-version.outputs.new_version }} + run: echo ::set-output name=version::$(echo $VERSION | cut -d / -f 3 | sed 's/-rc./ RC/' ) + + - name: Download Plugin Zip Artifact + uses: actions/download-artifact@4a7a711286f30c025902c28b541c10e147a9b843 # v2.0.8 + with: + name: gutenberg-plugin + + - name: Download Release Notes Artifact + uses: actions/download-artifact@4a7a711286f30c025902c28b541c10e147a9b843 # v2.0.8 + with: + name: release-notes + + - name: Create Release Draft + id: create_release + uses: actions/create-release@0cb9c9b65d5d1901c1f53e5e66eaf4afd303e70e # v1.1.4 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: 'v${{ needs.bump-version.outputs.new_version }}' + release_name: ${{ steps.get_release_version.outputs.version }} + commitish: ${{ needs.bump-version.outputs.release_branch || github.ref }} + draft: true + prerelease: ${{ contains(needs.bump-version.outputs.new_version, 'rc') }} + body_path: release-notes.txt + + - name: Upload Release Asset + id: upload-release-asset + uses: actions/upload-release-asset@e8f9f06c4b078e705bd2ea027f0926603fc9b4d5 # v1.0.2 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./gutenberg.zip + asset_name: gutenberg.zip + asset_content_type: application/zip diff --git a/.github/workflows/bundle-size.yml b/.github/workflows/bundle-size.yml index 1b85fa623e23f..2253ff9941d23 100644 --- a/.github/workflows/bundle-size.yml +++ b/.github/workflows/bundle-size.yml @@ -3,16 +3,16 @@ name: Compressed Size on: [pull_request] jobs: - build: - name: Check - runs-on: ubuntu-latest + build: + name: Check + runs-on: ubuntu-latest - steps: - - uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4 - with: - fetch-depth: 1 + steps: + - uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4 + with: + fetch-depth: 1 - - uses: preactjs/compressed-size-action@7d87f60a6b0c7d193b8183ce859ed00b356ea92f # v2.1.0 - with: - repo-token: "${{ secrets.GITHUB_TOKEN }}" - pattern: "{build/**/*.js,build/**/*.css}" + - uses: preactjs/compressed-size-action@7d87f60a6b0c7d193b8183ce859ed00b356ea92f # v2.1.0 + with: + repo-token: '${{ secrets.GITHUB_TOKEN }}' + pattern: '{build/**/*.js,build/**/*.css}' diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml index 6c8cc20fe1135..919a8a4691db8 100644 --- a/.github/workflows/cancel.yml +++ b/.github/workflows/cancel.yml @@ -1,15 +1,15 @@ name: Cancel on: pull_request jobs: - cancel: - name: 'Cancel Previous Runs' - runs-on: ubuntu-latest - timeout-minutes: 3 - steps: - - name: Get all workflow ids and set to env variable - run: echo "WORKFLOW_IDS_TO_CANCEL=$(curl https://api.github.com/repos/${GITHUB_REPOSITORY}/actions/workflows -s | jq -r '.workflows | map(.id|tostring) | join(",")')" >> $GITHUB_ENV + cancel: + name: 'Cancel Previous Runs' + runs-on: ubuntu-latest + timeout-minutes: 3 + steps: + - name: Get all workflow ids and set to env variable + run: echo "WORKFLOW_IDS_TO_CANCEL=$(curl https://api.github.com/repos/${GITHUB_REPOSITORY}/actions/workflows -s | jq -r '.workflows | map(.id|tostring) | join(",")')" >> $GITHUB_ENV - - uses: styfle/cancel-workflow-action@3d86a7cc43670094ac248017207be0295edbc31d # v0.8.0 - with: - workflow_id: ${{ env.WORKFLOW_IDS_TO_CANCEL }} - access_token: ${{ secrets.GITHUB_TOKEN }} + - uses: styfle/cancel-workflow-action@3d86a7cc43670094ac248017207be0295edbc31d # v0.8.0 + with: + workflow_id: ${{ env.WORKFLOW_IDS_TO_CANCEL }} + access_token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/create-block.yml b/.github/workflows/create-block.yml index e27b9a8368676..e2d76e14788da 100644 --- a/.github/workflows/create-block.yml +++ b/.github/workflows/create-block.yml @@ -1,41 +1,41 @@ name: Create Block on: - pull_request: - push: - branches: [trunk, wp/trunk] + pull_request: + push: + branches: [trunk, wp/trunk] jobs: - checks: - name: Checks - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - node: [12, 14] + checks: + name: Checks + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + node: [12, 14] - steps: - - uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4 + steps: + - uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4 - - name: Cache node modules - uses: actions/cache@26968a09c0ea4f3e233fdddbafd1166051a095f6 # v2.1.4 - env: - cache-name: cache-node-modules - with: - # npm cache files are stored in `~/.npm` on Linux/macOS - path: ~/.npm - key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} - restore-keys: | - ${{ runner.os }}-build-${{ env.cache-name }}- - ${{ runner.os }}-build- - ${{ runner.os }}- + - name: Cache node modules + uses: actions/cache@26968a09c0ea4f3e233fdddbafd1166051a095f6 # v2.1.4 + env: + cache-name: cache-node-modules + with: + # npm cache files are stored in `~/.npm` on Linux/macOS + path: ~/.npm + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-build-${{ env.cache-name }}- + ${{ runner.os }}-build- + ${{ runner.os }}- - - name: Use Node.js ${{ matrix.node }}.x - uses: actions/setup-node@46071b5c7a2e0c34e49c3cb8a0e792e86e18d5ea # v2.1.5 - with: - node-version: ${{ matrix.node }} + - name: Use Node.js ${{ matrix.node }}.x + uses: actions/setup-node@46071b5c7a2e0c34e49c3cb8a0e792e86e18d5ea # v2.1.5 + with: + node-version: ${{ matrix.node }} - - name: npm install, build, format and lint - run: | - npm ci - npm run test:create-block + - name: npm install, build, format and lint + run: | + npm ci + npm run test:create-block diff --git a/.github/workflows/end2end-test.yml b/.github/workflows/end2end-test.yml index 4d0bbe41c5b27..6f4576b6cd37c 100644 --- a/.github/workflows/end2end-test.yml +++ b/.github/workflows/end2end-test.yml @@ -1,63 +1,62 @@ name: End-to-End Tests on: - pull_request: - push: - branches: - - trunk - - 'wp/**' + pull_request: + push: + branches: + - trunk + - 'wp/**' jobs: - admin: - name: Admin - ${{ matrix.part }} - - runs-on: ubuntu-latest - - strategy: - fail-fast: false - matrix: - part: [1, 2, 3, 4] - - - steps: - - uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4 - - - name: Cache node modules - uses: actions/cache@26968a09c0ea4f3e233fdddbafd1166051a095f6 # v2.1.4 - env: - cache-name: cache-node-modules - with: - # npm cache files are stored in `~/.npm` on Linux/macOS - path: ~/.npm - key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} - restore-keys: | - ${{ runner.os }}-build-${{ env.cache-name }}- - ${{ runner.os }}-build- - ${{ runner.os }}- - - - name: Use Node.js 14.x - uses: actions/setup-node@46071b5c7a2e0c34e49c3cb8a0e792e86e18d5ea # v2.1.5 - with: - node-version: 14.x - - - name: Npm install and build - run: | - npm ci - FORCE_REDUCED_MOTION=true npm run build - - - name: Install WordPress - run: | - chmod -R 767 ./ # TODO: Possibly integrate in wp-env - npm run wp-env start - - - name: Running the tests - run: | - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --listTests > ~/.jest-e2e-tests - $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --cacheDirectory="$HOME/.jest-cache" --runTestsByPath $( awk 'NR % 4 == ${{ matrix.part }} - 1' < ~/.jest-e2e-tests ) - - - name: Archive debug artifacts (screenshots, HTML snapshots) - uses: actions/upload-artifact@e448a9b857ee2131e752b06002bf0e093c65e571 # v2.2.2 - if: always() - with: - name: failures-artifacts - path: artifacts + admin: + name: Admin - ${{ matrix.part }} + + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + part: [1, 2, 3, 4] + + steps: + - uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4 + + - name: Cache node modules + uses: actions/cache@26968a09c0ea4f3e233fdddbafd1166051a095f6 # v2.1.4 + env: + cache-name: cache-node-modules + with: + # npm cache files are stored in `~/.npm` on Linux/macOS + path: ~/.npm + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-build-${{ env.cache-name }}- + ${{ runner.os }}-build- + ${{ runner.os }}- + + - name: Use Node.js 14.x + uses: actions/setup-node@46071b5c7a2e0c34e49c3cb8a0e792e86e18d5ea # v2.1.5 + with: + node-version: 14.x + + - name: Npm install and build + run: | + npm ci + FORCE_REDUCED_MOTION=true npm run build + + - name: Install WordPress + run: | + chmod -R 767 ./ # TODO: Possibly integrate in wp-env + npm run wp-env start + + - name: Running the tests + run: | + $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --listTests > ~/.jest-e2e-tests + $( npm bin )/wp-scripts test-e2e --config=./packages/e2e-tests/jest.config.js --cacheDirectory="$HOME/.jest-cache" --runTestsByPath $( awk 'NR % 4 == ${{ matrix.part }} - 1' < ~/.jest-e2e-tests ) + + - name: Archive debug artifacts (screenshots, HTML snapshots) + uses: actions/upload-artifact@e448a9b857ee2131e752b06002bf0e093c65e571 # v2.2.2 + if: always() + with: + name: failures-artifacts + path: artifacts diff --git a/.github/workflows/performance.yml b/.github/workflows/performance.yml index e3adb12f17384..bf9fb39e4b065 100644 --- a/.github/workflows/performance.yml +++ b/.github/workflows/performance.yml @@ -1,58 +1,56 @@ name: Performances Tests on: - pull_request: - release: - types: [created] + pull_request: + release: + types: [created] jobs: - performance: - name: Run performance tests - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4 - - - name: Cache node modules - uses: actions/cache@26968a09c0ea4f3e233fdddbafd1166051a095f6 # v2.1.4 - env: - cache-name: cache-node-modules - with: - # npm cache files are stored in `~/.npm` on Linux/macOS - path: ~/.npm - key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} - restore-keys: | - ${{ runner.os }}-build-${{ env.cache-name }}- - ${{ runner.os }}-build- - ${{ runner.os }}- - - - name: Use Node.js 14.x - uses: actions/setup-node@46071b5c7a2e0c34e49c3cb8a0e792e86e18d5ea # v2.1.5 - with: - node-version: 14.x - - - name: Npm install - run: | - npm ci - - - name: Compare performance with trunk - if: github.event_name == 'pull_request' - run: ./bin/plugin/cli.js perf --ci $GITHUB_SHA trunk --tests-branch $GITHUB_SHA - - - name: Compare performance with current WordPress Core and previous Gutenberg versions - if: github.event_name == 'release' - env: - PLUGIN_VERSION: ${{ github.event.release.name }} - run: | - IFS='.' read -r -a PLUGIN_VERSION_ARRAY <<< "$PLUGIN_VERSION" - CURRENT_RELEASE_BRANCH="release/${PLUGIN_VERSION_ARRAY[0]}.${PLUGIN_VERSION_ARRAY[1]}" - PREVIOUS_VERSION_BASE_10=$(expr ${PLUGIN_VERSION_ARRAY[0]} \* 10 + ${PLUGIN_VERSION_ARRAY[1]} - 1) - PREVIOUS_RELEASE_BRANCH="release/$(expr $PREVIOUS_VERSION_BASE_10 / 10).$(expr $PREVIOUS_VERSION_BASE_10 % 10)" - TESTED_UP_TO_REGEX="Tested up to: \K([0-9]+)\.([0-9]+)\.?([0-9]?)" - WP_VERSION=$(grep -oP "$TESTED_UP_TO_REGEX" ./readme.txt) - IFS='.' read -r -a WP_VERSION_ARRAY <<< "$WP_VERSION" - WP_BRANCH="wp/${WP_VERSION_ARRAY[0]}.${WP_VERSION_ARRAY[1]}" - ./bin/plugin/cli.js perf --ci $WP_BRANCH $PREVIOUS_RELEASE_BRANCH $CURRENT_RELEASE_BRANCH - - + performance: + name: Run performance tests + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4 + + - name: Cache node modules + uses: actions/cache@26968a09c0ea4f3e233fdddbafd1166051a095f6 # v2.1.4 + env: + cache-name: cache-node-modules + with: + # npm cache files are stored in `~/.npm` on Linux/macOS + path: ~/.npm + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-build-${{ env.cache-name }}- + ${{ runner.os }}-build- + ${{ runner.os }}- + + - name: Use Node.js 14.x + uses: actions/setup-node@46071b5c7a2e0c34e49c3cb8a0e792e86e18d5ea # v2.1.5 + with: + node-version: 14.x + + - name: Npm install + run: | + npm ci + + - name: Compare performance with trunk + if: github.event_name == 'pull_request' + run: ./bin/plugin/cli.js perf --ci $GITHUB_SHA trunk --tests-branch $GITHUB_SHA + + - name: Compare performance with current WordPress Core and previous Gutenberg versions + if: github.event_name == 'release' + env: + PLUGIN_VERSION: ${{ github.event.release.name }} + run: | + IFS='.' read -r -a PLUGIN_VERSION_ARRAY <<< "$PLUGIN_VERSION" + CURRENT_RELEASE_BRANCH="release/${PLUGIN_VERSION_ARRAY[0]}.${PLUGIN_VERSION_ARRAY[1]}" + PREVIOUS_VERSION_BASE_10=$(expr ${PLUGIN_VERSION_ARRAY[0]} \* 10 + ${PLUGIN_VERSION_ARRAY[1]} - 1) + PREVIOUS_RELEASE_BRANCH="release/$(expr $PREVIOUS_VERSION_BASE_10 / 10).$(expr $PREVIOUS_VERSION_BASE_10 % 10)" + TESTED_UP_TO_REGEX="Tested up to: \K([0-9]+)\.([0-9]+)\.?([0-9]?)" + WP_VERSION=$(grep -oP "$TESTED_UP_TO_REGEX" ./readme.txt) + IFS='.' read -r -a WP_VERSION_ARRAY <<< "$WP_VERSION" + WP_BRANCH="wp/${WP_VERSION_ARRAY[0]}.${WP_VERSION_ARRAY[1]}" + ./bin/plugin/cli.js perf --ci $WP_BRANCH $PREVIOUS_RELEASE_BRANCH $CURRENT_RELEASE_BRANCH diff --git a/.github/workflows/pull-request-automation.yml b/.github/workflows/pull-request-automation.yml index b3fe89023d2bf..f97e9c28ec7e9 100644 --- a/.github/workflows/pull-request-automation.yml +++ b/.github/workflows/pull-request-automation.yml @@ -1,23 +1,23 @@ on: - pull_request_target: - types: [opened] - push: + pull_request_target: + types: [opened] + push: name: Pull request automation jobs: - pull-request-automation: - runs-on: ubuntu-latest - steps: - # Checkout defaults to using the branch which triggered the event, which - # isn't necessarily `trunk` (e.g. in the case of a merge). - - uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4 - with: - ref: trunk + pull-request-automation: + runs-on: ubuntu-latest + steps: + # Checkout defaults to using the branch which triggered the event, which + # isn't necessarily `trunk` (e.g. in the case of a merge). + - uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4 + with: + ref: trunk - # Changing into the action's directory and running `npm install` is much - # faster than a full project-wide `npm ci`. - - run: cd packages/project-management-automation && npm install + # Changing into the action's directory and running `npm install` is much + # faster than a full project-wide `npm ci`. + - run: cd packages/project-management-automation && npm install - - uses: ./packages/project-management-automation - with: - github_token: ${{ secrets.GITHUB_TOKEN }} + - uses: ./packages/project-management-automation + with: + github_token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/rnmobile-android-runner.yml b/.github/workflows/rnmobile-android-runner.yml index 384cfaf5de5a0..74b722c70fcbb 100644 --- a/.github/workflows/rnmobile-android-runner.yml +++ b/.github/workflows/rnmobile-android-runner.yml @@ -1,54 +1,52 @@ name: React Native E2E Tests (Android) on: - pull_request: - push: - branches: [trunk] + pull_request: + push: + branches: [trunk] jobs: - test: - runs-on: macos-latest - strategy: - matrix: - native-test-name: [ - gutenberg-editor-initial-html - ] - - steps: - - name: checkout - uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4 - - - name: Restore npm cache - uses: actions/cache@26968a09c0ea4f3e233fdddbafd1166051a095f6 # v2.1.4 - with: - path: ~/.npm - key: ${{ runner.os }}-npm-${{ hashFiles('package-lock.json') }} - restore-keys: | - ${{ runner.os }}-npm- - - - run: npm ci - - - name: Restore Gradle cache - uses: actions/cache@26968a09c0ea4f3e233fdddbafd1166051a095f6 # v2.1.4 - with: - path: ~/.gradle/caches - key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} - restore-keys: ${{ runner.os }}-gradle - - - uses: reactivecircus/android-emulator-runner@d2799957d660add41c61a5103e2fbb9e2889eb73 # v2.15.0 - with: - api-level: 28 - profile: pixel_xl - script: npm run native test:e2e:android:local ${{ matrix.native-test-name }} - - - uses: actions/upload-artifact@e448a9b857ee2131e752b06002bf0e093c65e571 # v2.2.2 - if: always() - with: - name: android-screen-recordings - path: packages/react-native-editor/android-screen-recordings - - - uses: actions/upload-artifact@e448a9b857ee2131e752b06002bf0e093c65e571 # v2.2.2 - if: always() - with: - name: appium-logs - path: packages/react-native-editor/appium-out.log + test: + runs-on: macos-latest + strategy: + matrix: + native-test-name: [gutenberg-editor-initial-html] + + steps: + - name: checkout + uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4 + + - name: Restore npm cache + uses: actions/cache@26968a09c0ea4f3e233fdddbafd1166051a095f6 # v2.1.4 + with: + path: ~/.npm + key: ${{ runner.os }}-npm-${{ hashFiles('package-lock.json') }} + restore-keys: | + ${{ runner.os }}-npm- + + - run: npm ci + + - name: Restore Gradle cache + uses: actions/cache@26968a09c0ea4f3e233fdddbafd1166051a095f6 # v2.1.4 + with: + path: ~/.gradle/caches + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} + restore-keys: ${{ runner.os }}-gradle + + - uses: reactivecircus/android-emulator-runner@d2799957d660add41c61a5103e2fbb9e2889eb73 # v2.15.0 + with: + api-level: 28 + profile: pixel_xl + script: npm run native test:e2e:android:local ${{ matrix.native-test-name }} + + - uses: actions/upload-artifact@e448a9b857ee2131e752b06002bf0e093c65e571 # v2.2.2 + if: always() + with: + name: android-screen-recordings + path: packages/react-native-editor/android-screen-recordings + + - uses: actions/upload-artifact@e448a9b857ee2131e752b06002bf0e093c65e571 # v2.2.2 + if: always() + with: + name: appium-logs + path: packages/react-native-editor/appium-out.log diff --git a/.github/workflows/rnmobile-ios-runner.yml b/.github/workflows/rnmobile-ios-runner.yml index c05bbb42da10a..1f178df8a6b21 100644 --- a/.github/workflows/rnmobile-ios-runner.yml +++ b/.github/workflows/rnmobile-ios-runner.yml @@ -1,85 +1,83 @@ name: React Native E2E Tests (iOS) on: - pull_request: - push: - branches: [trunk] + pull_request: + push: + branches: [trunk] jobs: - test: - runs-on: macos-latest - strategy: - matrix: - xcode: [12.2] - native-test-name: [ - gutenberg-editor-initial-html - ] - - steps: - - uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4 - - - name: Restore npm cache - uses: actions/cache@26968a09c0ea4f3e233fdddbafd1166051a095f6 # v2.1.4 - with: - path: ~/.npm - key: ${{ runner.os }}-npm-${{ hashFiles('package-lock.json') }} - restore-keys: | - ${{ runner.os }}-npm- - - - run: npm ci - - - name: Prepare build cache key - run: find package-lock.json packages/react-native-editor/ios packages/react-native-aztec/ios packages/react-native-bridge/ios -type f -print0 | sort -z | xargs -0 shasum | tee ios-checksums.txt - - - name: Restore build cache - uses: actions/cache@26968a09c0ea4f3e233fdddbafd1166051a095f6 # v2.1.4 - with: - path: | - packages/react-native-editor/ios/build/GutenbergDemo/Build/Products/Release-iphonesimulator/GutenbergDemo.app - packages/react-native-editor/ios/build/WDA - key: ${{ runner.os }}-ios-build-${{ matrix.xcode }}-${{ hashFiles('ios-checksums.txt') }} - - - name: Restore pods cache - uses: actions/cache@26968a09c0ea4f3e233fdddbafd1166051a095f6 # v2.1.4 - with: - path: | - packages/react-native-editor/ios/Pods - ~/Library/Caches/CocoaPods - ~/.cocoapods/repos/trunk - packages/react-native-editor/ios/vendor - key: ${{ runner.os }}-pods-${{ hashFiles('packages/react-native-editor/ios/Gemfile.lock') }}-${{ hashFiles('packages/react-native-editor/ios/Podfile.lock') }}-${{ hashFiles('package-lock.json') }} - restore-keys: | - ${{ runner.os }}-pods-${{ hashFiles('packages/react-native-editor/ios/Gemfile.lock') }}-${{ hashFiles('packages/react-native-editor/ios/Podfile.lock') }}-${{ hashFiles('package-lock.json') }} - ${{ runner.os }}-pods-${{ hashFiles('packages/react-native-editor/ios/Gemfile.lock') }}-${{ hashFiles('packages/react-native-editor/ios/Podfile.lock') }}- - ${{ runner.os }}-pods-${{ hashFiles('packages/react-native-editor/ios/Gemfile.lock') }}- - ${{ runner.os }}-pods- - - - name: Bundle iOS - run: npm run native test:e2e:bundle:ios - - - name: Switch Xcode version to ${{ matrix.xcode }} - run: sudo xcode-select --switch /Applications/Xcode_${{ matrix.xcode }}.app - - - name: Build (if needed) - run: test -e packages/react-native-editor/ios/build/GutenbergDemo/Build/Products/Release-iphonesimulator/GutenbergDemo.app/GutenbergDemo || npm run native test:e2e:build-app:ios - - - name: Build Web Driver Agent (if needed) - run: test -d packages/react-native-editor/ios/build/WDA || npm run native test:e2e:build-wda - - - name: Run iOS Device Tests - run: TEST_RN_PLATFORM=ios npm run native device-tests:local ${{ matrix.native-test-name }} - - - name: Prepare build cache - run: rm packages/react-native-editor/ios/build/GutenbergDemo/Build/Products/Release-iphonesimulator/GutenbergDemo.app/main.jsbundle - - - uses: actions/upload-artifact@e448a9b857ee2131e752b06002bf0e093c65e571 # v2.2.2 - if: always() - with: - name: ios-screen-recordings - path: packages/react-native-editor/ios-screen-recordings - - - uses: actions/upload-artifact@e448a9b857ee2131e752b06002bf0e093c65e571 # v2.2.2 - if: always() - with: - name: appium-logs - path: packages/react-native-editor/appium-out.log + test: + runs-on: macos-latest + strategy: + matrix: + xcode: [12.2] + native-test-name: [gutenberg-editor-initial-html] + + steps: + - uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4 + + - name: Restore npm cache + uses: actions/cache@26968a09c0ea4f3e233fdddbafd1166051a095f6 # v2.1.4 + with: + path: ~/.npm + key: ${{ runner.os }}-npm-${{ hashFiles('package-lock.json') }} + restore-keys: | + ${{ runner.os }}-npm- + + - run: npm ci + + - name: Prepare build cache key + run: find package-lock.json packages/react-native-editor/ios packages/react-native-aztec/ios packages/react-native-bridge/ios -type f -print0 | sort -z | xargs -0 shasum | tee ios-checksums.txt + + - name: Restore build cache + uses: actions/cache@26968a09c0ea4f3e233fdddbafd1166051a095f6 # v2.1.4 + with: + path: | + packages/react-native-editor/ios/build/GutenbergDemo/Build/Products/Release-iphonesimulator/GutenbergDemo.app + packages/react-native-editor/ios/build/WDA + key: ${{ runner.os }}-ios-build-${{ matrix.xcode }}-${{ hashFiles('ios-checksums.txt') }} + + - name: Restore pods cache + uses: actions/cache@26968a09c0ea4f3e233fdddbafd1166051a095f6 # v2.1.4 + with: + path: | + packages/react-native-editor/ios/Pods + ~/Library/Caches/CocoaPods + ~/.cocoapods/repos/trunk + packages/react-native-editor/ios/vendor + key: ${{ runner.os }}-pods-${{ hashFiles('packages/react-native-editor/ios/Gemfile.lock') }}-${{ hashFiles('packages/react-native-editor/ios/Podfile.lock') }}-${{ hashFiles('package-lock.json') }} + restore-keys: | + ${{ runner.os }}-pods-${{ hashFiles('packages/react-native-editor/ios/Gemfile.lock') }}-${{ hashFiles('packages/react-native-editor/ios/Podfile.lock') }}-${{ hashFiles('package-lock.json') }} + ${{ runner.os }}-pods-${{ hashFiles('packages/react-native-editor/ios/Gemfile.lock') }}-${{ hashFiles('packages/react-native-editor/ios/Podfile.lock') }}- + ${{ runner.os }}-pods-${{ hashFiles('packages/react-native-editor/ios/Gemfile.lock') }}- + ${{ runner.os }}-pods- + + - name: Bundle iOS + run: npm run native test:e2e:bundle:ios + + - name: Switch Xcode version to ${{ matrix.xcode }} + run: sudo xcode-select --switch /Applications/Xcode_${{ matrix.xcode }}.app + + - name: Build (if needed) + run: test -e packages/react-native-editor/ios/build/GutenbergDemo/Build/Products/Release-iphonesimulator/GutenbergDemo.app/GutenbergDemo || npm run native test:e2e:build-app:ios + + - name: Build Web Driver Agent (if needed) + run: test -d packages/react-native-editor/ios/build/WDA || npm run native test:e2e:build-wda + + - name: Run iOS Device Tests + run: TEST_RN_PLATFORM=ios npm run native device-tests:local ${{ matrix.native-test-name }} + + - name: Prepare build cache + run: rm packages/react-native-editor/ios/build/GutenbergDemo/Build/Products/Release-iphonesimulator/GutenbergDemo.app/main.jsbundle + + - uses: actions/upload-artifact@e448a9b857ee2131e752b06002bf0e093c65e571 # v2.2.2 + if: always() + with: + name: ios-screen-recordings + path: packages/react-native-editor/ios-screen-recordings + + - uses: actions/upload-artifact@e448a9b857ee2131e752b06002bf0e093c65e571 # v2.2.2 + if: always() + with: + name: appium-logs + path: packages/react-native-editor/appium-out.log diff --git a/.github/workflows/stale-issue-add-needs-testing.yml b/.github/workflows/stale-issue-add-needs-testing.yml index a963f97287939..e17bfa7b29567 100644 --- a/.github/workflows/stale-issue-add-needs-testing.yml +++ b/.github/workflows/stale-issue-add-needs-testing.yml @@ -1,17 +1,17 @@ -name: "Mark old issues as needs confirmation" +name: 'Mark old issues as needs confirmation' on: - schedule: - - cron: "45 1 * * *" + schedule: + - cron: '45 1 * * *' jobs: - stale: - runs-on: ubuntu-latest - steps: - - uses: actions/stale@996798eb71ef485dc4c7b4d3285842d714040c4a # v3.0.17 - with: - repo-token: ${{ secrets.GITHUB_TOKEN }} - stale-issue-message: "Hi,\nThis issue has gone 180 days without any activity. This means it is time for a check-in to make sure it is still relevant. If you are still experiencing this issue with the latest versions, you can help the project by responding to confirm the problem and by providing any updated reproduction steps.\nThanks for helping out." - days-before-stale: 180 - days-before-close: -1 - remove-stale-when-updated: false - stale-issue-label: 'Needs Testing' + stale: + runs-on: ubuntu-latest + steps: + - uses: actions/stale@996798eb71ef485dc4c7b4d3285842d714040c4a # v3.0.17 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + stale-issue-message: "Hi,\nThis issue has gone 180 days without any activity. This means it is time for a check-in to make sure it is still relevant. If you are still experiencing this issue with the latest versions, you can help the project by responding to confirm the problem and by providing any updated reproduction steps.\nThanks for helping out." + days-before-stale: 180 + days-before-close: -1 + remove-stale-when-updated: false + stale-issue-label: 'Needs Testing' diff --git a/.github/workflows/stale-issue-mark-stale.yml b/.github/workflows/stale-issue-mark-stale.yml index 91d29cccedbe8..983b62c1e0700 100644 --- a/.github/workflows/stale-issue-mark-stale.yml +++ b/.github/workflows/stale-issue-mark-stale.yml @@ -1,17 +1,17 @@ -name: "Mark issues stale after needs testing for 30 days" +name: 'Mark issues stale after needs testing for 30 days' on: - schedule: - - cron: "55 1 * * *" + schedule: + - cron: '55 1 * * *' jobs: - stale: - runs-on: ubuntu-latest - steps: - - uses: actions/stale@996798eb71ef485dc4c7b4d3285842d714040c4a # v3.0.17 - with: - repo-token: ${{ secrets.GITHUB_TOKEN }} - days-before-stale: 30 - days-before-close: -1 - only-labels: 'Needs Testing' - skip-stale-issue-message: true - stale-issue-label: '[Status] Stale' + stale: + runs-on: ubuntu-latest + steps: + - uses: actions/stale@996798eb71ef485dc4c7b4d3285842d714040c4a # v3.0.17 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + days-before-stale: 30 + days-before-close: -1 + only-labels: 'Needs Testing' + skip-stale-issue-message: true + stale-issue-label: '[Status] Stale' diff --git a/.github/workflows/stale-issue-needs-info.yml b/.github/workflows/stale-issue-needs-info.yml index 7dede45c224ed..c0f3e4ed6bec6 100644 --- a/.github/workflows/stale-issue-needs-info.yml +++ b/.github/workflows/stale-issue-needs-info.yml @@ -1,17 +1,17 @@ -name: "Mark issues stale that require info" +name: 'Mark issues stale that require info' on: - schedule: - - cron: "30 1 * * *" + schedule: + - cron: '30 1 * * *' jobs: - stale: - runs-on: ubuntu-latest - steps: - - uses: actions/stale@996798eb71ef485dc4c7b4d3285842d714040c4a # v3.0.17 - with: - repo-token: ${{ secrets.GITHUB_TOKEN }} - stale-issue-message: 'Help us move this issue forward. This issue is being marked stale since it has no activity after 15 days of requesting more information. Please add info requested so we can help move the issue forward. Note: The triage policy is to close stale issues that need more info and no response after 2 weeks.' - days-before-stale: 15 - days-before-close: -1 - only-labels: '[Status] Needs More Info' - stale-issue-label: '[Status] Stale' + stale: + runs-on: ubuntu-latest + steps: + - uses: actions/stale@996798eb71ef485dc4c7b4d3285842d714040c4a # v3.0.17 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + stale-issue-message: 'Help us move this issue forward. This issue is being marked stale since it has no activity after 15 days of requesting more information. Please add info requested so we can help move the issue forward. Note: The triage policy is to close stale issues that need more info and no response after 2 weeks.' + days-before-stale: 15 + days-before-close: -1 + only-labels: '[Status] Needs More Info' + stale-issue-label: '[Status] Stale' diff --git a/.github/workflows/static-checks.yml b/.github/workflows/static-checks.yml index ad10daa5a167f..4264af972e028 100644 --- a/.github/workflows/static-checks.yml +++ b/.github/workflows/static-checks.yml @@ -1,59 +1,59 @@ name: Static Analysis (Linting, License, Type checks...) on: - pull_request: - push: - branches: - - trunk - - 'wp/**' + pull_request: + push: + branches: + - trunk + - 'wp/**' jobs: - check: - name: All - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4 - - - name: Cache node modules - uses: actions/cache@26968a09c0ea4f3e233fdddbafd1166051a095f6 # v2.1.4 - env: - cache-name: cache-node-modules - with: - # npm cache files are stored in `~/.npm` on Linux/macOS - path: ~/.npm - key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} - restore-keys: | - ${{ runner.os }}-build-${{ env.cache-name }}- - ${{ runner.os }}-build- - ${{ runner.os }}- - - - name: Use Node.js 14.x - uses: actions/setup-node@46071b5c7a2e0c34e49c3cb8a0e792e86e18d5ea # v2.1.5 - with: - node-version: 14.x - - - name: Npm install and build - # A "full" install is executed, since `npm ci` does not always exit - # with an error status code if the lock file is inaccurate. - # - # See: https://github.com/WordPress/gutenberg/issues/16157 - run: | - npm install - npm run build - - - name: Lint JavaScript and Styles - run: npm run lint - - - name: Lint ES5 built files (IE11) - run: npx eslint --parser-options=ecmaVersion:5 --no-eslintrc --no-ignore ./build/**/*.js - - - name: Type checking - run: npm run build:package-types - - - name: Build artifacts - run: npm run check-local-changes - - - name: License compatibility - run: npm run check-licenses + check: + name: All + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4 + + - name: Cache node modules + uses: actions/cache@26968a09c0ea4f3e233fdddbafd1166051a095f6 # v2.1.4 + env: + cache-name: cache-node-modules + with: + # npm cache files are stored in `~/.npm` on Linux/macOS + path: ~/.npm + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-build-${{ env.cache-name }}- + ${{ runner.os }}-build- + ${{ runner.os }}- + + - name: Use Node.js 14.x + uses: actions/setup-node@46071b5c7a2e0c34e49c3cb8a0e792e86e18d5ea # v2.1.5 + with: + node-version: 14.x + + - name: Npm install and build + # A "full" install is executed, since `npm ci` does not always exit + # with an error status code if the lock file is inaccurate. + # + # See: https://github.com/WordPress/gutenberg/issues/16157 + run: | + npm install + npm run build + + - name: Lint JavaScript and Styles + run: npm run lint + + - name: Lint ES5 built files (IE11) + run: npx eslint --parser-options=ecmaVersion:5 --no-eslintrc --no-ignore ./build/**/*.js + + - name: Type checking + run: npm run build:package-types + + - name: Build artifacts + run: npm run check-local-changes + + - name: License compatibility + run: npm run check-licenses diff --git a/.github/workflows/storybook-pages.yml b/.github/workflows/storybook-pages.yml index 5ea64c6789934..d717c1cf58c3a 100644 --- a/.github/workflows/storybook-pages.yml +++ b/.github/workflows/storybook-pages.yml @@ -1,45 +1,45 @@ name: Storybook GitHub Pages on: - push: - branches: - - trunk + push: + branches: + - trunk jobs: - deploy: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4 - with: - ref: trunk + deploy: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4 + with: + ref: trunk - - name: Cache node modules - uses: actions/cache@26968a09c0ea4f3e233fdddbafd1166051a095f6 # v2.1.4 - env: - cache-name: cache-node-modules - with: - # npm cache files are stored in `~/.npm` on Linux/macOS - path: ~/.npm - key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} - restore-keys: | - ${{ runner.os }}-build-${{ env.cache-name }}- - ${{ runner.os }}-build- - ${{ runner.os }}- + - name: Cache node modules + uses: actions/cache@26968a09c0ea4f3e233fdddbafd1166051a095f6 # v2.1.4 + env: + cache-name: cache-node-modules + with: + # npm cache files are stored in `~/.npm` on Linux/macOS + path: ~/.npm + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-build-${{ env.cache-name }}- + ${{ runner.os }}-build- + ${{ runner.os }}- - - name: Setup Node - uses: actions/setup-node@46071b5c7a2e0c34e49c3cb8a0e792e86e18d5ea # v2.1.5 - with: - node-version: '14.x' + - name: Setup Node + uses: actions/setup-node@46071b5c7a2e0c34e49c3cb8a0e792e86e18d5ea # v2.1.5 + with: + node-version: '14.x' - - name: Install Dependencies - run: npm ci + - name: Install Dependencies + run: npm ci - - name: Build Storybook - run: npm run storybook:build + - name: Build Storybook + run: npm run storybook:build - - name: Deploy - uses: peaceiris/actions-gh-pages@bbdfb200618d235585ad98e965f4aafc39b4c501 # v3.7.3 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: ./storybook/build + - name: Deploy + uses: peaceiris/actions-gh-pages@bbdfb200618d235585ad98e965f4aafc39b4c501 # v3.7.3 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: ./storybook/build diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml index a5ccf320fbef5..a14504275a780 100644 --- a/.github/workflows/unit-test.yml +++ b/.github/workflows/unit-test.yml @@ -3,137 +3,136 @@ name: Unit Tests # Since Unit Tests are required to pass for each PR, # we cannot disable them for documentation-only changes. on: - pull_request: - push: - branches: - - trunk - - 'wp/**' + pull_request: + push: + branches: + - trunk + - 'wp/**' jobs: - unit-js: - name: JavaScript - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - node: [12, 14] - - steps: - - uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4 - - - name: Cache node modules - uses: actions/cache@26968a09c0ea4f3e233fdddbafd1166051a095f6 # v2.1.4 - env: - cache-name: cache-node-modules - with: - # npm cache files are stored in `~/.npm` on Linux/macOS - path: ~/.npm - key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} - restore-keys: | - ${{ runner.os }}-build-${{ env.cache-name }}- - ${{ runner.os }}-build- - ${{ runner.os }}- - - - name: Use Node.js ${{ matrix.node }}.x - uses: actions/setup-node@46071b5c7a2e0c34e49c3cb8a0e792e86e18d5ea # v2.1.5 - with: - node-version: ${{ matrix.node }} - - - name: Npm install and build - # It's not necessary to run the full build, since Jest can interpret - # source files with `babel-jest`. Some packages have their own custom - # build tasks, however. These must be run. - run: | - npm ci - npx lerna run build - - - name: Running the tests - run: npm run test-unit -- --ci --maxWorkers=2 --cacheDirectory="$HOME/.jest-cache" - - - name: Running the date tests - run: npm run test-unit:date -- --ci --maxWorkers=2 --cacheDirectory="$HOME/.jest-cache" - - unit-php: - name: PHP - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4 - - - name: Cache node modules - uses: actions/cache@26968a09c0ea4f3e233fdddbafd1166051a095f6 # v2.1.4 - env: - cache-name: cache-node-modules - with: - # npm cache files are stored in `~/.npm` on Linux/macOS - path: ~/.npm - key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} - restore-keys: | - ${{ runner.os }}-build-${{ env.cache-name }}- - ${{ runner.os }}-build- - ${{ runner.os }}- - - - name: Use Node.js 14.x - uses: actions/setup-node@46071b5c7a2e0c34e49c3cb8a0e792e86e18d5ea # v2.1.5 - with: - node-version: 14.x - - - name: Npm install and build - run: | - npm ci - npm run build - - - name: Install WordPress - run: | - chmod -R 767 ./ # TODO: Possibly integrate in wp-env - npm run wp-env start - - - name: Running lint check - run: npm run lint-php - - - name: Running single site unit tests - run: npm run test-unit-php - if: ${{ success() || failure() }} - - - name: Running multisite unit tests - run: npm run test-unit-php-multisite - if: ${{ success() || failure() }} - - - mobile-unit-js: - name: Mobile - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4 - - - name: Cache node modules - uses: actions/cache@26968a09c0ea4f3e233fdddbafd1166051a095f6 # v2.1.4 - env: - cache-name: cache-node-modules - with: - # npm cache files are stored in `~/.npm` on Linux/macOS - path: ~/.npm - key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} - restore-keys: | - ${{ runner.os }}-build-${{ env.cache-name }}- - ${{ runner.os }}-build- - ${{ runner.os }}- - - - name: Use Node.js 14.x - uses: actions/setup-node@46071b5c7a2e0c34e49c3cb8a0e792e86e18d5ea # v2.1.5 - with: - node-version: 14.x - - - name: Npm install and build - # It's not necessary to run the full build, since Jest can interpret - # source files with `babel-jest`. Some packages have their own custom - # build tasks, however. These must be run. - run: | - npm ci - npx lerna run build - - - name: Running the tests - run: npm run test-unit:native -- --ci --maxWorkers=2 --cacheDirectory="$HOME/.jest-cache" + unit-js: + name: JavaScript + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + node: [12, 14] + + steps: + - uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4 + + - name: Cache node modules + uses: actions/cache@26968a09c0ea4f3e233fdddbafd1166051a095f6 # v2.1.4 + env: + cache-name: cache-node-modules + with: + # npm cache files are stored in `~/.npm` on Linux/macOS + path: ~/.npm + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-build-${{ env.cache-name }}- + ${{ runner.os }}-build- + ${{ runner.os }}- + + - name: Use Node.js ${{ matrix.node }}.x + uses: actions/setup-node@46071b5c7a2e0c34e49c3cb8a0e792e86e18d5ea # v2.1.5 + with: + node-version: ${{ matrix.node }} + + - name: Npm install and build + # It's not necessary to run the full build, since Jest can interpret + # source files with `babel-jest`. Some packages have their own custom + # build tasks, however. These must be run. + run: | + npm ci + npx lerna run build + + - name: Running the tests + run: npm run test-unit -- --ci --maxWorkers=2 --cacheDirectory="$HOME/.jest-cache" + + - name: Running the date tests + run: npm run test-unit:date -- --ci --maxWorkers=2 --cacheDirectory="$HOME/.jest-cache" + + unit-php: + name: PHP + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4 + + - name: Cache node modules + uses: actions/cache@26968a09c0ea4f3e233fdddbafd1166051a095f6 # v2.1.4 + env: + cache-name: cache-node-modules + with: + # npm cache files are stored in `~/.npm` on Linux/macOS + path: ~/.npm + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-build-${{ env.cache-name }}- + ${{ runner.os }}-build- + ${{ runner.os }}- + + - name: Use Node.js 14.x + uses: actions/setup-node@46071b5c7a2e0c34e49c3cb8a0e792e86e18d5ea # v2.1.5 + with: + node-version: 14.x + + - name: Npm install and build + run: | + npm ci + npm run build + + - name: Install WordPress + run: | + chmod -R 767 ./ # TODO: Possibly integrate in wp-env + npm run wp-env start + + - name: Running lint check + run: npm run lint-php + + - name: Running single site unit tests + run: npm run test-unit-php + if: ${{ success() || failure() }} + + - name: Running multisite unit tests + run: npm run test-unit-php-multisite + if: ${{ success() || failure() }} + + mobile-unit-js: + name: Mobile + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4 + + - name: Cache node modules + uses: actions/cache@26968a09c0ea4f3e233fdddbafd1166051a095f6 # v2.1.4 + env: + cache-name: cache-node-modules + with: + # npm cache files are stored in `~/.npm` on Linux/macOS + path: ~/.npm + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-build-${{ env.cache-name }}- + ${{ runner.os }}-build- + ${{ runner.os }}- + + - name: Use Node.js 14.x + uses: actions/setup-node@46071b5c7a2e0c34e49c3cb8a0e792e86e18d5ea # v2.1.5 + with: + node-version: 14.x + + - name: Npm install and build + # It's not necessary to run the full build, since Jest can interpret + # source files with `babel-jest`. Some packages have their own custom + # build tasks, however. These must be run. + run: | + npm ci + npx lerna run build + + - name: Running the tests + run: npm run test-unit:native -- --ci --maxWorkers=2 --cacheDirectory="$HOME/.jest-cache" diff --git a/.github/workflows/upload-release-to-plugin-repo.yml b/.github/workflows/upload-release-to-plugin-repo.yml index 0f77e22b1844e..e0997cd45ee58 100644 --- a/.github/workflows/upload-release-to-plugin-repo.yml +++ b/.github/workflows/upload-release-to-plugin-repo.yml @@ -1,154 +1,154 @@ name: Update Changelog and upload Gutenberg plugin to WordPress.org plugin repo on: - release: - types: [published] + release: + types: [published] jobs: - get-release-branch: - name: Get release branch name - runs-on: ubuntu-latest - if: github.event.release.assets[0] - outputs: - release_branch: ${{ steps.get_release_branch.outputs.release_branch }} - steps: - - name: Compute release branch name - id: get_release_branch - env: - TAG: ${{ github.event.release.tag_name }} - run: | - IFS='.' read -r -a VERSION_ARRAY <<< "${TAG#v}" - RELEASE_BRANCH="release/${VERSION_ARRAY[0]}.${VERSION_ARRAY[1]}" - echo "::set-output name=release_branch::$(echo $RELEASE_BRANCH)" - - update-changelog: - name: Update Changelog on ${{ matrix.branch }} branch - runs-on: ubuntu-latest - if: github.event.release.assets[0] - needs: get-release-branch - env: - TAG: ${{ github.event.release.tag_name }} - strategy: - matrix: - include: - - branch: trunk - label: trunk - - branch: ${{ needs.get-release-branch.outputs.release_branch }} - label: release - steps: - - name: Checkout code - uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4 - with: - ref: ${{ matrix.branch }} - token: ${{ secrets.GUTENBERG_TOKEN }} - - - name: Update the Changelog to include the release notes - run: | - # First, determine where to insert the new Changelog entry. - SERIES="${RELEASE_BRANCH#release/}" - SERIES_REGEX="=\s${SERIES}\.[0-9]+\s=" - CUT_MARKS=$( grep -nP -m 1 "${SERIES_REGEX}" changelog.txt | cut -d: -f1 ) - if [[ -z "${CUT_MARKS}" ]]; then - CHANGELOG_REGEX="=\s[0-9]+\.[0-9]+\.[0-9]+(-rc\.[0-9]+)?\s=" - RC_REGEX="=\s${TAG#v}(-rc\.[0-9]+)?\s=" - CUT_MARKS=$( awk "/${RC_REGEX}/ {print NR; next}; /${CHANGELOG_REGEX}/ {print NR; exit}" changelog.txt ) - fi - BEFORE=$( echo "$CUT_MARKS" | head -n 1 ) - AFTER=$( echo "$CUT_MARKS" | tail -n 1 ) - # Okay, we have all we need to build the new Changelog. - head -n $(( "${BEFORE}" - 1 )) changelog.txt > new_changelog.txt - printf '= %s =\n\n' "${TAG#v}" >> new_changelog.txt - # Need to use a heredoc in order to preserve special characters. - cat <<- "EOF" > release_notes.txt - ${{ github.event.release.body }} - EOF - # Normalize empty lines: Trim them from beginning and end of file... - awk 'NF {p=1} p' <<< "$(< release_notes.txt)" >> new_changelog.txt - # ...then add two empty lines at the end. - printf '\n\n' >> new_changelog.txt - tail -n +"${AFTER}" changelog.txt >> new_changelog.txt - mv new_changelog.txt changelog.txt - - - name: Configure git user name and email - run: | - git config user.name "Gutenberg Repository Automation" - git config user.email gutenberg@wordpress.org - - - name: Commit the Changelog update - run: | - git add changelog.txt - git commit -m "Update Changelog for ${TAG#v}" - git push --set-upstream origin "${{ matrix.branch }}" - - - name: Upload Changelog artifact - uses: actions/upload-artifact@e448a9b857ee2131e752b06002bf0e093c65e571 # v2.2.2 - with: - name: changelog ${{ matrix.label }} - path: ./changelog.txt - - upload: - name: Upload Gutenberg Plugin - runs-on: ubuntu-latest - environment: wp.org plugin - needs: update-changelog - if: ${{ !github.event.release.prerelease && github.event.release.assets[0] }} - env: - PLUGIN_REPO_URL: 'https://plugins.svn.wordpress.org/gutenberg' - STABLE_VERSION_REGEX: '[0-9]\+\.[0-9]\+\.[0-9]\+\s*' - SVN_USERNAME: ${{ secrets.svn_username }} - SVN_PASSWORD: ${{ secrets.svn_password }} - VERSION: ${{ github.event.release.name }} - steps: - - name: Check out Gutenberg trunk from WP.org plugin repo - run: svn checkout "$PLUGIN_REPO_URL/trunk" - - - name: Get previous stable version - id: get_previous_stable_version + get-release-branch: + name: Get release branch name + runs-on: ubuntu-latest + if: github.event.release.assets[0] + outputs: + release_branch: ${{ steps.get_release_branch.outputs.release_branch }} + steps: + - name: Compute release branch name + id: get_release_branch + env: + TAG: ${{ github.event.release.tag_name }} + run: | + IFS='.' read -r -a VERSION_ARRAY <<< "${TAG#v}" + RELEASE_BRANCH="release/${VERSION_ARRAY[0]}.${VERSION_ARRAY[1]}" + echo "::set-output name=release_branch::$(echo $RELEASE_BRANCH)" + + update-changelog: + name: Update Changelog on ${{ matrix.branch }} branch + runs-on: ubuntu-latest + if: github.event.release.assets[0] + needs: get-release-branch env: - STABLE_TAG_REGEX: 'Stable tag: \K${{ env.STABLE_VERSION_REGEX }}' - run: echo ::set-output name=stable_version::$(grep -oP "${STABLE_TAG_REGEX}" ./trunk/readme.txt) - - - name: Delete everything - working-directory: ./trunk - run: find . -maxdepth 1 -not -name ".svn" -not -name "." -not -name ".." -exec rm -rf {} + - - - name: Download and unzip Gutenberg plugin asset into trunk folder - env: - PLUGIN_URL: ${{ github.event.release.assets[0].browser_download_url }} - run: | - curl -L -o gutenberg.zip $PLUGIN_URL - unzip gutenberg.zip -d trunk - rm gutenberg.zip - - - name: Replace the stable tag placeholder with the existing stable tag on the SVN repository + TAG: ${{ github.event.release.tag_name }} + strategy: + matrix: + include: + - branch: trunk + label: trunk + - branch: ${{ needs.get-release-branch.outputs.release_branch }} + label: release + steps: + - name: Checkout code + uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4 + with: + ref: ${{ matrix.branch }} + token: ${{ secrets.GUTENBERG_TOKEN }} + + - name: Update the Changelog to include the release notes + run: | + # First, determine where to insert the new Changelog entry. + SERIES="${RELEASE_BRANCH#release/}" + SERIES_REGEX="=\s${SERIES}\.[0-9]+\s=" + CUT_MARKS=$( grep -nP -m 1 "${SERIES_REGEX}" changelog.txt | cut -d: -f1 ) + if [[ -z "${CUT_MARKS}" ]]; then + CHANGELOG_REGEX="=\s[0-9]+\.[0-9]+\.[0-9]+(-rc\.[0-9]+)?\s=" + RC_REGEX="=\s${TAG#v}(-rc\.[0-9]+)?\s=" + CUT_MARKS=$( awk "/${RC_REGEX}/ {print NR; next}; /${CHANGELOG_REGEX}/ {print NR; exit}" changelog.txt ) + fi + BEFORE=$( echo "$CUT_MARKS" | head -n 1 ) + AFTER=$( echo "$CUT_MARKS" | tail -n 1 ) + # Okay, we have all we need to build the new Changelog. + head -n $(( "${BEFORE}" - 1 )) changelog.txt > new_changelog.txt + printf '= %s =\n\n' "${TAG#v}" >> new_changelog.txt + # Need to use a heredoc in order to preserve special characters. + cat <<- "EOF" > release_notes.txt + ${{ github.event.release.body }} + EOF + # Normalize empty lines: Trim them from beginning and end of file... + awk 'NF {p=1} p' <<< "$(< release_notes.txt)" >> new_changelog.txt + # ...then add two empty lines at the end. + printf '\n\n' >> new_changelog.txt + tail -n +"${AFTER}" changelog.txt >> new_changelog.txt + mv new_changelog.txt changelog.txt + + - name: Configure git user name and email + run: | + git config user.name "Gutenberg Repository Automation" + git config user.email gutenberg@wordpress.org + + - name: Commit the Changelog update + run: | + git add changelog.txt + git commit -m "Update Changelog for ${TAG#v}" + git push --set-upstream origin "${{ matrix.branch }}" + + - name: Upload Changelog artifact + uses: actions/upload-artifact@e448a9b857ee2131e752b06002bf0e093c65e571 # v2.2.2 + with: + name: changelog ${{ matrix.label }} + path: ./changelog.txt + + upload: + name: Upload Gutenberg Plugin + runs-on: ubuntu-latest + environment: wp.org plugin + needs: update-changelog + if: ${{ !github.event.release.prerelease && github.event.release.assets[0] }} env: - STABLE_TAG_PLACEHOLDER: 'Stable tag: V\.V\.V' - STABLE_TAG: 'Stable tag: ${{ steps.get_previous_stable_version.outputs.stable_version }}' - run: sed -i "s/${STABLE_TAG_PLACEHOLDER}/${STABLE_TAG}/g" ./trunk/readme.txt - - - name: Download Changelog Artifact - uses: actions/download-artifact@4a7a711286f30c025902c28b541c10e147a9b843 # v2.0.8 - with: - name: changelog trunk - path: trunk - - - name: Commit the content changes - working-directory: ./trunk - run: | - svn st | grep '^?' | awk '{print $2}' | xargs -r svn add - svn st | grep '^!' | awk '{print $2}' | xargs -r svn rm - svn commit -m "Committing version $VERSION" \ - --no-auth-cache --non-interactive --username "$SVN_USERNAME" --password "$SVN_PASSWORD" - - - name: Create the SVN tag - working-directory: ./trunk - run: | - svn copy "$PLUGIN_REPO_URL/trunk" "$PLUGIN_REPO_URL/tags/$VERSION" -m "Tagging version $VERSION" \ - --no-auth-cache --non-interactive --username "$SVN_USERNAME" --password "$SVN_PASSWORD" - - - name: Update the plugin's stable version - working-directory: ./trunk - run: | - sed -i "s/Stable tag: ${STABLE_VERSION_REGEX}/Stable tag: ${VERSION}/g" ./readme.txt - svn commit -m "Releasing version $VERSION" \ - --no-auth-cache --non-interactive --username "$SVN_USERNAME" --password "$SVN_PASSWORD" + PLUGIN_REPO_URL: 'https://plugins.svn.wordpress.org/gutenberg' + STABLE_VERSION_REGEX: '[0-9]\+\.[0-9]\+\.[0-9]\+\s*' + SVN_USERNAME: ${{ secrets.svn_username }} + SVN_PASSWORD: ${{ secrets.svn_password }} + VERSION: ${{ github.event.release.name }} + steps: + - name: Check out Gutenberg trunk from WP.org plugin repo + run: svn checkout "$PLUGIN_REPO_URL/trunk" + + - name: Get previous stable version + id: get_previous_stable_version + env: + STABLE_TAG_REGEX: 'Stable tag: \K${{ env.STABLE_VERSION_REGEX }}' + run: echo ::set-output name=stable_version::$(grep -oP "${STABLE_TAG_REGEX}" ./trunk/readme.txt) + + - name: Delete everything + working-directory: ./trunk + run: find . -maxdepth 1 -not -name ".svn" -not -name "." -not -name ".." -exec rm -rf {} + + + - name: Download and unzip Gutenberg plugin asset into trunk folder + env: + PLUGIN_URL: ${{ github.event.release.assets[0].browser_download_url }} + run: | + curl -L -o gutenberg.zip $PLUGIN_URL + unzip gutenberg.zip -d trunk + rm gutenberg.zip + + - name: Replace the stable tag placeholder with the existing stable tag on the SVN repository + env: + STABLE_TAG_PLACEHOLDER: 'Stable tag: V\.V\.V' + STABLE_TAG: 'Stable tag: ${{ steps.get_previous_stable_version.outputs.stable_version }}' + run: sed -i "s/${STABLE_TAG_PLACEHOLDER}/${STABLE_TAG}/g" ./trunk/readme.txt + + - name: Download Changelog Artifact + uses: actions/download-artifact@4a7a711286f30c025902c28b541c10e147a9b843 # v2.0.8 + with: + name: changelog trunk + path: trunk + + - name: Commit the content changes + working-directory: ./trunk + run: | + svn st | grep '^?' | awk '{print $2}' | xargs -r svn add + svn st | grep '^!' | awk '{print $2}' | xargs -r svn rm + svn commit -m "Committing version $VERSION" \ + --no-auth-cache --non-interactive --username "$SVN_USERNAME" --password "$SVN_PASSWORD" + + - name: Create the SVN tag + working-directory: ./trunk + run: | + svn copy "$PLUGIN_REPO_URL/trunk" "$PLUGIN_REPO_URL/tags/$VERSION" -m "Tagging version $VERSION" \ + --no-auth-cache --non-interactive --username "$SVN_USERNAME" --password "$SVN_PASSWORD" + + - name: Update the plugin's stable version + working-directory: ./trunk + run: | + sed -i "s/Stable tag: ${STABLE_VERSION_REGEX}/Stable tag: ${VERSION}/g" ./readme.txt + svn commit -m "Releasing version $VERSION" \ + --no-auth-cache --non-interactive --username "$SVN_USERNAME" --password "$SVN_PASSWORD" diff --git a/packages/project-management-automation/action.yml b/packages/project-management-automation/action.yml index c5cd00678edd4..34490f539875c 100644 --- a/packages/project-management-automation/action.yml +++ b/packages/project-management-automation/action.yml @@ -1,10 +1,10 @@ name: Gutenberg project management automation description: > - Various automation to assist with managing the Gutenberg GitHub repository. + Various automation to assist with managing the Gutenberg GitHub repository. inputs: - github_token: - description: Secret GitHub API token to use for making API requests. - required: true + github_token: + description: Secret GitHub API token to use for making API requests. + required: true runs: - using: node12 - main: lib/index.js + using: node12 + main: lib/index.js