@@ -12,23 +12,47 @@ build:
1212 tools :
1313 python : " 3"
1414
15- commands :
16- # https://docs.readthedocs.io/en/stable/build-customization.html#cancel-build-based-on-a-condition
17- #
18- # Cancel building pull requests when there aren't changes in the Doc directory.
19- #
20- # If there are no changes (git diff exits with 0) we force the command to return with 183.
21- # This is a special exit code on Read the Docs that will cancel the build immediately.
22- - |
23- if [ "$READTHEDOCS_VERSION_TYPE" = "external" ] && [ "$(git diff --quiet origin/main -- Doc/ .readthedocs.yml; echo $?)" -eq 0 ];
24- then
25- echo "No changes to Doc/ - exiting the build.";
26- exit 183;
27- fi
28-
29- - asdf plugin add uv
30- - asdf install uv latest
31- - asdf global uv latest
32- - make -C Doc venv html
33- - mkdir _readthedocs
34- - mv Doc/build/html _readthedocs/html
15+ jobs :
16+ post_checkout :
17+ # https://docs.readthedocs.com/platform/stable/guides/build/skip-build.html#skip-builds-based-on-conditions
18+ #
19+ # Cancel building pull requests when there aren't changes in the Doc
20+ # directory or RTD configuration, or if we can't cleanly merge the base
21+ # branch.
22+ - |
23+ set -eEux;
24+ if [ "$READTHEDOCS_VERSION_TYPE" = "external" ];
25+ then
26+ base_branch=3.14;
27+ git fetch --depth=50 origin $base_branch;
28+ for attempt in $(seq 10);
29+ do
30+ if ! git merge-base HEAD origin/$base_branch;
31+ then
32+ git fetch --deepen=50 origin $base_branch;
33+ else
34+ break;
35+ fi;
36+ done;
37+ if ! git -c "user.name=rtd" -c "user.email=no-reply@readthedocs.org" merge --no-stat --no-edit origin/$base_branch;
38+ then
39+ echo "Unsuccessful merge with '$base_branch' branch, skipping the build";
40+ exit 183;
41+ fi;
42+ if git diff --exit-code --stat origin/$base_branch -- Doc/ .readthedocs.yml;
43+ then
44+ echo "No changes to Doc/ - skipping the build.";
45+ exit 183;
46+ fi;
47+ fi;
48+ create_environment :
49+ - echo "Skipping default environment creation"
50+ install :
51+ - asdf plugin add uv
52+ - asdf install uv latest
53+ - asdf global uv latest
54+ build :
55+ html :
56+ - make -C Doc venv html
57+ - mkdir -p "$READTHEDOCS_OUTPUT"
58+ - mv Doc/build/html "$READTHEDOCS_OUTPUT/"
0 commit comments