Compare commits

...

8 Commits

12 changed files with 774 additions and 1186 deletions

View File

@ -62,7 +62,7 @@ Setup PHP with required extensions, php.ini configuration, code-coverage support
|Ubuntu 20.04|`ubuntu-latest` or `ubuntu-20.04`|`PHP 7.4` to `PHP 8.0`| |Ubuntu 20.04|`ubuntu-latest` or `ubuntu-20.04`|`PHP 7.4` to `PHP 8.0`|
|Windows Server 2019|`windows-latest` or `windows-2019`|`PHP 8.0`| |Windows Server 2019|`windows-latest` or `windows-2019`|`PHP 8.0`|
|macOS 10.15 Catalina|`macos-latest` or `macos-10.15`|`PHP 8.0`| |macOS 10.15 Catalina|`macos-latest` or `macos-10.15`|`PHP 8.0`|
|macOS 11.0 Big Sur|`macos-11.0`|`PHP 8.0`| |macOS 11.x Big Sur|`macos-11`|`PHP 8.0`|
## :heavy_plus_sign: PHP Extension Support ## :heavy_plus_sign: PHP Extension Support
- On `ubuntu` by default extensions which are available as a package can be installed. If the extension is not available as a package but it is on `PECL`, it can be installed by specifying `pecl` in the tools input. - On `ubuntu` by default extensions which are available as a package can be installed. If the extension is not available as a package but it is on `PECL`, it can be installed by specifying `pecl` in the tools input.

View File

@ -127,6 +127,11 @@ describe('Tools tests', () => {
expect(script).toContain( expect(script).toContain(
'Add-Tool https://github.com/phar-io/phive/releases/download/0.13.5/phive-0.13.5.phar phive' 'Add-Tool https://github.com/phar-io/phive/releases/download/0.13.5/phive-0.13.5.phar phive'
); );
script = await tools.addPhive('latest', '7.2', 'win32');
expect(script).toContain(
'Add-Tool https://github.com/phar-io/phive/releases/download/0.14.5/phive-0.14.5.phar phive'
);
}); });
it('checking getPhpunitUri', async () => { it('checking getPhpunitUri', async () => {

View File

@ -23,7 +23,11 @@ async function cleanup(path: string): Promise<void> {
describe('Utils tests', () => { describe('Utils tests', () => {
it('checking readEnv', async () => { it('checking readEnv', async () => {
process.env['test'] = 'setup-php'; process.env['test'] = 'setup-php';
process.env['test-hyphen'] = 'setup-php';
expect(await utils.readEnv('test')).toBe('setup-php'); expect(await utils.readEnv('test')).toBe('setup-php');
expect(await utils.readEnv('TEST')).toBe('setup-php');
expect(await utils.readEnv('test_hyphen')).toBe('setup-php');
expect(await utils.readEnv('TEST_HYPHEN')).toBe('setup-php');
expect(await utils.readEnv('undefined')).toBe(''); expect(await utils.readEnv('undefined')).toBe('');
}); });

88
dist/index.js vendored
View File

@ -230,7 +230,7 @@ async function addExtensionDarwin(extension_csv, version) {
' ' + ' ' +
ext_prefix; ext_prefix;
return; return;
case /(5\.6|7\.[0-4]|8.0)(amqp|grpc|igbinary|imagick|imap|msgpack|^(pecl_)?http$|propro|protobuf|psr|raphf|rdkafka|redis|swoole|xdebug|xdebug2|zmq)/.test(version_extension): case /(5\.6|7\.[0-4]|8.0)(amqp|grpc|igbinary|imagick|imap|mongodb|msgpack|^(pecl_)?http$|propro|protobuf|psr|raphf|rdkafka|redis|swoole|xdebug|xdebug2|yaml|zmq)/.test(version_extension):
case /(7\.[1-4]|8\.0])pcov/.test(version_extension): case /(7\.[1-4]|8\.0])pcov/.test(version_extension):
case /^(5\.6|7\.[0-3])phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension): case /^(5\.6|7\.[0-3])phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
command = 'add_brew_extension ' + extension_name.replace('pecl_', ''); command = 'add_brew_extension ' + extension_name.replace('pecl_', '');
@ -571,6 +571,9 @@ async function addPhive(version, php_version, os_version) {
case /7\.1/.test(php_version): case /7\.1/.test(php_version):
version = version.replace('latest', '0.13.5'); version = version.replace('latest', '0.13.5');
break; break;
case /7\.2/.test(php_version):
version = version.replace('latest', '0.14.5');
break;
} }
switch (version) { switch (version) {
case 'latest': case 'latest':
@ -821,13 +824,14 @@ const https = __importStar(__nccwpck_require__(211));
const path = __importStar(__nccwpck_require__(622)); const path = __importStar(__nccwpck_require__(622));
const core = __importStar(__nccwpck_require__(186)); const core = __importStar(__nccwpck_require__(186));
async function readEnv(property) { async function readEnv(property) {
const value = process.env[property]; const property_lc = property.toLowerCase();
switch (value) { const property_uc = property.toUpperCase();
case undefined: return (process.env[property] ||
return ''; process.env[property_lc] ||
default: process.env[property_uc] ||
return value; process.env[property_lc.replace('_', '-')] ||
} process.env[property_uc.replace('_', '-')] ||
'');
} }
exports.readEnv = readEnv; exports.readEnv = readEnv;
async function getInput(name, mandatory) { async function getInput(name, mandatory) {
@ -1133,7 +1137,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
}); });
}; };
Object.defineProperty(exports, "__esModule", ({ value: true })); 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.getMultilineInput = exports.getInput = exports.addPath = exports.setSecret = exports.exportVariable = exports.ExitCode = void 0; 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 = __nccwpck_require__(241); const command_1 = __nccwpck_require__(241);
const file_command_1 = __nccwpck_require__(717); const file_command_1 = __nccwpck_require__(717);
const utils_1 = __nccwpck_require__(278); const utils_1 = __nccwpck_require__(278);
@ -1311,19 +1315,30 @@ exports.debug = debug;
/** /**
* Adds an error issue * Adds an error issue
* @param message error issue message. Errors will be converted to string via toString() * @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) { function error(message, properties = {}) {
command_1.issue('error', message instanceof Error ? message.toString() : message); command_1.issueCommand('error', utils_1.toCommandProperties(properties), message instanceof Error ? message.toString() : message);
} }
exports.error = error; 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 message warning issue message. Errors will be converted to string via toString()
* @param properties optional properties to add to the annotation.
*/ */
function warning(message) { function warning(message, properties = {}) {
command_1.issue('warning', message instanceof Error ? message.toString() : message); command_1.issueCommand('warning', utils_1.toCommandProperties(properties), message instanceof Error ? message.toString() : message);
} }
exports.warning = warning; 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. * Writes info to log with console.log.
* @param message info message * @param message info message
@ -1455,7 +1470,7 @@ exports.issueCommand = issueCommand;
// We use any as a valid input type // We use any as a valid input type
/* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/no-explicit-any */
Object.defineProperty(exports, "__esModule", ({ value: true })); 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 * Sanitizes an input into a string so it can be passed into issueCommand safely
* @param input input to sanitize into a string * @param input input to sanitize into a string
@ -1470,6 +1485,25 @@ function toCommandValue(input) {
return JSON.stringify(input); return JSON.stringify(input);
} }
exports.toCommandValue = toCommandValue; 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,
line: annotationProperties.startLine,
endLine: annotationProperties.endLine,
col: annotationProperties.startColumn,
endColumn: annotationProperties.endColumn
};
}
exports.toCommandProperties = toCommandProperties;
//# sourceMappingURL=utils.js.map //# sourceMappingURL=utils.js.map
/***/ }), /***/ }),
@ -2740,70 +2774,70 @@ function copyFile(srcFile, destFile, force) {
/***/ 357: /***/ 357:
/***/ ((module) => { /***/ ((module) => {
module.exports = require("assert");; module.exports = require("assert");
/***/ }), /***/ }),
/***/ 129: /***/ 129:
/***/ ((module) => { /***/ ((module) => {
module.exports = require("child_process");; module.exports = require("child_process");
/***/ }), /***/ }),
/***/ 614: /***/ 614:
/***/ ((module) => { /***/ ((module) => {
module.exports = require("events");; module.exports = require("events");
/***/ }), /***/ }),
/***/ 747: /***/ 747:
/***/ ((module) => { /***/ ((module) => {
module.exports = require("fs");; module.exports = require("fs");
/***/ }), /***/ }),
/***/ 211: /***/ 211:
/***/ ((module) => { /***/ ((module) => {
module.exports = require("https");; module.exports = require("https");
/***/ }), /***/ }),
/***/ 87: /***/ 87:
/***/ ((module) => { /***/ ((module) => {
module.exports = require("os");; module.exports = require("os");
/***/ }), /***/ }),
/***/ 622: /***/ 622:
/***/ ((module) => { /***/ ((module) => {
module.exports = require("path");; module.exports = require("path");
/***/ }), /***/ }),
/***/ 304: /***/ 304:
/***/ ((module) => { /***/ ((module) => {
module.exports = require("string_decoder");; module.exports = require("string_decoder");
/***/ }), /***/ }),
/***/ 213: /***/ 213:
/***/ ((module) => { /***/ ((module) => {
module.exports = require("timers");; module.exports = require("timers");
/***/ }), /***/ }),
/***/ 669: /***/ 669:
/***/ ((module) => { /***/ ((module) => {
module.exports = require("util");; module.exports = require("util");
/***/ }) /***/ })
@ -2842,7 +2876,9 @@ module.exports = require("util");;
/************************************************************************/ /************************************************************************/
/******/ /* webpack/runtime/compat */ /******/ /* webpack/runtime/compat */
/******/ /******/
/******/ if (typeof __nccwpck_require__ !== 'undefined') __nccwpck_require__.ab = __dirname + "/";/************************************************************************/ /******/ if (typeof __nccwpck_require__ !== 'undefined') __nccwpck_require__.ab = __dirname + "/";
/******/
/************************************************************************/
/******/ /******/
/******/ // startup /******/ // startup
/******/ // Load entry module and return exports /******/ // Load entry module and return exports

1802
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
{ {
"name": "setup-php", "name": "setup-php",
"version": "1.11.2", "version": "1.11.3",
"private": false, "private": false,
"description": "Setup PHP for use with GitHub Actions", "description": "Setup PHP for use with GitHub Actions",
"main": "lib/install.js", "main": "lib/install.js",
@ -24,27 +24,27 @@
"author": "shivammathur", "author": "shivammathur",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@actions/core": "^1.4.0", "@actions/core": "^1.5.0",
"@actions/exec": "^1.1.0", "@actions/exec": "^1.1.0",
"@actions/io": "^1.1.1", "@actions/io": "^1.1.1",
"fs": "0.0.1-security" "fs": "0.0.1-security"
}, },
"devDependencies": { "devDependencies": {
"@types/jest": "^26.0.24", "@types/jest": "^27.0.1",
"@types/node": "^16.3.1", "@types/node": "^16.7.1",
"@typescript-eslint/eslint-plugin": "^4.28.3", "@typescript-eslint/eslint-plugin": "^4.29.2",
"@typescript-eslint/parser": "^4.28.3", "@typescript-eslint/parser": "^4.29.2",
"@vercel/ncc": "^0.28.6", "@vercel/ncc": "^0.29.2",
"eslint": "^7.30.0", "eslint": "^7.32.0",
"eslint-config-prettier": "^8.3.0", "eslint-config-prettier": "^8.3.0",
"eslint-plugin-import": "^2.23.4", "eslint-plugin-import": "^2.24.1",
"eslint-plugin-jest": "^24.3.6", "eslint-plugin-jest": "^24.4.0",
"eslint-plugin-prettier": "^3.4.0", "eslint-plugin-prettier": "^3.4.1",
"husky": "^4.3.8", "husky": "^4.3.8",
"jest": "^27.0.6", "jest": "^27.0.6",
"jest-circus": "^27.0.6", "jest-circus": "^27.0.6",
"prettier": "^2.3.2", "prettier": "^2.3.2",
"ts-jest": "^27.0.3", "ts-jest": "^27.0.5",
"typescript": "^4.3.5" "typescript": "^4.3.5"
}, },
"husky": { "husky": {

View File

@ -30,9 +30,9 @@ export async function addExtensionDarwin(
' ' + ' ' +
ext_prefix; ext_prefix;
return; return;
// match 5.6 to 8.0 amqp, grpc, igbinary, imagick, imap, msgpack, pecl_http, propro, protobuf, raphf, rdkafka, redis, swoole, xdebug, xdebug2, zmq // match 5.6 to 8.0 amqp, grpc, igbinary, imagick, imap, mongodb, msgpack, pecl_http, propro, protobuf, raphf, rdkafka, redis, swoole, xdebug, xdebug2, yaml, zmq
// match 7.1pcov to 8.0pcov // match 7.1pcov to 8.0pcov
case /(5\.6|7\.[0-4]|8.0)(amqp|grpc|igbinary|imagick|imap|msgpack|^(pecl_)?http$|propro|protobuf|psr|raphf|rdkafka|redis|swoole|xdebug|xdebug2|zmq)/.test( case /(5\.6|7\.[0-4]|8.0)(amqp|grpc|igbinary|imagick|imap|mongodb|msgpack|^(pecl_)?http$|propro|protobuf|psr|raphf|rdkafka|redis|swoole|xdebug|xdebug2|yaml|zmq)/.test(
version_extension version_extension
): ):
case /(7\.[1-4]|8\.0])pcov/.test(version_extension): case /(7\.[1-4]|8\.0])pcov/.test(version_extension):

View File

@ -95,7 +95,7 @@ add_brew_tap() {
if ! [ -d "$tap_dir/$tap" ]; then if ! [ -d "$tap_dir/$tap" ]; then
fetch_brew_tap "$tap" >/dev/null 2>&1 fetch_brew_tap "$tap" >/dev/null 2>&1
if ! [ -d "$tap_dir/$tap" ]; then if ! [ -d "$tap_dir/$tap" ]; then
brew tap --shallow "$tap" >/dev/null 2>&1 brew tap "$tap" >/dev/null 2>&1
fi fi
fi fi
} }
@ -311,6 +311,7 @@ brew_repo="$(brew --repository)"
tap_dir="$brew_repo"/Library/Taps tap_dir="$brew_repo"/Library/Taps
existing_version=$(get_brewed_php) existing_version=$(get_brewed_php)
export HOMEBREW_CHANGE_ARCH_TO_ARM=1 export HOMEBREW_CHANGE_ARCH_TO_ARM=1
export HOMEBREW_DEVELOPER=1
export HOMEBREW_NO_INSTALL_CLEANUP=1 export HOMEBREW_NO_INSTALL_CLEANUP=1
export HOMEBREW_NO_AUTO_UPDATE=1 export HOMEBREW_NO_AUTO_UPDATE=1
export HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1 export HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1

View File

@ -313,7 +313,7 @@ cross="✗"
version=$1 version=$1
dist=$2 dist=$2
debconf_fix="DEBIAN_FRONTEND=noninteractive" debconf_fix="DEBIAN_FRONTEND=noninteractive"
apt_install="sudo $debconf_fix apt-fast install -y" apt_install="sudo $debconf_fix apt-fast install -y --no-install-recommends"
tool_path_dir="/usr/local/bin" tool_path_dir="/usr/local/bin"
curl_opts=(-sL) curl_opts=(-sL)
composer_home="$HOME/.composer" composer_home="$HOME/.composer"

View File

@ -119,6 +119,9 @@ export async function addPhive(
case /7\.1/.test(php_version): case /7\.1/.test(php_version):
version = version.replace('latest', '0.13.5'); version = version.replace('latest', '0.13.5');
break; break;
case /7\.2/.test(php_version):
version = version.replace('latest', '0.14.5');
break;
} }
switch (version) { switch (version) {
case 'latest': case 'latest':

View File

@ -10,13 +10,16 @@ import * as core from '@actions/core';
* @param property * @param property
*/ */
export async function readEnv(property: string): Promise<string> { export async function readEnv(property: string): Promise<string> {
const value = process.env[property]; const property_lc: string = property.toLowerCase();
switch (value) { const property_uc: string = property.toUpperCase();
case undefined: return (
return ''; process.env[property] ||
default: process.env[property_lc] ||
return value; process.env[property_uc] ||
} process.env[property_lc.replace('_', '-')] ||
process.env[property_uc.replace('_', '-')] ||
''
);
} }
/** /**

View File

@ -2,7 +2,7 @@
"compilerOptions": { "compilerOptions": {
"esModuleInterop": true, "esModuleInterop": true,
"lib": [ "lib": [
"ESNext" "ES2020"
], ],
"module": "commonjs", "module": "commonjs",
"moduleResolution": "node", "moduleResolution": "node",
@ -12,7 +12,7 @@
"rootDir": "./src", "rootDir": "./src",
"sourceMap": true, "sourceMap": true,
"strict": true, "strict": true,
"target": "ESNext" "target": "ES2019"
}, },
"exclude": ["__tests__", "lib", "node_modules"] "exclude": ["__tests__", "lib", "node_modules"]
} }