From b029f91bdad2db9a6010313d47e013e045f9b18b Mon Sep 17 00:00:00 2001 From: Chris Reynolds Date: Fri, 24 May 2024 11:17:01 -0600 Subject: [PATCH 1/3] Add NPM Diff action (#275) * use NPM Lockfile Changes * make sure the workflow also runs when package-lock files are updated * rename the workflow file since it's not just composer anymore * allow fuzzy matching because excluded subdirectory files should not trigger behat tests --- .../{composer-diff.yml => composer-npm-diff.yml} | 16 +++++++++++++++- bin/maybe-skip-tests.sh | 2 +- 2 files changed, 16 insertions(+), 2 deletions(-) rename .github/workflows/{composer-diff.yml => composer-npm-diff.yml} (63%) diff --git a/.github/workflows/composer-diff.yml b/.github/workflows/composer-npm-diff.yml similarity index 63% rename from .github/workflows/composer-diff.yml rename to .github/workflows/composer-npm-diff.yml index 243a92c9..c43fe8f7 100644 --- a/.github/workflows/composer-diff.yml +++ b/.github/workflows/composer-npm-diff.yml @@ -1,8 +1,9 @@ -name: Composer Diff +name: Composer and NPM Package Diff on: pull_request: paths: - 'composer.lock' + - 'package-lock.json' permissions: contents: write pull-requests: write @@ -26,3 +27,16 @@ jobs: Composer Changes ${{ steps.composer_diff.outputs.composer_diff }} + npm-diff: + name: NPM Lockfile Diff + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: NPM Lockfile Changes + uses: codepunkt/npm-lockfile-changes@main + with: + token: ${{ github.token }} + updateComment: true diff --git a/bin/maybe-skip-tests.sh b/bin/maybe-skip-tests.sh index c49d309e..60934e89 100755 --- a/bin/maybe-skip-tests.sh +++ b/bin/maybe-skip-tests.sh @@ -30,7 +30,7 @@ should_run_tests=true is_ignored_file(){ for ignore in "${ignored_paths[@]}"; do - if [[ "${1:-}" == "$ignore" ]]; then + if [[ "${1:-}" == *"$ignore"* ]]; then return 0 fi done From 313919fc65e29b0b2b7570652ad6a203d9376ff7 Mon Sep 17 00:00:00 2001 From: Chris Reynolds Date: Fri, 24 May 2024 12:00:28 -0600 Subject: [PATCH 2/3] Build unminified css (#276) * add gulp-rename for renaming the minified css file * update the build workflow to create two css files * explicitly enqueue the minified css file * define the path * full path to workspace? * add an npm install step to generate the lockfile might be ignored by .gitattributes * re-add path * don't fail if the test fails * temporarily don't ignore package-lock.json files * remove path * run workflow when the workflow itself is changed so we can see the effects of our changes * pass path * remove unnecessary params the defaults cover these * comment out the npm package diff and add description why * don't run on package-lock updates --- .gitattributes | 2 +- .github/workflows/composer-npm-diff.yml | 32 ++++++++++++++----------- gulpfile.mjs | 5 +++- inc/admin-interface.php | 4 +++- package-lock.json | 10 ++++++++ package.json | 1 + 6 files changed, 37 insertions(+), 17 deletions(-) diff --git a/.gitattributes b/.gitattributes index 01832158..7be32ee0 100644 --- a/.gitattributes +++ b/.gitattributes @@ -20,7 +20,7 @@ /composer.lock export-ignore /CONTRIBUTING.md export-ignore /gulpfile.mjs export-ignore -/package-lock.json export-ignore +#/package-lock.json export-ignore /package.json export-ignore /phpcs.xml.dist export-ignore /phpunit.xml.dist export-ignore diff --git a/.github/workflows/composer-npm-diff.yml b/.github/workflows/composer-npm-diff.yml index c43fe8f7..b5ca48fa 100644 --- a/.github/workflows/composer-npm-diff.yml +++ b/.github/workflows/composer-npm-diff.yml @@ -3,7 +3,7 @@ on: pull_request: paths: - 'composer.lock' - - 'package-lock.json' + # - 'package-lock.json' permissions: contents: write pull-requests: write @@ -27,16 +27,20 @@ jobs: Composer Changes ${{ steps.composer_diff.outputs.composer_diff }} - npm-diff: - name: NPM Lockfile Diff - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: NPM Lockfile Changes - uses: codepunkt/npm-lockfile-changes@main - with: - token: ${{ github.token }} - updateComment: true + # Removing because the workflow fails for some unknown reason, see https://github.com/pantheon-systems/pantheon-advanced-page-cache/actions/runs/9228002744/job/25391128483 + # There's no support for this action, so we might need to build something new. + # npm-diff: + # name: NPM Lockfile Diff + # runs-on: ubuntu-latest + # continue-on-error: true + # steps: + # - name: Checkout + # uses: actions/checkout@v4 + # with: + # fetch-depth: 0 + # - name: Compile NPM packages + # run: npm ci + # - name: NPM Lockfile Changes + # uses: codepunkt/npm-lockfile-changes@main + # with: + # token: ${{ github.token }} diff --git a/gulpfile.mjs b/gulpfile.mjs index a1775b97..e1fe4ec1 100644 --- a/gulpfile.mjs +++ b/gulpfile.mjs @@ -3,14 +3,17 @@ import gulp from 'gulp'; import csso from 'gulp-csso'; import * as sassCompiler from 'sass'; import gulpSass from 'gulp-sass'; +import rename from 'gulp-rename' const sass = gulpSass(sassCompiler); gulp.task('styles', () => { return gulp.src('assets/sass/styles.scss') // Only compile the main file .pipe(sass().on('error', sass.logError)) // Compile SASS to CSS + .pipe(gulp.dest('assets/css')) // Save unminified CSS .pipe(csso()) // Minify CSS - .pipe(gulp.dest('assets/css')); // Save the CSS file + .pipe(rename({suffix: '.min'})) // Rename to styles.min.css + .pipe(gulp.dest('assets/css')); // Save the minified CSS file }); gulp.task('clean', () => { diff --git a/inc/admin-interface.php b/inc/admin-interface.php index 580cdac8..a95e10fe 100644 --- a/inc/admin-interface.php +++ b/inc/admin-interface.php @@ -59,7 +59,9 @@ function enqueue_admin_assets() { // If WP_DEBUG is true, append a timestamp to the end of the path so we get a fresh copy of the css. $debug = defined( 'WP_DEBUG' ) && WP_DEBUG ? '-' . time() : ''; - wp_enqueue_style( 'papc-admin', plugin_dir_url( __DIR__ ) . 'assets/css/styles.css', [], '2.0.0' . $debug ); + // Use minified css unless SCRIPT_DEBUG is true. + $min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; + wp_enqueue_style( 'papc-admin', plugin_dir_url( __DIR__ ) . "assets/css/styles$min.css", [], '2.0.0' . $debug ); } /** diff --git a/package-lock.json b/package-lock.json index b23a51c2..401fb61c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,6 +14,7 @@ "gulp-autoprefixer": "^9.0.0", "gulp-concat": "^2.6.1", "gulp-csso": "^4.0.1", + "gulp-rename": "^2.0.0", "gulp-sass": "^5.1.0", "node-sass": "^9.0.0", "sass": "^1.77.1" @@ -1885,6 +1886,15 @@ "url": "https://github.com/chalk/chalk?sponsor=1" } }, + "node_modules/gulp-rename": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/gulp-rename/-/gulp-rename-2.0.0.tgz", + "integrity": "sha512-97Vba4KBzbYmR5VBs9mWmK+HwIf5mj+/zioxfZhOKeXtx5ZjBk57KFlePf5nxq9QsTtFl0ejnHE3zTC9MHXqyQ==", + "dev": true, + "engines": { + "node": ">=4" + } + }, "node_modules/gulp-sass": { "version": "5.1.0", "resolved": "https://registry.npmjs.org/gulp-sass/-/gulp-sass-5.1.0.tgz", diff --git a/package.json b/package.json index abd411ef..8afd0180 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,7 @@ "gulp-autoprefixer": "^9.0.0", "gulp-concat": "^2.6.1", "gulp-csso": "^4.0.1", + "gulp-rename": "^2.0.0", "gulp-sass": "^5.1.0", "node-sass": "^9.0.0", "sass": "^1.77.1" From e0abcd576c84e474b0fac2ea8d60ae3e83dd572e Mon Sep 17 00:00:00 2001 From: Pantheon Automation Date: Fri, 24 May 2024 18:00:41 +0000 Subject: [PATCH 3/3] Release 2.0.0 --- package-lock.json | 4 ++-- package.json | 2 +- pantheon-advanced-page-cache.php | 4 ++-- readme.txt | 6 +++--- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index 401fb61c..09555df1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "pantheon-advanced-page-cache", - "version": "2.0.0-dev", + "version": "2.0.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "pantheon-advanced-page-cache", - "version": "2.0.0-dev", + "version": "2.0.0", "license": "GPL-2.0-only", "devDependencies": { "del": "^7.1.0", diff --git a/package.json b/package.json index 8afd0180..2d7a58fe 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pantheon-advanced-page-cache", - "version": "2.0.0-dev", + "version": "2.0.0", "author": "Pantheon", "license": "GPL-2.0-only", "homepage": "https://github.com/pantheon-systems/pantheon-advanced-page-cache", diff --git a/pantheon-advanced-page-cache.php b/pantheon-advanced-page-cache.php index e5537698..06b130ff 100644 --- a/pantheon-advanced-page-cache.php +++ b/pantheon-advanced-page-cache.php @@ -7,7 +7,7 @@ * Author URI: https://pantheon.io * Text Domain: pantheon-advanced-page-cache * Domain Path: /languages - * Version: 2.0.0-dev + * Version: 2.0.0 * Requires at least: 6.4 * Tested up to: 6.5.3 * @@ -107,7 +107,7 @@ function pantheon_wp_prefix_surrogate_keys_with_blog_id( $keys ) { * * Expects that a bootstrap() function exists in the namespaced file. * - * @since 2.0.0-dev + * @since 2.0.0 * @return void */ function pantheon_bootstrap_namespaces() { diff --git a/readme.txt b/readme.txt index b5068f0d..568bb9ef 100644 --- a/readme.txt +++ b/readme.txt @@ -3,7 +3,7 @@ Contributors: getpantheon, danielbachhuber, kporras07, jspellman, jazzs3quence, Tags: pantheon, cdn, cache Requires at least: 6.4 Tested up to: 6.5.3 -Stable tag: 2.0.0-dev +Stable tag: 2.0.0 License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html @@ -360,7 +360,7 @@ Pantheon Advanced Page Cache integrates with WordPress plugins, including: See [CONTRIBUTING.md](https://github.com/pantheon-systems/wp-saml-auth/blob/master/CONTRIBUTING.md) for information on contributing. == Changelog == -= 2.0.0-dev = += 2.0.0 (24 May 2024) = * Adds new admin alerts and Site Health tests about default cache max age settings and recommendations [[#268](https://github.com/pantheon-systems/pantheon-advanced-page-cache/pull/268), [#271](https://github.com/pantheon-systems/pantheon-advanced-page-cache/pull/271)]. The default Pantheon GCDN cache max age value has been updated to 1 week in the [Pantheon MU plugin](https://github.com/pantheon-systems/pantheon-mu-plugin). For more information, see the [release note](https://docs.pantheon.io/release-notes/2024/04/pantheon-mu-plugin-1-4-0-update). * Updated UI in Pantheon Page Cache admin page when used in a Pantheon environment (with the Pantheon MU plugin). [[#272](https://github.com/pantheon-systems/pantheon-advanced-page-cache/pull/272)] * Automatically updates the cache max age to the recommended value (1 week) if it was saved at the old default value (600 seconds). [[#269](https://github.com/pantheon-systems/pantheon-advanced-page-cache/pull/269)] @@ -442,7 +442,7 @@ See [CONTRIBUTING.md](https://github.com/pantheon-systems/wp-saml-auth/blob/mast * Initial release. == Upgrade Notice == -= 2.0.0-dev = += 2.0.0 (24 May 2024) = This release requires a minimum WordPress version of 6.4.0. It uses Site Health checks and the `wp_admin_notices` function to alert users to the new cache max-age default settings and recommendations. The plugin will still function with earlier versions, but you will not get the benefit of the alerts and Site Health checks. This version also automatically updates the cache max age (set in the [Pantheon Page Cache settings](https://docs.pantheon.io/guides/wordpress-configurations/wordpress-cache-plugin)) to the recommended value (1 week) if it was saved at the old default value (600 seconds). If the cache max age was set to any other value (or not set at all), it will not be changed. A one-time notice will be displayed in the admin interface to inform administrators of this change.