Compare commits

...

3 Commits

Author SHA1 Message Date
Priya Gupta
a5f9b05d2d Update default Go module caching to use go.mod (#705)
* Update module cache to use go.mod as key

* Fix typo

* Revise breaking changes in README for V6

Updated breaking changes section with enhanced formatting and clarified toolchain management details.
2026-01-26 10:59:03 -06:00
dependabot[bot]
7a3fe6cf4c Bump qs from 6.14.0 to 6.14.1 (#703)
* Bump qs from 6.11.2 to 6.14.1

Bumps [qs](https://github.com/ljharb/qs) from 6.11.2 to 6.14.1.
- [Changelog](https://github.com/ljharb/qs/blob/main/CHANGELOG.md)
- [Commits](https://github.com/ljharb/qs/compare/v6.11.2...v6.14.1)

---
updated-dependencies:
- dependency-name: qs
  dependency-version: 6.14.1
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

* package.json version update

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Aparna Jyothi <aparnajyothi-y@github.com>
2026-01-12 20:41:32 -06:00
dependabot[bot]
b9adafd441 Bump actions/checkout from 5 to 6 (#686)
Bumps [actions/checkout](https://github.com/actions/checkout) from 5 to 6.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v5...v6)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: '6'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-01-12 20:37:59 -06:00
13 changed files with 99 additions and 102 deletions

View File

@@ -14,7 +14,7 @@ jobs:
steps: steps:
- name: Checking out - name: Checking out
uses: actions/checkout@v5 uses: actions/checkout@v6
- name: Publish - name: Publish
id: publish id: publish
uses: actions/publish-immutable-action@v0.0.4 uses: actions/publish-immutable-action@v0.0.4

View File

@@ -20,7 +20,7 @@ jobs:
matrix: matrix:
os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large] os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large]
steps: steps:
- uses: actions/checkout@v5 - uses: actions/checkout@v6
- name: Setup Go Stable - name: Setup Go Stable
uses: ./ uses: ./
with: with:
@@ -35,7 +35,7 @@ jobs:
matrix: matrix:
os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large] os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large]
steps: steps:
- uses: actions/checkout@v5 - uses: actions/checkout@v6
- name: Setup Go oldStable - name: Setup Go oldStable
uses: ./ uses: ./
with: with:
@@ -57,7 +57,7 @@ jobs:
- os: macos-latest-large - os: macos-latest-large
architecture: x32 architecture: x32
steps: steps:
- uses: actions/checkout@v5 - uses: actions/checkout@v6
- name: Setup Go ${{ matrix.version }} ${{ matrix.architecture }} - name: Setup Go ${{ matrix.version }} ${{ matrix.architecture }}
uses: ./ uses: ./
with: with:
@@ -82,7 +82,7 @@ jobs:
go: 1.23.2 go: 1.23.2
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v5 uses: actions/checkout@v6
- name: setup-go ${{ matrix.go }} - name: setup-go ${{ matrix.go }}
uses: ./ uses: ./
@@ -101,7 +101,7 @@ jobs:
os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large] os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large]
go-version: ['1.20', '1.21', '1.22', '1.23'] go-version: ['1.20', '1.21', '1.22', '1.23']
steps: steps:
- uses: actions/checkout@v5 - uses: actions/checkout@v6
- name: Setup Go and check latest - name: Setup Go and check latest
uses: ./ uses: ./
with: with:
@@ -117,7 +117,7 @@ jobs:
matrix: matrix:
os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large] os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large]
steps: steps:
- uses: actions/checkout@v5 - uses: actions/checkout@v6
- name: Setup Go and check latest - name: Setup Go and check latest
uses: ./ uses: ./
with: with:
@@ -133,7 +133,7 @@ jobs:
matrix: matrix:
os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large] os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large]
steps: steps:
- uses: actions/checkout@v5 - uses: actions/checkout@v6
- name: Setup Go and check latest - name: Setup Go and check latest
uses: ./ uses: ./
with: with:
@@ -149,7 +149,7 @@ jobs:
matrix: matrix:
os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large] os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large]
steps: steps:
- uses: actions/checkout@v5 - uses: actions/checkout@v6
- name: Setup Go and check latest - name: Setup Go and check latest
uses: ./ uses: ./
with: with:
@@ -165,7 +165,7 @@ jobs:
matrix: matrix:
os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large] os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large]
steps: steps:
- uses: actions/checkout@v5 - uses: actions/checkout@v6
- name: Setup Go from .go-version file - name: Setup Go from .go-version file
uses: ./ uses: ./
with: with:
@@ -183,7 +183,7 @@ jobs:
go: [1.20.14, 1.21.10, 1.22.8, 1.23.2] go: [1.20.14, 1.21.10, 1.22.8, 1.23.2]
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v5 uses: actions/checkout@v6
- name: setup-go ${{ matrix.go }} - name: setup-go ${{ matrix.go }}
uses: ./ uses: ./
@@ -203,7 +203,7 @@ jobs:
go: [1.11.12] go: [1.11.12]
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v5 uses: actions/checkout@v6
- name: setup-go ${{ matrix.go }} - name: setup-go ${{ matrix.go }}
uses: ./ uses: ./
@@ -231,7 +231,7 @@ jobs:
- os: macos-latest-large - os: macos-latest-large
architecture: x64 architecture: x64
steps: steps:
- uses: actions/checkout@v5 - uses: actions/checkout@v6
- name: Setup Go and check latest - name: Setup Go and check latest
uses: ./ uses: ./
with: with:

View File

@@ -19,7 +19,7 @@ jobs:
cache: [false, true] cache: [false, true]
go: [1.20.1] go: [1.20.1]
steps: steps:
- uses: actions/checkout@v5 - uses: actions/checkout@v6
- name: 'Setup ${{ matrix.cache }}, cache: ${{ matrix.go }}' - name: 'Setup ${{ matrix.cache }}, cache: ${{ matrix.go }}'
uses: ./ uses: ./
@@ -88,7 +88,7 @@ jobs:
matrix: matrix:
cache: [false, true] cache: [false, true]
steps: steps:
- uses: actions/checkout@v5 - uses: actions/checkout@v6
- name: 'Setup default go, cache: ${{ matrix.cache }}' - name: 'Setup default go, cache: ${{ matrix.cache }}'
uses: ./ uses: ./
@@ -121,7 +121,7 @@ jobs:
cache: [false] cache: [false]
go: [1.20.1] go: [1.20.1]
steps: steps:
- uses: actions/checkout@v5 - uses: actions/checkout@v6
- name: 'Setup ${{ matrix.go }}, cache: ${{ matrix.cache }}' - name: 'Setup ${{ matrix.go }}, cache: ${{ matrix.cache }}'
uses: ./ uses: ./

View File

@@ -24,24 +24,18 @@ steps:
### V6 Changes ### V6 Changes
#### Node Runtime Upgrade **Node Runtime Upgrade**
- **Upgraded from Node 20 to Node 24** - **Upgraded from Node 20 to Node 24**
- ⚠️ **Action Required**: Ensure your runner is on version v2.327.1 or later for compatibility - ⚠️ **Action Required**: Ensure your runner is on version v2.327.1 or later for compatibility
- See [Release Notes](https://github.com/actions/runner/releases/tag/v2.327.1) for more details - See [Release Notes](https://github.com/actions/runner/releases/tag/v2.327.1) for more details
#### Enhanced Go Toolchain Management **Enhanced Go Toolchain Management**
V6 introduces significant improvements for reliable and consistent Go version selection: V6 introduces significant improvements for reliable and consistent Go version selection. Supports both `go` and `toolchain` directives in `go.mod`. If the `toolchain` directive is present, its version is used; otherwise, the action falls back to the go directive.
**Toolchain Directive Support** **Cache Key Update**
Now correctly interprets both `go` and `toolchain` directives from `go.mod`:
```go
go 1.23.0 // Minimum required version
toolchain go1.23.2 // V6 uses this exact version
```
**Intelligent Caching** By default, caching for Go modules now relies on `go.mod`. To use `go.sum`, configure the `cache-dependency-path` input.
Cache keys now incorporate the `toolchain` directive version from `go.mod`, eliminating cache conflicts when switching between different toolchain versions within the same Go minor release.
For more details, see the [full release notes](https://github.com/actions/setup-go/releases/tag/v6.0.0). For more details, see the [full release notes](https://github.com/actions/setup-go/releases/tag/v6.0.0).
@@ -257,7 +251,7 @@ The action features integrated caching for Go modules and build outputs. Built o
#### Automatic Caching #### Automatic Caching
Default behavior: Searches for `go.sum` in the repository root and uses its hash for the cache key. Default behavior: Searches for `go.mod` in the repository root and uses its hash for the cache key.
```yaml ```yaml
steps: steps:
@@ -368,7 +362,7 @@ jobs:
path: | path: |
${{ env.GO_MOD_CACHE }} ${{ env.GO_MOD_CACHE }}
${{ env.GO_BUILD_CACHE }} ${{ env.GO_BUILD_CACHE }}
key: setup-go-${{ runner.os }}-${{ env.ARCH }}-${{ env.CACHE_OS_SUFFIX }}go-${{ steps.setup-go.outputs.go-version }}-${{ hashFiles('**/go.sum') }} key: setup-go-${{ runner.os }}-${{ env.ARCH }}-${{ env.CACHE_OS_SUFFIX }}go-${{ steps.setup-go.outputs.go-version }}-${{ hashFiles('**/go.mod') }}
- name: Download modules - name: Download modules
run: go mod download run: go mod download
- name: Build - name: Build

View File

@@ -1,94 +1,83 @@
import * as cache from '@actions/cache'; import * as cache from '@actions/cache';
import * as core from '@actions/core'; import * as core from '@actions/core';
import * as glob from '@actions/glob'; import * as glob from '@actions/glob';
import fs from 'fs';
import * as cacheRestore from '../src/cache-restore'; import * as cacheRestore from '../src/cache-restore';
import * as cacheUtils from '../src/cache-utils'; import * as cacheUtils from '../src/cache-utils';
import {PackageManagerInfo} from '../src/package-managers'; import {PackageManagerInfo} from '../src/package-managers';
describe('restoreCache', () => { describe('restoreCache', () => {
//Arrange let hashFilesSpy: jest.SpyInstance;
const hashFilesSpy = jest.spyOn(glob, 'hashFiles'); let getCacheDirectoryPathSpy: jest.SpyInstance;
const getCacheDirectoryPathSpy = jest.spyOn( let restoreCacheSpy: jest.SpyInstance;
cacheUtils, let infoSpy: jest.SpyInstance;
'getCacheDirectoryPath' let setOutputSpy: jest.SpyInstance;
);
const restoreCacheSpy = jest.spyOn(cache, 'restoreCache');
const infoSpy = jest.spyOn(core, 'info');
const setOutputSpy = jest.spyOn(core, 'setOutput');
const versionSpec = '1.13.1'; const versionSpec = '1.13.1';
const packageManager = 'default'; const packageManager = 'default';
const cacheDependencyPath = 'path'; const cacheDependencyPath = 'path';
let originalWorkspace: string | undefined;
beforeEach(() => { beforeEach(() => {
originalWorkspace = process.env.GITHUB_WORKSPACE;
process.env.GITHUB_WORKSPACE = '/test/workspace';
//Arrange
hashFilesSpy = jest.spyOn(glob, 'hashFiles');
getCacheDirectoryPathSpy = jest.spyOn(cacheUtils, 'getCacheDirectoryPath');
restoreCacheSpy = jest.spyOn(cache, 'restoreCache');
infoSpy = jest.spyOn(core, 'info');
setOutputSpy = jest.spyOn(core, 'setOutput');
getCacheDirectoryPathSpy.mockImplementation( getCacheDirectoryPathSpy.mockImplementation(
(PackageManager: PackageManagerInfo) => { (PackageManager: PackageManagerInfo) => {
return new Promise<string[]>(resolve => { return Promise.resolve([
resolve(['cache_directory_path', 'cache_directory_path']); 'cache_directory_path',
}); 'cache_directory_path'
]);
} }
); );
}); });
it('should throw if dependency file path is not valid', async () => { afterEach(() => {
//Arrange process.env.GITHUB_WORKSPACE = originalWorkspace;
hashFilesSpy.mockImplementation((somePath: string) => { jest.restoreAllMocks();
return new Promise<string>(resolve => { });
resolve('');
});
});
//Act + Assert it('should throw if dependency file path is not valid', async () => {
await expect(async () => { // Arrange
await cacheRestore.restoreCache( hashFilesSpy.mockImplementation(() => Promise.resolve(''));
// Act + Assert
await expect(
cacheRestore.restoreCache(
versionSpec, versionSpec,
packageManager, packageManager,
cacheDependencyPath cacheDependencyPath
); )
}).rejects.toThrow( ).rejects.toThrow(
'Some specified paths were not resolved, unable to cache dependencies.' 'Some specified paths were not resolved, unable to cache dependencies.'
); );
}); });
it('should inform if cache hit is not occured', async () => { it('should inform if cache hit is not occurred', async () => {
//Arrange // Arrange
hashFilesSpy.mockImplementation((somePath: string) => { hashFilesSpy.mockImplementation(() => Promise.resolve('file_hash'));
return new Promise<string>(resolve => { restoreCacheSpy.mockImplementation(() => Promise.resolve(''));
resolve('file_hash'); // Act + Assert
});
});
restoreCacheSpy.mockImplementation(() => {
return new Promise<string>(resolve => {
resolve('');
});
});
//Act + Assert
await cacheRestore.restoreCache( await cacheRestore.restoreCache(
versionSpec, versionSpec,
packageManager, packageManager,
cacheDependencyPath cacheDependencyPath
); );
expect(infoSpy).toHaveBeenCalledWith(`Cache is not found`); expect(infoSpy).toHaveBeenCalledWith('Cache is not found');
}); });
it('should set output if cache hit is occured', async () => { it('should set output if cache hit is occurred', async () => {
//Arrange // Arrange
hashFilesSpy.mockImplementation((somePath: string) => { hashFilesSpy.mockImplementation(() => Promise.resolve('file_hash'));
return new Promise<string>(resolve => { restoreCacheSpy.mockImplementation(() => Promise.resolve('cache_key'));
resolve('file_hash'); // Act + Assert
});
});
restoreCacheSpy.mockImplementation(() => {
return new Promise<string>(resolve => {
resolve('cache_key');
});
});
//Act + Assert
await cacheRestore.restoreCache( await cacheRestore.restoreCache(
versionSpec, versionSpec,
packageManager, packageManager,
@@ -96,4 +85,18 @@ describe('restoreCache', () => {
); );
expect(setOutputSpy).toHaveBeenCalledWith('cache-hit', true); expect(setOutputSpy).toHaveBeenCalledWith('cache-hit', true);
}); });
it('should throw if dependency file is not found in workspace', async () => {
jest.spyOn(fs, 'readdirSync').mockReturnValue(['main.go'] as any);
await expect(
cacheRestore.restoreCache(
versionSpec,
packageManager
// No cacheDependencyPath
)
).rejects.toThrow(
'Dependencies file is not found in /test/workspace. Supported file pattern: go.mod'
);
});
}); });

View File

@@ -47,7 +47,7 @@ describe('getPackageManagerInfo', () => {
//Arrange //Arrange
const packageManagerName = 'default'; const packageManagerName = 'default';
const expectedResult = { const expectedResult = {
dependencyFilePattern: 'go.sum', dependencyFilePattern: 'go.mod',
cacheFolderCommandList: ['go env GOMODCACHE', 'go env GOCACHE'] cacheFolderCommandList: ['go env GOMODCACHE', 'go env GOCACHE']
}; };
@@ -73,7 +73,7 @@ describe('getCacheDirectoryPath', () => {
const getExecOutputSpy = jest.spyOn(exec, 'getExecOutput'); const getExecOutputSpy = jest.spyOn(exec, 'getExecOutput');
const validPackageManager: PackageManagerInfo = { const validPackageManager: PackageManagerInfo = {
dependencyFilePattern: 'go.sum', dependencyFilePattern: 'go.mod',
cacheFolderCommandList: ['go env GOMODCACHE', 'go env GOCACHE'] cacheFolderCommandList: ['go env GOMODCACHE', 'go env GOCACHE']
}; };

View File

@@ -16,7 +16,7 @@ inputs:
description: Used to specify whether caching is needed. Set to true, if you'd like to enable caching. description: Used to specify whether caching is needed. Set to true, if you'd like to enable caching.
default: true default: true
cache-dependency-path: cache-dependency-path:
description: 'Used to specify the path to a dependency file - go.sum' description: 'Used to specify the path to a dependency file (e.g., go.mod, go.sum)'
architecture: architecture:
description: 'Target architecture for Go to use. Examples: x86, x64. Will use system architecture by default.' description: 'Target architecture for Go to use. Examples: x86, x64. Will use system architecture by default.'
outputs: outputs:

View File

@@ -44277,7 +44277,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.supportedPackageManagers = void 0; exports.supportedPackageManagers = void 0;
exports.supportedPackageManagers = { exports.supportedPackageManagers = {
default: { default: {
dependencyFilePattern: 'go.sum', dependencyFilePattern: 'go.mod',
cacheFolderCommandList: ['go env GOMODCACHE', 'go env GOCACHE'] cacheFolderCommandList: ['go env GOMODCACHE', 'go env GOCACHE']
} }
}; };

6
dist/setup/index.js vendored
View File

@@ -49364,8 +49364,8 @@ const findDependencyFile = (packageManager) => {
const dependencyFile = packageManager.dependencyFilePattern; const dependencyFile = packageManager.dependencyFilePattern;
const workspace = process.env.GITHUB_WORKSPACE; const workspace = process.env.GITHUB_WORKSPACE;
const rootContent = fs_1.default.readdirSync(workspace); const rootContent = fs_1.default.readdirSync(workspace);
const goSumFileExists = rootContent.includes(dependencyFile); const goModFileExists = rootContent.includes(dependencyFile);
if (!goSumFileExists) { if (!goModFileExists) {
throw new Error(`Dependencies file is not found in ${workspace}. Supported file pattern: ${dependencyFile}`); throw new Error(`Dependencies file is not found in ${workspace}. Supported file pattern: ${dependencyFile}`);
} }
return path_1.default.join(workspace, dependencyFile); return path_1.default.join(workspace, dependencyFile);
@@ -50182,7 +50182,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.supportedPackageManagers = void 0; exports.supportedPackageManagers = void 0;
exports.supportedPackageManagers = { exports.supportedPackageManagers = {
default: { default: {
dependencyFilePattern: 'go.sum', dependencyFilePattern: 'go.mod',
cacheFolderCommandList: ['go env GOMODCACHE', 'go env GOCACHE'] cacheFolderCommandList: ['go env GOMODCACHE', 'go env GOCACHE']
} }
}; };

10
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{ {
"name": "setup-go", "name": "setup-go",
"version": "6.0.1", "version": "6.2.0",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "setup-go", "name": "setup-go",
"version": "6.0.1", "version": "6.2.0",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@actions/cache": "^5.0.1", "@actions/cache": "^5.0.1",
@@ -5487,9 +5487,9 @@
"license": "MIT" "license": "MIT"
}, },
"node_modules/qs": { "node_modules/qs": {
"version": "6.14.0", "version": "6.14.1",
"resolved": "https://registry.npmjs.org/qs/-/qs-6.14.0.tgz", "resolved": "https://registry.npmjs.org/qs/-/qs-6.14.1.tgz",
"integrity": "sha512-YWWTjgABSKcvs/nWBi9PycY/JiPJqOD4JA6o9Sej2AtvSGarXxKC3OQSk4pAarbdQlKAh5D4FCQkJNkW+GAn3w==", "integrity": "sha512-4EK3+xJl8Ts67nLYNwqw/dsFVnCf+qR7RgXSK9jEEm9unao3njwMDdmsdvoKBKHzxd7tCYz5e5M+SnMjdtXGQQ==",
"dev": true, "dev": true,
"license": "BSD-3-Clause", "license": "BSD-3-Clause",
"dependencies": { "dependencies": {

View File

@@ -1,6 +1,6 @@
{ {
"name": "setup-go", "name": "setup-go",
"version": "6.0.1", "version": "6.2.0",
"private": true, "private": true,
"description": "setup go action", "description": "setup go action",
"main": "lib/setup-go.js", "main": "lib/setup-go.js",

View File

@@ -55,8 +55,8 @@ const findDependencyFile = (packageManager: PackageManagerInfo) => {
const workspace = process.env.GITHUB_WORKSPACE!; const workspace = process.env.GITHUB_WORKSPACE!;
const rootContent = fs.readdirSync(workspace); const rootContent = fs.readdirSync(workspace);
const goSumFileExists = rootContent.includes(dependencyFile); const goModFileExists = rootContent.includes(dependencyFile);
if (!goSumFileExists) { if (!goModFileExists) {
throw new Error( throw new Error(
`Dependencies file is not found in ${workspace}. Supported file pattern: ${dependencyFile}` `Dependencies file is not found in ${workspace}. Supported file pattern: ${dependencyFile}`
); );

View File

@@ -9,7 +9,7 @@ export interface PackageManagerInfo {
export const supportedPackageManagers: SupportedPackageManagers = { export const supportedPackageManagers: SupportedPackageManagers = {
default: { default: {
dependencyFilePattern: 'go.sum', dependencyFilePattern: 'go.mod',
cacheFolderCommandList: ['go env GOMODCACHE', 'go env GOCACHE'] cacheFolderCommandList: ['go env GOMODCACHE', 'go env GOCACHE']
} }
}; };