Skip to content

Commit

Permalink
ci: update github actions workflows for zig build system
Browse files Browse the repository at this point in the history
  • Loading branch information
ripperi committed Sep 26, 2024
1 parent 5d800aa commit 59f3af4
Showing 1 changed file with 37 additions and 110 deletions.
147 changes: 37 additions & 110 deletions .github/workflows/shared.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,8 @@ jobs:
urbit:
strategy:
fail-fast: false
matrix:
include:
# GitHub doesn't provide AArch64 Linux machines, so we self-host a
# runner with BuildJet instead.
- { target: linux-aarch64, runner: buildjet-2vcpu-ubuntu-2204-arm }
- { target: linux-x86_64, runner: ubuntu-22.04 }
# GitHub doesn't provide macOS machines with Apple Silicon, so we
# self-host a runner with MacStadium instead.
- { target: macos-aarch64, runner: [self-hosted, macos, ARM64] }
- { target: macos-x86_64, runner: macos-12 }

runs-on: ${{ matrix.runner }}
runs-on: ubuntu-22.04

steps:
#
Expand All @@ -57,7 +47,6 @@ jobs:
- uses: actions/checkout@v3

- name: Set swap space
if: ${{ matrix.target == 'linux-x86_64' || matrix.target == 'linux-aarch64'}}
run: |
echo "Memory and swap:"
free -h
Expand All @@ -83,116 +72,54 @@ jobs:
swapon --show
echo
- name: chown /usr/local
if: ${{ matrix.target == 'linux-x86_64' || matrix.target == 'linux-aarch64'}}
run: |
sudo chown $(whoami) /usr/local
- name: Set up build cache
uses: actions/cache@v3
with:
key: ${{ matrix.target }}-cache-1
key: linux-x86_64-zig-cache
path: |
# # Cache bazel path on Linux.
~/.cache/bazel/_bazel_$(whoami)
# # Cache bazel path on macOS.
/private/var/tmp/_bazel_$(whoami)
# Cache musl libc toolchains.
/usr/local/*-musl
- name: chown /usr/local/*-musl
if: ${{ matrix.target == 'linux-x86_64' || matrix.target == 'linux-aarch64'}}
run: |
chown -R $USER /usr/local/*-musl || true
~/.zig
~/.cache/zig
${{ github.workspace }}/.zig-cache
- name: Install bazel
if: ${{ matrix.target == 'linux-aarch64' }}
- name: Install Zig
run: |
version="6.2.0"
platform="linux-arm64"
base_url="https://github.com/bazelbuild/bazel/releases/download/${version}/bazel-${version}-${platform}"
# download bazel from github releases
curl -L -O "${base_url}"
# make bazel executable
chmod +x bazel-${version}-${platform}
# verify the binary has a good checksum
curl -L -O "${base_url}.sha256"
if [[ "$(sha256sum bazel-${version}-${platform})" == "$(cat bazel-${version}-${platform}.sha256)" ]]; then
echo "Checksum matches"
else
echo "Checksum does not match"
exit 1
fi
# download and import the public key
curl -L -O https://bazel.build/bazel-release.pub.gpg
gpg --import bazel-release.pub.gpg
# verify the binary has a good signature
curl -L -O "${base_url}.sig"
if [[ `gpg --verify bazel-${version}-${platform}.sig` -eq 0 ]]; then
echo "Good signature from bazel"
sudo mv bazel-${version}-${platform} /usr/local/bin/bazel
else
echo "Bad signature from bazel"
exit 1
if [ ! -d "$HOME/.zig" ]; then
url="https://ziglang.org/download/0.13.0/zig-linux-x86_64-0.13.0.tar.xz"
# download zig
curl -L -o $HOME/zig.tar.xz "${url}"
# unpack to ./zig
mkdir $HOME/.zig
tar -xf $HOME/zig.tar.xz -C $HOME/.zig --strip-components=1
fi
# add zig to path
echo $HOME/.zig >> $GITHUB_PATH
zig bulid --help
- name: Install toolchains
- name: Build binaries
run: |
case "${{ matrix.target }}" in
"linux-aarch64")
sudo apt-get -y install autoconf-archive
bazel run //bazel/toolchain:aarch64-linux-musl-gcc
;;
"linux-x86_64")
sudo apt-get -y install autoconf-archive
bazel run //bazel/toolchain:x86_64-linux-musl-gcc
;;
"macos-aarch64")
brew install pkg-config autoconf-archive
;;
"macos-x86_64")
# Switch Xcode path to match the path specified in our bazel toolchain.
sudo xcode-select --switch /Library/Developer/CommandLineTools
brew install automake autoconf-archive libtool llvm@15
;;
*)
echo "Unsupported target: ${{ matrix.target }}"
exit 1
;;
esac
- name: Build binary
run: |
echo "${{ inputs.pace }}" > ./PACE
case "${{ matrix.target }}" in
"linux-aarch64")
bazel build :urbit
;;
"linux-x86_64")
bazel build :urbit
;;
"macos-aarch64")
bazel build :urbit
;;
"macos-x86_64")
bazel build --clang_version=15.0.7 --extra_toolchains=//bazel/toolchain:brew-clang-macos-x86_64-toolchain :urbit
;;
esac
zig build \
-Doptimize=ReleaseFast \
-Dpace=${{inputs.pace}}
- name: Run unit tests
run: |
if [[ "${{ matrix.target }}" == "macos-x86_64" ]]; then
bazel test --build_tests_only --clang_version=15.0.7 --extra_toolchains=//bazel/toolchain:brew-clang-macos-x86_64-toolchain ...
else
bazel test --build_tests_only ...
fi
- name: Run fake ship tests
if: ${{ matrix.target == 'linux-x86_64' && inputs.fake_tests }}
run: |
# See https://github.com/urbit/vere/issues/40.
bazel build //pkg/vere:test-fake-ship
zig build \
ur-test ent-test \
hashtable-test jets-test \
nock-test retrieve-test \
serial-test ames-test \
boot-test newt-test \
vere-noun-test unix-test \
benchmarks \
-Doptimize=ReleaseFast \
-Dpace=${{inputs.pace}} \
--summary all
# - name: Run fake ship tests
# if: ${{ matrix.target == 'linux-x86_64' && inputs.fake_tests }}
# run: |
# # See https://github.com/urbit/vere/issues/40.
# bazel build //pkg/vere:test-fake-ship


#
Expand Down

0 comments on commit 59f3af4

Please sign in to comment.