@@ -20,26 +20,9 @@ set -x
2020# defines the get_dep and show_installed_libraries functions
2121source build_tools/shared.sh
2222
23- if [ -n " $GITHUB_ACTION " ]
23+ if [[ -n " $CI_PULL_REQUEST " && -z " $CI_TARGET_BRANCH " ] ]
2424then
25- # Map the variables from Github Action to CircleCI
26- CIRCLE_SHA1=$( git log -1 --pretty=format:%H)
27-
28- CIRCLE_JOB=$GITHUB_JOB
29-
30- if [ " $GITHUB_EVENT_NAME " == " pull_request" ]
31- then
32- CIRCLE_BRANCH=$GITHUB_HEAD_REF
33- CI_PULL_REQUEST=true
34- CI_TARGET_BRANCH=$GITHUB_BASE_REF
35- else
36- CIRCLE_BRANCH=$GITHUB_REF_NAME
37- fi
38- fi
39-
40- if [[ -n " $CI_PULL_REQUEST " && -z " $CI_TARGET_BRANCH " ]]
41- then
42- # Get the target branch name when using CircleCI
25+ # CircleCI does not expose the PR base branch as an environment variable.
4326 CI_TARGET_BRANCH=$( curl -s " https://api.github.com/repos/scikit-learn/scikit-learn/pulls/$CIRCLE_PR_NUMBER " | jq -r .base.ref)
4427fi
4528
@@ -140,7 +123,15 @@ then
140123 exit 0
141124fi
142125
143- if [[ " $CIRCLE_BRANCH " =~ ^main$| ^[0-9]+\. [0-9]+\. X$ && -z " $CI_PULL_REQUEST " ]]
126+ # ZIP, image optimization and version listing are only useful for the
127+ # documentation that is deployed to the website (the "doc" CircleCI job).
128+ deploy_docs=false
129+ if [[ " $CIRCLE_BRANCH " =~ ^main$| ^[0-9]+\. [0-9]+\. X$ && -z " $CI_PULL_REQUEST " && " $CIRCLE_JOB " == " doc" ]]
130+ then
131+ deploy_docs=true
132+ fi
133+
134+ if [[ " $deploy_docs " == " true" ]]
144135then
145136 # ZIP linked into HTML
146137 make_args=dist
@@ -157,10 +148,15 @@ else
157148fi
158149
159150# Installing required system packages to support the rendering of math
160- # notation in the HTML documentation and to optimize the image files
151+ # notation in the HTML documentation. zip and optipng are only needed when
152+ # building the downloadable documentation archive for the website.
153+ apt_packages=" dvipng gsfonts ccache"
154+ if [[ " $make_args " == " dist" ]]
155+ then
156+ apt_packages=" $apt_packages zip optipng"
157+ fi
161158sudo -E apt-get -yq update --allow-releaseinfo-change
162- sudo -E apt-get -yq --no-install-suggests --no-install-recommends \
163- install dvipng gsfonts ccache zip optipng
159+ sudo -E apt-get -yq --no-install-suggests --no-install-recommends install $apt_packages
164160
165161# deactivate circleci virtualenv and setup a conda env instead
166162if [[ ` type -t deactivate` ]]; then
203199 towncrier build --yes
204200fi
205201
206- if [[ " $CIRCLE_BRANCH " =~ ^ main$ && -z " $CI_PULL_REQUEST " ]]
202+ if [[ " $CIRCLE_BRANCH " == " main" && " $deploy_docs " == " true " ]]
207203then
208204 # List available documentation versions if on main
209205 python build_tools/circle/list_versions.py --json doc/js/versions.json --rst doc/versions.rst
0 commit comments