-
Notifications
You must be signed in to change notification settings - Fork 2
/
.gitlab-ci.yml
234 lines (208 loc) · 6.62 KB
/
.gitlab-ci.yml
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
# A pipeline is composed of independent jobs that run scripts, grouped into stages.
# Stages run in sequential order, but jobs within stages run in parallel.
#
# For more information, see: https://docs.gitlab.com/ee/ci/yaml/index.html#stages
####################################################################################################
# global settings
####################################################################################################
# list of stages and order of execution
stages:
- build
- cleanup_build
- test
- cleanup
# - deploy
# workflow rules (exclude issue branches from pipeline)
workflow:
rules:
- if: $CI_PIPELINE_SOURCE == "web"
when: always
# - changes:
# - src/*
# - src/*/*
# - CMakeLists.txt
# when: always
- if: '$CI_COMMIT_BRANCH =~ /^[\d]+-.*$/'
when: never
- if: $CI_COMMIT_MESSAGE =~ /-draft$/
when: never
- if: $CI_PIPELINE_SOURCE == "push"
when: never
# - when: always
# global variables for all jobs
variables:
OUTPUT_DIR: output # Adjust this to your Fortran code's output directory
TEST_DIR: test # Adjust this to your Fortran code's output directory
COMPARE_OUTPUT: ../../tools/output_comparison.py # python output file comparison script
# special job that runs before any other stages
before_script:
- echo "Setting up environment for jobs"
- export MODULEPATH="/opt/intel/oneapi/modulefiles:/opt/intel/oneapi/tbb/latest/modulefiles:$MODULEPATH"
- export MODULEPATH="/home/ned/modules/modulefiles:$MODULEPATH"
# - apt-get update -qy
# - apt-get install -y gfortran # Install gfortran (or any other Fortran compiler you prefer)
####################################################################################################
# jobs
####################################################################################################
# build job - gfortran
build:gfortran:
stage: build
when: always
script:
# need to query modules before gcc can be found and loaded
- module avail
# - /usr/local/gcc-13.2.0/bin/gfortran-13.2.0 --version
- module load gcc/13.2.0
- which gfortran-13.2.0
- gfortran-13.2.0 --version
- mkdir -p $OUTPUT_DIR
- echo "Compiling the code using gfortran..."
- mkdir -p build
- cd build
- cmake3 -DCMAKE_BUILD_TYPE="Release" -DCMAKE_INSTALL_PREFIX="../bin" -DCMAKE_Fortran_COMPILER="gfortran-13.2.0" ..
- make
- make install
- cd ..
- echo "Compile complete using gfortran."
artifacts:
paths:
- bin/
tags:
- gfortran
# build job - ifort
build:ifort:
stage: build
when: always
script:
# - /opt/intel/oneapi/compiler/2023.2.1/linux/bin/intel64/ifort --version
- module load compiler/2023.2.1
- which ifort
- ifort --version
- mkdir -p $OUTPUT_DIR
- echo "Compiling the code using ifort..."
- mkdir -p build
- cd build
- cmake3 -DCMAKE_BUILD_TYPE="Release" -DCMAKE_INSTALL_PREFIX="../bin" -DCMAKE_Fortran_COMPILER="ifort" ..
- make
- make install
- cd ..
- echo "Compile complete using ifort."
artifacts:
paths:
- bin/
tags:
- ifort
# build job - ifx
build:ifx:
stage: build
when: always
script:
# - /opt/intel/oneapi/compiler/2023.2.1/linux/bin/ifx --version
- module load compiler/2023.2.1
- which ifx
- ifx --version
- mkdir -p $OUTPUT_DIR
- echo "Compiling the code using ifx..."
- mkdir -p build
- cd build
- cmake3 -DCMAKE_BUILD_TYPE="Release" -DCMAKE_INSTALL_PREFIX="../bin" -DCMAKE_Fortran_COMPILER="ifx" ..
- make
- make install
- cd ..
- echo "Compile complete using ifx."
artifacts:
paths:
- bin/
tags:
- ifx
####################################################################################################
# compilation cleanup on failure
####################################################################################################
# cleanup build job
cleanup_build_job:
stage: cleanup_build
when: on_failure
script:
- echo "Performing cleanup tasks after failed build jobs"
- rm -r build
####################################################################################################
# test jobs
####################################################################################################
# unit test job - gfortran
test:gfortran:
stage: test
needs: ["build:gfortran"]
script:
# need to query modules before gcc can be found and loaded
- module avail
- module load gcc/13.2.0
- echo "Running unit tests..."
- cd $TEST_DIR/mnist
- make FC=gfortran-13.2.0 build
- ./bin/athena_test -f test_job.in >actual_output.txt
- python $COMPARE_OUTPUT expected_output_gfortran.txt actual_output.txt
- cd -
artifacts:
paths:
- $TEST_DIR/mnist/actual_output.txt
tags:
- gfortran
# unit test job - ifort
test:ifort:
stage: test
needs: ["build:ifort"]
script:
- module load compiler/2023.2.1
- echo "Running unit tests..."
- cd $TEST_DIR/mnist
- make FC=ifort build
- ./bin/athena_test -f test_job.in >actual_output.txt
- python $COMPARE_OUTPUT expected_output_ifort.txt actual_output.txt
- cd -
artifacts:
paths:
- $TEST_DIR/mnist/actual_output.txt
tags:
- ifort
# unit test job - ifx
test:ifx:
stage: test
needs: ["build:ifx"]
script:
- module load compiler/2023.2.1
- echo "Running unit tests..."
- cd $TEST_DIR/mnist
- make FC=ifx build
- ./bin/athena_test -f test_job.in >actual_output.txt
- python $COMPARE_OUTPUT expected_output_ifx.txt actual_output.txt
- cd -
artifacts:
paths:
- $TEST_DIR/mnist/actual_output.txt
tags:
- ifx
####################################################################################################
# test cleanup on success
####################################################################################################
# cleanup job after test jobs
cleanup_job:
stage: cleanup
when: on_success
script:
- echo "Performing cleanup tasks after jobs"
- rm -r build
- rm -r test/*/obj
- rm -r test/*/bin
- rm -r bin
# lint-test-job: # This job also runs in the test stage.
# stage: test # It can run at the same time as unit-test-job (in parallel).
# script:
# - echo "Linting code... This will take about 10 seconds."
# - sleep 10
# - echo "No lint issues found."
# deploy-job: # This job runs in the deploy stage.
# stage: deploy # It only runs when *both* jobs in the test stage complete successfully.
# environment: production
# script:
# - echo "Deploying application..."
# - echo "Application successfully deployed."