authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-01-06 23:17:00-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-01-06 23:40:17-07:00
logce5222d945b4e1c3637f1673716bc224434da19a
treed32ff834b5268df0560fa8f7fcca6b40a21c9fdd
parentf1ef0a80f1d614bbbb9ad8fae7992d55111c8cd7

ci: rework linux script

* no longer depend on apt.llvm.org, instead we rely on a zig-bootstrap tarball with pre-built Zig, LLVM, LLD, and Clang. Similar to the Windows Dev Kit but for Linux. This also makes the script no longer depend on Docker, libxml2, or GCC. * remove bash retry logic; it was only needed for flaky apt.llvm.org and isn't needed for the other resources we download. * build and upload the experimental std lib automatically generated docs. langref.html is moved to docs/langref.html because the std lib docs are in docs/std/. * the superfluous "zig" directory in $prefix/lib/zig/std/std.zig is removed from the tarball. * update_download_page makes a commit in the www.ziglang.org repository updating data/releases.json so that repository can manage deploys.

3 files changed, 90 insertions(+), 57 deletions(-)

ci/azure/linux_script+74-53
......@@ -3,48 +3,35 @@
33set -x
44set -e
55
6# This parameters we wait at most 2mins, it should be enough to sort out any
7# transient error.
8CMD_MAX_RETRY=12
9CMD_WAIT_TIME=10s
10
11# Execute the given command and, in case of failure, try to execute it again
12# after sleeping for CMD_WAIT_TIME.
13# We give up after retrying CMD_MAX_RETRY times.
14retry() {
15 for i in $(seq 1 "$CMD_MAX_RETRY"); do
16 eval "$@" && return
17 echo "command \"$@\" failed, retrying..."
18 sleep ${CMD_WAIT_TIME}
19 done
20
21 echo "command \"$@\" failed, giving up..."
22 exit 1
23}
24
25BUILDDIR="$(pwd)"
26
27sudo sh -c 'echo "deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-11 main" >> /etc/apt/sources.list'
28retry 'wget -O - http://apt.llvm.org/llvm-snapshot.gpg.key|sudo apt-key add -'
29retry sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
30
31sudo apt-get remove -y llvm-*
32sudo rm -rf /usr/local/*
33
34retry sudo apt-get update -q
35retry sudo apt-get install -y \
36 libxml2-dev libclang-11-dev llvm-11 llvm-11-dev liblld-11-dev cmake s3cmd \
37 gcc-7 g++-7 ninja-build tidy \
6sudo apt-get update -q
7sudo apt-get install -y cmake s3cmd ninja-build tidy
8
9ZIGDIR="$(pwd)"
10ARCH="$(uname -m)"
11CACHE_BASENAME="zig+llvm+lld+clang-$ARCH-linux-musl-0.8.0-dev.859+f1ef0a80f"
12PREFIX="$HOME/$CACHE_BASENAME"
13
14rm -rf $PREFIX
15cd $HOME
16
17wget -nv "https://ziglang.org/deps/$CACHE_BASENAME.tar.xz"
18tar xf "$CACHE_BASENAME.tar.xz"
3819
3920QEMUBASE="qemu-linux-x86_64-5.2.0"
40wget -nv https://ziglang.org/deps/$QEMUBASE.tar.xz
41tar xf $QEMUBASE.tar.xz
42PATH=$PWD/$QEMUBASE/bin:$PATH
21wget -nv "https://ziglang.org/deps/$QEMUBASE.tar.xz"
22tar xf "$QEMUBASE.tar.xz"
23export PATH="$(pwd)/$QEMUBASE/bin:$PATH"
4324
4425WASMTIME="wasmtime-v0.20.0-x86_64-linux"
45wget -nv https://github.com/bytecodealliance/wasmtime/releases/download/v0.20.0/$WASMTIME.tar.xz
46tar xf $WASMTIME.tar.xz
47PATH=$PWD/$WASMTIME:$PATH
26wget -nv "https://github.com/bytecodealliance/wasmtime/releases/download/v0.20.0/$WASMTIME.tar.xz"
27tar xf "$WASMTIME.tar.xz"
28export PATH="$(pwd)/$WASMTIME:$PATH"
29
30ZIG="$PREFIX/bin/zig"
31export CC="$ZIG cc"
32export CXX="$ZIG c++"
33
34cd $ZIGDIR
4835
4936# Make the `zig version` number consistent.
5037# This will affect the cmake command below.
......@@ -52,29 +39,63 @@ git config core.abbrev 9
5239git fetch --unshallow || true
5340git fetch --tags
5441
55export CC=gcc-7
56export CXX=g++-7
5742mkdir build
5843cd build
59cmake .. -DCMAKE_BUILD_TYPE=Release -GNinja
44cmake .. \
45 -DCMAKE_INSTALL_PREFIX="$(pwd)/release" \
46 -DCMAKE_PREFIX_PATH="$PREFIX" \
47 -DCMAKE_BUILD_TYPE=Release \
48 -DZIG_TARGET_TRIPLE="$ARCH-linux-musl" \
49 -DZIG_TARGET_MCPU="baseline" \
50 -DZIG_STATIC=ON \
51 -GNinja
52
53# Now cmake will use zig as the C/C++ compiler. We reset the environment variables
54# so that installation and testing do not get affected by them.
55unset CC
56unset CXX
57
6058ninja install
61./zig build test -Denable-qemu -Denable-wasmtime
6259
63# look for HTML errors
64tidy -qe ../zig-cache/langref.html
60# Here we rebuild zig but this time using the Zig binary we just now produced to
61# build zig1.o rather than relying on the one built with stage0. See
62# https://github.com/ziglang/zig/issues/6830 for more details.
63cmake .. -DZIG_EXECUTABLE="$(pwd)/release/bin/zig"
64ninja install
6565
66VERSION="$(./zig version)"
66release/bin/zig build test -Denable-qemu -Denable-wasmtime
67
68# Look for HTML errors.
69tidy -qe ../zig-cache/langref.html
6770
6871if [ "${BUILD_REASON}" != "PullRequest" ]; then
69 ARTIFACTSDIR="$BUILDDIR/artifacts"
70 mkdir "$ARTIFACTSDIR"
71 docker run -i --mount type=bind,source="$ARTIFACTSDIR",target=/z ziglang/static-base:llvm11-x86_64-1 -j2 $BUILD_SOURCEVERSION
72 TARBALL="$(ls $ARTIFACTSDIR)"
72 # Produce the experimental std lib documentation.
73 mkdir -p release/docs/std
74 release/bin/zig test ../lib/std/std.zig -femit-docs=release/docs/std -fno-emit-bin
75
76 mv ../LICENSE release/
77 mv ../zig-cache/langref.html release/docs/
78
79 # Remove the unnecessary bin dir in $prefix/bin/zig
80 mv release/bin/zig release/
81 rmdir release/bin
82
83 # Remove the unnecessary zig dir in $prefix/lib/zig/std/std.zig
84 mv release/lib/zig release/lib2
85 rmdir release/lib
86 mv release/lib2 release/lib
87
88 VERSION=$(release/zig version)
89 DIRNAME="zig-linux-$ARCH-$VERSION"
90 TARBALL="$DIRNAME.tar.xz"
91 mv release "$DIRNAME"
92 tar cfJ "$TARBALL" "$DIRNAME"
93
7394 mv "$DOWNLOADSECUREFILE_SECUREFILEPATH" "$HOME/.s3cfg"
74 s3cmd put -P --add-header="cache-control: public, max-age=31536000, immutable" "$ARTIFACTSDIR/$TARBALL" s3://ziglang.org/builds/
95 s3cmd put -P --add-header="cache-control: public, max-age=31536000, immutable" "$TARBALL" s3://ziglang.org/builds/
7596
76 SHASUM=$(sha256sum $ARTIFACTSDIR/$TARBALL | cut '-d ' -f1)
77 BYTESIZE=$(wc -c < $ARTIFACTSDIR/$TARBALL)
97 SHASUM=$(sha256sum $TARBALL | cut '-d ' -f1)
98 BYTESIZE=$(wc -c < $TARBALL)
7899
79100 JSONFILE="linux-$GITBRANCH.json"
80101 touch $JSONFILE
......@@ -83,7 +104,7 @@ if [ "${BUILD_REASON}" != "PullRequest" ]; then
83104 echo "\"size\": \"$BYTESIZE\"}" >>$JSONFILE
84105
85106 s3cmd put -P --add-header="Cache-Control: max-age=0, must-revalidate" "$JSONFILE" "s3://ziglang.org/builds/$JSONFILE"
86 s3cmd put -P "$JSONFILE" "s3://ziglang.org/builds/x86_64-linux-$VERSION.json"
107 s3cmd put -P "$JSONFILE" "s3://ziglang.org/builds/$ARCH-linux-$VERSION.json"
87108
88109 # `set -x` causes these variables to be mangled.
89110 # See https://developercommunity.visualstudio.com/content/problem/375679/pipeline-variable-incorrectly-inserts-single-quote.html
ci/srht/on_master_success+1
......@@ -24,6 +24,7 @@ packages:
2424 - xz
2525secrets:
2626 - 51bfddf5-86a6-4e01-8576-358c72a4a0a4
27 - 8d5f230b-78d9-4e7c-b583-8cbb1b15807c
2728sources:
2829 - https://github.com/ziglang/zig
2930tasks:
ci/srht/update_download_page+15-4
......@@ -35,7 +35,7 @@ wget "https://ziglang.org/builds/$NATIVE_TARBALL"
3535tar xf "$NATIVE_TARBALL"
3636ZIGDIR=$(basename $NATIVE_TARBALL .tar.xz)
3737ZIG="$ZIGDIR/zig"
38LANGREF="$ZIGDIR/langref.html"
38LANGREF="$ZIGDIR/docs/langref.html"
3939SRCTARBALLDIR="zig-$VERSION"
4040export SRC_TARBALL="$SRCTARBALLDIR.tar.xz"
4141mv "$SRCDIR" "$SRCTARBALLDIR"
......@@ -68,13 +68,24 @@ export X86_64_FREEBSD_TARBALL="$(echo "$X86_64_FREEBSD_JSON" | jq .tarball -r)"
6868export X86_64_FREEBSD_BYTESIZE="$(echo "$X86_64_FREEBSD_JSON" | jq .size -r)"
6969export X86_64_FREEBSD_SHASUM="$(echo "$X86_64_FREEBSD_JSON" | jq .shasum -r)"
7070
71git clone https://github.com/ziglang/www.ziglang.org --depth 1
71git clone git@github.com:ziglang/www.ziglang.org.git
7272cd www.ziglang.org
73git checkout hugo-redesign
7374export MASTER_DATE="$(date +%Y-%m-%d)"
7475export MASTER_VERSION="$VERSION"
7576"../$ZIG" run update-download-page.zig
7677
7778$S3CMD put -P --no-mime-magic --add-header="cache-control: public, max-age=31536000, immutable" "../$SRC_TARBALL" s3://ziglang.org/builds/
79
7880$S3CMD put -P --no-mime-magic "../$LANGREF" s3://ziglang.org/documentation/master/index.html --add-header="Cache-Control: max-age=0, must-revalidate"
79$S3CMD put -P --no-mime-magic www/download/index.html s3://ziglang.org/download/index.html --add-header="Cache-Control: max-age=0, must-revalidate"
80$S3CMD put -P --no-mime-magic www/download/index.json s3://ziglang.org/download/index.json --add-header="Cache-Control: max-age=0, must-revalidate"
81$S3CMD put -P --no-mime-magic "../$ZIGDIR/docs/std/index.html" s3://ziglang.org/documentation/master/std/index.html --add-header="Cache-Control: max-age=0, must-revalidate"
82$S3CMD put -P --no-mime-magic "../$ZIGDIR/docs/std/data.js" s3://ziglang.org/documentation/master/std/data.js --add-header="Cache-Control: max-age=0, must-revalidate"
83$S3CMD put -P --no-mime-magic "../$ZIGDIR/docs/std/main.js" s3://ziglang.org/documentation/master/std/main.js --add-header="Cache-Control: max-age=0, must-revalidate"
84
85$S3CMD put -P --no-mime-magic ci/out/index.html s3://ziglang.org/download/index.html --add-header="Cache-Control: max-age=0, must-revalidate"
86$S3CMD put -P --no-mime-magic ci/out/index.json s3://ziglang.org/download/index.json --add-header="Cache-Control: max-age=0, must-revalidate"
87
88cp ci/out/index.json data/releases.json
89git add data/releases.json
90git commit -m "CI: update releases.json"
91git push origin hugo-redesign