Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
76f84c1a27 | ||
|
|
28ef0db7df |
@@ -1,4 +1,5 @@
|
|||||||
import * as install from '../src/cache';
|
import * as install from '../src/cache';
|
||||||
|
import * as utils from '../src/utils';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mock cache.ts
|
* Mock cache.ts
|
||||||
@@ -6,8 +7,11 @@ import * as install from '../src/cache';
|
|||||||
jest.mock('../src/cache', () => ({
|
jest.mock('../src/cache', () => ({
|
||||||
run: jest.fn().mockImplementation(
|
run: jest.fn().mockImplementation(
|
||||||
async (): Promise<string> => {
|
async (): Promise<string> => {
|
||||||
const version: string = process.env['php-version'] || '';
|
let version: string = process.env['php-version'] || '';
|
||||||
const extensions: string = process.env['extensions'] || '';
|
version = version.length > 1 ? version.slice(0, 3) : version + '.0';
|
||||||
|
const extensions = await utils.filterExtensions(
|
||||||
|
process.env['extensions'] || ''
|
||||||
|
);
|
||||||
const key: string = process.env['key'] || '';
|
const key: string = process.env['key'] || '';
|
||||||
const script_path = 'extensions.sh';
|
const script_path = 'extensions.sh';
|
||||||
|
|
||||||
@@ -22,10 +26,8 @@ jest.mock('../src/cache', () => ({
|
|||||||
* Function to set the process.env
|
* Function to set the process.env
|
||||||
*
|
*
|
||||||
* @param version
|
* @param version
|
||||||
* @param os
|
* @param extensions
|
||||||
* @param extension_csv
|
* @param key
|
||||||
* @param ini_values_csv
|
|
||||||
* @param coverage_driver
|
|
||||||
*/
|
*/
|
||||||
function setEnv(
|
function setEnv(
|
||||||
version: string | number,
|
version: string | number,
|
||||||
@@ -51,4 +53,11 @@ describe('Install', () => {
|
|||||||
const script: string = await install.run();
|
const script: string = await install.run();
|
||||||
expect(script).toContain('bash extensions.sh "xdebug, zip" cache-v2 7.4');
|
expect(script).toContain('bash extensions.sh "xdebug, zip" cache-v2 7.4');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('Test Run', async () => {
|
||||||
|
setEnv('7.4', 'xdebug, :zip', 'cache-v2');
|
||||||
|
// @ts-ignore
|
||||||
|
const script: string = await install.run();
|
||||||
|
expect(script).toContain('bash extensions.sh "xdebug" cache-v2 7.4');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
import * as fs from 'fs';
|
|
||||||
import * as path from 'path';
|
|
||||||
import * as utils from '../src/utils';
|
import * as utils from '../src/utils';
|
||||||
|
|
||||||
jest.mock('@actions/core', () => ({
|
jest.mock('@actions/core', () => ({
|
||||||
@@ -19,4 +17,9 @@ describe('Utils tests', () => {
|
|||||||
);
|
);
|
||||||
expect(await utils.getInput('DoesNotExist', false)).toBe('');
|
expect(await utils.getInput('DoesNotExist', false)).toBe('');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('checking filterExtensions', async () => {
|
||||||
|
expect(await utils.filterExtensions('a,:b,c')).toBe('a,c');
|
||||||
|
expect(await utils.filterExtensions('a, :b, c')).toBe('a, c');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
101
dist/index.js
vendored
101
dist/index.js
vendored
@@ -354,13 +354,20 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|||||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
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 });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
const os = __webpack_require__(87);
|
const os = __importStar(__webpack_require__(87));
|
||||||
const events = __webpack_require__(614);
|
const events = __importStar(__webpack_require__(614));
|
||||||
const child = __webpack_require__(129);
|
const child = __importStar(__webpack_require__(129));
|
||||||
const path = __webpack_require__(622);
|
const path = __importStar(__webpack_require__(622));
|
||||||
const io = __webpack_require__(1);
|
const io = __importStar(__webpack_require__(1));
|
||||||
const ioUtil = __webpack_require__(672);
|
const ioUtil = __importStar(__webpack_require__(672));
|
||||||
/* eslint-disable @typescript-eslint/unbound-method */
|
/* eslint-disable @typescript-eslint/unbound-method */
|
||||||
const IS_WINDOWS = process.platform === 'win32';
|
const IS_WINDOWS = process.platform === 'win32';
|
||||||
/*
|
/*
|
||||||
@@ -804,6 +811,12 @@ class ToolRunner extends events.EventEmitter {
|
|||||||
resolve(exitCode);
|
resolve(exitCode);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
if (this.options.input) {
|
||||||
|
if (!cp.stdin) {
|
||||||
|
throw new Error('child process missing stdin');
|
||||||
|
}
|
||||||
|
cp.stdin.end(this.options.input);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -990,6 +1003,22 @@ function getInput(name, mandatory) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
exports.getInput = getInput;
|
exports.getInput = getInput;
|
||||||
|
/**
|
||||||
|
* Function to filter extensions
|
||||||
|
*
|
||||||
|
* @param extension_csv
|
||||||
|
*/
|
||||||
|
function filterExtensions(extension_csv) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
return extension_csv
|
||||||
|
.split(',')
|
||||||
|
.filter(extension => {
|
||||||
|
return extension.trim()[0] != ':';
|
||||||
|
})
|
||||||
|
.join(',');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
exports.filterExtensions = filterExtensions;
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
@@ -1068,14 +1097,28 @@ class Command {
|
|||||||
return cmdStr;
|
return cmdStr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Sanitizes an input into a string so it can be passed into issueCommand safely
|
||||||
|
* @param input input to sanitize into a string
|
||||||
|
*/
|
||||||
|
function toCommandValue(input) {
|
||||||
|
if (input === null || input === undefined) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
else if (typeof input === 'string' || input instanceof String) {
|
||||||
|
return input;
|
||||||
|
}
|
||||||
|
return JSON.stringify(input);
|
||||||
|
}
|
||||||
|
exports.toCommandValue = toCommandValue;
|
||||||
function escapeData(s) {
|
function escapeData(s) {
|
||||||
return (s || '')
|
return toCommandValue(s)
|
||||||
.replace(/%/g, '%25')
|
.replace(/%/g, '%25')
|
||||||
.replace(/\r/g, '%0D')
|
.replace(/\r/g, '%0D')
|
||||||
.replace(/\n/g, '%0A');
|
.replace(/\n/g, '%0A');
|
||||||
}
|
}
|
||||||
function escapeProperty(s) {
|
function escapeProperty(s) {
|
||||||
return (s || '')
|
return toCommandValue(s)
|
||||||
.replace(/%/g, '%25')
|
.replace(/%/g, '%25')
|
||||||
.replace(/\r/g, '%0D')
|
.replace(/\r/g, '%0D')
|
||||||
.replace(/\n/g, '%0A')
|
.replace(/\n/g, '%0A')
|
||||||
@@ -1131,11 +1174,13 @@ var ExitCode;
|
|||||||
/**
|
/**
|
||||||
* Sets env variable for this action and future actions in the job
|
* Sets env variable for this action and future actions in the job
|
||||||
* @param name the name of the variable to set
|
* @param name the name of the variable to set
|
||||||
* @param val the value of the variable
|
* @param val the value of the variable. Non-string values will be converted to a string via JSON.stringify
|
||||||
*/
|
*/
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
function exportVariable(name, val) {
|
function exportVariable(name, val) {
|
||||||
process.env[name] = val;
|
const convertedVal = command_1.toCommandValue(val);
|
||||||
command_1.issueCommand('set-env', { name }, val);
|
process.env[name] = convertedVal;
|
||||||
|
command_1.issueCommand('set-env', { name }, convertedVal);
|
||||||
}
|
}
|
||||||
exports.exportVariable = exportVariable;
|
exports.exportVariable = exportVariable;
|
||||||
/**
|
/**
|
||||||
@@ -1174,12 +1219,22 @@ exports.getInput = getInput;
|
|||||||
* Sets the value of an output.
|
* Sets the value of an output.
|
||||||
*
|
*
|
||||||
* @param name name of the output to set
|
* @param name name of the output to set
|
||||||
* @param value value to store
|
* @param value value to store. Non-string values will be converted to a string via JSON.stringify
|
||||||
*/
|
*/
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
function setOutput(name, value) {
|
function setOutput(name, value) {
|
||||||
command_1.issueCommand('set-output', { name }, value);
|
command_1.issueCommand('set-output', { name }, value);
|
||||||
}
|
}
|
||||||
exports.setOutput = setOutput;
|
exports.setOutput = setOutput;
|
||||||
|
/**
|
||||||
|
* Enables or disables the echoing of commands into stdout for the rest of the step.
|
||||||
|
* Echoing is disabled by default if ACTIONS_STEP_DEBUG is not set.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
function setCommandEcho(enabled) {
|
||||||
|
command_1.issue('echo', enabled ? 'on' : 'off');
|
||||||
|
}
|
||||||
|
exports.setCommandEcho = setCommandEcho;
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
// Results
|
// Results
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
@@ -1213,18 +1268,18 @@ function debug(message) {
|
|||||||
exports.debug = debug;
|
exports.debug = debug;
|
||||||
/**
|
/**
|
||||||
* Adds an error issue
|
* Adds an error issue
|
||||||
* @param message error issue message
|
* @param message error issue message. Errors will be converted to string via toString()
|
||||||
*/
|
*/
|
||||||
function error(message) {
|
function error(message) {
|
||||||
command_1.issue('error', message);
|
command_1.issue('error', message instanceof Error ? message.toString() : message);
|
||||||
}
|
}
|
||||||
exports.error = error;
|
exports.error = error;
|
||||||
/**
|
/**
|
||||||
* Adds an warning issue
|
* Adds an warning issue
|
||||||
* @param message warning issue message
|
* @param message warning issue message. Errors will be converted to string via toString()
|
||||||
*/
|
*/
|
||||||
function warning(message) {
|
function warning(message) {
|
||||||
command_1.issue('warning', message);
|
command_1.issue('warning', message instanceof Error ? message.toString() : message);
|
||||||
}
|
}
|
||||||
exports.warning = warning;
|
exports.warning = warning;
|
||||||
/**
|
/**
|
||||||
@@ -1282,8 +1337,9 @@ exports.group = group;
|
|||||||
* Saves state for current action, the state can only be retrieved by this action's post job execution.
|
* Saves state for current action, the state can only be retrieved by this action's post job execution.
|
||||||
*
|
*
|
||||||
* @param name name of the state to store
|
* @param name name of the state to store
|
||||||
* @param value value to store
|
* @param value value to store. Non-string values will be converted to a string via JSON.stringify
|
||||||
*/
|
*/
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
function saveState(name, value) {
|
function saveState(name, value) {
|
||||||
command_1.issueCommand('save-state', { name }, value);
|
command_1.issueCommand('save-state', { name }, value);
|
||||||
}
|
}
|
||||||
@@ -1559,7 +1615,7 @@ function run() {
|
|||||||
try {
|
try {
|
||||||
let version = yield utils.getInput('php-version', true);
|
let version = yield utils.getInput('php-version', true);
|
||||||
version = version.length > 1 ? version.slice(0, 3) : version + '.0';
|
version = version.length > 1 ? version.slice(0, 3) : version + '.0';
|
||||||
const extensions = yield utils.getInput('extensions', true);
|
const extensions = yield utils.filterExtensions(yield utils.getInput('extensions', true));
|
||||||
const key = yield utils.getInput('key', true);
|
const key = yield utils.getInput('key', true);
|
||||||
const script_path = path.join(__dirname, '../src/extensions.sh');
|
const script_path = path.join(__dirname, '../src/extensions.sh');
|
||||||
yield exec_1.exec('bash ' + script_path + ' "' + extensions + '" ' + key + ' ' + version);
|
yield exec_1.exec('bash ' + script_path + ' "' + extensions + '" ' + key + ' ' + version);
|
||||||
@@ -1597,8 +1653,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|||||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
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 });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
const tr = __webpack_require__(9);
|
const tr = __importStar(__webpack_require__(9));
|
||||||
/**
|
/**
|
||||||
* Exec a command.
|
* Exec a command.
|
||||||
* Output will be streamed to the live console.
|
* Output will be streamed to the live console.
|
||||||
|
|||||||
2952
package-lock.json
generated
2952
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
30
package.json
30
package.json
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "cache-extensions",
|
"name": "cache-extensions",
|
||||||
"version": "1.0.5",
|
"version": "1.0.6",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "Cache extensions in GitHub Actions",
|
"description": "Cache extensions in GitHub Actions",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
@@ -24,25 +24,25 @@
|
|||||||
"author": "shivammathur",
|
"author": "shivammathur",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^1.2.3",
|
"@actions/core": "^1.2.4",
|
||||||
"@actions/exec": "^1.0.3"
|
"@actions/exec": "^1.0.4"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/jest": "^25.2.1",
|
"@types/jest": "^25.2.1",
|
||||||
"@types/node": "^13.11.1",
|
"@types/node": "^13.13.5",
|
||||||
"@typescript-eslint/eslint-plugin": "^2.27.0",
|
"@typescript-eslint/eslint-plugin": "^2.31.0",
|
||||||
"@typescript-eslint/parser": "^2.27.0",
|
"@typescript-eslint/parser": "^2.31.0",
|
||||||
"@zeit/ncc": "^0.22.1",
|
"@zeit/ncc": "^0.22.1",
|
||||||
"eslint": "^6.8.0",
|
"eslint": "^7.0.0",
|
||||||
"eslint-config-prettier": "^6.10.1",
|
"eslint-config-prettier": "^6.11.0",
|
||||||
"eslint-plugin-import": "^2.20.2",
|
"eslint-plugin-import": "^2.20.2",
|
||||||
"eslint-plugin-jest": "^23.8.2",
|
"eslint-plugin-jest": "^23.10.0",
|
||||||
"eslint-plugin-prettier": "^3.1.2",
|
"eslint-plugin-prettier": "^3.1.3",
|
||||||
"husky": "^4.2.4",
|
"husky": "^4.2.5",
|
||||||
"jest": "^25.3.0",
|
"jest": "^26.0.1",
|
||||||
"jest-circus": "^25.3.0",
|
"jest-circus": "^26.0.1",
|
||||||
"prettier": "^2.0.4",
|
"prettier": "^2.0.5",
|
||||||
"ts-jest": "^25.3.1",
|
"ts-jest": "^25.5.1",
|
||||||
"typescript": "^3.8.3"
|
"typescript": "^3.8.3"
|
||||||
},
|
},
|
||||||
"husky": {
|
"husky": {
|
||||||
|
|||||||
@@ -10,7 +10,9 @@ export async function run(): Promise<void> {
|
|||||||
try {
|
try {
|
||||||
let version: string = await utils.getInput('php-version', true);
|
let version: string = await utils.getInput('php-version', true);
|
||||||
version = version.length > 1 ? version.slice(0, 3) : version + '.0';
|
version = version.length > 1 ? version.slice(0, 3) : version + '.0';
|
||||||
const extensions: string = await utils.getInput('extensions', true);
|
const extensions = await utils.filterExtensions(
|
||||||
|
await utils.getInput('extensions', true)
|
||||||
|
);
|
||||||
const key: string = await utils.getInput('key', true);
|
const key: string = await utils.getInput('key', true);
|
||||||
const script_path: string = path.join(__dirname, '../src/extensions.sh');
|
const script_path: string = path.join(__dirname, '../src/extensions.sh');
|
||||||
await exec(
|
await exec(
|
||||||
|
|||||||
14
src/utils.ts
14
src/utils.ts
@@ -20,3 +20,17 @@ export async function getInput(
|
|||||||
return input;
|
return input;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function to filter extensions
|
||||||
|
*
|
||||||
|
* @param extension_csv
|
||||||
|
*/
|
||||||
|
export async function filterExtensions(extension_csv: string): Promise<string> {
|
||||||
|
return extension_csv
|
||||||
|
.split(',')
|
||||||
|
.filter(extension => {
|
||||||
|
return extension.trim()[0] != ':';
|
||||||
|
})
|
||||||
|
.join(',');
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user