Merge pull request #35 from DeLaGuardo/34-add-missing-config-file

Use linux-install.sh for Linux and MacOS
This commit is contained in:
Kirill Chernyshov 2021-12-01 18:50:50 +01:00 committed by GitHub
commit 4b90301b8a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 2142 additions and 9203 deletions

View File

@ -65,7 +65,9 @@
"never"
],
"@typescript-eslint/type-annotation-spacing": "error",
"@typescript-eslint/unbound-method": "error"
"@typescript-eslint/unbound-method": "error",
"sort-imports": "off",
"i18n-text/no-en": "off"
},
"env": {
"node": true,

View File

@ -9,6 +9,7 @@ const tempDir = path.join(__dirname, 'runner', 'temp', 'boot')
process.env['RUNNER_TOOL_CACHE'] = toolDir
process.env['RUNNER_TEMP'] = tempDir
import * as boot from '../src/boot'
import {getCacheVersionString} from '../src/utils'
describe('boot tests', () => {
beforeAll(async () => {
@ -37,7 +38,12 @@ describe('boot tests', () => {
it('Install boot with normal version', async () => {
await boot.setup('2.8.3')
const clojureDir = path.join(toolDir, 'Boot', '2.8.3', os.arch())
const clojureDir = path.join(
toolDir,
'Boot',
getCacheVersionString('2.8.3'),
os.arch()
)
expect(fs.existsSync(`${clojureDir}.complete`)).toBe(true)
expect(fs.existsSync(path.join(clojureDir, 'bin', 'boot'))).toBe(true)
@ -45,7 +51,12 @@ describe('boot tests', () => {
it('Install latest boot', async () => {
await boot.setup('latest')
const clojureDir = path.join(toolDir, 'Boot', 'latest.0.0', os.arch())
const clojureDir = path.join(
toolDir,
'Boot',
getCacheVersionString('latest'),
os.arch()
)
expect(fs.existsSync(`${clojureDir}.complete`)).toBe(true)
expect(fs.existsSync(path.join(clojureDir, 'bin', 'boot'))).toBe(true)

View File

@ -9,6 +9,7 @@ const tempDir = path.join(__dirname, 'runner', 'temp', 'leiningen')
process.env['RUNNER_TOOL_CACHE'] = toolDir
process.env['RUNNER_TEMP'] = tempDir
import * as leiningen from '../src/leiningen'
import {getCacheVersionString} from '../src/utils'
describe('leiningen tests', () => {
beforeAll(async () => {
@ -37,7 +38,12 @@ describe('leiningen tests', () => {
it('Install leiningen with normal version', async () => {
await leiningen.setup('2.9.1')
const clojureDir = path.join(toolDir, 'Leiningen', '2.9.1', os.arch())
const clojureDir = path.join(
toolDir,
'Leiningen',
getCacheVersionString('2.9.1'),
os.arch()
)
expect(fs.existsSync(`${clojureDir}.complete`)).toBe(true)
expect(fs.existsSync(path.join(clojureDir, 'bin', 'lein'))).toBe(true)
@ -45,7 +51,12 @@ describe('leiningen tests', () => {
it('Install latest leiningen', async () => {
await leiningen.setup('latest')
const clojureDir = path.join(toolDir, 'Leiningen', 'latest.0.0', os.arch())
const clojureDir = path.join(
toolDir,
'Leiningen',
getCacheVersionString('latest'),
os.arch()
)
expect(fs.existsSync(`${clojureDir}.complete`)).toBe(true)
expect(fs.existsSync(path.join(clojureDir, 'bin', 'lein'))).toBe(true)

View File

@ -10,6 +10,7 @@ const tempDir = path.join(__dirname, 'runner', 'temp', 'tdeps')
process.env['RUNNER_TOOL_CACHE'] = toolDir
process.env['RUNNER_TEMP'] = tempDir
import * as tdeps from '../src/cli'
import {getCacheVersionString} from '../src/utils'
describe('tdeps tests', () => {
beforeAll(async () => {
@ -41,7 +42,7 @@ describe('tdeps tests', () => {
const clojureDir = path.join(
toolDir,
'ClojureToolsDeps',
'1.10.1-469',
getCacheVersionString('1.10.1.469'),
os.arch()
)
@ -54,7 +55,7 @@ describe('tdeps tests', () => {
const clojureDir = path.join(
toolDir,
'ClojureToolsDeps',
'latest.0.0',
getCacheVersionString('latest'),
os.arch()
)
@ -66,7 +67,7 @@ describe('tdeps tests', () => {
const clojureDir: string = path.join(
toolDir,
'ClojureToolsDeps',
'1.10.1-469',
getCacheVersionString('1.10.1.469'),
os.arch()
)
await io.mkdirP(clojureDir)

606
dist/index.js vendored
View File

@ -54,6 +54,25 @@ require('./sourcemap-register.js');module.exports =
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
@ -63,19 +82,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.findInPath = exports.which = exports.mkdirP = exports.rmRF = exports.mv = exports.cp = void 0;
const assert_1 = __webpack_require__(357);
const childProcess = __importStar(__webpack_require__(129));
const path = __importStar(__webpack_require__(622));
const util_1 = __webpack_require__(669);
const ioUtil = __importStar(__webpack_require__(672));
const exec = util_1.promisify(childProcess.exec);
const execFile = util_1.promisify(childProcess.execFile);
/**
* Copies a file or folder.
* Based off of shelljs - https://github.com/shelljs/shelljs/blob/9237f66c52e5daa40458f94f9565e18e8132f5a6/src/cp.js
@ -86,14 +101,14 @@ const exec = util_1.promisify(childProcess.exec);
*/
function cp(source, dest, options = {}) {
return __awaiter(this, void 0, void 0, function* () {
const { force, recursive } = readCopyOptions(options);
const { force, recursive, copySourceDirectory } = readCopyOptions(options);
const destStat = (yield ioUtil.exists(dest)) ? yield ioUtil.stat(dest) : null;
// Dest is an existing file, but not forcing
if (destStat && destStat.isFile() && !force) {
return;
}
// If dest is an existing directory, should copy inside.
const newDest = destStat && destStat.isDirectory()
const newDest = destStat && destStat.isDirectory() && copySourceDirectory
? path.join(dest, path.basename(source))
: dest;
if (!(yield ioUtil.exists(source))) {
@ -158,12 +173,22 @@ function rmRF(inputPath) {
if (ioUtil.IS_WINDOWS) {
// Node doesn't provide a delete operation, only an unlink function. This means that if the file is being used by another
// program (e.g. antivirus), it won't be deleted. To address this, we shell out the work to rd/del.
// Check for invalid characters
// https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file
if (/[*"<>|]/.test(inputPath)) {
throw new Error('File path must not contain `*`, `"`, `<`, `>` or `|` on Windows');
}
try {
const cmdPath = ioUtil.getCmdPath();
if (yield ioUtil.isDirectory(inputPath, true)) {
yield exec(`rd /s /q "${inputPath}"`);
yield exec(`${cmdPath} /s /c "rd /s /q "%inputPath%""`, {
env: { inputPath }
});
}
else {
yield exec(`del /f /a "${inputPath}"`);
yield exec(`${cmdPath} /s /c "del /f /a "%inputPath%""`, {
env: { inputPath }
});
}
}
catch (err) {
@ -196,7 +221,7 @@ function rmRF(inputPath) {
return;
}
if (isDir) {
yield exec(`rm -rf "${inputPath}"`);
yield execFile(`rm`, [`-rf`, `${inputPath}`]);
}
else {
yield ioUtil.unlink(inputPath);
@ -214,7 +239,8 @@ exports.rmRF = rmRF;
*/
function mkdirP(fsPath) {
return __awaiter(this, void 0, void 0, function* () {
yield ioUtil.mkdirP(fsPath);
assert_1.ok(fsPath, 'a path argument must be provided');
yield ioUtil.mkdir(fsPath, { recursive: true });
});
}
exports.mkdirP = mkdirP;
@ -312,7 +338,10 @@ exports.findInPath = findInPath;
function readCopyOptions(options) {
const force = options.force == null ? true : options.force;
const recursive = Boolean(options.recursive);
return { force, recursive };
const copySourceDirectory = options.copySourceDirectory == null
? true
: Boolean(options.copySourceDirectory);
return { force, recursive, copySourceDirectory };
}
function cpDirRecursive(sourceDir, destDir, currentDepth, force) {
return __awaiter(this, void 0, void 0, function* () {
@ -373,6 +402,25 @@ function copyFile(srcFile, destFile, force) {
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
@ -382,20 +430,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.argStringToArray = exports.ToolRunner = void 0;
const os = __importStar(__webpack_require__(87));
const events = __importStar(__webpack_require__(614));
const child = __importStar(__webpack_require__(129));
const path = __importStar(__webpack_require__(622));
const io = __importStar(__webpack_require__(1));
const ioUtil = __importStar(__webpack_require__(672));
const timers_1 = __webpack_require__(213);
/* eslint-disable @typescript-eslint/unbound-method */
const IS_WINDOWS = process.platform === 'win32';
/*
@ -465,11 +508,12 @@ class ToolRunner extends events.EventEmitter {
s = s.substring(n + os.EOL.length);
n = s.indexOf(os.EOL);
}
strBuffer = s;
return s;
}
catch (err) {
// streaming lines to console is best effort. Don't fail a build.
this._debug(`error processing line. Failed with error ${err}`);
return '';
}
}
_getSpawnFileName() {
@ -751,7 +795,7 @@ class ToolRunner extends events.EventEmitter {
// if the tool is only a file name, then resolve it from the PATH
// otherwise verify it exists (add extension on Windows if necessary)
this.toolPath = yield io.which(this.toolPath, true);
return new Promise((resolve, reject) => {
return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
this._debug(`exec tool: ${this.toolPath}`);
this._debug('arguments:');
for (const arg of this.args) {
@ -765,9 +809,12 @@ class ToolRunner extends events.EventEmitter {
state.on('debug', (message) => {
this._debug(message);
});
if (this.options.cwd && !(yield ioUtil.exists(this.options.cwd))) {
return reject(new Error(`The cwd: ${this.options.cwd} does not exist!`));
}
const fileName = this._getSpawnFileName();
const cp = child.spawn(fileName, this._getSpawnArgs(optionsNonNull), this._getSpawnOptions(this.options, fileName));
const stdbuffer = '';
let stdbuffer = '';
if (cp.stdout) {
cp.stdout.on('data', (data) => {
if (this.options.listeners && this.options.listeners.stdout) {
@ -776,14 +823,14 @@ class ToolRunner extends events.EventEmitter {
if (!optionsNonNull.silent && optionsNonNull.outStream) {
optionsNonNull.outStream.write(data);
}
this._processLineBuffer(data, stdbuffer, (line) => {
stdbuffer = this._processLineBuffer(data, stdbuffer, (line) => {
if (this.options.listeners && this.options.listeners.stdline) {
this.options.listeners.stdline(line);
}
});
});
}
const errbuffer = '';
let errbuffer = '';
if (cp.stderr) {
cp.stderr.on('data', (data) => {
state.processStderr = true;
@ -798,7 +845,7 @@ class ToolRunner extends events.EventEmitter {
: optionsNonNull.outStream;
s.write(data);
}
this._processLineBuffer(data, errbuffer, (line) => {
errbuffer = this._processLineBuffer(data, errbuffer, (line) => {
if (this.options.listeners && this.options.listeners.errline) {
this.options.listeners.errline(line);
}
@ -845,7 +892,7 @@ class ToolRunner extends events.EventEmitter {
}
cp.stdin.end(this.options.input);
}
});
}));
});
}
}
@ -931,7 +978,7 @@ class ExecState extends events.EventEmitter {
this._setResult();
}
else if (this.processExited) {
this.timeout = setTimeout(ExecState.HandleTimeout, this.delay, this);
this.timeout = timers_1.setTimeout(ExecState.HandleTimeout, this.delay, this);
}
}
_debug(message) {
@ -1085,8 +1132,13 @@ function _getOsVersion() {
const lines = lsbContents.split('\n');
for (const line of lines) {
const parts = line.split('=');
if (parts.length === 2 && parts[0].trim() === 'DISTRIB_RELEASE') {
version = parts[1].trim();
if (parts.length === 2 &&
(parts[0].trim() === 'VERSION_ID' ||
parts[0].trim() === 'DISTRIB_RELEASE')) {
version = parts[1]
.trim()
.replace(/^"/, '')
.replace(/"$/, '');
break;
}
}
@ -1096,10 +1148,14 @@ function _getOsVersion() {
}
exports._getOsVersion = _getOsVersion;
function _readLinuxVersionFile() {
const lsbFile = '/etc/lsb-release';
const lsbReleaseFile = '/etc/lsb-release';
const osReleaseFile = '/etc/os-release';
let contents = '';
if (fs.existsSync(lsbFile)) {
contents = fs.readFileSync(lsbFile).toString();
if (fs.existsSync(lsbReleaseFile)) {
contents = fs.readFileSync(lsbReleaseFile).toString();
}
else if (fs.existsSync(osReleaseFile)) {
contents = fs.readFileSync(osReleaseFile).toString();
}
return contents;
}
@ -1116,7 +1172,7 @@ exports._readLinuxVersionFile = _readLinuxVersionFile;
// We use any as a valid input type
/* eslint-disable @typescript-eslint/no-explicit-any */
Object.defineProperty(exports, "__esModule", { value: true });
exports.toCommandValue = void 0;
exports.toCommandProperties = exports.toCommandValue = void 0;
/**
* Sanitizes an input into a string so it can be passed into issueCommand safely
* @param input input to sanitize into a string
@ -1131,6 +1187,26 @@ function toCommandValue(input) {
return JSON.stringify(input);
}
exports.toCommandValue = toCommandValue;
/**
*
* @param annotationProperties
* @returns The command properties to send with the actual annotation command
* See IssueCommandProperties: https://github.com/actions/runner/blob/main/src/Runner.Worker/ActionCommandManager.cs#L646
*/
function toCommandProperties(annotationProperties) {
if (!Object.keys(annotationProperties).length) {
return {};
}
return {
title: annotationProperties.title,
file: annotationProperties.file,
line: annotationProperties.startLine,
endLine: annotationProperties.endLine,
col: annotationProperties.startColumn,
endColumn: annotationProperties.endColumn
};
}
exports.toCommandProperties = toCommandProperties;
//# sourceMappingURL=utils.js.map
/***/ }),
@ -1614,6 +1690,79 @@ function installBoot(binScript, destinationFolder, version) {
module.exports = require("https");
/***/ }),
/***/ 213:
/***/ (function(module) {
module.exports = require("timers");
/***/ }),
/***/ 226:
/***/ (function(__unusedmodule, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
class BasicCredentialHandler {
constructor(username, password) {
this.username = username;
this.password = password;
}
prepareRequest(options) {
options.headers['Authorization'] =
'Basic ' +
Buffer.from(this.username + ':' + this.password).toString('base64');
}
// This handler cannot handle 401
canHandleAuthentication(response) {
return false;
}
handleAuthentication(httpClient, requestInfo, objs) {
return null;
}
}
exports.BasicCredentialHandler = BasicCredentialHandler;
class BearerCredentialHandler {
constructor(token) {
this.token = token;
}
// currently implements pre-authorization
// TODO: support preAuth = false where it hooks on 401
prepareRequest(options) {
options.headers['Authorization'] = 'Bearer ' + this.token;
}
// This handler cannot handle 401
canHandleAuthentication(response) {
return false;
}
handleAuthentication(httpClient, requestInfo, objs) {
return null;
}
}
exports.BearerCredentialHandler = BearerCredentialHandler;
class PersonalAccessTokenCredentialHandler {
constructor(token) {
this.token = token;
}
// currently implements pre-authorization
// TODO: support preAuth = false where it hooks on 401
prepareRequest(options) {
options.headers['Authorization'] =
'Basic ' + Buffer.from('PAT:' + this.token).toString('base64');
}
// This handler cannot handle 401
canHandleAuthentication(response) {
return false;
}
handleAuthentication(httpClient, requestInfo, objs) {
return null;
}
}
exports.PersonalAccessTokenCredentialHandler = PersonalAccessTokenCredentialHandler;
/***/ }),
/***/ 280:
@ -3217,6 +3366,13 @@ function coerce (version, options) {
}
/***/ }),
/***/ 304:
/***/ (function(module) {
module.exports = require("string_decoder");
/***/ }),
/***/ 357:
@ -3560,12 +3716,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getState = exports.saveState = exports.group = exports.endGroup = exports.startGroup = exports.info = exports.warning = exports.error = exports.debug = exports.isDebug = exports.setFailed = exports.setCommandEcho = exports.setOutput = exports.getBooleanInput = exports.getInput = exports.addPath = exports.setSecret = exports.exportVariable = exports.ExitCode = void 0;
exports.getIDToken = exports.getState = exports.saveState = exports.group = exports.endGroup = exports.startGroup = exports.info = exports.notice = exports.warning = exports.error = exports.debug = exports.isDebug = exports.setFailed = exports.setCommandEcho = exports.setOutput = exports.getBooleanInput = exports.getMultilineInput = exports.getInput = exports.addPath = exports.setSecret = exports.exportVariable = exports.ExitCode = void 0;
const command_1 = __webpack_require__(431);
const file_command_1 = __webpack_require__(102);
const utils_1 = __webpack_require__(82);
const os = __importStar(__webpack_require__(87));
const path = __importStar(__webpack_require__(622));
const oidc_utils_1 = __webpack_require__(742);
/**
* The code to exit an action
*/
@ -3646,6 +3803,21 @@ function getInput(name, options) {
return val.trim();
}
exports.getInput = getInput;
/**
* Gets the values of an multiline input. Each value is also trimmed.
*
* @param name name of the input to get
* @param options optional. See InputOptions.
* @returns string[]
*
*/
function getMultilineInput(name, options) {
const inputs = getInput(name, options)
.split('\n')
.filter(x => x !== '');
return inputs;
}
exports.getMultilineInput = getMultilineInput;
/**
* Gets the input value of the boolean type in the YAML 1.2 "core schema" specification.
* Support boolean input list: `true | True | TRUE | false | False | FALSE` .
@ -3723,19 +3895,30 @@ exports.debug = debug;
/**
* Adds an error issue
* @param message error issue message. Errors will be converted to string via toString()
* @param properties optional properties to add to the annotation.
*/
function error(message) {
command_1.issue('error', message instanceof Error ? message.toString() : message);
function error(message, properties = {}) {
command_1.issueCommand('error', utils_1.toCommandProperties(properties), message instanceof Error ? message.toString() : message);
}
exports.error = error;
/**
* Adds an warning issue
* Adds a warning issue
* @param message warning issue message. Errors will be converted to string via toString()
* @param properties optional properties to add to the annotation.
*/
function warning(message) {
command_1.issue('warning', message instanceof Error ? message.toString() : message);
function warning(message, properties = {}) {
command_1.issueCommand('warning', utils_1.toCommandProperties(properties), message instanceof Error ? message.toString() : message);
}
exports.warning = warning;
/**
* Adds a notice issue
* @param message notice issue message. Errors will be converted to string via toString()
* @param properties optional properties to add to the annotation.
*/
function notice(message, properties = {}) {
command_1.issueCommand('notice', utils_1.toCommandProperties(properties), message instanceof Error ? message.toString() : message);
}
exports.notice = notice;
/**
* Writes info to log with console.log.
* @param message info message
@ -3808,6 +3991,12 @@ function getState(name) {
return process.env[`STATE_${name}`] || '';
}
exports.getState = getState;
function getIDToken(aud) {
return __awaiter(this, void 0, void 0, function* () {
return yield oidc_utils_1.OidcClient.getIDToken(aud);
});
}
exports.getIDToken = getIDToken;
//# sourceMappingURL=core.js.map
/***/ }),
@ -3863,9 +4052,12 @@ function setup(version) {
core.info(`Clojure CLI found in cache ${toolPath}`);
}
else {
const clojureToolsFile = yield tc.downloadTool(`https://download.clojure.org/install/clojure-tools${version === 'latest' ? '' : `-${version}`}.tar.gz`);
const tempDir = path.join(tempDirectory, `temp_${Math.floor(Math.random() * 2000000000)}`);
const clojureToolsDir = yield installClojureToolsDeps(clojureToolsFile, tempDir);
const clojureInstallScript = yield tc.downloadTool(`https://download.clojure.org/install/linux-install${version === 'latest' ? '' : `-${version}`}.sh`);
if (utils.isMacOS()) {
yield MacOSDeps(clojureInstallScript);
}
const clojureToolsDir = yield runLinuxInstall(clojureInstallScript, tempDir);
core.debug(`clojure tools deps installed to ${clojureToolsDir}`);
toolPath = yield tc.cacheDir(clojureToolsDir, 'ClojureToolsDeps', utils.getCacheVersionString(version));
}
@ -3875,6 +4067,28 @@ function setup(version) {
});
}
exports.setup = setup;
function runLinuxInstall(installScript, destinationFolder) {
return __awaiter(this, void 0, void 0, function* () {
yield io.mkdirP(destinationFolder);
const file = path.normalize(installScript);
yield exec.exec('bash', [file, '--prefix', destinationFolder]);
return destinationFolder;
});
}
function MacOSDeps(file) {
return __awaiter(this, void 0, void 0, function* () {
fs.readFile(file, 'utf-8', function (err, data) {
if (err)
throw err;
const newValue = data.replace(/install -D/gim, '$(brew --prefix coreutils)/bin/ginstall -D');
fs.writeFile(file, newValue, 'utf-8', function (e) {
if (e)
throw e;
});
});
yield exec.exec(`brew install coreutils`);
});
}
function setupWindows(version) {
return __awaiter(this, void 0, void 0, function* () {
const url = `download.clojure.org/install/win-install-${version}.ps1`;
@ -3884,53 +4098,6 @@ function setupWindows(version) {
});
}
exports.setupWindows = setupWindows;
function installClojureToolsDeps(installScript, destinationFolder) {
return __awaiter(this, void 0, void 0, function* () {
yield io.mkdirP(destinationFolder);
const file = path.normalize(installScript);
const stats = fs.statSync(file);
if (stats.isFile()) {
const binDir = path.join(destinationFolder, 'clojure', 'bin');
const libDir = path.join(destinationFolder, 'clojure', 'lib');
const manDir = path.join(destinationFolder, 'clojure', 'share', 'man', 'man1');
const clojureLibDir = path.join(libDir, 'clojure');
const clojureLibexecDir = path.join(clojureLibDir, 'libexec');
yield tc.extractTar(file, destinationFolder);
const sourceDir = path.join(destinationFolder, 'clojure-tools');
yield io.mkdirP(binDir);
yield io.mkdirP(manDir);
yield io.mkdirP(clojureLibexecDir);
yield io.mv(path.join(sourceDir, 'deps.edn'), clojureLibDir);
yield io.mv(path.join(sourceDir, 'example-deps.edn'), clojureLibDir);
yield Promise.all(fs
.readdirSync(sourceDir)
.filter(f => f.endsWith('jar'))
.map((f) => __awaiter(this, void 0, void 0, function* () { return yield io.mv(path.join(sourceDir, f), clojureLibexecDir); })));
yield readWriteAsync(path.join(sourceDir, 'clojure'), '"$CLOJURE_INSTALL_DIR"');
yield io.mv(path.join(sourceDir, 'clj'), binDir);
yield io.mv(path.join(sourceDir, 'clojure'), binDir);
yield io.mv(path.join(sourceDir, 'clojure.1'), manDir);
yield io.mv(path.join(sourceDir, 'clj.1'), manDir);
return path.join(destinationFolder, 'clojure');
}
else {
throw new Error(`Not a file`);
}
});
}
function readWriteAsync(file, replacement) {
return __awaiter(this, void 0, void 0, function* () {
fs.readFile(file, 'utf-8', function (err, data) {
if (err)
throw err;
const newValue = data.replace(/PREFIX/gim, replacement);
fs.writeFile(file, newValue, 'utf-8', function (e) {
if (e)
throw e;
});
});
});
}
/***/ }),
@ -5040,7 +5207,9 @@ class HttpClient {
maxSockets: maxSockets,
keepAlive: this._keepAlive,
proxy: {
proxyAuth: `${proxyUrl.username}:${proxyUrl.password}`,
...((proxyUrl.username || proxyUrl.password) && {
proxyAuth: `${proxyUrl.username}:${proxyUrl.password}`
}),
host: proxyUrl.hostname,
port: proxyUrl.port
}
@ -5182,14 +5351,15 @@ var __importStar = (this && this.__importStar) || function (mod) {
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.isWindows = exports.getTempDir = exports.getCacheVersionString = void 0;
exports.isMacOS = exports.isWindows = exports.getTempDir = exports.getCacheVersionString = void 0;
const path = __importStar(__webpack_require__(622));
const version_1 = __webpack_require__(775);
function getCacheVersionString(version) {
const versionArray = version.split('.');
const major = versionArray[0];
const minor = versionArray.length > 1 ? versionArray[1] : '0';
const patch = versionArray.length > 2 ? versionArray.slice(2).join('-') : '0';
return `${major}.${minor}.${patch}`;
return `${major}.${minor}.${patch}-${version_1.VERSION}`;
}
exports.getCacheVersionString = getCacheVersionString;
function getTempDir() {
@ -5219,6 +5389,10 @@ function isWindows() {
return process.platform === 'win32';
}
exports.isWindows = isWindows;
function isMacOS() {
return process.platform === 'darwin';
}
exports.isMacOS = isMacOS;
/***/ }),
@ -5256,6 +5430,25 @@ module.exports = require("util");
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
@ -5265,16 +5458,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
var _a;
Object.defineProperty(exports, "__esModule", { value: true });
const assert_1 = __webpack_require__(357);
exports.getCmdPath = exports.tryGetExecutablePath = exports.isRooted = exports.isDirectory = exports.exists = exports.IS_WINDOWS = exports.unlink = exports.symlink = exports.stat = exports.rmdir = exports.rename = exports.readlink = exports.readdir = exports.mkdir = exports.lstat = exports.copyFile = exports.chmod = void 0;
const fs = __importStar(__webpack_require__(747));
const path = __importStar(__webpack_require__(622));
_a = fs.promises, exports.chmod = _a.chmod, exports.copyFile = _a.copyFile, exports.lstat = _a.lstat, exports.mkdir = _a.mkdir, exports.readdir = _a.readdir, exports.readlink = _a.readlink, exports.rename = _a.rename, exports.rmdir = _a.rmdir, exports.stat = _a.stat, exports.symlink = _a.symlink, exports.unlink = _a.unlink;
@ -5317,49 +5503,6 @@ function isRooted(p) {
return p.startsWith('/');
}
exports.isRooted = isRooted;
/**
* Recursively create a directory at `fsPath`.
*
* This implementation is optimistic, meaning it attempts to create the full
* path first, and backs up the path stack from there.
*
* @param fsPath The path to create
* @param maxDepth The maximum recursion depth
* @param depth The current recursion depth
*/
function mkdirP(fsPath, maxDepth = 1000, depth = 1) {
return __awaiter(this, void 0, void 0, function* () {
assert_1.ok(fsPath, 'a path argument must be provided');
fsPath = path.resolve(fsPath);
if (depth >= maxDepth)
return exports.mkdir(fsPath);
try {
yield exports.mkdir(fsPath);
return;
}
catch (err) {
switch (err.code) {
case 'ENOENT': {
yield mkdirP(path.dirname(fsPath), maxDepth, depth + 1);
yield exports.mkdir(fsPath);
return;
}
default: {
let stats;
try {
stats = yield exports.stat(fsPath);
}
catch (err2) {
throw err;
}
if (!stats.isDirectory())
throw err;
}
}
}
});
}
exports.mkdirP = mkdirP;
/**
* Best effort attempt to determine whether a file exists and is executable.
* @param filePath file path to check
@ -5456,6 +5599,12 @@ function isUnixExecutable(stats) {
((stats.mode & 8) > 0 && stats.gid === process.getgid()) ||
((stats.mode & 64) > 0 && stats.uid === process.getuid()));
}
// Get the path of cmd.exe in windows
function getCmdPath() {
var _a;
return (_a = process.env['COMSPEC']) !== null && _a !== void 0 ? _a : `cmd.exe`;
}
exports.getCmdPath = getCmdPath;
//# sourceMappingURL=io-util.js.map
/***/ }),
@ -5491,6 +5640,90 @@ function bytesToUuid(buf, offset) {
module.exports = bytesToUuid;
/***/ }),
/***/ 742:
/***/ (function(__unusedmodule, exports, __webpack_require__) {
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.OidcClient = void 0;
const http_client_1 = __webpack_require__(539);
const auth_1 = __webpack_require__(226);
const core_1 = __webpack_require__(470);
class OidcClient {
static createHttpClient(allowRetry = true, maxRetry = 10) {
const requestOptions = {
allowRetries: allowRetry,
maxRetries: maxRetry
};
return new http_client_1.HttpClient('actions/oidc-client', [new auth_1.BearerCredentialHandler(OidcClient.getRequestToken())], requestOptions);
}
static getRequestToken() {
const token = process.env['ACTIONS_ID_TOKEN_REQUEST_TOKEN'];
if (!token) {
throw new Error('Unable to get ACTIONS_ID_TOKEN_REQUEST_TOKEN env variable');
}
return token;
}
static getIDTokenUrl() {
const runtimeUrl = process.env['ACTIONS_ID_TOKEN_REQUEST_URL'];
if (!runtimeUrl) {
throw new Error('Unable to get ACTIONS_ID_TOKEN_REQUEST_URL env variable');
}
return runtimeUrl;
}
static getCall(id_token_url) {
var _a;
return __awaiter(this, void 0, void 0, function* () {
const httpclient = OidcClient.createHttpClient();
const res = yield httpclient
.getJson(id_token_url)
.catch(error => {
throw new Error(`Failed to get ID Token. \n
Error Code : ${error.statusCode}\n
Error Message: ${error.result.message}`);
});
const id_token = (_a = res.result) === null || _a === void 0 ? void 0 : _a.value;
if (!id_token) {
throw new Error('Response json body do not have ID Token field');
}
return id_token;
});
}
static getIDToken(audience) {
return __awaiter(this, void 0, void 0, function* () {
try {
// New ID Token is requested from action service
let id_token_url = OidcClient.getIDTokenUrl();
if (audience) {
const encodedAudience = encodeURIComponent(audience);
id_token_url = `${id_token_url}&audience=${encodedAudience}`;
}
core_1.debug(`ID token url is ${id_token_url}`);
const id_token = yield OidcClient.getCall(id_token_url);
core_1.setSecret(id_token);
return id_token;
}
catch (error) {
throw new Error(`Error message: ${error.message}`);
}
});
}
}
exports.OidcClient = OidcClient;
//# sourceMappingURL=oidc-utils.js.map
/***/ }),
/***/ 747:
@ -5498,6 +5731,18 @@ module.exports = bytesToUuid;
module.exports = require("fs");
/***/ }),
/***/ 775:
/***/ (function(__unusedmodule, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.VERSION = void 0;
exports.VERSION = '3-6';
/***/ }),
/***/ 794:
@ -5703,6 +5948,25 @@ exports.RetryHelper = RetryHelper;
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
@ -5712,14 +5976,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getExecOutput = exports.exec = void 0;
const string_decoder_1 = __webpack_require__(304);
const tr = __importStar(__webpack_require__(9));
/**
* Exec a command.
@ -5745,6 +6004,51 @@ function exec(commandLine, args, options) {
});
}
exports.exec = exec;
/**
* Exec a command and get the output.
* Output will be streamed to the live console.
* Returns promise with the exit code and collected stdout and stderr
*
* @param commandLine command to execute (can include additional args). Must be correctly escaped.
* @param args optional arguments for tool. Escaping is handled by the lib.
* @param options optional exec options. See ExecOptions
* @returns Promise<ExecOutput> exit code, stdout, and stderr
*/
function getExecOutput(commandLine, args, options) {
var _a, _b;
return __awaiter(this, void 0, void 0, function* () {
let stdout = '';
let stderr = '';
//Using string decoder covers the case where a mult-byte character is split
const stdoutDecoder = new string_decoder_1.StringDecoder('utf8');
const stderrDecoder = new string_decoder_1.StringDecoder('utf8');
const originalStdoutListener = (_a = options === null || options === void 0 ? void 0 : options.listeners) === null || _a === void 0 ? void 0 : _a.stdout;
const originalStdErrListener = (_b = options === null || options === void 0 ? void 0 : options.listeners) === null || _b === void 0 ? void 0 : _b.stderr;
const stdErrListener = (data) => {
stderr += stderrDecoder.write(data);
if (originalStdErrListener) {
originalStdErrListener(data);
}
};
const stdOutListener = (data) => {
stdout += stdoutDecoder.write(data);
if (originalStdoutListener) {
originalStdoutListener(data);
}
};
const listeners = Object.assign(Object.assign({}, options === null || options === void 0 ? void 0 : options.listeners), { stdout: stdOutListener, stderr: stdErrListener });
const exitCode = yield exec(commandLine, args, Object.assign(Object.assign({}, options), { listeners }));
//flush any remaining characters
stdout += stdoutDecoder.end();
stderr += stderrDecoder.end();
return {
exitCode,
stdout,
stderr
};
});
}
exports.getExecOutput = getExecOutput;
//# sourceMappingURL=exec.js.map
/***/ })

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

10562
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -25,25 +25,25 @@
"author": "DeLaGuardo",
"license": "MIT",
"dependencies": {
"@actions/core": "^1.3.0",
"@actions/exec": "^1.0.4",
"@actions/io": "^1.1.0",
"@actions/tool-cache": "^1.7.0"
"@actions/core": "^1.6.0",
"@actions/exec": "^1.1.0",
"@actions/io": "^1.1.1",
"@actions/tool-cache": "^1.7.1"
},
"devDependencies": {
"@types/jest": "^26.0.23",
"@types/node": "^15.6.1",
"@types/semver": "^7.3.6",
"@typescript-eslint/parser": "^4.26.0",
"@types/jest": "^27.0.3",
"@types/node": "^16.11.11",
"@types/semver": "^7.3.9",
"@typescript-eslint/parser": "^5.5.0",
"@zeit/ncc": "^0.22.3",
"eslint": "^7.27.0",
"eslint-plugin-github": "^4.1.3",
"eslint-plugin-jest": "^24.3.6",
"jest": "^27.0.3",
"jest-circus": "^27.0.3",
"eslint": "^8.3.0",
"eslint-plugin-github": "^4.3.5",
"eslint-plugin-jest": "^25.3.0",
"jest": "^27.4.3",
"jest-circus": "^27.4.2",
"js-yaml": "^4.1.0",
"prettier": "2.3.0",
"ts-jest": "^27.0.2",
"typescript": "^4.3.2"
"prettier": "2.5.0",
"ts-jest": "^27.0.7",
"typescript": "^4.5.2"
}
}

View File

@ -19,19 +19,21 @@ export async function setup(version: string): Promise<void> {
if (toolPath && version !== 'latest') {
core.info(`Clojure CLI found in cache ${toolPath}`)
} else {
const clojureToolsFile = await tc.downloadTool(
`https://download.clojure.org/install/clojure-tools${
version === 'latest' ? '' : `-${version}`
}.tar.gz`
)
const tempDir: string = path.join(
tempDirectory,
`temp_${Math.floor(Math.random() * 2000000000)}`
)
const clojureToolsDir = await installClojureToolsDeps(
clojureToolsFile,
tempDir
const clojureInstallScript = await tc.downloadTool(
`https://download.clojure.org/install/linux-install${
version === 'latest' ? '' : `-${version}`
}.sh`
)
if (utils.isMacOS()) {
await MacOSDeps(clojureInstallScript)
}
const clojureToolsDir = await runLinuxInstall(clojureInstallScript, tempDir)
core.debug(`clojure tools deps installed to ${clojureToolsDir}`)
toolPath = await tc.cacheDir(
clojureToolsDir,
@ -45,79 +47,37 @@ export async function setup(version: string): Promise<void> {
core.addPath(path.join(toolPath, 'bin'))
}
export async function setupWindows(version: string): Promise<void> {
const url = `download.clojure.org/install/win-install-${version}.ps1`
exec.exec(`powershell -c "iwr -useb ${url} | iex"`, [], {
input: Buffer.from('1')
})
}
async function installClojureToolsDeps(
async function runLinuxInstall(
installScript: string,
destinationFolder: string
): Promise<string> {
await io.mkdirP(destinationFolder)
const file = path.normalize(installScript)
const stats = fs.statSync(file)
if (stats.isFile()) {
const binDir = path.join(destinationFolder, 'clojure', 'bin')
const libDir = path.join(destinationFolder, 'clojure', 'lib')
const manDir = path.join(
destinationFolder,
'clojure',
'share',
'man',
'man1'
)
const clojureLibDir = path.join(libDir, 'clojure')
const clojureLibexecDir = path.join(clojureLibDir, 'libexec')
await exec.exec('bash', [file, '--prefix', destinationFolder])
await tc.extractTar(file, destinationFolder)
const sourceDir = path.join(destinationFolder, 'clojure-tools')
await io.mkdirP(binDir)
await io.mkdirP(manDir)
await io.mkdirP(clojureLibexecDir)
await io.mv(path.join(sourceDir, 'deps.edn'), clojureLibDir)
await io.mv(path.join(sourceDir, 'example-deps.edn'), clojureLibDir)
await Promise.all(
fs
.readdirSync(sourceDir)
.filter(f => f.endsWith('jar'))
.map(
async (f): Promise<void> =>
await io.mv(path.join(sourceDir, f), clojureLibexecDir)
)
)
await readWriteAsync(
path.join(sourceDir, 'clojure'),
'"$CLOJURE_INSTALL_DIR"'
)
await io.mv(path.join(sourceDir, 'clj'), binDir)
await io.mv(path.join(sourceDir, 'clojure'), binDir)
await io.mv(path.join(sourceDir, 'clojure.1'), manDir)
await io.mv(path.join(sourceDir, 'clj.1'), manDir)
return path.join(destinationFolder, 'clojure')
} else {
throw new Error(`Not a file`)
}
return destinationFolder
}
async function readWriteAsync(
file: string,
replacement: string
): Promise<void> {
async function MacOSDeps(file: string): Promise<void> {
fs.readFile(file, 'utf-8', function (err, data) {
if (err) throw err
const newValue = data.replace(/PREFIX/gim, replacement)
const newValue = data.replace(
/install -D/gim,
'$(brew --prefix coreutils)/bin/ginstall -D'
)
fs.writeFile(file, newValue, 'utf-8', function (e) {
if (e) throw e
})
})
await exec.exec(`brew install coreutils`)
}
export async function setupWindows(version: string): Promise<void> {
const url = `download.clojure.org/install/win-install-${version}.ps1`
exec.exec(`powershell -c "iwr -useb ${url} | iex"`, [], {
input: Buffer.from('1')
})
}

View File

@ -43,7 +43,7 @@ async function run(): Promise<void> {
throw new Error('You must specify at least one clojure tool.')
}
} catch (error) {
core.setFailed(error.message)
core.setFailed((error as Error).message)
}
}

View File

@ -1,11 +1,12 @@
import * as path from 'path'
import {VERSION} from './version'
export function getCacheVersionString(version: string): string {
const versionArray = version.split('.')
const major = versionArray[0]
const minor = versionArray.length > 1 ? versionArray[1] : '0'
const patch = versionArray.length > 2 ? versionArray.slice(2).join('-') : '0'
return `${major}.${minor}.${patch}`
return `${major}.${minor}.${patch}-${VERSION}`
}
export function getTempDir(): string {
@ -32,3 +33,7 @@ export function getTempDir(): string {
export function isWindows(): boolean {
return process.platform === 'win32'
}
export function isMacOS(): boolean {
return process.platform === 'darwin'
}

1
src/version.ts Normal file
View File

@ -0,0 +1 @@
export const VERSION = '3-6'