mirror of
https://github.com/shivammathur/setup-php.git
synced 2024-11-22 11:51:07 +07:00
Improve documentation
This commit is contained in:
parent
f7f5b1a7e1
commit
99bbaa2a58
10
action.yml
10
action.yml
@ -1,21 +1,21 @@
|
||||
name: 'Setup PHP Action'
|
||||
author: shivammathur
|
||||
description: 'Setup a PHP environment with composer and add it to the PATH'
|
||||
description: 'GitHub action to setup PHP with required extensions, php.ini configuration, code-coverage support and composer'
|
||||
branding:
|
||||
icon: 'activity'
|
||||
color: 'purple'
|
||||
inputs:
|
||||
php-version:
|
||||
description: 'PHP version to be installed.'
|
||||
description: 'PHP version you want to install.'
|
||||
required: true
|
||||
extension-csv:
|
||||
description: '(Optional) Comma seperated list of PHP extensions to be installed.'
|
||||
description: '(Optional) PHP extensions you want to install.'
|
||||
required: false
|
||||
ini-values-csv:
|
||||
description: '(Optional) Custom values you want to set in php.ini'
|
||||
description: '(Optional) Custom values you want to set in php.ini.'
|
||||
required: false
|
||||
coverage:
|
||||
description: '(Optional) Driver to calculate code coverage (Accepts: xdebug, pcov and none)'
|
||||
description: '(Optional) Code coverage driver you want to install. (Accepts: xdebug, pcov and none)'
|
||||
required: false
|
||||
runs:
|
||||
using: 'node12'
|
||||
|
@ -19,6 +19,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const utils = __importStar(require("./utils"));
|
||||
const extensions = __importStar(require("./extensions"));
|
||||
const config = __importStar(require("./config"));
|
||||
/**
|
||||
* Function to set coverage driver
|
||||
*
|
||||
* @param coverage_driver
|
||||
* @param version
|
||||
* @param os_version
|
||||
*/
|
||||
function addCoverage(coverage_driver, version, os_version) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
coverage_driver.toLowerCase();
|
||||
@ -35,6 +42,12 @@ function addCoverage(coverage_driver, version, os_version) {
|
||||
});
|
||||
}
|
||||
exports.addCoverage = addCoverage;
|
||||
/**
|
||||
* Function to setup Xdebug
|
||||
*
|
||||
* @param version
|
||||
* @param os_version
|
||||
*/
|
||||
function addCoverageXdebug(version, os_version) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let script = '\n';
|
||||
@ -44,6 +57,12 @@ function addCoverageXdebug(version, os_version) {
|
||||
});
|
||||
}
|
||||
exports.addCoverageXdebug = addCoverageXdebug;
|
||||
/**
|
||||
* Function to setup PCOV
|
||||
*
|
||||
* @param version
|
||||
* @param os_version
|
||||
*/
|
||||
function addCoveragePCOV(version, os_version) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let script = '\n';
|
||||
@ -83,6 +102,12 @@ function addCoveragePCOV(version, os_version) {
|
||||
});
|
||||
}
|
||||
exports.addCoveragePCOV = addCoveragePCOV;
|
||||
/**
|
||||
* Function to disable Xdebug and PCOV
|
||||
*
|
||||
* @param version
|
||||
* @param os_version
|
||||
*/
|
||||
function disableCoverage(version, os_version) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let script = '\n';
|
||||
|
@ -17,6 +17,14 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const utils = __importStar(require("./utils"));
|
||||
/**
|
||||
* Install and enable extensions
|
||||
*
|
||||
* @param extension_csv
|
||||
* @param version
|
||||
* @param os_version
|
||||
* @param log_prefix
|
||||
*/
|
||||
function addExtension(extension_csv, version, os_version, log_prefix = 'Add Extension') {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
switch (os_version) {
|
||||
|
12
lib/utils.js
12
lib/utils.js
@ -19,6 +19,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const fs = __importStar(require("fs"));
|
||||
const path = __importStar(require("path"));
|
||||
const core = __importStar(require("@actions/core"));
|
||||
/**
|
||||
* Function to get inputs from both with and env annotations.
|
||||
*
|
||||
* @param name
|
||||
* @param mandatory
|
||||
*/
|
||||
function getInput(name, mandatory) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let input = process.env[name];
|
||||
@ -117,6 +123,7 @@ function writeScript(filename, version, script) {
|
||||
exports.writeScript = writeScript;
|
||||
/**
|
||||
* Function to break extension csv into an array
|
||||
*
|
||||
* @param extension_csv
|
||||
*/
|
||||
function extensionArray(extension_csv) {
|
||||
@ -196,6 +203,11 @@ function log(message, os_version, log_type, prefix = '') {
|
||||
});
|
||||
}
|
||||
exports.log = log;
|
||||
/**
|
||||
* Function to get prefix required to load an extension.
|
||||
*
|
||||
* @param extension
|
||||
*/
|
||||
function getExtensionPrefix(extension) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let zend = ['xdebug', 'opcache', 'ioncube', 'eaccelerator'];
|
||||
|
@ -2,6 +2,13 @@ import * as utils from './utils';
|
||||
import * as extensions from './extensions';
|
||||
import * as config from './config';
|
||||
|
||||
/**
|
||||
* Function to set coverage driver
|
||||
*
|
||||
* @param coverage_driver
|
||||
* @param version
|
||||
* @param os_version
|
||||
*/
|
||||
export async function addCoverage(
|
||||
coverage_driver: string,
|
||||
version: string,
|
||||
@ -20,6 +27,12 @@ export async function addCoverage(
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to setup Xdebug
|
||||
*
|
||||
* @param version
|
||||
* @param os_version
|
||||
*/
|
||||
export async function addCoverageXdebug(version: string, os_version: string) {
|
||||
let script: string = '\n';
|
||||
script += await extensions.addExtension(
|
||||
@ -38,6 +51,12 @@ export async function addCoverageXdebug(version: string, os_version: string) {
|
||||
return script;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to setup PCOV
|
||||
*
|
||||
* @param version
|
||||
* @param os_version
|
||||
*/
|
||||
export async function addCoveragePCOV(version: string, os_version: string) {
|
||||
let script: string = '\n';
|
||||
switch (version) {
|
||||
@ -93,6 +112,12 @@ export async function addCoveragePCOV(version: string, os_version: string) {
|
||||
return script;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to disable Xdebug and PCOV
|
||||
*
|
||||
* @param version
|
||||
* @param os_version
|
||||
*/
|
||||
export async function disableCoverage(version: string, os_version: string) {
|
||||
let script: string = '\n';
|
||||
switch (os_version) {
|
||||
|
@ -1,5 +1,13 @@
|
||||
import * as utils from './utils';
|
||||
|
||||
/**
|
||||
* Install and enable extensions
|
||||
*
|
||||
* @param extension_csv
|
||||
* @param version
|
||||
* @param os_version
|
||||
* @param log_prefix
|
||||
*/
|
||||
export async function addExtension(
|
||||
extension_csv: string,
|
||||
version: string,
|
||||
|
@ -18,14 +18,11 @@ if [ "$existing_version" != "$1" ]; then
|
||||
fi
|
||||
|
||||
if [ ! -e "/usr/bin/composer" ]; then
|
||||
EXPECTED_SIGNATURE="$(curl -s https://composer.github.io/installer.sig)" &
|
||||
curl -s -L https://getcomposer.org/installer > composer-setup.php &
|
||||
ACTUAL_SIGNATURE="$(php -r "echo hash_file('sha384', 'composer-setup.php');")" &
|
||||
|
||||
if [ "$EXPECTED_SIGNATURE" != "$ACTUAL_SIGNATURE" ]; then
|
||||
curl -s -L https://getcomposer.org/installer > composer-setup.php
|
||||
if [ "$(curl -s https://composer.github.io/installer.sig)" != "$(php -r "echo hash_file('sha384', 'composer-setup.php');")" ]; then
|
||||
>&2 echo 'ERROR: Invalid installer signature'
|
||||
else
|
||||
COMPOSER_ALLOW_SUPERUSER=1
|
||||
export COMPOSER_ALLOW_SUPERUSER=1
|
||||
sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer
|
||||
fi
|
||||
rm composer-setup.php
|
||||
|
12
src/utils.ts
12
src/utils.ts
@ -2,6 +2,12 @@ import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
import * as core from '@actions/core';
|
||||
|
||||
/**
|
||||
* Function to get inputs from both with and env annotations.
|
||||
*
|
||||
* @param name
|
||||
* @param mandatory
|
||||
*/
|
||||
export async function getInput(
|
||||
name: string,
|
||||
mandatory: boolean
|
||||
@ -117,6 +123,7 @@ export async function writeScript(
|
||||
|
||||
/**
|
||||
* Function to break extension csv into an array
|
||||
*
|
||||
* @param extension_csv
|
||||
*/
|
||||
export async function extensionArray(
|
||||
@ -202,6 +209,11 @@ export async function log(
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to get prefix required to load an extension.
|
||||
*
|
||||
* @param extension
|
||||
*/
|
||||
export async function getExtensionPrefix(extension: string): Promise<string> {
|
||||
let zend: Array<string> = ['xdebug', 'opcache', 'ioncube', 'eaccelerator'];
|
||||
switch (zend.indexOf(extension)) {
|
||||
|
Loading…
Reference in New Issue
Block a user