Add support for .tool-versions file in setup-go, update workflow (#673)

* setup go in local

* add .tool-versions file support
This commit is contained in:
priya-kinthali
2025-10-28 20:56:52 +05:30
committed by GitHub
parent 7bc60db215
commit faf52423ec
8 changed files with 63 additions and 14 deletions

View File

@@ -866,6 +866,9 @@ exclude example.com/thismodule v1.3.0
use .
`;
const toolVersionsContents = `golang 1.23
`;
it('reads version from go.mod', async () => {
@@ -892,6 +895,18 @@ use .
expect(logSpy).toHaveBeenCalledWith('matching 1.19...');
});
it('reads version from .tool-versions', async () => {
inputs['go-version-file'] = '.tool-versions';
existsSpy.mockImplementation(() => true);
readFileSpy.mockImplementation(() => Buffer.from(toolVersionsContents));
await main.run();
expect(logSpy).toHaveBeenCalledWith('Setup go version spec 1.23');
expect(logSpy).toHaveBeenCalledWith('Attempting to download 1.23...');
expect(logSpy).toHaveBeenCalledWith('matching 1.23...');
});
it('reads version from .go-version', async () => {
inputs['go-version-file'] = '.go-version';
existsSpy.mockImplementation(() => true);