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

feat: add skip_path option in watch #27

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jamietanna
Copy link

This PR adds support for specifying a skip_path option that support either a path or a list of paths that shouldn't result in adding the trigger step as part of the dynamically generated pipeline.

Note even in cases where a line in the diff is skipped due to skip_path and there are other paths in the diff that match path but doesn't match skip_path, the step will still be added to the dynamically generated pipeline. i.e. for the step to be effectively ignored, the paths in skip_path should match all of those in the given diff.

Motivation

The motivation for this is the lack of support for negation cases in doublestar (the package used for glob pattern matching) See bmatcuk/doublestar#49.

I had a use case where I needed to avoid changes in certain subdirectories to trigger a step (if there were the only changes in the diff) and I tried to use the following pattern: path: "/main/{*,!(subdir1|subdir2)/**/*}" which should be a valid glob for filtering out subdir1 and subdir2, but didn't work.

With this, I could instead do something like:

- path: "main/"
  skip_path:
    - "main/subdir1"
    - "main/subdir2"

and the result would be the same.


This is a git cherry-pick from adikari#88

This will close #20.

@jamietanna jamietanna requested a review from a team as a code owner October 7, 2024 09:22
README.md Show resolved Hide resolved
Copy link

@tomowatt tomowatt left a comment

Choose a reason for hiding this comment

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

@jamietanna cheers for raising this, the README changes need reviewed but everything is all good!

@jamietanna
Copy link
Author

Thank you! Will make those tweaks now.

As an aside, @tomowatt, the Buildkite pipeline's not public - not sure if intended or not :)

@mcncl
Copy link

mcncl commented Oct 7, 2024

The reason that CI is failing is because of the fork issue we've seen elsewhere, I'll fix that up

As part of buildkite-plugins#20, we want to be able to negate specific paths in a given
`watch` path by using `skip_path`.

This PR adds support for specifying a `skip_path` option that support
either a path or a list of paths that shouldn't result in adding the
`trigger` step as part of the dynamically generated pipeline.

Note even in cases where a line in the `diff` is skipped due to
`skip_path` and there are other paths in the `diff` that match `path`
but doesn't match `skip_path`, the step will still be added to the
dynamically generated pipeline. i.e. for the step to be effectively
ignored, the paths in `skip_path` should match all of those in the given
`diff`.

This is required due to the lack of support for negation cases in
`doublestar`, which we use for glob pattern matching[0].

Closes buildkite-plugins#20.

[0]: bmatcuk/doublestar#49
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 skipping paths option to path
4 participants