-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.gitlab-ci.yml
236 lines (225 loc) · 8.15 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
235
236
workflow:
rules: # Do not create pipelines for tag updates
- if: $CI_COMMIT_TAG
when: never
- when: always
stages:
- environment
- test
- deploy
before_script:
# Assumes CI executes on AEA compute servers
- aea_compute_path="/projects/aea_compute"
- aea_modulefiles="${aea_compute_path}/modulefiles"
- module use ${aea_modulefiles}
- module load texlive
# Start with an AEA environment to put Conda on PATH
- environment_choices="aea-beta aea-quarterly aea-release"
- for env in ${environment_choices}; do if [[ -d "${aea_compute_path}/${env}" ]]; then environment=${env}; break; fi; done
- echo ${environment}
- module load ${environment}
# Activate CI environment if available. If not, rely on environment job running before other jobs.
- module use ${PWD}/modulefiles
- project_environment='turbo-turtle-dev'
- environment_path="${aea_compute_path}/${project_environment}"
- echo ${environment_path}
- if [[ -d ${environment_path} ]]; then module unload ${environment}; module load ${project_environment}; fi
- conda info
- conda_artifacts_directory='conda-bld'
- croot="/scratch/$USER/$(basename $PWD)/${conda_artifacts_directory}"
environment:
stage: environment
variables:
GIT_STRATEGY: clone
rules:
- if: $CI_PIPELINE_SOURCE == "schedule"
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
- if: $CI_COMMIT_BRANCH == "main"
script:
# Always build from the base/aea compute environment with boa/libmamba
- module unload ${project_environment}
- module load ${environment}
# Don't rebuild environment for merge request pipelines unless the environment is missing
- if [[ -d "${environment_path}" ]]; then exists=true; else exists=false; fi
- if [[ $CI_PIPELINE_SOURCE == "merge_request_event" ]] && ${exists}; then exit 0; fi
# Don't rebuild environment for main unless the environment file has changed or the environment doesn't exist
- files=$(git diff --name-only ${CI_COMMIT_SHA} ${CI_COMMIT_BEFORE_SHA}) || true
- if [[ $CI_COMMIT_BRANCH == "main" ]]; then production=true; else production=false; fi
- if [[ "${files}" == *"environment.yml"* ]]; then modified=true; else modified=false; fi
- if ${production} && ${exists} && ! ${modified}; then exit 0; fi
# Set LANL proxies
- export ALL_PROXY="proxyout.lanl.gov:8080"
- export HTTP_PROXY="http://$ALL_PROXY"
- export HTTPS_PROXY=$HTTP_PROXY
# Re-build the Conda environment on changes to environment files
- conda env create --prefix ${environment_path} --file environment.yml --solver=libmamba --force
# Remove write permissions from group to avoid accidental environment changes
- chmod -R 755 ${environment_path}
# place the common modulefiles in an accessible location
- cp ${PWD}/modulefiles/* ${aea_modulefiles}
# Link SCons man pages to the expected MANPATH location
- ln ${environment_path}/scons.1 ${environment_path}/man/man1/scons.1 || true
- ln ${environment_path}/sconsign.1 ${environment_path}/man/man1/sconsign.1 || true
- ln ${environment_path}/scons-time.1 ${environment_path}/man/man1/scons-time.1 || true
tags:
- shell-aea
test:
stage: test
variables:
GIT_STRATEGY: clone
rules:
- if: $CI_PIPELINE_SOURCE == "schedule"
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
script:
- |
if [[ $CI_PIPELINE_SOURCE == "schedule" ]]; then
abaqus_command='--abaqus-command=/apps/abaqus/Commands/abq2024 --abaqus-command=/apps/abaqus/Commands/abq2023'
cubit_command='--cubit-command=/apps/Cubit-16.16/cubit --cubit-command=/apps/Cubit-16.12/cubit'
else
abaqus_command=''
cubit_command=''
fi
- echo ${abaqus_command}
- echo ${cubit_command}
- scons regression ${abaqus_command} ${cubit_command}
coverage: '/(?i)total.*? (100(?:\.0+)?\%|[1-9]?\d(?:\.\d+)?\%)$/'
artifacts:
reports:
coverage_report:
coverage_format: cobertura
path: build/pytest/coverage.xml
tags:
- shell-aea
style:
stage: test
variables:
GIT_STRATEGY: clone
rules:
- if: $CI_PIPELINE_SOURCE == "schedule"
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
script:
- scons flake8 black-check
tags:
- shell-aea
conda-build:
stage: test
variables:
GIT_STRATEGY: clone
dependencies: []
rules:
- if: $CI_PIPELINE_SOURCE == "schedule"
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
- if: $CI_COMMIT_BRANCH == "main"
script:
# Set the LANL internal proxies
- export ALL_PROXY="proxyout.lanl.gov:8080"
- export HTTP_PROXY="http://$ALL_PROXY"
- export HTTPS_PROXY=$HTTP_PROXY
# Override default permissions. Set group to rx with no write permissions.
- umask 0022
- mkdir ${conda_artifacts_directory}
- VERSION=$(python -m setuptools_scm) conda mambabuild recipe-internal --channel conda-forge --no-anaconda-upload --croot ${croot} --output-folder ${conda_artifacts_directory}
- conda build purge --croot ${croot}
artifacts:
expire_in: '2 hrs'
paths:
- conda-bld/noarch/turbo_turtle-*-*.tar.bz2
tags:
- shell-aea
conda-build-external:
stage: test
variables:
GIT_STRATEGY: clone
dependencies: []
rules:
- if: $CI_PIPELINE_SOURCE == "schedule"
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
script:
# Set the LANL internal proxies
- export ALL_PROXY="proxyout.lanl.gov:8080"
- export HTTP_PROXY="http://$ALL_PROXY"
- export HTTPS_PROXY=$HTTP_PROXY
# Override default permissions. Set group to rx with no write permissions.
- umask 0022
- mkdir ${conda_artifacts_directory}
- VERSION=$(python -m setuptools_scm) conda mambabuild recipe --channel conda-forge --no-anaconda-upload --croot ${croot}/recipe-external --output-folder ${conda_artifacts_directory}
- conda build purge --croot ${croot}/recipe-external
tags:
- shell-aea
conda-build-matrix:
timeout: 4h
stage: test
variables:
GIT_STRATEGY: clone
dependencies: []
rules:
- if: $CI_PIPELINE_SOURCE == "schedule"
script:
# Set the LANL internal proxies
- export ALL_PROXY="proxyout.lanl.gov:8080"
- export HTTP_PROXY="http://$ALL_PROXY"
- export HTTPS_PROXY=$HTTP_PROXY
# Override default permissions. Set group to rx with no write permissions.
- umask 0022
- mkdir ${conda_artifacts_directory}
- pytest recipe-matrix/matrix.py -v --no-showlocals --tb=short
- conda build purge --croot ${croot}/recipe-matrix
tags:
- shell-aea
# https://re-git.lanl.gov/aea/developer-operations/aea-conda
aea-conda-deploy:
stage: deploy
rules:
- if: $CI_PIPELINE_SOURCE == "schedule"
when: never
- if: $CI_COMMIT_BRANCH == "main"
variables:
PARENT_CI_PROJECT_PATH: $CI_PROJECT_PATH
PARENT_CI_COMMIT_BRANCH: $CI_COMMIT_BRANCH
AEA_CONDA_PACKAGE_JOB: conda-build
AEA_CONDA_PACKAGE_ARTIFACTS: conda-bld/noarch/turbo_turtle-*-*.tar.bz2
trigger:
project: aea/developer-operations/aea-conda
branch: main
strategy: depend
pypi-deploy:
stage: deploy
variables:
GIT_STRATEGY: clone
dependencies: []
rules:
- if: $CI_PIPELINE_SOURCE == "schedule"
when: never
- if: $CI_COMMIT_BRANCH == "main"
script:
# Only deploy to Gitlab PyPI registry for clean version tags
- if [[ -z $(git tag --points-at HEAD) ]]; then exit 0; fi
- scons html-internal man
- cp -r build/docs/html-internal turbo_turtle/docs
- cp build/docs/man/*.1 turbo_turtle/docs
- python -m build
- TWINE_PASSWORD=${CI_JOB_TOKEN} TWINE_USERNAME=gitlab-ci-token python -m twine upload --repository-url ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/pypi dist/*
tags:
- shell-aea
# It MUST be called pages
pages:
stage: deploy
variables:
GIT_STRATEGY: clone
dependencies: []
rules:
- if: $CI_PIPELINE_SOURCE == "schedule"
when: never
- if: $CI_COMMIT_BRANCH == "main"
script:
- rm -rf public && mkdir -p public
# Ensure the ``_version.py`` file is created
- python -m setuptools_scm
- scons html-internal --clean && scons html-internal
- cp -r build/docs/html-internal/* public/
artifacts:
paths:
# It MUST be called public
- public
tags:
- shell-aea