Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .github/workflows/versions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,22 @@ jobs:
run: __tests__/verify-go.sh 1.22.4
shell: bash

go-version-file-with-mise:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest, macos-latest-large]
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Setup Go from mise.toml
uses: ./
with:
go-version-file: __tests__/data/mise.toml
- name: verify go
run: __tests__/verify-go.sh 1.23.2
shell: bash

setup-versions-from-manifest:
runs-on: ${{ matrix.os }}
strategy:
Expand Down
35 changes: 35 additions & 0 deletions .licenses/npm/smol-toml.dep.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ See [action.yml](action.yml).
# Version or version range of Go to use
go-version: '1.23'

# Path to go.mod, go.work, .go-version, or .tool-versions file
# Path to go.mod, go.work, .go-version, .tool-versions, or mise.toml file
# Note: if both go-version and go-version-file are provided, go-version takes precedence.
go-version-file: 'go.mod'

Expand Down
2 changes: 2 additions & 0 deletions __tests__/data/mise.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[tools]
go = "1.23.2"
43 changes: 43 additions & 0 deletions __tests__/setup-go.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -952,6 +952,9 @@ use .
`;

const toolVersionsContents = `golang 1.23
`;
const miseTomlContents = `[tools]
go = "1.24"
`;

it('reads version from go.mod', async () => {
Expand Down Expand Up @@ -990,6 +993,46 @@ use .
expect(logSpy).toHaveBeenCalledWith('matching 1.23...');
});

it('reads version from mise.toml', async () => {
inputs['go-version-file'] = 'mise.toml';
existsSpy.mockImplementation(() => true);
readFileSpy.mockImplementation(() => Buffer.from(miseTomlContents));

await main.run();

expect(logSpy).toHaveBeenCalledWith('Setup go version spec 1.24');
expect(logSpy).toHaveBeenCalledWith('Attempting to download 1.24...');
expect(logSpy).toHaveBeenCalledWith('matching 1.24...');
});

it('reads an object version from mise.toml', async () => {
inputs['go-version-file'] = 'mise.toml';
existsSpy.mockImplementation(() => true);
readFileSpy.mockImplementation(() =>
Buffer.from('[tools]\ngo = { version = "1.25" }\n')
);

await main.run();

expect(logSpy).toHaveBeenCalledWith('Setup go version spec 1.25');
expect(logSpy).toHaveBeenCalledWith('Attempting to download 1.25...');
expect(logSpy).toHaveBeenCalledWith('matching 1.25...');
});

it('reads the first version from an array in mise.toml', async () => {
inputs['go-version-file'] = 'mise.toml';
existsSpy.mockImplementation(() => true);
readFileSpy.mockImplementation(() =>
Buffer.from('[tools]\ngo = ["1.26", "1.27"]\n')
);

await main.run();

expect(logSpy).toHaveBeenCalledWith('Setup go version spec 1.26');
expect(logSpy).toHaveBeenCalledWith('Attempting to download 1.26...');
expect(logSpy).toHaveBeenCalledWith('matching 1.26...');
});

it('reads version from .go-version', async () => {
inputs['go-version-file'] = '.go-version';
existsSpy.mockImplementation(() => true);
Expand Down
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ inputs:
go-version:
description: 'The Go version to download (if necessary) and use. Supports semver spec and ranges. Be sure to enclose this option in single quotation marks.'
go-version-file:
description: 'Path to the go.mod, go.work, .go-version, or .tool-versions file.'
description: 'Path to the go.mod, go.work, .go-version, .tool-versions, or mise.toml file.'
check-latest:
description: 'Set this option to true if you want the action to always check for the latest available version that satisfies the version spec'
default: false
Expand Down
Loading