Skip to content

Commit a8452c9

Browse files
committed
Add cache probe workflow
1 parent ba965b4 commit a8452c9

File tree

1 file changed

+254
-0
lines changed

1 file changed

+254
-0
lines changed

.github/workflows/cache-probe.yaml

Lines changed: 254 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,254 @@
1+
name: Cache Probe
2+
3+
on:
4+
workflow_dispatch:
5+
6+
permissions:
7+
contents: read
8+
packages: write
9+
10+
jobs:
11+
cw-cluster-start:
12+
name: CW Cluster Start (${{ matrix.mode }})
13+
runs-on: ubuntu-latest
14+
timeout-minutes: 120
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
mode: [baseline, verbose]
19+
20+
steps:
21+
- name: Checkout code
22+
uses: actions/checkout@v4
23+
24+
- name: Set up Python 3.12
25+
uses: actions/setup-python@v5
26+
with:
27+
python-version: "3.12"
28+
29+
- name: Install uv
30+
uses: astral-sh/setup-uv@v7
31+
with:
32+
enable-cache: true
33+
34+
- name: Install dependencies
35+
run: uv sync --all-packages --extra=cpu --no-default-groups
36+
37+
- name: Write CoreWeave kubeconfig
38+
run: |
39+
mkdir -p ~/.kube
40+
echo "${{ secrets.CW_KUBECONFIG }}" > ~/.kube/coreweave-iris
41+
chmod 600 ~/.kube/coreweave-iris
42+
43+
- name: Log in to GitHub Container Registry
44+
uses: docker/login-action@v3
45+
with:
46+
registry: ghcr.io
47+
username: ${{ github.actor }}
48+
password: ${{ secrets.GITHUB_TOKEN }}
49+
50+
- name: Inspect buildx builder
51+
run: docker buildx inspect | tee builder-inspect.txt
52+
53+
- name: Start CoreWeave cluster
54+
id: start
55+
shell: bash
56+
run: |
57+
set -euo pipefail
58+
59+
if [[ "${{ matrix.mode }}" == "verbose" ]]; then
60+
export BUILDKIT_PROGRESS=plain
61+
iris_args=(-v)
62+
else
63+
iris_args=()
64+
fi
65+
66+
start_ts=$(date +%s)
67+
.venv/bin/iris "${iris_args[@]}" --config=lib/iris/examples/coreweave.yaml cluster start 2>&1 | tee cluster-start.log
68+
end_ts=$(date +%s)
69+
70+
echo "elapsed_seconds=$((end_ts - start_ts))" >> "$GITHUB_OUTPUT"
71+
env:
72+
R2_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }}
73+
R2_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }}
74+
75+
- name: Summarize cluster-start logs
76+
if: always()
77+
shell: bash
78+
env:
79+
ELAPSED_SECONDS: ${{ steps.start.outputs.elapsed_seconds }}
80+
run: |
81+
set -euo pipefail
82+
83+
log_file=cluster-start.log
84+
line_count=0
85+
cached_count=0
86+
done_count=0
87+
88+
if [[ -f "$log_file" ]]; then
89+
line_count=$(wc -l < "$log_file" | tr -d ' ')
90+
cached_count=$(grep -c ' CACHED' "$log_file" || true)
91+
done_count=$(grep -cE '^#.* DONE( |$)' "$log_file" || true)
92+
fi
93+
94+
{
95+
echo "## CW cluster start: ${{ matrix.mode }}"
96+
echo
97+
echo "- elapsed_seconds: ${ELAPSED_SECONDS:-unknown}"
98+
echo "- log_lines: ${line_count}"
99+
echo "- cached_lines: ${cached_count}"
100+
echo "- done_lines: ${done_count}"
101+
echo "- step_outcome: ${{ steps.start.outcome }}"
102+
} >> "$GITHUB_STEP_SUMMARY"
103+
104+
- name: Upload cluster-start logs
105+
if: always()
106+
uses: actions/upload-artifact@v4
107+
with:
108+
name: cw-cluster-start-${{ matrix.mode }}-${{ github.run_id }}-${{ github.run_attempt }}
109+
path: |
110+
builder-inspect.txt
111+
cluster-start.log
112+
if-no-files-found: warn
113+
114+
- name: Stop CoreWeave cluster
115+
if: always()
116+
continue-on-error: true
117+
run: .venv/bin/iris --config=lib/iris/examples/coreweave.yaml cluster stop
118+
env:
119+
R2_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }}
120+
R2_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }}
121+
122+
seed-iris-task:
123+
name: Seed iris-task (${{ matrix.mode }})
124+
runs-on: ubuntu-latest
125+
timeout-minutes: 45
126+
strategy:
127+
fail-fast: false
128+
matrix:
129+
mode: [noinline, inline]
130+
131+
steps:
132+
- name: Checkout code
133+
uses: actions/checkout@v4
134+
135+
- name: Log in to GitHub Container Registry
136+
uses: docker/login-action@v3
137+
with:
138+
registry: ghcr.io
139+
username: ${{ github.actor }}
140+
password: ${{ secrets.GITHUB_TOKEN }}
141+
142+
- name: Seed cache image
143+
shell: bash
144+
run: |
145+
set -euo pipefail
146+
147+
cache_ref="ghcr.io/marin-community/iris-task:cache-probe-${{ github.run_id }}-${{ github.run_attempt }}-${{ matrix.mode }}"
148+
extra_args=()
149+
if [[ "${{ matrix.mode }}" == "inline" ]]; then
150+
extra_args+=(--cache-to type=inline)
151+
fi
152+
153+
docker buildx build \
154+
--platform linux/amd64 \
155+
--progress plain \
156+
--build-arg "IRIS_GIT_HASH=$(git rev-parse --short HEAD)" \
157+
--tag "$cache_ref" \
158+
"${extra_args[@]}" \
159+
--push \
160+
-f lib/iris/Dockerfile.task \
161+
.
162+
163+
{
164+
echo "## Seed iris-task: ${{ matrix.mode }}"
165+
echo
166+
echo "- cache_ref: $cache_ref"
167+
} >> "$GITHUB_STEP_SUMMARY"
168+
169+
measure-iris-task:
170+
name: Measure iris-task (${{ matrix.mode }})
171+
runs-on: ubuntu-latest
172+
timeout-minutes: 45
173+
needs: seed-iris-task
174+
strategy:
175+
fail-fast: false
176+
matrix:
177+
mode: [noinline, inline]
178+
179+
steps:
180+
- name: Checkout code
181+
uses: actions/checkout@v4
182+
183+
- name: Log in to GitHub Container Registry
184+
uses: docker/login-action@v3
185+
with:
186+
registry: ghcr.io
187+
username: ${{ github.actor }}
188+
password: ${{ secrets.GITHUB_TOKEN }}
189+
190+
- name: Inspect buildx builder
191+
run: docker buildx inspect | tee builder-inspect.txt
192+
193+
- name: Measure cache reuse
194+
id: measure
195+
shell: bash
196+
run: |
197+
set -euo pipefail
198+
199+
cache_ref="ghcr.io/marin-community/iris-task:cache-probe-${{ github.run_id }}-${{ github.run_attempt }}-${{ matrix.mode }}"
200+
probe_tag="iris-task:probe-${{ matrix.mode }}"
201+
202+
start_ts=$(date +%s)
203+
docker buildx build \
204+
--platform linux/amd64 \
205+
--progress plain \
206+
--build-arg "IRIS_GIT_HASH=$(git rev-parse --short HEAD)" \
207+
--tag "$probe_tag" \
208+
--cache-from "type=registry,ref=$cache_ref" \
209+
--output "type=docker,name=$probe_tag" \
210+
-f lib/iris/Dockerfile.task \
211+
. \
212+
2>&1 | tee measure.log
213+
end_ts=$(date +%s)
214+
215+
echo "elapsed_seconds=$((end_ts - start_ts))" >> "$GITHUB_OUTPUT"
216+
217+
- name: Summarize measurement logs
218+
if: always()
219+
shell: bash
220+
env:
221+
ELAPSED_SECONDS: ${{ steps.measure.outputs.elapsed_seconds }}
222+
run: |
223+
set -euo pipefail
224+
225+
line_count=0
226+
cached_count=0
227+
done_count=0
228+
229+
if [[ -f measure.log ]]; then
230+
line_count=$(wc -l < measure.log | tr -d ' ')
231+
cached_count=$(grep -c ' CACHED' measure.log || true)
232+
done_count=$(grep -cE '^#.* DONE( |$)' measure.log || true)
233+
fi
234+
235+
{
236+
echo "## Measure iris-task: ${{ matrix.mode }}"
237+
echo
238+
echo "- cache_ref: ghcr.io/marin-community/iris-task:cache-probe-${{ github.run_id }}-${{ github.run_attempt }}-${{ matrix.mode }}"
239+
echo "- elapsed_seconds: ${ELAPSED_SECONDS:-unknown}"
240+
echo "- log_lines: ${line_count}"
241+
echo "- cached_lines: ${cached_count}"
242+
echo "- done_lines: ${done_count}"
243+
echo "- step_outcome: ${{ steps.measure.outcome }}"
244+
} >> "$GITHUB_STEP_SUMMARY"
245+
246+
- name: Upload measurement logs
247+
if: always()
248+
uses: actions/upload-artifact@v4
249+
with:
250+
name: iris-task-measure-${{ matrix.mode }}-${{ github.run_id }}-${{ github.run_attempt }}
251+
path: |
252+
builder-inspect.txt
253+
measure.log
254+
if-no-files-found: warn

0 commit comments

Comments
 (0)