.gitlab-ci.yml 19.2 KB
Newer Older
1 2
variables:
  GIT_SSL_NO_VERIFY: "1"
3

4
  # Commit of ghc/ci-images repository from which to pull Docker images
5
  DOCKER_REV: cefaee3c742af193e0f7783f87edb0d35374515c
6 7 8 9 10 11

before_script:
  - python3 .gitlab/fix-submodules.py
  - git submodule sync --recursive
  - git submodule update --init --recursive
  - git checkout .gitmodules
12
  - "git fetch https://gitlab.haskell.org/ghc/ghc-performance-notes.git refs/notes/perf:refs/notes/perf || true"
13

Ben Gamari's avatar
Ben Gamari committed
14
stages:
15 16 17 18 19 20
  - lint       # Source linting
  - build      # A quick smoke-test to weed out broken commits
  - full-build # Build all the things
  - cleanup    # See Note [Cleanup on Windows]
  - packaging  # Source distribution, etc.
  - hackage    # head.hackage testing
21
  - deploy     # push documentation
Ben Gamari's avatar
Ben Gamari committed
22

23 24 25 26 27 28 29
.only-default: &only-default
  only:
    - master
    - /ghc-[0-9]+\.[0-9]+/
    - merge_requests
    - tags

Ben Gamari's avatar
Ben Gamari committed
30
############################################################
31
# Runner Tags
Ben Gamari's avatar
Ben Gamari committed
32 33 34 35 36 37 38 39 40 41
############################################################
#
# * x86_64-linux: Any Docker-capable x86_64 Linux machine
# * aarch64-linux: Any Docker-capable AArch64 Linux machine
# * x86_64-windows: A x86_64 Windows machine
# * lint: Any Docker-capable x86_64 Linux machine; distinct from
#         x86_64-linux to ensure low-latency availability.
#


Ben Gamari's avatar
Ben Gamari committed
42 43 44 45 46
############################################################
# Linting
############################################################

ghc-linters:
47
  allow_failure: true
Ben Gamari's avatar
Ben Gamari committed
48
  stage: lint
49
  image: "registry.gitlab.haskell.org/ghc/ci-images/linters:$DOCKER_REV"
Ben Gamari's avatar
Ben Gamari committed
50
  script:
51 52
    - git fetch origin $CI_MERGE_REQUEST_TARGET_BRANCH_NAME
    - base="$(git merge-base FETCH_HEAD $CI_COMMIT_SHA)"
Ben Gamari's avatar
Ben Gamari committed
53
    - "echo Merge base $base"
54 55 56 57
    #    - validate-commit-msg .git $(git rev-list $base..$CI_COMMIT_SHA)
    - validate-whitespace .git $(git rev-list $base..$CI_COMMIT_SHA)
    - .gitlab/linters/check-makefiles.py $base $CI_COMMIT_SHA
    - .gitlab/linters/check-cpp.py $base $CI_COMMIT_SHA
58
  dependencies: []
Ben Gamari's avatar
Ben Gamari committed
59 60
  tags:
    - lint
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
  only:
    refs:
      - merge_requests

# We allow the submodule checker to fail when run on merge requests (to
# accomodate, e.g., haddock changes not yet upstream) but not on `master` or
# Marge jobs.
.lint-submods:
  stage: lint
  image: "registry.gitlab.haskell.org/ghc/ci-images/linters:$DOCKER_REV"
  script:
    - submodchecker .git $(git rev-list $base..$CI_COMMIT_SHA)
  dependencies: []
  tags:
    - lint

lint-submods:
  extends: .lint-submods
  only:
    refs:
      - master
      - /ghc-[0-9]+\.[0-9]+/
      - wip/marge_bot_batch_merge_job

lint-submods-mr:
  extends: .lint-submods
  allow_failure: true
  only:
    refs:
      - merge_requests
Ben Gamari's avatar
Ben Gamari committed
91

Ben Gamari's avatar
Ben Gamari committed
92 93 94
############################################################
# Validation via Pipelines (hadrian)
############################################################
95

Ben Gamari's avatar
Ben Gamari committed
96
.validate-hadrian:
97
  <<: *only-default
Ben Gamari's avatar
Ben Gamari committed
98
  allow_failure: true
Ben Gamari's avatar
Ben Gamari committed
99
  script:
100
    - cabal update
101
    - git clean -xdf && git submodule foreach git clean -xdf
Ben Gamari's avatar
Ben Gamari committed
102 103 104
    - bash .circleci/prepare-system.sh
    - if [[ -d ./cabal-cache ]]; then cp -R ./.cabal-cache ~/.cabal-cache; fi
    - ./boot
Ben Gamari's avatar
Ben Gamari committed
105
    - ./configure $CONFIGURE_ARGS
106 107
    - hadrian/build.cabal.sh -j`mk/detect-cpu-count.sh` --docs=no-sphinx binary-dist
    - mv _build/bindist/ghc*.tar.xz ghc.tar.xz
Ben Gamari's avatar
Ben Gamari committed
108 109
  cache:
    key: hadrian
110
    paths:
Ben Gamari's avatar
Ben Gamari committed
111
      - cabal-cache
112 113 114 115
  artifacts:
    when: always
    paths:
      - ghc.tar.xz
116

Ben Gamari's avatar
Ben Gamari committed
117
validate-x86_64-linux-deb8-hadrian:
Ben Gamari's avatar
Ben Gamari committed
118
  extends: .validate-hadrian
119
  stage: build
120
  image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb8:$DOCKER_REV"
Ben Gamari's avatar
Ben Gamari committed
121 122 123
  before_script:
    # workaround for docker permissions
    - sudo chown ghc:ghc -R .
124 125 126 127
    - python3 .gitlab/fix-submodules.py
    - git submodule sync --recursive
    - git submodule update --init --recursive
    - git checkout .gitmodules
128
    - "git fetch https://gitlab.haskell.org/ghc/ghc-performance-notes.git refs/notes/perf:refs/notes/perf || true"
Ben Gamari's avatar
Ben Gamari committed
129 130 131
  tags:
    - x86_64-linux

132
hadrian-ghc-in-ghci:
133
  <<: *only-default
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
  stage: build
  image: ghcci/x86_64-linux-deb8:0.1
  before_script:
    # workaround for docker permissions
    - sudo chown ghc:ghc -R .
    - python3 .gitlab/fix-submodules.py
    - git submodule sync --recursive
    - git submodule update --init --recursive
    - git checkout .gitmodules
  tags:
    - x86_64-linux
  script:
    - cabal update
    - git clean -xdf && git submodule foreach git clean -xdf
    - bash .circleci/prepare-system.sh
    - if [[ -d ./cabal-cache ]]; then cp -R ./.cabal-cache ~/.cabal-cache; fi
    - ./boot
    - ./configure $CONFIGURE_ARGS
    # Load ghc-in-ghci then immediately exit
    - echo ":q" | hadrian/ghci.sh
  cache:
    key: hadrian-ghci
    paths:
      - cabal-cache

Ben Gamari's avatar
Ben Gamari committed
159 160 161 162 163
############################################################
# Validation via Pipelines (make)
############################################################

.validate:
164
  <<: *only-default
165 166
  variables:
    TEST_TYPE: test
Ben Gamari's avatar
Ben Gamari committed
167
  before_script:
168
    - git clean -xdf && git submodule foreach git clean -xdf
Ben Gamari's avatar
Ben Gamari committed
169
  script:
Ben Gamari's avatar
Ben Gamari committed
170
    - ./boot
Ben Gamari's avatar
Ben Gamari committed
171
    - ./configure $CONFIGURE_ARGS
Ben Gamari's avatar
Ben Gamari committed
172 173
    - |
      THREADS=`mk/detect-cpu-count.sh`
174
      make V=0 -j$THREADS WERROR=-Werror
Ben Gamari's avatar
Ben Gamari committed
175 176
    - |
      make binary-dist TAR_COMP_OPTS="-1"
177 178 179 180 181
    - |
      # Prepare to push git notes.
      METRICS_FILE=$(mktemp)
      git config user.email "ben+ghc-ci@smart-cactus.org"
      git config user.name "GHC GitLab CI"
Ben Gamari's avatar
Ben Gamari committed
182 183
    - |
      THREADS=`mk/detect-cpu-count.sh`
184 185 186 187
      make $TEST_TYPE THREADS=$THREADS JUNIT_FILE=../../junit.xml METRICS_FILE=$METRICS_FILE
    - |
      # Push git notes.
      METRICS_FILE=$METRICS_FILE .gitlab/push-test-metrics.sh
188
  dependencies: []
189 190 191
  artifacts:
    reports:
      junit: junit.xml
192
    expire_in: 2 week
193
    paths:
194
      - ghc-*.tar.xz
195 196
      - junit.xml

197 198 199 200
#################################
# x86_64-darwin
#################################

Ben Gamari's avatar
Ben Gamari committed
201
validate-x86_64-darwin:
Ben Gamari's avatar
Ben Gamari committed
202
  extends: .validate
203
  stage: full-build
Ben Gamari's avatar
Ben Gamari committed
204 205 206
  tags:
    - x86_64-darwin
  variables:
207
    GHC_VERSION: 8.6.3
208
    BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-x86_64-apple-darwin.tar.xz"
Ben Gamari's avatar
Ben Gamari committed
209 210 211
    MACOSX_DEPLOYMENT_TARGET: "10.7"
    # Only Sierra and onwards supports clock_gettime. See #12858
    ac_cv_func_clock_gettime: "no"
212
    LANG: "en_US.UTF-8"
213
    CONFIGURE_ARGS: --with-intree-gmp
214
    TEST_ENV: "x86_64-darwin"
Ben Gamari's avatar
Ben Gamari committed
215
  before_script:
Ben Gamari's avatar
Ben Gamari committed
216
    - git clean -xdf && git submodule foreach git clean -xdf
217
    - python3 .gitlab/fix-submodules.py
218 219 220
    - git submodule sync --recursive
    - git submodule update --init --recursive
    - git checkout .gitmodules
221
    - "git fetch https://gitlab.haskell.org/ghc/ghc-performance-notes.git refs/notes/perf:refs/notes/perf || true"
222

Ben Gamari's avatar
Ben Gamari committed
223 224 225 226
    - bash .gitlab/darwin-init.sh
    - PATH="`pwd`/toolchain/bin:$PATH"
  after_script:
    - cp -Rf $HOME/.cabal cabal-cache
227 228
  artifacts:
    when: always
229
    expire_in: 2 week
Ben Gamari's avatar
Ben Gamari committed
230 231 232 233 234 235
  cache:
    key: darwin
    paths:
      - cabal-cache
      - toolchain

Ben Gamari's avatar
Ben Gamari committed
236
.validate-linux:
Ben Gamari's avatar
Ben Gamari committed
237 238 239 240
  extends: .validate
  tags:
    - x86_64-linux
  before_script:
Ben Gamari's avatar
Ben Gamari committed
241
    - git clean -xdf && git submodule foreach git clean -xdf
242 243 244 245
    - python3 .gitlab/fix-submodules.py
    - git submodule sync --recursive
    - git submodule update --init --recursive
    - git checkout .gitmodules
246
    - "git fetch https://gitlab.haskell.org/ghc/ghc-performance-notes.git refs/notes/perf:refs/notes/perf || true"
247

Ben Gamari's avatar
Ben Gamari committed
248 249 250 251 252 253
    - bash .circleci/prepare-system.sh
    # workaround for docker permissions
    - sudo chown ghc:ghc -R .
  after_script:
    - cp -Rf $HOME/.cabal cabal-cache
  cache:
Ben Gamari's avatar
Ben Gamari committed
254
    key: linux
Ben Gamari's avatar
Ben Gamari committed
255 256 257 258
    paths:
      - cabal-cache
      - toolchain

259 260 261 262 263
#################################
# aarch64-linux-deb9
#################################

.build-aarch64-linux-deb9:
Ben Gamari's avatar
Ben Gamari committed
264
  extends: .validate-linux
265
  stage: full-build
266
  image: "registry.gitlab.haskell.org/ghc/ci-images/aarch64-linux-deb9:$DOCKER_REV"
Ben Gamari's avatar
Ben Gamari committed
267
  allow_failure: true
268 269
  variables:
    TEST_ENV: "aarch64-linux-deb9"
270
    BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-aarch64-linux-deb9.tar.xz"
Ben Gamari's avatar
Ben Gamari committed
271 272 273 274 275
  cache:
    key: linux-aarch64-deb9
  tags:
    - aarch64-linux

276 277 278 279 280 281
validate-aarch64-linux-deb9:
  extends: .build-aarch64-linux-deb9
  artifacts:
    when: always
    expire_in: 2 week

282
nightly-aarch64-linux-deb9:
283
  extends: .build-aarch64-linux-deb9
284
  artifacts:
285
    expire_in: 2 year
286 287 288 289 290 291
  variables:
    TEST_TYPE: slowtest
  only:
    variables:
      - $NIGHTLY

292 293 294 295 296
#################################
# i386-linux-deb9
#################################

.build-i386-linux-deb9:
297 298
  extends: .validate-linux
  stage: full-build
299
  image: "registry.gitlab.haskell.org/ghc/ci-images/i386-linux-deb9:$DOCKER_REV"
300 301
  variables:
    TEST_ENV: "i386-linux-deb9"
302
    BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-i386-deb9-linux.tar.xz"
303 304 305 306 307
  cache:
    key: linux-i386-deb9

validate-i386-linux-deb9:
  extends: .build-i386-linux-deb9
308 309 310
  artifacts:
    when: always
    expire_in: 2 week
311 312

nightly-i386-linux-deb9:
313
  extends: .build-i386-linux-deb9
314 315 316 317
  variables:
    TEST_TYPE: slowtest
  artifacts:
    when: always
318
    expire_in: 2 week
319 320 321
  only:
    variables:
      - $NIGHTLY
322

323 324 325
#################################
# x86_64-linux-deb9
#################################
Ben Gamari's avatar
Ben Gamari committed
326

327
.build-x86_64-linux-deb9:
Ben Gamari's avatar
Ben Gamari committed
328
  extends: .validate-linux
329
  stage: full-build
330
  image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV"
331 332
  variables:
    TEST_ENV: "x86_64-linux-deb9"
333
    BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-x86_64-deb9-linux.tar.xz"
Ben Gamari's avatar
Ben Gamari committed
334 335 336
  cache:
    key: linux-x86_64-deb9

337 338
validate-x86_64-linux-deb9:
  extends: .build-x86_64-linux-deb9
339 340 341 342
  artifacts:
    when: always
    expire_in: 2 week

343
nightly-x86_64-linux-deb9:
344
  extends: .build-x86_64-linux-deb9
345
  artifacts:
346
    expire_in: 2 year
347 348 349 350 351 352
  variables:
    TEST_TYPE: slowtest
  only:
    variables:
      - $NIGHTLY

353 354 355
# N.B. Has DEBUG assertions enabled in stage2
validate-x86_64-linux-deb9-debug:
  extends: .build-x86_64-linux-deb9
356
  stage: build
357 358 359 360
  variables:
    BUILD_FLAVOUR: validate
    TEST_ENV: "x86_64-linux-deb9-debug"

Ben Gamari's avatar
Ben Gamari committed
361
validate-x86_64-linux-deb9-llvm:
362
  extends: .build-x86_64-linux-deb9
363
  stage: full-build
Ben Gamari's avatar
Ben Gamari committed
364 365
  variables:
    BUILD_FLAVOUR: perf-llvm
366
    TEST_ENV: "x86_64-linux-deb9-llvm"
367 368 369 370 371 372 373

validate-x86_64-linux-deb9-integer-simple:
  extends: .build-x86_64-linux-deb9
  stage: full-build
  variables:
    INTEGER_LIBRARY: integer-simple
    TEST_ENV: "x86_64-linux-deb9-integer-simple"
374
    BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-x86_64-deb9-linux-integer-simple.tar.xz"
375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399

nightly-x86_64-linux-deb9-integer-simple:
  extends: .build-x86_64-linux-deb9
  stage: full-build
  variables:
    INTEGER_LIBRARY: integer-simple
    TEST_ENV: "x86_64-linux-deb9-integer-simple"
    TEST_TYPE: slowtest
  artifacts:
    expire_in: 2 year
  only:
    variables:
      - $NIGHTLY

validate-x86_64-linux-deb9-unreg:
  extends: .build-x86_64-linux-deb9
  stage: full-build
  variables:
    CONFIGURE_ARGS: --enable-unregisterised
    TEST_ENV: "x86_64-linux-deb9-unreg"


#################################
# x86_64-linux-deb8
#################################
Ben Gamari's avatar
Ben Gamari committed
400

401
release-x86_64-linux-deb8:
Ben Gamari's avatar
Ben Gamari committed
402
  extends: .validate-linux
403
  stage: full-build
404
  image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb8:$DOCKER_REV"
405 406
  variables:
    TEST_ENV: "x86_64-linux-deb8"
407
    BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-x86_64-deb8-linux.tar.xz"
408 409
  only:
    - tags
Ben Gamari's avatar
Ben Gamari committed
410 411
  cache:
    key: linux-x86_64-deb8
412 413 414
  artifacts:
    when: always
    expire_in: 2 week
Ben Gamari's avatar
Ben Gamari committed
415

416 417 418 419 420

#################################
# x86_64-linux-fedora27
#################################

421
validate-x86_64-linux-fedora27:
Ben Gamari's avatar
Ben Gamari committed
422
  extends: .validate-linux
423
  stage: full-build
424
  image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-fedora27:$DOCKER_REV"
425 426
  variables:
    TEST_ENV: "x86_64-linux-fedora27"
427
    BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-x86_64-fedora27-linux.tar.xz"
Ben Gamari's avatar
Ben Gamari committed
428 429
  cache:
    key: linux-x86_64-fedora27
430 431
  artifacts:
    when: always
432
    expire_in: 2 week
Ben Gamari's avatar
Ben Gamari committed
433

Ben Gamari's avatar
Ben Gamari committed
434
############################################################
435
# Validation via Pipelines (Windows)
Ben Gamari's avatar
Ben Gamari committed
436 437
############################################################

438
.build-windows:
439
  <<: *only-default
Ben Gamari's avatar
Ben Gamari committed
440
  before_script:
441
    - git clean -xdf
442
    - git submodule foreach git clean -xdf
443 444 445 446 447 448 449 450 451

    # Use a local temporary directory to ensure that concurrent builds don't
    # interfere with one another
    - |
      mkdir tmp
      set TMP=%cd%\tmp
      set TEMP=%cd%\tmp

    - set PATH=C:\msys64\usr\bin;%PATH%
Ben Gamari's avatar
Ben Gamari committed
452 453 454 455
    - python .gitlab/fix-submodules.py
    - git submodule sync --recursive
    - git submodule update --init --recursive
    - git checkout .gitmodules
456
    - "git fetch https://gitlab.haskell.org/ghc/ghc-performance-notes.git refs/notes/perf:refs/notes/perf || true"
Ben Gamari's avatar
Ben Gamari committed
457
    - bash .gitlab/win32-init.sh
458 459
  after_script:
    - rd /s /q tmp
460
    - robocopy /np /nfl /ndl /e "%APPDATA%\cabal" cabal-cache
461
    - bash -c 'make clean || true'
462
  dependencies: []
Tamar Christina's avatar
Tamar Christina committed
463 464
  variables:
    FORCE_SYMLINKS: 1
465
    LANG: "en_US.UTF-8"
Ben Gamari's avatar
Ben Gamari committed
466 467 468 469 470 471
  cache:
    paths:
      - cabal-cache
      - ghc-8.6.2
      - ghc-tarballs

472 473
.build-windows-hadrian:
  extends: .build-windows
474
  stage: full-build
Ben Gamari's avatar
Ben Gamari committed
475 476 477 478 479
  variables:
    GHC_VERSION: "8.6.2"
  script:
    - |
      python boot
480
      bash -c './configure --enable-tarballs-autodownload GHC=`pwd`/toolchain/bin/ghc HAPPY=`pwd`/toolchain/bin/happy ALEX=`pwd`/toolchain/bin/alex'
481 482
    - bash -c "PATH=`pwd`/toolchain/bin:$PATH hadrian/build.cabal.sh -j`mk/detect-cpu-count.sh` --flavour=Quick --docs=no-sphinx binary-dist"
    - mv _build/bindist/ghc*.tar.xz ghc.tar.xz
483
    # FIXME: Testsuite disabled due to #16156.
484
    # - bash -c 'make V=0 test THREADS=`mk/detect-cpu-count.sh` JUNIT_FILE=../../junit.xml'
Ben Gamari's avatar
Ben Gamari committed
485 486
  tags:
    - x86_64-windows
487 488 489 490
  artifacts:
    when: always
    paths:
      - ghc.tar.xz
Ben Gamari's avatar
Ben Gamari committed
491

492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510
validate-x86_64-windows-hadrian:
  extends: .build-windows-hadrian
  variables:
    MSYSTEM: MINGW64
  cache:
    key: x86_64-windows-hadrian

nightly-i386-windows-hadrian:
  extends: .build-windows-hadrian
  variables:
    MSYSTEM: MINGW32
  only:
    variables:
      - $NIGHTLY
  cache:
    key: i386-windows-hadrian

.build-windows-make:
  extends: .build-windows
511
  stage: full-build
512 513
  # due to #16084
  allow_failure: true
514
  variables:
515
    BUILD_FLAVOUR: "quick"
516
    GHC_VERSION: "8.6.2"
517
    BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-x86_64-mingw32.tar.xz"
518 519 520
  script:
    - |
      python boot
521
      bash -c './configure --enable-tarballs-autodownload GHC=`pwd`/toolchain/bin/ghc HAPPY=`pwd`/toolchain/bin/happy ALEX=`pwd`/toolchain/bin/alex $CONFIGURE_ARGS'
522
    - bash -c "echo include mk/flavours/${BUILD_FLAVOUR}.mk > mk/build.mk"
523
    - bash -c "PATH=`pwd`/toolchain/bin:$PATH make -j`mk/detect-cpu-count.sh`"
524
    - bash -c "PATH=`pwd`/toolchain/bin:$PATH make binary-dist TAR_COMP_OPTS=-1"
525
    - bash -c 'make V=0 test THREADS=`mk/detect-cpu-count.sh` JUNIT_FILE=../../junit.xml'
526 527
  tags:
    - x86_64-windows
528 529
  artifacts:
    when: always
530
    expire_in: 2 week
531 532 533
    reports:
      junit: junit.xml
    paths:
534
      - ghc-*.tar.xz
535
      - junit.xml
Ben Gamari's avatar
Ben Gamari committed
536

537 538 539 540
validate-x86_64-windows:
  extends: .build-windows-make
  variables:
    MSYSTEM: MINGW64
541
    CONFIGURE_ARGS: "--target=x86_64-unknown-mingw32"
542 543 544
  cache:
    key: x86_64-windows

545 546 547 548 549 550
# Normal Windows validate builds are profiled; that won't do for releases.
release-x86_64-windows:
  extends: validate-x86_64-windows
  variables:
    MSYSTEM: MINGW64
    BUILD_FLAVOUR: "perf"
551
    CONFIGURE_ARGS: "--target=x86_64-unknown-mingw32"
552 553 554
  only:
    - tags

555 556 557 558 559 560
release-i386-windows:
  extends: .build-windows-make
  only:
    - tags
  variables:
    MSYSTEM: MINGW32
561
    BUILD_FLAVOUR: "perf"
562
    CONFIGURE_ARGS: "--target=i386-unknown-mingw32"
563 564 565 566 567 568 569 570 571 572
  cache:
    key: i386-windows

nightly-i386-windows:
  extends: .build-windows-make
  only:
    variables:
      - $NIGHTLY
  variables:
    MSYSTEM: MINGW32
573
    CONFIGURE_ARGS: "--target=i386-unknown-mingw32"
574 575 576
  cache:
    key: i386-windows

577 578 579 580
############################################################
# Cleanup
############################################################

581 582
# Note [Cleaning up after shell executor]
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
583 584 585 586 587 588 589 590 591
#
# As noted in [1], gitlab-runner's shell executor doesn't clean up its working
# directory after builds. Unfortunately, we are forced to use the shell executor
# on Windows. To avoid running out of disk space we add a stage at the end of
# the build to remove the \GitLabRunner\builds directory. Since we only run a
# single build at a time on Windows this should be safe.
#
# [1] https://gitlab.com/gitlab-org/gitlab-runner/issues/3856

592
# See Note [Cleanup after shell executor]
593
cleanup-windows:
594
  <<: *only-default
595 596 597 598
  stage: cleanup
  tags:
    - x86_64-windows
  when: always
599
  dependencies: []
600 601 602 603 604 605 606 607 608
  before_script:
    - echo "Time to clean up"
  script:
    - echo "Let's go"
  after_script:
    - set "BUILD_DIR=%CI_PROJECT_DIR%"
    - set "BUILD_DIR=%BUILD_DIR:/=\%"
    - echo "Cleaning %BUILD_DIR%"
    - cd \GitLabRunner
609 610 611 612
    # This is way more complicated than it should be:
    # See https://stackoverflow.com/questions/1965787
    - del %BUILD_DIR%\* /F /Q
    - for /d %%p in (%BUILD_DIR%\*) do rd /Q /S "%%p"
613
    - exit /b 0
614 615 616

# See Note [Cleanup after shell executor]
cleanup-darwin:
617
  <<: *only-default
618 619 620 621
  stage: cleanup
  tags:
    - x86_64-darwin
  when: always
622
  dependencies: []
623 624 625 626 627 628 629 630 631 632 633
  before_script:
    - echo "Time to clean up"
  script:
    - echo "Let's go"
  after_script:
    - BUILD_DIR=$CI_PROJECT_DIR
    - echo "Cleaning $BUILD_DIR"
    - cd $HOME
    - rm -Rf $BUILD_DIR/*
    - exit 0

634 635 636 637 638
############################################################
# Packaging
############################################################

doc-tarball:
639
  <<: *only-default
640
  stage: packaging
641
  allow_failure: true
642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660
  tags:
    - x86_64-linux
  image: ghcci/x86_64-linux-deb9:0.2
  dependencies:
    - validate-x86_64-linux-deb9
    - validate-x86_64-windows
  artifacts:
    paths:
      - haddock.html.tar.xz
      - libraries.html.tar.xz
      - users_guide.html.tar.xz
      - index.html
      - "*.pdf"
  script:
    - rm -Rf docs
    - distrib/mkDocs/mkDocs ghc-x86_64-deb9-linux.tar.xz ghc-x86_64-mingw32.tar.xz
    - ls -lh
    - mv docs/*.tar.xz .

661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678
source-tarball:
  stage: packaging
  tags:
    - x86_64-linux
  image: ghcci/x86_64-linux-deb9:0.2
  only:
    - tags
  artifacts:
    paths:
      - ghc-*.tar.xz
      - version
  script:
    - mk/get-win32-tarballs.sh download all
    - ./boot
    - ./configure
    - make sdist
    - mv sdistprep/*.xz  .
    - make show VALUE=version > version
679 680 681 682 683 684 685 686 687 688 689 690 691


############################################################
# Testing via head.hackage
############################################################

# Triggering jobs in the ghc/head.hackage project requires that we have a job
# token for that repository. Furthermore the head.hackage CI job must have
# access to an unprivileged access token with the ability to query the ghc/ghc
# project such that it can find the job ID of the fedora27 job for the current
# pipeline.

.hackage:
692
  <<: *only-default
693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717
  stage: hackage
  image: ghcci/x86_64-linux-deb9:0.2
  tags:
    - x86_64-linux
  dependencies: []
  variables:
    HEAD_HACKAGE_PROJECT_ID: "78"
  script:
    - bash .gitlab/start-head.hackage.sh

hackage:
  extends: .hackage
  when: manual

hackage-label:
  extends: .hackage
  only:
    variables:
      - $CI_MERGE_REQUEST_LABELS =~ /.*user-facing.*/

nightly-hackage:
  extends: .hackage
  only:
    variables:
      - $NIGHTLY
718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737

pages:
  stage: deploy
  dependencies:
    - doc-tarball
  image: ghcci/x86_64-linux-deb9:0.2
  tags:
    - x86_64-linux
  script:
    - mkdir -p public/doc
    - tar -xf haddock.html.tar.xz -C public/doc
    - tar -xf libraries.html.tar.xz -C public/doc
    - tar -xf users_guide.html.tar.xz -C public/doc
    - cp -f index.html public/doc
  only:
    - master
  artifacts:
    paths:
      - public