From aabcd82874ac639eecd888d979c7170c6ad0d30e Mon Sep 17 00:00:00 2001 From: Piotr Galar Date: Sat, 12 Aug 2023 21:56:36 +0200 Subject: [PATCH 1/8] 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 6890d07..9ffe529 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/8] 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 b0a3f4e..25798cc 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 be90e10..3748ab5 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/8] 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 9ffe529..cba2c8c 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 3748ab5..d8ac3a1 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: From 801823434715e45aa48743a38182d33b33675d02 Mon Sep 17 00:00:00 2001 From: Artem Gavrilov Date: Fri, 25 Aug 2023 12:31:19 +0200 Subject: [PATCH 4/8] Improve documentation regarding dependencies cachin --- README.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6dafed1..52a5510 100644 --- a/README.md +++ b/README.md @@ -159,7 +159,7 @@ The `cache` input is optional, and caching is turned on by default. The action defaults to search for the dependency file - go.sum in the repository root, and uses its hash as a part of the cache key. Use `cache-dependency-path` input for cases when multiple dependency files are used, or they are located -in different subdirectories. +in different subdirectories. Wildcards also supported. If some problem that prevents success caching happens then the action issues the warning in the log and continues the execution of the pipeline. @@ -172,7 +172,11 @@ steps: with: go-version: '1.17' check-latest: true - cache-dependency-path: subdir/go.sum + cache-dependency-path: | + subdir/go.sum + tools/go.sum + # cache-dependency-path: "**/*.sum" + - run: go run hello.go ``` From 317c6617fa9e4e67f1e5e20ad8bc98bf298a0f8f Mon Sep 17 00:00:00 2001 From: Artem Gavrilov Date: Mon, 28 Aug 2023 12:47:43 +0200 Subject: [PATCH 5/8] Replace `wildcards` term with `globs`. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 52a5510..4500fe5 100644 --- a/README.md +++ b/README.md @@ -159,7 +159,7 @@ The `cache` input is optional, and caching is turned on by default. The action defaults to search for the dependency file - go.sum in the repository root, and uses its hash as a part of the cache key. Use `cache-dependency-path` input for cases when multiple dependency files are used, or they are located -in different subdirectories. Wildcards also supported. +in different subdirectories. Globs also supported. If some problem that prevents success caching happens then the action issues the warning in the log and continues the execution of the pipeline. From d45ebba0ce181dc5604aaf69ce5a0bdcbd3b1807 Mon Sep 17 00:00:00 2001 From: Artem Gavrilov Date: Tue, 29 Aug 2023 15:43:02 +0200 Subject: [PATCH 6/8] Rephrase sentence Co-authored-by: Ivan <98037481+IvanZosimov@users.noreply.github.com> --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4500fe5..525820a 100644 --- a/README.md +++ b/README.md @@ -159,7 +159,7 @@ The `cache` input is optional, and caching is turned on by default. The action defaults to search for the dependency file - go.sum in the repository root, and uses its hash as a part of the cache key. Use `cache-dependency-path` input for cases when multiple dependency files are used, or they are located -in different subdirectories. Globs also supported. +in different subdirectories. The input supports glob patterns. If some problem that prevents success caching happens then the action issues the warning in the log and continues the execution of the pipeline. From 8a505c9cf2e2726eda7f3268d6992e386a12da52 Mon Sep 17 00:00:00 2001 From: Rui Chen Date: Mon, 4 Sep 2023 14:19:48 -0400 Subject: [PATCH 7/8] feat: bump to use node20 runtime Signed-off-by: Rui Chen --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 12b47b6..9946e47 100644 --- a/action.yml +++ b/action.yml @@ -25,7 +25,7 @@ outputs: cache-hit: description: 'A boolean value to indicate if a cache was hit' runs: - using: 'node16' + using: 'node20' main: 'dist/setup/index.js' post: 'dist/cache-save/index.js' post-if: success() From 3d65fa57fcbfe4a359b6b71a6c65e6eec12984eb Mon Sep 17 00:00:00 2001 From: Rui Chen Date: Tue, 5 Sep 2023 11:42:39 -0400 Subject: [PATCH 8/8] feat: bump to use actions/checkout@v4 Signed-off-by: Rui Chen --- .github/workflows/versions.yml | 20 +++++++-------- .github/workflows/windows-validation.yml | 8 +++--- README.md | 32 ++++++++++++------------ docs/adrs/0000-caching-dependencies.md | 12 ++++----- 4 files changed, 36 insertions(+), 36 deletions(-) diff --git a/.github/workflows/versions.yml b/.github/workflows/versions.yml index 89fc7b8..ef31ef5 100644 --- a/.github/workflows/versions.yml +++ b/.github/workflows/versions.yml @@ -20,7 +20,7 @@ jobs: matrix: os: [ubuntu-latest, windows-latest, macos-latest] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Setup Go Stable uses: ./ with: @@ -35,7 +35,7 @@ jobs: matrix: os: [ubuntu-latest, windows-latest, macos-latest] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Setup Go oldStable uses: ./ with: @@ -55,7 +55,7 @@ jobs: - os: macos-latest architecture: x32 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Setup Go ${{ matrix.version }} ${{ matrix.architecture }} uses: ./ with: @@ -74,7 +74,7 @@ jobs: go: [1.17, 1.18, 1.19] steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: setup-go ${{ matrix.go }} uses: ./ @@ -93,7 +93,7 @@ jobs: os: [ubuntu-latest, windows-latest, macos-latest] go-version: [1.16, 1.17] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Setup Go and check latest uses: ./ with: @@ -109,7 +109,7 @@ jobs: matrix: os: [ubuntu-latest, windows-latest, macos-latest] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Setup Go and check latest uses: ./ with: @@ -125,7 +125,7 @@ jobs: matrix: os: [ubuntu-latest, windows-latest, macos-latest] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Setup Go and check latest uses: ./ with: @@ -144,7 +144,7 @@ jobs: go: [1.12.16, 1.13.11, 1.14.3] steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: setup-go ${{ matrix.go }} uses: ./ @@ -165,7 +165,7 @@ jobs: go: [1.9, 1.8.6] steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: setup-go ${{ matrix.go }} uses: ./ @@ -184,7 +184,7 @@ jobs: os: [ubuntu-latest, windows-latest, macos-latest] go-version: [1.16, 1.17] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Setup Go and check latest uses: ./ with: diff --git a/.github/workflows/windows-validation.yml b/.github/workflows/windows-validation.yml index cba2c8c..ed05b0d 100644 --- a/.github/workflows/windows-validation.yml +++ b/.github/workflows/windows-validation.yml @@ -19,7 +19,7 @@ jobs: cache: [false, true] go: [1.20.1] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: 'Setup ${{ matrix.cache }}, cache: ${{ matrix.go }}' uses: ./ @@ -61,7 +61,7 @@ jobs: echo 'which go should return "/c/hostedtoolcache/windows/go/${{ matrix.go }}/x64/bin/go"' exit 1 fi - if [ $(go env GOROOT) != 'C:\hostedtoolcache\windows\go\${{ matrix.go }}\x64' ];then + if [ $(go env GOROOT) != 'C:\hostedtoolcache\windows\go\${{ matrix.go }}\x64' ];then echo 'go env GOROOT should return "C:\hostedtoolcache\windows\go\${{ matrix.go }}\x64"' exit 1 fi @@ -88,7 +88,7 @@ jobs: matrix: cache: [false, true] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: 'Setup default go, cache: ${{ matrix.cache }}' uses: ./ @@ -121,7 +121,7 @@ jobs: cache: [false] go: [1.20.1] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: 'Setup ${{ matrix.go }}, cache: ${{ matrix.cache }}' uses: ./ diff --git a/README.md b/README.md index 525820a..74cd6ee 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ Matching by [semver spec](https://github.com/npm/node-semver): ```yaml steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: actions/setup-go@v4 with: go-version: '^1.13.1' # The Go version to download (if necessary) and use. @@ -51,7 +51,7 @@ steps: ```yaml steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: actions/setup-go@v4 with: go-version: '>=1.17.0' @@ -59,17 +59,17 @@ steps: ``` > **Note**: Due to the peculiarities of YAML parsing, it is recommended to wrap the version in single quotation marks: -> +> > ```yaml > go-version: '1.20' > ``` -> +> > The recommendation is based on the YAML parser's behavior, which interprets non-wrapped values as numbers and, in the case of version 1.20, trims it down to 1.2, which may not be very obvious. Matching an unstable pre-release: ```yaml steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: actions/setup-go@v4 with: go-version: '1.18.0-rc.1' # The Go version to download (if necessary) and use. @@ -78,7 +78,7 @@ steps: ```yaml steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: actions/setup-go@v4 with: go-version: '1.16.0-beta.1' # The Go version to download (if necessary) and use. @@ -93,7 +93,7 @@ See [action.yml](action.yml) ```yaml steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: actions/setup-go@v4 with: go-version: '1.16.1' # The Go version to download (if necessary) and use. @@ -114,7 +114,7 @@ want the most up-to-date Go version to always be used. ```yaml steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: actions/setup-go@v4 with: go-version: '1.14' @@ -135,7 +135,7 @@ set to `true` ```yaml steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: actions/setup-go@v4 with: go-version: 'stable' @@ -144,7 +144,7 @@ steps: ```yaml steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: actions/setup-go@v4 with: go-version: 'oldstable' @@ -161,20 +161,20 @@ The action defaults to search for the dependency file - go.sum in the repository the cache key. Use `cache-dependency-path` input for cases when multiple dependency files are used, or they are located in different subdirectories. The input supports glob patterns. -If some problem that prevents success caching happens then the action issues the warning in the log and continues the execution of the pipeline. +If some problem that prevents success caching happens then the action issues the warning in the log and continues the execution of the pipeline. **Caching in monorepos** ```yaml steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: actions/setup-go@v4 with: go-version: '1.17' check-latest: true cache-dependency-path: | - subdir/go.sum - tools/go.sum + subdir/go.sum + tools/go.sum # cache-dependency-path: "**/*.sum" - run: go run hello.go @@ -193,7 +193,7 @@ If both the `go-version` and the `go-version-file` inputs are provided then the ```yaml steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: actions/setup-go@v4 with: go-version-file: 'path/to/go.mod' @@ -211,7 +211,7 @@ jobs: go: [ '1.14', '1.13' ] name: Go ${{ matrix.go }} sample steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Setup go uses: actions/setup-go@v4 with: diff --git a/docs/adrs/0000-caching-dependencies.md b/docs/adrs/0000-caching-dependencies.md index dc8d858..3f80d61 100644 --- a/docs/adrs/0000-caching-dependencies.md +++ b/docs/adrs/0000-caching-dependencies.md @@ -4,7 +4,7 @@ Date: 2022-04-13 Status: Accepted # Context -`actions/setup-go` is the one of the most popular action related to Golang in GitHub Actions. Many customers use it in conjunction with [actions/cache](https://github.com/actions/cache) to speed up dependency installation process. +`actions/setup-go` is the one of the most popular action related to Golang in GitHub Actions. Many customers use it in conjunction with [actions/cache](https://github.com/actions/cache) to speed up dependency installation process. See more examples on proper usage in [actions/cache documentation](https://github.com/actions/cache/blob/main/examples.md#go---modules). # Goals & Anti-Goals @@ -16,7 +16,7 @@ Integration of caching functionality into `actions/setup-go` action will bring t We don't pursue the goal to provide wide customization of caching in scope of `actions/setup-go` action. The purpose of this integration is covering ~90% of basic use-cases. If user needs flexible customization, we should advice them to use `actions/cache` directly. # Decision -- Add `cache` input parameter to `actions/setup-go`. For now, input will accept the following values: +- Add `cache` input parameter to `actions/setup-go`. For now, input will accept the following values: - `true` - enable caching for go dependencies - `false`- disable caching for go dependencies. This value will be set as default value - Cache feature will be disabled by default to make sure that we don't break existing customers. We will consider enabling cache by default in next major releases @@ -32,7 +32,7 @@ We don't pursue the goal to provide wide customization of caching in scope of `a ```yml steps: -- uses: actions/checkout@v3 +- uses: actions/checkout@v4 - uses: actions/setup-go@v3 with: go-version: '18' @@ -43,7 +43,7 @@ steps: ```yml steps: -- uses: actions/checkout@v3 +- uses: actions/checkout@v4 - uses: actions/setup-go@v3 with: go-version: '18' @@ -53,7 +53,7 @@ steps: ```yml steps: -- uses: actions/checkout@v3 +- uses: actions/checkout@v4 - uses: actions/setup-go@v3 with: go-version: '18' @@ -66,4 +66,4 @@ steps: # Release process As soon as functionality is implemented, we will release minor update of action. No need to bump major version since there are no breaking changes for existing users. -After that, we will update [starter-workflows](https://github.com/actions/starter-workflows/blob/main/ci/go.yml) \ No newline at end of file +After that, we will update [starter-workflows](https://github.com/actions/starter-workflows/blob/main/ci/go.yml)