authorgravatar for michael.dusan@gmail.comMichael Dusan <michael.dusan@gmail.com> 2021-11-02 09:47:36-04:00
committergravatar for michael.dusan@gmail.comMichael Dusan <michael.dusan@gmail.com> 2021-11-02 10:44:01-04:00
log325bae7fc0025f7153bd1de1c28e642e896190b1
treef8d3bbbe49e062ff0752bdad923455bf72994a94
parent70ef9bc75c42ec00e9d4231a2e1f1dca84144748
signaturelock-open Commit is signed but in an unrecognized format.

ci: add new linux pipeline

A new zsf-hosted server is being brought online. This should be enough for linux build, test and packaging pipeline. Currently this pipeline does not not post artifacts.

2 files changed, 177 insertions(+), 0 deletions(-)

ci/zinc/drone.yml created+15
......@@ -0,0 +1,15 @@
1---
2kind: pipeline
3type: docker
4name: x86_64-linux
5platform:
6 os: linux
7 arch: amd64
8workspace:
9 path: /workspace
10
11steps:
12- name: build-test-package
13 image: ci/debian-amd64:11.1-1
14 commands:
15 - ./ci/zinc/linux_build.sh
ci/zinc/linux_build.sh created+162
......@@ -0,0 +1,162 @@
1#!/bin/sh
2
3set -x
4set -e
5
6# Probe CPU/brand details.
7echo "lscpu:"
8(lscpu | sed 's,^, : ,') 1>&2
9
10pwd
11(env | sort | sed 's,^, : ,') 1>&2
12
13WORKSPACE="$DRONE_WORKSPACE"
14LOCAL="/deps/local"
15ZIG="$LOCAL/bin/zig"
16ARCH="$(uname -m)"
17TARGET="${ARCH}-linux-musl"
18MCPU="baseline"
19JOBS="-j$(nproc)"
20export PATH=/deps/local/bin:$PATH
21
22# Make the `zig version` number consistent.
23# This will affect the cmake command below.
24git config core.abbrev 9
25
26# Build debug zig.
27echo "BUILD debug zig with zig:$($ZIG version)"
28
29export CC="$ZIG cc -target $TARGET -mcpu=$MCPU"
30export CXX="$ZIG c++ -target $TARGET -mcpu=$MCPU"
31
32mkdir _debug
33cd _debug
34cmake .. \
35 -DCMAKE_INSTALL_PREFIX="$(pwd)/staging" \
36 -DCMAKE_PREFIX_PATH="$LOCAL" \
37 -DCMAKE_BUILD_TYPE=Debug \
38 -DZIG_TARGET_TRIPLE="$TARGET" \
39 -DZIG_TARGET_MCPU="$MCPU" \
40 -DZIG_STATIC=ON \
41 -GNinja
42
43# Now cmake will use zig as the C/C++ compiler. We reset the environment variables
44# so that installation and testing do not get affected by them.
45unset CC
46unset CXX
47
48ninja $JOBS install
49
50ZIG=$(pwd)/staging/bin/zig
51
52# Here we rebuild zig but this time using the Zig binary we just now produced to
53# build zig1.o rather than relying on the one built with stage0. See
54# https://github.com/ziglang/zig/issues/6830 for more details.
55cmake .. -DZIG_EXECUTABLE="$ZIG"
56ninja $JOBS install
57
58cd $WORKSPACE
59
60# Build release zig.
61echo "BUILD release zig with zig:$($ZIG version)"
62echo "zig version: $($ZIG version)"
63export CC="$ZIG cc -target $TARGET -mcpu=$MCPU"
64export CXX="$ZIG c++ -target $TARGET -mcpu=$MCPU"
65mkdir _release
66cd _release
67cmake .. \
68 -DCMAKE_INSTALL_PREFIX="$(pwd)/staging" \
69 -DCMAKE_PREFIX_PATH="$LOCAL" \
70 -DCMAKE_BUILD_TYPE=Release \
71 -DZIG_TARGET_TRIPLE="$TARGET" \
72 -DZIG_TARGET_MCPU="$MCPU" \
73 -DZIG_STATIC=ON \
74 -GNinja
75unset CC
76unset CXX
77ninja $JOBS install
78
79cd $WORKSPACE
80
81# Look for non-conforming code formatting.
82# Formatting errors can be fixed by running `zig fmt` on the files printed here.
83$ZIG fmt --check .
84
85$ZIG test test/behavior.zig -fno-stage1 -fLLVM -I test
86
87$ZIG build test-behavior -Denable-qemu -Denable-wasmtime
88$ZIG build test-compiler-rt -Denable-qemu -Denable-wasmtime
89$ZIG build test-std -Denable-qemu -Denable-wasmtime
90$ZIG build test-minilibc -Denable-qemu -Denable-wasmtime
91$ZIG build test-compare-output -Denable-qemu -Denable-wasmtime
92$ZIG build test-standalone -Denable-qemu -Denable-wasmtime
93$ZIG build test-stack-traces -Denable-qemu -Denable-wasmtime
94$ZIG build test-cli -Denable-qemu -Denable-wasmtime
95$ZIG build test-asm-link -Denable-qemu -Denable-wasmtime
96$ZIG build test-runtime-safety -Denable-qemu -Denable-wasmtime
97$ZIG build test-translate-c -Denable-qemu -Denable-wasmtime
98$ZIG build test-run-translated-c -Denable-qemu -Denable-wasmtime
99$ZIG build docs -Denable-qemu -Denable-wasmtime
100$ZIG build # test building self-hosted without LLVM
101$ZIG build test-fmt -Denable-qemu -Denable-wasmtime
102$ZIG build test-stage2 -Denable-qemu -Denable-wasmtime
103
104# Look for HTML errors.
105tidy --drop-empty-elements no -qe zig-cache/langref.html
106
107# The remainder of this script is for master branch only.
108if [ -n "$DRONE_PULL_REQUEST" ]; then
109 exit 0
110fi
111
112STAGING=_release/staging
113
114# Produce the experimental std lib documentation.
115mkdir -p $STAGING/docs/std
116$ZIG test lib/std/std.zig \
117 --zig-lib-dir lib \
118 -femit-docs=$STAGING/docs/std \
119 -fno-emit-bin
120
121cp LICENSE $STAGING/
122cp zig-cache/langref.html $STAGING/docs/
123
124# Remove the unnecessary bin dir in $prefix/bin/zig
125mv $STAGING/bin/zig $STAGING/
126rmdir $STAGING/bin
127
128# Remove the unnecessary zig dir in $prefix/lib/zig/std/std.zig
129mv $STAGING/lib/zig $STAGING/lib2
130rmdir $STAGING/lib
131mv $STAGING/lib2 $STAGING/lib
132
133VERSION=$($STAGING/zig version)
134BASENAME="zig-linux-$ARCH-$VERSION"
135TARBALL="${BASENAME}.tar.xz"
136mv "$STAGING" "$BASENAME"
137tar cfJ "$TARBALL" "$BASENAME"
138ls -l "$TARBALL"
139
140# TODO: push artifact/meta somewhere
141## mv "$DOWNLOADSECUREFILE_SECUREFILEPATH" "$HOME/.s3cfg"
142## s3cmd put -P --add-header="cache-control: public, max-age=31536000, immutable" "$TARBALL" s3://ziglang.org/builds/
143##
144## SHASUM=$(sha256sum $TARBALL | cut '-d ' -f1)
145## BYTESIZE=$(wc -c < $TARBALL)
146##
147## JSONFILE="linux-$GITBRANCH.json"
148## touch $JSONFILE
149## echo "{\"tarball\": \"$TARBALL\"," >>$JSONFILE
150## echo "\"shasum\": \"$SHASUM\"," >>$JSONFILE
151## echo "\"size\": \"$BYTESIZE\"}" >>$JSONFILE
152##
153## s3cmd put -P --add-header="Cache-Control: max-age=0, must-revalidate" "$JSONFILE" "s3://ziglang.org/builds/$JSONFILE"
154## s3cmd put -P "$JSONFILE" "s3://ziglang.org/builds/$ARCH-linux-$VERSION.json"
155##
156## # `set -x` causes these variables to be mangled.
157## # See https://developercommunity.visualstudio.com/content/problem/375679/pipeline-variable-incorrectly-inserts-single-quote.html
158## set +x
159## echo "##vso[task.setvariable variable=tarball;isOutput=true]$TARBALL"
160## echo "##vso[task.setvariable variable=shasum;isOutput=true]$SHASUM"
161## echo "##vso[task.setvariable variable=bytesize;isOutput=true]$BYTESIZE"
162## echo "##vso[task.setvariable variable=version;isOutput=true]$VERSION"