Improve documentation

This commit is contained in:
Shivam Mathur 2019-10-11 23:09:05 +05:30
parent f7f5b1a7e1
commit 99bbaa2a58
No known key found for this signature in database
GPG Key ID: 3E13E4C8591ACC2A
8 changed files with 98 additions and 11 deletions

View File

@ -1,21 +1,21 @@
name: 'Setup PHP Action' name: 'Setup PHP Action'
author: shivammathur 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: branding:
icon: 'activity' icon: 'activity'
color: 'purple' color: 'purple'
inputs: inputs:
php-version: php-version:
description: 'PHP version to be installed.' description: 'PHP version you want to install.'
required: true required: true
extension-csv: extension-csv:
description: '(Optional) Comma seperated list of PHP extensions to be installed.' description: '(Optional) PHP extensions you want to install.'
required: false required: false
ini-values-csv: 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 required: false
coverage: 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 required: false
runs: runs:
using: 'node12' using: 'node12'

View File

@ -19,6 +19,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
const utils = __importStar(require("./utils")); const utils = __importStar(require("./utils"));
const extensions = __importStar(require("./extensions")); const extensions = __importStar(require("./extensions"));
const config = __importStar(require("./config")); 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) { function addCoverage(coverage_driver, version, os_version) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
coverage_driver.toLowerCase(); coverage_driver.toLowerCase();
@ -35,6 +42,12 @@ function addCoverage(coverage_driver, version, os_version) {
}); });
} }
exports.addCoverage = addCoverage; exports.addCoverage = addCoverage;
/**
* Function to setup Xdebug
*
* @param version
* @param os_version
*/
function addCoverageXdebug(version, os_version) { function addCoverageXdebug(version, os_version) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
let script = '\n'; let script = '\n';
@ -44,6 +57,12 @@ function addCoverageXdebug(version, os_version) {
}); });
} }
exports.addCoverageXdebug = addCoverageXdebug; exports.addCoverageXdebug = addCoverageXdebug;
/**
* Function to setup PCOV
*
* @param version
* @param os_version
*/
function addCoveragePCOV(version, os_version) { function addCoveragePCOV(version, os_version) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
let script = '\n'; let script = '\n';
@ -83,6 +102,12 @@ function addCoveragePCOV(version, os_version) {
}); });
} }
exports.addCoveragePCOV = addCoveragePCOV; exports.addCoveragePCOV = addCoveragePCOV;
/**
* Function to disable Xdebug and PCOV
*
* @param version
* @param os_version
*/
function disableCoverage(version, os_version) { function disableCoverage(version, os_version) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
let script = '\n'; let script = '\n';

View File

@ -17,6 +17,14 @@ var __importStar = (this && this.__importStar) || function (mod) {
}; };
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
const utils = __importStar(require("./utils")); 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') { function addExtension(extension_csv, version, os_version, log_prefix = 'Add Extension') {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
switch (os_version) { switch (os_version) {

View File

@ -19,6 +19,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
const fs = __importStar(require("fs")); const fs = __importStar(require("fs"));
const path = __importStar(require("path")); const path = __importStar(require("path"));
const core = __importStar(require("@actions/core")); const core = __importStar(require("@actions/core"));
/**
* Function to get inputs from both with and env annotations.
*
* @param name
* @param mandatory
*/
function getInput(name, mandatory) { function getInput(name, mandatory) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
let input = process.env[name]; let input = process.env[name];
@ -117,6 +123,7 @@ function writeScript(filename, version, script) {
exports.writeScript = writeScript; exports.writeScript = writeScript;
/** /**
* Function to break extension csv into an array * Function to break extension csv into an array
*
* @param extension_csv * @param extension_csv
*/ */
function extensionArray(extension_csv) { function extensionArray(extension_csv) {
@ -196,6 +203,11 @@ function log(message, os_version, log_type, prefix = '') {
}); });
} }
exports.log = log; exports.log = log;
/**
* Function to get prefix required to load an extension.
*
* @param extension
*/
function getExtensionPrefix(extension) { function getExtensionPrefix(extension) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
let zend = ['xdebug', 'opcache', 'ioncube', 'eaccelerator']; let zend = ['xdebug', 'opcache', 'ioncube', 'eaccelerator'];

View File

@ -2,6 +2,13 @@ import * as utils from './utils';
import * as extensions from './extensions'; import * as extensions from './extensions';
import * as config from './config'; import * as config from './config';
/**
* Function to set coverage driver
*
* @param coverage_driver
* @param version
* @param os_version
*/
export async function addCoverage( export async function addCoverage(
coverage_driver: string, coverage_driver: string,
version: 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) { export async function addCoverageXdebug(version: string, os_version: string) {
let script: string = '\n'; let script: string = '\n';
script += await extensions.addExtension( script += await extensions.addExtension(
@ -38,6 +51,12 @@ export async function addCoverageXdebug(version: string, os_version: string) {
return script; return script;
} }
/**
* Function to setup PCOV
*
* @param version
* @param os_version
*/
export async function addCoveragePCOV(version: string, os_version: string) { export async function addCoveragePCOV(version: string, os_version: string) {
let script: string = '\n'; let script: string = '\n';
switch (version) { switch (version) {
@ -93,6 +112,12 @@ export async function addCoveragePCOV(version: string, os_version: string) {
return script; return script;
} }
/**
* Function to disable Xdebug and PCOV
*
* @param version
* @param os_version
*/
export async function disableCoverage(version: string, os_version: string) { export async function disableCoverage(version: string, os_version: string) {
let script: string = '\n'; let script: string = '\n';
switch (os_version) { switch (os_version) {

View File

@ -1,5 +1,13 @@
import * as utils from './utils'; import * as utils from './utils';
/**
* Install and enable extensions
*
* @param extension_csv
* @param version
* @param os_version
* @param log_prefix
*/
export async function addExtension( export async function addExtension(
extension_csv: string, extension_csv: string,
version: string, version: string,

View File

@ -18,14 +18,11 @@ if [ "$existing_version" != "$1" ]; then
fi fi
if [ ! -e "/usr/bin/composer" ]; then 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
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
ACTUAL_SIGNATURE="$(php -r "echo hash_file('sha384', 'composer-setup.php');")" &
if [ "$EXPECTED_SIGNATURE" != "$ACTUAL_SIGNATURE" ]; then
>&2 echo 'ERROR: Invalid installer signature' >&2 echo 'ERROR: Invalid installer signature'
else else
COMPOSER_ALLOW_SUPERUSER=1 export COMPOSER_ALLOW_SUPERUSER=1
sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer
fi fi
rm composer-setup.php rm composer-setup.php

View File

@ -2,6 +2,12 @@ import * as fs from 'fs';
import * as path from 'path'; import * as path from 'path';
import * as core from '@actions/core'; import * as core from '@actions/core';
/**
* Function to get inputs from both with and env annotations.
*
* @param name
* @param mandatory
*/
export async function getInput( export async function getInput(
name: string, name: string,
mandatory: boolean mandatory: boolean
@ -117,6 +123,7 @@ export async function writeScript(
/** /**
* Function to break extension csv into an array * Function to break extension csv into an array
*
* @param extension_csv * @param extension_csv
*/ */
export async function extensionArray( 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> { export async function getExtensionPrefix(extension: string): Promise<string> {
let zend: Array<string> = ['xdebug', 'opcache', 'ioncube', 'eaccelerator']; let zend: Array<string> = ['xdebug', 'opcache', 'ioncube', 'eaccelerator'];
switch (zend.indexOf(extension)) { switch (zend.indexOf(extension)) {