Skip to content

Commit

Permalink
Merge pull request #2 from newfold-labs/add/secondary-module-inputs
Browse files Browse the repository at this point in the history
Add/secondary module inputs
  • Loading branch information
circlecube authored Mar 18, 2024
2 parents 08efbb8 + 2b11898 commit c464dd8
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 5 deletions.
26 changes: 22 additions & 4 deletions .github/workflows/module-plugin-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit c464dd8

Please sign in to comment.