@@ -19,6 +19,14 @@ inputs:
1919 description : " where the CTK components will be installed to, relative to $PWD"
2020 required : false
2121 default : " ./cuda_toolkit"
22+ install-mode :
23+ description : >
24+ "replace" (default) empties cuda-path before installing.
25+ "add" installs the components on top of the mini CTK that an earlier
26+ fetch_ctk call installed at the same cuda-path, and leaves the
27+ environment that call exported unchanged.
28+ required : false
29+ default : " replace"
2230 redist-base-url :
2331 description : >
2432 Base URL of a redistrib server (manifest and component archives).
4351 with :
4452 dependent_exes : " curl unzip tar sha256sum cygpath"
4553
54+ - name : Check install mode
55+ shell : bash --noprofile --norc -xeuo pipefail {0}
56+ run : |
57+ case "${{ inputs.install-mode }}" in
58+ replace)
59+ ;;
60+ add)
61+ # The environment exports are skipped in this mode, so the target
62+ # must be the CUDA_PATH an earlier fetch_ctk call exported.
63+ if [[ -z "${CUDA_PATH:-}" ]]; then
64+ echo "::error::install-mode 'add' requires CUDA_PATH from an earlier fetch_ctk call"
65+ exit 1
66+ fi
67+ EXISTING_PATH="$CUDA_PATH"
68+ if [[ "${{ inputs.host-platform }}" == win* ]]; then
69+ EXISTING_PATH="$(cygpath -u "$EXISTING_PATH")"
70+ fi
71+ if [[ "$(realpath -e "${{ inputs.cuda-path }}")" != "$(realpath -e "$EXISTING_PATH")" ]]; then
72+ echo "::error::install-mode 'add' requires cuda-path to be the existing CUDA_PATH ($CUDA_PATH)"
73+ exit 1
74+ fi
75+ ;;
76+ *)
77+ echo "::error::install-mode must be 'replace' or 'add', got '${{ inputs.install-mode }}'"
78+ exit 1
79+ ;;
80+ esac
81+
4682 - name : Set up CTK cache variable
4783 shell : bash --noprofile --norc -xeuo pipefail {0}
4884 run : |
92128
93129 - name : Download CTK cache
94130 id : ctk-get-cache
95- uses : actions/cache/restore@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4
131+ uses : actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
96132 continue-on-error : true
97133 with :
98134 key : ${{ env.CTK_CACHE_KEY }}
@@ -170,7 +206,9 @@ runs:
170206 # symlinks from a prerelease CTK at ./cuda_toolkit/include etc., causing
171207 # "cp: cannot overwrite non-directory" failures on the next restore).
172208 CUDA_PATH="${{ inputs.cuda-path }}"
173- rm -rf $CUDA_PATH
209+ if [[ "${{ inputs.install-mode }}" == replace ]]; then
210+ rm -rf $CUDA_PATH
211+ fi
174212 mkdir -p $CUDA_PATH
175213 # Unfortunately we cannot use "rsync -av $CACHE_TMP_DIR/ $CUDA_PATH" because
176214 # not all runners have rsync pre-installed (or even installable, such as
@@ -182,7 +220,7 @@ runs:
182220 - name : Upload CTK cache
183221 if : ${{ !cancelled() &&
184222 steps.ctk-get-cache.outputs.cache-hit != 'true' }}
185- uses : actions/cache/save@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4
223+ uses : actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
186224 with :
187225 key : ${{ env.CTK_CACHE_KEY }}
188226 path : ./${{ env.CTK_CACHE_FILENAME }}
@@ -194,7 +232,9 @@ runs:
194232 ls -l
195233 CACHE_TMP_DIR="./cache_tmp_dir"
196234 CUDA_PATH="${{ inputs.cuda-path }}"
197- rm -rf $CUDA_PATH
235+ if [[ "${{ inputs.install-mode }}" == replace ]]; then
236+ rm -rf $CUDA_PATH
237+ fi
198238 mkdir -p $CUDA_PATH
199239 tar -xzvf $CTK_CACHE_FILENAME
200240 # Can't use rsync here, see above
@@ -203,6 +243,7 @@ runs:
203243 ls -l $CUDA_PATH
204244
205245 - name : Set output environment variables
246+ if : ${{ inputs.install-mode == 'replace' }}
206247 shell : bash --noprofile --norc -xeuo pipefail {0}
207248 run : |
208249 # mimics actual CTK installation
0 commit comments