Skip to content

Commit c394e21

Browse files
authored
Re-do CI build
Per the plan in whatwg/meta#173 (comment), this revamps the CI build to reduce coupling between the html-build and html repositories. Now, running CI (currently Travis) for the html-build repository produces a whatwg/html-build Docker container, pushed to Docker Hub, which can be given an input directory containing the contents of whatwg/html, and an output directory. The corresponding changes in whatwg/html are in whatwg/html#5945.
1 parent 6233161 commit c394e21

File tree

11 files changed

+112
-181
lines changed

11 files changed

+112
-181
lines changed

.travis.yml

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,23 @@ services:
33
- docker
44

55
script:
6+
# Shellcheck
67
- shellcheck *.sh
7-
- shellcheck ci-deploy/*.sh
8-
- cd .. &&
9-
git clone https://github.com/whatwg/html.git --depth 2 &&
10-
IS_TEST_OF_HTML_BUILD_ITSELF=true bash ./html-build/ci-deploy/outside-container.sh
8+
- shellcheck ci-build/*.sh
9+
10+
# Build the Docker container, tagged as whatwg/html-build
11+
- bash ci-build/docker-build.sh
12+
13+
# Test the Docker container
14+
- git clone https://github.com/whatwg/html.git --depth 2
15+
- mkdir output
16+
- bash ci-build/docker-run.sh html output
17+
18+
# Tag and publish the Docker container
19+
- docker tag whatwg/html-build "whatwg/html-build:$(git rev-list --count HEAD)"
20+
- docker tag whatwg/html-build whatwg/html-build:latest
21+
- if [[ "$TRAVIS_PULL_REQUEST" = "false" ]]; then docker login --username "$DOCKER_USERNAME" --password "$DOCKER_PASSWORD"; fi
22+
- if [[ "$TRAVIS_PULL_REQUEST" = "false" ]]; then docker push whatwg/html-build; fi
1123

1224
branches:
1325
only:

ci-deploy/Dockerfile renamed to ci-build/Dockerfile

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -37,18 +37,6 @@ RUN apt-get install --yes --no-install-recommends ./prince_13.5-1_debian10_amd64
3737
rm prince_13.5-1_debian10_amd64.deb && \
3838
echo '@font-face { font-family: serif; src: local("Symbola") }' >> /usr/lib/prince/style/fonts.css
3939

40-
ARG html_build_dir
4140
ADD . /whatwg/html-build
4241

43-
# Note: we do not ADD /whatwg/html, but instead mount it in outside-container.html, since it
44-
# contains the deploy_key, and thus should not be part of the image. The image is cached, publicly,
45-
# on Docker Hub.
46-
ENV HTML_SOURCE /whatwg/html
47-
48-
ARG travis_pull_request
49-
ARG is_test_of_html_build_itself
50-
ENV TRAVIS_PULL_REQUEST=${travis_pull_request}
51-
ENV IS_TEST_OF_HTML_BUILD_ITSELF=${is_test_of_html_build_itself}
52-
53-
ENV SKIP_BUILD_UPDATE_CHECK=true
54-
ENTRYPOINT ["bash", "/whatwg/html-build/ci-deploy/inside-container.sh"]
42+
ENTRYPOINT ["bash", "/whatwg/html-build/ci-build/inside-container.sh"]

ci-build/README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# HTML Standard CI Build
2+
3+
This directory contains the infrastructure for building and running a Docker container, [whatwg/html-build](https://hub.docker.com/r/whatwg/html-build), which performs a "full" build of the HTML Standard, producing artifacts ready for deployment.
4+
5+
The relevant entrypoints are:
6+
7+
- `docker-build.sh` will build the Docker container
8+
- `docker-run.sh $INPUT $OUTPUT` will run the Docker container to do such a full build.
9+
- `$INPUT` should contain a checkout of the [whatwg/html](https://github.com/whatwg/html) repository
10+
- `$OUTPUT` should be an empty directory

ci-build/docker-build.sh

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/bin/bash
2+
set -o errexit
3+
set -o nounset
4+
set -o pipefail
5+
shopt -s extglob
6+
7+
TMP_DIR=$(mktemp -d)
8+
9+
function main {
10+
local here
11+
here=$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )
12+
13+
# We want the image to contain:
14+
# * All of the important stuff from the top-level (html-build) directory
15+
# * But, the Dockerfile from this (ci-build) directory
16+
# And in particular it should *not* contain the top-level Dockerfile, non-.pl dotfiles, .git/, and
17+
# any html/ and output/ directories that might be hanging around from local testing.
18+
cp "$here/Dockerfile" "$TMP_DIR"
19+
cd "$here/.."
20+
cp -r !(.*|html|output|Dockerfile) "$TMP_DIR"
21+
cp .*.pl "$TMP_DIR"
22+
cd "$TMP_DIR"
23+
trap cleanTemp EXIT
24+
25+
local docker_hub_repo="whatwg/html-build"
26+
27+
# Build the Docker image, using Docker Hub as a cache. (This will be fast if nothing has changed
28+
# in html-build or its dependencies).
29+
docker pull whatwg/wattsi
30+
docker pull ptspts/pdfsizeopt
31+
docker pull "$docker_hub_repo" || true
32+
docker build --cache-from "$docker_hub_repo" --tag "$docker_hub_repo" .
33+
}
34+
35+
function cleanTemp {
36+
rm -rf "$TMP_DIR"
37+
}
38+
39+
main "$@"

ci-build/docker-run.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
set -o errexit
3+
set -o nounset
4+
set -o pipefail
5+
shopt -s extglob
6+
7+
HTML_SOURCE=$(realpath "$1")
8+
HTML_OUTPUT=$(realpath "$2")
9+
10+
docker run --rm --mount "type=bind,source=$HTML_SOURCE,destination=/whatwg/html,readonly=1" \
11+
--env "HTML_SOURCE=/whatwg/html" \
12+
--mount "type=bind,source=$HTML_OUTPUT,destination=/whatwg/output" \
13+
--env "HTML_OUTPUT=/whatwg/output" \
14+
whatwg/html-build

ci-build/inside-container.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/bash
2+
set -o errexit
3+
set -o nounset
4+
set -o pipefail
5+
cd "$(dirname "$0")/../.."
6+
7+
PDF_SERVE_PORT=8080
8+
9+
SKIP_BUILD_UPDATE_CHECK=true ./html-build/build.sh
10+
11+
echo ""
12+
echo "Running conformance checker..."
13+
# the -Xmx1g argument sets the size of the Java heap space to 1 gigabyte
14+
java -Xmx1g -jar ./vnu.jar --skip-non-html "$HTML_OUTPUT"
15+
echo ""
16+
17+
# Serve the built output so that Prince can snapshot it
18+
# The nohup/sleep incantations are necessary because normal & does not work inside Docker:
19+
# https://stackoverflow.com/q/50211207/3191
20+
(
21+
cd "$HTML_OUTPUT"
22+
nohup bash -c "python3 -m http.server $PDF_SERVE_PORT &" && sleep 4
23+
)
24+
25+
echo ""
26+
echo "Building PDF..."
27+
PDF_TMP="$(mktemp --suffix=.pdf)"
28+
prince --verbose --output "$PDF_TMP" "http://0.0.0.0:$PDF_SERVE_PORT/"
29+
30+
echo ""
31+
echo "Optimizing PDF..."
32+
PATH=/bin/pdfsizeopt:$PATH pdfsizeopt --v=30 "$PDF_TMP" "$HTML_OUTPUT/print.pdf"

ci-deploy/.dockerignore

Lines changed: 0 additions & 3 deletions
This file was deleted.

ci-deploy/README.md

Lines changed: 0 additions & 10 deletions
This file was deleted.

ci-deploy/deploy-key.enc

-3.17 KB
Binary file not shown.

ci-deploy/inside-container.sh

Lines changed: 0 additions & 84 deletions
This file was deleted.

0 commit comments

Comments
 (0)