gitlab-ci: Cleanup Windows builds
[ghc.git] / .gitlab-ci.yml
index 6d8276f..162c19c 100644 (file)
@@ -11,6 +11,7 @@ stages:
   - lint
   - build
   - full-build
+  - cleanup # See Note [Cleanup on Windows]
 
 ############################################################
 # Runner Tags
@@ -119,15 +120,13 @@ validate-x86_64-darwin:
     LANG: "en_US.UTF-8"
   before_script:
     - git clean -xdf && git submodule foreach git clean -xdf
-    - python .gitlab/fix-submodules.py
+    - python3 .gitlab/fix-submodules.py
     - git submodule sync --recursive
     - git submodule update --init --recursive
     - git checkout .gitmodules
 
     - bash .gitlab/darwin-init.sh
     - PATH="`pwd`/toolchain/bin:$PATH"
-      # Disable sphinx PDF output as MacTeX apparently doesn't provide xelatex
-    - echo "BUILD_SPHINX_PDF=NO" >> mk/build.mk
     - echo "libraries/integer-gmp_CONFIGURE_OPTS += --configure-option=--with-intree-gmp" >> mk/build.mk
   after_script:
     - cp -Rf $HOME/.cabal cabal-cache
@@ -337,7 +336,7 @@ validate-x86_64-windows-hadrian:
     - |
       set MSYSTEM=MINGW64
       python boot
-      bash -c './configure --with-ghc=`pwd`/toolchain/bin/ghc --enable-tarballs-autodownload HappyCmd=`pwd`/toolchain/bin/happy AlexCmd=`pwd`/toolchain/bin/alex'
+      bash -c './configure --enable-tarballs-autodownload GHC=`pwd`/toolchain/bin/ghc HAPPY=`pwd`/toolchain/bin/happy ALEX=`pwd`/toolchain/bin/alex'
       mkdir -p _build
       cp -R inplace/mingw _build/mingw
     # FIXME: --no-lint due to #15950
@@ -361,7 +360,8 @@ validate-x86_64-windows:
     - |
       set MSYSTEM=MINGW64
       python boot
-      bash -c './configure --with-ghc=`pwd`/toolchain/bin/ghc --enable-tarballs-autodownload HappyCmd=`pwd`/toolchain/bin/happy AlexCmd=`pwd`/toolchain/bin/alex'
+      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 "PATH=`pwd`/toolchain/bin:$PATH make -j`mk/detect-cpu-count.sh`"
     - bash -c 'make V=0 test THREADS=`mk/detect-cpu-count.sh` JUNIT_FILE=../../junit.xml'
   cache:
@@ -369,6 +369,35 @@ validate-x86_64-windows:
   tags:
     - x86_64-windows
 
+# Note [Cleanup on Windows]
+# ~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+# 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
+
+# See Note [Cleanup on Windows]
+cleanup-windows:
+  stage: cleanup
+  tags:
+    - x86_64-windows
+  when: always
+  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
+    - rmdir /S /Q %BUILD_DIR%/*
+    - exit /b 0
+
 ############################################################
 # Validation via CircleCI
 ############################################################