authorgravatar for michael.dusan@gmail.comMichael Dusan <michael.dusan@gmail.com> 2021-11-08 04:08:29-05:00
committergravatar for michael.dusan@gmail.comMichael Dusan <michael.dusan@gmail.com> 2021-11-08 13:45:03-05:00
loga7d215759e93be971ba5e560578e7473655cdd82
tree90cdab59b25f38a72d28bdf02296952e13e54760
parent3c7310f8cc164dbf6e6393392e8812c9f5b6a270

ci: fully activate ci.ziglang.org linux

- disable azure/linux - split probe/build/test steps for log clarity - add package step; enabled only when master/pull - add on-master-success pipeline; enabled only when master/pull

9 files changed, 195 insertions(+), 107 deletions(-)

ci/azure/macos_script+1
...@@ -95,4 +95,5 @@ if [ "${BUILD_REASON}" != "PullRequest" ]; then...@@ -95,4 +95,5 @@ if [ "${BUILD_REASON}" != "PullRequest" ]; then
95 echo "##vso[task.setvariable variable=tarball;isOutput=true]$TARBALL"95 echo "##vso[task.setvariable variable=tarball;isOutput=true]$TARBALL"
96 echo "##vso[task.setvariable variable=shasum;isOutput=true]$SHASUM"96 echo "##vso[task.setvariable variable=shasum;isOutput=true]$SHASUM"
97 echo "##vso[task.setvariable variable=bytesize;isOutput=true]$BYTESIZE"97 echo "##vso[task.setvariable variable=bytesize;isOutput=true]$BYTESIZE"
98 echo "##vso[task.setvariable variable=version;isOutput=true]$VERSION"
98fi99fi
ci/azure/pipelines.yml+1-13
...@@ -21,17 +21,6 @@ jobs:...@@ -21,17 +21,6 @@ jobs:
21 - script: ci/azure/macos_arm64_script21 - script: ci/azure/macos_arm64_script
22 name: main22 name: main
23 displayName: 'Build'23 displayName: 'Build'
24- job: BuildLinux
25 pool:
26 vmImage: 'ubuntu-18.04'
27 timeoutInMinutes: 360
28 steps:
29 - task: DownloadSecureFile@1
30 inputs:
31 secureFile: s3cfg
32 - script: ci/azure/linux_script
33 name: main
34 displayName: 'Build and test'
35- job: BuildWindows24- job: BuildWindows
36 pool:25 pool:
37 vmImage: 'windows-2019'26 vmImage: 'windows-2019'
...@@ -60,7 +49,6 @@ jobs:...@@ -60,7 +49,6 @@ jobs:
60 dependsOn:49 dependsOn:
61 - BuildMacOS50 - BuildMacOS
62 - BuildMacOS_arm6451 - BuildMacOS_arm64
63 - BuildLinux
64 - BuildWindows52 - BuildWindows
65 condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))53 condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
66 strategy:54 strategy:
...@@ -68,7 +56,7 @@ jobs:...@@ -68,7 +56,7 @@ jobs:
68 pool:56 pool:
69 vmImage: 'ubuntu-18.04'57 vmImage: 'ubuntu-18.04'
70 variables:58 variables:
71 version: $[ dependencies.BuildLinux.outputs['main.version'] ]59 version: $[ dependencies.BuildMacOS.outputs['main.version'] ]
72 steps:60 steps:
73 - task: DownloadSecureFile@161 - task: DownloadSecureFile@1
74 inputs:62 inputs:
ci/zinc/drone.yml+57-2
...@@ -9,7 +9,62 @@ workspace:...@@ -9,7 +9,62 @@ workspace:
9 path: /workspace9 path: /workspace
1010
11steps:11steps:
12- name: build-test-package12- name: probe
13 image: ci/debian-amd64:11.1-113 image: ci/debian-amd64:11.1-2
14 commands:
15 - ./ci/zinc/linux_probe.sh
16
17- name: build
18 image: ci/debian-amd64:11.1-2
14 commands:19 commands:
15 - ./ci/zinc/linux_build.sh20 - ./ci/zinc/linux_build.sh
21
22- name: test
23 depends_on:
24 - build
25 image: ci/debian-amd64:11.1-2
26 commands:
27 - ./ci/zinc/linux_test.sh
28
29- name: package
30 depends_on:
31 - test
32 when:
33 branch:
34 - master
35 event:
36 - push
37 image: ci/debian-amd64:11.1-2
38 environment:
39 AWS_ACCESS_KEY_ID:
40 from_secret: AWS_ACCESS_KEY_ID
41 AWS_SECRET_ACCESS_KEY:
42 from_secret: AWS_SECRET_ACCESS_KEY
43 commands:
44 - ./ci/zinc/linux_package.sh
45
46---
47kind: pipeline
48type: docker
49name: on-master-success
50platform:
51 os: linux
52 arch: amd64
53workspace:
54 path: /workspace
55depends_on:
56- x86_64-linux
57trigger:
58 branch:
59 - master
60 event:
61 - push
62
63steps:
64- name: on-master-sucess
65 image: ci/debian-amd64:11.1-2
66 environment:
67 SRHT_OAUTH_TOKEN:
68 from_secret: SRHT_OAUTH_TOKEN
69 commands:
70 - ./ci/zinc/linux_on_master_sucess.sh
ci/zinc/linux_base.sh created+28
...@@ -0,0 +1,28 @@
1#!/bin/sh
2
3# https://docs.drone.io/pipeline/docker/syntax/workspace/
4#
5# Drone automatically creates a temporary volume, known as your workspace,
6# where it clones your repository. The workspace is the current working
7# directory for each step in your pipeline.
8#
9# Because the workspace is a volume, filesystem changes are persisted between
10# pipeline steps. In other words, individual steps can communicate and share
11# state using the filesystem.
12#
13# Workspace volumes are ephemeral. They are created when the pipeline starts
14# and destroyed after the pipeline completes.
15
16set -x
17set -e
18
19ARCH="$(uname -m)"
20JOBS="-j$(nproc)"
21
22DEPS_LOCAL="/deps/local"
23WORKSPACE="$DRONE_WORKSPACE"
24
25DEBUG_STAGING="$WORKSPACE/_debug/staging"
26RELEASE_STAGING="$WORKSPACE/_release/staging"
27
28export PATH=$DEPS_LOCAL/bin:$PATH
ci/zinc/linux_build.sh+9-92
...@@ -1,16 +1,10 @@...@@ -1,16 +1,10 @@
1#!/bin/sh1#!/bin/sh
22
3set -x3. ./ci/zinc/linux_base.sh
4set -e
54
6WORKSPACE="$DRONE_WORKSPACE"5ZIG="$DEPS_LOCAL/bin/zig"
7LOCAL="/deps/local"
8ZIG="$LOCAL/bin/zig"
9ARCH="$(uname -m)"
10TARGET="${ARCH}-linux-musl"6TARGET="${ARCH}-linux-musl"
11MCPU="baseline"7MCPU="baseline"
12JOBS="-j$(nproc)"
13export PATH=/deps/local/bin:$PATH
148
15# Make the `zig version` number consistent.9# Make the `zig version` number consistent.
16# This will affect the cmake command below.10# This will affect the cmake command below.
...@@ -25,8 +19,8 @@ export CXX="$ZIG c++ -target $TARGET -mcpu=$MCPU"...@@ -25,8 +19,8 @@ export CXX="$ZIG c++ -target $TARGET -mcpu=$MCPU"
25mkdir _debug19mkdir _debug
26cd _debug20cd _debug
27cmake .. \21cmake .. \
28 -DCMAKE_INSTALL_PREFIX="$(pwd)/staging" \22 -DCMAKE_INSTALL_PREFIX="$DEBUG_STAGING" \
29 -DCMAKE_PREFIX_PATH="$LOCAL" \23 -DCMAKE_PREFIX_PATH="$DEPS_LOCAL" \
30 -DCMAKE_BUILD_TYPE=Debug \24 -DCMAKE_BUILD_TYPE=Debug \
31 -DZIG_TARGET_TRIPLE="$TARGET" \25 -DZIG_TARGET_TRIPLE="$TARGET" \
32 -DZIG_TARGET_MCPU="$MCPU" \26 -DZIG_TARGET_MCPU="$MCPU" \
...@@ -40,7 +34,7 @@ unset CXX...@@ -40,7 +34,7 @@ unset CXX
4034
41ninja $JOBS install35ninja $JOBS install
4236
43ZIG=$(pwd)/staging/bin/zig37ZIG=$DEBUG_STAGING/bin/zig
4438
45# Here we rebuild zig but this time using the Zig binary we just now produced to39# Here we rebuild zig but this time using the Zig binary we just now produced to
46# build zig1.o rather than relying on the one built with stage0. See40# build zig1.o rather than relying on the one built with stage0. See
...@@ -52,14 +46,13 @@ cd $WORKSPACE...@@ -52,14 +46,13 @@ cd $WORKSPACE
5246
53# Build release zig.47# Build release zig.
54echo "BUILD release zig with zig:$($ZIG version)"48echo "BUILD release zig with zig:$($ZIG version)"
55echo "zig version: $($ZIG version)"
56export CC="$ZIG cc -target $TARGET -mcpu=$MCPU"49export CC="$ZIG cc -target $TARGET -mcpu=$MCPU"
57export CXX="$ZIG c++ -target $TARGET -mcpu=$MCPU"50export CXX="$ZIG c++ -target $TARGET -mcpu=$MCPU"
58mkdir _release51mkdir _release
59cd _release52cd _release
60cmake .. \53cmake .. \
61 -DCMAKE_INSTALL_PREFIX="$(pwd)/staging" \54 -DCMAKE_INSTALL_PREFIX="$RELEASE_STAGING" \
62 -DCMAKE_PREFIX_PATH="$LOCAL" \55 -DCMAKE_PREFIX_PATH="$DEPS_LOCAL" \
63 -DCMAKE_BUILD_TYPE=Release \56 -DCMAKE_BUILD_TYPE=Release \
64 -DZIG_TARGET_TRIPLE="$TARGET" \57 -DZIG_TARGET_TRIPLE="$TARGET" \
65 -DZIG_TARGET_MCPU="$MCPU" \58 -DZIG_TARGET_MCPU="$MCPU" \
...@@ -75,81 +68,5 @@ cd $WORKSPACE...@@ -75,81 +68,5 @@ cd $WORKSPACE
75# Formatting errors can be fixed by running `zig fmt` on the files printed here.68# Formatting errors can be fixed by running `zig fmt` on the files printed here.
76$ZIG fmt --check .69$ZIG fmt --check .
7770
78$ZIG test test/behavior.zig -fno-stage1 -fLLVM -I test71# Explicit exit helps show last command duration.
7972exit
80$ZIG build test-behavior -Denable-qemu -Denable-wasmtime
81$ZIG build test-compiler-rt -Denable-qemu -Denable-wasmtime
82$ZIG build test-std -Denable-qemu -Denable-wasmtime
83$ZIG build test-minilibc -Denable-qemu -Denable-wasmtime
84$ZIG build test-compare-output -Denable-qemu -Denable-wasmtime
85$ZIG build test-standalone -Denable-qemu -Denable-wasmtime
86$ZIG build test-stack-traces -Denable-qemu -Denable-wasmtime
87$ZIG build test-cli -Denable-qemu -Denable-wasmtime
88$ZIG build test-asm-link -Denable-qemu -Denable-wasmtime
89$ZIG build test-runtime-safety -Denable-qemu -Denable-wasmtime
90$ZIG build test-translate-c -Denable-qemu -Denable-wasmtime
91$ZIG build test-run-translated-c -Denable-qemu -Denable-wasmtime
92$ZIG build docs -Denable-qemu -Denable-wasmtime
93$ZIG build # test building self-hosted without LLVM
94$ZIG build test-fmt -Denable-qemu -Denable-wasmtime
95$ZIG build test-stage2 -Denable-qemu -Denable-wasmtime
96
97# Look for HTML errors.
98tidy --drop-empty-elements no -qe zig-cache/langref.html
99
100# The remainder of this script is for master branch only.
101if [ -n "$DRONE_PULL_REQUEST" ]; then
102 exit 0
103fi
104
105STAGING=_release/staging
106
107# Produce the experimental std lib documentation.
108mkdir -p $STAGING/docs/std
109$ZIG test lib/std/std.zig \
110 --zig-lib-dir lib \
111 -femit-docs=$STAGING/docs/std \
112 -fno-emit-bin
113
114cp LICENSE $STAGING/
115cp zig-cache/langref.html $STAGING/docs/
116
117# Remove the unnecessary bin dir in $prefix/bin/zig
118mv $STAGING/bin/zig $STAGING/
119rmdir $STAGING/bin
120
121# Remove the unnecessary zig dir in $prefix/lib/zig/std/std.zig
122mv $STAGING/lib/zig $STAGING/lib2
123rmdir $STAGING/lib
124mv $STAGING/lib2 $STAGING/lib
125
126VERSION=$($STAGING/zig version)
127BASENAME="zig-linux-$ARCH-$VERSION"
128TARBALL="${BASENAME}.tar.xz"
129mv "$STAGING" "$BASENAME"
130tar cfJ "$TARBALL" "$BASENAME"
131ls -l "$TARBALL"
132
133# TODO: push artifact/meta somewhere
134## mv "$DOWNLOADSECUREFILE_SECUREFILEPATH" "$HOME/.s3cfg"
135## s3cmd put -P --add-header="cache-control: public, max-age=31536000, immutable" "$TARBALL" s3://ziglang.org/builds/
136##
137## SHASUM=$(sha256sum $TARBALL | cut '-d ' -f1)
138## BYTESIZE=$(wc -c < $TARBALL)
139##
140## JSONFILE="linux-$GITBRANCH.json"
141## touch $JSONFILE
142## echo "{\"tarball\": \"$TARBALL\"," >>$JSONFILE
143## echo "\"shasum\": \"$SHASUM\"," >>$JSONFILE
144## echo "\"size\": \"$BYTESIZE\"}" >>$JSONFILE
145##
146## s3cmd put -P --add-header="Cache-Control: max-age=0, must-revalidate" "$JSONFILE" "s3://ziglang.org/builds/$JSONFILE"
147## s3cmd put -P "$JSONFILE" "s3://ziglang.org/builds/$ARCH-linux-$VERSION.json"
148##
149## # `set -x` causes these variables to be mangled.
150## # See https://developercommunity.visualstudio.com/content/problem/375679/pipeline-variable-incorrectly-inserts-single-quote.html
151## set +x
152## echo "##vso[task.setvariable variable=tarball;isOutput=true]$TARBALL"
153## echo "##vso[task.setvariable variable=shasum;isOutput=true]$SHASUM"
154## echo "##vso[task.setvariable variable=bytesize;isOutput=true]$BYTESIZE"
155## echo "##vso[task.setvariable variable=version;isOutput=true]$VERSION"
ci/zinc/linux_on_master_sucess.sh created+12
...@@ -0,0 +1,12 @@
1#!/bin/sh
2
3. ./ci/zinc/linux_base.sh
4
5# Avoid leaking oauth token.
6set +x
7
8cd $WORKSPACE
9./ci/srht/on_master_success "$VERSION" "$SRHT_OAUTH_TOKEN"
10
11# Explicit exit helps show last command duration.
12exit
ci/zinc/linux_package.sh created+40
...@@ -0,0 +1,40 @@
1#!/bin/sh
2
3. ./ci/zinc/linux_base.sh
4
5cp LICENSE $RELEASE_STAGING/
6cp zig-cache/langref.html $RELEASE_STAGING/docs/
7
8# Remove the unnecessary bin dir in $prefix/bin/zig
9mv $RELEASE_STAGING/bin/zig $RELEASE_STAGING/
10rmdir $RELEASE_STAGING/bin
11
12# Remove the unnecessary zig dir in $prefix/lib/zig/std/std.zig
13mv $RELEASE_STAGING/lib/zig $RELEASE_STAGING/lib2
14rmdir $RELEASE_STAGING/lib
15mv $RELEASE_STAGING/lib2 $RELEASE_STAGING/lib
16
17VERSION=$($RELEASE_STAGING/zig version)
18BASENAME="zig-linux-$ARCH-$VERSION"
19TARBALL="$BASENAME.tar.xz"
20mv "$RELEASE_STAGING" "$BASENAME"
21tar cfJ "$TARBALL" "$BASENAME"
22ls -l "$TARBALL"
23
24SHASUM=$(sha256sum $TARBALL | cut '-d ' -f1)
25BYTESIZE=$(wc -c < $TARBALL)
26
27MANIFEST="manifest.json"
28touch $MANIFEST
29echo "{\"tarball\": \"$TARBALL\"," >>$MANIFEST
30echo "\"shasum\": \"$SHASUM\"," >>$MANIFEST
31echo "\"size\": \"$BYTESIZE\"}" >>$MANIFEST
32
33# Publish artifact.
34s3cmd put -P --add-header="cache-control: public, max-age=31536000, immutable" "$TARBALL" s3://ziglang.org/builds/
35
36# Publish manifest.
37s3cmd put -P --add-header="cache-control: max-age=0, must-revalidate" "$MANIFEST" "s3://ziglang.org/builds/$ARCH-linux-$VERSION.json"
38
39# Explicit exit helps show last command duration.
40exit
ci/zinc/linux_probe.sh created+10
...@@ -0,0 +1,10 @@
1#!/bin/sh
2
3. ./ci/zinc/linux_base.sh
4
5# Probe CPU/brand details.
6echo "lscpu:"
7(lscpu | sed 's,^, : ,') 1>&2
8
9# Explicit exit helps show last command duration.
10exit
ci/zinc/linux_test.sh created+37
...@@ -0,0 +1,37 @@
1#!/bin/sh
2
3. ./ci/zinc/linux_base.sh
4
5ZIG=$DEBUG_STAGING/bin/zig
6
7$ZIG test test/behavior.zig -fno-stage1 -fLLVM -I test
8
9$ZIG build test-behavior -Denable-qemu -Denable-wasmtime
10$ZIG build test-compiler-rt -Denable-qemu -Denable-wasmtime
11$ZIG build test-std -Denable-qemu -Denable-wasmtime
12$ZIG build test-minilibc -Denable-qemu -Denable-wasmtime
13$ZIG build test-compare-output -Denable-qemu -Denable-wasmtime
14$ZIG build test-standalone -Denable-qemu -Denable-wasmtime
15$ZIG build test-stack-traces -Denable-qemu -Denable-wasmtime
16$ZIG build test-cli -Denable-qemu -Denable-wasmtime
17$ZIG build test-asm-link -Denable-qemu -Denable-wasmtime
18$ZIG build test-runtime-safety -Denable-qemu -Denable-wasmtime
19$ZIG build test-translate-c -Denable-qemu -Denable-wasmtime
20$ZIG build test-run-translated-c -Denable-qemu -Denable-wasmtime
21$ZIG build docs -Denable-qemu -Denable-wasmtime
22$ZIG build # test building self-hosted without LLVM
23$ZIG build test-fmt -Denable-qemu -Denable-wasmtime
24$ZIG build test-stage2 -Denable-qemu -Denable-wasmtime
25
26# Produce the experimental std lib documentation.
27mkdir -p $RELEASE_STAGING/docs/std
28$ZIG test lib/std/std.zig \
29 --zig-lib-dir lib \
30 -femit-docs=$RELEASE_STAGING/docs/std \
31 -fno-emit-bin
32
33# Look for HTML errors.
34tidy --drop-empty-elements no -qe zig-cache/langref.html
35
36# Explicit exit helps show last command duration.
37exit