Skip to content

Commit b965ecb

Browse files
committed
Tweak github action used to detect changed paths on push/pull request
1 parent 59e2c38 commit b965ecb

File tree

1 file changed

+39
-28
lines changed

1 file changed

+39
-28
lines changed

.github/workflows/main.yml

Lines changed: 39 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -30,63 +30,78 @@ 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_push: ${{ steps.filter.outputs.extra_push }}
34-
extra_pull_request: ${{ steps.filter.outputs.extra_pull_request }}
35-
stackhpc: ${{ steps.filter.outputs.stackhpc }}
36-
trivvyscan: ${{ steps.filter.outputs.trivvyscan }}
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_some: ${{ steps.filter_some.outputs.stackhpc }}
36+
stackhpc_every: ${{ steps.filter_every.outputs.stackhpc }}
37+
trivvyscan: ${{ steps.filter_some.outputs.trivvyscan }}
3738
steps:
3839
- name: Checkout
3940
uses: actions/checkout@v4
4041

41-
- name: Paths Filter
42+
- name: Paths matching on any filter
4243
# For safety using commit of dorny/paths-filter@v3
4344
uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36
44-
id: filter
45+
id: filter_some
4546
with:
47+
predicate-quantifier: 'some'
4648
list-files: 'json'
4749
filters: |
48-
extra_push:
50+
extra_on_push:
4951
- 'environments/.stackhpc/tofu/cluster_image.auto.tfvars.json'
5052
- 'ansible/roles/doca/**'
5153
- 'ansible/roles/cuda/**'
5254
- 'ansible/roles/slurm_recompile/**' # runs on cuda group
5355
- 'ansible/roles/lustre/**'
5456
- '.github/workflows/extra.yml'
55-
extra_pull_request:
57+
extra_on_pull_request:
5658
- 'environments/.stackhpc/tofu/cluster_image.auto.tfvars.json'
5759
- 'ansible/roles/doca/**'
5860
- 'ansible/roles/cuda/**'
5961
- 'ansible/roles/lustre/**'
6062
- '.github/workflows/extra.yml'
63+
stackhpc:
64+
#- '**'
65+
#- '!dev/**'
66+
- 'dev/setup-env.sh'
67+
#- '!docs/**'
68+
#- '!README.md'
69+
#- '!.gitignore'
70+
#- '!.github/workflows/'
71+
- '.github/workflows/stackhpc'
72+
trivvyscan:
73+
- 'environments/.stackhpc/tofu/cluster_image.auto.tfvars.json'
74+
75+
- name: Paths matching on every filter
76+
# For safety using commit of dorny/paths-filter@v3
77+
uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36
78+
id: filter_every
79+
with:
80+
predicate-quantifier: 'every'
81+
list-files: 'json'
82+
filters: |
6183
stackhpc:
6284
- '**'
6385
- '!dev/**'
64-
- 'dev/setup-env.sh'
6586
- '!docs/**'
6687
- '!README.md'
6788
- '!.gitignore'
6889
- '!.github/workflows/'
69-
- '.github/workflows/stackhpc'
70-
trivvyscan:
71-
- 'environments/.stackhpc/tofu/cluster_image.auto.tfvars.json'
7290
7391
- name: Paths Filter Result
7492
run: >
75-
echo '{ "extra_push_files": ${{ steps.filter.outputs.extra_push_files }} }' | jq -r '.';
76-
echo '{ "extra_pull_request_files": ${{ steps.filter.outputs.extra_pull_request_files }} }' | jq -r '.';
77-
echo '{ "stackhpc_files": ${{ steps.filter.outputs.stackhpc_files }} }' | jq -r '.';
78-
echo '{ "trivvyscan_files": ${{ steps.filter.outputs.trivvyscan_files }} }' | jq -r '.'
93+
echo '{ "extra_on_push_files": ${{ steps.filter_some.outputs.extra_on_push_files }} }' | jq -r '.';
94+
echo '{ "extra_on_pull_request_files": ${{ steps.filter_some.outputs.extra_on_pull_request_files }} }' | jq -r '.';
95+
echo '{ "stackhpc_some_files": ${{ steps.filter_some.outputs.stackhpc_some_files }} }' | jq -r '.';
96+
echo '{ "stackhpc_every_files": ${{ steps.filter_every.outputs.stackhpc_every_files }} }' | jq -r '.';
97+
echo '{ "trivvyscan_files": ${{ steps.filter_some.outputs.trivvyscan_files }} }' | jq -r '.'
7998
8099
extra:
81100
name: Test extra build
82101
needs: files_changed
83-
#if: |
84-
# needs.files_changed.outputs.should_skip != 'true' &&
85-
# (( github.event_name != 'pull_request' && !fromJSON(needs.files_changed.outputs.paths_result).extra_push.should_skip ) ||
86-
# ( github.event_name == 'pull_request' && !fromJSON(needs.files_changed.outputs.paths_result).extra_pull_request.should_skip ))
87102
if: |
88-
github.event_name != 'pull_request' && needs.files_changed.outputs.extra_push == 'true' ||
89-
github.event_name == 'pull_request' && needs.files_changed.outputs.extra_pull_request == 'true'
103+
github.event_name != 'pull_request' && needs.files_changed.outputs.extra_on_push == 'true' ||
104+
github.event_name == 'pull_request' && needs.files_changed.outputs.extra_on_pull_request == 'true'
90105
#uses: ./.github/workflows/extra.yml
91106
steps: # TEST
92107
- name: Test extra build...
@@ -99,10 +114,9 @@ jobs:
99114
stackhpc:
100115
name: Test deployment and reimage on OpenStack
101116
needs: files_changed
102-
#if: |
103-
# needs.files_changed.outputs.should_skip != 'true' && !fromJSON(needs.files_changed.outputs.paths_result).stackhpc.should_skip
104117
if: |
105-
needs.files_changed.outputs.stackhpc == 'true'
118+
needs.files_changed.outputs.stackhpc_some == 'true' ||
119+
needs.files_changed.outputs.stackhpc_every == 'true'
106120
#uses: ./.github/workflows/stackhpc.yml
107121
steps: # TEST
108122
- name: Test deployment and reimage on OpenStack...
@@ -115,9 +129,6 @@ jobs:
115129
trivvyscan:
116130
name: Trivy scan image for vulnerabilities
117131
needs: files_changed
118-
#if: |
119-
# github.event_name == 'pull_request' &&
120-
# needs.files_changed.outputs.should_skip != 'true' && !fromJSON(needs.files_changed.outputs.paths_result).trivvyscan.should_skip
121132
if: |
122133
github.event_name == 'pull_request' &&
123134
needs.files_changed.outputs.trivvyscan == 'true'

0 commit comments

Comments
 (0)