From 99bbaa2a5885594dd981ec78a1af50a71f7e397a Mon Sep 17 00:00:00 2001 From: Shivam Mathur Date: Fri, 11 Oct 2019 23:09:05 +0530 Subject: [PATCH] Improve documentation --- action.yml | 10 +++++----- lib/coverage.js | 25 +++++++++++++++++++++++++ lib/extensions.js | 8 ++++++++ lib/utils.js | 12 ++++++++++++ src/coverage.ts | 25 +++++++++++++++++++++++++ src/extensions.ts | 8 ++++++++ src/scripts/linux.sh | 9 +++------ src/utils.ts | 12 ++++++++++++ 8 files changed, 98 insertions(+), 11 deletions(-) diff --git a/action.yml b/action.yml index 45f0b5f9..5e88def7 100644 --- a/action.yml +++ b/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' diff --git a/lib/coverage.js b/lib/coverage.js index 3451c57b..52a3a093 100644 --- a/lib/coverage.js +++ b/lib/coverage.js @@ -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'; diff --git a/lib/extensions.js b/lib/extensions.js index db448175..9f0c3f99 100644 --- a/lib/extensions.js +++ b/lib/extensions.js @@ -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) { diff --git a/lib/utils.js b/lib/utils.js index c283638c..7d923847 100644 --- a/lib/utils.js +++ b/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']; diff --git a/src/coverage.ts b/src/coverage.ts index b349efbd..6d9204c3 100644 --- a/src/coverage.ts +++ b/src/coverage.ts @@ -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) { diff --git a/src/extensions.ts b/src/extensions.ts index b72da2e2..68d7a202 100644 --- a/src/extensions.ts +++ b/src/extensions.ts @@ -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, diff --git a/src/scripts/linux.sh b/src/scripts/linux.sh index 0a33e846..d2553078 100644 --- a/src/scripts/linux.sh +++ b/src/scripts/linux.sh @@ -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 diff --git a/src/utils.ts b/src/utils.ts index 73d21e39..0b22f572 100644 --- a/src/utils.ts +++ b/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 { let zend: Array = ['xdebug', 'opcache', 'ioncube', 'eaccelerator']; switch (zend.indexOf(extension)) {