Persist Zig build caches in CI
Build and Release / Build executables (pull_request) Failing after 20s
Build and Release / Build executables (pull_request) Failing after 20s
This commit is contained in:
@@ -1,11 +1,19 @@
|
|||||||
name: Build and Release
|
name: Build and Release
|
||||||
|
|
||||||
on:
|
on:
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
tags:
|
tags:
|
||||||
- 'v*'
|
- 'v*'
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
|
||||||
|
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: write
|
contents: write
|
||||||
@@ -14,15 +22,40 @@ jobs:
|
|||||||
build:
|
build:
|
||||||
name: Build executables
|
name: Build executables
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
env:
|
||||||
|
ZIG_INSTALL_ROOT: /ci-cache/zig-chess/0.16.0/linux-amd64/tool
|
||||||
|
ZIG_LOCAL_CACHE_DIR: /ci-cache/zig-chess/0.16.0/linux-amd64/local
|
||||||
|
ZIG_GLOBAL_CACHE_DIR: /ci-cache/zig-chess/0.16.0/linux-amd64/global
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: https://github.com/actions/checkout@v4
|
||||||
|
|
||||||
- name: Set up Zig
|
- name: Install pinned Zig from the persistent cache
|
||||||
uses: mlugg/setup-zig@v2
|
run: |
|
||||||
with:
|
set -eu
|
||||||
version: 0.16.0
|
cache_parent="$(dirname "$ZIG_INSTALL_ROOT")"
|
||||||
|
mkdir -p "$cache_parent"
|
||||||
|
exec 9>"$cache_parent/.install.lock"
|
||||||
|
flock -x 9
|
||||||
|
if ! test -x "$ZIG_INSTALL_ROOT/zig" || \
|
||||||
|
! test "$("$ZIG_INSTALL_ROOT/zig" version)" = "0.16.0"; then
|
||||||
|
archive="$(mktemp /tmp/zig-0.16.0.XXXXXXXX.tar.xz)"
|
||||||
|
staging="$(mktemp -d "$cache_parent/.tool.XXXXXXXX")"
|
||||||
|
trap 'rm -f "$archive"; rm -rf "$staging"' EXIT
|
||||||
|
curl --fail --location --retry 3 --retry-all-errors \
|
||||||
|
--output "$archive" \
|
||||||
|
https://ziglang.org/download/0.16.0/zig-x86_64-linux-0.16.0.tar.xz
|
||||||
|
printf '%s %s\n' \
|
||||||
|
70e49664a74374b48b51e6f3fdfbf437f6395d42509050588bd49abe52ba3d00 \
|
||||||
|
"$archive" | sha256sum --check -
|
||||||
|
tar -xJf "$archive" --strip-components=1 -C "$staging"
|
||||||
|
rm -rf "$ZIG_INSTALL_ROOT"
|
||||||
|
mv "$staging" "$ZIG_INSTALL_ROOT"
|
||||||
|
rm -f "$archive"
|
||||||
|
trap - EXIT
|
||||||
|
fi
|
||||||
|
echo "$ZIG_INSTALL_ROOT" >> "$GITHUB_PATH"
|
||||||
|
|
||||||
- name: Install shader compiler
|
- name: Install shader compiler
|
||||||
run: |
|
run: |
|
||||||
@@ -34,17 +67,21 @@ jobs:
|
|||||||
zig version
|
zig version
|
||||||
glslc --version
|
glslc --version
|
||||||
|
|
||||||
|
- name: Prepare persistent Zig caches
|
||||||
|
run: |
|
||||||
|
mkdir -p "$ZIG_LOCAL_CACHE_DIR" "$ZIG_GLOBAL_CACHE_DIR"
|
||||||
|
|
||||||
- name: Build GUI executable
|
- name: Build GUI executable
|
||||||
run: |
|
run: |
|
||||||
zig build \
|
zig build \
|
||||||
--cache-dir /tmp/zig-chess-cache \
|
--cache-dir "$ZIG_LOCAL_CACHE_DIR" \
|
||||||
--global-cache-dir /tmp/zig-global-cache
|
--global-cache-dir "$ZIG_GLOBAL_CACHE_DIR"
|
||||||
|
|
||||||
- name: Build magic generator executable
|
- name: Build magic generator executable
|
||||||
run: |
|
run: |
|
||||||
zig build magic-numbers \
|
zig build magic-numbers \
|
||||||
--cache-dir /tmp/zig-chess-cache \
|
--cache-dir "$ZIG_LOCAL_CACHE_DIR" \
|
||||||
--global-cache-dir /tmp/zig-global-cache
|
--global-cache-dir "$ZIG_GLOBAL_CACHE_DIR"
|
||||||
|
|
||||||
- name: Package executables
|
- name: Package executables
|
||||||
run: |
|
run: |
|
||||||
@@ -60,7 +97,7 @@ jobs:
|
|||||||
sha256sum "dist/${artifact_dir}.tar.gz" > "dist/${artifact_dir}.tar.gz.sha256"
|
sha256sum "dist/${artifact_dir}.tar.gz" > "dist/${artifact_dir}.tar.gz.sha256"
|
||||||
|
|
||||||
- name: Upload build artifact
|
- name: Upload build artifact
|
||||||
uses: actions/upload-artifact@v3
|
uses: https://github.com/actions/upload-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: zig-chess-${{ github.ref_name }}
|
name: zig-chess-${{ github.ref_name }}
|
||||||
path: |
|
path: |
|
||||||
|
|||||||
Reference in New Issue
Block a user