Skip to content

Commit bb7e107

Browse files
StanFromIrelandhugovk
authored andcommitted
[3.10] RTD Previews: Get correct base branch for backports (GH-150690)
(cherry picked from commit 082ac30) Co-authored-by: Stan Ulbrych <stan@python.org>
1 parent 938ec03 commit bb7e107

1 file changed

Lines changed: 55 additions & 9 deletions

File tree

.readthedocs.yml

Lines changed: 55 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,60 @@
1-
# This is a dummy config file so that readthedocs.org doesn't fail on security branches.
2-
# Note that this won't result in docs actually getting built;
3-
# clicking on the docs preview link on a PR will result in a 404.
1+
# Read the Docs configuration file
2+
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
3+
# Project page: https://readthedocs.org/projects/cpython-previews/
4+
45
version: 2
5-
formats: []
6+
67
sphinx:
7-
configuration: Doc/conf.py
8+
configuration: Doc/conf.py
9+
810
build:
9-
os: "ubuntu-22.04"
11+
os: ubuntu-24.04
1012
tools:
11-
python: "3.11"
13+
python: "3"
14+
apt_packages:
15+
- jq
16+
1217
jobs:
13-
post_checkout:
14-
- exit 183
18+
post_system_dependencies:
19+
# https://docs.readthedocs.com/platform/stable/guides/build/skip-build.html#skip-builds-based-on-conditions
20+
#
21+
# Cancel building pull requests when there are no changes in the Doc
22+
# directory or RTD configuration, or if we can't cleanly merge the base
23+
# branch.
24+
- |
25+
set -eEux;
26+
if [ "$READTHEDOCS_VERSION_TYPE" = "external" ];
27+
then
28+
base_branch=$(wget -qO- "https://api.github.com/repos/python/cpython/pulls/$READTHEDOCS_VERSION" | jq -er ".base.ref");
29+
git fetch --depth=50 origin $base_branch:origin-$base_branch;
30+
for attempt in $(seq 10);
31+
do
32+
if ! git merge-base HEAD origin-$base_branch;
33+
then
34+
git fetch --deepen=50 origin $base_branch;
35+
else
36+
break;
37+
fi;
38+
done;
39+
if ! git -c "user.name=rtd" -c "user.email=no-reply@readthedocs.org" merge --no-stat --no-edit origin-$base_branch;
40+
then
41+
echo "Unsuccessful merge with '$base_branch' branch, skipping the build";
42+
exit 183;
43+
fi;
44+
if git diff --exit-code --stat origin-$base_branch -- Doc/ .readthedocs.yml;
45+
then
46+
echo "No changes to Doc/ - skipping the build.";
47+
exit 183;
48+
fi;
49+
fi;
50+
create_environment:
51+
- echo "Skipping default environment creation"
52+
install:
53+
- asdf plugin add uv
54+
- asdf install uv latest
55+
- asdf global uv latest
56+
build:
57+
html:
58+
- make -C Doc venv html
59+
- mkdir -p "$READTHEDOCS_OUTPUT"
60+
- mv Doc/build/html "$READTHEDOCS_OUTPUT/"

0 commit comments

Comments
 (0)