Skip to content

Commit 738dbdc

Browse files
leofangclaude
andauthored
Clean up CI annotations and surface sccache stats from cibuildwheel (#1879)
* Suppress pip cache and root-user warnings in Linux container CI jobs Set PIP_CACHE_DIR=/tmp/pip-cache and PIP_ROOT_USER_ACTION=ignore in the container env for test-wheel-linux and coverage-linux jobs. These jobs run as root in Ubuntu containers where /github/home/.cache/pip is not writable, causing ~54 harmless warnings per CI run. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * Move PIP_ROOT_USER_ACTION from container.env to job-level env The pip root-user warning was still appearing because actions/setup-python runs its internal "pip upgrade" on the host runner, not inside the container. Container-level env vars are invisible to host-side actions. Moving PIP_ROOT_USER_ACTION to the job-level env block makes it available to both host-side actions (setup-python) and container-side run steps. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * Revert PIP_ROOT_USER_ACTION changes (ineffective for setup-python) The pip root-user warning originates from actions/setup-python's internal ensurepip call, which deliberately strips all PIP_* env vars (CPython design, see python/cpython#139363). Neither container.env nor job-level env can suppress it. See PR comment for full analysis. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * Bump actions/cache to v5.0.4 (node24) and disable sccache annotations - Update actions/cache from v4.2.3 (node20) to v5.0.4 (node24) in fetch_ctk to eliminate Node.js 20 deprecation warnings. All runners are on v2.332+ (v5 requires >= 2.327.1). - Set disable_annotations on sccache-action to suppress the cache stats notice annotations and job summaries. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * Bump doc_preview actions to node24-compatible versions - JamesIves/github-pages-deploy-action: v4.7.3 (node20) → v4.8.0 (node24) - marocchino/sticky-pull-request-comment: v2.9.2 (node20) → v3.0.3 (node24) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * Add sccache-summary action and surface container stats in job summary sccache stats were previously lost because cibuildwheel runs compilation inside a manylinux container with its own sccache server instance, while sccache-action on the host sees 0 hits. Fix by dumping sccache stats JSON from inside the container to the host filesystem (via /host/ mount), then reading it in a new composite action that writes a formatted table to GITHUB_STEP_SUMMARY. Inspired by NVIDIA/cccl PR #3621. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * Fix sccache hit rate calculation and add step link hint - Use cache_hits + cache_misses (per language) as the denominator instead of compile_requests, which includes non-compilation calls (linker invocations, etc). This matches sccache's own hit rate. - Add build-step input to reference the cibuildwheel step name in the summary for easier navigation to full stats. - Remove intermediate summary file; only write to GITHUB_STEP_SUMMARY. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * Remove build-step input from sccache-summary action GHA has no construct to reference a previous step's name dynamically (steps context only exposes outcome/conclusion/outputs). The label input already identifies which build produced the stats, so the hardcoded build-step name is redundant. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * Revert "Remove build-step input from sccache-summary action" This reverts commit f4ed3f3. --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 87c305b commit 738dbdc

File tree

6 files changed

+121
-9
lines changed

6 files changed

+121
-9
lines changed

.github/actions/doc_preview/action.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ runs:
2222
# Note: the PR previews will be removed once merged to main or release/* (see below)
2323
- name: Deploy doc preview
2424
if: ${{ github.ref_name != 'main' && !startsWith(github.ref_name, 'release/') }}
25-
uses: JamesIves/github-pages-deploy-action@6c2d9db40f9296374acc17b90404b6e8864128c8 # v4.7.3
25+
uses: JamesIves/github-pages-deploy-action@d92aa235d04922e8f08b40ce78cc5442fcfbfa2f # v4.8.0
2626
with:
2727
git-config-name: cuda-python-bot
2828
git-config-email: cuda-python-bot@users.noreply.github.com
@@ -32,7 +32,7 @@ runs:
3232

3333
- name: Leave a comment after deployment
3434
if: ${{ github.ref_name != 'main' && !startsWith(github.ref_name, 'release/') }}
35-
uses: marocchino/sticky-pull-request-comment@67d0dec7b07ed060a405f9b2a64b8ab319fdd7db # v2.9.2
35+
uses: marocchino/sticky-pull-request-comment@d4d6b0936434b21bc8345ad45a440c5f7d2c40ff # v3.0.3
3636
with:
3737
header: pr-preview
3838
number: ${{ inputs.pr-number }}
@@ -49,7 +49,7 @@ runs:
4949
# The steps below are executed only when building on main or release/*.
5050
- name: Remove doc preview
5151
if: ${{ github.ref_name == 'main' || startsWith(github.ref_name, 'release/') }}
52-
uses: JamesIves/github-pages-deploy-action@6c2d9db40f9296374acc17b90404b6e8864128c8 # v4.7.3
52+
uses: JamesIves/github-pages-deploy-action@d92aa235d04922e8f08b40ce78cc5442fcfbfa2f # v4.8.0
5353
with:
5454
git-config-name: cuda-python-bot
5555
git-config-email: cuda-python-bot@users.noreply.github.com
@@ -59,7 +59,7 @@ runs:
5959

6060
- name: Leave a comment after removal
6161
if: ${{ github.ref_name == 'main' || startsWith(github.ref_name, 'release/') }}
62-
uses: marocchino/sticky-pull-request-comment@67d0dec7b07ed060a405f9b2a64b8ab319fdd7db # v2.9.2
62+
uses: marocchino/sticky-pull-request-comment@d4d6b0936434b21bc8345ad45a440c5f7d2c40ff # v3.0.3
6363
with:
6464
header: pr-preview
6565
number: ${{ inputs.pr-number }}

.github/actions/fetch_ctk/action.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ runs:
6060

6161
- name: Download CTK cache
6262
id: ctk-get-cache
63-
uses: actions/cache/restore@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
63+
uses: actions/cache/restore@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4
6464
continue-on-error: true
6565
with:
6666
key: ${{ env.CTK_CACHE_KEY }}
@@ -142,7 +142,7 @@ runs:
142142
- name: Upload CTK cache
143143
if: ${{ !cancelled() &&
144144
steps.ctk-get-cache.outputs.cache-hit != 'true' }}
145-
uses: actions/cache/save@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
145+
uses: actions/cache/save@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4
146146
with:
147147
key: ${{ env.CTK_CACHE_KEY }}
148148
path: ./${{ env.CTK_CACHE_FILENAME }}
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
#
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
name: sccache summary
6+
description: Parse sccache stats JSON and write a summary table to GITHUB_STEP_SUMMARY
7+
8+
# Inspired by NVIDIA/cccl's prepare-execution-summary.py (PR #3621).
9+
# Only counts C/C++ and CUDA language hits (excludes PTX/CUBIN which are
10+
# not included in sccache's compile_requests counter).
11+
12+
inputs:
13+
json-file:
14+
description: "Path to the sccache stats JSON file (from sccache --show-stats --stats-format=json)"
15+
required: true
16+
label:
17+
description: "Label for the stats row (e.g. cuda.bindings, cuda.core)"
18+
required: false
19+
default: "sccache"
20+
build-step:
21+
description: "Name of the cibuildwheel build step (for deep-link in summary)"
22+
required: false
23+
default: ""
24+
25+
runs:
26+
using: composite
27+
steps:
28+
- name: Report sccache stats
29+
shell: bash --noprofile --norc -euo pipefail {0}
30+
env:
31+
SCCACHE_JSON: ${{ inputs.json-file }}
32+
SCCACHE_LABEL: ${{ inputs.label }}
33+
SCCACHE_BUILD_STEP: ${{ inputs.build-step }}
34+
run: |
35+
if [ ! -f "$SCCACHE_JSON" ]; then
36+
echo "::warning::sccache stats file not found: $SCCACHE_JSON"
37+
exit 0
38+
fi
39+
40+
python3 - <<'PYEOF'
41+
import json, os, urllib.parse
42+
43+
json_file = os.environ["SCCACHE_JSON"]
44+
label = os.environ["SCCACHE_LABEL"]
45+
build_step = os.environ.get("SCCACHE_BUILD_STEP", "")
46+
47+
with open(json_file) as f:
48+
stats = json.load(f)["stats"]
49+
50+
# compile_requests includes non-compilation calls (linker, etc).
51+
# Use cache_hits + cache_misses as the denominator to match sccache's
52+
# own "Cache hits rate" which only counts actual compilation requests.
53+
counted_languages = {"C/C++", "CUDA"}
54+
hits = sum(
55+
v for k, v in stats.get("cache_hits", {}).get("counts", {}).items()
56+
if k in counted_languages
57+
)
58+
misses = sum(
59+
v for k, v in stats.get("cache_misses", {}).get("counts", {}).items()
60+
if k in counted_languages
61+
)
62+
total = hits + misses
63+
pct = int(100 * hits / total) if total > 0 else 0
64+
65+
# Build a deep-link to the cibuildwheel step if step name is provided.
66+
# GHA step summary links use the format: #step:N:L but we can't know the
67+
# step number here. Instead, link to the job page with a search hint.
68+
link_note = ""
69+
if build_step:
70+
link_note = f"\n\n_Full stats in the **{build_step}** step log._\n"
71+
72+
summary_file = os.environ.get("GITHUB_STEP_SUMMARY", "")
73+
if summary_file:
74+
with open(summary_file, "a") as sf:
75+
sf.write(f"### 📊 {label} — sccache stats\n")
76+
sf.write("| Hit Rate | Hits | Misses | Requests |\n")
77+
sf.write("|----------|------|--------|----------|\n")
78+
sf.write(f"| {pct}% | {hits} | {misses} | {total} |{link_note}\n")
79+
80+
print(f"{label}: {pct}% hit rate ({hits}/{total})")
81+
PYEOF

.github/workflows/build-wheel.yml

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ jobs:
4848
# are exposed by this action.
4949
- name: Enable sccache
5050
uses: mozilla-actions/sccache-action@7d986dd989559c6ecdb630a3fd2557667be217ad # 0.0.9
51+
with:
52+
disable_annotations: 'true'
5153

5254
# xref: https://github.com/orgs/community/discussions/42856#discussioncomment-7678867
5355
- name: Adding addtional GHA cache-related env vars
@@ -175,13 +177,22 @@ jobs:
175177
CUDA_PYTHON_PARALLEL_LEVEL=${{ env.CUDA_PYTHON_PARALLEL_LEVEL }}
176178
# check cache stats before leaving cibuildwheel
177179
CIBW_BEFORE_TEST_LINUX: >
178-
"/host/${{ env.SCCACHE_PATH }}" --show-stats
180+
"/host/${{ env.SCCACHE_PATH }}" --show-stats &&
181+
"/host/${{ env.SCCACHE_PATH }}" --show-stats --stats-format=json > /host/${{ github.workspace }}/sccache_bindings.json
179182
# force the test stage to be run (so that before-test is not skipped)
180183
# TODO: we might want to think twice on adding this, it does a lot of
181184
# things before reaching this command.
182185
CIBW_TEST_COMMAND: >
183186
echo "ok!"
184187
188+
- name: Report sccache stats (cuda.bindings)
189+
if: ${{ inputs.host-platform != 'win-64' }}
190+
uses: ./.github/actions/sccache-summary
191+
with:
192+
json-file: sccache_bindings.json
193+
label: "cuda.bindings"
194+
build-step: "Build cuda.bindings wheel"
195+
185196
- name: List the cuda.bindings artifacts directory
186197
run: |
187198
if [[ "${{ inputs.host-platform }}" == win* ]]; then
@@ -233,13 +244,22 @@ jobs:
233244
PIP_FIND_LINKS="$(cygpath -w ${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }})"
234245
# check cache stats before leaving cibuildwheel
235246
CIBW_BEFORE_TEST_LINUX: >
236-
"/host${{ env.SCCACHE_PATH }}" --show-stats
247+
"/host${{ env.SCCACHE_PATH }}" --show-stats &&
248+
"/host${{ env.SCCACHE_PATH }}" --show-stats --stats-format=json > /host/${{ github.workspace }}/sccache_core.json
237249
# force the test stage to be run (so that before-test is not skipped)
238250
# TODO: we might want to think twice on adding this, it does a lot of
239251
# things before reaching this command.
240252
CIBW_TEST_COMMAND: >
241253
echo "ok!"
242254
255+
- name: Report sccache stats (cuda.core)
256+
if: ${{ inputs.host-platform != 'win-64' }}
257+
uses: ./.github/actions/sccache-summary
258+
with:
259+
json-file: sccache_core.json
260+
label: "cuda.core"
261+
build-step: "Build cuda.core wheel"
262+
243263
- name: List the cuda.core artifacts directory and rename
244264
run: |
245265
if [[ "${{ inputs.host-platform }}" == win* ]]; then
@@ -412,13 +432,22 @@ jobs:
412432
PIP_FIND_LINKS="$(cygpath -w ${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }})"
413433
# check cache stats before leaving cibuildwheel
414434
CIBW_BEFORE_TEST_LINUX: >
415-
"/host${{ env.SCCACHE_PATH }}" --show-stats
435+
"/host${{ env.SCCACHE_PATH }}" --show-stats &&
436+
"/host${{ env.SCCACHE_PATH }}" --show-stats --stats-format=json > /host/${{ github.workspace }}/sccache_core_prev.json
416437
# force the test stage to be run (so that before-test is not skipped)
417438
# TODO: we might want to think twice on adding this, it does a lot of
418439
# things before reaching this command.
419440
CIBW_TEST_COMMAND: >
420441
echo "ok!"
421442
443+
- name: Report sccache stats (cuda.core prev)
444+
if: ${{ inputs.host-platform != 'win-64' }}
445+
uses: ./.github/actions/sccache-summary
446+
with:
447+
json-file: sccache_core_prev.json
448+
label: "cuda.core (prev CTK)"
449+
build-step: "Build cuda.core wheel"
450+
422451
- name: List the cuda.core artifacts directory and rename
423452
run: |
424453
if [[ "${{ inputs.host-platform }}" == win* ]]; then

.github/workflows/coverage.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ jobs:
5050
image: ubuntu:22.04
5151
env:
5252
NVIDIA_VISIBLE_DEVICES: ${{ env.NVIDIA_VISIBLE_DEVICES }}
53+
PIP_CACHE_DIR: "/tmp/pip-cache"
5354
steps:
5455
- name: Ensure GPU is working
5556
run: nvidia-smi

.github/workflows/test-wheel-linux.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ jobs:
8585
image: ubuntu:22.04
8686
env:
8787
NVIDIA_VISIBLE_DEVICES: ${{ env.NVIDIA_VISIBLE_DEVICES }}
88+
PIP_CACHE_DIR: "/tmp/pip-cache"
8889
steps:
8990
- name: Ensure GPU is working
9091
run: nvidia-smi

0 commit comments

Comments
 (0)