Skip to content

Commit

Permalink
resolve comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmitry Shibanov committed Jun 23, 2020
1 parent a2c84d5 commit e8c9273
Show file tree
Hide file tree
Showing 5 changed files with 106 additions and 148 deletions.
57 changes: 0 additions & 57 deletions .github/workflows/test.yml

This file was deleted.

102 changes: 62 additions & 40 deletions .github/workflows/versions.yml
Original file line number Diff line number Diff line change
@@ -1,54 +1,76 @@
name: go-versions
name: Validate 'setup-go'
on:
push:
branches:
- master
paths-ignore:
- '**.md'
pull_request:
paths-ignore:
- '**.md'
push:
pull_request:
schedule:
- cron: 0 0 * * *

jobs:
run:
name: Go
runs-on: ${{ matrix.operating-system }}
local-cache:
name: Setup local-cache version
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
operating-system: [ubuntu-latest, windows-latest, macos-latest]
os: [macos-latest, windows-latest, ubuntu-latest]
go: [1.11.13, 1.12.17, 1.13.12]
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Checkout
uses: actions/checkout@v2

- name: setup-go 1.13.6
uses: ./
with:
go-version: 1.13.6
- name: setup-go ${{ matrix.go }}
uses: ./
with:
go-version: ${{ matrix.go }}

- name: verify go
run: __tests__/verify-go.sh go1.13.6
shell: bash
- name: verify go
run: __tests__/verify-go.sh ${{ matrix.go }}
shell: bash

- name: setup-go 1.13
uses: ./
with:
go-version: 1.13
- name: Run simple code
run: go run __tests__/simple/simple.go

- name: verify go
run: __tests__/verify-go.sh go1.13.*
shell: bash
setup-versions-from-manifest:
name: Setup ${{ matrix.go }} ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macos-latest, windows-latest, ubuntu-latest]
go: [1.12.16, 1.13.11, 1.14.3]
steps:
- name: Checkout
uses: actions/checkout@v2

- name: setup-go ${{ matrix.go }}
uses: ./
with:
go-version: ${{ matrix.go }}

- name: verify go
run: __tests__/verify-go.sh ${{ matrix.go }}
shell: bash

- name: Run simple code
run: go run __tests__/simple/simple.go

- name: setup-go 1.12.9
setup-versions-from-dist:
name: Setup ${{ matrix.go }} ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macos-latest, windows-latest, ubuntu-latest]
go: [1.7, 1.8.6, 1.15beta1]
steps:
- name: Checkout
uses: actions/checkout@v2
- name: setup-go ${{ matrix.go }}
uses: ./
with:
go-version: 1.12.9

go-version: ${{ matrix.go }}
- name: verify go
run: __tests__/verify-go.sh go1.12.9
shell: bash

- name: dump env
run: __tests__/verify-go.sh ${{ matrix.go }}
shell: bash
run: |
echo $PATH
echo go versions in tool cache:
echo $(ls $RUNNER_TOOL_CACHE/go)
- name: Run simple code
run: go run __tests__/simple/simple.go
39 changes: 18 additions & 21 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6926,7 +6926,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getInfoFromManifest = exports.makeSemver = exports.getVersionsDist = exports.findMatch = exports.extractGoArchive = exports.getGo = void 0;
exports.makeSemver = exports.getVersionsDist = exports.getInfoFromManifest = exports.findMatch = exports.extractGoArchive = exports.getGo = void 0;
const tc = __importStar(__webpack_require__(533));
const core = __importStar(__webpack_require__(470));
const semver = __importStar(__webpack_require__(876));
Expand Down Expand Up @@ -7004,7 +7004,7 @@ function installGoVersion(info, auth) {
console.log('Extracting Go...');
const extPath = yield extractGoArchive(downloadPath);
console.log('Adding to the cache ...');
return yield tc.cacheDir(extPath, 'go', info.resolvedVersion);
return yield tc.cacheDir(extPath, 'go', makeSemver(info.resolvedVersion));
});
}
function extractGoArchive(archivePath) {
Expand All @@ -7028,9 +7028,6 @@ function getInfoFromDist(versionSpec, stable) {
if (!version) {
return null;
}
//
// Download - a tool installer intimately knows how to get the tool (and construct urls)
//
let downloadUrl = `https://storage.googleapis.com/golang/${version.files[0].filename}`;
return {
downloadUrl: downloadUrl,
Expand Down Expand Up @@ -7083,6 +7080,22 @@ function findMatch(versionSpec, stable) {
});
}
exports.findMatch = findMatch;
function getInfoFromManifest(versionSpec, stable, auth) {
return __awaiter(this, void 0, void 0, function* () {
let info = null;
const releases = yield tc.getManifestFromRepo('actions', 'go-versions', auth);
console.log(`matching ${versionSpec}...`);
const rel = yield tc.findFromManifest(versionSpec, stable, releases);
if (rel && rel.files.length > 0) {
info = {};
info.resolvedVersion = rel.version;
info.downloadUrl = rel.files[0].download_url;
info.fileName = rel.files[0].filename;
}
return info;
});
}
exports.getInfoFromManifest = getInfoFromManifest;
function getVersionsDist(dlUrl) {
return __awaiter(this, void 0, void 0, function* () {
// this returns versions descending so latest is first
Expand Down Expand Up @@ -7113,22 +7126,6 @@ function makeSemver(version) {
return `${verPart}${prereleasePart}`;
}
exports.makeSemver = makeSemver;
function getInfoFromManifest(versionSpec, stable, auth) {
return __awaiter(this, void 0, void 0, function* () {
let info = null;
const releases = yield tc.getManifestFromRepo('actions', 'go-versions', auth);
console.log(`matching ${versionSpec}...`);
const rel = yield tc.findFromManifest(versionSpec, stable, releases);
if (rel && rel.files.length > 0) {
info = {};
info.resolvedVersion = rel.version;
info.downloadUrl = rel.files[0].download_url;
info.fileName = rel.files[0].filename;
}
return info;
});
}
exports.getInfoFromManifest = getInfoFromManifest;


/***/ }),
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,18 @@
"@actions/http-client": "^1.0.6",
"@actions/io": "^1.0.2",
"@actions/tool-cache": "^1.5.5",
"semver": "^7.1.3"
"semver": "^6.1.1"
},
"devDependencies": {
"@types/jest": "^26.0.0",
"@types/jest": "^24.0.13",
"@types/node": "^12.0.4",
"@types/semver": "7.1.0",
"@types/semver": "^6.0.0",
"@zeit/ncc": "^0.21.0",
"jest": "^25.2.1",
"jest-circus": "^25.1.0",
"jest-circus": "^24.7.1",
"nock": "^10.0.6",
"prettier": "^1.17.1",
"ts-jest": "^25.2.1",
"ts-jest": "^24.0.2",
"typescript": "^3.8.3"
}
}
46 changes: 21 additions & 25 deletions src/installer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ async function installGoVersion(
const extPath = await extractGoArchive(downloadPath);

console.log('Adding to the cache ...');
return await tc.cacheDir(extPath, 'go', info.resolvedVersion);
return await tc.cacheDir(extPath, 'go', makeSemver(info.resolvedVersion));
}

export async function extractGoArchive(archivePath: string): Promise<string> {
Expand All @@ -140,10 +140,6 @@ async function getInfoFromDist(
return null;
}

//
// Download - a tool installer intimately knows how to get the tool (and construct urls)
//

let downloadUrl: string = `https://storage.googleapis.com/golang/${version.files[0].filename}`;

return <IGoVersionInfo>{
Expand Down Expand Up @@ -210,6 +206,26 @@ export async function findMatch(
return result;
}

export async function getInfoFromManifest(
versionSpec: string,
stable: boolean,
auth: string | undefined
): Promise<IGoVersionInfo | null> {
let info: IGoVersionInfo | null = null;
const releases = await tc.getManifestFromRepo('actions', 'go-versions', auth);
console.log(`matching ${versionSpec}...`);
const rel = await tc.findFromManifest(versionSpec, stable, releases);

if (rel && rel.files.length > 0) {
info = <IGoVersionInfo>{};
info.resolvedVersion = rel.version;
info.downloadUrl = rel.files[0].download_url;
info.fileName = rel.files[0].filename;
}

return info;
}

export async function getVersionsDist(
dlUrl: string
): Promise<IGoVersion[] | null> {
Expand Down Expand Up @@ -242,23 +258,3 @@ export function makeSemver(version: string): string {

return `${verPart}${prereleasePart}`;
}

export async function getInfoFromManifest(
versionSpec: string,
stable: boolean,
auth: string | undefined
): Promise<IGoVersionInfo | null> {
let info: IGoVersionInfo | null = null;
const releases = await tc.getManifestFromRepo('actions', 'go-versions', auth);
console.log(`matching ${versionSpec}...`);
const rel = await tc.findFromManifest(versionSpec, stable, releases);

if (rel && rel.files.length > 0) {
info = <IGoVersionInfo>{};
info.resolvedVersion = rel.version;
info.downloadUrl = rel.files[0].download_url;
info.fileName = rel.files[0].filename;
}

return info;
}

0 comments on commit e8c9273

Please sign in to comment.