From ba5306eea91f9f8be26f08d40cd8f2be21118edf Mon Sep 17 00:00:00 2001 From: Shivam Mathur Date: Fri, 4 Oct 2019 13:30:16 +0530 Subject: [PATCH 1/2] Use pre-compiled PCOV binary for PHP7.4 on windows --- __tests__/utils.test.ts | 1 + lib/utils.js | 20 +++++++++++--------- package-lock.json | 2 +- package.json | 2 +- src/ext/php_pcov.dll | Bin 0 -> 27136 bytes src/scripts/win32.ps1 | 6 ++++-- src/utils.ts | 36 +++++++++++++++--------------------- 7 files changed, 33 insertions(+), 34 deletions(-) create mode 100644 src/ext/php_pcov.dll diff --git a/__tests__/utils.test.ts b/__tests__/utils.test.ts index 849e4a19..da5fdec5 100644 --- a/__tests__/utils.test.ts +++ b/__tests__/utils.test.ts @@ -56,6 +56,7 @@ describe('Utils tests', () => { expect(await utils.readScript('darwin.sh', '7.3', 'darwin')).toBe(darwin); expect(await utils.readScript('linux.sh', '7.4', 'linux')).toBe(linux); expect(await utils.readScript('linux.sh', '7.3', 'linux')).toBe(linux); + expect(await utils.readScript('win32.ps1', '7.4', 'win32')).toBe(win32); expect(await utils.readScript('win32.ps1', '7.3', 'win32')).toBe(win32); expect(await utils.readScript('fedora.sh', '7.3', 'fedora')).toContain( 'Platform fedora is not supported' diff --git a/lib/utils.js b/lib/utils.js index 28e7f65e..26155909 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -79,24 +79,26 @@ function readScript(filename, version, os_version) { 'scripts/pcov.sh' ]); return fs.readFileSync(path.join(__dirname, '../src/scripts/7.4.sh'), 'utf8'); - case '7.3': - default: - return fs.readFileSync(path.join(__dirname, '../src/scripts/' + filename), 'utf8'); } + break; case 'linux': switch (version) { case '7.4': yield readFiles74(['scripts/xdebug.sh', 'scripts/pcov.sh']); - return fs.readFileSync(path.join(__dirname, '../src/scripts/' + filename), 'utf8'); - case '7.3': - default: - return fs.readFileSync(path.join(__dirname, '../src/scripts/' + filename), 'utf8'); + break; } + break; case 'win32': - return fs.readFileSync(path.join(__dirname, '../src/scripts/' + filename), 'utf8'); + switch (version) { + case '7.4': + yield readFiles74(['ext/php_pcov.dll']); + break; + } + break; default: return yield log('Platform ' + os_version + ' is not supported', os_version, 'error'); } + return fs.readFileSync(path.join(__dirname, '../src/scripts/' + filename), 'utf8'); }); } exports.readScript = readScript; @@ -179,7 +181,7 @@ function log(message, os_version, log_type) { exports.log = log; function getExtensionPrefix(extension) { return __awaiter(this, void 0, void 0, function* () { - let zend = ['xdebug', 'opcache']; + let zend = ['xdebug', 'opcache', 'ioncube', 'eaccelerator']; switch (zend.indexOf(extension)) { case 0: case 1: diff --git a/package-lock.json b/package-lock.json index 912c5586..b3b3be0b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "setup-php", - "version": "1.3.7", + "version": "1.3.8", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index a28afecd..6b8a1712 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "setup-php", - "version": "1.3.7", + "version": "1.3.8", "private": false, "description": "Setup php action", "main": "lib/setup-php.js", diff --git a/src/ext/php_pcov.dll b/src/ext/php_pcov.dll new file mode 100644 index 0000000000000000000000000000000000000000..a63db08da2df863695aef0bc9115ab773a2f969a GIT binary patch literal 27136 zcmeHw3w&F}mG{V&Z6zp?lG@;aOGHqLY3!hvZP}8I96#cKlPIxc8}d*bTaIk}5c0iw z&;T~qE>>vb5K?L!Zr22_FjWO(6cqr++}EK?(Xgp3|qX0fY@zl?>1Dft}}G?w0f7$ znKRoMB|WQb@%ojXn>DdidEH6P&B!k-x@p#G{#-Synm7s=lA~C##q@YmU7Ky zs=0br21u>~)mP%FM{@JLp1-FsmaY`XpKKoh5bAA@GM2(z<-8KrqYC_~JPhm6E})%w z?xEs7#-=Xf4)DE*+{n{C0s6|7w~rW0FnAmGT;JkO+dn{>mp8)%m0@9XbD8JY-^Za&U(_%^sVxo zJYdS&`-A-??x*cA9J$h{KFV0grIN-~;s+zglP~GCz9AwQb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*i*Qza981Ap36JNq~72kcMVe` z$rnlnOLmuhz2y5Pua~@8GFhT>XdH7LS2?VXn;nA=+3|?upB&FQUUB@|@$Zf)ht|2k zdA+mHS>bd$H#%=~e!=-A=l7k%&KI1&bxt_naZWl}X=dqlrTL}yQdenB>6+5U(oLl; zrJbch>CV!-O21h8aOrnS50xG({YB}i(s1cJrRPfjQaZaVvn;1>_MNgrWus-|Wp9_AEla;qd*cl^-cCWS0pGab@rdb{&{Ue)ZZ0=3H`kjx%tPk; z%@3I$Ge2W~)BJn$r1^q5%VM-tSlpJamhF~%Ee~4$-g3Y)W_i={KD75aYq7P~y3V@Z z+G!0~@3%f@{gaj1=Gm^a8Ek88UfaF4hiw03`@QW$TSmck1!V=d7xow4TX?eY9Y`~y z_>0BOj@upE9q%|)&MfD>&Ig?*oS!fCmu@fJSk_tgOxd$HQm{;G%%!FWOe*sh^V)*V z1rHTu6wNI%*`4-2`@Z7GiVqY&QT$}_Q^g01pDi9PK2khZe7yKX@z07+7Qb11s`#zq zaB*MBK*>7leutq1>3#H^kvgGP2V#eHdUKN^F8KA%?Hef z%ty_ynis%U-IiM|KFb}JFI#?#9)HI=VNJ7@*eYzRZ0l^I?F+Vk^f6@nitVem{k8+P z@7jJ~`;qMk?DuE3H*I0tJFwy@TY7=Mz))Z+a22d5@D*$?=qm^nJX-L}fih5cH))m~}8)!t(tu*E}xGN-eOnveHVD2?F5(dYJW=OiK=u`$#?oZj zU}?2QC*noJu^n@z1IA1vc<*MGMJ{x7@w0B8UJ literal 0 HcmV?d00001 diff --git a/src/scripts/win32.ps1 b/src/scripts/win32.ps1 index 82c60ca1..50658cf6 100644 --- a/src/scripts/win32.ps1 +++ b/src/scripts/win32.ps1 @@ -26,16 +26,18 @@ if($installed -ne $version) { } echo "Housekeeping in PHP.ini, enabling openssl" +$ext_dir = "C:\tools\php\ext" Add-Content C:\tools\php\php.ini "date.timezone = 'UTC'" -Set-PhpIniKey extension_dir C:\tools\php\ext +Set-PhpIniKey extension_dir $ext_dir + if($version -lt '7.4') { Enable-PhpExtension openssl } else { Add-Content C:\tools\php\php.ini "extension=php_openssl.dll" + Copy-Item "php_pcov.dll" -Destination $ext_dir"\php_pcov.dll" } echo "Installing Composer" Install-Composer -Scope System -Path C:\tools\php -$ext_dir = Get-PhpIniKey extension_dir php -v composer -V \ No newline at end of file diff --git a/src/utils.ts b/src/utils.ts index 89836723..b2bffb8f 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -70,33 +70,22 @@ export async function readScript( path.join(__dirname, '../src/scripts/7.4.sh'), 'utf8' ); - case '7.3': - default: - return fs.readFileSync( - path.join(__dirname, '../src/scripts/' + filename), - 'utf8' - ); } + break; case 'linux': switch (version) { case '7.4': await readFiles74(['scripts/xdebug.sh', 'scripts/pcov.sh']); - return fs.readFileSync( - path.join(__dirname, '../src/scripts/' + filename), - 'utf8' - ); - case '7.3': - default: - return fs.readFileSync( - path.join(__dirname, '../src/scripts/' + filename), - 'utf8' - ); + break; } + break; case 'win32': - return fs.readFileSync( - path.join(__dirname, '../src/scripts/' + filename), - 'utf8' - ); + switch (version) { + case '7.4': + await readFiles74(['ext/php_pcov.dll']); + break; + } + break; default: return await log( 'Platform ' + os_version + ' is not supported', @@ -104,6 +93,11 @@ export async function readScript( 'error' ); } + + return fs.readFileSync( + path.join(__dirname, '../src/scripts/' + filename), + 'utf8' + ); } /** @@ -189,7 +183,7 @@ export async function log( } export async function getExtensionPrefix(extension: string): Promise { - let zend: Array = ['xdebug', 'opcache']; + let zend: Array = ['xdebug', 'opcache', 'ioncube', 'eaccelerator']; switch (zend.indexOf(extension)) { case 0: case 1: From 17d90ace86636230996133068005d51503200283 Mon Sep 17 00:00:00 2001 From: Shivam Mathur Date: Fri, 4 Oct 2019 19:34:05 +0530 Subject: [PATCH 2/2] Improve examples and logging, and fix PCOV setup on linux --- README.md | 21 ++-- __tests__/features.test.ts | 6 +- __tests__/utils.test.ts | 40 +++++-- example/{laravel.yml => laravel-mysql.yml} | 14 +-- example/laravel-postgres.yml | 54 ++++++++++ example/slim-framework.yml | 21 ++++ lib/features.js | 68 ++++++------ lib/utils.js | 23 +++- src/features.ts | 119 ++++++++++++++------- src/utils.ts | 26 ++++- 10 files changed, 289 insertions(+), 103 deletions(-) rename example/{laravel.yml => laravel-mysql.yml} (86%) create mode 100644 example/laravel-postgres.yml create mode 100644 example/slim-framework.yml diff --git a/README.md b/README.md index c10339dd..dfbe1001 100644 --- a/README.md +++ b/README.md @@ -10,8 +10,8 @@ GitHub Actions status LICENSE PHP Versions Supported - Support me on Patreon Support me on Paypal - Get Help on codementor + Support me on Patreon Support me on PayPal + Contact me on Codementor

Setup PHP with required extensions, php.ini configuration and composer in [GitHub Actions](https://github.com/features/actions). This action can be added as a step in your action workflow and it will setup the PHP environment you need to test your application. Refer to [Usage](#memo-usage) section to see how to use this. @@ -44,7 +44,7 @@ Setup PHP with required extensions, php.ini configuration and composer in [GitHu - On `ubuntu` extensions which have the package in apt are installed. - On `windows` and `macOS` PECL extensions are installed. - Extensions which are installed along with PHP if specified are enabled. -- Extensions which cannot be installed gracefully leave an error message in the logs, the action is not interruped. +- Extensions which cannot be installed gracefully leave an error message in the logs, the action is not interrupted. ## :signal_strength: Coverage support - Specify `coverage: xdebug` to use `Xdebug`. @@ -70,10 +70,10 @@ with: Inputs supported by this GitHub Action. -- php-version -- extension-csv (optional) -- ini-values-csv (optional) -- coverage (optional) +- php-version `required` +- extension-csv `optional` +- ini-values-csv `optional` +- coverage `optional` See [action.yml](action.yml) for more info @@ -131,8 +131,13 @@ jobs: ### Examples -- [Laravel](./example/laravel.yml) +Examples for setting up this GitHub Action with different PHP Frameworks/Packages. +**Note:** Make sure you add steps to run your tests after the setup steps given in these examples. + +- [Laravel with MySQL](./example/laravel-mysql.yml) +- [Laravel with PostgreSQL](./example/laravel-postgres.yml) +- [Slim Framework](./example/slim-framework.yml) ## :scroll: License diff --git a/__tests__/features.test.ts b/__tests__/features.test.ts index a744c096..6083ee43 100644 --- a/__tests__/features.test.ts +++ b/__tests__/features.test.ts @@ -173,10 +173,10 @@ describe('Features tests', () => { expect(win32).toContain(''); win32 = await features.addCoverage('pcov', '7.0', 'win32'); - expect(win32).toContain('pcov requires php 7.1 or newer'); + expect(win32).toContain('PCOV requires PHP 7.1 or newer'); win32 = await features.addCoverage('pcov', '5.6', 'win32'); - expect(win32).toContain('pcov requires php 7.1 or newer'); + expect(win32).toContain('PCOV requires PHP 7.1 or newer'); win32 = await features.addCoverage('', '7.4', 'win32'); expect(win32).toEqual(''); @@ -189,6 +189,7 @@ describe('Features tests', () => { linux = await features.addCoverage('pcov', '7.4', 'linux'); expect(linux).toContain('./pcov.sh'); expect(linux).toContain('sudo sed -i "/xdebug/d" $ini_file'); + expect(linux).toContain('sudo phpdismod xdebug'); linux = await features.addCoverage('', '7.4', 'linux'); expect(linux).toEqual(''); @@ -203,7 +204,6 @@ describe('Features tests', () => { darwin = await features.addCoverage('pcov', '7.4', 'darwin'); expect(darwin).toContain('sh ./pcov.sh'); - expect(darwin).toContain('sudo sed -i \'\' "/xdebug/d" $ini_file\n'); darwin = await features.addCoverage('', '7.4', 'win32'); expect(darwin).toEqual(''); diff --git a/__tests__/utils.test.ts b/__tests__/utils.test.ts index da5fdec5..672de019 100644 --- a/__tests__/utils.test.ts +++ b/__tests__/utils.test.ts @@ -100,31 +100,53 @@ describe('Utils tests', () => { let message: string = 'Test message'; let warning_log: string = await utils.log(message, 'win32', 'warning'); - // expect(warning_log).toEqual( - // "Write-Host '" + message + "' -ForegroundColor yellow" - // ); + expect(warning_log).toEqual( + "Write-Host '" + message + "' -ForegroundColor yellow" + ); warning_log = await utils.log(message, 'linux', 'warning'); expect(warning_log).toEqual('echo "\\033[33;1m' + message + '\\033[0m"'); warning_log = await utils.log(message, 'darwin', 'warning'); expect(warning_log).toEqual('echo "\\033[33;1m' + message + '\\033[0m"'); let error_log: string = await utils.log(message, 'win32', 'error'); - // expect(error_log).toEqual( - // "Write-Host '" + message + "' -ForegroundColor red" - // ); + expect(error_log).toEqual( + "Write-Host '" + message + "' -ForegroundColor red" + ); error_log = await utils.log(message, 'linux', 'error'); expect(error_log).toEqual('echo "\\033[31;1m' + message + '\\033[0m"'); error_log = await utils.log(message, 'darwin', 'error'); expect(error_log).toEqual('echo "\\033[31;1m' + message + '\\033[0m"'); let success_log: string = await utils.log(message, 'win32', 'success'); - // expect(success_log).toEqual( - // "Write-Host '" + message + "' -ForegroundColor green" - // ); + expect(success_log).toEqual( + "Write-Host '" + message + "' -ForegroundColor green" + ); success_log = await utils.log(message, 'linux', 'success'); expect(success_log).toEqual('echo "\\033[32;1m' + message + '\\033[0m"'); success_log = await utils.log(message, 'darwin', 'success'); expect(success_log).toEqual('echo "\\033[32;1m' + message + '\\033[0m"'); + + success_log = await utils.log(message, 'win32', 'success', 'Test win'); + expect(success_log).toEqual( + "Write-Host 'Test win: " + message + "' -ForegroundColor green" + ); + }); + + it('checking log with prefix', async () => { + let message: string = 'Test message'; + let prefix_log: string = await utils.log( + message, + 'linux', + 'success', + 'Test Prefix' + ); + expect(prefix_log).toEqual( + 'echo "\\033[32;1mTest Prefix: ' + message + '\\033[0m"' + ); + prefix_log = await utils.log(message, 'darwin', 'success', 'Test'); + expect(prefix_log).toEqual( + 'echo "\\033[32;1mTest: ' + message + '\\033[0m"' + ); }); it('checking getExtensionPrefix', async () => { diff --git a/example/laravel.yml b/example/laravel-mysql.yml similarity index 86% rename from example/laravel.yml rename to example/laravel-mysql.yml index 38ff0d0b..36af164c 100644 --- a/example/laravel.yml +++ b/example/laravel-mysql.yml @@ -1,11 +1,8 @@ -name: Laravel - +name: Testing Laravel with MySQL on: [push, pull_request] - jobs: - - phpunit: - name: PHPUnit (PHP ${{ matrix.php-versions }} on ${{ matrix.operating-system }}) + laravel: + name: Laravel (PHP ${{ matrix.php-versions }} on ${{ matrix.operating-system }}) runs-on: ubuntu-latest env: DB_PASSWORD: password @@ -37,12 +34,11 @@ jobs: steps: - name: Checkout uses: actions/checkout@v1 - - name: Install PHP + - name: Setup PHP, with composer and extensions uses: shivammathur/setup-php@master #https://github.com/shivammathur/setup-php with: php-version: ${{ matrix.php-versions }} - extension-csv: mbstring, xdebug #optional - ini-values-csv: "post_max_size=256M, short_open_tag=On" #optional + extension-csv: mbstring #optional coverage: xdebug #optional - name: Install Composer dependencies run: composer install --no-progress --no-suggest --prefer-dist --optimize-autoloader diff --git a/example/laravel-postgres.yml b/example/laravel-postgres.yml new file mode 100644 index 00000000..b996bf23 --- /dev/null +++ b/example/laravel-postgres.yml @@ -0,0 +1,54 @@ +name: Testing Laravel with MySQL +on: [push, pull_request] +jobs: + laravel: + name: Laravel (PHP ${{ matrix.php-versions }} on ${{ matrix.operating-system }}) + runs-on: ubuntu-latest + env: + BROADCAST_DRIVER: log + CACHE_DRIVER: redis + QUEUE_CONNECTION: redis + SESSION_DRIVER: redis + services: + postgres: + image: postgres:10.8 + env: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + POSTGRES_DB: postgres + ports: + - 5432/tcp + options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 3 + redis: + image: redis + ports: + - 6379/tcp + options: --health-cmd="redis-cli ping" --health-interval=10s --health-timeout=5s --health-retries=3 + strategy: + fail-fast: false + max-parallel: 15 + matrix: + operating-system: [ubuntu-latest, windows-latest, macOS-latest] + php-versions: ['7.2', '7.3'] + steps: + - name: Checkout + uses: actions/checkout@v1 + - name: Setup PHP, with composer and extensions + uses: shivammathur/setup-php@master #https://github.com/shivammathur/setup-php + with: + php-version: ${{ matrix.php-versions }} + extension-csv: mbstring #optional + coverage: xdebug #optional + - name: Install Composer dependencies + run: composer install --no-progress --no-suggest --prefer-dist --optimize-autoloader + - name: Prepare the application + run: | + cp .env.example .env + php artisan key:generate + - name: Clear Config + run: php artisan config:clear + - name: Run Migration + run: php artisan migrate -v + env: + POSTGRES_HOST: localhost + POSTGRES_PORT: ${{ job.services.postgres.ports[5432] }} \ No newline at end of file diff --git a/example/slim-framework.yml b/example/slim-framework.yml new file mode 100644 index 00000000..a051ccc3 --- /dev/null +++ b/example/slim-framework.yml @@ -0,0 +1,21 @@ +name: Testing Slim Framework +on: [push, pull_request] +jobs: + build: + strategy: + max-parallel: 6 + matrix: + operating-system: [ubuntu-latest, windows-latest, macOS-latest] + php-versions: [7.2, 7.3] + runs-on: ${{ matrix.operating-system }} + steps: + - name: Checkout + uses: actions/checkout@master + - name: Setup PHP, with composer and extensions + uses: shivammathur/setup-php@master #https://github.com/shivammathur/setup-php + with: + php-version: ${{ matrix.php-versions }} + extension-csv: 'mbstring' + coverage: 'xdebug' + - name: Install dependencies + run: composer install --no-progress --no-suggest --prefer-dist --optimize-autoloader \ No newline at end of file diff --git a/lib/features.js b/lib/features.js index 262f2b84..23cb8c16 100644 --- a/lib/features.js +++ b/lib/features.js @@ -18,17 +18,17 @@ var __importStar = (this && this.__importStar) || function (mod) { Object.defineProperty(exports, "__esModule", { value: true }); const utils = __importStar(require("./utils")); const pecl = __importStar(require("./pecl")); -function addExtension(extension_csv, version, os_version) { +function addExtension(extension_csv, version, os_version, log_prefix = 'Add Extension') { return __awaiter(this, void 0, void 0, function* () { switch (os_version) { case 'win32': - return yield addExtensionWindows(extension_csv, version); + return yield addExtensionWindows(extension_csv, version, log_prefix); case 'darwin': - return yield addExtensionDarwin(extension_csv, version); + return yield addExtensionDarwin(extension_csv, version, log_prefix); case 'linux': - return yield addExtensionLinux(extension_csv, version); + return yield addExtensionLinux(extension_csv, version, log_prefix); default: - return yield utils.log('Platform ' + os_version + ' is not supported', os_version, 'error'); + return yield utils.log('Platform ' + os_version + ' is not supported', os_version, 'error', log_prefix); } }); } @@ -42,7 +42,7 @@ function addINIValues(ini_values_csv, os_version) { case 'linux': return yield addINIValuesUnix(ini_values_csv); default: - return yield utils.log('Platform ' + os_version + ' is not supported', os_version, 'error'); + return yield utils.log('Platform ' + os_version + ' is not supported', os_version, 'error', 'Add Config'); } }); } @@ -52,18 +52,18 @@ exports.addINIValues = addINIValues; * * @param extension */ -function enableExtensionWindows(extension) { +function enableExtensionWindows(extension, log_prefix) { return __awaiter(this, void 0, void 0, function* () { return (`try { $exist = Test-Path -Path $ext_dir\\php_${extension}.dll if(!(php -m | findstr -i ${extension}) -and $exist) { Add-Content C:\\tools\\php\\php.ini "${yield utils.getExtensionPrefix(extension)}=php_${extension}.dll"\n` + - (yield utils.log('Enabled ' + extension, 'win32', 'success')) + + (yield utils.log('Enabled ' + extension, 'win32', 'success', log_prefix)) + ` } elseif(php -m | findstr -i ${extension}) {\n` + - (yield utils.log('Extension ' + extension + ' was already enabled', 'win32', 'success')) + + (yield utils.log(extension + ' was already enabled', 'win32', 'success', log_prefix)) + ` } } catch [Exception] {\n` + - (yield utils.log(extension + ' could not be enabled', 'win32', 'error')) + + (yield utils.log(extension + ' could not be enabled', 'win32', 'error', log_prefix)) + ` }\n`); }); } @@ -74,13 +74,13 @@ exports.enableExtensionWindows = enableExtensionWindows; * @param extension * @param os_version */ -function enableExtensionUnix(extension, os_version) { +function enableExtensionUnix(extension, os_version, log_prefix) { return __awaiter(this, void 0, void 0, function* () { return (`if [ ! "$(php -m | grep -i ${extension})" ] && [ -e "$ext_dir/${extension}.so" ]; then echo "${yield utils.getExtensionPrefix(extension)}=${extension}" >> 'php -i | grep "Loaded Configuration" | sed -e "s|.*=>\s*||"'\n` + - (yield utils.log('Enabled ' + extension, os_version, 'success')) + + (yield utils.log('Enabled ' + extension, os_version, 'success', log_prefix)) + `;\n elif [ "$(php -m | grep -i ${extension})" ]; then \n` + - (yield utils.log('Extension ' + extension + ' was already enabled', os_version, 'success')) + + (yield utils.log(extension + ' was already enabled', os_version, 'success', log_prefix)) + `; fi\n`); }); } @@ -91,7 +91,7 @@ exports.enableExtensionUnix = enableExtensionUnix; * @param extension_csv * @param version */ -function addExtensionDarwin(extension_csv, version) { +function addExtensionDarwin(extension_csv, version, log_prefix) { return __awaiter(this, void 0, void 0, function* () { let extensions = yield utils.extensionArray(extension_csv); let script = '\n'; @@ -99,7 +99,7 @@ function addExtensionDarwin(extension_csv, version) { return __awaiter(this, void 0, void 0, function* () { extension = extension.toLowerCase(); // add script to enable extension is already installed along with php - script += yield enableExtensionUnix(extension, 'darwin'); + script += yield enableExtensionUnix(extension, 'darwin', log_prefix); switch (yield pecl.checkPECLExtension(extension)) { case true: let install_command = ''; @@ -126,9 +126,9 @@ function addExtensionDarwin(extension_csv, version) { ')" ]; then ' + install_command + ' && ' + - (yield utils.log('Installed and enabled ' + extension, 'darwin', 'success')) + + (yield utils.log('Installed and enabled ' + extension, 'darwin', 'success', log_prefix)) + ' || ' + - (yield utils.log('Could not install ' + extension + ' on PHP' + version, 'darwin', 'error')) + + (yield utils.log('Could not install ' + extension + ' on PHP' + version, 'darwin', 'error', log_prefix)) + '; fi\n'; break; case false: @@ -137,7 +137,7 @@ function addExtensionDarwin(extension_csv, version) { 'if [ ! "$(php -m | grep -i ' + extension + ')" ]; then \n' + - (yield utils.log('Could not find ' + extension + ' for PHP' + version + ' on PECL', 'darwin', 'error')) + + (yield utils.log('Could not find ' + extension + ' for PHP' + version + ' on PECL', 'darwin', 'error', log_prefix)) + '; fi\n'; break; } @@ -153,7 +153,7 @@ exports.addExtensionDarwin = addExtensionDarwin; * @param extension_csv * @param version */ -function addExtensionWindows(extension_csv, version) { +function addExtensionWindows(extension_csv, version, log_prefix) { return __awaiter(this, void 0, void 0, function* () { let extensions = yield utils.extensionArray(extension_csv); let script = '\n'; @@ -161,7 +161,7 @@ function addExtensionWindows(extension_csv, version) { return __awaiter(this, void 0, void 0, function* () { extension = extension.toLowerCase(); // add script to enable extension is already installed along with php - script += yield enableExtensionWindows(extension); + script += yield enableExtensionWindows(extension, log_prefix); switch (yield pecl.checkPECLExtension(extension)) { case true: let install_command = ''; @@ -186,9 +186,9 @@ function addExtensionWindows(extension_csv, version) { 'try { ' + install_command + '\n' + - (yield utils.log('Installed and enabled ' + extension, 'win32', 'success')) + + (yield utils.log('Installed and enabled ' + extension, 'win32', 'success', log_prefix)) + ' } catch [Exception] { ' + - (yield utils.log('Could not install ' + extension + ' on PHP' + version, 'win32', 'error')) + + (yield utils.log('Could not install ' + extension + ' on PHP' + version, 'win32', 'error', log_prefix)) + ' } }\n'; break; case false: @@ -197,7 +197,7 @@ function addExtensionWindows(extension_csv, version) { 'if(!(php -m | findstr -i ' + extension + ')) { ' + - (yield utils.log('Could not find ' + extension + ' for PHP' + version + ' on PECL', 'win32', 'error')) + + (yield utils.log('Could not find ' + extension + ' for PHP' + version + ' on PECL', 'win32', 'error', log_prefix)) + ' } \n'; break; } @@ -213,7 +213,7 @@ exports.addExtensionWindows = addExtensionWindows; * @param extension_csv * @param version */ -function addExtensionLinux(extension_csv, version) { +function addExtensionLinux(extension_csv, version, log_prefix) { return __awaiter(this, void 0, void 0, function* () { let extensions = yield utils.extensionArray(extension_csv); let script = '\n'; @@ -221,7 +221,7 @@ function addExtensionLinux(extension_csv, version) { return __awaiter(this, void 0, void 0, function* () { extension = extension.toLowerCase(); // add script to enable extension is already installed along with php - script += yield enableExtensionUnix(extension, 'linux'); + script += yield enableExtensionUnix(extension, 'linux', log_prefix); let install_command = ''; switch (version + extension) { case '7.4xdebug': @@ -247,9 +247,9 @@ function addExtensionLinux(extension_csv, version) { ')" ]; then ' + install_command + ' && ' + - (yield utils.log('Installed and enabled ' + extension, 'linux', 'success')) + + (yield utils.log('Installed and enabled ' + extension, 'linux', 'success', log_prefix)) + ' || ' + - (yield utils.log('Could not find php' + version + '-' + extension + ' on APT repository', 'linux', 'error')) + + (yield utils.log('Could not find php' + version + '-' + extension + ' on APT repository', 'linux', 'error', log_prefix)) + '; fi\n'; }); }); @@ -306,11 +306,15 @@ function addCoverage(coverage, version, os_version) { // if version is 7.1 or newer switch (version) { default: - script += yield addExtension('pcov', version, os_version); + script += yield addExtension('pcov', version, os_version, 'Set Coverage Driver'); script += yield addINIValues('pcov.enabled=1', os_version); // add command to disable xdebug and enable pcov switch (os_version) { case 'linux': + script += + 'if [ -e /etc/php/' + + version + + '/mods-available/xdebug.ini ]; then sudo phpdismod xdebug; fi\n'; script += 'sudo sed -i "/xdebug/d" $ini_file\n'; break; case 'darwin': @@ -322,19 +326,19 @@ function addCoverage(coverage, version, os_version) { break; } // success - script += yield utils.log('pcov enabled as coverage driver', os_version, 'success'); + script += yield utils.log('PCOV enabled as coverage driver', os_version, 'success', 'Set Coverage Driver'); // version is not supported break; case '5.6': case '7.0': - script += yield utils.log('pcov requires php 7.1 or newer', os_version, 'warning'); + script += yield utils.log('PCOV requires PHP 7.1 or newer', os_version, 'warning', 'Set Coverage Driver'); break; } break; //xdebug case 'xdebug': - script += yield addExtension('xdebug', version, os_version); - script += yield utils.log('Xdebug enabled as coverage driver', os_version, 'success'); + script += yield addExtension('xdebug', version, os_version, 'Set Coverage Driver'); + script += yield utils.log('Xdebug enabled as coverage driver', os_version, 'success', 'Set Coverage Driver'); break; // unknown coverage driver default: diff --git a/lib/utils.js b/lib/utils.js index 26155909..beae17af 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -156,13 +156,21 @@ function INIArray(ini_values_csv) { }); } exports.INIArray = INIArray; -function log(message, os_version, log_type) { +function log(message, os_version, log_type, prefix = '') { return __awaiter(this, void 0, void 0, function* () { const unix_color = { error: '31', success: '32', warning: '33' }; + switch (prefix) { + case '': + prefix = prefix; + break; + default: + prefix = prefix + ': '; + break; + } switch (os_version) { case 'win32': const color = { @@ -170,11 +178,20 @@ function log(message, os_version, log_type) { success: 'green', warning: 'yellow' }; - return "Write-Host '" + message + "' -ForegroundColor " + color[log_type]; + return ("Write-Host '" + + prefix + + message + + "' -ForegroundColor " + + color[log_type]); case 'linux': case 'darwin': default: - return ('echo "\\033[' + unix_color[log_type] + ';1m' + message + '\\033[0m"'); + return ('echo "\\033[' + + unix_color[log_type] + + ';1m' + + prefix + + message + + '\\033[0m"'); } }); } diff --git a/src/features.ts b/src/features.ts index 4ceed88a..e9108079 100644 --- a/src/features.ts +++ b/src/features.ts @@ -4,20 +4,22 @@ import * as pecl from './pecl'; export async function addExtension( extension_csv: string, version: string, - os_version: string + os_version: string, + log_prefix = 'Add Extension' ): Promise { switch (os_version) { case 'win32': - return await addExtensionWindows(extension_csv, version); + return await addExtensionWindows(extension_csv, version, log_prefix); case 'darwin': - return await addExtensionDarwin(extension_csv, version); + return await addExtensionDarwin(extension_csv, version, log_prefix); case 'linux': - return await addExtensionLinux(extension_csv, version); + return await addExtensionLinux(extension_csv, version, log_prefix); default: return await utils.log( 'Platform ' + os_version + ' is not supported', os_version, - 'error' + 'error', + log_prefix ); } } @@ -33,7 +35,8 @@ export async function addINIValues(ini_values_csv: string, os_version: string) { return await utils.log( 'Platform ' + os_version + ' is not supported', os_version, - 'error' + 'error', + 'Add Config' ); } } @@ -43,7 +46,10 @@ export async function addINIValues(ini_values_csv: string, os_version: string) { * * @param extension */ -export async function enableExtensionWindows(extension: string) { +export async function enableExtensionWindows( + extension: string, + log_prefix: string +) { return ( `try { $exist = Test-Path -Path $ext_dir\\php_${extension}.dll @@ -51,16 +57,22 @@ export async function enableExtensionWindows(extension: string) { Add-Content C:\\tools\\php\\php.ini "${await utils.getExtensionPrefix( extension )}=php_${extension}.dll"\n` + - (await utils.log('Enabled ' + extension, 'win32', 'success')) + + (await utils.log('Enabled ' + extension, 'win32', 'success', log_prefix)) + ` } elseif(php -m | findstr -i ${extension}) {\n` + (await utils.log( - 'Extension ' + extension + ' was already enabled', + extension + ' was already enabled', 'win32', - 'success' + 'success', + log_prefix )) + ` } } catch [Exception] {\n` + - (await utils.log(extension + ' could not be enabled', 'win32', 'error')) + + (await utils.log( + extension + ' could not be enabled', + 'win32', + 'error', + log_prefix + )) + ` }\n` ); } @@ -73,19 +85,26 @@ export async function enableExtensionWindows(extension: string) { */ export async function enableExtensionUnix( extension: string, - os_version: string + os_version: string, + log_prefix: string ) { return ( `if [ ! "$(php -m | grep -i ${extension})" ] && [ -e "$ext_dir/${extension}.so" ]; then echo "${await utils.getExtensionPrefix( extension )}=${extension}" >> 'php -i | grep "Loaded Configuration" | sed -e "s|.*=>\s*||"'\n` + - (await utils.log('Enabled ' + extension, os_version, 'success')) + + (await utils.log( + 'Enabled ' + extension, + os_version, + 'success', + log_prefix + )) + `;\n elif [ "$(php -m | grep -i ${extension})" ]; then \n` + (await utils.log( - 'Extension ' + extension + ' was already enabled', + extension + ' was already enabled', os_version, - 'success' + 'success', + log_prefix )) + `; fi\n` ); @@ -99,14 +118,15 @@ export async function enableExtensionUnix( */ export async function addExtensionDarwin( extension_csv: string, - version: string + version: string, + log_prefix: string ): Promise { let extensions: Array = await utils.extensionArray(extension_csv); let script: string = '\n'; await utils.asyncForEach(extensions, async function(extension: string) { extension = extension.toLowerCase(); // add script to enable extension is already installed along with php - script += await enableExtensionUnix(extension, 'darwin'); + script += await enableExtensionUnix(extension, 'darwin', log_prefix); switch (await pecl.checkPECLExtension(extension)) { case true: let install_command: string = ''; @@ -136,13 +156,15 @@ export async function addExtensionDarwin( (await utils.log( 'Installed and enabled ' + extension, 'darwin', - 'success' + 'success', + log_prefix )) + ' || ' + (await utils.log( 'Could not install ' + extension + ' on PHP' + version, 'darwin', - 'error' + 'error', + log_prefix )) + '; fi\n'; break; @@ -155,7 +177,8 @@ export async function addExtensionDarwin( (await utils.log( 'Could not find ' + extension + ' for PHP' + version + ' on PECL', 'darwin', - 'error' + 'error', + log_prefix )) + '; fi\n'; break; @@ -172,14 +195,15 @@ export async function addExtensionDarwin( */ export async function addExtensionWindows( extension_csv: string, - version: string + version: string, + log_prefix: string ): Promise { let extensions: Array = await utils.extensionArray(extension_csv); let script: string = '\n'; await utils.asyncForEach(extensions, async function(extension: string) { extension = extension.toLowerCase(); // add script to enable extension is already installed along with php - script += await enableExtensionWindows(extension); + script += await enableExtensionWindows(extension, log_prefix); switch (await pecl.checkPECLExtension(extension)) { case true: @@ -209,13 +233,15 @@ export async function addExtensionWindows( (await utils.log( 'Installed and enabled ' + extension, 'win32', - 'success' + 'success', + log_prefix )) + ' } catch [Exception] { ' + (await utils.log( 'Could not install ' + extension + ' on PHP' + version, 'win32', - 'error' + 'error', + log_prefix )) + ' } }\n'; break; @@ -228,7 +254,8 @@ export async function addExtensionWindows( (await utils.log( 'Could not find ' + extension + ' for PHP' + version + ' on PECL', 'win32', - 'error' + 'error', + log_prefix )) + ' } \n'; break; @@ -245,14 +272,15 @@ export async function addExtensionWindows( */ export async function addExtensionLinux( extension_csv: string, - version: string + version: string, + log_prefix: string ): Promise { let extensions: Array = await utils.extensionArray(extension_csv); let script: string = '\n'; await utils.asyncForEach(extensions, async function(extension: string) { extension = extension.toLowerCase(); // add script to enable extension is already installed along with php - script += await enableExtensionUnix(extension, 'linux'); + script += await enableExtensionUnix(extension, 'linux', log_prefix); let install_command: string = ''; switch (version + extension) { @@ -282,13 +310,15 @@ export async function addExtensionLinux( (await utils.log( 'Installed and enabled ' + extension, 'linux', - 'success' + 'success', + log_prefix )) + ' || ' + (await utils.log( 'Could not find php' + version + '-' + extension + ' on APT repository', 'linux', - 'error' + 'error', + log_prefix )) + '; fi\n'; }); @@ -343,12 +373,21 @@ export async function addCoverage( // if version is 7.1 or newer switch (version) { default: - script += await addExtension('pcov', version, os_version); + script += await addExtension( + 'pcov', + version, + os_version, + 'Set Coverage Driver' + ); script += await addINIValues('pcov.enabled=1', os_version); // add command to disable xdebug and enable pcov switch (os_version) { case 'linux': + script += + 'if [ -e /etc/php/' + + version + + '/mods-available/xdebug.ini ]; then sudo phpdismod xdebug; fi\n'; script += 'sudo sed -i "/xdebug/d" $ini_file\n'; break; case 'darwin': @@ -362,29 +401,37 @@ export async function addCoverage( // success script += await utils.log( - 'pcov enabled as coverage driver', + 'PCOV enabled as coverage driver', os_version, - 'success' + 'success', + 'Set Coverage Driver' ); // version is not supported break; case '5.6': case '7.0': script += await utils.log( - 'pcov requires php 7.1 or newer', + 'PCOV requires PHP 7.1 or newer', os_version, - 'warning' + 'warning', + 'Set Coverage Driver' ); break; } break; //xdebug case 'xdebug': - script += await addExtension('xdebug', version, os_version); + script += await addExtension( + 'xdebug', + version, + os_version, + 'Set Coverage Driver' + ); script += await utils.log( 'Xdebug enabled as coverage driver', os_version, - 'success' + 'success', + 'Set Coverage Driver' ); break; // unknown coverage driver diff --git a/src/utils.ts b/src/utils.ts index b2bffb8f..866f0a80 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -157,13 +157,22 @@ export async function INIArray(ini_values_csv: string): Promise> { export async function log( message: string, os_version: string, - log_type: string + log_type: string, + prefix = '' ): Promise { const unix_color: any = { error: '31', success: '32', warning: '33' }; + switch (prefix) { + case '': + prefix = prefix; + break; + default: + prefix = prefix + ': '; + break; + } switch (os_version) { case 'win32': const color: any = { @@ -171,13 +180,24 @@ export async function log( success: 'green', warning: 'yellow' }; - return "Write-Host '" + message + "' -ForegroundColor " + color[log_type]; + return ( + "Write-Host '" + + prefix + + message + + "' -ForegroundColor " + + color[log_type] + ); case 'linux': case 'darwin': default: return ( - 'echo "\\033[' + unix_color[log_type] + ';1m' + message + '\\033[0m"' + 'echo "\\033[' + + unix_color[log_type] + + ';1m' + + prefix + + message + + '\\033[0m"' ); } }