forked from NOAA-ORR-ERD/PyGnome
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
220 lines (190 loc) · 7.26 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
variables:
PYTHON_VER: "3.10"
IMAGE_NAME: "miniforge-python"
GIT_DEPTH: 2
stages:
- compile
- test
- build
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:
- echo "compiling PyGNOME"
- yum install gcc gcc-c++ make libXext libSM libXrender -y
# 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 --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/
- cd ./py_gnome
- python setup.py install
- cd ../ # make sure that it won't find the source gnome package.
- python -c "import gnome" # make sure that it imports
# need extra requirements for the docs
- conda install -y --file conda_requirements_docs.txt
- cd py_gnome/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 conda_requirements_test.txt
- cd ./py_gnome/tests/unit_tests && pytest --runslow
- 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/centos7-python$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
tags:
- windows
- visual-studio-22
allow_failure: true
before_script:
- Get-Location
- dir
- echo $CI_PIPELINE_ID
- activate ./$CI_PIPELINE_ID
- conda config --add channels defaults
- conda config --add channels conda-forge
- conda config --get channels
- conda config --set channel_priority strict
script:
- echo "Building and testing PyGNOME"
# make sure our conda package is first in the path
- $Env:Path = 'C:\ProgramData\Miniconda3\Library\bin;' + $Env:Path
- $Env:Path = 'C:\ProgramData\Miniconda3\;' + $Env:Path
- $Env:Path = 'C:\ProgramData\Miniconda3\Scripts;' + $Env:Path
- echo "Our environemt vars:"
- $Env:Path
- echo "Python is running from:"
- python -c "import sys; print(sys.executable)"
# 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
- 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
- echo "Building PyGNOME"
- cd ./py_gnome
# - python setup.py install
- python setup.py develop
# Make sure that it imports from some folder other than the
# gnome package folder.
# - cd ../
# - python -c "import gnome"
- 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
- 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:develop
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker push registry.orr.noaa.gov/gnome/pygnome:develop
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
- 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
- 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