gitlab-ci: Pass --target explicitly to configure on Windows
[ghc.git] / .gitlab-ci.yml
index cca7551..0364cec 100644 (file)
@@ -2,7 +2,7 @@ variables:
   GIT_SSL_NO_VERIFY: "1"
 
   # Commit of ghc/ci-images repository from which to pull Docker images
-  DOCKER_REV: 6d19c3adc1f5c28c82aed8c5b1ac40931ac60f3f
+  DOCKER_REV: cefaee3c742af193e0f7783f87edb0d35374515c
 
 before_script:
   - python3 .gitlab/fix-submodules.py
@@ -12,11 +12,19 @@ before_script:
   - "git fetch https://gitlab.haskell.org/ghc/ghc-performance-notes.git refs/notes/perf:refs/notes/perf || true"
 
 stages:
-  - lint
-  - build
-  - full-build
-  - cleanup # See Note [Cleanup on Windows]
-  - packaging
+  - 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
+
+.only-default: &only-default
+  only:
+    - master
+    - /ghc-[0-9]+\.[0-9]+/
+    - merge_requests
+    - tags
 
 ############################################################
 # Runner Tags
@@ -38,24 +46,58 @@ ghc-linters:
   stage: lint
   image: "registry.gitlab.haskell.org/ghc/ci-images/linters:$DOCKER_REV"
   script:
-    - |
-      if [ -n "$CI_MERGE_REQUEST_ID" ]; then
-        base="$(git merge-base $CI_MERGE_REQUEST_BRANCH_NAME HEAD)"
-        validate-commit-msg .git $(git rev-list $base..$CI_COMMIT_SHA)
-        submodchecker .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
-      fi
+    - git fetch origin
+    - git checkout "$CI_MERGE_REQUEST_TARGET_BRANCH_NAME"
+    - git reset --hard "origin/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME"
+    - echo "$CI_MERGE_REQUEST_ID"
+    - echo "$CI_MERGE_REQUEST_TARGET_BRANCH_NAME"
+    - echo "$CI_COMMIT_SHA"
+    - base="$(git merge-base $CI_MERGE_REQUEST_TARGET_BRANCH_NAME $CI_COMMIT_SHA)"
+    - echo $base
+    #    - 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
+  dependencies: []
+  tags:
+    - lint
+  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
+
 ############################################################
 # Validation via Pipelines (hadrian)
 ############################################################
 
 .validate-hadrian:
+  <<: *only-default
   allow_failure: true
   script:
     - cabal update
@@ -91,6 +133,7 @@ validate-x86_64-linux-deb8-hadrian:
     - x86_64-linux
 
 hadrian-ghc-in-ghci:
+  <<: *only-default
   stage: build
   image: ghcci/x86_64-linux-deb8:0.1
   before_script:
@@ -121,6 +164,7 @@ hadrian-ghc-in-ghci:
 ############################################################
 
 .validate:
+  <<: *only-default
   variables:
     TEST_TYPE: test
   before_script:
@@ -285,7 +329,7 @@ nightly-i386-linux-deb9:
 
 .build-x86_64-linux-deb9:
   extends: .validate-linux
-  stage: build
+  stage: full-build
   image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV"
   variables:
     TEST_ENV: "x86_64-linux-deb9"
@@ -312,6 +356,7 @@ nightly-x86_64-linux-deb9:
 # N.B. Has DEBUG assertions enabled in stage2
 validate-x86_64-linux-deb9-debug:
   extends: .build-x86_64-linux-deb9
+  stage: build
   variables:
     BUILD_FLAVOUR: validate
     TEST_ENV: "x86_64-linux-deb9-debug"
@@ -393,7 +438,8 @@ validate-x86_64-linux-fedora27:
 # Validation via Pipelines (Windows)
 ############################################################
 
-.validate-windows:
+.build-windows:
+  <<: *only-default
   before_script:
     - git clean -xdf
     - git submodule foreach git clean -xdf
@@ -419,29 +465,26 @@ validate-x86_64-linux-fedora27:
   dependencies: []
   variables:
     FORCE_SYMLINKS: 1
+    LANG: "en_US.UTF-8"
   cache:
     paths:
       - cabal-cache
       - ghc-8.6.2
       - ghc-tarballs
 
-validate-x86_64-windows-hadrian:
-  extends: .validate-windows
+.build-windows-hadrian:
+  extends: .build-windows
   stage: full-build
   variables:
     GHC_VERSION: "8.6.2"
-    LANG: "en_US.UTF-8"
   script:
     - |
-      set MSYSTEM=MINGW64
       python boot
       bash -c './configure --enable-tarballs-autodownload GHC=`pwd`/toolchain/bin/ghc HAPPY=`pwd`/toolchain/bin/happy ALEX=`pwd`/toolchain/bin/alex'
     - 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
     # FIXME: Testsuite disabled due to #16156.
     # - bash -c 'make V=0 test THREADS=`mk/detect-cpu-count.sh` JUNIT_FILE=../../junit.xml'
-  cache:
-    key: x86_64-windows
   tags:
     - x86_64-windows
   artifacts:
@@ -449,36 +492,91 @@ validate-x86_64-windows-hadrian:
     paths:
       - ghc.tar.xz
 
-validate-x86_64-windows:
-  extends: .validate-windows
+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
   stage: full-build
   # due to #16084
   allow_failure: true
   variables:
+    BUILD_FLAVOUR: "quick"
     GHC_VERSION: "8.6.2"
-    LANG: "en_US.UTF-8"
     BIN_DIST_PREP_TAR_COMP: "bindistprep/ghc-x86_64-mingw32.tar.xz"
   script:
     - |
-      set MSYSTEM=MINGW64
       python boot
-      bash -c './configure --enable-tarballs-autodownload GHC=`pwd`/toolchain/bin/ghc HAPPY=`pwd`/toolchain/bin/happy ALEX=`pwd`/toolchain/bin/alex'
-    - bash -c "echo include mk/flavours/quick.mk > mk/build.mk"
+      bash -c './configure --enable-tarballs-autodownload GHC=`pwd`/toolchain/bin/ghc HAPPY=`pwd`/toolchain/bin/happy ALEX=`pwd`/toolchain/bin/alex $CONFIGURE_ARGS'
+    - bash -c "echo include mk/flavours/${BUILD_FLAVOUR}.mk > mk/build.mk"
     - bash -c "PATH=`pwd`/toolchain/bin:$PATH make -j`mk/detect-cpu-count.sh`"
     - bash -c "PATH=`pwd`/toolchain/bin:$PATH make binary-dist TAR_COMP_OPTS=-1"
     - bash -c 'make V=0 test THREADS=`mk/detect-cpu-count.sh` JUNIT_FILE=../../junit.xml'
-  cache:
-    key: x86_64-windows
   tags:
     - x86_64-windows
   artifacts:
     when: always
+    expire_in: 2 week
     reports:
       junit: junit.xml
     paths:
       - ghc-*.tar.xz
       - junit.xml
 
+validate-x86_64-windows:
+  extends: .build-windows-make
+  variables:
+    MSYSTEM: MINGW64
+    CONFIGURE_ARGS: "--target=x86_64-unknown-mingw32"
+  cache:
+    key: x86_64-windows
+
+# 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"
+    CONFIGURE_ARGS: "--target=x86_64-unknown-mingw32"
+  only:
+    - tags
+
+release-i386-windows:
+  extends: .build-windows-make
+  only:
+    - tags
+  variables:
+    MSYSTEM: MINGW32
+    BUILD_FLAVOUR: "perf"
+    CONFIGURE_ARGS: "--target=i386-unknown-mingw32"
+  cache:
+    key: i386-windows
+
+nightly-i386-windows:
+  extends: .build-windows-make
+  only:
+    variables:
+      - $NIGHTLY
+  variables:
+    MSYSTEM: MINGW32
+    CONFIGURE_ARGS: "--target=i386-unknown-mingw32"
+  cache:
+    key: i386-windows
+
 ############################################################
 # Cleanup
 ############################################################
@@ -496,6 +594,7 @@ validate-x86_64-windows:
 
 # See Note [Cleanup after shell executor]
 cleanup-windows:
+  <<: *only-default
   stage: cleanup
   tags:
     - x86_64-windows
@@ -518,6 +617,7 @@ cleanup-windows:
 
 # See Note [Cleanup after shell executor]
 cleanup-darwin:
+  <<: *only-default
   stage: cleanup
   tags:
     - x86_64-darwin
@@ -539,6 +639,7 @@ cleanup-darwin:
 ############################################################
 
 doc-tarball:
+  <<: *only-default
   stage: packaging
   tags:
     - x86_64-linux
@@ -577,3 +678,42 @@ source-tarball:
     - make sdist
     - mv sdistprep/*.xz  .
     - make show VALUE=version > version
+
+
+############################################################
+# 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:
+  <<: *only-default
+  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