]> git.lizzy.rs Git - rust.git/blob - .azure-pipelines/steps/run.yml
Simplify SaveHandler trait
[rust.git] / .azure-pipelines / steps / run.yml
1 # FIXME(linux): need to configure core dumps, enable them, and then dump
2 # backtraces on failure from all core dumps:
3 #
4 # - bash: sudo apt install gdb
5 # - bash: sudo sh -c 'echo "/checkout/obj/cores/core.%p.%E" > /proc/sys/kernel/core_pattern'
6 #
7 # Check travis config for `gdb --batch` command to print all crash logs
8
9 parameters:
10   # When this parameter is set to anything other than an empty string the tests
11   # will only be executed when the commit updates submodules
12   only_on_updated_submodules: ''
13
14 steps:
15
16 # Disable automatic line ending conversion, which is enabled by default on
17 # Azure's Windows image. Having the conversion enabled caused regressions both
18 # in our test suite (it broke miri tests) and in the ecosystem, since we
19 # started shipping install scripts with CRLF endings instead of the old LF.
20 #
21 # Note that we do this a couple times during the build as the PATH and current
22 # user/directory change, e.g. when mingw is enabled.
23 - bash: git config --global core.autocrlf false
24   displayName: "Disable git automatic line ending conversion"
25
26 - checkout: self
27   fetchDepth: 2
28
29 # Set the SKIP_JOB environment variable if this job is supposed to only run
30 # when submodules are updated and they were not. The following time consuming
31 # tasks will be skipped when the environment variable is present.
32 - ${{ if parameters.only_on_updated_submodules }}:
33   - bash: |
34       set -e
35       # Submodules pseudo-files inside git have the 160000 permissions, so when
36       # those files are present in the diff a submodule was updated.
37       if git diff HEAD^ | grep "^index .* 160000" >/dev/null 2>&1; then
38           echo "Executing the job since submodules are updated"
39       else
40           echo "Not executing this job since no submodules were updated"
41           echo "##vso[task.setvariable variable=SKIP_JOB;]1"
42       fi
43     displayName: Decide whether to run this job
44
45 # Spawn a background process to collect CPU usage statistics which we'll upload
46 # at the end of the build. See the comments in the script here for more
47 # information.
48 - bash: python src/ci/cpu-usage-over-time.py &> cpu-usage.csv &
49   displayName: "Collect CPU-usage statistics in the background"
50
51 - bash: printenv | sort
52   displayName: Show environment variables
53
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 # Install some dependencies needed to build LLDB/Clang, currently only needed
66 # during the `dist` target
67 - bash: |
68     set -e
69     brew update
70     brew install xz
71     brew install swig@3
72     brew link --force swig@3
73   displayName: Install build dependencies (OSX)
74   condition: and(succeeded(), eq(variables['Agent.OS'], 'Darwin'), eq(variables['SCRIPT'],'./x.py dist'))
75
76 # Switch to XCode 9.3 on OSX since it seems to be the last version that supports
77 # i686-apple-darwin. We'll eventually want to upgrade this and it will probably
78 # force us to drop i686-apple-darwin, but let's keep the wheels turning for now.
79 - bash: |
80     set -e
81     sudo xcode-select --switch /Applications/Xcode_9.3.app
82   displayName: Switch to Xcode 9.3 (OSX)
83   condition: and(succeeded(), eq(variables['Agent.OS'], 'Darwin'))
84
85 - template: install-windows-build-deps.yml
86
87 # Looks like docker containers have IPv6 disabled by default, so let's turn it
88 # on since libstd tests require it
89 - bash: |
90     set -e
91     sudo mkdir -p /etc/docker
92     echo '{"ipv6":true,"fixed-cidr-v6":"fd9a:8454:6789:13f7::/64"}' | sudo tee /etc/docker/daemon.json
93     sudo service docker restart
94   displayName: Enable IPv6
95   condition: and(succeeded(), not(variables.SKIP_JOB), eq(variables['Agent.OS'], 'Linux'))
96
97 # Disable automatic line ending conversion (again). On Windows, when we're
98 # installing dependencies, something switches the git configuration directory or
99 # re-enables autocrlf. We've not tracked down the exact cause -- and there may
100 # be multiple -- but this should ensure submodules are checked out with the
101 # appropriate line endings.
102 - bash: git config --replace-all --global core.autocrlf false
103   displayName: "Disable git automatic line ending conversion"
104
105 # Check out all our submodules, but more quickly than using git by using one of
106 # our custom scripts
107 - bash: |
108     set -e
109     mkdir -p $HOME/rustsrc
110     $BUILD_SOURCESDIRECTORY/src/ci/init_repo.sh . $HOME/rustsrc
111   condition: and(succeeded(), not(variables.SKIP_JOB), ne(variables['Agent.OS'], 'Windows_NT'))
112   displayName: Check out submodules (Unix)
113 - script: |
114     if not exist C:\cache\rustsrc\NUL mkdir C:\cache\rustsrc
115     sh src/ci/init_repo.sh . /c/cache/rustsrc
116   condition: and(succeeded(), not(variables.SKIP_JOB), eq(variables['Agent.OS'], 'Windows_NT'))
117   displayName: Check out submodules (Windows)
118
119 # See also the disable for autocrlf above, this just checks that it worked
120 #
121 # We check both in rust-lang/rust and in a submodule to make sure both are
122 # accurate. Submodules are checked out significantly later than the main
123 # repository in this script, so settings can (and do!) change between then.
124 #
125 # Linux (and maybe macOS) builders don't currently have dos2unix so just only
126 # run this step on Windows.
127 - bash: |
128     set -x
129     # print out the git configuration so we can better investigate failures in
130     # the following
131     git config --list --show-origin
132     dos2unix -ih Cargo.lock src/tools/rust-installer/install-template.sh
133     endings=$(dos2unix -ic Cargo.lock src/tools/rust-installer/install-template.sh)
134     # if endings has non-zero length, error out
135     if [ -n "$endings" ]; then exit 1 ; fi
136   condition: and(succeeded(), eq(variables['Agent.OS'], 'Windows_NT'))
137   displayName: Verify line endings are LF
138
139 # Ensure the `aws` CLI is installed so we can deploy later on, cache docker
140 # images, etc.
141 - bash: |
142     set -e
143     # Temporary code to debug #62967.
144     debug_failed_connections() {
145         echo "trying to ping pypi.org"
146         ping pypi.org -c10 || true
147         echo "trying to ping google.com"
148         ping google.com -c10 || true
149         echo "trying to ping 8.8.8.8"
150         ping 8.8.8.8 -c10 || true
151         echo "trying to download pypi.org"
152         curl https://pypi.org || true
153         echo "trying to download from our S3 bucket"
154         curl https://rust-lang-ci2.s3.amazonaws.com || true
155         echo "trying to dig pypi.org"
156         dig pypi.org || true
157         echo "trying to dig files.pythonhosted.org"
158         dig files.pythonhosted.org || true
159         echo "trying to connect to pypi.org with openssl"
160         echo | openssl s_client -connect pypi.org:443 || true
161         echo "trying to connect to files.pythonhosted.org with openssl"
162         echo | openssl s_client -connect files.pythonhosted.org:443 || true
163     }
164     debug_failed_connections_and_fail() {
165         debug_failed_connections
166         return 1
167     }
168     source src/ci/shared.sh
169     sudo apt-get install -y python3-setuptools
170     debug_failed_connections
171     retry pip3 install -r src/ci/awscli-requirements.txt --upgrade --user || debug_failed_connections_and_fail
172     echo "##vso[task.prependpath]$HOME/.local/bin"
173   displayName: Install awscli (Linux)
174   condition: and(succeeded(), not(variables.SKIP_JOB), eq(variables['Agent.OS'], 'Linux'))
175 - script: pip install -r src/ci/awscli-requirements.txt
176   displayName: Install awscli (non-Linux)
177   condition: and(succeeded(), not(variables.SKIP_JOB), ne(variables['Agent.OS'], 'Linux'))
178
179 # Configure our CI_JOB_NAME variable which log analyzers can use for the main
180 # step to see what's going on.
181 - bash: |
182     builder=$(echo $AGENT_JOBNAME | cut -d ' ' -f 2)
183     echo "##vso[task.setvariable variable=CI_JOB_NAME]$builder"
184   displayName: Configure Job Name
185
186 # As a quick smoke check on the otherwise very fast mingw-check linux builder
187 # check our own internal scripts.
188 - bash: |
189     set -e
190     git clone --depth=1 https://github.com/rust-lang-nursery/rust-toolstate.git
191     cd rust-toolstate
192     python2.7 "$BUILD_SOURCESDIRECTORY/src/tools/publish_toolstate.py" "$(git rev-parse HEAD)" "$(git log --format=%s -n1 HEAD)" "" ""
193     cd ..
194     rm -rf rust-toolstate
195   condition: and(succeeded(), not(variables.SKIP_JOB), eq(variables['IMAGE'], 'mingw-check'))
196   displayName: Verify the publish_toolstate script works
197
198 - bash: |
199     set -e
200     # Remove any preexisting rustup installation since it can interfere
201     # with the cargotest step and its auto-detection of things like Clippy in
202     # the environment
203     rustup self uninstall -y || true
204     if [ "$IMAGE" = "" ]; then
205       src/ci/run.sh
206     else
207       src/ci/docker/run.sh $IMAGE
208     fi
209   #timeoutInMinutes: 180
210   timeoutInMinutes: 600
211   env:
212     CI: true
213     SRC: .
214     AWS_SECRET_ACCESS_KEY: $(AWS_SECRET_ACCESS_KEY)
215     TOOLSTATE_REPO_ACCESS_TOKEN: $(TOOLSTATE_REPO_ACCESS_TOKEN)
216   condition: and(succeeded(), not(variables.SKIP_JOB))
217   displayName: Run build
218
219 # If we're a deploy builder, use the `aws` command to publish everything to our
220 # bucket.
221 - bash: |
222     set -e
223     source src/ci/shared.sh
224     if [ "$AGENT_OS" = "Linux" ]; then
225         rm -rf obj/build/dist/doc
226         upload_dir=obj/build/dist
227     else
228         rm -rf build/dist/doc
229         upload_dir=build/dist
230     fi
231     ls -la $upload_dir
232     deploy_dir=rustc-builds
233     if [ "$DEPLOY_ALT" == "1" ]; then
234         deploy_dir=rustc-builds-alt
235     fi
236     retry aws s3 cp --no-progress --recursive --acl public-read ./$upload_dir s3://$DEPLOY_BUCKET/$deploy_dir/$BUILD_SOURCEVERSION
237   env:
238     AWS_SECRET_ACCESS_KEY: $(AWS_SECRET_ACCESS_KEY)
239   condition: and(succeeded(), not(variables.SKIP_JOB), or(eq(variables.DEPLOY, '1'), eq(variables.DEPLOY_ALT, '1')))
240   displayName: Upload artifacts
241
242 # Upload CPU usage statistics that we've been gathering this whole time. Always
243 # execute this step in case we want to inspect failed builds, but don't let
244 # errors here ever fail the build since this is just informational.
245 - bash: aws s3 cp --acl public-read cpu-usage.csv s3://$DEPLOY_BUCKET/rustc-builds/$BUILD_SOURCEVERSION/cpu-$SYSTEM_JOBNAME.csv
246   env:
247     AWS_SECRET_ACCESS_KEY: $(AWS_SECRET_ACCESS_KEY)
248   condition: variables['AWS_SECRET_ACCESS_KEY']
249   continueOnError: true
250   displayName: Upload CPU usage statistics