Skip to content

Commit b376a57

Browse files
committed
Workflows: reworked how to skip eamxx testing jobs
* Remove check-skip-labels action * For each eamxx workflow * Run two "generic" jobs on ubuntu-latest to - retrieve labels - check touched files Then, add skip logic to other jobs to avoid running if labels or touched files are not right
1 parent e902e38 commit b376a57

File tree

5 files changed

+177
-140
lines changed

5 files changed

+177
-140
lines changed

.github/actions/check-skip-labels/README.md

Lines changed: 0 additions & 24 deletions
This file was deleted.

.github/actions/check-skip-labels/action.yml

Lines changed: 0 additions & 48 deletions
This file was deleted.

.github/workflows/eamxx-sa-testing.yml

Lines changed: 70 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,6 @@ on:
55
pull_request:
66
branches: [ master ]
77
types: [opened, synchronize, ready_for_review, reopened]
8-
paths:
9-
- components/eamxx/**
10-
- components/eam/src/physics/rrtmgp/**
11-
- components/eam/src/physics/p3/scream/**
12-
- components/eam/src/physics/cam/**
13-
- .github/workflows/eamxx-standalone-testing.yml
14-
- externals/ekat/**
15-
- externals/scorpio/**
16-
- externals/haero/**
17-
- externals/YAKL/**
18-
- components/eam/src/physics/rrtmgp/external/**
198

209
# Manual run is used to bless
2110
workflow_dispatch:
@@ -48,15 +37,70 @@ env:
4837
submit: ${{ github.event_name == 'schedule' && 'true' || 'false' }} # Submit to cdash only for nightlies
4938

5039
jobs:
40+
pr_relevant:
41+
if: ${{ github.event_name == 'pull_request' }}
42+
runs-on: ubuntu-latest # This job can run anywhere
43+
outputs:
44+
value: ${{ steps.check_paths.outputs.touched }}
45+
steps:
46+
- name: check_paths
47+
run: |
48+
paths=(
49+
components/eamxx
50+
components/eam/src/physics/rrtmgp
51+
components/eam/src/physics/p3/scream
52+
components/eam/src/physics/cam
53+
components/eam/src/physics/rrtmgp/external
54+
externals/ekat
55+
externals/scorpio
56+
externals/haero
57+
externals/YAKL
58+
.github/workflows/eamxx-sa-testing.yml
59+
)
60+
pattern=$(IFS=\|; echo "${paths[*]}")
61+
62+
# Use the GitHub API to get the list of changed files
63+
response=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
64+
"https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.number }}/files")
65+
changed_files=$(echo "$response" | grep -o '"filename": *"[^"]*"' | sed 's/"filename": *//; s/"//g')
66+
67+
# Check for matches and echo the matching files (or "" if none)
68+
matching_files=$(echo "$changed_files" | grep -E "^($pattern)" || echo "")
69+
if [[ -n "$matching_files" ]]; then
70+
echo "Found relevant files: $matching_files"
71+
echo "touched=true" >> $GITHUB_OUTPUT
72+
else
73+
echo "No relevant files touched by this PR."
74+
echo "touched=false" >> $GITHUB_OUTPUT
75+
fi
76+
get_labels:
77+
if: ${{ github.event_name == 'pull_request' }}
78+
runs-on: ubuntu-latest
79+
outputs:
80+
labels: ${{ steps.get_labels.outputs.labels }}
81+
steps:
82+
- name: get_labels
83+
run: |
84+
labels="${{ join(github.event.pull_request.labels.*.name, ',') }}"
85+
echo "labels=${labels}" >> $GITHUB_OUTPUT
5186
gcc-openmp:
87+
needs: pr_relevant, get_labels
88+
if: |
89+
(github.event_name == 'pull_request' &&
90+
needs.pr_relevant.outputs.value=='true' &&
91+
!contains(needs.get_labels.outputs.labels,'CI: skip gcc') &&
92+
!contains(needs.get_labels.outputs.labels,'CI: skip openmp') &&
93+
!contains(needs.get_labels.outputs.labels,'CI: skip eamxx-sa') &&
94+
!contains(needs.get_labels.outputs.labels,'CI: skip eamxx-all')) ||
95+
(github.event_name == 'workflow_dispatch' &&
96+
github.event.inputs.job_to_run == 'gcc-openmp' ||
97+
github.event.inputs.job_to_run == 'all') ||
98+
github.event_name == 'schedule'
5299
runs-on: [self-hosted, ghci-snl-cpu, gcc]
53100
strategy:
54101
fail-fast: false
55102
matrix:
56103
build_type: [sp, dbg, fpe, opt]
57-
if: ${{ github.event_name != 'workflow_dispatch' ||
58-
github.event.inputs.job_to_run == 'gcc-openmp' ||
59-
github.event.inputs.job_to_run == 'all' }}
60104
name: gcc-openmp / ${{ matrix.build_type }}
61105
steps:
62106
- name: Check out the repository
@@ -67,13 +111,6 @@ jobs:
67111
submodules: recursive
68112
- name: Show action trigger
69113
uses: ./.github/actions/show-workflow-trigger
70-
- name: Check for skip labels
71-
if: ${{ github.event_name == 'pull_request' || github.event_name == 'pull_request_review' }}
72-
uses: ./.github/actions/check-skip-labels
73-
with:
74-
skip_labels: 'AT: skip gcc,AT: skip openmp,AT: skip eamxx-sa,AT: skip eamxx-all'
75-
token: ${{ secrets.GITHUB_TOKEN }}
76-
pr_number: ${{ github.event.pull_request.number }}
77114
- name: Set test-all inputs based on event specs
78115
run: |
79116
echo "generate=false" >> $GITHUB_ENV
@@ -91,14 +128,23 @@ jobs:
91128
submit: ${{ env.submit }}
92129
cmake-configs: Kokkos_ENABLE_OPENMP=ON
93130
gcc-cuda:
131+
needs: pr_relevant, get_labels
132+
if: |
133+
(github.event_name == 'pull_request' &&
134+
needs.pr_relevant.outputs.value=='true' &&
135+
!contains(needs.get_labels.outputs.labels,'CI: skip gcc') &&
136+
!contains(needs.get_labels.outputs.labels,'CI: skip cuda') &&
137+
!contains(needs.get_labels.outputs.labels,'CI: skip eamxx-sa') &&
138+
!contains(needs.get_labels.outputs.labels,'CI: skip eamxx-all')) ||
139+
(github.event_name == 'workflow_dispatch' &&
140+
github.event.inputs.job_to_run == 'gcc-cuda' ||
141+
github.event.inputs.job_to_run == 'all') ||
142+
github.event_name == 'schedule'
94143
runs-on: [self-hosted, ghci-snl-cuda, cuda, gcc]
95144
strategy:
96145
fail-fast: false
97146
matrix:
98147
build_type: [sp, dbg, opt]
99-
if: ${{ github.event_name != 'workflow_dispatch' ||
100-
github.event.inputs.job_to_run == 'gcc-cuda' ||
101-
github.event.inputs.job_to_run == 'all' }}
102148
name: gcc-cuda / ${{ matrix.build_type }}
103149
steps:
104150
- name: Check out the repository
@@ -109,13 +155,6 @@ jobs:
109155
submodules: recursive
110156
- name: Show action trigger
111157
uses: ./.github/actions/show-workflow-trigger
112-
- name: Check for skip labels
113-
if: ${{ github.event_name == 'pull_request' || github.event_name == 'pull_request_review' }}
114-
uses: ./.github/actions/check-skip-labels
115-
with:
116-
skip_labels: 'AT: skip gcc,AT: skip cuda,AT: skip eamxx-sa,AT: skip eamxx-all'
117-
token: ${{ secrets.GITHUB_TOKEN }}
118-
pr_number: ${{ github.event.pull_request.number }}
119158
- name: Set test-all inputs based on event specs
120159
run: |
121160
echo "generate=false" >> $GITHUB_ENV

.github/workflows/eamxx-scripts-tests.yml

Lines changed: 50 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,6 @@ on:
55
pull_request:
66
branches: [ master ]
77
types: [opened, synchronize, ready_for_review, reopened]
8-
paths:
9-
- components/eamxx/scripts/**
10-
- components/eamxx/cime_config/*.py
11-
- .github/workflows/eamxx-scripts-tests.yml
12-
- externals/ekat/**
13-
- externals/scorpio/**
14-
- externals/haero/**
15-
- externals/YAKL/**
16-
- components/eam/src/physics/rrtmgp/external/**
178

189
# Manual run for debug purposes only
1910
workflow_dispatch:
@@ -30,7 +21,57 @@ concurrency:
3021
cancel-in-progress: true
3122

3223
jobs:
24+
pr_relevant:
25+
if: ${{ github.event_name == 'pull_request' }}
26+
runs-on: ubuntu-latest # This job can run anywhere
27+
outputs:
28+
value: ${{ steps.check_paths.outputs.touched }}
29+
steps:
30+
- name: check_paths
31+
id: check_paths
32+
run: |
33+
paths=(
34+
components/eamxx/scripts
35+
components/eamxx/cime_config/eamxx
36+
components/eamxx/cime_config/build
37+
components/eamxx/cime_config/yaml_utils.py
38+
.github/workflows/eamxx-scripts-tests.yml
39+
)
40+
pattern=$(IFS=\|; echo "${paths[*]}")
41+
42+
# Use the GitHub API to get the list of changed files
43+
response=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
44+
"https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.number }}/files")
45+
changed_files=$(echo "$response" | grep -o '"filename": *"[^"]*"' | sed 's/"filename": *//; s/"//g')
46+
47+
# Check for matches and echo the matching files (or "" if none)
48+
matching_files=$(echo "$changed_files" | grep -E "^($pattern)" || echo "")
49+
if [[ -n "$matching_files" ]]; then
50+
echo "Found relevant files: $matching_files"
51+
echo "touched=true" >> $GITHUB_OUTPUT
52+
else
53+
echo "No relevant files touched by this PR."
54+
echo "touched=false" >> $GITHUB_OUTPUT
55+
fi
56+
get_labels:
57+
if: ${{ github.event_name == 'pull_request' }}
58+
runs-on: ubuntu-latest
59+
outputs:
60+
labels: ${{ steps.get_labels.outputs.labels }}
61+
steps:
62+
- name: get_labels
63+
id: get_labels
64+
run: |
65+
labels="${{ join(github.event.pull_request.labels.*.name, ',') }}"
66+
echo "labels=${labels}" >> $GITHUB_OUTPUT
3367
cpu-gcc:
68+
needs: [pr_relevant, get_labels]
69+
if: |
70+
github.event_name != 'pull_request' ||
71+
(
72+
needs.pr_relevant.outputs.value == 'true' &&
73+
!contains(needs.get_labels.outputs.labels, 'CI: skip eamxx-all')
74+
)
3475
runs-on: [self-hosted, gcc, ghci-snl-cpu]
3576
steps:
3677
- name: Check out the repository
@@ -41,13 +82,6 @@ jobs:
4182
submodules: recursive
4283
- name: Show action trigger
4384
uses: ./.github/actions/show-workflow-trigger
44-
- name: Check for skip labels
45-
if: ${{ github.event_name == 'pull_request' || github.event_name == 'pull_request_review' }}
46-
uses: ./.github/actions/check-skip-labels
47-
with:
48-
skip_labels: 'AT: skip eamxx-all'
49-
token: ${{ secrets.GITHUB_TOKEN }}
50-
pr_number: ${{ github.event.pull_request.number }}
5185
- name: Run test
5286
run: |
5387
cd components/eamxx

0 commit comments

Comments
 (0)