Skip to content

Commit aa4689f

Browse files
committed
ci: key fetch_ctk cache on the full manifest hash; keep Git Bash first on PATH
- fetch_ctk: use the full SHA-256 of the manifest in the cache key and filename instead of 8 hex digits, so an alternate server cannot share a key with the public server by colliding a truncated hash. - install_windows_deps: when the validated Git Bash is not the first bash on PATH (for example the WSL launcher comes first), prepend its directory to PATH and GITHUB_PATH so later 'shell: bash' steps use Git Bash.
1 parent af01a00 commit aa4689f

2 files changed

Lines changed: 14 additions & 5 deletions

File tree

‎.github/actions/fetch_ctk/action.yml‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,15 @@ runs:
7676
--metadata-path "$CTK_JSON_FILE")"
7777
7878
# Alternate redist servers (non-default) publish different manifests for the
79-
# same CUDA version; keying on the manifest hash keeps them from restoring
80-
# each other's toolkit.
79+
# same CUDA version; keying on the full manifest hash keeps them from restoring
80+
# each other's toolkit (a truncated hash could be collided on purpose).
8181
# Hash via stdin: with a backslash in the path (Windows RUNNER_TEMP), sha256sum
8282
# prefixes its output line with "\", which would end up in the cache key.
83-
MANIFEST_SHA8="$(sha256sum < "$CTK_JSON_FILE" | cut -c1-8)"
83+
MANIFEST_SHA256="$(sha256sum < "$CTK_JSON_FILE" | awk '{print $1}')"
8484
HASH=$(echo -n "${CTK_CACHE_COMPONENTS}" | sha256sum | awk '{print $1}')
8585
{
86-
echo "CTK_CACHE_KEY=mini-ctk-${{ inputs.cuda-version }}-${{ inputs.host-platform }}-$HASH-m$MANIFEST_SHA8"
87-
echo "CTK_CACHE_FILENAME=mini-ctk-${{ inputs.cuda-version }}-${{ inputs.host-platform }}-$HASH-m$MANIFEST_SHA8.tar.gz"
86+
echo "CTK_CACHE_KEY=mini-ctk-${{ inputs.cuda-version }}-${{ inputs.host-platform }}-$HASH-m$MANIFEST_SHA256"
87+
echo "CTK_CACHE_FILENAME=mini-ctk-${{ inputs.cuda-version }}-${{ inputs.host-platform }}-$HASH-m$MANIFEST_SHA256.tar.gz"
8888
echo "CTK_CACHE_COMPONENTS=${CTK_CACHE_COMPONENTS}"
8989
echo "CTK_BASE_URL=${CTK_BASE_URL}"
9090
echo "CTK_JSON_FILE=${CTK_JSON_FILE}"

‎.github/actions/install_windows_deps/action.yml‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,15 @@ runs:
3131
if ($bash) {
3232
& $bash.Source --noprofile --norc -c $check
3333
if ($LASTEXITCODE -eq 0) {
34+
# Later `shell: bash` steps resolve `bash` through PATH. If that is not the
35+
# Git Bash validated above (e.g. the WSL launcher comes first), put it first.
36+
$pathBash = Get-Command bash -ErrorAction SilentlyContinue
37+
if ($pathBash -and ($pathBash.Source -ne $bash.Source)) {
38+
$bashDir = Split-Path -Parent $bash.Source
39+
$env:PATH = "$bashDir;$env:PATH"
40+
$bashDir | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
41+
Write-Host "Prepended $bashDir to PATH so steps use Git Bash instead of $($pathBash.Source)."
42+
}
3443
Write-Host 'All dependencies are found. Do nothing.'
3544
exit 0
3645
}

0 commit comments

Comments
 (0)