@@ -30,21 +30,55 @@ jobs:
30
30
runs-on : ubuntu-latest
31
31
# Map a step output to a job output, this allows other jobs to be gated on the filter results
32
32
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 }}
37
38
steps :
38
39
- name : Checkout
39
40
uses : actions/checkout@v4
40
41
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
+
41
74
- name : Paths matching on any filter rule
42
75
# For safety use the commit of dorny/paths-filter@v3
43
76
uses : dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36
44
- id : filter_some
77
+ id : filter_on_some
45
78
with :
46
79
# 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.
48
82
predicate-quantifier : ' some'
49
83
list-files : ' json'
50
84
filters : |
@@ -67,41 +101,15 @@ jobs:
67
101
trivvyscan:
68
102
- 'environments/.stackhpc/tofu/cluster_image.auto.tfvars.json'
69
103
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
-
87
104
- 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.
89
106
# 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.
99
107
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 '.'
105
113
106
114
extra :
107
115
name : Test extra build
0 commit comments