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

Added paths filter to GitHub actions #204

Merged
merged 14 commits into from
Dec 8, 2022
Merged

Added paths filter to GitHub actions #204

merged 14 commits into from
Dec 8, 2022

Conversation

iamdharmesh
Copy link
Member

@iamdharmesh iamdharmesh commented Nov 30, 2022

Description of the Change

This PR adds a paths filter in GitHub action workflows to run it only on specific file extensions. For example, This PR doesn't contain any PHP, JS, or CSS file changes. So, the related workflows(E2E tests, PHPUnit, PHPCS, PHP Compatibility, and ESLint) will not be run against this PR.

Closes #203

How to test the Change

See GitHub Actions check on this PR, E2E tests, PHPUnit, PHPCS, PHP Compatibility, and ESLint check should not run on this PR as we made changes in workflow files only.

Changelog Entry

Changed - Made GitHub Action workflow run only when required.

Credits

Props @iamdharmesh

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.

@iamdharmesh iamdharmesh marked this pull request as ready for review November 30, 2022 11:39
@github-actions github-actions bot added the needs:code-review This requires code review. label Nov 30, 2022
@iamdharmesh iamdharmesh added this to the 1.3.0 milestone Nov 30, 2022
@iamdharmesh iamdharmesh requested review from a team and peterwilsoncc and removed request for a team November 30, 2022 11:39
peterwilsoncc
peterwilsoncc previously approved these changes Dec 1, 2022
Copy link
Contributor

@peterwilsoncc peterwilsoncc left a comment

Choose a reason for hiding this comment

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

Fake approval to see what happens.

@peterwilsoncc peterwilsoncc dismissed their stale review December 1, 2022 02:40

Testing things and stuff

peterwilsoncc
peterwilsoncc previously approved these changes Dec 1, 2022
Copy link
Contributor

@peterwilsoncc peterwilsoncc left a comment

Choose a reason for hiding this comment

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

Another fake approval to test things now that develop has been merged in.

@peterwilsoncc peterwilsoncc dismissed their stale review December 1, 2022 02:42

Finished testing various things.

Copy link
Contributor

@peterwilsoncc peterwilsoncc left a comment

Choose a reason for hiding this comment

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

Sorry for the review spam while I was testing the effects of this PR.

In its current state, it prevents merging of approved PRs as the required actions have not completed.

I think what you'll want to do is something like this (pseudo code)

step:
  Name: Succeed early if files are not modified
  run: |
    if ( no_relevant_file_modified() ) {
      finish_action_with_success();
    }

I'm not sure if that is possible though, it's something you'll need to check in the docs.

Screen Shot 2022-12-01 at 1 41 46 pm

@iamdharmesh
Copy link
Member Author

iamdharmesh commented Dec 1, 2022

@peterwilsoncc we can handle this by adding a generic workflow that ignores the path we added to the actual workflow So, it will run instead of the actual workflow and we can satisfy the required condition. More info can be found here

I have created and added that workflow for PHPCS(c4d298d) and it works as expected. what do you think about this approach? If you think adding an additional dummy workflow for each required workflow is additional overhead then we might add path filters only on heavy workflows like E2E tests OR maybe adjust required workflow settings.

Thanks
cc: @dkotter

@peterwilsoncc
Copy link
Contributor

Thank @iamdharmesh -- that looks like a really nice approach.

It does require repeating the paths in two files, so would need comments to alert people to change them in both locations. You could use a constant but I think that for two instances that would be over-engineering.

peterwilsoncc
peterwilsoncc previously approved these changes Dec 4, 2022
Copy link
Contributor

@peterwilsoncc peterwilsoncc left a comment

Choose a reason for hiding this comment

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

LGTM with a minor nitpick inline.

I tested the changes with #209 to ensure that the tests run and fail as expected when needed.

.github/workflows/ignore-eslint.yml Outdated Show resolved Hide resolved
.github/workflows/ignore-phpunit.yml Outdated Show resolved Hide resolved
Copy link
Contributor

@peterwilsoncc peterwilsoncc left a comment

Choose a reason for hiding this comment

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

Thank you! LGTM.

@jeffpaul jeffpaul merged commit 6e34054 into develop Dec 8, 2022
@jeffpaul jeffpaul deleted the enhancement/203 branch December 8, 2022 04:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs:code-review This requires code review.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make actions to run only on changed files.
3 participants