Skip to content

Commit

Permalink
ci: update github actions workflows to use zig build system
Browse files Browse the repository at this point in the history
  • Loading branch information
ripperi committed Sep 24, 2024
1 parent ad81559 commit 11d5d77
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 113 deletions.
149 changes: 38 additions & 111 deletions .github/workflows/shared.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,9 @@ jobs:
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 }
- { host: linux-x86_64 }

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

steps:
#
Expand All @@ -57,7 +50,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 +75,51 @@ 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: 463b405f9fb795e5032da9f9646d42b267fba90a
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
- name: Install bazel
if: ${{ matrix.target == 'linux-aarch64' }}
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
fi
~/.cache/zig
./.zig-cache
- name: Install toolchains
- name: Install Zig
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
version="0.14.0-dev.1637+8c232922b"
url="https://ziglang.org/builds/zig-linux-x86_64-0.14.0-dev.1637+8c232922b.tar.xz"
# download zig
curl -L -o zig.tar.xz "${url}"
# unpack to ./zig
mkdir zig
tar -xf zig.tar.xz -C zig --strip-components=1
# add zig to path
echo $(pwd)/zig >> $GITHUB_PATH
- name: Build binaries
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 \
-Drelease \
-Dpace=${{inputs.pace}} \
--summary all
- 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
3 changes: 1 addition & 2 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,8 @@ pub fn build(b: *std.Build) !void {
},
.max_output_bytes = 1024,
});
const git_rev = git_cmd.stdout[0..9];
const version = if (!release)
VERSION ++ "-" ++ git_rev
VERSION ++ "-" ++ git_cmd.stdout[0..9]
else
VERSION;

Expand Down

0 comments on commit 11d5d77

Please sign in to comment.