Introduce 'paths_filter' option along with new return values#159
Introduce 'paths_filter' option along with new return values#159paescuj wants to merge 5 commits intofkirc:masterfrom
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 * 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_filterwhich 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_resultoutput 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_resultreturns an empty object ({}). This can be easily intercepted in theifcondition of a job by checking the result of the "global"should_skipoutput first (see above).The
globalkey in the output ofpaths_resultcorresponds to the "global"paths_ignoreandpathsinputs, which makes it possible to profit from the information ofpaths_resulteven when only defining "global"paths_ignoreand/orpathsinputs.As you can see above, the
paths_resultobject also returns a list of matched files, if there are any, andskipped_byinformation.The
backtrack_countshows how many commits where traced back (skipped) until a result has been found.The named filters in
paths_filteralso accept thepaths_ignoresetting andbacktrackingcan 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_countto process the list of changed files.reason: The reason why the current run is considered skippable or unskippable.skip_after_successful_duplicateThis 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.