Skip to content

Commit 59ba649

Browse files
thomasjpfanjeremiedbb
authored andcommitted
CI Adds skipping to azure pipelines with commit message (#19134)
1 parent b188f94 commit 59ba649

File tree

1 file changed

+71
-46
lines changed

1 file changed

+71
-46
lines changed

azure-pipelines.yml

+71-46
Original file line numberDiff line numberDiff line change
@@ -8,66 +8,65 @@ schedules:
88
always: true
99

1010
jobs:
11-
- job: linting
12-
displayName: Linting
11+
- job: git_commit
12+
displayName: Get Git Commit
1313
pool:
1414
vmImage: ubuntu-18.04
1515
steps:
16-
- task: UsePythonVersion@0
17-
inputs:
18-
versionSpec: '3.9'
19-
- bash: |
20-
pip install flake8 mypy==0.782
21-
displayName: Install linters
2216
- bash: |
2317
set -ex
2418
if [[ $BUILD_REASON == "PullRequest" ]]; then
2519
# By default pull requests use refs/pull/PULL_ID/merge as the source branch
2620
# which has a "Merge ID into ID" as a commit message. The latest commit
2721
# message is the second to last commit
2822
COMMIT_ID=$(echo $BUILD_SOURCEVERSIONMESSAGE | awk '{print $2}')
29-
COMMIT_MESSAGE=$(git log $COMMIT_ID -1 --pretty=%B)
23+
message=$(git log $COMMIT_ID -1 --pretty=%B)
3024
else
31-
COMMIT_MESSAGE=$BUILD_SOURCEVERSIONMESSAGE
25+
message=$BUILD_SOURCEVERSIONMESSAGE
3226
fi
33-
echo "##vso[task.setvariable variable=COMMIT_MESSAGE]$COMMIT_MESSAGE"
27+
echo "##vso[task.setvariable variable=message;isOutput=true]$message"
28+
name: commit
3429
displayName: Get source version message
30+
31+
- job: linting
32+
dependsOn: [git_commit]
33+
condition: |
34+
and(
35+
succeeded(),
36+
not(contains(dependencies['git_commit']['outputs']['commit.message'], '[lint skip]')),
37+
not(contains(dependencies['git_commit']['outputs']['commit.message'], '[ci skip]'))
38+
)
39+
displayName: Linting
40+
pool:
41+
vmImage: ubuntu-18.04
42+
steps:
43+
- task: UsePythonVersion@0
44+
inputs:
45+
versionSpec: '3.9'
3546
- bash: |
36-
set -ex
37-
if [[ "$COMMIT_MESSAGE" =~ "[lint skip]" ]]; then
38-
# skip linting
39-
echo "Skipping flake8 linting"
40-
exit 0
41-
else
42-
./build_tools/circle/linting.sh
43-
fi
47+
pip install flake8 mypy==0.782
48+
displayName: Install linters
49+
- bash: |
50+
./build_tools/circle/linting.sh
4451
displayName: Run linting
4552
- bash: |
46-
set -ex
47-
if [[ "$COMMIT_MESSAGE" =~ "[lint skip]" ]]; then
48-
# skip linting
49-
echo "Skipping mypy linting"
50-
exit 0
51-
else
52-
mypy sklearn/
53-
fi
53+
mypy sklearn/
5454
displayName: Run mypy
55-
- bash: |
56-
if [[ "$COMMIT_MESSAGE" =~ "[scipy-dev]" ]] || [[ $BUILD_REASON == "Schedule" ]]; then
57-
echo "Running scipy-dev"
58-
echo "##vso[task.setvariable variable=runScipyDev;isOutput=true]true"
59-
else
60-
echo "##vso[task.setvariable variable=runScipyDev;isOutput=true]false"
61-
fi
62-
name: gitCommitMessage
63-
displayName: Determine to run scipy-dev
6455
6556
- template: build_tools/azure/posix.yml
6657
parameters:
6758
name: Linux_Nightly
6859
vmImage: ubuntu-18.04
69-
dependsOn: [linting]
70-
condition: eq(dependencies['linting']['outputs']['gitCommitMessage.runScipyDev'], 'true')
60+
dependsOn: [git_commit, linting]
61+
condition: |
62+
and(
63+
succeeded(),
64+
not(contains(dependencies['git_commit']['outputs']['commit.message'], '[ci skip]')),
65+
or(eq(variables['Build.Reason'], 'Schedule'),
66+
contains(dependencies['git_commit']['outputs']['commit.message'], '[scipy-dev]'
67+
)
68+
)
69+
)
7170
matrix:
7271
pylatest_pip_scipy_dev:
7372
DISTRIB: 'conda-pip-scipy-dev'
@@ -84,6 +83,12 @@ jobs:
8483
parameters:
8584
name: Linux_Runs
8685
vmImage: ubuntu-18.04
86+
dependsOn: [git_commit]
87+
condition: |
88+
and(
89+
succeeded(),
90+
not(contains(dependencies['git_commit']['outputs']['commit.message'], '[ci skip]'))
91+
)
8792
matrix:
8893
pylatest_conda_mkl:
8994
DISTRIB: 'conda'
@@ -95,8 +100,13 @@ jobs:
95100
parameters:
96101
name: Linux
97102
vmImage: ubuntu-18.04
98-
dependsOn: [linting]
99-
condition: and(ne(variables['Build.Reason'], 'Schedule'), succeeded('linting'))
103+
dependsOn: [linting, git_commit]
104+
condition: |
105+
and(
106+
succeeded(),
107+
not(contains(dependencies['git_commit']['outputs']['commit.message'], '[ci skip]')),
108+
ne(variables['Build.Reason'], 'Schedule')
109+
)
100110
matrix:
101111
# Linux environment to test that scikit-learn can be built against
102112
# versions of numpy, scipy with ATLAS that comes with Ubuntu Bionic 18.04
@@ -139,8 +149,13 @@ jobs:
139149
parameters:
140150
name: Linux32
141151
vmImage: ubuntu-18.04
142-
dependsOn: [linting]
143-
condition: and(ne(variables['Build.Reason'], 'Schedule'), succeeded('linting'))
152+
dependsOn: [linting, git_commit]
153+
condition: |
154+
and(
155+
succeeded(),
156+
not(contains(dependencies['git_commit']['outputs']['commit.message'], '[ci skip]')),
157+
ne(variables['Build.Reason'], 'Schedule')
158+
)
144159
matrix:
145160
py36_ubuntu_atlas_32bit:
146161
DISTRIB: 'ubuntu-32'
@@ -157,8 +172,13 @@ jobs:
157172
parameters:
158173
name: macOS
159174
vmImage: macOS-10.14
160-
dependsOn: [linting]
161-
condition: and(ne(variables['Build.Reason'], 'Schedule'), succeeded('linting'))
175+
dependsOn: [linting, git_commit]
176+
condition: |
177+
and(
178+
succeeded(),
179+
not(contains(dependencies['git_commit']['outputs']['commit.message'], '[ci skip]')),
180+
ne(variables['Build.Reason'], 'Schedule')
181+
)
162182
matrix:
163183
pylatest_conda_forge_mkl:
164184
DISTRIB: 'conda'
@@ -174,8 +194,13 @@ jobs:
174194
parameters:
175195
name: Windows
176196
vmImage: vs2017-win2016
177-
dependsOn: [linting]
178-
condition: and(ne(variables['Build.Reason'], 'Schedule'), succeeded('linting'))
197+
dependsOn: [linting, git_commit]
198+
condition: |
199+
and(
200+
succeeded(),
201+
not(contains(dependencies['git_commit']['outputs']['commit.message'], '[ci skip]')),
202+
ne(variables['Build.Reason'], 'Schedule')
203+
)
179204
matrix:
180205
py37_conda_mkl:
181206
PYTHON_VERSION: '3.7'

0 commit comments

Comments
 (0)