forked from MFlowCode/MFC
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
117 lines (95 loc) · 3.14 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
# CI Workflow for MFC running Ascent @ ORNL through GitLab.
# GitLab: https://docs.gitlab.com/ee/ci/variables/predefined_variables.html
# - User Set:
# - $GIT_STRATEGY: none -> Runner should not clone repository before executing script
# - User Read:
# - $CI_PROJECT_NAME -> e.g MFC, MFC-develop, ...
# - $CI_REPOSITORY_URL -> e.g https://gitlab-ci-token:[MASKED]@code.ornl.gov/ecpcitest/cfd154/MFC-develop.git
# - $CI_COMMIT_REF_SLUG -> e.g GPU, master, v4.0.0, hypoelastic, ...
# ORNL's Ascent:
# - User Set:
# - $SCHEDULER_PARAMETERS
# - User Read:
# - $MEMBERWORK -> e.g /gpfs/wolf/scratch/henrylb
stages:
- main
# Variables for all jobs
variables:
# Tell runner to not clone MFC
GIT_STRATEGY: none
# Ascent Job Scheduler parameters
SCHEDULER_PARAMETERS: "-P CFD154 -nnodes 1 -W 00:30"
# This script runs before each job's main script is executed.
# It defines useful environment variables used at runtime.
before_script:
# Check "$CI_PROJECT_NAME" contains "MFC" so we are sure
# we won't clone into or delete from an unsuspecting directory
# due to an unfortunate error.
- echo "[CI] Running in $(pwd):"
- if [[ ! "$CI_PROJECT_NAME" == *"MFC"* ]]; then exit 1; fi;
# (Tidy) Delete clones/builds on the same branch older than 10 days
- echo "Removing:"
- export CI_MFC_BRANCH_DIR="$MEMBERWORK/cfd154/.ci/$CI_PROJECT_NAME/$CI_COMMIT_REF_SLUG"
- mkdir -p "$CI_MFC_BRANCH_DIR"
- find "$CI_MFC_BRANCH_DIR" -mindepth 1 -maxdepth 1 -type d -mtime +10 | sed s/^/\ -\ Removing\ /g
- find "$CI_MFC_BRANCH_DIR" -mindepth 1 -maxdepth 1 -type d -mtime +10 | xargs rm -rf
# Define MFC directory path
- CI_MFC_DIR="$CI_MFC_BRANCH_DIR/$CI_COMMIT_SHORT_SHA"
.clone:
stage: main
script:
# Clean MFC directory if it exists (from a previous run)
- if [ -d "$CI_MFC_DIR/$JOB_MODE" ]; then rm -rf "$CI_MFC_DIR/$JOB_MODE"; fi
# Clone MFC into MFC directory & cd into it
- mkdir -p "$CI_MFC_DIR/$JOB_MODE/"
- git clone --single-branch --branch "$CI_COMMIT_REF_NAME" "$CI_REPOSITORY_URL" "$CI_MFC_DIR/$JOB_MODE/"
tags:
- nobatch
.build:
stage: main
script:
- cd "$CI_MFC_DIR/$JOB_MODE" && echo "[CI] Building in $(pwd):"
- . ./mfc.sh load -c a -m $(if [ "$(echo "$JOB_MODE" | grep -i 'cpu' | wc -c)" -gt 0 ]; then echo "c"; else echo "g"; fi)
- ./mfc.sh build -j 8 -m "$JOB_MODE"
tags:
- nobatch
.test:
stage: main
script:
- cd "$CI_MFC_DIR/$JOB_MODE" && echo "[CI] Running in $(pwd):"
- . ./mfc.sh load -c a -m $(if [ "$(echo "$JOB_MODE" | grep -i 'cpu' | wc -c)" -gt 0 ]; then echo "c"; else echo "g"; fi)
- ./mfc.sh test -j 8 -m "$JOB_MODE"
tags:
- batch
clone-cpu:
variables:
JOB_MODE: "release-cpu"
extends: .clone
build-cpu:
variables:
JOB_MODE: "release-cpu"
extends: .build
needs:
- clone-cpu
test-cpu:
variables:
JOB_MODE: "release-cpu"
extends: .test
needs:
- build-cpu
clone-gpu:
variables:
JOB_MODE: "release-gpu"
extends: .clone
build-gpu:
variables:
JOB_MODE: "release-gpu"
extends: .build
needs:
- clone-gpu
test-gpu:
variables:
JOB_MODE: "release-gpu"
extends: .test
needs:
- build-gpu