-
Notifications
You must be signed in to change notification settings - Fork 16
130 lines (120 loc) · 4.12 KB
/
CEFI_MOM6_c6-ci.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
name: CEFI-MOM6_c6-ci
on:
# Triggers this workflow on pull request event with "CEFI_MOM6_RT_gaea_c6" label
pull_request:
branches: [ "main" ]
types: [ labeled ]
#
env:
TEST_DIR: ${{ github.workspace }}/${{ github.run_id }}
PR_NUMBER: ${{ github.event.number }}
#
jobs:
checkout-build:
if: ${{ github.event.label.name == 'CEFI_MOM6_RT_gaea_c6' }}
runs-on: self-hosted
timeout-minutes: 600
strategy:
max-parallel: 1
steps:
- name: Checkout CEFI-regional-MOM6
uses: actions/checkout@v4
with:
path: ${{ github.run_id }}/CEFI_MOM6_CHECK
fetch-depth: 1
submodules: recursive
- name: Build MOM6SIS2
run: |
cd ${{ env.TEST_DIR }}/CEFI_MOM6_CHECK/builds
jobid=$(sbatch --parsable ci_build_driver_c6.sh | awk -F';' '{print $1}' | cut -f1)
#
sleep 1
while :; do
job_status=$(squeue -h -j "$jobid" -o "%T" 2>/dev/null)
if [ -z "$job_status" ]; then
echo "Job with ID $jobid is not found or completed."
break
else
echo "Job with ID $jobid is still running."
echo "Job Status: $job_status"
fi
sleep 60 # Adjust the sleep duration as needed
done
#
check_file="${{ env.TEST_DIR }}/CEFI_MOM6_CHECK/builds/build/gaea-ncrc6.intel23/ocean_ice/repro/MOM6SIS2"
if [ -f "$check_file" ]; then
echo "PASSED: $check_file"
else
echo "FAILED: $check_file"
exit 1
fi
run-CEFI_MOM6-ci:
needs: checkout-build
runs-on: self-hosted
strategy:
max-parallel: 2
matrix:
case: ["NWA12.COBALT", "NEP10.COBALT"]
steps:
- name: Run Experiment ${{ matrix.case }}
run: |
cd ${{ env.TEST_DIR }}/CEFI_MOM6_CHECK/exps/${{ matrix.case }}
jobid=$(sbatch --parsable driver.sh | awk -F';' '{print $1}' | cut -f1)
#
sleep 1
while :; do
job_status=$(squeue -h -j "$jobid" -o "%T" 2>/dev/null)
if [ -z "$job_status" ]; then
echo "Job with ID $jobid is not found or completed."
break
else
echo "Job with ID $jobid is still running."
echo "Job Status: $job_status"
fi
sleep 60 # Adjust the sleep duration as needed
done
#
expected_string="All restart files are identical, PASS"
check_file="${{ env.TEST_DIR }}/CEFI_MOM6_CHECK/exps/${{ matrix.case }}/${{ matrix.case }}_o.$jobid"
if [ -f "$check_file" ]; then
if grep -qF "$expected_string" $check_file; then
echo "PASSED: ${{ matrix.case }}"
else
echo "FAILED: ${{ matrix.case }}"
exit 1
fi
else
echo "Can not find $check_file. STOP"
exit 10
fi
add-pass-label:
needs: run-CEFI_MOM6-ci
runs-on: self-hosted
if: ${{ needs.run-CEFI_MOM6-ci.result == 'success' }}
steps:
- name: Add "pass_CEFI_MOM6_RT" label on success
run: |
TOKEN=${{ secrets.GITHUB_TOKEN }}
RT_TEST_LABEL="CEFI_MOM6_RT_gaea_c6"
PASS_LABEL="pass_CEFI_MOM6_RT"
# Remove the "CEFI_MOM6_RT_gaea_c6" label
curl -X DELETE \
-H "Authorization: Bearer $TOKEN" \
-H "Accept: application/vnd.github.v3+json" \
"https://api.github.com/repos/$GITHUB_REPOSITORY/issues/${{ env.PR_NUMBER }}/labels/$RT_TEST_LABEL"
# Add the "pass_CEFI_MOM6_RT" label
curl -X POST \
-H "Authorization: Bearer $TOKEN" \
-H "Accept: application/vnd.github.v3+json" \
"https://api.github.com/repos/$GITHUB_REPOSITORY/issues/${{ env.PR_NUMBER }}/labels" \
-d "{\"labels\":[\"$PASS_LABEL\"]}"
clean-up:
needs: add-pass-label
runs-on: self-hosted
strategy:
max-parallel: 1
steps:
- name: Clean-up
run: |
cd ${{ github.workspace }}
rm -rf ${{ github.run_id }}