gitlab-ci: Use build cleanup logic on Darwin as well
authorBen Gamari <ben@smart-cactus.org>
Mon, 21 Jan 2019 15:55:48 +0000 (10:55 -0500)
committerBen Gamari <ben@smart-cactus.org>
Wed, 30 Jan 2019 15:06:31 +0000 (10:06 -0500)
We use the shell executor on Darwin as well as Windows.
See https://gitlab.com/gitlab-org/gitlab-runner/issues/3856.

.gitlab-ci.yml

index 389906e..4a8cb62 100644 (file)
@@ -408,8 +408,8 @@ validate-x86_64-windows:
       - ghc.tar.xz
       - junit.xml
 
-# Note [Cleanup on Windows]
-# ~~~~~~~~~~~~~~~~~~~~~~~~~
+# Note [Cleaning up after shell executor]
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 #
 # 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
@@ -419,7 +419,7 @@ validate-x86_64-windows:
 #
 # [1] https://gitlab.com/gitlab-org/gitlab-runner/issues/3856
 
-# See Note [Cleanup on Windows]
+# See Note [Cleanup after shell executor]
 cleanup-windows:
   stage: cleanup
   tags:
@@ -440,3 +440,21 @@ cleanup-windows:
     - del %BUILD_DIR%\* /F /Q
     - for /d %%p in (%BUILD_DIR%\*) do rd /Q /S "%%p"
     - exit /b 0
+
+# See Note [Cleanup after shell executor]
+cleanup-darwin:
+  stage: cleanup
+  tags:
+    - x86_64-darwin
+  when: always
+  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
+