mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 13:54:21 +00:00
ci: init github actions support
This commit is contained in:
parent
b239a178c5
commit
dc96e47eb3
4 changed files with 250 additions and 0 deletions
53
.github/workflows/ci.yaml
vendored
Normal file
53
.github/workflows/ci.yaml
vendored
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
name: push_ci
|
||||
run-name: Push CI
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
jobs:
|
||||
# linux:
|
||||
# runs-on: [self-hosted, Linux, aarch64]
|
||||
# env:
|
||||
# ARCH: "aarch64"
|
||||
# steps:
|
||||
# - name: Checkout
|
||||
# uses: actions/checkout@v3
|
||||
|
||||
# - name: Test
|
||||
# run: echo "Success!"
|
||||
# - name: Run Build Script
|
||||
# run: sh ./ci/linux/build.sh
|
||||
macos-x86_64:
|
||||
strategy:
|
||||
matrix:
|
||||
version: ["11", "12"]
|
||||
runs-on: "macos-${{ matrix.version }}"
|
||||
env:
|
||||
ARCH: "x86_64"
|
||||
MACOS_VERSION: ${{ matrix.version }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Run Build Script
|
||||
run: ./ci/macos/build.sh
|
||||
macos-aarch64:
|
||||
runs-on: [self-hosted, macOS, aarch64]
|
||||
env:
|
||||
ARCH: "aarch64"
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Run Build Script
|
||||
run: ./ci/macos/build.sh
|
||||
# windows:
|
||||
# runs-on: [self-hosted, Windows, x64]
|
||||
# env:
|
||||
# ARCH: "x86_64"
|
||||
# steps:
|
||||
# - name: Checkout
|
||||
# uses: actions/checkout@v3
|
||||
|
||||
# # - name: Run Build Script
|
||||
# # run: ./ci/windows/build.ps1
|
||||
68
ci/linux/build.sh
Normal file
68
ci/linux/build.sh
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
#!/bin/sh
|
||||
|
||||
|
||||
# Requires cmake ninja-build
|
||||
|
||||
set -x
|
||||
set -e
|
||||
|
||||
ZIGDIR="$(pwd)"
|
||||
TARGET="$ARCH-linux-musl"
|
||||
MCPU="baseline"
|
||||
CACHE_BASENAME="zig+llvm+lld+clang-$TARGET-0.10.0-dev.4560+828735ac0"
|
||||
PREFIX="$HOME/$CACHE_BASENAME"
|
||||
JOBS="-j2"
|
||||
|
||||
rm -rf $PREFIX
|
||||
cd $HOME
|
||||
|
||||
wget -nv "https://ziglang.org/deps/$CACHE_BASENAME.tar.xz"
|
||||
tar xf "$CACHE_BASENAME.tar.xz"
|
||||
|
||||
ZIG="$PREFIX/bin/zig"
|
||||
|
||||
export CC="$ZIG cc -target $TARGET -mcpu=$MCPU"
|
||||
export CXX="$ZIG c++ -target $TARGET -mcpu=$MCPU"
|
||||
export PATH=$DEPS_LOCAL/bin:$PATH
|
||||
|
||||
mkdir build-release
|
||||
cd build-release
|
||||
cmake .. \
|
||||
-DCMAKE_INSTALL_PREFIX="stage3-release" \
|
||||
-DCMAKE_PREFIX_PATH="$PREFIX" \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DZIG_TARGET_TRIPLE="$TARGET" \
|
||||
-DZIG_TARGET_MCPU="$MCPU" \
|
||||
-DZIG_STATIC=ON \
|
||||
-GNinja
|
||||
|
||||
# Now cmake will use zig as the C/C++ compiler. We reset the environment variables
|
||||
# so that installation and testing do not get affected by them.
|
||||
unset CC
|
||||
unset CXX
|
||||
|
||||
ninja install
|
||||
|
||||
stage3-release/bin/zig build test docs \
|
||||
-fqemu \
|
||||
-fwasmtime \
|
||||
-Dstatic-llvm \
|
||||
-Dtarget=native-native-musl \
|
||||
--search-prefix "$PREFIX" \
|
||||
--zig-lib-dir "$(pwd)/../lib"
|
||||
|
||||
# Produce the experimental std lib documentation.
|
||||
mkdir -p "stage3-release/doc/std"
|
||||
stage3-release/bin/zig test ../lib/std/std.zig \
|
||||
-femit-docs=stage3-release/doc/std \
|
||||
-fno-emit-bin \
|
||||
--zig-lib-dir "$(pwd)/../lib"
|
||||
|
||||
# cp ../LICENSE $RELEASE_STAGING/
|
||||
# cp ../zig-cache/langref.html $RELEASE_STAGING/doc/
|
||||
|
||||
# # Look for HTML errors.
|
||||
# tidy --drop-empty-elements no -qe $RELEASE_STAGING/doc/langref.html
|
||||
|
||||
# Explicit exit helps show last command duration.
|
||||
exit
|
||||
65
ci/macos/build.sh
Executable file
65
ci/macos/build.sh
Executable file
|
|
@ -0,0 +1,65 @@
|
|||
#!/bin/sh
|
||||
|
||||
set -x
|
||||
set -e
|
||||
|
||||
echo "Running on Version:" $MACOS_VERSION
|
||||
|
||||
# Script assumes the presence of the following:
|
||||
# s3cmd
|
||||
|
||||
ZIGDIR="$(pwd)"
|
||||
TARGET="$ARCH-macos-none"
|
||||
MCPU="baseline"
|
||||
CACHE_BASENAME="zig+llvm+lld+clang-$TARGET-0.10.0-dev.4560+828735ac0"
|
||||
PREFIX="$HOME/$CACHE_BASENAME"
|
||||
JOBS="-j2"
|
||||
|
||||
rm -rf $PREFIX
|
||||
cd $HOME
|
||||
|
||||
curl -O "https://ziglang.org/deps/$CACHE_BASENAME.tar.xz"
|
||||
tar xf "$CACHE_BASENAME.tar.xz"
|
||||
|
||||
ZIG="$PREFIX/bin/zig"
|
||||
export CC="$ZIG cc -target $TARGET -mcpu=$MCPU"
|
||||
export CXX="$ZIG c++ -target $TARGET -mcpu=$MCPU"
|
||||
|
||||
cd $ZIGDIR
|
||||
|
||||
# Make the `zig version` number consistent.
|
||||
# This will affect the cmake command below.
|
||||
git config core.abbrev 9
|
||||
git fetch --unshallow || true
|
||||
git fetch --tags
|
||||
|
||||
mkdir build
|
||||
cd build
|
||||
cmake .. \
|
||||
-DCMAKE_INSTALL_PREFIX="stage3-release" \
|
||||
-DCMAKE_PREFIX_PATH="$PREFIX" \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DZIG_TARGET_TRIPLE="$TARGET" \
|
||||
-DZIG_TARGET_MCPU="$MCPU" \
|
||||
-DZIG_STATIC=ON
|
||||
|
||||
# Now cmake will use zig as the C/C++ compiler. We reset the environment variables
|
||||
# so that installation and testing do not get affected by them.
|
||||
unset CC
|
||||
unset CXX
|
||||
|
||||
make $JOBS install
|
||||
|
||||
stage3-release/bin/zig build test docs \
|
||||
--zig-lib-dir "$(pwd)/../lib" \
|
||||
-Denable-macos-sdk \
|
||||
-Dstatic-llvm \
|
||||
-Dskip-non-native \
|
||||
--search-prefix "$PREFIX"
|
||||
|
||||
# Produce the experimental std lib documentation.
|
||||
mkdir -p "stage3-release/doc/std"
|
||||
stage3-release/bin/zig test "$(pwd)/../lib/std/std.zig" \
|
||||
--zig-lib-dir "$(pwd)/../lib" \
|
||||
-femit-docs="$(pwd)/stage3-release/doc/std" \
|
||||
-fno-emit-bin
|
||||
64
ci/windows/build.ps1
Normal file
64
ci/windows/build.ps1
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
$TARGET = "$($Env:ARCH)-windows-gnu"
|
||||
$ZIG_LLVM_CLANG_LLD_NAME = "zig+llvm+lld+clang-$TARGET-0.11.0-dev.25+499dddb4c"
|
||||
$ZIG_LLVM_CLANG_LLD_URL = "https://ziglang.org/deps/$ZIG_LLVM_CLANG_LLD_NAME.zip"
|
||||
|
||||
Write-Output "Downloading $ZIG_LLVM_CLANG_LLD_URL"
|
||||
|
||||
Invoke-WebRequest -Uri "$ZIG_LLVM_CLANG_LLD_URL" -OutFile "$ZIG_LLVM_CLANG_LLD_NAME.zip"
|
||||
|
||||
Write-Output "Extracting..."
|
||||
|
||||
Add-Type -AssemblyName System.IO.Compression.FileSystem ;
|
||||
[System.IO.Compression.ZipFile]::ExtractToDirectory("$PWD/$ZIG_LLVM_CLANG_LLD_NAME.zip", "$PWD")
|
||||
|
||||
Set-Variable -Name ZIGLIBDIR -Value "$(Get-Location)\lib"
|
||||
Set-Variable -Name ZIGINSTALLDIR -Value "$(Get-Location)\stage3-release"
|
||||
Set-Variable -Name ZIGPREFIXPATH -Value "$(Get-Location)\$ZIG_LLVM_CLANG_LLD_NAME"
|
||||
|
||||
function CheckLastExitCode {
|
||||
if (!$?) {
|
||||
exit 1
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
# Make the `zig version` number consistent.
|
||||
# This will affect the `zig build` command below which uses `git describe`.
|
||||
git config core.abbrev 9
|
||||
git fetch --tags
|
||||
|
||||
if ((git rev-parse --is-shallow-repository) -eq "true") {
|
||||
git fetch --unshallow # `git describe` won't work on a shallow repo
|
||||
}
|
||||
|
||||
Write-Output "Building Zig..."
|
||||
|
||||
& "$ZIGPREFIXPATH\bin\zig.exe" build `
|
||||
--prefix "$ZIGINSTALLDIR" `
|
||||
--search-prefix "$ZIGPREFIXPATH" `
|
||||
--zig-lib-dir "$ZIGLIBDIR" `
|
||||
-Denable-stage1 `
|
||||
-Dstatic-llvm `
|
||||
-Drelease `
|
||||
-Dstrip `
|
||||
-Duse-zig-libcxx `
|
||||
-Dtarget="$TARGET"
|
||||
CheckLastExitCode
|
||||
|
||||
Write-Output " zig build test docs..."
|
||||
|
||||
& "$ZIGINSTALLDIR\bin\zig.exe" build test docs `
|
||||
--search-prefix "$ZIGPREFIXPATH" `
|
||||
-Dstatic-llvm `
|
||||
-Dskip-non-native
|
||||
CheckLastExitCode
|
||||
|
||||
# Produce the experimental std lib documentation.
|
||||
mkdir "$ZIGINSTALLDIR\doc\std" -force
|
||||
|
||||
Write-Output "zig test std/std.zig..."
|
||||
|
||||
& "$ZIGINSTALLDIR\bin\zig.exe" test "$ZIGLIBDIR\std\std.zig" `
|
||||
--zig-lib-dir "$ZIGLIBDIR" `
|
||||
-femit-docs="$ZIGINSTALLDIR\doc\std" `
|
||||
-fno-emit-bin
|
||||
Loading…
Add table
Reference in a new issue