-
Notifications
You must be signed in to change notification settings - Fork 44
/
.gitlab-ci.yml
265 lines (227 loc) · 9.21 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
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
variables:
PYTHON_VER: "3.10"
IMAGE_NAME: "ubuntu/ubuntuforge-python"
GIT_DEPTH: 2
stages:
- compile
- build
- test
cache:
paths:
- ./$CI_PIPELINE_ID
before_script:
- pwd
- echo $CI_PIPELINE_ID
- source activate ./$CI_PIPELINE_ID
configure_env:
stage: .pre
tags:
- docker
- linux
image: registry.orr.noaa.gov/erd/centos-conda/$IMAGE_NAME$PYTHON_VER
before_script:
- echo '' # manual override of before_script because we're on runner 12.3 and inherit options are only 12.9+
script:
- conda create --prefix ./$CI_PIPELINE_ID
artifacts:
expire_in: 5 days
paths:
- ./$CI_PIPELINE_ID
compile_pygnome:
stage: compile
tags:
- docker
- linux
image: registry.orr.noaa.gov/erd/centos-conda/$IMAGE_NAME$PYTHON_VER
script:
- apt-get update
- apt-get upgrade -y
- apt-get install git g++ make libxext-dev libsm-dev libxrender-dev -y
# # get the adios_db code: needed for tests and requirements
# no longer needed -- pygnome is pulling adios_db from conda-forge
# - git clone --depth 1 -b develop https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.orr.noaa.gov/gnome/oil_database/oil_database.git
- cd ./py_gnome
- conda install -y python=$PYTHON_VER --file conda_requirements.txt
--file conda_requirements_build.txt
# --file ../oil_database/adios_db/conda_requirements.txt
# # install adios_db
# - pip install ../oil_database/adios_db/
# Install pygnome
# If you want verbose output including the compiler/linker commands,
# run the following command:
# python -m build --no-isolation --config-setting cmake.verbose=true
#
# And there may be times we want to build a wheel file (.whl)
# The following command will build a wheel in the current directory:
# python -m pip wheel ./
- echo "compiling PyGNOME"
- python -m pip install ./
# need extra requirements for the docs
- conda install -y --file conda_requirements_docs.txt
- cd documentation && make html # build the docs
artifacts:
when: always
expire_in: 15 days
paths:
- ./$CI_PIPELINE_ID
- ./py_gnome/documentation/build/html
- ./conda_packages.txt
test_pygnome:
stage: test
tags:
- docker
- linux
allow_failure: false
image: registry.orr.noaa.gov/erd/centos-conda/$IMAGE_NAME$PYTHON_VER
script:
- conda install -y --file py_gnome/conda_requirements_test.txt
- cd ./py_gnome/tests/unit_tests && pytest --runslow
# save the package list if tests pass
- conda list > conda_packages.txt
# Ideally, all the scripts in "testing_scripts" should run without errors,
# but once in a while we refactor something that breaks something.
# So it would be good to get a warning from the CI.
# This shouldn't be a "it has to pass" job.
test_pygnome_scripts:
stage: test
tags:
- docker
- linux
allow_failure: true
image: registry.orr.noaa.gov/erd/centos-conda/$IMAGE_NAME$PYTHON_VER
script:
- cd ./py_gnome/scripts/testing_scripts && python run_all.py 2<&1
# We will not build a windows docker image, but we do want to know if there are
# any windows specific problems.
# So this job tries to compile PyGnome on Windows and run the pytests.
#
# Unfortunately, the Windows GitLab runner is running PowerShell, so it can't
# really be a true apples-to-apples test of a normal manual install on windows.
# Oh well, at least we can test the code.
test_pygnome_windows:
stage: test
when: manual
tags:
- windows
- visual-studio-22
allow_failure: true
cache: []
before_script:
- echo $CI_PIPELINE_ID
# where are we?
- Get-Location
- Get-ChildItem | % { $_.FullName } # this should list the current folder
- $Env:PathOrig = $Env:Path
- $Env:CurrDir = Get-Location
# Where is our conda installation?
# This will tell us where python is installed. This could change periodically
#- Get-ChildItem -Path 'C:\Python310' -Recurse -Include "python.exe", "conda.exe" | % { $_.FullName }
#- Get-ChildItem -Path 'C:\ProgramData\miniforge3' -Recurse -Include "python.exe", "conda.exe" | % { $_.FullName }
# make sure conda is on the path first in the path
- $Env:Path = 'C:\ProgramData\miniforge3\;' +
'C:\ProgramData\miniforge3\Scripts;' +
'C:\ProgramData\miniforge3\Lib\bin;' +
$Env:PathOrig
- $Env:Path -split ';'
- python -c "import sys; print(sys.executable)"
# This might be changing our current directory. It only needs to be run
# one time anyway, so we will comment it out.
#- Invoke-Expression "conda shell.powershell hook"
#- conda init powershell
# On SO, it was suggested that this would perform a `conda init`
# without needing to restart PowerShell. So we will test it.
- C:\ProgramData\miniforge3\shell\condabin\conda-hook.ps1
- conda config --add channels defaults
- conda config --add channels conda-forge
- conda config --get channels
- conda config --set channel_priority strict
- conda create -y -p ./pygnome python=$PYTHON_VER
#- $Env:Path = '' +
# (Get-Location) + '\pygnome\;' +
# (Get-Location) + '\pygnome\Scripts\;' +
# (Get-Location) + '\pygnome\Lib\bin\;' +
# $Env:PathOrig
- conda activate ./pygnome
script:
- echo "Building and testing PyGNOME"
# pulled from conda-forge now
# get the adios_db code: needed for tests and requirements
# - git clone --depth 1 -b develop https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.orr.noaa.gov/gnome/oil_database/oil_database.git
- conda install -y python=$PYTHON_VER mamba
- cd ./py_gnome
- echo "Setting up conda environment"
- mamba install -y python=$PYTHON_VER --file conda_requirements.txt
--file conda_requirements_build.txt
--file conda_requirements_test.txt
# --file ../oil_database/adios_db/conda_requirements.txt
# install adios_db
# - pip install ../oil_database/adios_db/
# Install pygnome
# If you want verbose output including the compiler/linker commands,
# run the following command:
# python -m build --no-isolation --config-setting cmake.verbose=true
#
# And there may be times we want to build a wheel file (.whl)
# The following command will build a wheel in the current directory:
# python -m pip wheel ./
- python -m pip install ./
- cd ./tests/unit_tests
- pytest --runslow
- cd ../../..
build_develop:
stage: build
only:
- develop
tags:
- shell
- build
before_script:
- echo '' # manual override of before_script because we're on runner 12.3 and inherit options are only 12.9+
script:
# get the adios_db code, so we can install it in the docker image
# note -- is should already be there from conda-forge
# - git clone --depth 1 -b develop https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.orr.noaa.gov/gnome/oil_database/oil_database.git
# build the py_gnome image
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker build . --build-arg PYTHON_VER=$PYTHON_VER -t registry.orr.noaa.gov/gnome/pygnome:$CI_COMMIT_BRANCH
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker push registry.orr.noaa.gov/gnome/pygnome:$CI_COMMIT_BRANCH
build_main:
stage: build
only:
- main
tags:
- shell
- build
before_script:
- echo '' # manual override of before_script because we're on runner 12.3 and inherit options are only 12.9+
script:
# get the adios_db code, so we can install it in the docker image
# note -- is should already be there -- from conda-forge
# - git clone --depth 1 -b production https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.orr.noaa.gov/gnome/oil_database/oil_database.git
# build the docs image
- docker build -f dockerfile-docs ./py_gnome/documentation/build/html -t registry.orr.noaa.gov/gnome/pygnome/docs
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker push registry.orr.noaa.gov/gnome/pygnome/docs
# build the py_gnome image
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker build . --build-arg PYTHON_VER=$PYTHON_VER -t registry.orr.noaa.gov/gnome/pygnome:main
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker push registry.orr.noaa.gov/gnome/pygnome:main
build_production:
stage: build
only:
- production
tags:
- shell
- build
before_script:
- echo ''
script:
# get the adios_db code, so we can install it in the docker image
# should be there from conda-forge
# - git clone --depth 1 -b production https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.orr.noaa.gov/gnome/oil_database/oil_database.git
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker build . --build-arg PYTHON_VER=$PYTHON_VER -t registry.orr.noaa.gov/gnome/pygnome:production
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker push registry.orr.noaa.gov/gnome/pygnome:production