-
-
Notifications
You must be signed in to change notification settings - Fork 41
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
Introduce 'paths_filter' option along with new return values #159
Conversation
b9a09bd
to
7533a27
Compare
Thanks for submitting the PR with detailed descriptions.
My hope is that small chunks of functionality make it easier to upgrade this action in a safe way. |
Hey @fkirc, thanks for your positive feedback! Sure, will split it up and submit separate pull requests tomorrow 👍 |
Also, please let me know if you have better ideas about the naming of the input/output parameters. |
* Udpdate all dependencies See #159 * Switch to Node.js v16 Node.js v16 is current LTS and now supported as action runtime * Only format files in 'src' folder
* Udpdate all dependencies See #159 * Switch to Node.js v16 Node.js v16 is current LTS and now supported as action runtime * Only format files in 'src' folder * Introduce 'reason' output See #159 Co-authored-by: Felix K <[email protected]>
* Udpdate all dependencies See #159 * Switch to Node.js v16 Node.js v16 is current LTS and now supported as action runtime * Only format files in 'src' folder * Introduce 'reason' output See #159 * Introduce 'paths_filter' option and 'changed_files' output See #159 * Fix action.yml and first part of README update * Rebuild * Update README.md to reflect new input/outputs
This introduces a new option called
paths_filter
which can be used to define one or more named filters with path patterns (paths_ignore
,paths
), inspired by the paths-filter action. When defining such filters, the action returns corresponding information in a new output calledpaths_result
.This makes it possible to get dedicated information about different path patterns and react accordingly, in a single run of 'skip-duplicate-actions'.
For example in a monorepo, I want to run jobs related to the "frontend" only if some files in the corresponding folder
frontend/
have changed and same with "backend". This can now be achieved with the following configuration:The
paths_result
output returns a JSON-object which looks something like this:If 'skip-duplicate-actions' terminates before the paths checks are performed (for example, when a successful duplicate run has been found) the
paths_result
returns an empty object ({}
). This can be easily intercepted in theif
condition of a job by checking the result of the "global"should_skip
output first (see above).The
global
key in the output ofpaths_result
corresponds to the "global"paths_ignore
andpaths
inputs, which makes it possible to profit from the information ofpaths_result
even when only defining "global"paths_ignore
and/orpaths
inputs.As you can see above, the
paths_result
object also returns a list of matched files, if there are any, andskipped_by
information.The
backtrack_count
shows how many commits where traced back (skipped) until a result has been found.The named filters in
paths_filter
also accept thepaths_ignore
setting andbacktracking
can optionally be disabled or limited to a number of commits, for example:In addition, this pull request introduces the following outputs:
changed_files
: A two-dimensional array, with a list of changed files for each commit that was traced back. Returns information only if one of the options "paths_ignore", "paths" or "paths_filter" is set.[["some/example/file.txt", "another/example/file.txt"], ["frontend/file.txt"]]
changed_files[0]
to get the changed files in the current commit. One might also use the output ofbacktrack_count
to process the list of changed files.reason
: The reason why the current run is considered skippable or unskippable.skip_after_successful_duplicate
This pull request contains no breaking changes and I was particularly careful to not compromise the performance of the action.
Closes #139
@fkirc If you like those changes (I really hope you do 😄), I'll happily update the README.