mirror of
https://github.com/actions/setup-go.git
synced 2025-07-09 10:39:43 +08:00
Compare commits
15 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
6f26dcc668 | ||
|
8d4083a006 | ||
|
fa96338abe | ||
|
4de67c04ab | ||
|
d35c59abb0 | ||
|
29694d72cd | ||
|
78535dd5f2 | ||
|
bb65d8857b | ||
|
7f17e836c0 | ||
|
dca8468d37 | ||
|
691cc3533f | ||
|
0aaccfd150 | ||
|
c4c1141886 | ||
|
5a083d0e9a | ||
|
1d82324e53 |
2
.github/ISSUE_TEMPLATE/bug_report.md
vendored
2
.github/ISSUE_TEMPLATE/bug_report.md
vendored
@ -7,7 +7,7 @@ assignees: ''
|
||||
|
||||
---
|
||||
|
||||
<!--- Please direct any generic questions related to actions to our support community forum at https://github.community/c/code-to-cloud/github-actions/41 --->
|
||||
<!--- Please direct any generic questions related to actions to our support community forum at https://github.com/orgs/community/discussions/categories/actions --->
|
||||
<!--- Before opening up a new bug report, please make sure to check for similar existing issues -->
|
||||
|
||||
**Description:**
|
||||
|
2
.github/ISSUE_TEMPLATE/feature_request.md
vendored
2
.github/ISSUE_TEMPLATE/feature_request.md
vendored
@ -5,7 +5,7 @@ title: ''
|
||||
labels: feature request, needs triage
|
||||
assignees: ''
|
||||
---
|
||||
<!--- Please direct any generic questions related to actions to our support community forum at https://github.community/c/code-to-cloud/github-actions/41 --->
|
||||
<!--- Please direct any generic questions related to actions to our support community forum at https://github.com/orgs/community/discussions/categories/actions --->
|
||||
<!--- Before opening up a new feature request, please make sure to check for similar existing issues and pull requests -->
|
||||
|
||||
**Description:**
|
||||
|
BIN
.licenses/npm/@actions/cache.dep.yml
generated
BIN
.licenses/npm/@actions/cache.dep.yml
generated
Binary file not shown.
Binary file not shown.
BIN
.licenses/npm/@actions/tool-cache.dep.yml
generated
BIN
.licenses/npm/@actions/tool-cache.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/@protobuf-ts/plugin-framework.dep.yml
generated
BIN
.licenses/npm/@protobuf-ts/plugin-framework.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/@protobuf-ts/plugin.dep.yml
generated
BIN
.licenses/npm/@protobuf-ts/plugin.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/@protobuf-ts/protoc.dep.yml
generated
BIN
.licenses/npm/@protobuf-ts/protoc.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/@protobuf-ts/runtime-rpc.dep.yml
generated
BIN
.licenses/npm/@protobuf-ts/runtime-rpc.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/@protobuf-ts/runtime.dep.yml
generated
BIN
.licenses/npm/@protobuf-ts/runtime.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/camel-case.dep.yml
generated
BIN
.licenses/npm/camel-case.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/commander.dep.yml
generated
BIN
.licenses/npm/commander.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/dot-object.dep.yml
generated
BIN
.licenses/npm/dot-object.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/fs.realpath.dep.yml
generated
BIN
.licenses/npm/fs.realpath.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/glob.dep.yml
generated
BIN
.licenses/npm/glob.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/inflight.dep.yml
generated
BIN
.licenses/npm/inflight.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/inherits.dep.yml
generated
BIN
.licenses/npm/inherits.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/lodash.dep.yml
generated
BIN
.licenses/npm/lodash.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/lower-case.dep.yml
generated
BIN
.licenses/npm/lower-case.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/lru-cache.dep.yml
generated
BIN
.licenses/npm/lru-cache.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/no-case.dep.yml
generated
BIN
.licenses/npm/no-case.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/once.dep.yml
generated
BIN
.licenses/npm/once.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/pascal-case.dep.yml
generated
BIN
.licenses/npm/pascal-case.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/path-is-absolute.dep.yml
generated
BIN
.licenses/npm/path-is-absolute.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/path-to-regexp.dep.yml
generated
BIN
.licenses/npm/path-to-regexp.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/prettier.dep.yml
generated
BIN
.licenses/npm/prettier.dep.yml
generated
Binary file not shown.
Binary file not shown.
BIN
.licenses/npm/ts-poet.dep.yml
generated
BIN
.licenses/npm/ts-poet.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/twirp-ts.dep.yml
generated
BIN
.licenses/npm/twirp-ts.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/undici.dep.yml
generated
BIN
.licenses/npm/undici.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/uuid-3.4.0.dep.yml
generated
BIN
.licenses/npm/uuid-3.4.0.dep.yml
generated
Binary file not shown.
Binary file not shown.
BIN
.licenses/npm/wrappy.dep.yml
generated
BIN
.licenses/npm/wrappy.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/yallist.dep.yml
generated
BIN
.licenses/npm/yallist.dep.yml
generated
Binary file not shown.
BIN
.licenses/npm/yaml.dep.yml
generated
BIN
.licenses/npm/yaml.dep.yml
generated
Binary file not shown.
52
__tests__/utils.test.ts
Normal file
52
__tests__/utils.test.ts
Normal file
@ -0,0 +1,52 @@
|
||||
import {isSelfHosted} from '../src/utils';
|
||||
|
||||
describe('utils', () => {
|
||||
describe('isSelfHosted', () => {
|
||||
let AGENT_ISSELFHOSTED: string | undefined;
|
||||
let RUNNER_ENVIRONMENT: string | undefined;
|
||||
|
||||
beforeEach(() => {
|
||||
AGENT_ISSELFHOSTED = process.env['AGENT_ISSELFHOSTED'];
|
||||
delete process.env['AGENT_ISSELFHOSTED'];
|
||||
RUNNER_ENVIRONMENT = process.env['RUNNER_ENVIRONMENT'];
|
||||
delete process.env['RUNNER_ENVIRONMENT'];
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
if (AGENT_ISSELFHOSTED === undefined) {
|
||||
delete process.env['AGENT_ISSELFHOSTED'];
|
||||
} else {
|
||||
process.env['AGENT_ISSELFHOSTED'] = AGENT_ISSELFHOSTED;
|
||||
}
|
||||
if (RUNNER_ENVIRONMENT === undefined) {
|
||||
delete process.env['RUNNER_ENVIRONMENT'];
|
||||
} else {
|
||||
process.env['RUNNER_ENVIRONMENT'] = RUNNER_ENVIRONMENT;
|
||||
}
|
||||
});
|
||||
|
||||
it('isSelfHosted should be true if no environment variables set', () => {
|
||||
expect(isSelfHosted()).toBeTruthy();
|
||||
});
|
||||
|
||||
it('isSelfHosted should be true if environment variable is not set to denote GitHub hosted', () => {
|
||||
process.env['RUNNER_ENVIRONMENT'] = 'some';
|
||||
expect(isSelfHosted()).toBeTruthy();
|
||||
});
|
||||
|
||||
it('isSelfHosted should be true if environment variable set to denote Azure Pipelines self hosted', () => {
|
||||
process.env['AGENT_ISSELFHOSTED'] = '1';
|
||||
expect(isSelfHosted()).toBeTruthy();
|
||||
});
|
||||
|
||||
it('isSelfHosted should be false if environment variable set to denote GitHub hosted', () => {
|
||||
process.env['RUNNER_ENVIRONMENT'] = 'github-hosted';
|
||||
expect(isSelfHosted()).toBeFalsy();
|
||||
});
|
||||
|
||||
it('isSelfHosted should be false if environment variable is not set to denote Azure Pipelines self hosted', () => {
|
||||
process.env['AGENT_ISSELFHOSTED'] = 'some';
|
||||
expect(isSelfHosted()).toBeFalsy();
|
||||
});
|
||||
});
|
||||
});
|
3072
dist/cache-save/index.js
vendored
3072
dist/cache-save/index.js
vendored
File diff suppressed because it is too large
Load Diff
4329
dist/setup/index.js
vendored
4329
dist/setup/index.js
vendored
File diff suppressed because it is too large
Load Diff
1176
package-lock.json
generated
1176
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
26
package.json
26
package.json
@ -25,31 +25,31 @@
|
||||
"author": "GitHub",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@actions/cache": "^4.0.0",
|
||||
"@actions/core": "^1.10.0",
|
||||
"@actions/exec": "^1.1.0",
|
||||
"@actions/glob": "^0.4.0",
|
||||
"@actions/cache": "^4.0.3",
|
||||
"@actions/core": "^1.11.1",
|
||||
"@actions/exec": "^1.1.1",
|
||||
"@actions/glob": "^0.5.0",
|
||||
"@actions/http-client": "^2.2.1",
|
||||
"@actions/io": "^1.0.2",
|
||||
"@actions/tool-cache": "^2.0.1",
|
||||
"semver": "^7.6.0"
|
||||
"@actions/tool-cache": "^2.0.2",
|
||||
"semver": "^7.6.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/jest": "^29.5.12",
|
||||
"@types/jest": "^29.5.14",
|
||||
"@types/node": "^20.11.28",
|
||||
"@types/semver": "^7.5.8",
|
||||
"@typescript-eslint/eslint-plugin": "^5.54.0",
|
||||
"@typescript-eslint/parser": "^5.54.0",
|
||||
"@typescript-eslint/eslint-plugin": "^8.31.1",
|
||||
"@typescript-eslint/parser": "^8.35.1",
|
||||
"@vercel/ncc": "^0.38.1",
|
||||
"eslint": "^8.57.0",
|
||||
"eslint-config-prettier": "^8.6.0",
|
||||
"eslint-plugin-jest": "^27.9.0",
|
||||
"eslint-config-prettier": "^10.0.1",
|
||||
"eslint-plugin-jest": "^28.11.0",
|
||||
"eslint-plugin-node": "^11.1.0",
|
||||
"jest": "^29.7.0",
|
||||
"jest-circus": "^29.7.0",
|
||||
"nock": "^10.0.6",
|
||||
"prettier": "^2.8.4",
|
||||
"ts-jest": "^29.1.2",
|
||||
"ts-jest": "^29.3.2",
|
||||
"typescript": "^5.4.2"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ import * as httpm from '@actions/http-client';
|
||||
import * as sys from './system';
|
||||
import fs from 'fs';
|
||||
import os from 'os';
|
||||
import {StableReleaseAlias} from './utils';
|
||||
import {StableReleaseAlias, isSelfHosted} from './utils';
|
||||
|
||||
const MANIFEST_REPO_OWNER = 'actions';
|
||||
const MANIFEST_REPO_NAME = 'go-versions';
|
||||
@ -180,11 +180,7 @@ async function cacheWindowsDir(
|
||||
if (os.platform() !== 'win32') return false;
|
||||
|
||||
// make sure the action runs in the hosted environment
|
||||
if (
|
||||
process.env['RUNNER_ENVIRONMENT'] !== 'github-hosted' &&
|
||||
process.env['AGENT_ISSELFHOSTED'] === '1'
|
||||
)
|
||||
return false;
|
||||
if (isSelfHosted()) return false;
|
||||
|
||||
const defaultToolCacheRoot = process.env['RUNNER_TOOL_CACHE'];
|
||||
if (!defaultToolCacheRoot) return false;
|
||||
@ -279,11 +275,46 @@ export async function extractGoArchive(archivePath: string): Promise<string> {
|
||||
return extPath;
|
||||
}
|
||||
|
||||
function isIToolRelease(obj: any): obj is tc.IToolRelease {
|
||||
return (
|
||||
typeof obj === 'object' &&
|
||||
obj !== null &&
|
||||
typeof obj.version === 'string' &&
|
||||
typeof obj.stable === 'boolean' &&
|
||||
Array.isArray(obj.files) &&
|
||||
obj.files.every(
|
||||
(file: any) =>
|
||||
typeof file.filename === 'string' &&
|
||||
typeof file.platform === 'string' &&
|
||||
typeof file.arch === 'string' &&
|
||||
typeof file.download_url === 'string'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
export async function getManifest(
|
||||
auth: string | undefined
|
||||
): Promise<tc.IToolRelease[]> {
|
||||
try {
|
||||
return await getManifestFromRepo(auth);
|
||||
const manifest = await getManifestFromRepo(auth);
|
||||
if (
|
||||
Array.isArray(manifest) &&
|
||||
manifest.length &&
|
||||
manifest.every(isIToolRelease)
|
||||
) {
|
||||
return manifest;
|
||||
}
|
||||
|
||||
let errorMessage =
|
||||
'An unexpected error occurred while fetching the manifest.';
|
||||
if (
|
||||
typeof manifest === 'object' &&
|
||||
manifest !== null &&
|
||||
'message' in manifest
|
||||
) {
|
||||
errorMessage = (manifest as {message: string}).message;
|
||||
}
|
||||
throw new Error(errorMessage);
|
||||
} catch (err) {
|
||||
core.debug('Fetching the manifest via the API failed.');
|
||||
if (err instanceof Error) {
|
||||
|
10
src/utils.ts
10
src/utils.ts
@ -2,3 +2,13 @@ export enum StableReleaseAlias {
|
||||
Stable = 'stable',
|
||||
OldStable = 'oldstable'
|
||||
}
|
||||
|
||||
export const isSelfHosted = (): boolean =>
|
||||
process.env['RUNNER_ENVIRONMENT'] !== 'github-hosted' &&
|
||||
(process.env['AGENT_ISSELFHOSTED'] === '1' ||
|
||||
process.env['AGENT_ISSELFHOSTED'] === undefined);
|
||||
/* the above is simplified from:
|
||||
process.env['RUNNER_ENVIRONMENT'] !== 'github-hosted' && process.env['AGENT_ISSELFHOSTED'] === '1'
|
||||
||
|
||||
process.env['RUNNER_ENVIRONMENT'] !== 'github-hosted' && process.env['AGENT_ISSELFHOSTED'] === undefined
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user