Skip to content

Commit 7bd52a1

Browse files
VSTS: Skip build steps when only docs have changed (GH-8546)
(cherry picked from commit b221c93) Co-authored-by: Steve Dower <steve.dower@microsoft.com>
1 parent 5799e5a commit 7bd52a1

5 files changed

Lines changed: 87 additions & 1 deletion

File tree

.vsts/docs.yml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,35 @@ steps:
2323
clean: true
2424
fetchDepth: 5
2525

26+
- script: |
27+
git fetch -q origin $(system.pullRequest.targetBranch)
28+
if ! git diff --name-only HEAD $(git merge-base HEAD FETCH_HEAD) | grep -qE '(\.rst$|^Doc|^Misc)'
29+
then
30+
echo "No docs were updated, stopping build process."
31+
echo "##vso[task.setvariable variable=NoDocs]true"
32+
exit
33+
fi
34+
displayName: Detect doc-only changes
35+
condition: and(succeeded(), variables['system.pullRequest.targetBranch'])
36+
2637
- task: UsePythonVersion@0
2738
displayName: 'Use Python 3.6 or later'
2839
inputs:
2940
versionSpec: '>=3.6'
41+
condition: and(succeeded(), ne(variables['NoDocs'], 'true'))
3042

3143
- script: python -m pip install sphinx~=1.6.1 blurb python-docs-theme
3244
displayName: 'Install build dependencies'
45+
condition: and(succeeded(), ne(variables['NoDocs'], 'true'))
3346

3447
- script: make check suspicious html PYTHON=python
3548
workingDirectory: '$(build.sourcesDirectory)/Doc'
3649
displayName: 'Build documentation'
50+
condition: and(succeeded(), ne(variables['NoDocs'], 'true'))
3751

3852
- task: PublishBuildArtifacts@1
3953
displayName: 'Publish build'
40-
condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest'))
54+
condition: and(and(succeeded(), ne(variables['Build.Reason'], 'PullRequest')), ne(variables['NoDocs'], 'true'))
4155
inputs:
4256
PathToPublish: '$(build.sourcesDirectory)/Doc/build'
4357
ArtifactName: build

.vsts/linux-coverage.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,24 @@ steps:
2727
clean: true
2828
fetchDepth: 5
2929

30+
- script: |
31+
git fetch -q origin $(system.pullRequest.targetBranch)
32+
if ! git diff --name-only HEAD $(git merge-base HEAD FETCH_HEAD) | grep -qvE '(\.rst$|^Doc|^Misc)'
33+
then
34+
echo "Only docs were updated, stopping build process."
35+
echo "##vso[task.setvariable variable=DocOnly]true"
36+
exit
37+
fi
38+
displayName: Detect doc-only changes
39+
condition: and(succeeded(), variables['system.pullRequest.targetBranch'])
40+
3041
#- template: linux-deps.yml
3142

3243
# See https://github.com/Microsoft/vsts-agent/blob/master/docs/preview/yamlgettingstarted-templates.md
3344
# For now, we copy/paste the steps
3445
- script: echo "deb-src http://archive.ubuntu.com/ubuntu/ xenial main" > /etc/apt/sources.list.d/python.list && sudo apt-get update
3546
displayName: 'Update apt-get lists'
47+
condition: and(succeeded(), ne(variables['DocOnly'], 'true'))
3648

3749
- script: echo ##vso[task.prependpath]$(OPENSSL_DIR)
3850
displayName: 'Add $(OPENSSL_DIR) to PATH'
@@ -55,24 +67,32 @@ steps:
5567
uuid-dev
5668
xvfb
5769
displayName: 'Install dependencies'
70+
condition: and(succeeded(), ne(variables['DocOnly'], 'true'))
5871
- script: python3 Tools/ssl/multissltests.py --steps=library --base-directory $(build.sourcesDirectory)/multissl --openssl $(OPENSSL) --system Linux
5972
displayName: 'python multissltests.py'
73+
condition: and(succeeded(), ne(variables['DocOnly'], 'true'))
6074

6175

6276
- script: ./configure --with-pydebug
6377
displayName: 'Configure CPython (debug)'
78+
condition: and(succeeded(), ne(variables['DocOnly'], 'true'))
6479

6580
- script: make -s -j4
6681
displayName: 'Build CPython'
82+
condition: and(succeeded(), ne(variables['DocOnly'], 'true'))
6783

6884
- script: ./python -m venv venv && ./venv/bin/python -m pip install -U coverage
6985
displayName: 'Set up virtual environment'
86+
condition: and(succeeded(), ne(variables['DocOnly'], 'true'))
7087

7188
- script: ./venv/bin/python -m test.pythoninfo
7289
displayName: 'Display build info'
90+
condition: and(succeeded(), ne(variables['DocOnly'], 'true'))
7391

7492
- script: xvfb-run ./venv/bin/python -m coverage run --pylib -m test --fail-env-changed -uall,-cpu -x test_multiprocessing_fork -x test_multiprocessing_forkserver -x test_multiprocessing_spawn -x test_concurrent_futures
7593
displayName: 'Tests with coverage'
94+
condition: and(succeeded(), ne(variables['DocOnly'], 'true'))
7695

7796
- script: source ./venv/bin/activate && bash <(curl -s https://codecov.io/bash)
7897
displayName: 'Publish code coverage results'
98+
condition: and(succeeded(), ne(variables['DocOnly'], 'true'))

.vsts/linux-pr.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,29 @@ steps:
2727
clean: true
2828
fetchDepth: 5
2929

30+
- script: |
31+
git fetch -q origin $(system.pullRequest.targetBranch)
32+
if ! git diff --name-only HEAD $(git merge-base HEAD FETCH_HEAD) | grep -qvE '(\.rst$|^Doc|^Misc)'
33+
then
34+
echo "Only docs were updated, stopping build process."
35+
echo "##vso[task.setvariable variable=DocOnly]true"
36+
exit
37+
fi
38+
displayName: Detect doc-only changes
39+
condition: and(succeeded(), variables['system.pullRequest.targetBranch'])
40+
3041
#- template: linux-deps.yml
3142

3243
# See https://github.com/Microsoft/vsts-agent/blob/master/docs/preview/yamlgettingstarted-templates.md
3344
# For now, we copy/paste the steps
3445
- script: echo "deb-src http://archive.ubuntu.com/ubuntu/ xenial main" > /etc/apt/sources.list.d/python.list && sudo apt-get update
3546
displayName: 'Update apt-get lists'
47+
condition: and(succeeded(), ne(variables['DocOnly'], 'true'))
3648

3749
- script: echo ##vso[task.prependpath]$(OPENSSL_DIR)
3850
displayName: 'Add $(OPENSSL_DIR) to PATH'
51+
condition: and(succeeded(), ne(variables['DocOnly'], 'true'))
52+
3953
- script: >
4054
sudo apt-get -yq install
4155
build-essential
@@ -55,22 +69,30 @@ steps:
5569
uuid-dev
5670
xvfb
5771
displayName: 'Install dependencies'
72+
condition: and(succeeded(), ne(variables['DocOnly'], 'true'))
73+
5874
- script: python3 Tools/ssl/multissltests.py --steps=library --base-directory $(build.sourcesDirectory)/multissl --openssl $(OPENSSL) --system Linux
5975
displayName: 'python multissltests.py'
76+
condition: and(succeeded(), ne(variables['DocOnly'], 'true'))
6077

6178

6279
- script: ./configure --with-pydebug
6380
displayName: 'Configure CPython (debug)'
81+
condition: and(succeeded(), ne(variables['DocOnly'], 'true'))
6482

6583
- script: make -s -j4
6684
displayName: 'Build CPython'
85+
condition: and(succeeded(), ne(variables['DocOnly'], 'true'))
6786

6887
- script: make pythoninfo
6988
displayName: 'Display build info'
89+
condition: and(succeeded(), ne(variables['DocOnly'], 'true'))
7090

7191
# Run patchcheck and fail if anything is discovered
7292
- script: ./python Tools/scripts/patchcheck.py --travis true
7393
displayName: 'Run patchcheck.py'
94+
condition: and(succeeded(), ne(variables['DocOnly'], 'true'))
7495

7596
- script: xvfb-run make buildbottest TESTOPTS="-j4 -uall,-cpu"
7697
displayName: 'Tests'
98+
condition: and(succeeded(), ne(variables['DocOnly'], 'true'))

.vsts/macos-pr.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,32 @@ steps:
2424
clean: true
2525
fetchDepth: 5
2626

27+
- script: |
28+
git fetch -q origin $(system.pullRequest.targetBranch)
29+
changes = $(git diff --name-only HEAD $(git merge-base HEAD FETCH_HEAD))
30+
echo "Files changed:"
31+
echo "$changes"
32+
if ! echo "$changes" | grep -qvE '(\.rst$)|(^Doc)|(^Misc)'
33+
then
34+
echo "Only docs were updated, stopping build process."
35+
echo "##vso[task.setvariable variable=DocOnly]true"
36+
exit
37+
fi
38+
displayName: Detect doc-only changes
39+
condition: and(succeeded(), variables['system.pullRequest.targetBranch'])
40+
2741
- script: ./configure --with-pydebug --with-openssl=/usr/local/opt/openssl --prefix=/opt/python-vsts
2842
displayName: 'Configure CPython (debug)'
43+
condition: and(succeeded(), ne(variables['DocOnly'], 'true'))
2944

3045
- script: make -s -j4
3146
displayName: 'Build CPython'
47+
condition: and(succeeded(), ne(variables['DocOnly'], 'true'))
3248

3349
- script: make pythoninfo
3450
displayName: 'Display build info'
51+
condition: and(succeeded(), ne(variables['DocOnly'], 'true'))
3552

3653
- script: make buildbottest TESTOPTS="-j4 -uall,-cpu"
3754
displayName: 'Tests'
55+
condition: and(succeeded(), ne(variables['DocOnly'], 'true'))

.vsts/windows-pr.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,25 @@ steps:
3737
clean: true
3838
fetchDepth: 5
3939

40+
- powershell: |
41+
git fetch -q origin $(System.PullRequest.TargetBranch)
42+
if (-not (git diff --name-only HEAD (git merge-base HEAD FETCH_HEAD) | sls -NotMatch '(\.rst$)|(^Doc)|(^Misc)')) {
43+
Write-Host 'Only docs were updated. Skipping build'
44+
Write-Host '##vso[task.setvariable variable=DocOnly]true'
45+
}
46+
displayName: Detect doc-only changes
47+
condition: and(succeeded(), variables['System.PullRequest.TargetBranch'])
48+
4049
- script: PCbuild\build.bat -e $(buildOpt)
4150
displayName: 'Build CPython'
51+
condition: and(succeeded(), ne(variables['DocOnly'], 'true'))
4252

4353
- script: python.bat -m test.pythoninfo
4454
displayName: 'Display build info'
55+
condition: and(succeeded(), ne(variables['DocOnly'], 'true'))
4556

4657
- script: PCbuild\rt.bat -q -uall -u-cpu -rwW --slowest --timeout=1200 -j0
4758
displayName: 'Tests'
4859
env:
4960
PREFIX: $(Py_OutDir)\$(outDirSuffix)
61+
condition: and(succeeded(), ne(variables['DocOnly'], 'true'))

0 commit comments

Comments
 (0)