Path filtering on required pull request checks #26857
-
We have a monorepo holding multiple microservices. On a pull request, we want to only run unit tests on a service that has been changed within the PR. We accomplish this with a workflow syntax like this:
However, when we mark the branch protection check as required then we can’t merge any pull requests that do not include changes to serviceA. Is there a way we can work around this? |
Beta Was this translation helpful? Give feedback.
Replies: 7 comments
-
Hi @connorgraham , I can repro the same on my side, the required check run will stay at ‘Expected- Waiting…’ status. You can remove paths setting for pull_request event, and remove checkrun from branch protection rule. Instead, check the file commit info, execute different jobs according to the file path. If it comes from service A, execute job1, if it comes from other file, execute job2…etc, it will skip unneccessary jobs and only one check run in pull request. Please check the link about how to get the file name(path). Or you can create another yaml file with different paths setting, cover the files changes out of service A. Thanks |
Beta Was this translation helpful? Give feedback.
-
Thanks @weide-zhou I solved it using the github actions script:
|
Beta Was this translation helpful? Give feedback.
-
I published an Action that solves all those required-check-problems: https://github.com/marketplace/actions/skip-duplicate-actions This is similar to GitHub’s path filter, but the underlying algorithm is smarter. |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
You can add a
The
This will short circuit the required check when it is skipped and if the the required fails, this will not overwrite that so the PR will still be in a failed state. |
Beta Was this translation helpful? Give feedback.
-
I tried to use skip-duplicate-actions but I think it's currently bugged and won't skip the jobs, instead I ended up using changed-files. |
Beta Was this translation helpful? Give feedback.
-
solution works but it is very inefficient, lots of status checks running for nothing. |
Beta Was this translation helpful? Give feedback.
Thanks @weide-zhou
I solved it using the github actions script: