@@ -30,21 +30,55 @@ jobs:
3030 runs-on : ubuntu-latest
3131 # Map a step output to a job output, this allows other jobs to be gated on the filter results
3232 outputs :
33- extra_on_push : ${{ steps.filter_some.outputs.extra_on_push }}
34- extra_on_pull_request : ${{ steps.filter_some.outputs.extra_on_pull_request }}
35- stackhpc : ${{ toJson(fromJson(steps.filter_some.outputs.stackhpc) || fromJson(steps.filter_every.outputs.stackhpc)) }}
36- trivvyscan : ${{ steps.filter_some.outputs.trivvyscan }}
33+ extra_on_push : ${{ steps.filter_on_some.outputs.extra_on_push }}
34+ extra_on_pull_request : ${{ steps.filter_on_some.outputs.extra_on_pull_request }}
35+ # The 'stackhpc' output will be 'true' if either of the two stackhpc filters below matched
36+ stackhpc : ${{ toJson(fromJson(steps.filter_on_every.outputs.stackhpc) || fromJson(steps.filter_on_some.outputs.stackhpc)) }}
37+ trivvyscan : ${{ steps.filter_on_some.outputs.trivvyscan }}
3738 steps :
3839 - name : Checkout
3940 uses : actions/checkout@v4
4041
42+ # NOTE: We're detecting the changed files within a job so that we can gate execution of other jobs.
43+ # We use dorny/paths-filter which doesn't work like the conventional 'paths' and 'paths_exclude',
44+ # we can't do the following:
45+ # paths:
46+ # - '**'
47+ # - '!dev/**'
48+ # - 'dev/setup-env.sh'
49+ #
50+ # Which would include all files whilst removing all "dev/" files except "dev/setup-env.sh".
51+ # We have to use two filters:
52+ # * first filter includes all changed files and removes "dev/" files
53+ # * second filter explicitly adds 'dev/setup-env.sh'
54+ # We use the logical OR of the filters outputs to gate jobs.
55+
56+ - name : Paths matching on every filter rule
57+ # For safety use the commit of dorny/paths-filter@v3
58+ uses : dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36
59+ id : filter_on_every
60+ with :
61+ # Filter changed files, 'every' means the file is matched only if it matches all filter rules.
62+ # NOTE: currently seeing: Warning: Unexpected input(s) 'predicate-quantifier', valid inputs are..
63+ # this can be ignored, filtering works as expected.
64+ predicate-quantifier : ' every'
65+ list-files : ' json'
66+ filters : |
67+ stackhpc:
68+ - '**'
69+ - '!dev/**'
70+ - '!**/*.md'
71+ - '!.gitignore'
72+ - '!.github/workflows/**'
73+
4174 - name : Paths matching on any filter rule
4275 # For safety use the commit of dorny/paths-filter@v3
4376 uses : dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36
44- id : filter_some
77+ id : filter_on_some
4578 with :
4679 # Filter changed files, 'some' means the file is matched if any one of the filter rules match.
47- # Processing is different from 'paths' and 'paths_exclude', see note below.
80+ # NOTE: currently seeing: Warning: Unexpected input(s) 'predicate-quantifier', valid inputs are..
81+ # this can be ignored, filtering works as expected.
4882 predicate-quantifier : ' some'
4983 list-files : ' json'
5084 filters : |
@@ -67,41 +101,15 @@ jobs:
67101 trivvyscan:
68102 - 'environments/.stackhpc/tofu/cluster_image.auto.tfvars.json'
69103
70- - name : Paths matching on every filter rule
71- # For safety use the commit of dorny/paths-filter@v3
72- uses : dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36
73- id : filter_every
74- with :
75- # Filter changed files, 'every' means the file is matched only if matches all filter rules.
76- # Processing is different from 'paths' and 'paths_exclude', see note below.
77- predicate-quantifier : ' every'
78- list-files : ' json'
79- filters : |
80- stackhpc:
81- - '**'
82- - '!dev/**'
83- - '!**/*.md'
84- - '!.gitignore'
85- - '!.github/workflows/**'
86-
87104 - name : Paths matched output
88- # NOTE: This is a debug step, it prints the paths that matched the filters
105+ # NOTE: This is a debug step, it shows what files were matched by the filters.
89106 # It's useful because dorny/paths-filter doesn't work like the conventional 'paths' and 'paths_exclude'
90- # We can't do the following:
91- # paths:
92- # - '**'
93- # - '!dev/**'
94- # - 'dev/setup-env.sh'
95- #
96- # Which would include all files whilst removing all "dev/" files except "dev/setup-env.sh".
97- # Instead the 'some' stackhpc filter ensures we include "dev/setup-env.sh" - if changed,
98- # the 'every' stackhpc filter ensures we don't include any other "dev/**" files.
99107 run : >
100- echo '{ "extra_on_push_files": ${{ steps.filter_some .outputs.extra_on_push_files }} }' | jq -r '.';
101- echo '{ "extra_on_pull_request_files": ${{ steps.filter_some .outputs.extra_on_pull_request_files }} }' | jq -r '.';
102- echo '{ "stackhpc_some_files ": ${{ steps.filter_some .outputs.stackhpc_files }} }' | jq -r '.';
103- echo '{ "stackhpc_every_files ": ${{ steps.filter_every .outputs.stackhpc_files }} }' | jq -r '.';
104- echo '{ "trivvyscan_files": ${{ steps.filter_some .outputs.trivvyscan_files }} }' | jq -r '.'
108+ echo '{ "extra_on_push_files": ${{ steps.filter_on_some .outputs.extra_on_push_files }} }' | jq -r '.';
109+ echo '{ "extra_on_pull_request_files": ${{ steps.filter_on_some .outputs.extra_on_pull_request_files }} }' | jq -r '.';
110+ echo '{ "stackhpc_every_files ": ${{ steps.filter_on_every .outputs.stackhpc_files }} }' | jq -r '.';
111+ echo '{ "stackhpc_some_files ": ${{ steps.filter_on_some .outputs.stackhpc_files }} }' | jq -r '.';
112+ echo '{ "trivvyscan_files": ${{ steps.filter_on_some .outputs.trivvyscan_files }} }' | jq -r '.'
105113
106114 extra :
107115 name : Test extra build
0 commit comments