mirror of
https://github.com/actions/setup-go
synced 2024-11-09 15:12:40 +00:00
bit of cleanup
This commit is contained in:
parent
f4b0281c15
commit
7af81a4a65
3 changed files with 22 additions and 11 deletions
16
README.md
16
README.md
|
@ -11,6 +11,22 @@ This action sets up a go environment for use in actions by:
|
||||||
- optionally downloading and caching a version of Go by version and adding to PATH
|
- optionally downloading and caching a version of Go by version and adding to PATH
|
||||||
- registering problem matchers for error output
|
- registering problem matchers for error output
|
||||||
|
|
||||||
|
# V2 Beta
|
||||||
|
|
||||||
|
The V2 beta offers:
|
||||||
|
- Proxy Support
|
||||||
|
- stable input
|
||||||
|
- Bug Fixes (including issues around version matching and semver)
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: actions/setup-go@v2-beta
|
||||||
|
with:
|
||||||
|
go-version: '^1.13.1' # The Go version to download (if necessary) and use.
|
||||||
|
- run: go version
|
||||||
|
```
|
||||||
|
|
||||||
# Usage
|
# Usage
|
||||||
|
|
||||||
See [action.yml](action.yml)
|
See [action.yml](action.yml)
|
||||||
|
|
|
@ -20,7 +20,6 @@ describe('setup-go', () => {
|
||||||
let archSpy: jest.SpyInstance;
|
let archSpy: jest.SpyInstance;
|
||||||
let dlSpy: jest.SpyInstance;
|
let dlSpy: jest.SpyInstance;
|
||||||
let exSpy: jest.SpyInstance;
|
let exSpy: jest.SpyInstance;
|
||||||
//let http: httpm.HttpClient = new httpm.HttpClient('setup-go-tests');
|
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
tcSpy = jest.spyOn(tc, 'find');
|
tcSpy = jest.spyOn(tc, 'find');
|
||||||
|
@ -31,6 +30,7 @@ describe('setup-go', () => {
|
||||||
dlSpy = jest.spyOn(tc, 'downloadTool');
|
dlSpy = jest.spyOn(tc, 'downloadTool');
|
||||||
exSpy = jest.spyOn(tc, 'extractTar');
|
exSpy = jest.spyOn(tc, 'extractTar');
|
||||||
getSpy = jest.spyOn(im, 'getVersions');
|
getSpy = jest.spyOn(im, 'getVersions');
|
||||||
|
getSpy.mockImplementation(() => <im.IGoVersion[]>goJsonData);
|
||||||
cnSpy.mockImplementation(line => {
|
cnSpy.mockImplementation(line => {
|
||||||
// uncomment to debug
|
// uncomment to debug
|
||||||
//process.stderr.write('write2:' + line + '\n');
|
//process.stderr.write('write2:' + line + '\n');
|
||||||
|
@ -38,8 +38,7 @@ describe('setup-go', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
tcSpy.mockClear();
|
jest.resetAllMocks();
|
||||||
cnSpy.mockClear();
|
|
||||||
jest.clearAllMocks();
|
jest.clearAllMocks();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -75,11 +74,10 @@ describe('setup-go', () => {
|
||||||
expect(cnSpy).toHaveBeenCalledWith('::error::' + errMsg + os.EOL);
|
expect(cnSpy).toHaveBeenCalledWith('::error::' + errMsg + os.EOL);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('can mock go versions query', async () => {
|
it('can query versions', async () => {
|
||||||
getSpy.mockImplementation(
|
let versions: im.IGoVersion[] | null = await im.getVersions(
|
||||||
() => <im.IGoVersion[]>goJsonData
|
'https://non.existant.com/path'
|
||||||
);
|
);
|
||||||
let versions: im.IGoVersion[] | null = await im.getVersions('https://non.existant.com/path');
|
|
||||||
expect(versions).toBeDefined();
|
expect(versions).toBeDefined();
|
||||||
let l: number = versions ? versions.length : 0;
|
let l: number = versions ? versions.length : 0;
|
||||||
expect(l).toBe(91);
|
expect(l).toBe(91);
|
||||||
|
@ -88,9 +86,6 @@ describe('setup-go', () => {
|
||||||
it('finds stable match for exact version', async () => {
|
it('finds stable match for exact version', async () => {
|
||||||
platSpy.mockImplementation(() => 'linux');
|
platSpy.mockImplementation(() => 'linux');
|
||||||
archSpy.mockImplementation(() => 'amd64');
|
archSpy.mockImplementation(() => 'amd64');
|
||||||
getSpy.mockImplementation(
|
|
||||||
() => <im.IGoVersion[]>goJsonData
|
|
||||||
);
|
|
||||||
|
|
||||||
// get request is already mocked
|
// get request is already mocked
|
||||||
// spec: 1.13.1 => 1.13.1 (exact)
|
// spec: 1.13.1 => 1.13.1 (exact)
|
||||||
|
|
|
@ -96,7 +96,7 @@ export async function findMatch(
|
||||||
|
|
||||||
export async function getVersions(dlUrl: string): Promise<IGoVersion[] | null> {
|
export async function getVersions(dlUrl: string): Promise<IGoVersion[] | null> {
|
||||||
// this returns versions descending so latest is first
|
// this returns versions descending so latest is first
|
||||||
let http: httpm.HttpClient = new httpm.HttpClient('setup-go');
|
let http: httpm.HttpClient = new httpm.HttpClient('setup-go');
|
||||||
let candidates: IGoVersion[] | null = (await http.getJson<IGoVersion[]>(
|
let candidates: IGoVersion[] | null = (await http.getJson<IGoVersion[]>(
|
||||||
dlUrl
|
dlUrl
|
||||||
)).result;
|
)).result;
|
||||||
|
|
Loading…
Reference in a new issue