Skip to content

Commit cfc0c8f

Browse files
authored
Merge pull request #692 from effigies/doc/fix_1.3.x
DOC: Fix doc builds in maint/1.3.x
2 parents a221f61 + e24fe1c commit cfc0c8f

File tree

9 files changed

+219
-218
lines changed

9 files changed

+219
-218
lines changed

.circleci/config.yml

Lines changed: 43 additions & 135 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,22 @@
1-
docs_deploy: &docs
2-
docker:
3-
- image: node:8.10.0
4-
steps:
5-
- run:
6-
name: Check whether this is the original repo
7-
command: |
8-
if [[ "$CIRCLE_PROJECT_USERNAME" != "nipreps" ]]; then
9-
echo "Not in nipreps/niworkflows - skipping docs deploy."
10-
circleci step halt
11-
fi
12-
- checkout
13-
- attach_workspace:
14-
at: docs/_build
15-
- run:
16-
name: Disable jekyll builds
17-
command: touch docs/_build/html/.nojekyll
18-
- run:
19-
name: Install and configure dependencies
20-
command: |
21-
npm install -g --silent [email protected]
22-
git config user.email "[email protected]"
23-
git config user.name "Documentation Push"
24-
- add_ssh_keys:
25-
fingerprints:
26-
- "c8:a8:55:7d:1e:08:92:c2:86:29:7b:b4:4b:88:24:51"
27-
- run:
28-
name: Deploy docs to gh-pages branch
29-
command: gh-pages --dotfiles --message "doc(update) [skip ci]" --dist docs/_build/html
30-
31-
version: 2
1+
version: 2.1
2+
orbs:
3+
docker: circleci/[email protected]
4+
325
jobs:
336
build:
347
machine:
35-
image: ubuntu-1604:202007-01
8+
# https://discuss.circleci.com/t/linux-machine-executor-images-2021-april-q2-update/39928
9+
# upgrade Docker version
10+
image: ubuntu-2004:202104-01
3611
working_directory: /tmp/src/niworkflows
3712
environment:
3813
TZ: "/usr/share/zoneinfo/America/Los_Angeles"
3914
SCRATCH: "/scratch"
4015
steps:
4116
- restore_cache:
4217
keys:
43-
- build-v1-{{ .Branch }}-{{ epoch }}
18+
- build-v1-{{ .Branch }}-{{ .Revision }}
19+
- build-v1--{{ .Revision }}
4420
- build-v1-{{ .Branch }}-
4521
- build-v1-master-
4622
- build-v1-
@@ -50,8 +26,8 @@ jobs:
5026
- run:
5127
name: Docker authentication
5228
command: |
53-
if [[ -n $DOCKER_PASS ]]; then
54-
docker login -u $DOCKER_USER -p $DOCKER_PASS
29+
if [[ -n $DOCKER_PAT ]]; then
30+
echo "$DOCKER_PAT" | docker login -u $DOCKER_USER --password-stdin
5531
fi
5632
- run:
5733
name: Set up Docker registry
@@ -76,13 +52,13 @@ jobs:
7652
set -e
7753
if [[ "$success" = "0" ]]; then
7854
echo "Pulling from local registry"
79-
docker tag localhost:5000/ubuntu ubuntu:xenial-20191010
55+
docker tag localhost:5000/ubuntu ubuntu:focal-20210416
8056
docker pull localhost:5000/niworkflows
8157
docker tag localhost:5000/niworkflows niworkflows:latest
8258
else
8359
echo "Pulling from Docker Hub"
84-
docker pull ubuntu:xenial-20191010
85-
docker tag ubuntu:xenial-20191010 localhost:5000/ubuntu
60+
docker pull ubuntu:focal-20210416
61+
docker tag ubuntu:focal-20210416 localhost:5000/ubuntu
8662
docker push localhost:5000/ubuntu
8763
fi
8864
@@ -107,7 +83,7 @@ jobs:
10783
docker exec -it registry /bin/registry garbage-collect --delete-untagged \
10884
/etc/docker/registry/config.yml
10985
- save_cache:
110-
key: build-v1-{{ .Branch }}-{{ epoch }}
86+
key: build-v1-{{ .Branch }}-{{ .Revision }}
11187
paths:
11288
- /tmp/docker
11389
- /tmp/images
@@ -227,7 +203,7 @@ jobs:
227203

228204
test_pytest:
229205
machine:
230-
image: ubuntu-1604:202007-01
206+
image: ubuntu-2004:202104-01
231207
working_directory: /tmp/tests
232208
steps:
233209
- attach_workspace:
@@ -237,15 +213,16 @@ jobs:
237213
command: python -m pip install codecov
238214
- restore_cache:
239215
keys:
240-
- build-v1-{{ .Branch }}-{{ epoch }}
216+
- build-v1-{{ .Branch }}-{{ .Revision }}
217+
- build-v1--{{ .Revision }}
241218
- build-v1-{{ .Branch }}-
242219
- build-v1-master-
243220
- build-v1-
244221
- run:
245222
name: Docker authentication
246223
command: |
247-
if [[ -n $DOCKER_PASS ]]; then
248-
docker login -u $DOCKER_USER -p $DOCKER_PASS
224+
if [[ -n $DOCKER_PAT ]]; then
225+
echo "$DOCKER_PAT" | docker login -u $DOCKER_USER --password-stdin
249226
fi
250227
- run:
251228
name: Set up Docker registry
@@ -277,10 +254,9 @@ jobs:
277254
no_output_timeout: 2h
278255
command: |
279256
mkdir -p $PWD/artifacts $PWD/summaries
280-
sudo setfacl -d -m group:ubuntu:rwx $PWD
281-
sudo setfacl -m group:ubuntu:rwx $PWD
282-
docker run -u $( id -u ) -it --rm=false -w /src/niworkflows \
257+
docker run -u $( id -u ):$( id -g ) -it --rm -w /src/niworkflows \
283258
-e COVERAGE_FILE=/tmp/summaries/.pytest.coverage \
259+
-e SAVE_CIRCLE_ARTIFACTS="/tmp/artifacts/" \
284260
-e TEST_DATA_HOME=/data -v /tmp/data:/data \
285261
-e FS_LICENSE=/etc/fslicense.txt \
286262
-v /tmp/fslicense/license.txt:/etc/fslicense.txt:ro \
@@ -302,7 +278,7 @@ jobs:
302278
name: Run reportlet tests
303279
no_output_timeout: 2h
304280
command: |
305-
docker run -u $( id -u ) -it --rm=false -w /src/niworkflows \
281+
docker run -u $( id -u ):$( id -g ) -it --rm -w /src/niworkflows \
306282
-e COVERAGE_FILE=/tmp/summaries/.reportlets.coverage \
307283
-e SAVE_CIRCLE_ARTIFACTS="/tmp/artifacts/" \
308284
-e TEST_DATA_HOME=/data -v /tmp/data:/data \
@@ -450,7 +426,7 @@ jobs:
450426
451427
test_package:
452428
docker:
453-
- image: circleci/python:3.8.5
429+
- image: cimg/python:3.9
454430
working_directory: /tmp/src/niworkflows
455431
steps:
456432
- checkout
@@ -474,7 +450,7 @@ jobs:
474450
475451
deploy_pypi:
476452
docker:
477-
- image: circleci/python:3.8.5
453+
- image: cimg/python:3.9
478454
working_directory: /tmp/src/niworkflows
479455
steps:
480456
- checkout
@@ -503,12 +479,13 @@ jobs:
503479
504480
deploy_docker:
505481
machine:
506-
image: ubuntu-1604:202007-01
482+
image: ubuntu-2004:202104-01
507483
working_directory: /tmp/src/
508484
steps:
509485
- restore_cache:
510486
keys:
511-
- build-v1-{{ .Branch }}-{{ epoch }}
487+
- build-v1-{{ .Branch }}-{{ .Revision }}
488+
- build-v1--{{ .Revision }}
512489
- build-v1-{{ .Branch }}-
513490
- build-v1-master-
514491
- build-v1-
@@ -518,8 +495,8 @@ jobs:
518495
- run:
519496
name: Docker authentication
520497
command: |
521-
if [[ -n $DOCKER_PASS ]]; then
522-
docker login -u $DOCKER_USER -p $DOCKER_PASS
498+
if [[ -n $DOCKER_PAT ]]; then
499+
echo "$DOCKER_PAT" | docker login -u $DOCKER_USER --password-stdin
523500
fi
524501
- run:
525502
name: Set up Docker registry
@@ -542,28 +519,17 @@ jobs:
542519
name: Deploy to Docker Hub
543520
no_output_timeout: 40m
544521
command: |
545-
if [[ -n "$DOCKER_PASS" ]]; then
546-
docker login -u $DOCKER_USER -p $DOCKER_PASS
547-
docker push nipreps/niworkflows:latest
548-
docker tag nipreps/niworkflows nipreps/niworkflows:$CIRCLE_TAG
549-
docker push nipreps/niworkflows:$CIRCLE_TAG
550-
fi
522+
docker push nipreps/niworkflows:latest
523+
docker tag nipreps/niworkflows nipreps/niworkflows:$CIRCLE_TAG
524+
docker push nipreps/niworkflows:$CIRCLE_TAG
551525
552526
build_docs:
553527
docker:
554-
- image: circleci/python:3.8.5
528+
- image: cimg/python:3.9
555529
environment:
556530
- FSLOUTPUTTYPE: NIFTI
557531
- SUBJECTS_DIR: /tmp/subjects
558532
steps:
559-
- restore_cache:
560-
keys:
561-
- docs-v1-{{ .Branch }}-{{ .Revision }}
562-
- docs-v1-{{ .Branch }}-
563-
- docs-v1-master
564-
- docs-v1-
565-
paths:
566-
- ./docs/_build/_html
567533
- checkout
568534
- run:
569535
name: Create subjects folder
@@ -573,59 +539,21 @@ jobs:
573539
command: sudo apt update && sudo apt -y install graphviz
574540
- run:
575541
name: Install deps
576-
command: python -m pip install --no-cache-dir -r docs/requirements.txt
577-
- run:
578-
name: Build only this commit
579-
command: make -C docs SPHINXOPTS="-W" BUILDDIR="_build/no_version_html" html
580-
- store_artifacts:
581-
path: ./docs/_build/no_version_html
582-
- run:
583-
name: Install niworkflows
584542
command: |
585-
python -m pip install --no-cache-dir codecov
586-
python -m pip install --no-cache-dir .[all]
543+
python -m pip install --no-cache-dir -U "pip>=20.3"
544+
python -m pip install --no-cache-dir -r docs/requirements.txt
545+
eval "$(pyenv init -)"
587546
- run:
588-
name: Build only this commit with coverage collection
547+
name: Install Niworkflows
589548
command: |
590-
make -C docs/ clean
591-
export COVERAGE_FILE=/tmp/.coverage
592-
coverage run --source=niworkflows $( which sphinx-build ) \
593-
-b html -W -d docs/_build/no_version_doctrees ./docs/ docs/_build/no_version_html
594-
coverage xml -o /tmp/documentation.xml
595-
python -m codecov --file /tmp/documentation.xml --flags documentation -e CIRCLE_JOB
549+
python -m pip install .
596550
- run:
597-
name: Uninstall NiWorkflows
598-
command: |
599-
python -m pip uninstall -y niworkflows
600-
- run:
601-
name: Generate Versioned Docs
551+
name: Build only this commit
602552
command: |
603-
set +e
604-
force_versioned="$( git log --format=oneline -n 1 $CIRCLE_SHA1 | grep -i -E '\[docs?[ _]?versions?\]' )"
605-
set -e
606-
if [[ "x${CIRCLE_TAG}" = "x" && "${CIRCLE_BRANCH}" != "master" && "x${force_versioned}" = "x" ]]; then
607-
echo "Not a tag or master branch - skipping versioned docs."
608-
circleci step halt
609-
else
610-
make -C docs/ clean
611-
make -f ./docs/Makefile versioned CURBRANCH=${CIRCLE_TAG:-$CIRCLE_BRANCH}
612-
fi
613-
- save_cache:
614-
key: docs-v1-{{ .Branch }}-{{ .Revision }}
615-
paths:
616-
- ./docs/_build/_html
617-
- persist_to_workspace:
618-
root: docs/_build
619-
paths: html
553+
BRANCH=$( echo $CIRCLE_BRANCH | sed 's+/+_+g' )
554+
make -C docs SPHINXOPTS="-W" BUILDDIR="$HOME/docs" OUTDIR=${CIRCLE_TAG:-$BRANCH} html
620555
- store_artifacts:
621-
path: ./docs/_build/html
622-
623-
deploy_docs_tag:
624-
<<: *docs
625-
626-
deploy_docs_master:
627-
<<: *docs
628-
556+
path: ~/docs
629557

630558
workflows:
631559
version: 2
@@ -697,23 +625,3 @@ workflows:
697625
- /ds054\/.*/
698626
tags:
699627
only: /.*/
700-
701-
- deploy_docs_master:
702-
requires:
703-
- test_pytest
704-
- test_package
705-
- build_docs
706-
filters:
707-
branches:
708-
only: /master/
709-
tags:
710-
ignore: /.*/
711-
712-
- deploy_docs_tag:
713-
requires:
714-
- deploy_docker
715-
filters:
716-
branches:
717-
ignore: /.*/
718-
tags:
719-
only: /.*/

docs/Makefile

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ SPHINXOPTS =
66
SPHINXBUILD = sphinx-build
77
PAPER =
88
BUILDDIR = _build
9-
CURBRANCH = master
9+
OUTDIR = html
1010
PYTHONPATH = $(PWD)
1111

1212
# User-friendly check for sphinx-build
@@ -53,10 +53,13 @@ clean:
5353
rm -rf $(BUILDDIR)/*
5454
rm -rf reference/*
5555

56+
docs-coverage:
57+
PYTHONPATH=$(PYTHONPATH) $(SPHINXBUILD) -b coverage $(ALLSPHINXOPTS) $(BUILDDIR)/coverage
58+
5659
html:
57-
PYTHONPATH=$(PYTHONPATH) $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
60+
PYTHONPATH=$(PYTHONPATH) $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/$(OUTDIR)
5861
@echo
59-
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
62+
@echo "Build finished. The HTML pages are in $(BUILDDIR)/$(OUTDIR)."
6063

6164
dirhtml:
6265
$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
@@ -179,6 +182,3 @@ pseudoxml:
179182
$(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml
180183
@echo
181184
@echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml."
182-
183-
versioned:
184-
PYTHONPATH=$(PYTHONPATH) sphinx-versioning -vv -l ./docs/conf.py build -r $(CURBRANCH) ./docs/ docs/$(BUILDDIR)/html/

docs/_static/css/version-switch.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.version-tree ul {
2+
list-style-type: none;
3+
}

docs/_static/js/version-switch.js

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
$(document).ready(function() {
2+
var pathname = window.location.pathname;
3+
var cur_ver = $("#version-slug").text().replace(/^[\n\s]+|[\n\s]+$/g, '')
4+
var major_minor = "master";
5+
if ( cur_ver.lastIndexOf(" (dev)") == -1 ) {
6+
major_minor = `${cur_ver.split('.')[0]}.${cur_ver.split('.')[1]}`
7+
}
8+
var relpath = pathname.substring(pathname.lastIndexOf(major_minor)).replace(/\/$/, '');
9+
var levels = relpath.split("/").length - 1
10+
if ( levels == 0 ) {
11+
levels = 1
12+
relpath += "/"
13+
}
14+
var versions_file = "../".repeat(levels) + "versions.json"
15+
relpath = "../".repeat(levels) + relpath
16+
relpath = relpath.replace("//", "/")
17+
console.log(`relpath="${relpath}", cur_ver="${cur_ver}"`)
18+
19+
$.getJSON(versions_file, function (data) {
20+
$("#version-slug").remove(); // Unnecessary if JSON was downloaded
21+
22+
$.each(data["tags"].reverse(), function( i, val ) {
23+
var new_path = relpath.replace(major_minor, val)
24+
var item = `<li class="toctree-l2"><a class="reference internal" href="${new_path}">${val}</a></li>`
25+
if ( i == 0 ) {
26+
item = `<li class="toctree-l2"><a class="reference internal" href="${new_path}">${val} (Latest Release)</a></li>`
27+
}
28+
$("#v-tags").append(item)
29+
});
30+
$.each(data["heads"].reverse(), function( i, val ) {
31+
var new_path = relpath.replace(major_minor, val)
32+
var item = `<li class="toctree-l2"><a class="reference internal" href="${new_path}">${val}</a></li>`
33+
if ( val == "master" ) {
34+
item = `<li class="toctree-l2"><a class="reference internal" href="${new_path}">${val} (Development)</a></li>`
35+
}
36+
$("#v-tags").append(item)
37+
});
38+
}).fail(function() {
39+
$("#version-menu").hide(); // JSON download failed - hide dropdown
40+
});
41+
});

0 commit comments

Comments
 (0)