Skip to content

Commit a2d9bb7

Browse files
authored
Rollup merge of rust-lang#65202 - pietroalbini:scriptify-ci-config, r=alexcrichton
ci: move most of the prepare config into scripts This PR moves most of the configuration from the CI yamls into bash scripts, driven by a small Python script (which understands and emulates the two `##vso[` commands we use). There are two reasons why we'd want to do this: * Being able to prepare the build environment locally by just running `src/ci/prepare.py` simplifies a lot setting up a local VM similar to CI (software pre-installed in the CI images won't be prepared, but it's a start anyway). * When we'll switch to GitHub Actions we'll need to either duplicate code in multiple workflows or write a preprocessor. Having all the prepare steps in a single one is going to simplify the implementation of both options. Along with the move I did a few changes to the actual scripts: * Mirrored all the remaining external URLs we download (except chocolatey) to the `rust-lang-ci-mirrors` bucket, to increase reliability and reduce the chance of supply chain attacks. I didn't audit and mirror the CI scripts outside this PR though. * Extracted CI-specific behavior (like issuing `##vso[` commands and detecting the host platform) into `shared.sh` and included it in most of the scripts. This way a switch to another CI provider will be less painful. It's possible (and easier) to review this commit-by-commit. r? @alexcrichton cc @rust-lang/infra
2 parents 76a7e3e + 375e34d commit a2d9bb7

21 files changed

+421
-258
lines changed

src/ci/azure-pipelines/steps/install-clang.yml

Lines changed: 0 additions & 46 deletions
This file was deleted.

src/ci/azure-pipelines/steps/install-sccache.yml

Lines changed: 0 additions & 21 deletions
This file was deleted.

src/ci/azure-pipelines/steps/install-windows-build-deps.yml

Lines changed: 0 additions & 120 deletions
This file was deleted.

src/ci/azure-pipelines/steps/run.yml

Lines changed: 80 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -48,86 +48,99 @@ steps:
4848
- bash: python src/ci/cpu-usage-over-time.py &> cpu-usage.csv &
4949
displayName: "Collect CPU-usage statistics in the background"
5050

51-
- bash: printenv | sort
52-
displayName: Show environment variables
51+
- bash: src/ci/scripts/dump-environment.sh
52+
displayName: Show the current environment
5353

54-
- bash: |
55-
set -e
56-
df -h
57-
du . | sort -nr | head -n100
58-
displayName: Show disk usage
59-
# FIXME: this hasn't been tested, but maybe it works on Windows? Should test!
60-
condition: and(succeeded(), ne(variables['Agent.OS'], 'Windows_NT'))
61-
62-
- template: install-sccache.yml
63-
- template: install-clang.yml
64-
65-
# Switch to XCode 9.3 on OSX since it seems to be the last version that supports
66-
# i686-apple-darwin. We'll eventually want to upgrade this and it will probably
67-
# force us to drop i686-apple-darwin, but let's keep the wheels turning for now.
68-
- bash: |
69-
set -e
70-
sudo xcode-select --switch /Applications/Xcode_9.3.app
71-
displayName: Switch to Xcode 9.3 (OSX)
72-
condition: and(succeeded(), eq(variables['Agent.OS'], 'Darwin'))
54+
- bash: src/ci/scripts/install-sccache.sh
55+
env:
56+
AGENT_OS: $(Agent.OS)
57+
displayName: Install sccache
58+
condition: and(succeeded(), not(variables.SKIP_JOB))
7359

74-
- template: install-windows-build-deps.yml
60+
- bash: src/ci/scripts/install-clang.sh
61+
env:
62+
AGENT_OS: $(Agent.OS)
63+
displayName: Install clang
64+
condition: and(succeeded(), not(variables.SKIP_JOB))
7565

76-
# Looks like docker containers have IPv6 disabled by default, so let's turn it
77-
# on since libstd tests require it
78-
- bash: |
79-
set -e
80-
sudo mkdir -p /etc/docker
81-
echo '{"ipv6":true,"fixed-cidr-v6":"fd9a:8454:6789:13f7::/64"}' | sudo tee /etc/docker/daemon.json
82-
sudo service docker restart
83-
displayName: Enable IPv6
84-
condition: and(succeeded(), not(variables.SKIP_JOB), eq(variables['Agent.OS'], 'Linux'))
66+
- bash: src/ci/scripts/switch-xcode.sh
67+
env:
68+
AGENT_OS: $(Agent.OS)
69+
displayName: Switch to Xcode 9.3
70+
condition: and(succeeded(), not(variables.SKIP_JOB))
71+
72+
- bash: src/ci/scripts/install-wix.sh
73+
env:
74+
AGENT_OS: $(Agent.OS)
75+
displayName: Install wix
76+
condition: and(succeeded(), not(variables.SKIP_JOB))
77+
78+
- bash: src/ci/scripts/install-innosetup.sh
79+
env:
80+
AGENT_OS: $(Agent.OS)
81+
displayName: Install InnoSetup
82+
condition: and(succeeded(), not(variables.SKIP_JOB))
83+
84+
- bash: src/ci/scripts/windows-symlink-build-dir.sh
85+
env:
86+
AGENT_OS: $(Agent.OS)
87+
displayName: Ensure the build happens on C:\ instead of D:\
88+
condition: and(succeeded(), not(variables.SKIP_JOB))
89+
90+
- bash: src/ci/scripts/disable-git-crlf-conversion.sh
91+
displayName: "Disable git automatic line ending conversion (on C:/)"
92+
condition: and(succeeded(), not(variables.SKIP_JOB))
93+
94+
- bash: src/ci/scripts/install-msys2.sh
95+
env:
96+
AGENT_OS: $(Agent.OS)
97+
SYSTEM_WORKFOLDER: $(System.Workfolder)
98+
displayName: Install msys2
99+
condition: and(succeeded(), not(variables.SKIP_JOB))
100+
101+
- bash: src/ci/scripts/install-mingw.sh
102+
env:
103+
AGENT_OS: $(Agent.OS)
104+
SYSTEM_WORKFOLDER: $(System.Workfolder)
105+
displayName: Install MinGW
106+
condition: and(succeeded(), not(variables.SKIP_JOB))
107+
108+
- bash: src/ci/scripts/install-ninja.sh
109+
env:
110+
AGENT_OS: $(Agent.OS)
111+
displayName: Install ninja
112+
condition: and(succeeded(), not(variables.SKIP_JOB))
113+
114+
- bash: src/ci/scripts/enable-docker-ipv6.sh
115+
env:
116+
AGENT_OS: $(Agent.OS)
117+
displayName: Enable IPv6 on Docker
118+
condition: and(succeeded(), not(variables.SKIP_JOB))
85119

86120
# Disable automatic line ending conversion (again). On Windows, when we're
87121
# installing dependencies, something switches the git configuration directory or
88122
# re-enables autocrlf. We've not tracked down the exact cause -- and there may
89123
# be multiple -- but this should ensure submodules are checked out with the
90124
# appropriate line endings.
91-
- bash: git config --replace-all --global core.autocrlf false
92-
displayName: "Disable git automatic line ending conversion"
125+
- bash: src/ci/scripts/disable-git-crlf-conversion.sh
126+
displayName: Disable git automatic line ending conversion
127+
condition: and(succeeded(), not(variables.SKIP_JOB))
93128

94-
# Check out all our submodules, but more quickly than using git by using one of
95-
# our custom scripts
96-
- bash: |
97-
set -e
98-
mkdir -p $HOME/rustsrc
99-
$BUILD_SOURCESDIRECTORY/src/ci/init_repo.sh . $HOME/rustsrc
100-
condition: and(succeeded(), not(variables.SKIP_JOB), ne(variables['Agent.OS'], 'Windows_NT'))
101-
displayName: Check out submodules (Unix)
102-
- script: |
103-
if not exist C:\cache\rustsrc\NUL mkdir C:\cache\rustsrc
104-
sh src/ci/init_repo.sh . /c/cache/rustsrc
105-
condition: and(succeeded(), not(variables.SKIP_JOB), eq(variables['Agent.OS'], 'Windows_NT'))
106-
displayName: Check out submodules (Windows)
107-
108-
# See also the disable for autocrlf above, this just checks that it worked
109-
#
110-
# We check both in rust-lang/rust and in a submodule to make sure both are
111-
# accurate. Submodules are checked out significantly later than the main
112-
# repository in this script, so settings can (and do!) change between then.
113-
#
114-
# Linux (and maybe macOS) builders don't currently have dos2unix so just only
115-
# run this step on Windows.
116-
- bash: |
117-
set -x
118-
# print out the git configuration so we can better investigate failures in
119-
# the following
120-
git config --list --show-origin
121-
dos2unix -ih Cargo.lock src/tools/rust-installer/install-template.sh
122-
endings=$(dos2unix -ic Cargo.lock src/tools/rust-installer/install-template.sh)
123-
# if endings has non-zero length, error out
124-
if [ -n "$endings" ]; then exit 1 ; fi
125-
condition: and(succeeded(), eq(variables['Agent.OS'], 'Windows_NT'))
126-
displayName: Verify line endings are LF
129+
- bash: src/ci/scripts/checkout-submodules.sh
130+
env:
131+
AGENT_OS: $(Agent.OS)
132+
displayName: Checkout submodules
133+
condition: and(succeeded(), not(variables.SKIP_JOB))
134+
135+
- bash: src/ci/scripts/verify-line-endings.sh
136+
env:
137+
AGENT_OS: $(Agent.OS)
138+
displayName: Verify line endings
139+
condition: and(succeeded(), not(variables.SKIP_JOB))
127140

128141
# Ensure the `aws` CLI is installed so we can deploy later on, cache docker
129142
# images, etc.
130-
- bash: src/ci/install-awscli.sh
143+
- bash: src/ci/scripts/install-awscli.sh
131144
env:
132145
AGENT_OS: $(Agent.OS)
133146
condition: and(succeeded(), not(variables.SKIP_JOB))

src/ci/run.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ make check-bootstrap
117117

118118
# Display the CPU and memory information. This helps us know why the CI timing
119119
# is fluctuating.
120-
if isOSX; then
120+
if isMacOS; then
121121
system_profiler SPHardwareDataType || true
122122
sysctl hw || true
123123
ncpus=$(sysctl -n hw.ncpu)

src/ci/scripts/checkout-submodules.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
# Check out all our submodules, but more quickly than using git by using one of
3+
# our custom scripts
4+
5+
set -euo pipefail
6+
IFS=$'\n\t'
7+
8+
source "$(cd "$(dirname "$0")" && pwd)/../shared.sh"
9+
10+
if isWindows; then
11+
path="/c/cache/rustsrc"
12+
else
13+
path="${HOME}/rustsrc"
14+
fi
15+
16+
mkdir -p "${path}"
17+
"$(cd "$(dirname "$0")" && pwd)/../init_repo.sh" . "${path}"
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
# Disable automatic line ending conversion, which is enabled by default on
3+
# Azure's Windows image. Having the conversion enabled caused regressions both
4+
# in our test suite (it broke miri tests) and in the ecosystem, since we
5+
# started shipping install scripts with CRLF endings instead of the old LF.
6+
#
7+
# Note that we do this a couple times during the build as the PATH and current
8+
# user/directory change, e.g. when mingw is enabled.
9+
10+
set -euo pipefail
11+
IFS=$'\n\t'
12+
13+
git config --replace-all --global core.autocrlf false

0 commit comments

Comments
 (0)