Skip to content

Commit 458778d

Browse files
avalleteclaudejgoux
authored
chore(ci): pin Bun and add cache + retried fallback installer (#5228)
## Summary Enhanced the Bun setup action to improve installation reliability by adding toolchain caching, pinning to a specific version, implementing a fallback installation mechanism with retries, and adding version verification. ## Key Changes - **Pin Bun version**: Changed from `latest` to a specific version (`1.3.13`) for reproducible builds - **Add toolchain caching**: Implemented caching of the Bun toolchain to `/opt/hostedtoolcache/bun` to speed up subsequent workflow runs - **Implement fallback installation**: Added a retry-based fallback mechanism using `nick-fields/retry@v3` that directly downloads and installs Bun via curl if the primary setup action fails - **Add version verification**: Added a verification step to confirm Bun is properly installed by running `bun --version` - **Improve error handling**: Made the primary installation step non-blocking with `continue-on-error: true` to allow the fallback mechanism to execute ## Implementation Details - The fallback installation uses curl to download from `https://bun.sh/install` with up to 5 retry attempts and 30-second wait intervals between retries - The Bun binary path is explicitly added to `$GITHUB_PATH` in the fallback step to ensure it's available for subsequent steps - All steps use the pinned `BUN_VERSION` environment variable for consistency across the workflow https://claude.ai/code/session_01KYCuKb2pWDBjsAZ2DagygF Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Julien Goux <hi@jgoux.dev>
1 parent 6878356 commit 458778d

1 file changed

Lines changed: 29 additions & 1 deletion

File tree

.github/actions/setup/action.yml

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,38 @@ description: Perform standard setup and install dependencies using pnpm
55
runs:
66
using: "composite"
77
steps:
8+
- name: Resolve Bun version
9+
shell: bash
10+
run: echo "BUN_VERSION=1.3.13" >> "$GITHUB_ENV"
11+
12+
- name: Restore Bun toolchain cache
13+
id: bun-toolchain-cache
14+
uses: actions/cache@v4
15+
with:
16+
path: /opt/hostedtoolcache/bun
17+
key: bun-toolchain-${{ runner.os }}-${{ runner.arch }}-${{ env.BUN_VERSION }}
18+
819
- name: Install Bun
20+
id: install-bun
921
uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2
22+
continue-on-error: true
1023
with:
11-
bun-version: latest
24+
bun-version: ${{ env.BUN_VERSION }}
25+
26+
- name: Install Bun (fallback with retries)
27+
if: steps.install-bun.outcome == 'failure'
28+
uses: nick-fields/retry@v3
29+
with:
30+
timeout_minutes: 3
31+
max_attempts: 5
32+
retry_wait_seconds: 30
33+
command: |
34+
curl -fsSL https://bun.sh/install | bash -s "bun-v${BUN_VERSION}"
35+
echo "$HOME/.bun/bin" >> "$GITHUB_PATH"
36+
37+
- name: Verify Bun
38+
shell: bash
39+
run: bun --version
1240

1341
- name: Install Node.js
1442
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6

0 commit comments

Comments
 (0)