about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPietro Albini <pietro@pietroalbini.org>2019-10-08 11:57:06 +0200
committerPietro Albini <pietro@pietroalbini.org>2019-10-25 16:08:33 +0200
commit9a9d427ef903422301a62a02c2a90d9e7f7dbb2b (patch)
treeb48e8fb46d99396a0a6b9756f19e92c3242530ac
parentd264e954dc885bcb9cc5cc35cbbff862dffff6db (diff)
downloadrust-9a9d427ef903422301a62a02c2a90d9e7f7dbb2b.tar.gz
rust-9a9d427ef903422301a62a02c2a90d9e7f7dbb2b.zip
ci: extract checking out submodules into a script
-rw-r--r--src/ci/azure-pipelines/steps/run.yml16
-rwxr-xr-xsrc/ci/scripts/checkout-submodules.sh17
2 files changed, 22 insertions, 11 deletions
diff --git a/src/ci/azure-pipelines/steps/run.yml b/src/ci/azure-pipelines/steps/run.yml
index 0562b28ca9c..0b15ae36e0c 100644
--- a/src/ci/azure-pipelines/steps/run.yml
+++ b/src/ci/azure-pipelines/steps/run.yml
@@ -128,17 +128,11 @@ steps:
 
 # Check out all our submodules, but more quickly than using git by using one of
 # our custom scripts
-- bash: |
-    set -e
-    mkdir -p $HOME/rustsrc
-    $BUILD_SOURCESDIRECTORY/src/ci/init_repo.sh . $HOME/rustsrc
-  condition: and(succeeded(), not(variables.SKIP_JOB), ne(variables['Agent.OS'], 'Windows_NT'))
-  displayName: Check out submodules (Unix)
-- script: |
-    if not exist C:\cache\rustsrc\NUL mkdir C:\cache\rustsrc
-    sh src/ci/init_repo.sh . /c/cache/rustsrc
-  condition: and(succeeded(), not(variables.SKIP_JOB), eq(variables['Agent.OS'], 'Windows_NT'))
-  displayName: Check out submodules (Windows)
+- bash: src/ci/scripts/checkout-submodules.sh
+  env:
+    AGENT_OS: $(Agent.OS)
+  displayName: Checkout submodules
+  condition: and(succeeded(), not(variables.SKIP_JOB))
 
 # See also the disable for autocrlf above, this just checks that it worked
 #
diff --git a/src/ci/scripts/checkout-submodules.sh b/src/ci/scripts/checkout-submodules.sh
new file mode 100755
index 00000000000..0b44ea3c90b
--- /dev/null
+++ b/src/ci/scripts/checkout-submodules.sh
@@ -0,0 +1,17 @@
+#!/bin/bash
+# Check out all our submodules, but more quickly than using git by using one of
+# our custom scripts
+
+set -euo pipefail
+IFS=$'\n\t'
+
+source "$(cd "$(dirname "$0")" && pwd)/../shared.sh"
+
+if isWindows; then
+    path="/c/cache/rustsrc"
+else
+    path="${HOME}/rustsrc"
+fi
+
+mkdir -p "${path}"
+"$(cd "$(dirname "$0")" && pwd)/../init_repo.sh" . "${path}"