From 286781175a134beb23c41e49174840dad03c2b2c Mon Sep 17 00:00:00 2001 From: Joost de Valk Date: Fri, 19 Dec 2025 08:44:44 +0100 Subject: [PATCH 1/6] Try it --- .github/workflows/playground-merged.yml | 2 +- .github/workflows/playground.yml | 21 +++++++++++++++++++-- .wordpress-org/blueprints/playground.json | 3 +-- README.md | 2 +- 4 files changed, 22 insertions(+), 6 deletions(-) diff --git a/.github/workflows/playground-merged.yml b/.github/workflows/playground-merged.yml index 0a129e50ac..5cb421ffcc 100644 --- a/.github/workflows/playground-merged.yml +++ b/.github/workflows/playground-merged.yml @@ -42,5 +42,5 @@ jobs: with: message: | **Test merged PR on Playground** - [Test this pull request on the Playground](https://playground.wordpress.net/#${{ steps.blueprint.outputs.blueprint }}) + [Test this pull request on the Playground](https://playground.progressplanner.com/#${{ steps.blueprint.outputs.blueprint }}) or [download the zip](${{ github.server_url }}/${{ github.repository }}/archive/refs/heads/develop.zip) diff --git a/.github/workflows/playground.yml b/.github/workflows/playground.yml index cdfc5863c9..d9846aabe1 100644 --- a/.github/workflows/playground.yml +++ b/.github/workflows/playground.yml @@ -78,16 +78,33 @@ jobs: run: | set -euxo pipefail ARTIFACT_URL="https://nightly.link/${{ github.repository }}/actions/runs/${{ github.run_id }}/${{ github.event.repository.name }}.zip" + PR_LABELS='${{ toJson(github.event.pull_request.labels) }}' # Use Node.js to parse, modify, and stringify the JSON BLUEPRINT=$(node -e " const fs = require('fs'); const blueprint = JSON.parse(fs.readFileSync('.wordpress-org/blueprints/playground.json', 'utf8')); + + // Replace the current plugin with artifact URL blueprint.plugins = blueprint.plugins.map(plugin => plugin === '${{ github.event.repository.name }}' ? '$ARTIFACT_URL' : plugin ); + + // Extract plugin slugs from PR labels that start with 'plugin:' + const prLabels = JSON.parse(process.env.PR_LABELS || '[]'); + const pluginSlugs = prLabels + .filter(label => label.name && label.name.startsWith('plugin:')) + .map(label => label.name.replace(/^plugin:/, '')); + + // Add plugin slugs to the plugins array (avoid duplicates) + pluginSlugs.forEach(slug => { + if (!blueprint.plugins.includes(slug)) { + blueprint.plugins.push(slug); + } + }); + console.log(JSON.stringify(blueprint)); - ") + " PR_LABELS="$PR_LABELS") # Base64 encode the blueprint ENCODED_BLUEPRINT=$(echo -n "$BLUEPRINT" | base64 -w 0) @@ -109,5 +126,5 @@ jobs: with: message: | **Test on Playground** - [Test this pull request on the Playground](https://playground.wordpress.net/#${{ steps.blueprint.outputs.blueprint }}) + [Test this pull request on the Playground](https://playground.progressplanner.com/#${{ steps.blueprint.outputs.blueprint }}) or [download the zip](https://nightly.link/${{ github.repository }}/actions/runs/${{ github.run_id }}/${{ github.event.repository.name }}.zip) diff --git a/.wordpress-org/blueprints/playground.json b/.wordpress-org/blueprints/playground.json index f1e183750a..e570e5a5df 100644 --- a/.wordpress-org/blueprints/playground.json +++ b/.wordpress-org/blueprints/playground.json @@ -4,8 +4,7 @@ "networking": true }, "plugins": [ - "progress-planner", - "wordpress-seo" + "progress-planner" ], "steps": [ { diff --git a/README.md b/README.md index 6b6e782e52..7830551567 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ [![WordPress Plugin Rating](https://img.shields.io/wordpress/plugin/stars/progress-planner.svg)](https://wordpress.org/support/plugin/progress-planner/reviews/) [![GitHub](https://img.shields.io/github/license/ProgressPlanner/progress-planner.svg)](https://github.com/ProgressPlanner/progress-planner/blob/main/LICENSE) -[![Try Progress Planner on the WordPress playground](https://img.shields.io/badge/Try%20Progress%20Planner%20on%20the%20WordPress%20Playground-%23117AC9.svg?style=for-the-badge&logo=WordPress&logoColor=ddd)](https://playground.wordpress.net/?blueprint-url=https%3A%2F%2Fprogressplanner.com%2Fresearch%2Fblueprint-pp.php%3Frepo%3DProgressPlanner/progress-planner) +[![Try Progress Planner on the WordPress playground](https://img.shields.io/badge/Try%20Progress%20Planner%20on%20the%20WordPress%20Playground-%23117AC9.svg?style=for-the-badge&logo=WordPress&logoColor=ddd)](https://playground.progressplanner.com/?blueprint-url=https%3A%2F%2Fprogressplanner.com%2Fresearch%2Fblueprint-pp.php%3Frepo%3DProgressPlanner/progress-planner) # Progress Planner From 5ea345eb41cb4bf87f79fd805415c616d6048be8 Mon Sep 17 00:00:00 2001 From: Joost de Valk Date: Fri, 19 Dec 2025 08:49:28 +0100 Subject: [PATCH 2/6] Re-run when a label is added --- .github/workflows/playground.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/playground.yml b/.github/workflows/playground.yml index d9846aabe1..c0f537c51d 100644 --- a/.github/workflows/playground.yml +++ b/.github/workflows/playground.yml @@ -2,6 +2,7 @@ name: Playground Comment on: pull_request: + types: [opened, synchronize, reopened, labeled, unlabeled] jobs: playground: From 9d65358ccf8355c30dba46d5ed50c1c5176cdb41 Mon Sep 17 00:00:00 2001 From: Joost de Valk Date: Fri, 19 Dec 2025 09:47:38 +0100 Subject: [PATCH 3/6] Switch to WP playground, add some debug --- .github/workflows/playground-merged.yml | 2 +- .github/workflows/playground.yml | 4 +++- README.md | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/playground-merged.yml b/.github/workflows/playground-merged.yml index 5cb421ffcc..0a129e50ac 100644 --- a/.github/workflows/playground-merged.yml +++ b/.github/workflows/playground-merged.yml @@ -42,5 +42,5 @@ jobs: with: message: | **Test merged PR on Playground** - [Test this pull request on the Playground](https://playground.progressplanner.com/#${{ steps.blueprint.outputs.blueprint }}) + [Test this pull request on the Playground](https://playground.wordpress.net/#${{ steps.blueprint.outputs.blueprint }}) or [download the zip](${{ github.server_url }}/${{ github.repository }}/archive/refs/heads/develop.zip) diff --git a/.github/workflows/playground.yml b/.github/workflows/playground.yml index c0f537c51d..87b344b803 100644 --- a/.github/workflows/playground.yml +++ b/.github/workflows/playground.yml @@ -99,6 +99,8 @@ jobs: // Add plugin slugs to the plugins array (avoid duplicates) pluginSlugs.forEach(slug => { + console.log('slug', slug); + console.log('blueprint.plugins', blueprint.plugins); if (!blueprint.plugins.includes(slug)) { blueprint.plugins.push(slug); } @@ -127,5 +129,5 @@ jobs: with: message: | **Test on Playground** - [Test this pull request on the Playground](https://playground.progressplanner.com/#${{ steps.blueprint.outputs.blueprint }}) + [Test this pull request on the Playground](https://playground.wordpress.net/#${{ steps.blueprint.outputs.blueprint }}) or [download the zip](https://nightly.link/${{ github.repository }}/actions/runs/${{ github.run_id }}/${{ github.event.repository.name }}.zip) diff --git a/README.md b/README.md index 7830551567..6b6e782e52 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ [![WordPress Plugin Rating](https://img.shields.io/wordpress/plugin/stars/progress-planner.svg)](https://wordpress.org/support/plugin/progress-planner/reviews/) [![GitHub](https://img.shields.io/github/license/ProgressPlanner/progress-planner.svg)](https://github.com/ProgressPlanner/progress-planner/blob/main/LICENSE) -[![Try Progress Planner on the WordPress playground](https://img.shields.io/badge/Try%20Progress%20Planner%20on%20the%20WordPress%20Playground-%23117AC9.svg?style=for-the-badge&logo=WordPress&logoColor=ddd)](https://playground.progressplanner.com/?blueprint-url=https%3A%2F%2Fprogressplanner.com%2Fresearch%2Fblueprint-pp.php%3Frepo%3DProgressPlanner/progress-planner) +[![Try Progress Planner on the WordPress playground](https://img.shields.io/badge/Try%20Progress%20Planner%20on%20the%20WordPress%20Playground-%23117AC9.svg?style=for-the-badge&logo=WordPress&logoColor=ddd)](https://playground.wordpress.net/?blueprint-url=https%3A%2F%2Fprogressplanner.com%2Fresearch%2Fblueprint-pp.php%3Frepo%3DProgressPlanner/progress-planner) # Progress Planner From fe89b5a6e8e85949b4c66d20c6f75d33d5b75680 Mon Sep 17 00:00:00 2001 From: Joost de Valk Date: Fri, 19 Dec 2025 09:51:14 +0100 Subject: [PATCH 4/6] github.event.pull_request.labels is only populated on labeled and unlabeled events. On opened, synchronize, or reopened, it may be empty or missing, work around that --- .github/workflows/playground.yml | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/.github/workflows/playground.yml b/.github/workflows/playground.yml index 87b344b803..ea78f38b2a 100644 --- a/.github/workflows/playground.yml +++ b/.github/workflows/playground.yml @@ -79,7 +79,12 @@ jobs: run: | set -euxo pipefail ARTIFACT_URL="https://nightly.link/${{ github.repository }}/actions/runs/${{ github.run_id }}/${{ github.event.repository.name }}.zip" - PR_LABELS='${{ toJson(github.event.pull_request.labels) }}' + + # Fetch PR labels from GitHub API + PR_LABELS_JSON=$(curl -s \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ + "https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.number }}/labels") # Use Node.js to parse, modify, and stringify the JSON BLUEPRINT=$(node -e " @@ -92,22 +97,30 @@ jobs: ); // Extract plugin slugs from PR labels that start with 'plugin:' - const prLabels = JSON.parse(process.env.PR_LABELS || '[]'); + const prLabelsJson = process.env.PR_LABELS_JSON || '[]'; + let prLabels = []; + try { + prLabels = JSON.parse(prLabelsJson); + } catch (e) { + console.error('Error parsing PR labels JSON:', e); + console.error('Raw JSON:', prLabelsJson); + } + console.log('PR Labels:', JSON.stringify(prLabels, null, 2)); + const pluginSlugs = prLabels .filter(label => label.name && label.name.startsWith('plugin:')) .map(label => label.name.replace(/^plugin:/, '')); + console.log('Plugin slugs:', JSON.stringify(pluginSlugs, null, 2)); // Add plugin slugs to the plugins array (avoid duplicates) pluginSlugs.forEach(slug => { - console.log('slug', slug); - console.log('blueprint.plugins', blueprint.plugins); if (!blueprint.plugins.includes(slug)) { blueprint.plugins.push(slug); } }); console.log(JSON.stringify(blueprint)); - " PR_LABELS="$PR_LABELS") + " PR_LABELS_JSON="$PR_LABELS_JSON") # Base64 encode the blueprint ENCODED_BLUEPRINT=$(echo -n "$BLUEPRINT" | base64 -w 0) From 435d428d8a346dfaf24e415246c165bd5a4437cc Mon Sep 17 00:00:00 2001 From: Joost de Valk Date: Fri, 19 Dec 2025 09:53:37 +0100 Subject: [PATCH 5/6] Switching to the GitHub CLI (gh) to fetch PR labels, which is simpler and more reliable --- .github/workflows/playground.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/playground.yml b/.github/workflows/playground.yml index ea78f38b2a..1de823a99f 100644 --- a/.github/workflows/playground.yml +++ b/.github/workflows/playground.yml @@ -76,15 +76,14 @@ jobs: - name: Prepare blueprint with artifact link id: blueprint + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | set -euxo pipefail ARTIFACT_URL="https://nightly.link/${{ github.repository }}/actions/runs/${{ github.run_id }}/${{ github.event.repository.name }}.zip" - # Fetch PR labels from GitHub API - PR_LABELS_JSON=$(curl -s \ - -H "Accept: application/vnd.github+json" \ - -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ - "https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.number }}/labels") + # Fetch PR labels using GitHub CLI + PR_LABELS_JSON=$(gh pr view ${{ github.event.number }} --json labels --jq '.labels' || echo '[]') # Use Node.js to parse, modify, and stringify the JSON BLUEPRINT=$(node -e " From e9f3c72c0cf524281830757c0b3332e8d0f5d74b Mon Sep 17 00:00:00 2001 From: Joost de Valk Date: Fri, 19 Dec 2025 09:56:11 +0100 Subject: [PATCH 6/6] Try another fix --- .github/workflows/playground.yml | 76 ++++++++++++++++++-------------- 1 file changed, 42 insertions(+), 34 deletions(-) diff --git a/.github/workflows/playground.yml b/.github/workflows/playground.yml index 1de823a99f..b5b893faac 100644 --- a/.github/workflows/playground.yml +++ b/.github/workflows/playground.yml @@ -84,42 +84,50 @@ jobs: # Fetch PR labels using GitHub CLI PR_LABELS_JSON=$(gh pr view ${{ github.event.number }} --json labels --jq '.labels' || echo '[]') + echo "Fetched PR labels: $PR_LABELS_JSON" + + # Write PR labels to temp file to avoid shell quoting issues + echo "$PR_LABELS_JSON" > /tmp/pr_labels.json + + # Write Node.js script to temp file + cat > /tmp/prepare_blueprint.js <<'SCRIPT_END' +const fs = require('fs'); +const blueprint = JSON.parse(fs.readFileSync('.wordpress-org/blueprints/playground.json', 'utf8')); + +// Replace the current plugin with artifact URL +blueprint.plugins = blueprint.plugins.map(plugin => + plugin === process.env.REPO_NAME ? process.env.ARTIFACT_URL : plugin +); + +// Read PR labels from temp file +let prLabels = []; +try { + const prLabelsJson = fs.readFileSync('/tmp/pr_labels.json', 'utf8').trim(); + console.log('Raw PR labels JSON:', prLabelsJson); + prLabels = JSON.parse(prLabelsJson); +} catch (e) { + console.error('Error parsing PR labels JSON:', e); + console.error('Error details:', e.message); +} +console.log('PR Labels:', JSON.stringify(prLabels, null, 2)); + +const pluginSlugs = prLabels + .filter(label => label.name && label.name.startsWith('plugin:')) + .map(label => label.name.replace(/^plugin:/, '')); +console.log('Plugin slugs:', JSON.stringify(pluginSlugs, null, 2)); + +// Add plugin slugs to the plugins array (avoid duplicates) +pluginSlugs.forEach(slug => { + if (!blueprint.plugins.includes(slug)) { + blueprint.plugins.push(slug); + } +}); + +console.log(JSON.stringify(blueprint)); +SCRIPT_END # Use Node.js to parse, modify, and stringify the JSON - BLUEPRINT=$(node -e " - const fs = require('fs'); - const blueprint = JSON.parse(fs.readFileSync('.wordpress-org/blueprints/playground.json', 'utf8')); - - // Replace the current plugin with artifact URL - blueprint.plugins = blueprint.plugins.map(plugin => - plugin === '${{ github.event.repository.name }}' ? '$ARTIFACT_URL' : plugin - ); - - // Extract plugin slugs from PR labels that start with 'plugin:' - const prLabelsJson = process.env.PR_LABELS_JSON || '[]'; - let prLabels = []; - try { - prLabels = JSON.parse(prLabelsJson); - } catch (e) { - console.error('Error parsing PR labels JSON:', e); - console.error('Raw JSON:', prLabelsJson); - } - console.log('PR Labels:', JSON.stringify(prLabels, null, 2)); - - const pluginSlugs = prLabels - .filter(label => label.name && label.name.startsWith('plugin:')) - .map(label => label.name.replace(/^plugin:/, '')); - console.log('Plugin slugs:', JSON.stringify(pluginSlugs, null, 2)); - - // Add plugin slugs to the plugins array (avoid duplicates) - pluginSlugs.forEach(slug => { - if (!blueprint.plugins.includes(slug)) { - blueprint.plugins.push(slug); - } - }); - - console.log(JSON.stringify(blueprint)); - " PR_LABELS_JSON="$PR_LABELS_JSON") + BLUEPRINT=$(REPO_NAME='${{ github.event.repository.name }}' ARTIFACT_URL="https://nightly.link/${{ github.repository }}/actions/runs/${{ github.run_id }}/${{ github.event.repository.name }}.zip" node /tmp/prepare_blueprint.js) # Base64 encode the blueprint ENCODED_BLUEPRINT=$(echo -n "$BLUEPRINT" | base64 -w 0)