authorgravatar for kappaloris@gmail.comLoris Cro <kappaloris@gmail.com> 2022-11-14 22:41:36+01:00
committergravatar for kappaloris@gmail.comLoris Cro <kappaloris@gmail.com> 2022-11-14 22:41:36+01:00
logbbd0775d777324636f7427496b5d9a3137db93d1
treeb638b96ffcf8bfa3c13cbba1d9c1d7a651f35b6b
parent7eed028f9a538624b90279aa430f6e136a77f6a2

ci: init github actions support


4 files changed, 250 insertions(+), 0 deletions(-)

.github/workflows/ci.yaml created+53
...@@ -0,0 +1,53 @@
1name: push_ci
2run-name: Push CI
3on:
4 push:
5 branches:
6 - master
7jobs:
8 # linux:
9 # runs-on: [self-hosted, Linux, aarch64]
10 # env:
11 # ARCH: "aarch64"
12 # steps:
13 # - name: Checkout
14 # uses: actions/checkout@v3
15
16 # - name: Test
17 # run: echo "Success!"
18 # - name: Run Build Script
19 # run: sh ./ci/linux/build.sh
20 macos-x86_64:
21 strategy:
22 matrix:
23 version: ["11", "12"]
24 runs-on: "macos-${{ matrix.version }}"
25 env:
26 ARCH: "x86_64"
27 MACOS_VERSION: ${{ matrix.version }}
28 steps:
29 - name: Checkout
30 uses: actions/checkout@v3
31
32 - name: Run Build Script
33 run: ./ci/macos/build.sh
34 macos-aarch64:
35 runs-on: [self-hosted, macOS, aarch64]
36 env:
37 ARCH: "aarch64"
38 steps:
39 - name: Checkout
40 uses: actions/checkout@v3
41
42 - name: Run Build Script
43 run: ./ci/macos/build.sh
44 # windows:
45 # runs-on: [self-hosted, Windows, x64]
46 # env:
47 # ARCH: "x86_64"
48 # steps:
49 # - name: Checkout
50 # uses: actions/checkout@v3
51
52 # # - name: Run Build Script
53 # # run: ./ci/windows/build.ps1
ci/linux/build.sh created+68
...@@ -0,0 +1,68 @@
1#!/bin/sh
2
3
4# Requires cmake ninja-build
5
6set -x
7set -e
8
9ZIGDIR="$(pwd)"
10TARGET="$ARCH-linux-musl"
11MCPU="baseline"
12CACHE_BASENAME="zig+llvm+lld+clang-$TARGET-0.10.0-dev.4560+828735ac0"
13PREFIX="$HOME/$CACHE_BASENAME"
14JOBS="-j2"
15
16rm -rf $PREFIX
17cd $HOME
18
19wget -nv "https://ziglang.org/deps/$CACHE_BASENAME.tar.xz"
20tar xf "$CACHE_BASENAME.tar.xz"
21
22ZIG="$PREFIX/bin/zig"
23
24export CC="$ZIG cc -target $TARGET -mcpu=$MCPU"
25export CXX="$ZIG c++ -target $TARGET -mcpu=$MCPU"
26export PATH=$DEPS_LOCAL/bin:$PATH
27
28mkdir build-release
29cd build-release
30cmake .. \
31 -DCMAKE_INSTALL_PREFIX="stage3-release" \
32 -DCMAKE_PREFIX_PATH="$PREFIX" \
33 -DCMAKE_BUILD_TYPE=Release \
34 -DZIG_TARGET_TRIPLE="$TARGET" \
35 -DZIG_TARGET_MCPU="$MCPU" \
36 -DZIG_STATIC=ON \
37 -GNinja
38
39# Now cmake will use zig as the C/C++ compiler. We reset the environment variables
40# so that installation and testing do not get affected by them.
41unset CC
42unset CXX
43
44ninja install
45
46stage3-release/bin/zig build test docs \
47 -fqemu \
48 -fwasmtime \
49 -Dstatic-llvm \
50 -Dtarget=native-native-musl \
51 --search-prefix "$PREFIX" \
52 --zig-lib-dir "$(pwd)/../lib"
53
54# Produce the experimental std lib documentation.
55mkdir -p "stage3-release/doc/std"
56stage3-release/bin/zig test ../lib/std/std.zig \
57 -femit-docs=stage3-release/doc/std \
58 -fno-emit-bin \
59 --zig-lib-dir "$(pwd)/../lib"
60
61# cp ../LICENSE $RELEASE_STAGING/
62# cp ../zig-cache/langref.html $RELEASE_STAGING/doc/
63
64# # Look for HTML errors.
65# tidy --drop-empty-elements no -qe $RELEASE_STAGING/doc/langref.html
66
67# Explicit exit helps show last command duration.
68exit
\ No newline at end of file
ci/macos/build.sh created+65
...@@ -0,0 +1,65 @@
1#!/bin/sh
2
3set -x
4set -e
5
6echo "Running on Version:" $MACOS_VERSION
7
8# Script assumes the presence of the following:
9# s3cmd
10
11ZIGDIR="$(pwd)"
12TARGET="$ARCH-macos-none"
13MCPU="baseline"
14CACHE_BASENAME="zig+llvm+lld+clang-$TARGET-0.10.0-dev.4560+828735ac0"
15PREFIX="$HOME/$CACHE_BASENAME"
16JOBS="-j2"
17
18rm -rf $PREFIX
19cd $HOME
20
21curl -O "https://ziglang.org/deps/$CACHE_BASENAME.tar.xz"
22tar xf "$CACHE_BASENAME.tar.xz"
23
24ZIG="$PREFIX/bin/zig"
25export CC="$ZIG cc -target $TARGET -mcpu=$MCPU"
26export CXX="$ZIG c++ -target $TARGET -mcpu=$MCPU"
27
28cd $ZIGDIR
29
30# Make the `zig version` number consistent.
31# This will affect the cmake command below.
32git config core.abbrev 9
33git fetch --unshallow || true
34git fetch --tags
35
36mkdir build
37cd build
38cmake .. \
39 -DCMAKE_INSTALL_PREFIX="stage3-release" \
40 -DCMAKE_PREFIX_PATH="$PREFIX" \
41 -DCMAKE_BUILD_TYPE=Release \
42 -DZIG_TARGET_TRIPLE="$TARGET" \
43 -DZIG_TARGET_MCPU="$MCPU" \
44 -DZIG_STATIC=ON
45
46# Now cmake will use zig as the C/C++ compiler. We reset the environment variables
47# so that installation and testing do not get affected by them.
48unset CC
49unset CXX
50
51make $JOBS install
52
53stage3-release/bin/zig build test docs \
54 --zig-lib-dir "$(pwd)/../lib" \
55 -Denable-macos-sdk \
56 -Dstatic-llvm \
57 -Dskip-non-native \
58 --search-prefix "$PREFIX"
59
60# Produce the experimental std lib documentation.
61mkdir -p "stage3-release/doc/std"
62stage3-release/bin/zig test "$(pwd)/../lib/std/std.zig" \
63 --zig-lib-dir "$(pwd)/../lib" \
64 -femit-docs="$(pwd)/stage3-release/doc/std" \
65 -fno-emit-bin
\ No newline at end of file
ci/windows/build.ps1 created+64
...@@ -0,0 +1,64 @@
1$TARGET = "$($Env:ARCH)-windows-gnu"
2$ZIG_LLVM_CLANG_LLD_NAME = "zig+llvm+lld+clang-$TARGET-0.11.0-dev.25+499dddb4c"
3$ZIG_LLVM_CLANG_LLD_URL = "https://ziglang.org/deps/$ZIG_LLVM_CLANG_LLD_NAME.zip"
4
5Write-Output "Downloading $ZIG_LLVM_CLANG_LLD_URL"
6
7Invoke-WebRequest -Uri "$ZIG_LLVM_CLANG_LLD_URL" -OutFile "$ZIG_LLVM_CLANG_LLD_NAME.zip"
8
9Write-Output "Extracting..."
10
11Add-Type -AssemblyName System.IO.Compression.FileSystem ;
12[System.IO.Compression.ZipFile]::ExtractToDirectory("$PWD/$ZIG_LLVM_CLANG_LLD_NAME.zip", "$PWD")
13
14Set-Variable -Name ZIGLIBDIR -Value "$(Get-Location)\lib"
15Set-Variable -Name ZIGINSTALLDIR -Value "$(Get-Location)\stage3-release"
16Set-Variable -Name ZIGPREFIXPATH -Value "$(Get-Location)\$ZIG_LLVM_CLANG_LLD_NAME"
17
18function CheckLastExitCode {
19 if (!$?) {
20 exit 1
21 }
22 return 0
23}
24
25# Make the `zig version` number consistent.
26# This will affect the `zig build` command below which uses `git describe`.
27git config core.abbrev 9
28git fetch --tags
29
30if ((git rev-parse --is-shallow-repository) -eq "true") {
31 git fetch --unshallow # `git describe` won't work on a shallow repo
32}
33
34Write-Output "Building Zig..."
35
36& "$ZIGPREFIXPATH\bin\zig.exe" build `
37 --prefix "$ZIGINSTALLDIR" `
38 --search-prefix "$ZIGPREFIXPATH" `
39 --zig-lib-dir "$ZIGLIBDIR" `
40 -Denable-stage1 `
41 -Dstatic-llvm `
42 -Drelease `
43 -Dstrip `
44 -Duse-zig-libcxx `
45 -Dtarget="$TARGET"
46CheckLastExitCode
47
48Write-Output " zig build test docs..."
49
50& "$ZIGINSTALLDIR\bin\zig.exe" build test docs `
51 --search-prefix "$ZIGPREFIXPATH" `
52 -Dstatic-llvm `
53 -Dskip-non-native
54CheckLastExitCode
55
56# Produce the experimental std lib documentation.
57mkdir "$ZIGINSTALLDIR\doc\std" -force
58
59Write-Output "zig test std/std.zig..."
60
61& "$ZIGINSTALLDIR\bin\zig.exe" test "$ZIGLIBDIR\std\std.zig" `
62 --zig-lib-dir "$ZIGLIBDIR" `
63 -femit-docs="$ZIGINSTALLDIR\doc\std" `
64 -fno-emit-bin