Skip to content

Commit c046991

Browse files
committed
Tweak github action used to detect changed paths on push/pull request
1 parent 1e165bb commit c046991

File tree

1 file changed

+23
-31
lines changed

1 file changed

+23
-31
lines changed

.github/workflows/main.yml

Lines changed: 23 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,18 @@ jobs:
3333
extra_on_push: ${{ steps.filter_some.outputs.extra_on_push }}
3434
extra_on_pull_request: ${{ steps.filter_some.outputs.extra_on_pull_request }}
3535
stackhpc: ${{ toJson(fromJson(steps.filter_some.outputs.stackhpc) || fromJson(steps.filter_every.outputs.stackhpc)) }}
36-
stackhpc_some: ${{ steps.filter_some.outputs.stackhpc }}
37-
stackhpc_every: ${{ steps.filter_every.outputs.stackhpc }}
3836
trivvyscan: ${{ steps.filter_some.outputs.trivvyscan }}
3937
steps:
4038
- name: Checkout
4139
uses: actions/checkout@v4
4240

43-
- name: Paths matching on any filter
44-
# For safety using commit of dorny/paths-filter@v3
41+
- name: Paths matching on any filter rule
42+
# For safety use the commit of dorny/paths-filter@v3
4543
uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36
4644
id: filter_some
4745
with:
46+
# 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.
4848
predicate-quantifier: 'some'
4949
list-files: 'json'
5050
filters: |
@@ -62,54 +62,47 @@ jobs:
6262
- 'ansible/roles/lustre/**'
6363
- '.github/workflows/extra.yml'
6464
stackhpc:
65-
#- '**'
66-
#- '!dev/**'
67-
- 'dev/setup-env.sh___TMP_WILL_NOT_MATCH'
68-
#- '!docs/**'
69-
#- '!README.md'
70-
#- '!.gitignore'
71-
#- '!.github/workflows/'
65+
- 'dev/setup-env.sh'
7266
- '.github/workflows/stackhpc'
7367
trivvyscan:
7468
- 'environments/.stackhpc/tofu/cluster_image.auto.tfvars.json'
7569
76-
- name: Paths matching on every filter
77-
# For safety using commit of dorny/paths-filter@v3
70+
- name: Paths matching on every filter rule
71+
# For safety use the commit of dorny/paths-filter@v3
7872
uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36
7973
id: filter_every
8074
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.
8177
predicate-quantifier: 'every'
8278
list-files: 'json'
8379
filters: |
8480
stackhpc:
85-
- '**___TMP_WILL_NOT_MATCH'
81+
- '**'
8682
- '!dev/**'
8783
- '!**/*.md'
8884
- '!.gitignore'
8985
- '!.github/workflows/'
9086
91-
- name: Paths matching
87+
- name: Paths matched output
88+
# NOTE: This is a debug step, it prints the paths that matched the filters
89+
# 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.
9299
run: >
93100
echo '{ "extra_on_push_files": ${{ steps.filter_some.outputs.extra_on_push_files }} }' | jq -r '.';
94101
echo '{ "extra_on_pull_request_files": ${{ steps.filter_some.outputs.extra_on_pull_request_files }} }' | jq -r '.';
95102
echo '{ "stackhpc_some_files": ${{ steps.filter_some.outputs.stackhpc_files }} }' | jq -r '.';
96103
echo '{ "stackhpc_every_files": ${{ steps.filter_every.outputs.stackhpc_files }} }' | jq -r '.';
97104
echo '{ "trivvyscan_files": ${{ steps.filter_some.outputs.trivvyscan_files }} }' | jq -r '.'
98105
99-
debug:
100-
name: Debug paths matching
101-
needs: files_changed
102-
steps:
103-
- name: Debug paths matching
104-
run: >
105-
echo 'extra_on_push: ${{ needs.files_changed.outputs.extra_on_push }}';
106-
echo 'extra_on_pull_request: ${{ needs.files_changed.outputs.extra_on_pull_request }}';
107-
echo 'stackhpc: ${{ needs.files_changed.outputs.stackhpc }}';
108-
echo 'stackhpc_some: ${{ needs.files_changed.outputs.stackhpc_some }}';
109-
echo 'stackhpc_every: ${{ needs.files_changed.outputs.stackhpc_every }}';
110-
echo 'trivvyscan: ${{ needs.files_changed.outputs.trivvyscan }}'
111-
runs-on: ubuntu-latest # TEST
112-
113106
extra:
114107
name: Test extra build
115108
needs: files_changed
@@ -129,8 +122,7 @@ jobs:
129122
name: Test deployment and reimage on OpenStack
130123
needs: files_changed
131124
if: |
132-
needs.files_changed.outputs.stackhpc_some == 'true' ||
133-
needs.files_changed.outputs.stackhpc_every == 'true'
125+
needs.files_changed.outputs.stackhpc == 'true'
134126
#uses: ./.github/workflows/stackhpc.yml
135127
steps: # TEST
136128
- name: Test deployment and reimage on OpenStack...

0 commit comments

Comments
 (0)