From 531de3a9b3a0047a2858ca8fa32259c6dede496a Mon Sep 17 00:00:00 2001 From: Dale du Preez Date: Fri, 2 May 2025 20:18:13 +0200 Subject: [PATCH 01/12] Explore building plugin versions dynamically --- .github/actions/debug-action/action.yml | 23 ++++++++ .../get-wordpress-plugin-versions/action.yml | 54 +++++++++++++++++++ .github/workflows/test-matrix.yml | 38 +++++++++++++ 3 files changed, 115 insertions(+) create mode 100644 .github/actions/debug-action/action.yml create mode 100644 .github/actions/get-wordpress-plugin-versions/action.yml create mode 100644 .github/workflows/test-matrix.yml diff --git a/.github/actions/debug-action/action.yml b/.github/actions/debug-action/action.yml new file mode 100644 index 0000000000..98b27b8daa --- /dev/null +++ b/.github/actions/debug-action/action.yml @@ -0,0 +1,23 @@ +name: Debug action +description: Action to debug stuff + +inputs: + plugin-slug: + description: The WordPress plugin slug + type: string + required: true + version-count: + description: The number of released versions to return + type: number + default: '3' + +runs: + using: "composite" + steps: + - name: Debug details + id: debug-details + shell: bash + run: | + echo "plugin-slug: ${{ inputs.plugin-slug }}" + echo "version-count: ${{ inputs.version-count }}" + which curl \ No newline at end of file diff --git a/.github/actions/get-wordpress-plugin-versions/action.yml b/.github/actions/get-wordpress-plugin-versions/action.yml new file mode 100644 index 0000000000..104232858b --- /dev/null +++ b/.github/actions/get-wordpress-plugin-versions/action.yml @@ -0,0 +1,54 @@ +name: Get released versions for a WordPress plugin +description: Action to return the released versions for a WordPress plugin + +inputs: + plugin-slug: + description: The WordPress plugin slug + type: string + required: true + version-count: + description: The number of released versions to return + type: number + default: '3' +outputs: + versions-json: + description: The released versions for the plugin as a JSON array + value: ${{ steps.get-versions-json.outputs.versions-json }} + versions-text: + description: The released versions for the plugin as a newline-separated list + value: ${{ steps.get-versions-text.outputs.versions-text }} + +runs: + using: "composite" + steps: + - name: Debug details + id: debug-details + shell: bash + run: | + echo "plugin-slug: ${{ inputs.plugin-slug }}" + echo "version-count: ${{ inputs.version-count }}" + which curl + + - name: Get plugin info + id: get-plugin-info + shell: bash + run: | + curl -s 'https://api.wordpress.org/plugins/info/1.0/${{ inputs.plugin-slug }}.json' > '${{ inputs.plugin-slug }}.json + + - name: Get versions as JSON + id: get-versions-json + shell: bash + # jq does the following: + # - filters the versions to only include x.y.z versions, i.e. ignoring beta, rc, and dev versions etc + # - groups the versions by the first two parts of the version number, i.e. major.minor + # - reverses the order of the versions, so the highest major.minor versions are first + # - limits the number of major.versions to the number specified in the version-count input + # - returns the last version for each major.minor version + run: | + echo "versions-json=$(cat ${{ inputs.plugin-slug }}.json | jq '.versions | keys | map( select( test("^\\d+\\.\\d+\\.\\d+$"; "s") ) ) | group_by( split( "." ) | .[0:2] | join( "." ) ) | reverse | .[0:3] | [.[][-1]]' )" >> $GITHUB_OUTPUT + + - name: Get versions in text format + id: get-versions-text + shell: bash + run: | + echo "versions-text=$(echo ${{ steps.get-versions-json.outputs.versions-json }} | jq -r '.[]' )" >> $GITHUB_OUTPUT diff --git a/.github/workflows/test-matrix.yml b/.github/workflows/test-matrix.yml new file mode 100644 index 0000000000..adfded5b5f --- /dev/null +++ b/.github/workflows/test-matrix.yml @@ -0,0 +1,38 @@ +name: Test matrix computation for Woo versions + +on: + pull_request + +jobs: + debug-action: + runs-on: ubuntu-22.04 + steps: + - name: Debug action + uses: ./.github/actions/debug-action + with: + plugin-slug: 'woocommerce' + version-count: '3' + get-matrix: + runs-on: ubuntu-22.04 + outputs: + woocommerce-versions-json: ${{ steps.get-woo-versions.outputs.versions-json }} + steps: + - name: Get Woo plugin versions + id: get-woo-versions + uses: ./.github/actions/get-wordpress-plugin-versions + with: + plugin-slug: 'woocommerce' + - name: Debug Woo versions + run: | + echo "Woo versions (JSON): ${{ steps.get-woo-versions.outputs.versions-json }}" + echo "Woo versions (text): ${{ steps.get-woo-versions.outputs.versions-text }}" + debug-matrix: + needs: get-matrix + runs-on: ubuntu-22.04 + strategy: + matrix: + woocommerce-version: ${{ fromJson( needs.get-matrix.outputs.woocommerce-versions-json ) }} + steps: + - name: Debug matrix + run: | + echo "WooCommerce version: ${{ matrix.woocommerce-version }}" From efb0d0b6bc36c8087e0e789633fe71689cfab587 Mon Sep 17 00:00:00 2001 From: Dale du Preez Date: Fri, 2 May 2025 20:38:13 +0200 Subject: [PATCH 02/12] Get get-wordpress-plugin-versions action working --- .../actions/get-wordpress-plugin-versions/action.yml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/actions/get-wordpress-plugin-versions/action.yml b/.github/actions/get-wordpress-plugin-versions/action.yml index 104232858b..b84931fb74 100644 --- a/.github/actions/get-wordpress-plugin-versions/action.yml +++ b/.github/actions/get-wordpress-plugin-versions/action.yml @@ -33,7 +33,7 @@ runs: id: get-plugin-info shell: bash run: | - curl -s 'https://api.wordpress.org/plugins/info/1.0/${{ inputs.plugin-slug }}.json' > '${{ inputs.plugin-slug }}.json + curl -s 'https://api.wordpress.org/plugins/info/1.0/${{ inputs.plugin-slug }}.json' > '${{ inputs.plugin-slug }}.json' - name: Get versions as JSON id: get-versions-json @@ -45,10 +45,14 @@ runs: # - limits the number of major.versions to the number specified in the version-count input # - returns the last version for each major.minor version run: | - echo "versions-json=$(cat ${{ inputs.plugin-slug }}.json | jq '.versions | keys | map( select( test("^\\d+\\.\\d+\\.\\d+$"; "s") ) ) | group_by( split( "." ) | .[0:2] | join( "." ) ) | reverse | .[0:3] | [.[][-1]]' )" >> $GITHUB_OUTPUT + echo 'versions-json<> $GITHUB_OUTPUT + cat ${{ inputs.plugin-slug }}.json | jq '.versions | keys | map( select( test("^\\d+\\.\\d+\\.\\d+$"; "s") ) ) | group_by( split( "." ) | .[0:2] | join( "." ) ) | reverse | .[0:3] | [.[][-1]]' >> $GITHUB_OUTPUT + echo 'EOF' >> $GITHUB_OUTPUT - name: Get versions in text format id: get-versions-text shell: bash run: | - echo "versions-text=$(echo ${{ steps.get-versions-json.outputs.versions-json }} | jq -r '.[]' )" >> $GITHUB_OUTPUT + echo 'versions-text<> $GITHUB_OUTPUT + echo '${{ steps.get-versions-json.outputs.versions-json }}' | jq -r '.[]' >> $GITHUB_OUTPUT + echo 'EOF' >> $GITHUB_OUTPUT \ No newline at end of file From b17b83e56bc72da427d3edbf45cd3c152ae2f487 Mon Sep 17 00:00:00 2001 From: Dale du Preez Date: Fri, 2 May 2025 20:46:31 +0200 Subject: [PATCH 03/12] Wire version fetch into php-tests workflow --- .github/workflows/php-tests.yml | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/.github/workflows/php-tests.yml b/.github/workflows/php-tests.yml index 3a54232db7..05e20af116 100644 --- a/.github/workflows/php-tests.yml +++ b/.github/workflows/php-tests.yml @@ -4,8 +4,23 @@ on: pull_request jobs: + get-woocommerce-versions: + runs-on: ubuntu-22.04 + outputs: + woocommerce-versions-json: ${{ steps.get-released-woocommerce-versions.outputs.versions-json }} + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Get WooCommerce plugin versions + id: get-released-woocommerce-versions + uses: ./.github/actions/get-wordpress-plugin-versions + with: + plugin-slug: woocommerce + version-count: 3 test: runs-on: ubuntu-22.04 + needs: get-woocommerce-versions strategy: fail-fast: false max-parallel: 16 @@ -16,11 +31,11 @@ jobs: include: # WooCommerce - woocommerce_support_policy: L - woocommerce: '9.8.1' + woocommerce: ${{ fromJson(needs.get-woocommerce-versions.outputs.woocommerce-versions-json)[0] }} - woocommerce_support_policy: L-1 - woocommerce: '9.7.1' + woocommerce: ${{ fromJson(needs.get-woocommerce-versions.outputs.woocommerce-versions-json)[1] }} - woocommerce_support_policy: L-2 - woocommerce: '9.6.2' + woocommerce: ${{ fromJson(needs.get-woocommerce-versions.outputs.woocommerce-versions-json)[2] }} # WordPress - wordpress_support_policy: L wordpress: '6.7.2' From 465596eb7da6662edf596c4770f62c233aa1a9e6 Mon Sep 17 00:00:00 2001 From: Dale du Preez Date: Fri, 2 May 2025 20:49:38 +0200 Subject: [PATCH 04/12] Remove test-matrix workflow --- .github/workflows/test-matrix.yml | 38 ------------------------------- 1 file changed, 38 deletions(-) delete mode 100644 .github/workflows/test-matrix.yml diff --git a/.github/workflows/test-matrix.yml b/.github/workflows/test-matrix.yml deleted file mode 100644 index adfded5b5f..0000000000 --- a/.github/workflows/test-matrix.yml +++ /dev/null @@ -1,38 +0,0 @@ -name: Test matrix computation for Woo versions - -on: - pull_request - -jobs: - debug-action: - runs-on: ubuntu-22.04 - steps: - - name: Debug action - uses: ./.github/actions/debug-action - with: - plugin-slug: 'woocommerce' - version-count: '3' - get-matrix: - runs-on: ubuntu-22.04 - outputs: - woocommerce-versions-json: ${{ steps.get-woo-versions.outputs.versions-json }} - steps: - - name: Get Woo plugin versions - id: get-woo-versions - uses: ./.github/actions/get-wordpress-plugin-versions - with: - plugin-slug: 'woocommerce' - - name: Debug Woo versions - run: | - echo "Woo versions (JSON): ${{ steps.get-woo-versions.outputs.versions-json }}" - echo "Woo versions (text): ${{ steps.get-woo-versions.outputs.versions-text }}" - debug-matrix: - needs: get-matrix - runs-on: ubuntu-22.04 - strategy: - matrix: - woocommerce-version: ${{ fromJson( needs.get-matrix.outputs.woocommerce-versions-json ) }} - steps: - - name: Debug matrix - run: | - echo "WooCommerce version: ${{ matrix.woocommerce-version }}" From 05317205bb45056e591516b9b15d0d1ca69a3369 Mon Sep 17 00:00:00 2001 From: Dale du Preez Date: Fri, 2 May 2025 21:14:06 +0200 Subject: [PATCH 05/12] Clean up plugin versions --- .../actions/get-wordpress-plugin-versions/action.yml | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/.github/actions/get-wordpress-plugin-versions/action.yml b/.github/actions/get-wordpress-plugin-versions/action.yml index b84931fb74..e2a8049a84 100644 --- a/.github/actions/get-wordpress-plugin-versions/action.yml +++ b/.github/actions/get-wordpress-plugin-versions/action.yml @@ -21,14 +21,6 @@ outputs: runs: using: "composite" steps: - - name: Debug details - id: debug-details - shell: bash - run: | - echo "plugin-slug: ${{ inputs.plugin-slug }}" - echo "version-count: ${{ inputs.version-count }}" - which curl - - name: Get plugin info id: get-plugin-info shell: bash @@ -46,7 +38,7 @@ runs: # - returns the last version for each major.minor version run: | echo 'versions-json<> $GITHUB_OUTPUT - cat ${{ inputs.plugin-slug }}.json | jq '.versions | keys | map( select( test("^\\d+\\.\\d+\\.\\d+$"; "s") ) ) | group_by( split( "." ) | .[0:2] | join( "." ) ) | reverse | .[0:3] | [.[][-1]]' >> $GITHUB_OUTPUT + cat ${{ inputs.plugin-slug }}.json | jq '.versions | keys | map( select( test("^\\d+\\.\\d+\\.\\d+$"; "s") ) ) | group_by( split( "." ) | .[0:2] | join( "." ) ) | reverse | .[0:${{ inputs.version-count }}] | [.[][-1]]' >> $GITHUB_OUTPUT echo 'EOF' >> $GITHUB_OUTPUT - name: Get versions in text format @@ -55,4 +47,4 @@ runs: run: | echo 'versions-text<> $GITHUB_OUTPUT echo '${{ steps.get-versions-json.outputs.versions-json }}' | jq -r '.[]' >> $GITHUB_OUTPUT - echo 'EOF' >> $GITHUB_OUTPUT \ No newline at end of file + echo 'EOF' >> $GITHUB_OUTPUT From 184cb44b89b219e01bcc007a762edc50852582f4 Mon Sep 17 00:00:00 2001 From: Dale du Preez Date: Fri, 2 May 2025 21:19:38 +0200 Subject: [PATCH 06/12] Add WordPress version action; wire into php-tests --- .../get-wordpress-versions/action.yaml | 42 +++++++++++++++++++ .github/workflows/php-tests.yml | 24 ++++++++--- 2 files changed, 60 insertions(+), 6 deletions(-) create mode 100644 .github/actions/get-wordpress-versions/action.yaml diff --git a/.github/actions/get-wordpress-versions/action.yaml b/.github/actions/get-wordpress-versions/action.yaml new file mode 100644 index 0000000000..c0a6a1b28f --- /dev/null +++ b/.github/actions/get-wordpress-versions/action.yaml @@ -0,0 +1,42 @@ +name: Get released versions of WordPress +description: Action to return the released versions of WordPress + +inputs: + version-count: + description: The number of released versions to return + type: number + default: '3' + +outputs: + versions-json: + description: The released WordPress versions as a JSON array + value: ${{ steps.get-versions-json.outputs.versions-json }} + versions-text: + description: The released WordPress versions as a newline-separated list + value: ${{ steps.get-versions-text.outputs.versions-text }} + + +runs: + using: "composite" + steps: + - name: Get WordPress versions + id: get-wordpress-versions + shell: bash + run: | + curl -s 'https://api.wordpress.org/core/version-check/1.7/' | jq '[.offers.[].version] | unique | reverse' > wordpress-versions.json + + - name: Get WordPress versions as JSON + id: get-versions-json + shell: bash + run: | + echo 'versions-json<> $GITHUB_OUTPUT + cat wordpress-versions.json | jq 'group_by( split( "." ) | .[0:2] | join( "." ) ) | reverse | .[0:${{ inputs.version-count }}] | [.[][-1]]' >> $GITHUB_OUTPUT + echo 'EOF' >> $GITHUB_OUTPUT + + - name: Get WordPress versions in text format + id: get-versions-text + shell: bash + run: | + echo 'versions-text<> $GITHUB_OUTPUT + echo '${{ steps.get-versions-json.outputs.versions-json }}' | jq -r '.[]' >> $GITHUB_OUTPUT + echo 'EOF' >> $GITHUB_OUTPUT diff --git a/.github/workflows/php-tests.yml b/.github/workflows/php-tests.yml index 05e20af116..21c6a1b640 100644 --- a/.github/workflows/php-tests.yml +++ b/.github/workflows/php-tests.yml @@ -18,9 +18,23 @@ jobs: with: plugin-slug: woocommerce version-count: 3 + get-wordpress-versions: + runs-on: ubuntu-22.04 + outputs: + wordpress-versions-json: ${{ steps.get-wordpress-versions.outputs.versions-json }} + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Get WordPress versions + id: get-wordpress-versions + uses: ./.github/actions/get-wordpress-versions + with: + version-count: 3 + test: runs-on: ubuntu-22.04 - needs: get-woocommerce-versions + needs: [ get-woocommerce-versions, get-wordpress-versions ] strategy: fail-fast: false max-parallel: 16 @@ -38,13 +52,11 @@ jobs: woocommerce: ${{ fromJson(needs.get-woocommerce-versions.outputs.woocommerce-versions-json)[2] }} # WordPress - wordpress_support_policy: L - wordpress: '6.7.2' + wordpress: ${{ fromJson(needs.get-wordpress-versions.outputs.wordpress-versions-json)[0] }} - wordpress_support_policy: L-1 - wordpress: '6.6.2' - # WooCommerce 9.5.0+ requires WordPress 6.6+ - # (we'll keep two versions from the 6.6 branch until Apr when WP 6.8 is released) + wordpress: ${{ fromJson(needs.get-wordpress-versions.outputs.wordpress-versions-json)[1] }} - wordpress_support_policy: L-2 - wordpress: '6.6' + wordpress: ${{ fromJson(needs.get-wordpress-versions.outputs.wordpress-versions-json)[2] }} # PHP - php_support_policy: L php: '8.3' From ebbec7d049ae78c17a79454ff029f5d27dc6b33c Mon Sep 17 00:00:00 2001 From: Dale du Preez Date: Fri, 2 May 2025 22:35:13 +0200 Subject: [PATCH 07/12] Switch order for WordPress versions --- .github/actions/get-wordpress-versions/action.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/get-wordpress-versions/action.yaml b/.github/actions/get-wordpress-versions/action.yaml index c0a6a1b28f..d6ed978d12 100644 --- a/.github/actions/get-wordpress-versions/action.yaml +++ b/.github/actions/get-wordpress-versions/action.yaml @@ -30,7 +30,7 @@ runs: shell: bash run: | echo 'versions-json<> $GITHUB_OUTPUT - cat wordpress-versions.json | jq 'group_by( split( "." ) | .[0:2] | join( "." ) ) | reverse | .[0:${{ inputs.version-count }}] | [.[][-1]]' >> $GITHUB_OUTPUT + cat wordpress-versions.json | jq 'group_by( split( "." ) | .[0:2] | join( "." ) ) | reverse | .[0:${{ inputs.version-count }}] | [.[][0]]' >> $GITHUB_OUTPUT echo 'EOF' >> $GITHUB_OUTPUT - name: Get WordPress versions in text format From 17bda2c5ccecc9a2ce51e5b6d488ac92baeb4d33 Mon Sep 17 00:00:00 2001 From: Dale du Preez Date: Fri, 2 May 2025 22:35:13 +0200 Subject: [PATCH 08/12] Update jq filters to work with jq 1.6 --- .github/actions/get-wordpress-versions/action.yaml | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/.github/actions/get-wordpress-versions/action.yaml b/.github/actions/get-wordpress-versions/action.yaml index d6ed978d12..f0bbb012dc 100644 --- a/.github/actions/get-wordpress-versions/action.yaml +++ b/.github/actions/get-wordpress-versions/action.yaml @@ -20,17 +20,25 @@ runs: using: "composite" steps: - name: Get WordPress versions - id: get-wordpress-versions + id: get-all-wordpress-versions shell: bash run: | - curl -s 'https://api.wordpress.org/core/version-check/1.7/' | jq '[.offers.[].version] | unique | reverse' > wordpress-versions.json + curl -s 'https://api.wordpress.org/core/version-check/1.7/' > all-wordpress-versions.json - name: Get WordPress versions as JSON id: get-versions-json shell: bash + # The jq filtering does the following: + # - extracts the offers array + # - filters the offers to keep only the version field for each entry + # - removes duplicate versions + # - groups the versions by the first two parts of the version number, i.e. major.minor + # - reverses the order of the versions, so the highest major.minor versions are first + # - limits the number of major.minor versions to the number specified in the version-count input + # - returns the last version for each major.minor version run: | echo 'versions-json<> $GITHUB_OUTPUT - cat wordpress-versions.json | jq 'group_by( split( "." ) | .[0:2] | join( "." ) ) | reverse | .[0:${{ inputs.version-count }}] | [.[][0]]' >> $GITHUB_OUTPUT + cat all-wordpress-versions.json | jq '.offers | [.[].version] | unique | group_by( split( "." ) | .[0:2] | join( "." ) ) | reverse | .[0:${{ inputs.version-count }}] | [.[][0]]' >> $GITHUB_OUTPUT echo 'EOF' >> $GITHUB_OUTPUT - name: Get WordPress versions in text format From a748507235e9b1f02d3888e9a56bf2355de0a6ce Mon Sep 17 00:00:00 2001 From: Dale du Preez Date: Fri, 2 May 2025 23:10:37 +0200 Subject: [PATCH 09/12] Changelog --- changelog.txt | 1 + readme.txt | 1 + 2 files changed, 2 insertions(+) diff --git a/changelog.txt b/changelog.txt index 079f869176..b5c714372c 100644 --- a/changelog.txt +++ b/changelog.txt @@ -27,6 +27,7 @@ * Update - Add support for customer order notes and express checkout * Dev - Minor fix to e2e setup code * Dev - Make PHP error log from Docker container available in docker/logs/php/error.log +* Dev - Build dynamic WordPress and WooCommerce dependencies for unit tests = 9.4.1 - 2025-04-17 = * Dev - Forces rollback of version 9.4.0. diff --git a/readme.txt b/readme.txt index e77da14127..3e1b0ab676 100644 --- a/readme.txt +++ b/readme.txt @@ -137,5 +137,6 @@ If you get stuck, you can ask for help in the [Plugin Forum](https://wordpress.o * Update - Add support for customer order notes and express checkout * Dev - Minor fix to e2e setup code * Dev - Make PHP error log from Docker container available in docker/logs/php/error.log +* Dev - Build dynamic WordPress and WooCommerce dependencies for unit tests [See changelog for all versions](https://raw.githubusercontent.com/woocommerce/woocommerce-gateway-stripe/trunk/changelog.txt). From 32c9ec675485c2cfff9d4db5db05a82a814c81a5 Mon Sep 17 00:00:00 2001 From: Dale du Preez Date: Fri, 2 May 2025 23:22:23 +0200 Subject: [PATCH 10/12] Remove debugging action --- .github/actions/debug-action/action.yml | 23 ----------------------- 1 file changed, 23 deletions(-) delete mode 100644 .github/actions/debug-action/action.yml diff --git a/.github/actions/debug-action/action.yml b/.github/actions/debug-action/action.yml deleted file mode 100644 index 98b27b8daa..0000000000 --- a/.github/actions/debug-action/action.yml +++ /dev/null @@ -1,23 +0,0 @@ -name: Debug action -description: Action to debug stuff - -inputs: - plugin-slug: - description: The WordPress plugin slug - type: string - required: true - version-count: - description: The number of released versions to return - type: number - default: '3' - -runs: - using: "composite" - steps: - - name: Debug details - id: debug-details - shell: bash - run: | - echo "plugin-slug: ${{ inputs.plugin-slug }}" - echo "version-count: ${{ inputs.version-count }}" - which curl \ No newline at end of file From 04244a3f22ba57b9def3abf510cfb04706011648 Mon Sep 17 00:00:00 2001 From: Dale du Preez Date: Fri, 2 May 2025 23:36:41 +0200 Subject: [PATCH 11/12] Ensure we pick highest WordPress minor version --- .github/actions/get-wordpress-versions/action.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/get-wordpress-versions/action.yaml b/.github/actions/get-wordpress-versions/action.yaml index f0bbb012dc..fd34256161 100644 --- a/.github/actions/get-wordpress-versions/action.yaml +++ b/.github/actions/get-wordpress-versions/action.yaml @@ -38,7 +38,7 @@ runs: # - returns the last version for each major.minor version run: | echo 'versions-json<> $GITHUB_OUTPUT - cat all-wordpress-versions.json | jq '.offers | [.[].version] | unique | group_by( split( "." ) | .[0:2] | join( "." ) ) | reverse | .[0:${{ inputs.version-count }}] | [.[][0]]' >> $GITHUB_OUTPUT + cat all-wordpress-versions.json | jq '.offers | [.[].version] | unique | group_by( split( "." ) | .[0:2] | join( "." ) ) | reverse | .[0:${{ inputs.version-count }}] | [.[][-1]]' >> $GITHUB_OUTPUT echo 'EOF' >> $GITHUB_OUTPUT - name: Get WordPress versions in text format From 8c4615dbb1cc02aeea2e0fef03166f75f6a743b5 Mon Sep 17 00:00:00 2001 From: Dale du Preez Date: Mon, 5 May 2025 12:08:18 +0200 Subject: [PATCH 12/12] Try adding an hourly cache --- .../get-wordpress-versions/action.yaml | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/.github/actions/get-wordpress-versions/action.yaml b/.github/actions/get-wordpress-versions/action.yaml index fd34256161..c8c246ee2e 100644 --- a/.github/actions/get-wordpress-versions/action.yaml +++ b/.github/actions/get-wordpress-versions/action.yaml @@ -19,11 +19,27 @@ outputs: runs: using: "composite" steps: + - name: Build cache key + id: build-cache-key + shell: bash + run: | + echo "cache-timestamp=$( date -u "+%Y%m%d%H" )" >> $GITHUB_OUTPUT + + - name: Check WordPress version cache + id: check-wordpress-version-cache + uses: actions/cache@v4 + with: + key: wordpress-versions-${{ steps.build-cache-key.outputs.cache-timestamp }} + path: .wp-version-cache + enableCrossOsArchive: true + - name: Get WordPress versions - id: get-all-wordpress-versions + if: steps.check-wordpress-version-cache.outputs.cache-hit != 'true' + id: fetch-all-wordpress-versions shell: bash run: | - curl -s 'https://api.wordpress.org/core/version-check/1.7/' > all-wordpress-versions.json + mkdir .wp-version-cache + curl -s 'https://api.wordpress.org/core/version-check/1.7/' > .wp-version-cache/all-wordpress-versions.json - name: Get WordPress versions as JSON id: get-versions-json @@ -38,7 +54,7 @@ runs: # - returns the last version for each major.minor version run: | echo 'versions-json<> $GITHUB_OUTPUT - cat all-wordpress-versions.json | jq '.offers | [.[].version] | unique | group_by( split( "." ) | .[0:2] | join( "." ) ) | reverse | .[0:${{ inputs.version-count }}] | [.[][-1]]' >> $GITHUB_OUTPUT + cat .wp-version-cache/all-wordpress-versions.json | jq '.offers | [.[].version] | unique | group_by( split( "." ) | .[0:2] | join( "." ) ) | reverse | .[0:${{ inputs.version-count }}] | [.[][-1]]' >> $GITHUB_OUTPUT echo 'EOF' >> $GITHUB_OUTPUT - name: Get WordPress versions in text format