From 50bfdb46962ca377bb1b9fffd91ed78288590a17 Mon Sep 17 00:00:00 2001
From: Cheng Shao <terrorjack@type.dance>
Date: Thu, 22 Feb 2024 18:50:17 +0000
Subject: [PATCH] ci: enable parallelism in hadrian/ghci scripts

This commit enables parallelism when the hadrian/ghci scripts are
called in CI. The time bottleneck is in the hadrian build step, but
previously the build step wasn't parallelized.
---
 .gitlab-ci.yml | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 53f3959f2a51..c814a4697f80 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -402,7 +402,8 @@ hadrian-ghc-in-ghci:
     - "echo 'package hadrian'  > hadrian/cabal.project.local"
     - "echo '  ghc-options: -Werror'  >> hadrian/cabal.project.local"
     # Load ghc-in-ghci then immediately exit and check the modules loaded
-    - echo ":q" | hadrian/ghci -j`mk/detect-cpu-count.sh`| tail -n2 | grep "Ok,"
+    - export CORES="$(mk/detect-cpu-count.sh)"
+    - echo ":q" | HADRIAN_ARGS=-j$CORES hadrian/ghci -j$CORES | tail -n2 | grep "Ok,"
   after_script:
     - .gitlab/ci.sh save_cache
     - cat ci-timings
@@ -453,8 +454,9 @@ hadrian-multi:
     - .gitlab/ci.sh configure
     # Now GHC means, use this GHC for hadrian
     - export GHC=$BOOT_HC
+    - export CORES="$(mk/detect-cpu-count.sh)"
     # Load hadrian-multi then immediately exit and check the modules loaded
-    - echo ":q" | hadrian/ghci-multi -j`mk/detect-cpu-count.sh`| tail -n2 | grep "Ok,"
+    - echo ":q" | HADRIAN_ARGS=-j$CORES hadrian/ghci-multi -j$CORES | tail -n2 | grep "Ok,"
   after_script:
     - .gitlab/ci.sh save_cache
   cache:
-- 
GitLab