.gitlab-ci.yml 13.7 KB
Newer Older
1 2
image: "skgland/pakcs-swi-ci:latest"

3 4
# set TEST_DOWNLOAD=yes to run the download test
# set BUILD_NIGHTLY=yes to build a nightly
5
# set TEST_RELEASE=yes to force build a release
6 7 8 9 10
# add a tag with name v<major>.<minor>.<release> to trigger a release

# CURRY_LANG_ORG_ACCESS_TOKEN should contain the access-token to update
# the curry-lang.org project, it SHOULD NOT be committed in the git project
# but configured via Gitlab Settings > CI > Variables and should at least be masked
11 12
# the corresponding username and associated email address is set bellow,
# using CURRY_LANG_USER and CURRY_LANG_EMAIL respectively
13 14

variables:
15 16
  # packs version to download from http://www.informatik.uni-kiel.de/~pakcs/download/
  # in the run_download_make job
17 18 19 20 21 22 23 24
  DOWNLOAD_VERSION: "2.3.0"
  # make sure LANG and LC_ALL are well defined
  LANG: "C.UTF-8"
  LC_ALL: "C.UTF-8"
  # move the stack root and cabal dir to a place where we can cache them
  STACK_ROOT: "${CI_PROJECT_DIR}/.stack-root"
  CABAL_DIR: "${CI_PROJECT_DIR}/.cabal/"
  # cypm configs
25
  CPM_VERSION: "2.3.0" # used in ci/before_make.sh
26
  # move .cpm dir to where we can cache it
27 28 29
  BIN_INSTALL_PATH: "${CI_PROJECT_DIR}/.cpm/bin" # also in ci/before_make.sh
  # make the ci checkout submodules recursively
  GIT_SUBMODULE_STRATEGY: recursive
30
  # configuration for the link_release and link_nightly jobs
31 32
  CURRY_LANG_USER: project_457_bot # the username corresponding to the access token
  CURRY_LANG_EMAIL: project457_bot@example.com # email without '_' before project id
33
  CURRY_LANG_PROJECT: curry/curry-lang.org
34
  CURRY_LANG_BRANCH: hakyll
35
  # versions to install using cypm for run_test and make_manual
Bennet Bleßmann's avatar
Bennet Bleßmann committed
36 37 38
  CURRY_CHECK_VERSION: "3.0.0"
  CURRY_DOC_VERSION: "3.0.0"
  MARKDOWN_VERSION: "3.3.0"
39

40 41 42 43 44 45 46 47
# due to the limitations that jobs of the same stage may not depend on each other
# release is split in package_release, release and package_upload
#
# curry-lang-ci is part of the workaround for issue:
# https://gitlab.com/gitlab-org/gitlab/-/issues/246784
# when this is fixes curry-lang-ci may be removed and the [skip ci]
# can be removed from the commit messages in the curry-lang jobs.before_script,
# keeping it this way would keep the pipelines linked potentially giving a better overview
48
stages:
49 50 51 52
  - make            # build pakcs
  - test            # run test suite and check versioned tag
  - doc             # build lib and manual
  - package_release # build distribution
53
  - upload_release  # create tar for webserver
54
  - tag_release     # create release
55 56
  - curry-lang      # commit updated download data to curry-lang.org repo
  - curry-lang-ci   # trigger curry-lang.org repo CI
57

58 59
# cache the stack root, cabal and cpm dir
# on a per branch basis
60 61 62 63 64 65 66
cache:
  key: "${CI_COMMIT_REF_SLUG}-stack_cache"
  paths:
    - .stack-root/
    - .cabal/
    - .cpm/

67
# always run except for the nightly download test run
68 69 70
run_make:
  stage: make
  tags: 
Bennet Bleßmann's avatar
Bennet Bleßmann committed
71
    - docker2
72 73
  rules:
    - if: '$CI_PIPELINE_SOURCE == "push"'
Bennet Bleßmann's avatar
Bennet Bleßmann committed
74
    - if: '$CI_COMMIT_TAG != null'
75
    - if: '$BUILD_NIGHTLY == "yes"'
76
    - if: '$TEST_RELEASE == "yes"'
77
  before_script:
78
    - source ci/section_helper.sh
79
    - start_section before_script "Preparing for Job"
80 81
    - export PATH="${CI_PROJECT_DIR}/bin:${BIN_INSTALL_PATH}:${PATH}"
    - echo ${PATH}
Bennet Bleßmann's avatar
Bennet Bleßmann committed
82
    - time ./ci/before_make.sh
83 84
    # prevent the build stages from disagreeing over the date by generating it once at the start
    - export BUILD_DATE="$(date +%F)"
85
    - end_section before_script
86
  script:
87
    - start_section main_script "Building PAKCS"
88
    - time make CI_BUILD=yes COMPILERDATE="${BUILD_DATE}"
89 90 91
    - |
      BUILD_PAKCS_VERSION="$("${CI_PROJECT_DIR}"/bin/pakcs --numeric-version)"
      BUILD_PAKCS_ARCH="$(dpkg-architecture -qDEB_BUILD_ARCH)-$(uname -s)"
Bennet Bleßmann's avatar
Bennet Bleßmann committed
92 93 94
      echo "BUILD_PAKCS_VERSION=${BUILD_PAKCS_VERSION}
      BUILD_PAKCS_ARCH=${BUILD_PAKCS_ARCH}
      BUILD_DATE=${BUILD_DATE}" >> make.env
95
    - end_section main_script
96
  artifacts:
97 98 99
    reports:
      dotenv:
        - make.env
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
    paths:
      # this are currently all files that are added from a clean state during `make CI_BUILD=yes`
      - "**/.curry"
      - "**/dist"
      - bin
      - currytools/cpm/src/CPM.Main
      - currytools/optimize/BindingOpt
      - frontend/bin
      - frontend/pkg
      - lib
      - pakcsinitrc
      - scripts/makesavedstate
      - src/pakcs
      - src/pakcsversion.pl
      - src/prologbasics.pl

Bennet Bleßmann's avatar
Bennet Bleßmann committed
116 117
# template for test_download_src and test_download_amd64_linux
.test_download:
118 119
  stage: test
  tags:
Bennet Bleßmann's avatar
Bennet Bleßmann committed
120
    - docker2
121
  rules:
Bennet Bleßmann's avatar
Bennet Bleßmann committed
122
    # only run for the nightly download test run
123
    - if: '$TEST_DOWNLOAD == "yes"'
124
  variables:
125 126
    # may differ from default version above if download and current branch don't use the same version
    CURRY_CHECK_VERSION: "2.0.0"
Bennet Bleßmann's avatar
Bennet Bleßmann committed
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141
  timeout: 2h
  before_script:
    - source ci/make_download.sh
  script:
    - build_download_pakcs "${DOWNLOAD_VERSION}" tar_version

# instance of .test_download to test src tar
test_download_src:
  extends: .test_download
  script:
    - build_download_pakcs "${DOWNLOAD_VERSION}" src

# instance of .test_download to test amd64-Linux tar
test_download_amd64_linux:
  extends: .test_download
142
  script:
Bennet Bleßmann's avatar
Bennet Bleßmann committed
143
    - build_download_pakcs "${DOWNLOAD_VERSION}" amd64-Linux
144

145 146 147 148 149
# check that the tag version matches pakcs version
# this failing indicates an incorrect tag version or
# having forgotten to bump pakcs version
check_version:
  stage: test
150 151 152
  needs:
    - job: "run_make"
      artifacts: true
153
  rules:
Bennet Bleßmann's avatar
Bennet Bleßmann committed
154
    - if: '$CI_COMMIT_TAG =~ /^v\d*\.\d*\.\d*$/i'
155
    - if: '$TEST_RELEASE == "yes"'
156
  script:
157
    - ci/check_tag_version.sh
158 159

# run_make is run except for the nightly download test run
160 161 162
run_test:
  stage: test
  tags:
Bennet Bleßmann's avatar
Bennet Bleßmann committed
163
    - docker2
164 165
  rules:
    - if: '$CI_PIPELINE_SOURCE == "push"'
Bennet Bleßmann's avatar
Bennet Bleßmann committed
166
    - if: '$CI_COMMIT_TAG != null'
167
    - if: '$BUILD_NIGHTLY == "yes"'
168
    - if: '$TEST_RELEASE == "yes"'
169 170 171 172
  needs:
    - job: "run_make"
      artifacts: true
  before_script:
173
    - source ci/section_helper.sh
174
    - start_section before_script "Preparing for Job"
175 176 177
    - export PATH="${CI_PROJECT_DIR}/bin:${BIN_INSTALL_PATH}:${PATH}"
    - echo ${PATH}
    - ./ci/before_make.sh
178 179
    - end_section before_script
    - start_section cypm "Updating cypm index and installing tools"
180
    - ./bin/pakcs-cypm config
Bennet Bleßmann's avatar
Bennet Bleßmann committed
181 182 183 184 185
    - |
      set -ve
      source ci/cypm_helper.sh
      cypm_update
      cypm_install_binary currycheck "${CURRY_CHECK_VERSION}"
186
    - end_section cypm
187
  script:
188
    - start_section main_script "Running Testsuite"
Bennet Bleßmann's avatar
Bennet Bleßmann committed
189
    - time make CI_BUILD=yes runalltests RUNTESTPARAMS=-v
190
    - end_section main_script "Building Manual"
191

192
# run for the nightly and release runs
193 194 195
make_manual:
  stage: doc
  tags:
Bennet Bleßmann's avatar
Bennet Bleßmann committed
196
    - docker2
197
  rules:
Bennet Bleßmann's avatar
Bennet Bleßmann committed
198
    - if: '$CI_COMMIT_TAG != null'
199
    - if: '$BUILD_NIGHTLY == "yes"'
200
    - if: '$TEST_RELEASE == "yes"'
201 202 203
  needs:
    - job: "run_make"
      artifacts: true
204
  timeout: 4h
205
  before_script:
206
    - source ci/section_helper.sh
207
    - start_section before_script "Preparing for Job"
208 209 210 211
    - export PATH="${CI_PROJECT_DIR}/bin:${BIN_INSTALL_PATH}:${PATH}"
    - echo ${PATH}
    - ./ci/before_make.sh
    - ./bin/pakcs-cypm config
212 213
    - end_section before_script # ending this here as I want a separate section for the cypm stuff and nested section appear to have problems
    - start_section cypm "Updating cypm index and installing tools"
Bennet Bleßmann's avatar
Bennet Bleßmann committed
214 215 216
    - |
      set -ve
      source ci/cypm_helper.sh
217 218 219
      time cypm_update
      time cypm_install_binary currydoc "${CURRY_DOC_VERSION}"
      time cypm_install_binary markdown "${MARKDOWN_VERSION}"
220
    - end_section cypm
221
  script:
222
    - start_section main_script "Building Manual"
223
    - time make CI_BUILD=yes COMPILERDATE="${BUILD_DATE}" manual
224
    - echo "MANUAL_JOB_ID=${CI_JOB_ID}" >> manual.env
225
    - end_section main_script
226 227 228 229 230 231 232 233
  artifacts:
    paths:
      - docs/**.pdf
      - docs/**.html
    reports:
      dotenv:
        - manual.env

234 235
# run for the nightly and release runs
# builds the distribution
236
bundle_tar:
237
  stage: package_release
238
  tags:
Bennet Bleßmann's avatar
Bennet Bleßmann committed
239
    - docker2
240 241 242 243 244 245
  needs:
    - job: "run_make"
      artifacts: true
    - job: "make_manual"
      artifacts: true
  rules:
Bennet Bleßmann's avatar
Bennet Bleßmann committed
246
    - if: '$CI_COMMIT_TAG != null'
247
    - if: '$BUILD_NIGHTLY == "yes"'
248
    - if: '$TEST_RELEASE == "yes"'
249 250 251 252 253
  before_script:
    - export PATH="${CI_PROJECT_DIR}/bin:${BIN_INSTALL_PATH}:${PATH}"
    - echo ${PATH}
    - ./ci/before_make.sh
  script:
254
    - time make CI_BUILD=yes DIST_DATE="${BUILD_DATE}" COMPILERDATE="${BUILD_DATE}" dist
255 256 257 258 259 260 261 262
    - echo "BUNDLE_JOB_ID=${CI_JOB_ID}" >> bundle.env
  artifacts:
    reports:
      dotenv:
        - bundle.env
    paths:
      - pakcs-*.tar.gz

263
upload_release:
264
  stage: upload_release
265
  tags:
Bennet Bleßmann's avatar
Bennet Bleßmann committed
266
    - docker2
267 268
  rules:
    # only for tags matching the versioning scheme v<major>.<minor>.<release>
Bennet Bleßmann's avatar
Bennet Bleßmann committed
269
    - if: '$CI_COMMIT_TAG =~ /^v\d*\.\d*\.\d*$/i'
270
    - if: '$TEST_RELEASE == "yes"'
271
  needs:
272
    - job: "check_version" # don't publish a release when the check failed
273 274 275 276 277 278
    - job: "run_make"
      artifacts: true     # need pakcs binary to determine version
    - job: "make_manual"  # needed for Manual.pdf
      artifacts: true
    - job: "bundle_tar"   # needed for pakcs-<version>-src.tar.gz and pakcs-<version>-<arch>.tar.gz
      artifacts: true
279 280 281
  script: ci/upload_release.sh release

upload_nightly:
282
  stage: upload_release
283
  tags:
Bennet Bleßmann's avatar
Bennet Bleßmann committed
284
    - docker2
285 286
  rules:
      - if: '$BUILD_NIGHTLY == "yes"'
287 288 289 290 291 292 293
  needs:
    - job: "run_make"
      artifacts: true     # need pakcs binary to determine version
    - job: "make_manual"  # needed for Manual.pdf
      artifacts: true
    - job: "bundle_tar"   # needed for pakcs-<version>-src.tar.gz and pakcs-<version>-<arch>.tar.gz
      artifacts: true
294 295
  script: ci/upload_release.sh nightly

296
# run for release runs
297 298
# generate a .tar for the files that should be deployed for the updated pakcs download page
upload_page_tar:
299
  stage: upload_release
300
  tags:
Bennet Bleßmann's avatar
Bennet Bleßmann committed
301
    - docker2
302
  rules:
Bennet Bleßmann's avatar
Bennet Bleßmann committed
303
      - if: '$CI_COMMIT_TAG != null'
304
      - if: '$TEST_RELEASE == "yes"'
305 306
  needs:
    - job: "run_make"
307
      artifacts: true # need environment variables for build_pakcs_version
308 309 310 311 312 313 314 315
    - job: "make_manual"
      artifacts: true
    - job: "bundle_tar"
      artifacts: true
  variables:
    PUBLIC_HTML: "${CI_PROJECT_DIR}/public_html"
    PUBLIC_DOWNLOAD: "${CI_PROJECT_DIR}/public_html/download"
  before_script:
Bennet Bleßmann's avatar
Bennet Bleßmann committed
316
    - mkdir -p "${PUBLIC_HTML}" "${PUBLIC_DOWNLOAD}"
317 318 319 320 321
  script:
    # copy current distribution into latest release
    - cp -p pakcs*.tar.gz "${PUBLIC_DOWNLOAD}"
    # copy manual
    - cp -p docs/Manual.pdf "${PUBLIC_HTML}"
322
    - cp -p docs/Manual.pdf "${PUBLIC_DOWNLOAD}/pakcs-${BUILD_PAKCS_VERSION}-manual.pdf"
323 324 325 326 327 328 329 330 331 332 333 334 335 336
    - cp -p docs/markdown_syntax.html "${PUBLIC_HTML}"
    # copy release notes etc
    - |
      cp -p OLDRELNOTES.html \
            CHANGELOG.html \
            RESOURCES.html \
            docs/RELNOTES.html \
            docs/INSTALL.html \
            docs/GITINSTALL.html \
            "${PUBLIC_HTML}"
  artifacts:
    paths:
      - "${PUBLIC_HTML}"

337

338
# TODO release asset links accessible without being logged in see [Issue 289848](https://gitlab.com/gitlab-org/gitlab/-/issues/289848)
339 340 341
# run for release runs triggered by version tag
tag_release:
  stage: tag_release
342 343 344
  # this docker image MUST be used for a release job
  # see https://docs.gitlab.com/ee/ci/yaml/#release for reference
  image: registry.gitlab.com/gitlab-org/release-cli:latest
345
  tags:
Bennet Bleßmann's avatar
Bennet Bleßmann committed
346
    - docker2
347 348
  rules:
    # only for tags matching the versioning scheme v<major>.<minor>.<release>
Bennet Bleßmann's avatar
Bennet Bleßmann committed
349
    - if: '$CI_COMMIT_TAG =~ /^v\d*\.\d*\.\d*$/i'
350
    - if: '$TEST_RELEASE == "yes"'
Bennet Bleßmann's avatar
Bennet Bleßmann committed
351
  needs:
352
    - job: "check_version" # don't publish a release when the check failed
353
    - job: "run_make"
354
      artifacts: true # need environment variables for build_pakcs_version
355
    - job: upload_release # wait for upload
356
  script:
357 358
    - apk add --no-cache bash
    - ci/gitlab_release.sh
359

360 361
# run for nightly runs
# update the latest_nightly.version in the curry-lang.org repo
362
link_nightly:
363
  stage: curry-lang
364 365
  # make sure link nightly and link release don't run concurrently
  resource_group: link
366
  tags:
Bennet Bleßmann's avatar
Bennet Bleßmann committed
367
    - docker2
368 369
  rules:
    - if: '$BUILD_NIGHTLY == "yes"'
370
      when: on_success # wait for previous stage to finish
371 372
  needs:
    - job: "run_make"
373
      artifacts: true # need environment variables for build_pakcs_version
374 375 376 377
    - job: "bundle_tar"
      artifacts: true # need environment variables for bundle_job_id
    - job: "make_manual"
      artifacts: true # need environment variables for manual_job_id
378
    # - job: upload_nightly # wait for upload, TODO link to package files rather than artifacts
379
  script:
Bennet Bleßmann's avatar
Bennet Bleßmann committed
380
    - ci/update_version.sh nightly
381

382 383 384 385

# run for release runs
link_release:
  stage: curry-lang
386 387
  # make sure link nightly and link release don't run concurrently
  resource_group: link
388
  tags:
Bennet Bleßmann's avatar
Bennet Bleßmann committed
389
    - docker2
390 391
  rules:
    # only for tags matching the versioning scheme v<major>.<minor>.<release>
Bennet Bleßmann's avatar
Bennet Bleßmann committed
392
    - if: '$CI_COMMIT_TAG =~ /^v\d*\.\d*\.\d*$/i'
393 394 395
      when: on_success # wait for previous stage to finish
    - if: '$TEST_RELEASE == "yes"'
      when: on_success # wait for previous stage to finish
396
  needs:
397
    - job: "check_version" # don't publish a release when the check failed
398
    - job: "run_make"
399
      artifacts: true # need environment variables for build_pakcs_version
400
    - job: tag_release # wait for release as we are hyperlinking to release assets
401
  script:
402
    - ci/update_version.sh release
403 404

# run for nightly and release runs
405
# the commit done by the link_nightly job should be enough once https://gitlab.com/gitlab-org/gitlab/-/issues/246784 is fixed
406
# it may still be wanted to keep it this way to keep the pipelines linked
407
downstream:
408
  stage: curry-lang-ci
409
  rules:
Bennet Bleßmann's avatar
Bennet Bleßmann committed
410
    - if: '$CI_COMMIT_TAG =~ /^v\d*\.\d*\.\d*$/i'
411
      when: on_success # wait for previous stage to finish
412
    - if: '$TEST_RELEASE == "yes"'
413
      when: on_success # wait for previous stage to finish
414 415 416 417 418
    - if: '$BUILD_NIGHTLY == "yes"'
      when: on_success # wait for previous stage to finish
  trigger:
    project: curry/curry-lang.org
    branch: "${CURRY_LANG_BRANCH}"
419
    strategy: depend