Repository navigation
Expand file tree
/
Copy pathaction.yml
More file actions
96 lines (88 loc) · 4.69 KB
/
Copy pathaction.yml
File metadata and controls
96 lines (88 loc) · 4.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
name: setup
description: Install the pinned toolchain and workspace dependencies, using sticky dependency disks on Blacksmith and optional Turbo output caching on either provider.
inputs:
provider:
description: The CI_PROVIDER repo variable, forwarded to the cache action.
required: false
default: ''
turbo-cache-key:
description: Suffix for a Turbo cache mounted at ./.turbo. Empty skips the mount. Jobs that write Turbo entries need distinct suffixes, or last-writer-wins commits evict each other's entries.
required: false
default: ''
node-version:
description: Node version to install. Empty keeps the runner's preinstalled Node, for jobs that only ever ran Bun.
required: false
default: '24'
registry-url:
description: npm registry to write an .npmrc for, so `npm publish` reads NODE_AUTH_TOKEN. Empty writes none.
required: false
default: ''
# Sticky disk keys are scoped by event name, and fork PRs get their own namespace on
# top: untrusted fork runs must never share a cache with push runs (whose caches
# feed production image builds) or with trusted internal-PR runs.
#
# GitHub runners install directly: restoring both dependency archives takes longer
# than a clean Bun install. node_modules on sticky disks keys on the lockfile hash:
# `bun install --frozen-lockfile` adds what the lockfile needs without
# pruning what it dropped, so branches on different lockfiles were contaminating
# each other (a stale @next/swc 16.2.6 outlived the 16.2.11 bump). The bun and
# Turbo caches are content/hash-addressed, so they stay shared — that is what
# keeps a fresh node_modules disk cheap to fill.
runs:
using: composite
steps:
- name: Setup Bun
uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2
with:
bun-version: 1.4.4
- name: Setup Node
if: inputs.node-version != ''
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v6
with:
node-version: ${{ inputs.node-version }}
registry-url: ${{ inputs.registry-url }}
- name: Mount Bun cache
if: inputs.provider == '' || inputs.provider == 'blacksmith'
uses: ./.github/actions/cache
with:
provider: ${{ inputs.provider }}
key: ${{ github.repository }}-bun-cache-${{ github.event_name }}${{ github.event.pull_request.head.repo.fork && '-fork' || '' }}
path: ~/.bun/install/cache
- name: Mount node_modules
if: inputs.provider == '' || inputs.provider == 'blacksmith'
uses: ./.github/actions/cache
with:
provider: ${{ inputs.provider }}
key: ${{ github.repository }}-node-modules-${{ github.event_name }}${{ github.event.pull_request.head.repo.fork && '-fork' || '' }}-${{ hashFiles('bun.lock') }}
path: ./node_modules
- name: Mount Turbo cache
if: inputs.turbo-cache-key != '' && (inputs.provider == '' || inputs.provider == 'blacksmith')
uses: ./.github/actions/cache
with:
provider: ${{ inputs.provider }}
key: ${{ github.repository }}-${{ inputs.turbo-cache-key }}-${{ github.event_name }}${{ github.event.pull_request.head.repo.fork && '-fork' || '' }}
path: ./.turbo
- name: Restore and save Turbo cache
if: inputs.turbo-cache-key != '' && inputs.provider != '' && inputs.provider != 'blacksmith'
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v5
with:
key: ${{ github.repository }}-${{ inputs.turbo-cache-key }}-${{ github.event_name }}${{ github.event.pull_request.head.repo.fork && '-fork' || '' }}-${{ github.sha }}
restore-keys: ${{ github.repository }}-${{ inputs.turbo-cache-key }}-${{ github.event_name }}${{ github.event.pull_request.head.repo.fork && '-fork' || '' }}-
path: ./.turbo
# Bun retries a failed request itself, but a registry connection that stalls
# without failing leaves `bun install` waiting until the job's own timeout
# cancels it, the whole budget spent on one hung step. Healthy installs finish
# in under two and a half minutes cold, so an attempt past three is stalled:
# kill it and retry once, which leaves room inside the shortest caller's
# 10-minute job timeout. Any other failure is real and fails at once.
- name: Install dependencies
shell: bash
run: |
for attempt in 1 2; do
timeout --kill-after=15s 3m bun install --frozen-lockfile --ignore-scripts && exit 0
status=$?
if [ "$status" -ne 124 ] && [ "$status" -ne 137 ]; then exit "$status"; fi
echo "::warning title=bun install stalled::attempt ${attempt} of 2 ran past 3 minutes"
done
echo "::error title=bun install stalled::both attempts ran past 3 minutes"
exit 1