Skip to content

Commit 2d2dcb0

Browse files
committed
ci: add a pr builder to test tools when submodules are updated
The builder will skip time consuming tasks (like the actual tests) when it detects no updated submodules.
1 parent 78ca1bd commit 2d2dcb0

File tree

2 files changed

+38
-18
lines changed

2 files changed

+38
-18
lines changed

.azure-pipelines/pr.yml

+9-11
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,12 @@ jobs:
2020
mingw-check:
2121
IMAGE: mingw-check
2222

23-
# TODO: enable this job if the commit message matches this regex, need tools
24-
# figure out how to get the current commit message on azure and stick it in a
25-
# condition somewhere
26-
# if: commit_message =~ /(?i:^update.*\b(rls|rustfmt|clippy|miri|cargo)\b)/
27-
# - job: Linux-x86_64-gnu-tools
28-
# pool:
29-
# vmImage: ubuntu-16.04
30-
# steps:
31-
# - template: steps/run.yml
32-
# variables:
33-
# IMAGE: x86_64-gnu-tools
23+
- job: LinuxTools
24+
pool:
25+
vmImage: ubuntu-16.04
26+
steps:
27+
- template: steps/run.yml
28+
parameters:
29+
only_on_updated_submodules: 'yes'
30+
variables:
31+
IMAGE: x86_64-gnu-tools

.azure-pipelines/steps/run.yml

+29-7
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66
#
77
# Check travis config for `gdb --batch` command to print all crash logs
88

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+
914
steps:
1015

1116
# Disable automatic line ending conversion, which is enabled by default on
@@ -18,6 +23,22 @@ steps:
1823
- checkout: self
1924
fetchDepth: 2
2025

26+
# Set the SKIP_JOB environment variable if this job is supposed to only run
27+
# when submodules are updated and they were not. The following time consuming
28+
# tasks will be skipped when the environment variable is present.
29+
- ${{ if parameters.only_on_updated_submodules }}:
30+
- bash: |
31+
set -e
32+
# Submodules pseudo-files inside git have the 160000 permissions, so when
33+
# those files are present in the diff a submodule was updated.
34+
if git diff HEAD^ | grep "^index .* 160000" >/dev/null 2>&1; then
35+
echo "Executing the job since submodules are updated"
36+
else
37+
echo "Not executing this job since no submodules were updated"
38+
echo "##vso[task.setvariable variable=SKIP_JOB;]1"
39+
fi
40+
displayName: Decide whether to run this job
41+
2142
# Spawn a background process to collect CPU usage statistics which we'll upload
2243
# at the end of the build. See the comments in the script here for more
2344
# information.
@@ -68,20 +89,20 @@ steps:
6889
echo '{"ipv6":true,"fixed-cidr-v6":"fd9a:8454:6789:13f7::/64"}' | sudo tee /etc/docker/daemon.json
6990
sudo service docker restart
7091
displayName: Enable IPv6
71-
condition: and(succeeded(), eq(variables['Agent.OS'], 'Linux'))
92+
condition: and(succeeded(), not(variables.SKIP_JOB), eq(variables['Agent.OS'], 'Linux'))
7293

7394
# Check out all our submodules, but more quickly than using git by using one of
7495
# our custom scripts
7596
- bash: |
7697
set -e
7798
mkdir -p $HOME/rustsrc
7899
$BUILD_SOURCESDIRECTORY/src/ci/init_repo.sh . $HOME/rustsrc
79-
condition: and(succeeded(), ne(variables['Agent.OS'], 'Windows_NT'))
100+
condition: and(succeeded(), not(variables.SKIP_JOB), ne(variables['Agent.OS'], 'Windows_NT'))
80101
displayName: Check out submodules (Unix)
81102
- script: |
82103
if not exist D:\cache\rustsrc\NUL mkdir D:\cache\rustsrc
83104
sh src/ci/init_repo.sh . /d/cache/rustsrc
84-
condition: and(succeeded(), eq(variables['Agent.OS'], 'Windows_NT'))
105+
condition: and(succeeded(), not(variables.SKIP_JOB), eq(variables['Agent.OS'], 'Windows_NT'))
85106
displayName: Check out submodules (Windows)
86107

87108
# Ensure the `aws` CLI is installed so we can deploy later on, cache docker
@@ -93,10 +114,10 @@ steps:
93114
retry pip3 install awscli --upgrade --user
94115
echo "##vso[task.prependpath]$HOME/.local/bin"
95116
displayName: Install awscli (Linux)
96-
condition: and(succeeded(), eq(variables['Agent.OS'], 'Linux'))
117+
condition: and(succeeded(), not(variables.SKIP_JOB), eq(variables['Agent.OS'], 'Linux'))
97118
- script: pip install awscli
98119
displayName: Install awscli (non-Linux)
99-
condition: and(succeeded(), ne(variables['Agent.OS'], 'Linux'))
120+
condition: and(succeeded(), not(variables.SKIP_JOB), ne(variables['Agent.OS'], 'Linux'))
100121

101122
# Configure our CI_JOB_NAME variable which log analyzers can use for the main
102123
# step to see what's going on.
@@ -112,7 +133,7 @@ steps:
112133
python2.7 "$BUILD_SOURCESDIRECTORY/src/tools/publish_toolstate.py" "$(git rev-parse HEAD)" "$(git log --format=%s -n1 HEAD)" "" ""
113134
cd ..
114135
rm -rf rust-toolstate
115-
condition: and(succeeded(), eq(variables['IMAGE'], 'mingw-check'))
136+
condition: and(succeeded(), not(variables.SKIP_JOB), eq(variables['IMAGE'], 'mingw-check'))
116137
displayName: Verify the publish_toolstate script works
117138

118139
- bash: |
@@ -133,6 +154,7 @@ steps:
133154
SRC: .
134155
AWS_SECRET_ACCESS_KEY: $(AWS_SECRET_ACCESS_KEY)
135156
TOOLSTATE_REPO_ACCESS_TOKEN: $(TOOLSTATE_REPO_ACCESS_TOKEN)
157+
condition: and(succeeded(), not(variables.SKIP_JOB))
136158
displayName: Run build
137159

138160
# If we're a deploy builder, use the `aws` command to publish everything to our
@@ -155,7 +177,7 @@ steps:
155177
retry aws s3 cp --no-progress --recursive --acl public-read ./$upload_dir s3://$DEPLOY_BUCKET/$deploy_dir/$BUILD_SOURCEVERSION
156178
env:
157179
AWS_SECRET_ACCESS_KEY: $(AWS_SECRET_ACCESS_KEY)
158-
condition: and(succeeded(), or(eq(variables.DEPLOY, '1'), eq(variables.DEPLOY_ALT, '1')))
180+
condition: and(succeeded(), not(variables.SKIP_JOB), or(eq(variables.DEPLOY, '1'), eq(variables.DEPLOY_ALT, '1')))
159181
displayName: Upload artifacts
160182

161183
# Upload CPU usage statistics that we've been gathering this whole time. Always

0 commit comments

Comments
 (0)