Add linting GitHub Action workflows #20
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of the Change
Adds our (semi) standard GitHub Action linting workflows.
Historically we've had a single
lint.yml
workflow that has jobs for eslint and PHPCS. I've broken those into two different workflow files here so we can utilize GitHub Actions path filtering to only run those actions when either JS or PHP files have been changed respectively.We've talked about wanting to make these sorts of changes across all of our plugins (being smarter on when Actions run) so figured it was worth putting that effort in here and we can copy this approach across to other plugins as we see fit.
The PHPCS Action does the following:
develop
or code is pushed todevelop
ortrunk
composer install
and then lints any changed lines within the changed PHP filesThe eslint Action does the following:
develop
or code is pushed todevelop
ortrunk
.nvmrc
(v18 right now), runs annpm install
and then uses10up-tookit
to lint any changed JS filesMost of our plugins don't use
10up-toolkit
, they usewp-scripts
, so some slight adjustments on the eslint workflow will be needed if we copy these changes across.Closes #13
How to test the Change
Can see a commit with no PHP or JS changes here: https://github.com/10up/block-catalog/pull/20/checks?sha=9cb38084248909fa40b2ac5f7768b5f618eddf38
Can see a commit with a failing PHPCS check here: https://github.com/10up/block-catalog/pull/20/checks?sha=6ca435ccd683854226cf81f3fef620eaf174671b
Can see a commit with a failing eslint check here: https://github.com/10up/block-catalog/pull/20/checks?sha=4bce3a60ea78d14eb3dc3aef8371b4931aadd06b
And a commit with all checks passing: https://github.com/10up/block-catalog/pull/20/checks?sha=e62f072523b3bcd831a90fa0daa925919ed0d81e
Changelog Entry
Credits
Props @dkotter
Checklist: