From f9a94808dc2a7110c8a9b623d7681d2d103969c6 Mon Sep 17 00:00:00 2001 From: Evan Mullins Date: Mon, 29 Jan 2024 14:16:33 -0500 Subject: [PATCH 1/6] add inputs for secondary module repo and branch and steps --- .github/workflows/module-plugin-test.yml | 22 +++++++++++++++++++++- README.md | 14 +++++++++++++- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/.github/workflows/module-plugin-test.yml b/.github/workflows/module-plugin-test.yml index aaae6c8..50c8cff 100644 --- a/.github/workflows/module-plugin-test.yml +++ b/.github/workflows/module-plugin-test.yml @@ -26,6 +26,16 @@ on: description: The branch of the module to be tested type: string required: true + secondary-module-repo: + description: An optional secondary module repo + type: string + required: false + default: '' + secondary-module-branch: + description: The branch of the secondary module to be tested + type: string + required: false + default: '' sync-npm-package: description: Flag to sync module files to equivalent node module type: boolean @@ -83,7 +93,7 @@ jobs: repository: ${{ inputs.plugin-repo }} ref: ${{ inputs.plugin-branch }} - - name: Use Node.js 16.x + - name: Setup Node uses: actions/setup-node@v4 with: node-version: ${{ inputs.node-version }} @@ -126,6 +136,16 @@ jobs: working-directory: vendor/${{ inputs.module-repo }} run: git checkout --track origin/${{ inputs.module-branch }} + - name: Get Secondary Module Source + if: ${{ inputs.secondary-module-repo != '' }} + run: | + composer reinstall ${{ inputs.secondary-module-repo }} --prefer-source + + - name: Checkout Secondary Module Branch + if: ${{ inputs.secondary-module-branch != '' && inputs.secondary-module-repo != '' }} + working-directory: vendor/${{ inputs.secondary-module-repo }} + run: git checkout --track origin/${{ inputs.secondary-module-branch }} + - name: Validate composer.json and composer.lock working-directory: vendor/${{ inputs.module-repo }} run: composer validate diff --git a/README.md b/README.md index 02d079c..e1bd0a3 100644 --- a/README.md +++ b/README.md @@ -107,9 +107,21 @@ The `sync-npm-package` input, defaulting to `false`, is useful when the module a Refer to the [ecommerce module workflow PR](https://github.com/newfold-labs/wp-module-ecommerce/pull/192) for an example including this flag, as the module is also an installed npm package. +#### secondary-module +If the module work depends on updates in another module we can use the optional secondary module inputs to specify the additional module and branch to set up before performing tests. Set the `secondary-module-repo` value as `newfold-labs/wp-module-x` and the `secondary-module-branch` as `update/x`, for example, to also load in module x and branch update/x before building the plugin and performing the tests. +``` + bluehost: + name: Bluehost Build and Test + needs: setup + uses: newfold-labs/workflows/.github/workflows/module-plugin-test.yml@main + with: + plugin-repo: 'bluehost/bluehost-wordpress-plugin' + plugin-branch: 'develop' + secondary-module-repo: 'newfold-labs/wp-module-coming-soon' + secondary-module-branch: 'update/options' +``` ### Ideas for Improvement: -- Add an input to specify a secondary module repo and branch name to pull those changes in as well for integrated testing when corresponding changes are required in another module. (It should be enough to allow for one extra module change for now, if more are needed we can think through a json object or something.) - Add a flag to signify tests should run in Cypress cloud for easier debugging (devise a way to pass the plugin level key). - Add a flag to run for the full matrix of WP versions. - Add a flag to run for the full matrix of PHP versions. From 175af688febf04411f664a1544127beb6e818813 Mon Sep 17 00:00:00 2001 From: Evan Mullins Date: Mon, 29 Jan 2024 14:21:58 -0500 Subject: [PATCH 2/6] add main branch check - even though unlikely --- .github/workflows/module-plugin-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/module-plugin-test.yml b/.github/workflows/module-plugin-test.yml index 50c8cff..7bc46c5 100644 --- a/.github/workflows/module-plugin-test.yml +++ b/.github/workflows/module-plugin-test.yml @@ -142,7 +142,7 @@ jobs: composer reinstall ${{ inputs.secondary-module-repo }} --prefer-source - name: Checkout Secondary Module Branch - if: ${{ inputs.secondary-module-branch != '' && inputs.secondary-module-repo != '' }} + if: ${{ (inputs.secondary-module-branch != '') && (inputs.secondary-module-repo != '') && (inputs.secondary-module-repo != 'main') }} working-directory: vendor/${{ inputs.secondary-module-repo }} run: git checkout --track origin/${{ inputs.secondary-module-branch }} From 22295da8d32e4bd384a37805893c8b8999427d8e Mon Sep 17 00:00:00 2001 From: Evan Mullins Date: Mon, 29 Jan 2024 14:46:22 -0500 Subject: [PATCH 3/6] remove main check it may be helpful to test a module at main rather than at the currently tagged version will rely on smart inputs to avoid failures --- .github/workflows/module-plugin-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/module-plugin-test.yml b/.github/workflows/module-plugin-test.yml index 7bc46c5..7fee450 100644 --- a/.github/workflows/module-plugin-test.yml +++ b/.github/workflows/module-plugin-test.yml @@ -142,7 +142,7 @@ jobs: composer reinstall ${{ inputs.secondary-module-repo }} --prefer-source - name: Checkout Secondary Module Branch - if: ${{ (inputs.secondary-module-branch != '') && (inputs.secondary-module-repo != '') && (inputs.secondary-module-repo != 'main') }} + if: ${{ (inputs.secondary-module-branch != '') && (inputs.secondary-module-repo != '') }} working-directory: vendor/${{ inputs.secondary-module-repo }} run: git checkout --track origin/${{ inputs.secondary-module-branch }} From 7b14e61cf0737fa256924210cdda7ac0c2caab14 Mon Sep 17 00:00:00 2001 From: Evan Mullins Date: Mon, 29 Jan 2024 14:55:40 -0500 Subject: [PATCH 4/6] try fetch tags so we can reference them as a brach to checkout --- .github/workflows/module-plugin-test.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/module-plugin-test.yml b/.github/workflows/module-plugin-test.yml index 7fee450..33d92b2 100644 --- a/.github/workflows/module-plugin-test.yml +++ b/.github/workflows/module-plugin-test.yml @@ -144,7 +144,9 @@ jobs: - name: Checkout Secondary Module Branch if: ${{ (inputs.secondary-module-branch != '') && (inputs.secondary-module-repo != '') }} working-directory: vendor/${{ inputs.secondary-module-repo }} - run: git checkout --track origin/${{ inputs.secondary-module-branch }} + run: | + git fetch --all --tags --prune + git checkout --track origin/${{ inputs.secondary-module-branch }} - name: Validate composer.json and composer.lock working-directory: vendor/${{ inputs.module-repo }} From c7e5eccff0f78e6086e9929a7cd2196b50f89852 Mon Sep 17 00:00:00 2001 From: Evan Mullins Date: Mon, 29 Jan 2024 15:02:51 -0500 Subject: [PATCH 5/6] remove tags fetch --- .github/workflows/module-plugin-test.yml | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/.github/workflows/module-plugin-test.yml b/.github/workflows/module-plugin-test.yml index 33d92b2..f0c0069 100644 --- a/.github/workflows/module-plugin-test.yml +++ b/.github/workflows/module-plugin-test.yml @@ -128,8 +128,7 @@ jobs: run: npm ci --legacy-peer-deps - name: Get Module Source - run: | - composer reinstall ${{ inputs.module-repo }} --prefer-source + run: composer reinstall ${{ inputs.module-repo }} --prefer-source - name: Checkout Module Branch if: ${{ inputs.module-branch != 'main' }} @@ -138,15 +137,12 @@ jobs: - name: Get Secondary Module Source if: ${{ inputs.secondary-module-repo != '' }} - run: | - composer reinstall ${{ inputs.secondary-module-repo }} --prefer-source + run: composer reinstall ${{ inputs.secondary-module-repo }} --prefer-source - name: Checkout Secondary Module Branch if: ${{ (inputs.secondary-module-branch != '') && (inputs.secondary-module-repo != '') }} working-directory: vendor/${{ inputs.secondary-module-repo }} - run: | - git fetch --all --tags --prune - git checkout --track origin/${{ inputs.secondary-module-branch }} + run: git checkout --track origin/${{ inputs.secondary-module-branch }} - name: Validate composer.json and composer.lock working-directory: vendor/${{ inputs.module-repo }} From d347897d78cfab4bc3bb33dfe0019e58efec4538 Mon Sep 17 00:00:00 2001 From: Evan Mullins Date: Mon, 29 Jan 2024 15:19:10 -0500 Subject: [PATCH 6/6] update default node version too --- .github/workflows/module-plugin-test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/module-plugin-test.yml b/.github/workflows/module-plugin-test.yml index f0c0069..847f44a 100644 --- a/.github/workflows/module-plugin-test.yml +++ b/.github/workflows/module-plugin-test.yml @@ -9,7 +9,7 @@ on: node-version: description: The version of node to be used type: string - default: '16.x' + default: '20.x' plugin-repo: description: The plugin repo type: string @@ -55,7 +55,7 @@ on: node-version: description: The version of node to be used type: string - default: '16.x' + default: '20.x' plugin-repo: description: The plugin repo type: string