Skip to content

Commit d3adafb

Browse files
Update CircleCI and Buildkite configs to build the new spec (matrix-org#3017)
This PR attempts to update the CI of matrix-doc to build [the new spec redesign](matrix-org#2906). It does so by additionally building the new spec in parallel to the old. The plan is to continue to host the old spec at https://matrix.org/docs/spec, while the new spec will be at https://spec.matrix.org. Eventually we will retire the old version of the spec, and have the old URL redirect to the new one. In detail, this PR: * Adds a new step to CircleCI to build the new spec with `hugo`. This step uses alpine, grabs some dependencies, and then builds the HTML. * We needed to hand some specific options to hugo for CircleCI in order to continue allowing CircleCI to host temporary builds of the spec after each CI run. This required changing some assumptions related to relative paths. * CircleCI's artifacts hosting is also quite limited. Specifically it will not automatically resolve `/some/path` to `/some/path/index.html`, which our hugo theme relied on. Fixes were implemented for this, but we may want to consider switching away from CircleCI artifacts as a host, and using something like [netlify](https://www.netlify.com/) instead. * Modifies the existing Buildkite pipeline step to build both the new spec in a separate step. It additionally modifies the old spec to be built with alpine. (Separate out into another PR) * We'd like to separate out the deployment of matrix.org from the new spec. Therefore a new step, with a separate artifact build (`spec.tar.gz`). We will eventually remove the old step and the matrix.org build trigger. * Modifies `pyproject.toml` to update the config of [giles](https://github.com/OpenAstronomy/baldrick/blob/master/baldrick/plugins/circleci_artifacts.py), which is what creates the "docs", "swagger" links in the CI steps for matrix-docs PRs. * A new step was added for the new spec. The old spec was renamed to "legacy".
1 parent 68c8107 commit d3adafb

File tree

7 files changed

+67
-9
lines changed

7 files changed

+67
-9
lines changed

Diff for: .buildkite/pipeline.yaml

+21-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
steps:
2-
- label: ":books: Build spec"
2+
- label: ":books: Build the legacy spec"
33
command:
44
# Install the python dependencies necessary to build the spec
55
- python3 -m venv env && . env/bin/activate
@@ -16,3 +16,23 @@ steps:
1616
trigger: "matrix-dot-org"
1717
async: true
1818
branches: "master"
19+
20+
- label: ":books: Build the spec"
21+
command:
22+
# Install package dependencies
23+
- apk add nodejs npm git hugo
24+
# Install the node dependencies necessary to build the spec
25+
- npm i
26+
# Pull all git submodules, required for the hugo theme
27+
- git submodule update --init --recursive
28+
# Pull current proposal information
29+
- npm run get-proposals
30+
# Build the spec, will build to './spec'
31+
- hugo -d "spec"
32+
# Compress the result and make it available as an artifact
33+
- tar -czf spec.tar.gz spec
34+
artifact_paths:
35+
- spec.tar.gz
36+
plugins:
37+
- docker#v3.7.0:
38+
image: alpine

Diff for: .circleci/config.yml

+32-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,20 @@
1-
gendoc: &gendoc
2-
name: Generate the docs
1+
genlegacydoc: &genlegacydoc
2+
name: Generate the legacy docs
33
command: |
44
source /env/bin/activate
55
scripts/gendoc.py
66
7+
gendoc: &gendoc
8+
name: Generate the docs
9+
# Note: Node dependencies are required for the hugo build.
10+
# Note: We use a custom config file for circleci due to some specifics with hosting the
11+
# site using CircleCI's artifacts platform. See config-circleci.toml for details.
12+
command: |
13+
apk add nodejs npm git hugo
14+
npm i
15+
cat config-circleci.toml config.toml > hugo-config.toml
16+
hugo --config hugo-config.toml --baseURL "/${CIRCLE_NODE_INDEX}/public"
17+
718
genswagger: &genswagger
819
name: Validate sources and generate swagger json
920
command: |
@@ -63,17 +74,32 @@ jobs:
6374
steps:
6475
- checkout
6576
- run: *checkexamples
66-
build-docs:
77+
build-legacy-docs:
6778
docker:
6879
- image: uhoreg/matrix-doc-build
6980
steps:
7081
- checkout
71-
- run: *gendoc
82+
- run: *genlegacydoc
7283
- store_artifacts:
7384
path: scripts/gen
7485
- run:
75-
name: "Doc build is available at:"
86+
name: "Legacy doc build is available at:"
7687
command: DOCS_URL="${CIRCLE_BUILD_URL}/artifacts/${CIRCLE_NODE_INDEX}/${CIRCLE_WORKING_DIRECTORY/#\~/$HOME}/scripts/gen/index.html"; echo $DOCS_URL
88+
build-docs:
89+
docker:
90+
- image: alpine
91+
steps:
92+
# Note: We install git in the image so we can pull git submodules. The hugo theme in use
93+
# is a git submodule, which has its own submodules, and all need to be loaded.
94+
- run: apk add git
95+
- checkout
96+
- run: git submodule update --init --recursive
97+
- run: *gendoc
98+
- store_artifacts:
99+
path: public
100+
- run:
101+
name: "Doc build is available at:"
102+
command: DOCS_URL="${CIRCLE_BUILD_URL}/artifacts/${CIRCLE_NODE_INDEX}/public/index.html"; echo $DOCS_URL
77103
build-swagger:
78104
docker:
79105
- image: uhoreg/matrix-doc-build
@@ -104,6 +130,7 @@ workflows:
104130

105131
build-spec:
106132
jobs:
133+
- build-legacy-docs
107134
- build-docs
108135
- build-swagger
109136
- check-docs

Diff for: .gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
/scripts/swagger
1212
/scripts/tmp
1313
/templating/out
14+
/hugo-config.toml
15+
/public
1416
*.pyc
1517
*.swp
1618
_rendered.rst

Diff for: assets-hugo/scss/custom.scss

+1-1
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ Make padding symmetrical (this selector is used in the default styles to apply p
409409
}
410410

411411
.pageinfo-unstable {
412-
background-image: url('/icons/unstable.png');
412+
background-image: url('../icons/unstable.png');
413413
background-position: left 1rem center;
414414
background-repeat: no-repeat;
415415
padding-left: 100px;

Diff for: config-circleci.toml

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# When serving the documentation via CircleCI, we need to use '/path/index.html' URLs instead
2+
# of hugo's default of prettier '/path/' URLs. This is because CircleCI's artifacts webserver
3+
# does not resolve '/path/' to '/path/index.html' like webservers often do.
4+
# CircleCI discussion: https://discuss.circleci.com/t/circle-artifacts-com-not-using-index-html/320/3
5+
uglyURLs = true

Diff for: pyproject.toml

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
[ tool.gilesbot ]
22

3-
[ tool.gilesbot.circleci_artifacts.docs ]
3+
[ tool.gilesbot.circleci_artifacts.legacydocs ]
44
url = "gen/index.html"
5+
message = "Click details to preview the legacy HTML documentation."
6+
7+
[ tool.gilesbot.circleci_artifacts.docs ]
8+
url = "public/index.html"
59
message = "Click details to preview the HTML documentation."
610

711
[ tool.gilesbot.circleci_artifacts.swagger ]

Diff for: scripts/generate-matrix-org-assets

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ mkdir -p assets
1111
# generate specification/proposals.rst
1212
./scripts/proposals.py
1313

14-
# generate the spec docs
14+
# generate the legacy spec docs
1515
./scripts/gendoc.py -d assets/spec
1616

1717
# and the swagger

0 commit comments

Comments
 (0)