Skip to content

Commit 1897432

Browse files
committed
ci: use solana-zig bootstrap toolchain
1 parent 776f4c8 commit 1897432

File tree

4 files changed

+68
-24
lines changed

4 files changed

+68
-24
lines changed

.github/workflows/ci.yml

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
branches: [dev, main]
88

99
env:
10-
ZIG_VERSION: 0.15.2
10+
SOLANA_ZIG_VERSION: v1.52.0
1111

1212
jobs:
1313
format:
@@ -16,21 +16,17 @@ jobs:
1616
steps:
1717
- uses: actions/checkout@v4
1818

19-
- name: Install Zig ${{ env.ZIG_VERSION }}
20-
id: setup-zig
21-
uses: mlugg/setup-zig@v1
19+
- name: Cache solana-zig
20+
uses: actions/cache@v4
2221
with:
23-
version: ${{ env.ZIG_VERSION }}
24-
continue-on-error: true
22+
path: solana-zig
23+
key: solana-zig-${{ env.SOLANA_ZIG_VERSION }}-${{ runner.os }}
2524

26-
- name: Install Zig (master fallback)
27-
if: ${{ steps.setup-zig.outcome == 'failure' }}
28-
uses: mlugg/setup-zig@v1
29-
with:
30-
version: master
25+
- name: Install solana-zig
26+
run: bash ./install-solana-zig.sh solana-zig
3127

3228
- name: Check formatting
33-
run: zig fmt --check build.zig src
29+
run: ./solana-zig/zig fmt --check build.zig src
3430

3531
sdk-test:
3632
name: SDK Tests
@@ -43,18 +39,14 @@ jobs:
4339
steps:
4440
- uses: actions/checkout@v4
4541

46-
- name: Install Zig ${{ env.ZIG_VERSION }}
47-
id: setup-zig
48-
uses: mlugg/setup-zig@v1
42+
- name: Cache solana-zig
43+
uses: actions/cache@v4
4944
with:
50-
version: ${{ env.ZIG_VERSION }}
51-
continue-on-error: true
45+
path: solana-zig
46+
key: solana-zig-${{ env.SOLANA_ZIG_VERSION }}-${{ runner.os }}
5247

53-
- name: Install Zig (master fallback)
54-
if: ${{ steps.setup-zig.outcome == 'failure' }}
55-
uses: mlugg/setup-zig@v1
56-
with:
57-
version: master
48+
- name: Install solana-zig
49+
run: bash ./install-solana-zig.sh solana-zig
5850

5951
- name: Run tests
60-
run: zig build test --summary all
52+
run: ./solana-zig/zig build test --summary all

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
.zig-cache
22
zig-out
3+
solana-zig

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ A pure Zig port of the Solana SDK core types and common SPL program interfaces.
1111
- **Pure Zig**: no Solana runtime syscalls; works anywhere Zig runs
1212

1313
## Requirements
14-
- Zig **0.15.2** or newer (matches `build.zig.zon`)
14+
- Zig **0.15.2** or newer (matches `build.zig.zon`). CI pins the [solana-zig bootstrap](https://github.com/joncinque/solana-zig-bootstrap) release `v1.52.0` (bundled Zig 0.15.2); you can fetch the same toolchain locally via `./install-solana-zig.sh`.
1515

1616
## Getting started
1717
1. Add the package to your project (for example with `zig fetch --save <git-url>` or a local `.path` entry in `build.zig.zon`).

install-solana-zig.sh

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#!/usr/bin/env bash
2+
3+
if [[ -n $SOLANA_ZIG_VERSION ]]; then
4+
solana_zig_version="$SOLANA_ZIG_VERSION"
5+
else
6+
solana_zig_version="v1.52.0"
7+
fi
8+
solana_zig_release_url="https://github.com/joncinque/solana-zig-bootstrap/releases/download/solana-$solana_zig_version"
9+
10+
output_dir="$1"
11+
if [[ -z $output_dir ]]; then
12+
output_dir="solana-zig"
13+
fi
14+
output_dir="$(mkdir -p "$output_dir"; cd "$output_dir"; pwd)"
15+
cd $output_dir
16+
17+
arch=$(uname -m)
18+
if [[ "$arch" == "arm64" ]]; then
19+
arch="aarch64"
20+
fi
21+
case $(uname -s | cut -c1-7) in
22+
"Linux")
23+
os="linux"
24+
abi="musl"
25+
;;
26+
"Darwin")
27+
os="macos"
28+
abi="none"
29+
;;
30+
"Windows" | "MINGW64")
31+
os="windows"
32+
abi="gnu"
33+
;;
34+
*)
35+
echo "install-solana-zig.sh: Unknown OS $(uname -s)" >&2
36+
exit 1
37+
;;
38+
esac
39+
40+
solana_zig_tar=zig-$arch-$os-$abi.tar.bz2
41+
url="$solana_zig_release_url/$solana_zig_tar"
42+
echo "Downloading $url"
43+
curl --proto '=https' --tlsv1.2 -SfOL "$url"
44+
echo "Unpacking $solana_zig_tar"
45+
tar -xjf $solana_zig_tar
46+
rm $solana_zig_tar
47+
48+
solana_zig_dir="zig-$arch-$os-$abi-baseline"
49+
mv "$solana_zig_dir"/* .
50+
rmdir $solana_zig_dir
51+
echo "solana-zig compiler available at $output_dir"

0 commit comments

Comments
 (0)