From e8c92737abaa050099411d984754121bdabcf38b Mon Sep 17 00:00:00 2001 From: Dmitry Shibanov Date: Tue, 23 Jun 2020 11:02:49 +0300 Subject: [PATCH] resolve comments --- .github/workflows/test.yml | 57 ------------------ .github/workflows/versions.yml | 102 ++++++++++++++++++++------------- dist/index.js | 39 ++++++------- package.json | 10 ++-- src/installer.ts | 46 +++++++-------- 5 files changed, 106 insertions(+), 148 deletions(-) delete mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index f796178bb..000000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,57 +0,0 @@ -name: Validate 'setup-go' -on: - push: - pull_request: - schedule: - - cron: 0 0 * * * - -jobs: - default-version: - name: Setup default version - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - os: [macos-latest, windows-latest, ubuntu-latest] - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: setup default go - uses: ./ - - - name: Validate version - run: go version - - - name: Run simple go code - run: go run __tests__/simple/simple.go - - 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: Validate version - run: | - $goVersion = (go version) - if ( "$goVersion" -notmatch "${{ matrix.go }}"){ - Write-Host "The current version is $goVersion; expected version is ${{ matrix.go }}" - exit 1 - } - $goVersion - shell: pwsh - - - name: Run simple code - run: go run __tests__/simple/simple.go \ No newline at end of file diff --git a/.github/workflows/versions.yml b/.github/workflows/versions.yml index 0281ddebd..173cd3cf9 100644 --- a/.github/workflows/versions.yml +++ b/.github/workflows/versions.yml @@ -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 \ No newline at end of file diff --git a/dist/index.js b/dist/index.js index e02c0ca90..44e39d98f 100644 --- a/dist/index.js +++ b/dist/index.js @@ -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)); @@ -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) { @@ -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, @@ -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 @@ -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; /***/ }), diff --git a/package.json b/package.json index b481575ea..d0e8b467c 100644 --- a/package.json +++ b/package.json @@ -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" } } diff --git a/src/installer.ts b/src/installer.ts index 7298144f9..ab9bd3db3 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -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 { @@ -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 { @@ -210,6 +206,26 @@ export async function findMatch( return result; } +export async function getInfoFromManifest( + versionSpec: string, + stable: boolean, + auth: string | undefined +): Promise { + 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 = {}; + 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 { @@ -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 { - 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 = {}; - info.resolvedVersion = rel.version; - info.downloadUrl = rel.files[0].download_url; - info.fileName = rel.files[0].filename; - } - - return info; -}