Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add/secondary module inputs #2

Merged
merged 7 commits into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 23 additions & 5 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 @@ -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 }}
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