mirror of
https://github.com/actions/setup-go.git
synced 2026-06-09 14:33:17 +08:00
Compare commits
1 Commits
a9e971065c
...
v5.4.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0aaccfd150 |
2
.licenses/npm/undici.dep.yml
generated
2
.licenses/npm/undici.dep.yml
generated
@@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
name: undici
|
name: undici
|
||||||
version: 5.28.4
|
version: 5.28.5
|
||||||
type: npm
|
type: npm
|
||||||
summary: An HTTP/1.1 client, written from scratch for Node.js
|
summary: An HTTP/1.1 client, written from scratch for Node.js
|
||||||
homepage: https://undici.nodejs.org
|
homepage: https://undici.nodejs.org
|
||||||
|
|||||||
@@ -891,6 +891,18 @@ use .
|
|||||||
expect(logSpy).toHaveBeenCalledWith('matching 1.19...');
|
expect(logSpy).toHaveBeenCalledWith('matching 1.19...');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('reads version from .go-version', async () => {
|
||||||
|
inputs['go-version-file'] = '.go-version';
|
||||||
|
existsSpy.mockImplementation(() => true);
|
||||||
|
readFileSpy.mockImplementation(() => Buffer.from(`1.13.0${osm.EOL}`));
|
||||||
|
|
||||||
|
await main.run();
|
||||||
|
|
||||||
|
expect(logSpy).toHaveBeenCalledWith('Setup go version spec 1.13.0');
|
||||||
|
expect(logSpy).toHaveBeenCalledWith('Attempting to download 1.13.0...');
|
||||||
|
expect(logSpy).toHaveBeenCalledWith('matching 1.13.0...');
|
||||||
|
});
|
||||||
|
|
||||||
it('is overwritten by go-version', async () => {
|
it('is overwritten by go-version', async () => {
|
||||||
inputs['go-version'] = '1.13.1';
|
inputs['go-version'] = '1.13.1';
|
||||||
inputs['go-version-file'] = 'go.mod';
|
inputs['go-version-file'] = 'go.mod';
|
||||||
@@ -915,29 +927,6 @@ use .
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('go-version accepts a go.mod file', async () => {
|
|
||||||
inputs['go-version'] = 'go.mod';
|
|
||||||
existsSpy.mockImplementation(() => true);
|
|
||||||
readFileSpy.mockImplementation(() => Buffer.from(goModContents));
|
|
||||||
|
|
||||||
await main.run();
|
|
||||||
|
|
||||||
expect(logSpy).toHaveBeenCalledWith('Setup go version spec 1.14');
|
|
||||||
expect(logSpy).toHaveBeenCalledWith('Attempting to download 1.14...');
|
|
||||||
expect(logSpy).toHaveBeenCalledWith('matching 1.14...');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('go-version reports a read failure', async () => {
|
|
||||||
inputs['go-version'] = 'path/to/go.mod';
|
|
||||||
existsSpy.mockImplementation(() => false);
|
|
||||||
|
|
||||||
await main.run();
|
|
||||||
|
|
||||||
expect(cnSpy).toHaveBeenCalledWith(
|
|
||||||
`::error::The specified go version file at: path/to/go.mod does not exist${osm.EOL}`
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('acquires specified architecture of go', async () => {
|
it('acquires specified architecture of go', async () => {
|
||||||
for (const {arch, version, osSpec} of [
|
for (const {arch, version, osSpec} of [
|
||||||
{arch: 'amd64', version: '1.13.7', osSpec: 'linux'},
|
{arch: 'amd64', version: '1.13.7', osSpec: 'linux'},
|
||||||
|
|||||||
18
dist/cache-save/index.js
vendored
18
dist/cache-save/index.js
vendored
@@ -65451,6 +65451,14 @@ const { isUint8Array, isArrayBuffer } = __nccwpck_require__(9830)
|
|||||||
const { File: UndiciFile } = __nccwpck_require__(8511)
|
const { File: UndiciFile } = __nccwpck_require__(8511)
|
||||||
const { parseMIMEType, serializeAMimeType } = __nccwpck_require__(685)
|
const { parseMIMEType, serializeAMimeType } = __nccwpck_require__(685)
|
||||||
|
|
||||||
|
let random
|
||||||
|
try {
|
||||||
|
const crypto = __nccwpck_require__(6005)
|
||||||
|
random = (max) => crypto.randomInt(0, max)
|
||||||
|
} catch {
|
||||||
|
random = (max) => Math.floor(Math.random(max))
|
||||||
|
}
|
||||||
|
|
||||||
let ReadableStream = globalThis.ReadableStream
|
let ReadableStream = globalThis.ReadableStream
|
||||||
|
|
||||||
/** @type {globalThis['File']} */
|
/** @type {globalThis['File']} */
|
||||||
@@ -65536,7 +65544,7 @@ function extractBody (object, keepalive = false) {
|
|||||||
// Set source to a copy of the bytes held by object.
|
// Set source to a copy of the bytes held by object.
|
||||||
source = new Uint8Array(object.buffer.slice(object.byteOffset, object.byteOffset + object.byteLength))
|
source = new Uint8Array(object.buffer.slice(object.byteOffset, object.byteOffset + object.byteLength))
|
||||||
} else if (util.isFormDataLike(object)) {
|
} else if (util.isFormDataLike(object)) {
|
||||||
const boundary = `----formdata-undici-0${`${Math.floor(Math.random() * 1e11)}`.padStart(11, '0')}`
|
const boundary = `----formdata-undici-0${`${random(1e11)}`.padStart(11, '0')}`
|
||||||
const prefix = `--${boundary}\r\nContent-Disposition: form-data`
|
const prefix = `--${boundary}\r\nContent-Disposition: form-data`
|
||||||
|
|
||||||
/*! formdata-polyfill. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> */
|
/*! formdata-polyfill. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> */
|
||||||
@@ -86891,6 +86899,14 @@ module.exports = require("net");
|
|||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
||||||
|
/***/ 6005:
|
||||||
|
/***/ ((module) => {
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
module.exports = require("node:crypto");
|
||||||
|
|
||||||
|
/***/ }),
|
||||||
|
|
||||||
/***/ 5673:
|
/***/ 5673:
|
||||||
/***/ ((module) => {
|
/***/ ((module) => {
|
||||||
|
|
||||||
|
|||||||
48
dist/setup/index.js
vendored
48
dist/setup/index.js
vendored
@@ -71739,6 +71739,14 @@ const { isUint8Array, isArrayBuffer } = __nccwpck_require__(9830)
|
|||||||
const { File: UndiciFile } = __nccwpck_require__(8511)
|
const { File: UndiciFile } = __nccwpck_require__(8511)
|
||||||
const { parseMIMEType, serializeAMimeType } = __nccwpck_require__(685)
|
const { parseMIMEType, serializeAMimeType } = __nccwpck_require__(685)
|
||||||
|
|
||||||
|
let random
|
||||||
|
try {
|
||||||
|
const crypto = __nccwpck_require__(6005)
|
||||||
|
random = (max) => crypto.randomInt(0, max)
|
||||||
|
} catch {
|
||||||
|
random = (max) => Math.floor(Math.random(max))
|
||||||
|
}
|
||||||
|
|
||||||
let ReadableStream = globalThis.ReadableStream
|
let ReadableStream = globalThis.ReadableStream
|
||||||
|
|
||||||
/** @type {globalThis['File']} */
|
/** @type {globalThis['File']} */
|
||||||
@@ -71824,7 +71832,7 @@ function extractBody (object, keepalive = false) {
|
|||||||
// Set source to a copy of the bytes held by object.
|
// Set source to a copy of the bytes held by object.
|
||||||
source = new Uint8Array(object.buffer.slice(object.byteOffset, object.byteOffset + object.byteLength))
|
source = new Uint8Array(object.buffer.slice(object.byteOffset, object.byteOffset + object.byteLength))
|
||||||
} else if (util.isFormDataLike(object)) {
|
} else if (util.isFormDataLike(object)) {
|
||||||
const boundary = `----formdata-undici-0${`${Math.floor(Math.random() * 1e11)}`.padStart(11, '0')}`
|
const boundary = `----formdata-undici-0${`${random(1e11)}`.padStart(11, '0')}`
|
||||||
const prefix = `--${boundary}\r\nContent-Disposition: form-data`
|
const prefix = `--${boundary}\r\nContent-Disposition: form-data`
|
||||||
|
|
||||||
/*! formdata-polyfill. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> */
|
/*! formdata-polyfill. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> */
|
||||||
@@ -93147,7 +93155,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|||||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
exports.resolveStableVersionInput = exports.makeSemver = exports.getVersionsDist = exports.findMatch = exports.getInfoFromManifest = exports.getManifest = exports.extractGoArchive = exports.getGo = void 0;
|
exports.resolveStableVersionInput = exports.parseGoVersionFile = exports.makeSemver = exports.getVersionsDist = exports.findMatch = exports.getInfoFromManifest = exports.getManifest = exports.extractGoArchive = exports.getGo = void 0;
|
||||||
const tc = __importStar(__nccwpck_require__(7784));
|
const tc = __importStar(__nccwpck_require__(7784));
|
||||||
const core = __importStar(__nccwpck_require__(2186));
|
const core = __importStar(__nccwpck_require__(2186));
|
||||||
const path = __importStar(__nccwpck_require__(1017));
|
const path = __importStar(__nccwpck_require__(1017));
|
||||||
@@ -93471,6 +93479,16 @@ function makeSemver(version) {
|
|||||||
return fullVersion;
|
return fullVersion;
|
||||||
}
|
}
|
||||||
exports.makeSemver = makeSemver;
|
exports.makeSemver = makeSemver;
|
||||||
|
function parseGoVersionFile(versionFilePath) {
|
||||||
|
const contents = fs_1.default.readFileSync(versionFilePath).toString();
|
||||||
|
if (path.basename(versionFilePath) === 'go.mod' ||
|
||||||
|
path.basename(versionFilePath) === 'go.work') {
|
||||||
|
const match = contents.match(/^go (\d+(\.\d+)*)/m);
|
||||||
|
return match ? match[1] : '';
|
||||||
|
}
|
||||||
|
return contents.trim();
|
||||||
|
}
|
||||||
|
exports.parseGoVersionFile = parseGoVersionFile;
|
||||||
function resolveStableVersionDist(versionSpec, arch) {
|
function resolveStableVersionDist(versionSpec, arch) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
const archFilter = sys.getArch(arch);
|
const archFilter = sys.getArch(arch);
|
||||||
@@ -93670,22 +93688,18 @@ function parseGoVersion(versionString) {
|
|||||||
exports.parseGoVersion = parseGoVersion;
|
exports.parseGoVersion = parseGoVersion;
|
||||||
function resolveVersionInput() {
|
function resolveVersionInput() {
|
||||||
let version = core.getInput('go-version');
|
let version = core.getInput('go-version');
|
||||||
let versionFilePath = core.getInput('go-version-file');
|
const versionFilePath = core.getInput('go-version-file');
|
||||||
if (version && versionFilePath) {
|
if (version && versionFilePath) {
|
||||||
core.warning('Both go-version and go-version-file inputs are specified, only go-version will be used');
|
core.warning('Both go-version and go-version-file inputs are specified, only go-version will be used');
|
||||||
versionFilePath = '';
|
}
|
||||||
|
if (version) {
|
||||||
|
return version;
|
||||||
}
|
}
|
||||||
if (versionFilePath) {
|
if (versionFilePath) {
|
||||||
version = versionFilePath;
|
if (!fs_1.default.existsSync(versionFilePath)) {
|
||||||
}
|
throw new Error(`The specified go version file at: ${versionFilePath} does not exist`);
|
||||||
if (path_1.default.basename(version) === 'go.mod' ||
|
|
||||||
path_1.default.basename(version) === 'go.work') {
|
|
||||||
if (!fs_1.default.existsSync(version)) {
|
|
||||||
throw new Error(`The specified go version file at: ${version} does not exist`);
|
|
||||||
}
|
}
|
||||||
const contents = fs_1.default.readFileSync(version).toString();
|
version = installer.parseGoVersionFile(versionFilePath);
|
||||||
const match = contents.match(/^go (\d+(\.\d+)*)/m);
|
|
||||||
return match ? match[1] : '';
|
|
||||||
}
|
}
|
||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
@@ -93886,6 +93900,14 @@ module.exports = require("net");
|
|||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
||||||
|
/***/ 6005:
|
||||||
|
/***/ ((module) => {
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
module.exports = require("node:crypto");
|
||||||
|
|
||||||
|
/***/ }),
|
||||||
|
|
||||||
/***/ 5673:
|
/***/ 5673:
|
||||||
/***/ ((module) => {
|
/***/ ((module) => {
|
||||||
|
|
||||||
|
|||||||
7
package-lock.json
generated
7
package-lock.json
generated
@@ -5793,9 +5793,10 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/undici": {
|
"node_modules/undici": {
|
||||||
"version": "5.28.4",
|
"version": "5.28.5",
|
||||||
"resolved": "https://registry.npmjs.org/undici/-/undici-5.28.4.tgz",
|
"resolved": "https://registry.npmjs.org/undici/-/undici-5.28.5.tgz",
|
||||||
"integrity": "sha512-72RFADWFqKmUb2hmmvNODKL3p9hcB6Gt2DOQMis1SEBaV6a4MH8soBvzg+95CYhCKPFedut2JY9bMfrDl9D23g==",
|
"integrity": "sha512-zICwjrDrcrUE0pyyJc1I2QzBkLM8FINsgOrt6WjA+BgajVq9Nxu2PbFFXUrAggLfDXlZGZBVZYw7WNV5KiBiBA==",
|
||||||
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@fastify/busboy": "^2.0.0"
|
"@fastify/busboy": "^2.0.0"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -457,6 +457,20 @@ export function makeSemver(version: string): string {
|
|||||||
return fullVersion;
|
return fullVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function parseGoVersionFile(versionFilePath: string): string {
|
||||||
|
const contents = fs.readFileSync(versionFilePath).toString();
|
||||||
|
|
||||||
|
if (
|
||||||
|
path.basename(versionFilePath) === 'go.mod' ||
|
||||||
|
path.basename(versionFilePath) === 'go.work'
|
||||||
|
) {
|
||||||
|
const match = contents.match(/^go (\d+(\.\d+)*)/m);
|
||||||
|
return match ? match[1] : '';
|
||||||
|
}
|
||||||
|
|
||||||
|
return contents.trim();
|
||||||
|
}
|
||||||
|
|
||||||
async function resolveStableVersionDist(versionSpec: string, arch: string) {
|
async function resolveStableVersionDist(versionSpec: string, arch: string) {
|
||||||
const archFilter = sys.getArch(arch);
|
const archFilter = sys.getArch(arch);
|
||||||
const platFilter = sys.getPlatform();
|
const platFilter = sys.getPlatform();
|
||||||
|
|||||||
24
src/main.ts
24
src/main.ts
@@ -137,31 +137,25 @@ export function parseGoVersion(versionString: string): string {
|
|||||||
|
|
||||||
function resolveVersionInput(): string {
|
function resolveVersionInput(): string {
|
||||||
let version = core.getInput('go-version');
|
let version = core.getInput('go-version');
|
||||||
let versionFilePath = core.getInput('go-version-file');
|
const versionFilePath = core.getInput('go-version-file');
|
||||||
|
|
||||||
if (version && versionFilePath) {
|
if (version && versionFilePath) {
|
||||||
core.warning(
|
core.warning(
|
||||||
'Both go-version and go-version-file inputs are specified, only go-version will be used'
|
'Both go-version and go-version-file inputs are specified, only go-version will be used'
|
||||||
);
|
);
|
||||||
versionFilePath = '';
|
|
||||||
}
|
|
||||||
if (versionFilePath) {
|
|
||||||
version = versionFilePath;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (version) {
|
||||||
path.basename(version) === 'go.mod' ||
|
return version;
|
||||||
path.basename(version) === 'go.work'
|
}
|
||||||
) {
|
|
||||||
if (!fs.existsSync(version)) {
|
if (versionFilePath) {
|
||||||
|
if (!fs.existsSync(versionFilePath)) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`The specified go version file at: ${version} does not exist`
|
`The specified go version file at: ${versionFilePath} does not exist`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
version = installer.parseGoVersionFile(versionFilePath);
|
||||||
const contents = fs.readFileSync(version).toString();
|
|
||||||
const match = contents.match(/^go (\d+(\.\d+)*)/m);
|
|
||||||
return match ? match[1] : '';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return version;
|
return version;
|
||||||
|
|||||||
Reference in New Issue
Block a user