Skip to content

Commit d085b4f

Browse files
Merge pull request #411 from galargh/fix/windows-hostedtoolcache
Fix hosted tool cache usage on windows
2 parents 93397be + 48ac8fd commit d085b4f

File tree

3 files changed

+38
-1
lines changed

3 files changed

+38
-1
lines changed

.github/workflows/windows-validation.yml

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,32 @@ jobs:
105105
fi
106106
shell: bash
107107

108-
- name: 'Drive D: should not have Go installation, cache: ${{ matrix.cache}}'
108+
- name: 'Drive D: should not have Go installation, cache: ${{ matrix.cache }}'
109109
run: |
110110
if [ -e 'D:\hostedtoolcache\windows\go\${{ needs.find-default-go.outputs.version }}\x64' ];then
111111
echo 'D:\hostedtoolcache\windows\go\${{ needs.find-default-go.outputs.version }}\x64 should not exist for hosted version of go';
112112
exit 1
113113
fi
114114
shell: bash
115+
116+
hostedtoolcache:
117+
name: 'Validate if hostedtoolcache works as expected'
118+
runs-on: windows-latest
119+
strategy:
120+
matrix:
121+
cache: [false]
122+
go: [1.20.1]
123+
steps:
124+
- uses: actions/checkout@v3
125+
126+
- name: 'Setup ${{ matrix.go }}, cache: ${{ matrix.cache }}'
127+
uses: ./
128+
with:
129+
go-version: ${{ matrix.go }}
130+
cache: ${{ matrix.cache }}
131+
132+
- name: 'Setup ${{ matrix.go }}, cache: ${{ matrix.cache }} (from hostedtoolcache)'
133+
uses: ./
134+
with:
135+
go-version: ${{ matrix.go }}
136+
cache: ${{ matrix.cache }}

dist/setup/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61514,6 +61514,10 @@ function cacheWindowsDir(extPath, tool, version, arch) {
6151461514
fs_1.default.mkdirSync(path.dirname(defaultToolCacheDir), { recursive: true });
6151561515
fs_1.default.symlinkSync(actualToolCacheDir, defaultToolCacheDir, 'junction');
6151661516
core.info(`Created link ${defaultToolCacheDir} => ${actualToolCacheDir}`);
61517+
const actualToolCacheCompleteFile = `${actualToolCacheDir}.complete`;
61518+
const defaultToolCacheCompleteFile = `${defaultToolCacheDir}.complete`;
61519+
fs_1.default.symlinkSync(actualToolCacheCompleteFile, defaultToolCacheCompleteFile, 'file');
61520+
core.info(`Created link ${defaultToolCacheCompleteFile} => ${actualToolCacheCompleteFile}`);
6151761521
// make outer code to continue using toolcache as if it were installed on c:
6151861522
// restore toolcache root to default drive c:
6151961523
process.env['RUNNER_TOOL_CACHE'] = defaultToolCacheRoot;

src/installer.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,17 @@ async function cacheWindowsDir(
203203
fs.symlinkSync(actualToolCacheDir, defaultToolCacheDir, 'junction');
204204
core.info(`Created link ${defaultToolCacheDir} => ${actualToolCacheDir}`);
205205

206+
const actualToolCacheCompleteFile = `${actualToolCacheDir}.complete`;
207+
const defaultToolCacheCompleteFile = `${defaultToolCacheDir}.complete`;
208+
fs.symlinkSync(
209+
actualToolCacheCompleteFile,
210+
defaultToolCacheCompleteFile,
211+
'file'
212+
);
213+
core.info(
214+
`Created link ${defaultToolCacheCompleteFile} => ${actualToolCacheCompleteFile}`
215+
);
216+
206217
// make outer code to continue using toolcache as if it were installed on c:
207218
// restore toolcache root to default drive c:
208219
process.env['RUNNER_TOOL_CACHE'] = defaultToolCacheRoot;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy