From aabcd82874ac639eecd888d979c7170c6ad0d30e Mon Sep 17 00:00:00 2001 From: Piotr Galar Date: Sat, 12 Aug 2023 21:56:36 +0200 Subject: [PATCH 1/3] ci: add hostedtoolcache validation on windows --- .github/workflows/windows-validation.yml | 27 +++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/.github/workflows/windows-validation.yml b/.github/workflows/windows-validation.yml index 6890d07bc..9ffe5290c 100644 --- a/.github/workflows/windows-validation.yml +++ b/.github/workflows/windows-validation.yml @@ -105,10 +105,35 @@ jobs: fi shell: bash - - name: 'Drive D: should not have Go installation, cache: ${{ matrix.cache}}' + - name: 'Drive D: should not have Go installation, cache: ${{ matrix.cache }}' run: | if [ -e 'D:\hostedtoolcache\windows\go\${{ needs.find-default-go.outputs.version }}\x64' ];then echo 'D:\hostedtoolcache\windows\go\${{ needs.find-default-go.outputs.version }}\x64 should not exist for hosted version of go'; exit 1 fi shell: bash + + hostedtoolcache: + name: 'Validate if hostedtoolcache works as expected' + runs-on: windows-latest + strategy: + matrix: + cache: [false] + go: [1.20.1] + steps: + - uses: actions/checkout@v3 + + - name: 'Setup ${{ matrix.go }}, cache: ${{ matrix.cache }}' + uses: ./ + with: + go-version: ${{ matrix.go }} + cache: ${{ matrix.cache }} + + - name: 'Setup ${{ matrix.go }}, cache: ${{ matrix.cache }} (from hostedtoolcache)' + uses: ./ + with: + go-version: ${{ matrix.go }} + cache: ${{ matrix.cache }} + + + From 89a192af9d2921a36f6fc6e84b77c182e682c574 Mon Sep 17 00:00:00 2001 From: Piotr Galar Date: Sat, 12 Aug 2023 23:31:51 +0200 Subject: [PATCH 2/3] fix: sync .complete marker when caching tools on windows --- dist/setup/index.js | 4 ++++ src/installer.ts | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/dist/setup/index.js b/dist/setup/index.js index b0a3f4e6b..25798ccb6 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -61514,6 +61514,10 @@ function cacheWindowsDir(extPath, tool, version, arch) { fs_1.default.mkdirSync(path.dirname(defaultToolCacheDir), { recursive: true }); fs_1.default.symlinkSync(actualToolCacheDir, defaultToolCacheDir, 'junction'); core.info(`Created link ${defaultToolCacheDir} => ${actualToolCacheDir}`); + const actualToolCacheCompleteFile = `${actualToolCacheDir}.complete`; + const defaultToolCacheCompleteFile = `${defaultToolCacheDir}.complete`; + fs_1.default.symlinkSync(actualToolCacheCompleteFile, defaultToolCacheCompleteFile, 'file'); + core.info(`Created link ${defaultToolCacheCompleteFile} => ${actualToolCacheCompleteFile}`); // make outer code to continue using toolcache as if it were installed on c: // restore toolcache root to default drive c: process.env['RUNNER_TOOL_CACHE'] = defaultToolCacheRoot; diff --git a/src/installer.ts b/src/installer.ts index be90e101a..3748ab545 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -203,6 +203,11 @@ async function cacheWindowsDir( fs.symlinkSync(actualToolCacheDir, defaultToolCacheDir, 'junction'); core.info(`Created link ${defaultToolCacheDir} => ${actualToolCacheDir}`); + const actualToolCacheCompleteFile = `${actualToolCacheDir}.complete`; + const defaultToolCacheCompleteFile = `${defaultToolCacheDir}.complete`; + fs.symlinkSync(actualToolCacheCompleteFile, defaultToolCacheCompleteFile, 'file'); + core.info(`Created link ${defaultToolCacheCompleteFile} => ${actualToolCacheCompleteFile}`); + // make outer code to continue using toolcache as if it were installed on c: // restore toolcache root to default drive c: process.env['RUNNER_TOOL_CACHE'] = defaultToolCacheRoot; From 48ac8fd236c79c21571daf4d4cbab6e189121007 Mon Sep 17 00:00:00 2001 From: galargh Date: Sat, 12 Aug 2023 23:57:09 +0200 Subject: [PATCH 3/3] chore: format --- .github/workflows/windows-validation.yml | 7 ++----- src/installer.ts | 10 ++++++++-- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/.github/workflows/windows-validation.yml b/.github/workflows/windows-validation.yml index 9ffe5290c..cba2c8c4e 100644 --- a/.github/workflows/windows-validation.yml +++ b/.github/workflows/windows-validation.yml @@ -114,7 +114,7 @@ jobs: shell: bash hostedtoolcache: - name: 'Validate if hostedtoolcache works as expected' + name: 'Validate if hostedtoolcache works as expected' runs-on: windows-latest strategy: matrix: @@ -128,12 +128,9 @@ jobs: with: go-version: ${{ matrix.go }} cache: ${{ matrix.cache }} - + - name: 'Setup ${{ matrix.go }}, cache: ${{ matrix.cache }} (from hostedtoolcache)' uses: ./ with: go-version: ${{ matrix.go }} cache: ${{ matrix.cache }} - - - diff --git a/src/installer.ts b/src/installer.ts index 3748ab545..d8ac3a125 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -205,8 +205,14 @@ async function cacheWindowsDir( const actualToolCacheCompleteFile = `${actualToolCacheDir}.complete`; const defaultToolCacheCompleteFile = `${defaultToolCacheDir}.complete`; - fs.symlinkSync(actualToolCacheCompleteFile, defaultToolCacheCompleteFile, 'file'); - core.info(`Created link ${defaultToolCacheCompleteFile} => ${actualToolCacheCompleteFile}`); + fs.symlinkSync( + actualToolCacheCompleteFile, + defaultToolCacheCompleteFile, + 'file' + ); + core.info( + `Created link ${defaultToolCacheCompleteFile} => ${actualToolCacheCompleteFile}` + ); // make outer code to continue using toolcache as if it were installed on c: // restore toolcache root to default drive c: