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 linting GitHub Action workflows #20

Merged
merged 7 commits into from
Oct 18, 2023
Merged

Add linting GitHub Action workflows #20

merged 7 commits into from
Oct 18, 2023

Conversation

dkotter
Copy link
Collaborator

@dkotter dkotter commented Oct 17, 2023

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:

  • Runs anytime a PR is opened against develop or code is pushed to develop or trunk
  • Only runs if PHP files have been changed
  • Sets up PHP version 7.4 (our minimum), runs composer install and then lints any changed lines within the changed PHP files

The eslint Action does the following:

  • Runs anytime a PR is opened against develop or code is pushed to develop or trunk
  • Only runs if JS files have been changed
  • Sets up Node to match what's in our .nvmrc (v18 right now), runs an npm install and then uses 10up-tookit to lint any changed JS files

Most of our plugins don't use 10up-toolkit, they use wp-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

Added - GitHub Action workflows to lint our PHP and JS files.

Credits

Props @dkotter

Checklist:

  • I agree to follow this project's Code of Conduct.
  • I have updated the documentation accordingly.
  • I have added tests to cover my change.
  • All new and existing tests pass.

@dkotter dkotter self-assigned this Oct 17, 2023
@dkotter dkotter added this to the 1.5.1 milestone Oct 17, 2023
@dkotter dkotter marked this pull request as ready for review October 17, 2023 22:41
@dkotter dkotter requested review from jeffpaul, dsawardekar and a team as code owners October 17, 2023 22:41
Copy link
Member

@jeffpaul jeffpaul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, thanks!

@dkotter dkotter merged commit 8014241 into develop Oct 18, 2023
3 checks passed
@dkotter dkotter deleted the fix/13 branch October 18, 2023 16:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add/GitHub action - Linting (PHP & JS)
2 participants