.gitlab-ci.yml 5.83 KB
Newer Older
1
#############################################################################
2
3
4
5
# This file defines the build process for fslpy, as hosted at:
#
#    https://git.fmrib.ox.ac.uk/fsl/fslpy
#
Paul McCarthy's avatar
Paul McCarthy committed
6
# The build pipeline comprises the following stages:
7
8
9
#
#    1. test:   Unit tests
#
Paul McCarthy's avatar
Paul McCarthy committed
10
#    2. style:  Check coding style
11
#
Paul McCarthy's avatar
Paul McCarthy committed
12
#    3. doc:    Building and upload API documentation using GitLab Pages.
13
#
14
#    4. build:  Building source and wheel distributions
Paul McCarthy's avatar
Paul McCarthy committed
15
#
Paul McCarthy's avatar
Paul McCarthy committed
16
17
#    5. deploy: Uploading the build outputs to pypi/hosting servers.
#
18
#
Paul McCarthy's avatar
Paul McCarthy committed
19
20
21
22
23
# Custom docker images are used for several jobs - these images are
# available at:
#
#    https://hub.docker.com/u/pauldmccarthy/
#
Paul McCarthy's avatar
Paul McCarthy committed
24
# The test and style stages are executed on all branches of upstream and fork
25
26
# repositories.
#
Paul McCarthy's avatar
Paul McCarthy committed
27
# The doc stage is executed on release branches of the upstream repository.
28
#
Paul McCarthy's avatar
Paul McCarthy committed
29
30
# The build and deploy stages are executed on tags on the upstream
# repository, and the deploy stage must be manually instantiated.
31
32
33
34
#
# Most of the logic for each job is defined in shell scripts in the .ci
# sub-directory.
#############################################################################
35
36
37
38


stages:
 - test
Paul McCarthy's avatar
Paul McCarthy committed
39
 - style
40
41
42
43
44
 - doc
 - build
 - deploy


45
#################################################################################
46
47
48
49
50
51
52
53
54
55
# A number of variables must be set for the jobs to work. The following
# variables are implicitly defined in any gitlab CI job:
#
#   - CI_PROJECT_PATH    - gitlab namespace/project
#   - CI_COMMIT_REF_NAME - branch name, provided by gitlab
#   - CI_COMMIT_TAG      - present if build is running on a tag
#
# These variables must be explicitly set as "secret" variables:
#
#   - SSH_PRIVATE_KEY_GIT            - private key for git login to remote host
Paul McCarthy's avatar
Paul McCarthy committed
56
57
58
59
#                                      (UPSTREAM_URL)
#
#   - SSH_PRIVATE_KEY_FSL_DOWNLOAD   - private key for downloading some FSL
#                                      files from a remote server (FSL_HOST)
60
61
62
#
#   - SSH_SERVER_HOSTKEYS            - List of trusted SSH hosts
#
63
#   - FSL_HOST:                      - Username@host to download FSL data from
Paul McCarthy's avatar
Paul McCarthy committed
64
#                                      (most likely "paulmc@localhost")
65
#
66
67
68
#   - FSL_ATLAS_DIR:                 - Location of the FSL atlas data on
#                                      FSL_HOST.
#
69
70
#   - TWINE_USERNAME:                - Username to use when uploading to pypi
#
71
#   - TWINE_PASSWORD:                - Password to use when uploading to pypi
72
73
#
#   - TWINE_REPOSITORY_URL:          - Pypi repository to upload to
74
75
76
77
78
79
#
#   - ZENODO_URL:                    - Zenodo URL to deposit release file to.
#
#   - ZENODO_TOKEN:                  - Zenodo access token.
#
#   - ZENODO_DEPOSIT_ID:             - Deposit ID of previous Zenodo deposit.
80
81
82
83
###############################################################################


variables:
84
85
  UPSTREAM_PROJECT: "fsl/fslpy"
  UPSTREAM_URL:     "git@git.fmrib.ox.ac.uk"
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103


####################################
# These anchors are used to restrict
# when and where jobs are executed.
####################################


.only_upstream: &only_upstream
  only:
    - branches@fsl/fslpy


.only_master: &only_master
  only:
    - master@fsl/fslpy


Paul McCarthy's avatar
Paul McCarthy committed
104
105
106
107
108
.only_release_branches: &only_release_branches
  only:
    - /^v.+$/@fsl/fslpy


109
110
111
112
113
114
115
116
117
118
119
120
.only_releases: &only_releases
  only:
    - tags@fsl/fslpy


.except_releases: &except_releases
  except:
    - tags


.setup_ssh: &setup_ssh
  before_script:
121
    - bash ./.ci/setup_ssh.sh
122
123
124


###################################################
125
# The check_version anchor contains a before_script
126
127
128
129
130
131
# section which is run on release builds, and makes
# sure that the version in the code is up to date
# (i.e. equal to the tag name).
###################################################


132
.check_version: &check_version
133
  before_script:
134
    - bash ./.ci/check_version.sh
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151


############
# Test stage
############


.test: &test_template
  <<: *setup_ssh

  # Releases are just tags on a release
  # branch, so we don't need to test them.
  <<: *except_releases

  tags:
    - docker

Paul McCarthy's avatar
Paul McCarthy committed
152
  script:
153
    - bash ./.ci/test_template.sh
154

155

156
test:3.7:
157
  stage: test
158
  image: pauldmccarthy/fsleyes-py37-wxpy4-gtk3
159
  <<: *test_template
160
161


162
test:3.8:
163
  stage: test
164
  image: pauldmccarthy/fsleyes-py38-wxpy4-gtk3
165
166
167
  <<: *test_template


Paul McCarthy's avatar
Paul McCarthy committed
168
169
170
171
172
173
test:3.9:
  stage: test
  image: pauldmccarthy/fsleyes-py39-wxpy4-gtk3
  <<: *test_template


Paul McCarthy's avatar
Paul McCarthy committed
174
175
test:build-pypi-dist:
  stage: test
176
  image: pauldmccarthy/fsleyes-py36-wxpy4-gtk3
Paul McCarthy's avatar
Paul McCarthy committed
177
178
179
180
181
182
183
184
185
186
  <<: *except_releases

  tags:
    - docker

  script:
   - source /test.venv/bin/activate
   - bash ./.ci/build_pypi_dist.sh


Paul McCarthy's avatar
Paul McCarthy committed
187
188
189
190
191
192
193
#############
# Style stage
#############


style:
  stage: style
194
  image: pauldmccarthy/fsleyes-py36-wxpy4-gtk3
195
196
197
  <<: *test_template
  variables:
    TEST_STYLE:  "true"
Paul McCarthy's avatar
Paul McCarthy committed
198
199


Paul McCarthy's avatar
Paul McCarthy committed
200
201
202
203
204
205
206
207
208
#############
# Pages stage
#############

# I would like to have separate doc deploys for
# both the master and latest release branches,
# but this is awkward with gitlab pages. So
# currently the most recently executed pages
# job is the one that gets deployed.
209

Paul McCarthy's avatar
Paul McCarthy committed
210
211
pages:
  <<: *only_release_branches
212
213
214
215
216

  tags:
   - docker

  stage: doc
Paul McCarthy's avatar
Paul McCarthy committed
217
  image: python:3.7
218

Paul McCarthy's avatar
Paul McCarthy committed
219
  script:
220
221
    - bash ./.ci/build_doc.sh

222
223
  artifacts:
    paths:
Paul McCarthy's avatar
Paul McCarthy committed
224
      - public
225
226
227
228
229
230
231


#############
# Build stage
#############


232
build-pypi-dist:
233
  <<: *only_releases
234
  <<: *check_version
235
236

  stage: build
Paul McCarthy's avatar
Paul McCarthy committed
237
  image: python:3.7
Paul McCarthy's avatar
Paul McCarthy committed
238

239
240
  tags:
    - docker
241
242

  script:
243
244
245
246
247
248
249
250
   - bash ./.ci/build_pypi_dist.sh

  artifacts:
    expire_in: 1 day
    paths:
      - dist/*


251
252
253
254
255
256
257
258
259
260
##############
# Deploy stage
##############


deploy-pypi:
  <<: *only_releases
  <<: *setup_ssh
  stage: deploy
  when:  manual
Paul McCarthy's avatar
Paul McCarthy committed
261
  image: python:3.7
262
263
264
265
266

  tags:
    - docker

  dependencies:
267
    - build-pypi-dist
268
269

  script:
270
    - bash ./.ci/deploy_pypi.sh
271
272


Paul McCarthy's avatar
Paul McCarthy committed
273
deploy-zenodo:
274
275
276
277
  <<: *only_releases
  <<: *setup_ssh
  stage: deploy
  when:  manual
Paul McCarthy's avatar
Paul McCarthy committed
278
  image: python:3.7
279
280
281
282
283
284
285
286
287

  tags:
    - docker

  dependencies:
    - build-pypi-dist

  script:
    - bash ./.ci/zenodo_deposit.sh "$ZENODO_URL" "$ZENODO_TOKEN" "$ZENODO_DEPOSIT_ID"