Skip to content

Commit

Permalink
Merge pull request #303 from pantheon-systems/release-automation-only
Browse files Browse the repository at this point in the history
Apply release CI to the "release" branch
  • Loading branch information
pwtyler authored Oct 29, 2024
2 parents 3289437 + 46b718f commit 86cbb3d
Show file tree
Hide file tree
Showing 11 changed files with 514 additions and 363 deletions.
20 changes: 0 additions & 20 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,6 @@ workflows:
- master
jobs:
- test-behat
commands:
run_test:
steps:
- run:
name: "Run Tests"
command: |
bash bin/install-wp-tests.sh wordpress_test root '' 127.0.0.1 latest
composer phpunit
WP_MULTISITE=1 composer phpunit
rm -rf $WP_TESTS_DIR $WP_CORE_DIR
bash bin/install-wp-tests.sh wordpress_test root '' 127.0.0.1 nightly true
composer phpunit
bash bin/full-teardown-wp-tests.sh wordpress_test root '' 127.0.0.1 latest
bash bin/install-wp-tests.sh wordpress_test root '' 127.0.0.1 latest
vendor/bin/phpunit --group=cli_command
WP_MULTISITE=1 vendor/bin/phpunit --group=cli_command
rm -rf $WP_TESTS_DIR $WP_CORE_DIR
bash bin/install-wp-tests.sh wordpress_test root '' 127.0.0.1 nightly true
vendor/bin/phpunit --group=cli_command
jobs:
test-behat:
resource_class: small
Expand Down Expand Up @@ -81,4 +62,3 @@ jobs:
- run:
command: ./bin/behat-cleanup.sh
when: always

62 changes: 62 additions & 0 deletions .github/workflows/build-tag-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Build, Tag and Release
on:
push:
branches:
- release

permissions:
pull-requests: write
contents: write

jobs:
check-status:
name: Check Status
runs-on: ubuntu-latest
outputs:
is-asset-update: ${{ steps.set-outputs.outputs.is-asset-update }}
steps:
- uses: actions/checkout@v4
- id: get-changed-files
uses: jitterbit/get-changed-files@v1
- id: set-outputs
run: |
echo "Changed files: ${{ steps.get-changed-files.outputs.all }}"
shopt -s nocasematch
run_plugin_update="true"
for file in ${{ steps.get-changed-files.outputs.all }}; do
if
[[ ! "$file" =~ ^\.wordpress\.org/ ]] && \
[[ ! $file =~ ^\.github/ ]] && \
[[ "$file" != "readme.txt" ]] && \
[[ $file != "readme.md" ]] && \
[[ $file != ".gitignore" ]] && \
[[ $file != *"composer"* ]]; then
run_plugin_update="false"
break
fi
done
echo "::set-output name=is-asset-update::$run_plugin_update"
asset-only:
name: WP.org Asset Only Update
needs: check-status
if: ${{ needs.check-status.outputs.is-asset-update == 'true' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: WP.org Asset Only Update
uses: 10up/action-wordpress-plugin-asset-update@stable
env:
SVN_USERNAME: ${{ secrets.SVN_USERNAME }}
SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }}
tag:
needs: check-status
if: ${{ needs.check-status.outputs.is-asset-update == 'false' }}
name: Create Tag and Draft Release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build, Tag & Release
uses: pantheon-systems/plugin-release-actions/build-tag-release@main
with:
gh_token: ${{ github.token }}
readme_md: README.md
28 changes: 28 additions & 0 deletions .github/workflows/composer-diff.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Composer Diff
on:
pull_request:
paths:
- 'composer.lock'
permissions:
contents: write
pull-requests: write
jobs:
composer-diff:
name: Composer Diff
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Generate composer diff
id: composer_diff
uses: IonBazan/composer-diff-action@v1
- uses: marocchino/sticky-pull-request-comment@v2
if: ${{ steps.composer_diff.outputs.composer_diff_exit_code != 0 }}
with:
header: composer-diff
message: |
<strong>Composer Changes</strong>
${{ steps.composer_diff.outputs.composer_diff }}
29 changes: 21 additions & 8 deletions .github/workflows/lint-test.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,30 @@
name: Linting & Test
on: [push]
on:
schedule:
- cron: '0 0 * * *'
pull_request:
types:
- opened
- synchronize
- reopened
- ready_for_review
branches:
- '**'

jobs:
validate-readme-spacing:
name: Validate README Spacing
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- uses: pantheon-systems/validate-readme-spacing@v1
lint:
name: PHPCS Linting
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Cache dependencies
uses: actions/cache@v3
with:
Expand All @@ -33,17 +44,17 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- uses: pantheon-systems/phpcompatibility-action@dev
with:
paths: ${{ github.workspace }}/*.php ${{ github.workspace }}/inc/*.php
test-versions: 8.0-
test-versions: 8.3-
wporg-validation:
name: WP.org Plugin Validation
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- uses: pantheon-systems/[email protected]
with:
type: 'plugin'
Expand All @@ -53,12 +64,12 @@ jobs:
runs-on: ubuntu-latest
services:
mariadb:
image: mariadb:10.5
image: mariadb:10.6
strategy:
matrix:
php_version: [7.4, 8.2, 8.3]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
Expand All @@ -72,6 +83,8 @@ jobs:
path: ~/vendor
key: test-dependencies-{{ checksum "composer.json" }}
restore-keys: test-dependencies-{{ checksum "composer.json" }}
- name: Setup WP-CLI
uses: godaddy-wordpress/setup-wp-cli@1
- name: Install dependencies
run: |
if [ ${{ matrix.php_version }} = "7.4" ]; then
Expand Down
21 changes: 21 additions & 0 deletions .github/workflows/release-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Draft Release PR
on:
push:
branches:
- develop

permissions:
pull-requests: write
contents: write

jobs:
draft-release:
name: Draft Release PR
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Create Draft Release PR
uses: pantheon-systems/plugin-release-actions/release-pr@main
with:
gh_token: ${{ github.token }}
readme_md: README.md
14 changes: 0 additions & 14 deletions .github/workflows/shellcheck.yml

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ vendor/
bin/install-local-tests.sh
bin/install-wp-tests.sh
bin/phpunit-test.sh
bin/helpers.sh
33 changes: 19 additions & 14 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ You may notice there are two sets of tests running, on two different services:

Both of these test suites can be run locally, with a varying amount of setup.

PHPUnit requires the [WordPress PHPUnit test suite](https://make.wordpress.org/core/handbook/testing/automated-testing/phpunit/), and access to a database with name `wordpress_test`. If you haven't already configured the test suite locally, you can run `bash bin/install-wp-tests.sh wordpress_test root '' localhost`.
PHPUnit requires the [WordPress PHPUnit test suite](https://make.wordpress.org/core/handbook/testing/automated-testing/phpunit/), and access to a database with name `wordpress_test`. If you haven't already configured the test suite locally, you can run `composer test:install:withdb`. Otherwise, you can install the test suite with `composer test:install`, and run the tests with `composer test`.

Behat requires a Pantheon site. Once you've created the site, you'll need [install Terminus](https://github.com/pantheon-systems/terminus#installation), and set the `TERMINUS_TOKEN`, `TERMINUS_SITE`, and `TERMINUS_ENV` environment variables. Then, you can run `./bin/behat-prepare.sh` to prepare the site for the test suite.

Expand All @@ -27,23 +27,15 @@ We prefer to squash commits (i.e. avoid merge PRs) from a feature branch into `d

`develop` should be stable and usable, though will be few commits ahead of the public release on wp.org.

The `main` branch matches the latest stable release deployed to [wp.org](wp.org).
The `main` branch matches the latest stable release deployed to [wp.org](https://wordpress.org).

## Release Process

1. From `develop`, checkout a new branch `release_X.Y.Z`.
1. Make a release commit:
* Drop the `-dev` from the version number in `README.md`, `readme.txt`, and `pantheon-sessions.php`.
* Add the date to the "X.Y.X" heading in the changelog
* Commit these changes with the message `Release X.Y.Z`
* Push the release branch up.
1. Open a Pull Request to merge `release_X.Y.Z` into `main`. Your PR should consist of all commits to `develop` since the last release, and one commit to update the version number. The PR name should also be `Release X.Y.Z`. Copy the changelog for the current release to the PR body.
1. After all tests pass and you have received approval from a [CODEOWNER](./CODEOWNERS), merge the PR into `main`. "Rebase and merge" is preferred in this case. _Never_ squash to `main`.
1. Pull `main` locally, create a new tag (based on version number from previous steps), and push up. The tag should _only_ be the version number. It _should not_ be prefixed `v` (i.e. `X.Y.Z`, not `vX.Y.X`).
* `git tag X.Y.Z`
* `git push --tags`
1. Merge your feature branch into `develop` with a PR. This PR should include any necessary updates to the changelog in readme.txt and README.md.
1. A draft release PR will be generated by the [`release-pr`](https://github.com/pantheon-systems/pantheon-advanced-page-cache/actions/workflows/release-pr.yml) action. This PR needs to be switched to Ready to Review so automated testing will run.
1. After merging the release PR to the `release` branch, a draft Release will be automatically be created by the [`build-tag-release`](https://github.com/pantheon-systems/pantheon-advanced-page-cache/actions/workflows/build-tag-release.yml) workflow. This draft release will be automatically pre-filled with release notes.
1. Confirm that the necessary assets are present in the newly created tag, and test on a WP install if desired.
1. Create a [new release](https://github.com/pantheon-systems/wp-native-php-sessions/releases/new) using the tag created in the previous steps, naming the release with the new version number, and targeting the tag created in the previous step. Paste the release changelog from the `Changelog` section of [the readme](readme.txt) into the body of the release, including the links to the closed issues if applicable.
1. Review the release notes making any necessary changes and publish the release.
1. Wait for the [_Release wp-native-php-sessions plugin to wp.org_ action](https://github.com/pantheon-systems/wp-native-php-sessions/actions/workflows/wordpress-plugin-deploy.yml) to finish deploying to the WordPress.org plugin repository. If all goes well, users with SVN commit access for that plugin will receive an emailed diff of changes.
1. Check WordPress.org: Ensure that the changes are live on [the plugin repository](https://wordpress.org/plugins/native-php-sessions/). This may take a few minutes.
1. Following the release, prepare the next dev version with the following steps:
Expand All @@ -56,3 +48,16 @@ The `main` branch matches the latest stable release deployed to [wp.org](wp.org)
* `git add -A .`
* `git commit -m "Prepare X.Y.X-dev"`
* `git push origin develop`

## Asset-only Releases
Thanks to [10up/action-wordpress-plugin-asset-update](https://github.com/10up/action-wordpress-plugin-asset-update/) we can make asset-only updates to WordPress.org without needing to create a new release. This is useful for updating the plugin banner, icon, screenshots or just updating the readme.txt.

Broadly the process for creating asset-only releases is as follows:

1. Branch off of `main` (not `develop`) and make your changes. Ensure that you are _only_ making changes to `readme.txt`/`readme.md` or files in the `.wordpress.org` directory. Some other changes (e.g. to `.gitignore` or `composer.json`) are allowed but any file changes to anything beyond those locations will trigger the release automation.
1. Push your branch to GitHub and open a PR against `main`.
1. Automation will trigger and create a new release branch in the repository. Because the version numbers have not changed, you will need to ensure that the version numbers in your branch are correct. If they are not, and a new branch was created automatically that drops the `-dev` suffix but contains the correct version number, you can merge that branch into your PR branch to update the version numbers, then close the release branch. A release PR will not be created because the diffs will not have changed.
1. Once the PR is merged, the asset update action will run and update the assets on WordPress.org.
1. Check out `develop` and merge `main` into it to ensure that the asset-only changes are included in the next release. Then update the version numbers again to re-add the `-dev` suffix.

**Note:** In the future we will work on making this process smoother and more automated.
5 changes: 4 additions & 1 deletion bin/behat-prepare.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ set -ex
###
# Create a new environment for this particular test run.
###
terminus env:create "${TERMINUS_SITE}.dev" "$TERMINUS_ENV"
terminus env:create "${TERMINUS_SITE}.dev" "$TERMINUS_ENV"
terminus env:wipe "$SITE_ENV" --yes

###
Expand All @@ -32,6 +32,9 @@ PANTHEON_SITE_URL="$TERMINUS_ENV-$TERMINUS_SITE.pantheonsite.io"
PREPARE_DIR="/tmp/$TERMINUS_ENV-$TERMINUS_SITE"
BASH_DIR="$( cd -P "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

PHP_VERSION="$(terminus env:info "$SITE_ENV" --field=php_version)"
echo "PHP Version: $PHP_VERSION"

###
# Switch to git mode for pushing the files up
###
Expand Down
11 changes: 9 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,18 @@
"require-dev": {
"pantheon-systems/pantheon-wordpress-upstream-tests": "dev-master",
"pantheon-systems/pantheon-wp-coding-standards": "^2.0",
"pantheon-systems/wpunit-helpers": "^1.0",
"pantheon-systems/wpunit-helpers": "^2.0",
"phpunit/phpunit": "^9",
"yoast/phpunit-polyfills": "^2.0"
},
"scripts": {
"fix-perms": "chmod +x ./bin/*.sh",
"post-update-cmd": [
"@fix-perms"
],
"post-install-cmd": [
"@fix-perms"
],
"lint": [
"@phpcs",
"@phplint"
Expand All @@ -30,7 +37,7 @@
"phplint": "find . -type f -name '*.php' -not -path './vendor/*' -not -path './tests/*' -exec php -l {} \\;",
"phpunit": "vendor/bin/phpunit --do-not-cache-result",
"test": "@phpunit",
"test:install": "bin/install-local-tests.sh --no-db",
"test:install": "bin/install-local-tests.sh --skip-db=true",
"test:install:withdb": "bin/install-local-tests.sh"
},
"config": {
Expand Down
Loading

0 comments on commit 86cbb3d

Please sign in to comment.