diff --git a/.github/workflows/module-plugin-test.yml b/.github/workflows/module-plugin-test.yml index 3d010b3..601c259 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 @@ -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 @@ -45,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 @@ -118,14 +128,22 @@ 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' }} 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.