8000 CI Move documentation builder to actions (#21137) · scikit-learn/scikit-learn@eb95e44 · GitHub
[go: up one dir, main page]

Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit eb95e44

Browse files
CI Move documentation builder to actions (#21137)
Co-authored-by: Thomas J. Fan <thomasjpfan@gmail.com>
1 parent 122876e commit eb95e44

11 files changed

+163
-72
lines changed

.circleci/config.yml

Lines changed: 25 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,92 +1,42 @@
11
version: 2.1
22

3+
# Parameters required to trigger the execution
4+
# of the "doc-min-dependencies" and "doc" jobs
5+
parameters:
6+
GITHUB_RUN_URL:
7+
type: string
8+
default: "none"
9+
310
jobs:
411
doc-min-dependencies:
512
docker:
613
- image: cimg/python:3.8.12
714
environment:
8-
- OMP_NUM_THREADS: 2
9-
- MKL_NUM_THREADS: 2
10-
- CONDA_ENV_NAME: testenv
11-
- LOCK_FILE: build_tools/circle/doc_min_dependencies_linux-64_conda.lock
15+
- GITHUB_ARTIFACT_URL: << pipeline.parameters.GITHUB_RUN_URL >>/doc-min-dependencies.zip
1216
steps:
1317
- checkout
14-
- run: ./build_tools/circle/checkout_merge_commit.sh
15-
- restore_cache:
16-
key: v1-doc-min-deps-datasets-{{ .Branch }}
17-
- restore_cache:
18-
keys:
19-
- doc-min-deps-ccache-{{ .Branch }}
20-
- doc-min-deps-ccache
21-
- run: ./build_tools/circle/build_doc.sh
22-
- save_cache:
23-
key: doc-min-deps-ccache-{{ .Branch }}-{{ .BuildNum }}
24-
paths:
25-
- ~/.ccache
26-
- ~/.cache/pip
27-
- save_cache:
28-
key: v1-doc-min-deps-datasets-{{ .Branch }}
29-
paths:
30-
- ~/scikit_learn_data
18+
- run: bash build_tools/circle/download_documentation.sh
3119
- store_artifacts:
3220
path: doc/_build/html/stable
3321
destination: doc
34-
- store_artifacts:
35-
path: ~/log.txt
36-
destination: log.txt
3722

3823
doc:
3924
docker:
4025
- image: cimg/python:3.8.12
4126
environment:
42-
- OMP_NUM_THREADS: 2
43-
- MKL_NUM_THREADS: 2
44-
- CONDA_ENV_NAME: testenv
45-
- LOCK_FILE: build_tools/circle/doc_linux-64_conda.lock
27+
- GITHUB_ARTIFACT_URL: << pipeline.parameters.GITHUB_RUN_URL >>/doc.zip
4628
steps:
4729
- checkout
48-
- run: ./build_tools/circle/checkout_merge_commit.sh
49-
- restore_cache:
50-
key: v1-doc-datasets-{{ .Branch }}
51-
- restore_cache:
52-
keys:
53-
- doc-ccache-{{ .Branch }}
54-
- doc-ccache
55-
- run: ./build_tools/circle/build_doc.sh
56-
- save_cache:
57-
key: doc-ccache-{{ .Branch }}-{{ .BuildNum }}
58-
paths:
59-
- ~/.ccache
60-
- ~/.cache/pip
61-
- save_cache:
62-
key: v1-doc-datasets-{{ .Branch }}
63-
paths:
64-
- ~/scikit_learn_data
30+
- run: bash build_tools/circle/download_documentation.sh
6531
- store_artifacts:
6632
path: doc/_build/html/stable
6733
destination: doc
68-
- store_artifacts:
69-
path: ~/log.txt
70-
destination: log.txt
71-
# Persists generated documentation so that it can be attached and deployed
72-
# in the 'deploy' step.
34+
# Persists the generated documentation, so that it
35+
# can be attached and deployed in the "deploy" job
7336
- persist_to_workspace:
7437
root: doc/_build/html
7538
paths: .
7639

77-
lint:
78-
docker:
79-
- image: cimg/python:3.8.12
80-
steps:
81-
- checkout
82-
- run: ./build_tools/circle/checkout_merge_commit.sh
83-
- run:
84-
name: dependencies
85-
command: pip install flake8
86-
- run:
87-
name: linting
88-
command: ./build_tools/circle/linting.sh
89-
9040
linux-arm64:
9141
machine:
9242
image: ubuntu-2004:202101-01
@@ -127,18 +77,23 @@ jobs:
12777
12878
workflows:
12979
version: 2
80+
13081
build-doc-and-deploy:
82+
when:
83+
not:
84+
equal: [ "none", << pipeline.parameters.GITHUB_RUN_URL >> ]
85+
# The jobs should run only when triggered by the workflow
13186
jobs:
132-
- lint
133-
- doc:
134-
requires:
135-
- lint
136-
- doc-min-dependencies:
137-
requires:
138-
- lint
87+
- doc-min-dependencies
88+
- doc
13989
- deploy:
14090
requires:
14191
- doc
92+
14293
linux-arm64:
94+
when:
95+
equal: [ "none", << pipeline.parameters.GITHUB_RUN_URL >> ]
96+
# Prevent double execution of this job: on push
97+
# by default and when triggered by the workflow
14398
jobs:
14499
- linux-arm64

.github/workflows/build-docs.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# Workflow t 10000 o build the documentation
2+
name: Documentation builder
3+
4+
on:
5+
push:
6+
branches:
7+
- main
8+
# Release branches
9+
- "[0-9]+.[0-9]+.X"
10+
pull_request:
11+
branches:
12+
- main
13+
- "[0-9]+.[0-9]+.X"
14+
15+
jobs:
16+
# Build the documentation against the minimum version of the dependencies
17+
doc-min-dependencies:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Checkout scikit-learn
21+
uses: actions/checkout@v2
22+
with:
23+
ref: ${{ github.event.pull_request.head.sha }}
24+
25+
- name: Setup Python
26+
uses: actions/setup-python@v2
27+
28+
- name: Build documentation
29+
run: bash build_tools/github/build_doc.sh
30+
env:
31+
OMP_NUM_THREADS: 2
32+
MKL_NUM_THREADS: 2
33+
CONDA_ENV_NAME: testenv
34+
LOCK_FILE: build_tools/github/doc_min_dependencies_linux-64_conda.lock
35+
36+
- name: Upload documentation
37+
uses: actions/upload-artifact@v2
38+
with:
39+
name: doc-min-dependencies
40+
path: doc/_build/html/stable
41+
42+
# Build the documentation against the latest version of the dependencies
43+
doc:
44+
runs-on: ubuntu-latest
45+
steps:
46+
- name: Checkout scikit-learn
47+
uses: actions/checkout@v2
48+
with:
49+
ref: ${{ github.event.pull_request.head.sha }}
50+
51+
- name: Setup Python
52+
uses: actions/setup-python@v2
53+
54+
- name: Build documentation
55+
run: bash build_tools/github/build_doc.sh
56+
env:
57+
OMP_NUM_THREADS: 2
58+
MKL_NUM_THREADS: 2
59+
CONDA_ENV_NAME: testenv
60+
LOCK_FILE: build_tools/github/doc_linux-64_conda.lock
61+
62+
- name: Upload documentation
63+
uses: actions/upload-artifact@v2
64+
with:
65+
name: doc
66+
path: doc/_build/html/stable

.github/workflows/trigger-hosting.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Workflow to trigger the jobs that will host the documentation
2+
name: Documentation push trigger
3+
on:
4+
workflow_run:
5+
# Run the workflow after the separate "Documentation builder" workflow completes
6+
workflows: [Documentation builder]
7+
types:
8+
- completed
9+
10+
jobs:
11+
push:
12+
runs-on: ubuntu-latest
13+
# Run the job only if the "Documentation builder" workflow succeeded
14+
if: ${{ github.event.workflow_run.conclusion == 'success' }}
15+
steps:
16+
- name: Checkout scikit-learn
17+
uses: actions/checkout@v2
18+
19+
- name: Trigger hosting jobs
20+
run: bash build_tools/github/trigger_hosting.sh
21+
env:
22+
CIRCLE_CI_TOKEN: ${{ secrets.CIRCLE_CI_TOKEN }}
23+
EVENT: ${{ github.event.workflow_run.event }}
24+
RUN_ID: ${{ github.event.workflow_run.id }}
25+
HEAD_BRANCH: ${{ github.event.workflow_run.head_branch }}
26+
PULL_REQUEST_NUMBER: ${{ github.event.workflow_run.pull_requests[0].number }}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
3+
set -e
4+
set -x
5+
6+
wget $GITHUB_ARTIFACT_URL
7+
mkdir -p doc/_build/html/stable
8+
unzip doc*.zip -d doc/_build/html/stable

build_tools/circle/build_doc.sh renamed to build_tools/github/build_doc.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,21 @@ set -e
1717
# If the inspection of the current commit fails for any reason, the default
1818
# behavior is to quick build the documentation.
1919

20+
if [ -n "$GITHUB_ACTION" ]
21+
then
22+
# Map the variables for the new documentation builder to the old one
23+
CIRCLE_SHA1=$(git log --no-merges -1 --pretty=format:%H)
24+
CIRCLE_JOB=$GITHUB_JOB
25+
26+
if [ "$GITHUB_EVENT_NAME" == "pull_request" ]
27+
then
28+
CIRCLE_BRANCH=$GITHUB_HEAD_REF
29+
CI_PULL_REQUEST=true
30+
else
31+
CIRCLE_BRANCH=$GITHUB_REF_NAME
32+
fi
33+
fi
34+
2035
get_build_type() {
2136
if [ -z "$CIRCLE_SHA1" ]
2237
then

build_tools/github/trigger_hosting.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
3+
set -e
4+
set -x
5+
6+
GITHUB_RUN_URL=https://nightly.link/$GITHUB_REPOSITORY/actions/runs/$RUN_ID
7+
8+
if [ "$EVENT" == pull_request ]
9+
then
10+
BRANCH=pull/$PULL_REQUEST_NUMBER/head
11+
else
12+
BRANCH=$HEAD_BRANCH
13+
fi
14+
15+
curl --request POST \
16+
--url https://circleci.com/api/v2/project/gh/$GITHUB_REPOSITORY/pipeline \
17+
--header "Circle-Token: $CIRCLE_CI_TOKEN" \
18+
--header "content-type: application/json" \
19+
--header "x-attribution-actor-id: github_actions" \
20+
--header "x-attribution-login: github_actions" \
21+
--data \{\"branch\":\"$BRANCH\",\"parameters\":\{\"GITHUB_RUN_URL\":\"$GITHUB_RUN_URL\"\}\}

build_tools/update_environments_and_lock_files.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ def remove_from(alist, to_remove):
210210
},
211211
{
212212
"build_name": "doc_min_dependencies",
213-
"folder": "build_tools/circle",
213+
"folder": "build_tools/github",
214214
"platform": "linux-64",
215215
"channel": "conda-forge",
216216
"conda_dependencies": common_dependencies_without_coverage
@@ -242,7 +242,7 @@ def remove_from(alist, to_remove):
242242
},
243243
{
244244
"build_name": "doc",
245-
"folder": "build_tools/circle",
245+
"folder": "build_tools/github",
246246
"platform": "linux-64",
247247
"channel": "conda-forge",
248248
"conda_dependencies": common_dependencies_without_coverage

0 commit comments

Comments
 (0)
0