@@ -11,8 +11,50 @@ build:
1111 os : ubuntu-22.04
1212 tools :
1313 python : " 3"
14+ apt_packages :
15+ - jq
1416
15- commands :
16- - make -C Doc venv html
17- - mkdir _readthedocs
18- - mv Doc/build/html _readthedocs/html
17+ jobs :
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