Merge pull request #133 from shivammathur/develop

1.7.0
This commit is contained in:
Shivam Mathur 2019-12-31 06:54:06 +05:30 committed by GitHub
commit 0c9f8a8e7e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
46 changed files with 1308 additions and 796 deletions

View File

@ -13,13 +13,14 @@
<a href="#tada-php-support" title="PHP Versions Supported"><img alt="PHP Versions Supported" src="https://img.shields.io/badge/php-%3E%3D%205.6-8892BF.svg"></a> <a href="#tada-php-support" title="PHP Versions Supported"><img alt="PHP Versions Supported" src="https://img.shields.io/badge/php-%3E%3D%205.6-8892BF.svg"></a>
</p> </p>
Setup PHP with required extensions, php.ini configuration, code-coverage support and composer in [GitHub Actions](https://github.com/features/actions "GitHub Actions"). This action gives you a cross platform interface to setup the PHP environment you need to test your application. Refer to [Usage](#memo-usage "How to use this") section and [examples](#examples "Examples of use") to see how to use this. Setup PHP with required extensions, php.ini configuration, code-coverage support and tools like composer in [GitHub Actions](https://github.com/features/actions "GitHub Actions"). This action gives you a cross platform interface to setup the PHP environment you need to test your application. Refer to [Usage](#memo-usage "How to use this") section and [examples](#examples "Examples of use") to see how to use this.
## Contents ## Contents
- [PHP Support](#tada-php-support) - [PHP Support](#tada-php-support)
- [OS/Platform Support](#cloud-osplatform-support) - [OS/Platform Support](#cloud-osplatform-support)
- [PHP Extension Support](#wrench-php-extension-support) - [PHP Extension Support](#heavy_plus_sign-php-extension-support)
- [Tools Support](#wrench-tools-support)
- [Coverage support](#signal_strength-coverage-support) - [Coverage support](#signal_strength-coverage-support)
- [Xdebug](#xdebug) - [Xdebug](#xdebug)
- [PCOV](#pcov) - [PCOV](#pcov)
@ -49,7 +50,7 @@ Setup PHP with required extensions, php.ini configuration, code-coverage support
|7.4|`Stable`|`Active`| |7.4|`Stable`|`Active`|
|8.0|`Experimental`|`In development`| |8.0|`Experimental`|`In development`|
**Note:** Specifying `8.0` in `php-version` input installs a nightly build of `PHP 8.0.0-dev` with `PHP JIT` support. See [experimental setup](#experimental-setup) for more information. **Note:** Specifying `8.0` in `php-version` input installs a nightly build of `PHP 8.0.0-dev` with `PHP JIT`, `Union Types v2` and other [new features](https://wiki.php.net/rfc#php_80 "New features implemented in PHP 8"). See [experimental setup](#experimental-setup) for more information.
## :cloud: OS/Platform Support ## :cloud: OS/Platform Support
@ -60,13 +61,28 @@ Setup PHP with required extensions, php.ini configuration, code-coverage support
|Ubuntu 16.04|`ubuntu-16.04`| |Ubuntu 16.04|`ubuntu-16.04`|
|macOS X Catalina 10.15|`macOS-latest` or `macOS-10.15`| |macOS X Catalina 10.15|`macOS-latest` or `macOS-10.15`|
## :wrench: 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: true`. - 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 `windows` extensions which have `windows` binary on `PECL` can be installed. - On `windows` extensions which have `windows` binary on `PECL` can be installed.
- On `macOS` extensions which are on `PECL` can be installed. - On `macOS` extensions which are on `PECL` can be installed.
- Extensions which are installed along with PHP if specified are enabled. - 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 interrupted. - Extensions which cannot be installed gracefully leave an error message in the logs, the action is not interrupted.
## :wrench: Tools Support
The latest version of the following tools can be setup globally using the `tools` input
`composer`, `codeception`, `deployer`, `pecl`, `phinx`, `phpcbf`, `phpcpd`, `php-cs-fixer`, `phpcs`, `phpmd`, `phpstan`, `phpunit`, `prestissimo`, `psalm`
```yml
uses: shivammathur/setup-php@v1
with:
php-version: '7.4'
tools: php-cs-fixer, phpunit
```
**Note:** `composer` is setup by default, so that is not required to be specified.
## :signal_strength: Coverage support ## :signal_strength: Coverage support
### Xdebug ### Xdebug
@ -103,7 +119,7 @@ Specify `coverage: none` to disable both `Xdebug` and `PCOV`.
Consider disabling the coverage using this PHP action for these reasons. Consider disabling the coverage using this PHP action for these reasons.
- You are not generating coverage reports while testing. - You are not generating coverage reports while testing.
- It will disable `Xdebug`, which will have a positive impact on PHP performance. - It will remove `Xdebug`, which will have a positive impact on PHP performance.
- You are using `phpdbg` for running your tests. - You are using `phpdbg` for running your tests.
```yaml ```yaml
@ -121,7 +137,7 @@ Inputs supported by this GitHub Action.
- extensions `optional` - extensions `optional`
- ini-values `optional` - ini-values `optional`
- coverage `optional` - coverage `optional`
- pecl `optional` - tools `optional`
See [action.yml](action.yml "Metadata for this GitHub Action") and usage below for more info. See [action.yml](action.yml "Metadata for this GitHub Action") and usage below for more info.
@ -141,7 +157,7 @@ steps:
extensions: mbstring, intl #optional, setup extensions extensions: mbstring, intl #optional, setup extensions
ini-values: post_max_size=256M, short_open_tag=On #optional, setup php.ini configuration ini-values: post_max_size=256M, short_open_tag=On #optional, setup php.ini configuration
coverage: xdebug #optional, setup coverage driver coverage: xdebug #optional, setup coverage driver
pecl: false #optional, setup PECL tools: php-cs-fixer, phpunit #optional, setup tools globally
``` ```
### Matrix Setup ### Matrix Setup
@ -168,7 +184,7 @@ jobs:
extensions: mbstring, intl #optional, setup extensions extensions: mbstring, intl #optional, setup extensions
ini-values: post_max_size=256M, short_open_tag=On #optional, setup php.ini configuration ini-values: post_max_size=256M, short_open_tag=On #optional, setup php.ini configuration
coverage: xdebug #optional, setup coverage driver coverage: xdebug #optional, setup coverage driver
pecl: false #optional, setup PECL tools: php-cs-fixer, phpunit #optional, setup tools globally
``` ```
### Experimental Setup ### Experimental Setup
@ -179,6 +195,7 @@ jobs:
- `PECL` is installed by default with this version on `ubuntu`. - `PECL` is installed by default with this version on `ubuntu`.
- Some extensions might not support this version currently. - Some extensions might not support this version currently.
- Refer to this [RFC](https://wiki.php.net/rfc/jit "PHP JIT RFC configuration") for configuring `PHP JIT` on this version. - Refer to this [RFC](https://wiki.php.net/rfc/jit "PHP JIT RFC configuration") for configuring `PHP JIT` on this version.
- Refer to this [list of RFCs](https://wiki.php.net/rfc#php_80 "List of RFCs implemented in PHP8") implemented in this version.
```yaml ```yaml
steps: steps:
@ -191,7 +208,8 @@ steps:
php-version: '8.0' php-version: '8.0'
extensions: mbstring #optional, setup extensions extensions: mbstring #optional, setup extensions
ini-values: opcache.jit_buffer_size=256M, opcache.jit=1235, pcre.jit=1 #optional, setup php.ini configuration ini-values: opcache.jit_buffer_size=256M, opcache.jit=1235, pcre.jit=1 #optional, setup php.ini configuration
coverage: pcov #optional, setup PCOV, Xdebug does not support this version yet. coverage: pcov #optional, setup PCOV, Xdebug does not support this version yet.
tools: php-cs-fixer, phpunit #optional, setup tools globally
``` ```
### Cache dependencies ### Cache dependencies
@ -208,7 +226,7 @@ You can persist composer's internal cache directory using the [`action/cache`](h
- name: Cache dependencies - name: Cache dependencies
uses: actions/cache@v1 uses: actions/cache@v1
with: with:
path: ${{ steps.composer-cache.outputs.dir }} path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer- restore-keys: ${{ runner.os }}-composer-
@ -216,6 +234,12 @@ You can persist composer's internal cache directory using the [`action/cache`](h
run: composer install --prefer-dist run: composer install --prefer-dist
``` ```
In the above example, if you support a range of `composer` dependencies and do not commit `composer.lock`, you can use the hash of `composer.json` as the key for your cache.
```yml
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
```
### Problem Matchers ### Problem Matchers
You can setup problem matchers for your `PHPUnit` output. This will scan the errors in your tests and surface that information prominently in the GitHub Actions UI by creating annotations and log file decorations. You can setup problem matchers for your `PHPUnit` output. This will scan the errors in your tests and surface that information prominently in the GitHub Actions UI by creating annotations and log file decorations.

View File

@ -2,20 +2,15 @@ import * as coverage from '../src/coverage';
jest.mock('../src/extensions', () => ({ jest.mock('../src/extensions', () => ({
addExtension: jest.fn().mockImplementation(extension => { addExtension: jest.fn().mockImplementation(extension => {
return 'addExtension ' + extension + '\n'; return 'add_extension ' + extension + '\n';
}) })
})); }));
describe('Config tests', () => { describe('Config tests', () => {
it('checking addCoverage with PCOV on windows', async () => { it('checking addCoverage with PCOV on windows', async () => {
let win32: string = await coverage.addCoverage('pcov', '7.4', 'win32'); let win32: string = await coverage.addCoverage('pcov', '7.4', 'win32');
expect(win32).toContain('addExtension pcov'); expect(win32).toContain('add_extension pcov');
expect(win32).toContain( expect(win32).toContain('Remove-Extension xdebug');
'if(php -m | findstr -i xdebug) { Disable-PhpExtension xdebug $php_dir'
);
expect(win32).toContain(
'if (Test-Path $ext_dir\\php_xdebug.dll) { Remove-Item $ext_dir\\php_xdebug.dll }'
);
win32 = await coverage.addCoverage('pcov', '7.0', 'win32'); win32 = await coverage.addCoverage('pcov', '7.0', 'win32');
expect(win32).toContain('PHP 7.1 or newer is required'); expect(win32).toContain('PHP 7.1 or newer is required');
@ -26,24 +21,19 @@ describe('Config tests', () => {
it('checking addCoverage with PCOV on linux', async () => { it('checking addCoverage with PCOV on linux', async () => {
const linux: string = await coverage.addCoverage('pcov', '7.4', 'linux'); const linux: string = await coverage.addCoverage('pcov', '7.4', 'linux');
expect(linux).toContain('addExtension pcov'); expect(linux).toContain('add_extension pcov');
expect(linux).toContain('sudo sed -i "/xdebug/d" "$ini_file"'); expect(linux).toContain('remove_extension xdebug');
expect(linux).toContain('sudo phpdismod -v 7.4 xdebug');
expect(linux).toContain(
'sudo DEBIAN_FRONTEND=noninteractive apt-fast remove php-xdebug'
);
}); });
it('checking addCoverage with PCOV on darwin', async () => { it('checking addCoverage with PCOV on darwin', async () => {
const darwin: string = await coverage.addCoverage('pcov', '7.4', 'darwin'); const darwin: string = await coverage.addCoverage('pcov', '7.4', 'darwin');
expect(darwin).toContain('addExtension pcov'); expect(darwin).toContain('add_extension pcov');
expect(darwin).toContain('sudo sed -i \'\' "/xdebug/d" "$ini_file"'); expect(darwin).toContain('remove_extension xdebug');
expect(darwin).toContain('sudo rm -rf "$ext_dir"/xdebug.so');
}); });
it('checking addCoverage with Xdebug on windows', async () => { it('checking addCoverage with Xdebug on windows', async () => {
const win32: string = await coverage.addCoverage('xdebug', '7.4', 'win32'); const win32: string = await coverage.addCoverage('xdebug', '7.4', 'win32');
expect(win32).toContain('addExtension xdebug'); expect(win32).toContain('add_extension xdebug');
}); });
it('checking addCoverage with Xdebug on windows', async () => { it('checking addCoverage with Xdebug on windows', async () => {
@ -53,7 +43,7 @@ describe('Config tests', () => {
it('checking addCoverage with Xdebug on linux', async () => { it('checking addCoverage with Xdebug on linux', async () => {
const linux: string = await coverage.addCoverage('xdebug', '7.4', 'linux'); const linux: string = await coverage.addCoverage('xdebug', '7.4', 'linux');
expect(linux).toContain('addExtension xdebug'); expect(linux).toContain('add_extension xdebug');
}); });
it('checking addCoverage with Xdebug on linux', async () => { it('checking addCoverage with Xdebug on linux', async () => {
@ -67,7 +57,7 @@ describe('Config tests', () => {
'7.4', '7.4',
'darwin' 'darwin'
); );
expect(darwin).toContain('addExtension xdebug'); expect(darwin).toContain('add_extension xdebug');
}); });
it('checking addCoverage with Xdebug on darwin', async () => { it('checking addCoverage with Xdebug on darwin', async () => {
@ -81,33 +71,20 @@ describe('Config tests', () => {
it('checking disableCoverage windows', async () => { it('checking disableCoverage windows', async () => {
const win32 = await coverage.addCoverage('none', '7.4', 'win32'); const win32 = await coverage.addCoverage('none', '7.4', 'win32');
expect(win32).toContain('Disable-PhpExtension xdebug'); expect(win32).toContain('Remove-Extension xdebug');
expect(win32).toContain('Disable-PhpExtension pcov'); expect(win32).toContain('Remove-Extension pcov');
expect(win32).toContain(
'if (Test-Path $ext_dir\\php_xdebug.dll) { Remove-Item $ext_dir\\php_xdebug.dll }'
);
expect(win32).toContain(
'if (Test-Path $ext_dir\\php_pcov.dll) { Remove-Item $ext_dir\\php_pcov.dll }'
);
}); });
it('checking disableCoverage on linux', async () => { it('checking disableCoverage on linux', async () => {
const linux: string = await coverage.addCoverage('none', '7.4', 'linux'); const linux: string = await coverage.addCoverage('none', '7.4', 'linux');
expect(linux).toContain('sudo phpdismod -v 7.4 xdebug'); expect(linux).toContain('remove_extension xdebug');
expect(linux).toContain('sudo phpdismod -v 7.4 pcov'); expect(linux).toContain('remove_extension pcov');
expect(linux).toContain('sudo sed -i "/xdebug/d" "$ini_file"');
expect(linux).toContain('sudo sed -i "/pcov/d" "$ini_file"');
expect(linux).toContain(
'sudo DEBIAN_FRONTEND=noninteractive apt-fast remove php-xdebug php-pcov'
);
}); });
it('checking disableCoverage on darwin', async () => { it('checking disableCoverage on darwin', async () => {
const darwin: string = await coverage.addCoverage('none', '7.4', 'darwin'); const darwin: string = await coverage.addCoverage('none', '7.4', 'darwin');
expect(darwin).toContain('sudo sed -i \'\' "/xdebug/d" "$ini_file"'); expect(darwin).toContain('remove_extension xdebug');
expect(darwin).toContain('sudo sed -i \'\' "/pcov/d" "$ini_file"'); expect(darwin).toContain('remove_extension pcov');
expect(darwin).toContain('sudo rm -rf "$ext_dir"/xdebug.so');
expect(darwin).toContain('sudo rm -rf "$ext_dir"/pcov.so');
}); });
it('checking no or invalid coverage driver', async () => { it('checking no or invalid coverage driver', async () => {

View File

@ -3,20 +3,21 @@ import * as extensions from '../src/extensions';
describe('Extension tests', () => { describe('Extension tests', () => {
it('checking addExtensionOnWindows', async () => { it('checking addExtensionOnWindows', async () => {
let win32: string = await extensions.addExtension( let win32: string = await extensions.addExtension(
'xdebug, pcov, redis', 'xdebug, pcov, phalcon4',
'7.4', '7.4',
'win32' 'win32'
); );
expect(win32).toContain('Add-Extension xdebug'); expect(win32).toContain('Add-Extension xdebug');
expect(win32).toContain('Add-Extension pcov'); expect(win32).toContain('Add-Extension pcov');
expect(win32).toContain('Add-Extension redis beta'); expect(win32).toContain('phalcon.ps1 phalcon4');
win32 = await extensions.addExtension( win32 = await extensions.addExtension(
'does_not_exist', 'phalcon3, does_not_exist',
'7.2', '7.2',
'win32', 'win32',
true true
); );
expect(win32).toContain('phalcon.ps1 phalcon3');
expect(win32).toContain('Add-Extension does_not_exist'); expect(win32).toContain('Add-Extension does_not_exist');
win32 = await extensions.addExtension('xdebug', '7.2', 'fedora'); win32 = await extensions.addExtension('xdebug', '7.2', 'fedora');
@ -25,7 +26,7 @@ describe('Extension tests', () => {
it('checking addExtensionOnLinux', async () => { it('checking addExtensionOnLinux', async () => {
let linux: string = await extensions.addExtension( let linux: string = await extensions.addExtension(
'xdebug, pcov, redis', 'xdebug, pcov',
'7.4', '7.4',
'linux' 'linux'
); );
@ -37,9 +38,6 @@ describe('Extension tests', () => {
'sudo DEBIAN_FRONTEND=noninteractive apt-get install -y php7.4-pcov' 'sudo DEBIAN_FRONTEND=noninteractive apt-get install -y php7.4-pcov'
); );
expect(linux).toContain('pecl install pcov'); expect(linux).toContain('pecl install pcov');
expect(linux).toContain(
'sudo DEBIAN_FRONTEND=noninteractive apt-get install -y php7.4-igbinary php7.4-redis'
);
linux = await extensions.addExtension('gearman', '7.0', 'linux'); linux = await extensions.addExtension('gearman', '7.0', 'linux');
expect(linux).toContain('gearman.sh 7.0'); expect(linux).toContain('gearman.sh 7.0');
@ -51,8 +49,8 @@ describe('Extension tests', () => {
'7.2', '7.2',
'linux' 'linux'
); );
expect(linux).toContain('phalcon.sh 3.4.x 7.2'); expect(linux).toContain('phalcon.sh phalcon3 7.2');
expect(linux).toContain('phalcon.sh master 7.2'); expect(linux).toContain('phalcon.sh phalcon4 7.2');
expect(linux).toContain('gearman.sh 7.2'); expect(linux).toContain('gearman.sh 7.2');
linux = await extensions.addExtension( linux = await extensions.addExtension(
@ -60,12 +58,12 @@ describe('Extension tests', () => {
'7.3', '7.3',
'linux' 'linux'
); );
expect(linux).toContain('phalcon.sh 3.4.x 7.3'); expect(linux).toContain('phalcon.sh phalcon3 7.3');
expect(linux).toContain('phalcon.sh master 7.3'); expect(linux).toContain('phalcon.sh phalcon4 7.3');
expect(linux).toContain('gearman.sh 7.3'); expect(linux).toContain('gearman.sh 7.3');
linux = await extensions.addExtension('phalcon4, gearman', '7.4', 'linux'); linux = await extensions.addExtension('phalcon4, gearman', '7.4', 'linux');
expect(linux).toContain('phalcon.sh master 7.4'); expect(linux).toContain('phalcon.sh phalcon4 7.4');
expect(linux).toContain('gearman.sh 7.4'); expect(linux).toContain('gearman.sh 7.4');
linux = await extensions.addExtension('xdebug', '7.2', 'fedora'); linux = await extensions.addExtension('xdebug', '7.2', 'fedora');
@ -81,6 +79,12 @@ describe('Extension tests', () => {
expect(darwin).toContain('sudo pecl install xdebug'); expect(darwin).toContain('sudo pecl install xdebug');
expect(darwin).toContain('sudo pecl install pcov'); expect(darwin).toContain('sudo pecl install pcov');
darwin = await extensions.addExtension('phalcon3', '7.0', 'darwin');
expect(darwin).toContain('phalcon_darwin.sh phalcon3 7.0');
darwin = await extensions.addExtension('phalcon4', '7.3', 'darwin');
expect(darwin).toContain('phalcon_darwin.sh phalcon4 7.3');
darwin = await extensions.addExtension('pcov', '5.6', 'darwin'); darwin = await extensions.addExtension('pcov', '5.6', 'darwin');
expect(darwin).toContain('sudo pecl install pcov'); expect(darwin).toContain('sudo pecl install pcov');

View File

@ -13,6 +13,11 @@ jest.mock('../src/install', () => ({
const extension_csv: string = process.env['extensions'] || ''; const extension_csv: string = process.env['extensions'] || '';
const ini_values_csv: string = process.env['ini-values'] || ''; const ini_values_csv: string = process.env['ini-values'] || '';
const coverage_driver: string = process.env['coverage'] || ''; const coverage_driver: string = process.env['coverage'] || '';
let tools_csv: string = process.env['tools'] || '';
const pecl: string = process.env['pecl'] || '';
if (pecl == 'true') {
tools_csv = 'pecl, ' + tools_csv;
}
let script = 'initial script ' + filename + version + os_version; let script = 'initial script ' + filename + version + os_version;
if (extension_csv) { if (extension_csv) {
@ -24,6 +29,9 @@ jest.mock('../src/install', () => ({
if (coverage_driver) { if (coverage_driver) {
script += 'set coverage driver'; script += 'set coverage driver';
} }
if (tools_csv) {
script += 'add_tool';
}
return script; return script;
} }
@ -32,23 +40,17 @@ jest.mock('../src/install', () => ({
async (): Promise<string> => { async (): Promise<string> => {
const os_version: string = process.env['RUNNER_OS'] || ''; const os_version: string = process.env['RUNNER_OS'] || '';
let version: string = process.env['php-version'] || ''; let version: string = process.env['php-version'] || '';
version = version.length > 1 ? version : version + '.0'; version = version.length > 1 ? version.slice(0, 3) : version + '.0';
let script = ''; let script = '';
switch (os_version) { switch (os_version) {
case 'darwin': case 'darwin':
case 'linux':
script = await install.build(os_version + '.sh', version, os_version); script = await install.build(os_version + '.sh', version, os_version);
script += 'sh script.sh ' + version + ' ' + __dirname; script += 'sh script.sh ' + version + ' ' + __dirname;
break; break;
case 'linux': {
const pecl: string = process.env['pecl'] || '';
script = await install.build(os_version + '.sh', version, os_version);
script += 'sh script.sh ' + version + ' ' + pecl + ' ' + __dirname;
break;
}
case 'win32': case 'win32':
script = await install.build(os_version + '.sh', version, os_version); script = await install.build(os_version + '.sh', version, os_version);
script += script += 'pwsh script.ps1 ' + version + ' ' + __dirname;
'pwsh script.ps1 -version ' + version + ' -dir ' + __dirname;
break; break;
default: default:
script += os_version + ' is not supported'; script += os_version + ' is not supported';
@ -69,79 +71,83 @@ jest.mock('../src/install', () => ({
* @param coverage_driver * @param coverage_driver
*/ */
function setEnv( function setEnv(
version: string, version: string | number,
os: string, os: string,
extension_csv: string, extension_csv: string,
ini_values_csv: string, ini_values_csv: string,
coverage_driver: string, coverage_driver: string,
tools: string,
pecl: string pecl: string
): void { ): void {
process.env['php-version'] = version; process.env['php-version'] = version.toString();
process.env['RUNNER_OS'] = os; process.env['RUNNER_OS'] = os;
process.env['extensions'] = extension_csv; process.env['extensions'] = extension_csv;
process.env['ini-values'] = ini_values_csv; process.env['ini-values'] = ini_values_csv;
process.env['coverage'] = coverage_driver; process.env['coverage'] = coverage_driver;
process.env['tools'] = tools;
process.env['pecl'] = pecl; process.env['pecl'] = pecl;
} }
describe('Install', () => { describe('Install', () => {
it('Test install on windows', async () => { it('Test install on windows', async () => {
setEnv('7.0', 'win32', '', '', '', ''); setEnv('7.0', 'win32', '', '', '', '', '');
// @ts-ignore // @ts-ignore
let script: string = await install.run(); let script: string = await install.run();
expect(script).toContain('initial script'); expect(script).toContain('initial script');
expect(script).toContain('pwsh script.ps1 -version 7.0 -dir ' + __dirname); expect(script).toContain('pwsh script.ps1 7.0 ' + __dirname);
setEnv('7.3', 'win32', '', '', '', ''); setEnv('7.3', 'win32', '', '', '', '', '');
// @ts-ignore // @ts-ignore
script = await install.run(); script = await install.run();
expect(script).toContain('initial script'); expect(script).toContain('initial script');
expect(script).toContain('pwsh script.ps1 -version 7.3 -dir ' + __dirname); expect(script).toContain('pwsh script.ps1 7.3 ' + __dirname);
setEnv('7.3', 'win32', 'a, b', 'a=b', 'x', ''); setEnv('7.3', 'win32', 'a, b', 'a=b', 'x', '', '');
// @ts-ignore // @ts-ignore
script = await install.run(); script = await install.run();
expect(script).toContain('initial script'); expect(script).toContain('initial script');
expect(script).toContain('install extensions'); expect(script).toContain('install extensions');
expect(script).toContain('edit php.ini'); expect(script).toContain('edit php.ini');
expect(script).toContain('set coverage driver'); expect(script).toContain('set coverage driver');
expect(script).toContain('pwsh script.ps1 -version 7.3 -dir ' + __dirname); expect(script).toContain('pwsh script.ps1 7.3 ' + __dirname);
}); });
it('Test install on linux', async () => { it('Test install on linux', async () => {
setEnv('7.3', 'linux', '', '', '', ''); setEnv('7.3', 'linux', '', '', '', '', '');
// @ts-ignore // @ts-ignore
let script: string = await install.run(); let script: string = await install.run();
expect(script).toContain('initial script'); expect(script).toContain('initial script');
expect(script).toContain('sh script.sh 7.3 '); expect(script).toContain('sh script.sh 7.3 ');
setEnv('7.3', 'linux', 'a, b', 'a=b', 'x', 'true'); setEnv('7.3', 'linux', 'a, b', 'a=b', 'x', 'phpunit', 'true');
// @ts-ignore // @ts-ignore
script = await install.run(); script = await install.run();
expect(script).toContain('initial script'); expect(script).toContain('initial script');
expect(script).toContain('install extensions'); expect(script).toContain('install extensions');
expect(script).toContain('edit php.ini'); expect(script).toContain('edit php.ini');
expect(script).toContain('set coverage driver'); expect(script).toContain('set coverage driver');
expect(script).toContain('sh script.sh 7.3 true'); expect(script).toContain('sh script.sh 7.3');
expect(script).toContain('add_tool');
setEnv('7.3', 'linux', 'a, b', 'a=b', 'x', 'true'); setEnv('7.3', 'linux', 'a, b', 'a=b', 'x', 'phpunit', '');
// @ts-ignore // @ts-ignore
script = await install.run(); script = await install.run();
expect(script).toContain('initial script'); expect(script).toContain('initial script');
expect(script).toContain('install extensions'); expect(script).toContain('install extensions');
expect(script).toContain('edit php.ini'); expect(script).toContain('edit php.ini');
expect(script).toContain('set coverage driver'); expect(script).toContain('set coverage driver');
expect(script).toContain('sh script.sh 7.3 true'); expect(script).toContain('sh script.sh 7.3');
expect(script).toContain('add_tool');
}); });
it('Test install on darwin', async () => { it('Test install on darwin', async () => {
setEnv('7.3', 'darwin', '', '', '', ''); setEnv('7.3', 'darwin', '', '', '', '', '');
// @ts-ignore // @ts-ignore
let script: string = await install.run(); let script: string = await install.run();
expect(script).toContain('initial script'); expect(script).toContain('initial script');
expect(script).toContain('sh script.sh 7.3 ' + __dirname); expect(script).toContain('sh script.sh 7.3 ' + __dirname);
setEnv('7.3', 'darwin', 'a, b', 'a=b', 'x', ''); setEnv('7.3', 'darwin', 'a, b', 'a=b', 'x', '', '');
// @ts-ignore // @ts-ignore
script = await install.run(); script = await install.run();
expect(script).toContain('initial script'); expect(script).toContain('initial script');
@ -150,4 +156,24 @@ describe('Install', () => {
expect(script).toContain('set coverage driver'); expect(script).toContain('set coverage driver');
expect(script).toContain('sh script.sh 7.3 ' + __dirname); expect(script).toContain('sh script.sh 7.3 ' + __dirname);
}); });
it('Test malformed version inputs', async () => {
setEnv('7.4.1', 'darwin', '', '', '', '', '');
// @ts-ignore
let script: string = await install.run();
expect(script).toContain('initial script');
expect(script).toContain('sh script.sh 7.4 ' + __dirname);
setEnv(8.0, 'darwin', '', '', '', '', '');
// @ts-ignore
script = await install.run();
expect(script).toContain('initial script');
expect(script).toContain('sh script.sh 8.0 ' + __dirname);
setEnv(8, 'darwin', '', '', '', '', '');
// @ts-ignore
script = await install.run();
expect(script).toContain('initial script');
expect(script).toContain('sh script.sh 8.0 ' + __dirname);
});
}); });

110
__tests__/tools.test.ts Normal file
View File

@ -0,0 +1,110 @@
import * as tools from '../src/tools';
describe('Tools tests', () => {
it('checking getToolCommand', async () => {
expect(await tools.getToolCommand('linux')).toBe('add_tool ');
expect(await tools.getToolCommand('darwin')).toBe('add_tool ');
expect(await tools.getToolCommand('win32')).toBe('Add-Tool ');
expect(await tools.getToolCommand('fedora')).toContain(
'Platform fedora is not supported'
);
});
it('checking getPECLCommand', async () => {
expect(await tools.getPECLCommand('linux')).toBe('add_pecl ');
expect(await tools.getPECLCommand('darwin')).toBe('add_pecl ');
expect(await tools.getPECLCommand('win32')).toBe('Add-PECL ');
expect(await tools.getPECLCommand('fedora')).toContain(
'Platform fedora is not supported'
);
});
it('checking linkTool', async () => {
expect(await tools.linkTool('tool', 'linux')).toContain(
'sudo ln -s "$(composer -q global config home)"/vendor/bin/tool /usr/local/bin/tool'
);
expect(await tools.linkTool('tool', 'darwin')).toContain(
'sudo ln -s "$(composer -q global config home)"/vendor/bin/tool /usr/local/bin/tool'
);
expect(await tools.linkTool('tool', 'win32')).toContain(
'$composer_dir = composer -q global config home | % {$_ -replace "/", "\\"}'
);
expect(await tools.linkTool('tool', 'win32')).toContain(
'Add-Content -Path $PsHome\\profile.ps1 -Value "New-Alias tool $composer_dir\\vendor\\bin\\tool.bat"'
);
expect(await tools.linkTool('tool', 'fedora')).toContain(
'Platform fedora is not supported'
);
});
it('checking addTools', async () => {
let script: string = await tools.addTools(
'php-cs-fixer, phpstan, phpunit, pecl, phinx',
'linux'
);
expect(script).toContain(
'add_tool https://github.com/composer/composer/releases/latest/download/composer.phar composer'
);
expect(script).toContain(
'add_tool https://github.com/FriendsOfPHP/PHP-CS-Fixer/releases/latest/download/php-cs-fixer.phar php-cs-fixer'
);
expect(script).toContain(
'add_tool https://github.com/phpstan/phpstan/releases/latest/download/phpstan.phar phpstan'
);
expect(script).toContain(
'add_tool https://phar.phpunit.de/phpunit.phar phpunit'
);
expect(script).toContain('add_pecl');
expect(script).toContain('composer global require robmorgan/phinx');
expect(script).toContain(
'sudo ln -s "$(composer -q global config home)"/vendor/bin/phinx /usr/local/bin/phinx'
);
script = await tools.addTools(
'phpcs, phpcbf, phpcpd, phpmd, psalm, phinx',
'darwin'
);
expect(script).toContain(
'add_tool https://github.com/composer/composer/releases/latest/download/composer.phar composer'
);
expect(script).toContain(
'add_tool https://github.com/squizlabs/PHP_CodeSniffer/releases/latest/download/phpcs.phar phpcs'
);
expect(script).toContain(
'add_tool https://github.com/squizlabs/PHP_CodeSniffer/releases/latest/download/phpcbf.phar phpcbf'
);
expect(script).toContain(
'add_tool https://github.com/sebastianbergmann/phpcpd/releases/latest/download/phpcpd.phar phpcpd'
);
expect(script).toContain(
'add_tool https://github.com/phpmd/phpmd/releases/latest/download/phpmd.phar phpmd'
);
expect(script).toContain(
'https://github.com/vimeo/psalm/releases/latest/download/psalm.phar psalm'
);
expect(script).toContain('composer global require robmorgan/phinx');
expect(script).toContain(
'sudo ln -s "$(composer -q global config home)"/vendor/bin/phinx /usr/local/bin/phinx'
);
script = await tools.addTools(
'codeception, deployer, prestissimo, phpmd, phinx, does_not_exit',
'win32'
);
expect(script).toContain(
'Add-Tool https://github.com/composer/composer/releases/latest/download/composer.phar composer'
);
expect(script).toContain(
'Add-Tool https://deployer.org/deployer.phar deployer'
);
expect(script).toContain('composer global require hirak/prestissimo');
expect(script).toContain('composer global require robmorgan/phinx');
expect(script).toContain(
'$composer_dir = composer -q global config home | % {$_ -replace "/", "\\"}'
);
expect(script).toContain(
'Add-Content -Path $PsHome\\profile.ps1 -Value "New-Alias phinx $composer_dir\\vendor\\bin\\phinx.bat"'
);
expect(script).toContain('Tool does_not_exit is not supported');
});
});

View File

@ -87,13 +87,13 @@ describe('Utils tests', () => {
}); });
it('checking INIArray', async () => { it('checking INIArray', async () => {
expect(await utils.INIArray('a=1, b=2, c=3')).toEqual([ expect(await utils.CSVArray('a=1, b=2, c=3')).toEqual([
'a=1', 'a=1',
'b=2', 'b=2',
'c=3' 'c=3'
]); ]);
expect(await utils.INIArray('')).toEqual([]); expect(await utils.CSVArray('')).toEqual([]);
expect(await utils.INIArray(' ')).toEqual([]); expect(await utils.CSVArray(' ')).toEqual([]);
}); });
it('checking log', async () => { it('checking log', async () => {

View File

@ -17,8 +17,8 @@ inputs:
coverage: coverage:
description: 'Setup code coverage driver.' description: 'Setup code coverage driver.'
required: false required: false
pecl: tools:
description: 'Setup PECL on ubuntu' description: 'Setup popular tools globally.'
required: false required: false
# Deprecated options, do not use. Will not be supported after February 1, 2020. # Deprecated options, do not use. Will not be supported after February 1, 2020.
extension-csv: extension-csv:
@ -29,6 +29,10 @@ inputs:
description: 'Deprecated! Use ini-values instead.' description: 'Deprecated! Use ini-values instead.'
deprecationMessage: 'The ini-values-csv property will not be supported after February 1, 2020. Use ini-values instead.' deprecationMessage: 'The ini-values-csv property will not be supported after February 1, 2020. Use ini-values instead.'
required: false required: false
pecl:
description: 'Deprecated! Use tools instead to setup PECL.'
deprecationMessage: 'The pecl property will not be supported after February 1, 2020. Specify pecl in tools instead.'
required: false
runs: runs:
using: 'node12' using: 'node12'
main: 'dist/index.js' main: 'dist/index.js'

450
dist/index.js vendored
View File

@ -1172,36 +1172,42 @@ function extensionArray(extension_csv) {
case ' ': case ' ':
return []; return [];
default: default:
return extension_csv.split(',').map(function (extension) { return extension_csv
.split(',')
.map(function (extension) {
return extension return extension
.trim() .trim()
.replace('php-', '') .replace('php-', '')
.replace('php_', ''); .replace('php_', '');
}); })
.filter(Boolean);
} }
}); });
} }
exports.extensionArray = extensionArray; exports.extensionArray = extensionArray;
/** /**
* Function to break ini values csv into an array * Function to break csv into an array
* *
* @param ini_values_csv * @param values_csv
* @constructor * @constructor
*/ */
function INIArray(ini_values_csv) { function CSVArray(values_csv) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
switch (ini_values_csv) { switch (values_csv) {
case '': case '':
case ' ': case ' ':
return []; return [];
default: default:
return ini_values_csv.split(',').map(function (ini_value) { return values_csv
return ini_value.trim(); .split(',')
}); .map(function (value) {
return value.trim();
})
.filter(Boolean);
} }
}); });
} }
exports.INIArray = INIArray; exports.CSVArray = CSVArray;
/** /**
* Function to get prefix required to load an extension. * Function to get prefix required to load an extension.
* *
@ -1524,6 +1530,206 @@ function getState(name) {
exports.getState = getState; exports.getState = getState;
//# sourceMappingURL=core.js.map //# sourceMappingURL=core.js.map
/***/ }),
/***/ 534:
/***/ (function(__unusedmodule, exports, __webpack_require__) {
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const utils = __importStar(__webpack_require__(163));
function getToolCommand(os_version) {
return __awaiter(this, void 0, void 0, function* () {
switch (os_version) {
case 'linux':
case 'darwin':
return 'add_tool ';
case 'win32':
return 'Add-Tool ';
default:
return yield utils.log('Platform ' + os_version + ' is not supported', os_version, 'error');
}
});
}
exports.getToolCommand = getToolCommand;
function getPECLCommand(os_version) {
return __awaiter(this, void 0, void 0, function* () {
switch (os_version) {
case 'linux':
case 'darwin':
return 'add_pecl ';
case 'win32':
return 'Add-PECL ';
default:
return yield utils.log('Platform ' + os_version + ' is not supported', os_version, 'error');
}
});
}
exports.getPECLCommand = getPECLCommand;
function linkTool(tool, os_version) {
return __awaiter(this, void 0, void 0, function* () {
switch (os_version) {
case 'linux':
case 'darwin':
return ('sudo ln -s "$(composer -q global config home)"/vendor/bin/' +
tool +
' /usr/local/bin/' +
tool);
case 'win32':
return ('$composer_dir = composer -q global config home | % {$_ -replace "/", "\\"}' +
'\n' +
'Add-Content -Path $PsHome\\profile.ps1 -Value "New-Alias ' +
tool +
' $composer_dir\\vendor\\bin\\' +
tool +
'.bat"');
default:
return yield utils.log('Platform ' + os_version + ' is not supported', os_version, 'error');
}
});
}
exports.linkTool = linkTool;
/**
* Setup tools
*
* @param tool_csv
* @param os_version
*/
function addTools(tools_csv, os_version) {
return __awaiter(this, void 0, void 0, function* () {
let script = '\n' + (yield utils.stepLog('Setup Tools', os_version));
let tools = yield utils.CSVArray(tools_csv);
tools = tools.filter(tool => tool !== 'composer');
tools.unshift('composer');
yield utils.asyncForEach(tools, function (tool) {
return __awaiter(this, void 0, void 0, function* () {
script += '\n';
switch (tool) {
case 'php-cs-fixer':
script +=
(yield getToolCommand(os_version)) +
'https://github.com/FriendsOfPHP/PHP-CS-Fixer/releases/latest/download/php-cs-fixer.phar' +
' ' +
'php-cs-fixer';
break;
case 'phpcs':
script +=
(yield getToolCommand(os_version)) +
'https://github.com/squizlabs/PHP_CodeSniffer/releases/latest/download/phpcs.phar' +
' ' +
'phpcs';
break;
case 'phpcbf':
script +=
(yield getToolCommand(os_version)) +
'https://github.com/squizlabs/PHP_CodeSniffer/releases/latest/download/phpcbf.phar' +
' ' +
'phpcbf';
break;
case 'phpcpd':
script +=
(yield getToolCommand(os_version)) +
'https://github.com/sebastianbergmann/phpcpd/releases/latest/download/phpcpd.phar' +
' ' +
'phpcpd';
break;
case 'phpstan':
script +=
(yield getToolCommand(os_version)) +
'https://github.com/phpstan/phpstan/releases/latest/download/phpstan.phar' +
' ' +
'phpstan';
break;
case 'phpmd':
script +=
(yield getToolCommand(os_version)) +
'https://github.com/phpmd/phpmd/releases/latest/download/phpmd.phar' +
' ' +
'phpmd';
break;
case 'psalm':
script +=
(yield getToolCommand(os_version)) +
'https://github.com/vimeo/psalm/releases/latest/download/psalm.phar' +
' ' +
'psalm';
break;
case 'phinx':
script +=
'composer global require robmorgan/phinx' +
(yield utils.suppressOutput(os_version)) +
'\n' +
(yield linkTool('phinx', os_version)) +
'\n' +
(yield utils.addLog('$tick', 'phinx', 'Added', os_version));
break;
case 'composer':
script +=
(yield getToolCommand(os_version)) +
'https://github.com/composer/composer/releases/latest/download/composer.phar' +
' ' +
'composer';
break;
case 'codeception':
script +=
(yield getToolCommand(os_version)) +
'https://codeception.com/codecept.phar' +
' ' +
'codeception';
break;
case 'phpunit':
script +=
(yield getToolCommand(os_version)) +
'https://phar.phpunit.de/phpunit.phar' +
' ' +
'phpunit';
break;
case 'deployer':
script +=
(yield getToolCommand(os_version)) +
'https://deployer.org/deployer.phar' +
' ' +
'deployer';
break;
case 'prestissimo':
script +=
'composer global require hirak/prestissimo' +
(yield utils.suppressOutput(os_version)) +
'\n' +
(yield utils.addLog('$tick', 'hirak/prestissimo', 'Added', os_version));
break;
case 'pecl':
script += yield getPECLCommand(os_version);
break;
default:
script += yield utils.log('Tool ' + tool + ' is not supported', os_version, 'error');
break;
}
});
});
return script;
});
}
exports.addTools = addTools;
/***/ }), /***/ }),
/***/ 614: /***/ 614:
@ -1570,8 +1776,9 @@ const config = __importStar(__webpack_require__(641));
* *
* @param version * @param version
* @param os_version * @param os_version
* @param pipe
*/ */
function addCoverageXdebug(version, os_version) { function addCoverageXdebug(version, os_version, pipe) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
switch (version) { switch (version) {
case '8.0': case '8.0':
@ -1580,7 +1787,7 @@ function addCoverageXdebug(version, os_version) {
case '7.4': case '7.4':
default: default:
return ((yield extensions.addExtension('xdebug', version, os_version, true)) + return ((yield extensions.addExtension('xdebug', version, os_version, true)) +
(yield utils.suppressOutput(os_version)) + pipe +
'\n' + '\n' +
(yield utils.addLog('$tick', 'xdebug', 'Xdebug enabled as coverage driver', os_version))); (yield utils.addLog('$tick', 'xdebug', 'Xdebug enabled as coverage driver', os_version)));
} }
@ -1592,47 +1799,27 @@ exports.addCoverageXdebug = addCoverageXdebug;
* *
* @param version * @param version
* @param os_version * @param os_version
* @param pipe
*/ */
function addCoveragePCOV(version, os_version) { function addCoveragePCOV(version, os_version, pipe) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
let script = '\n'; let script = '\n';
switch (version) { switch (version) {
default: default:
script += script +=
(yield extensions.addExtension('pcov', version, os_version, true)) + (yield extensions.addExtension('pcov', version, os_version, true)) +
(yield utils.suppressOutput(os_version)) + pipe +
'\n'; '\n';
script += script +=
(yield config.addINIValues('pcov.enabled=1', os_version, true)) + '\n'; (yield config.addINIValues('pcov.enabled=1', os_version, true)) + '\n';
// add command to disable xdebug and enable pcov // add command to disable xdebug and enable pcov
switch (os_version) { switch (os_version) {
case 'linux': case 'linux':
script +=
'if [ -e /etc/php/' +
version +
'/mods-available/xdebug.ini ]; then sudo phpdismod -v ' +
version +
' xdebug; fi\n';
script += 'sudo sed -i "/xdebug/d" "$ini_file"\n';
script +=
'sudo DEBIAN_FRONTEND=noninteractive apt-fast remove php-xdebug -y ' +
(yield utils.suppressOutput('linux')) +
'\n';
break;
case 'darwin': case 'darwin':
script += 'sudo sed -i \'\' "/xdebug/d" "$ini_file"\n'; script += 'remove_extension xdebug' + pipe + '\n';
script +=
'sudo rm -rf "$ext_dir"/xdebug.so ' +
(yield utils.suppressOutput('darwin')) +
'\n';
break; break;
case 'win32': case 'win32':
script += script += 'Remove-Extension xdebug' + pipe + '\n';
'if(php -m | findstr -i xdebug) { Disable-PhpExtension xdebug $php_dir }\n';
script +=
'if (Test-Path $ext_dir\\php_xdebug.dll) { Remove-Item $ext_dir\\php_xdebug.dll }' +
(yield utils.suppressOutput('win32')) +
'\n';
break; break;
} }
// success // success
@ -1653,56 +1840,20 @@ exports.addCoveragePCOV = addCoveragePCOV;
* *
* @param version * @param version
* @param os_version * @param os_version
* @param pipe
*/ */
function disableCoverage(version, os_version) { function disableCoverage(version, os_version, pipe) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
let script = '\n'; let script = '\n';
switch (os_version) { switch (os_version) {
case 'linux': case 'linux':
script +=
'if [ -e /etc/php/' +
version +
'/mods-available/xdebug.ini ]; then sudo phpdismod -v ' +
version +
' xdebug; fi\n';
script +=
'if [ -e /etc/php/' +
version +
'/mods-available/pcov.ini ]; then sudo phpdismod -v ' +
version +
' pcov; fi\n';
script += 'sudo sed -i "/xdebug/d" "$ini_file"\n';
script += 'sudo sed -i "/pcov/d" "$ini_file"\n';
script +=
'sudo DEBIAN_FRONTEND=noninteractive apt-fast remove php-xdebug php-pcov -y ' +
(yield utils.suppressOutput('linux')) +
'\n';
break;
case 'darwin': case 'darwin':
script += 'sudo sed -i \'\' "/xdebug/d" "$ini_file"\n'; script += 'remove_extension xdebug' + pipe + '\n';
script += 'sudo sed -i \'\' "/pcov/d" "$ini_file"\n'; script += 'remove_extension pcov' + pipe + '\n';
script +=
'sudo rm -rf "$ext_dir"/xdebug.so ' +
(yield utils.suppressOutput('darwin')) +
'\n';
script +=
'sudo rm -rf "$ext_dir"/pcov.so ' +
(yield utils.suppressOutput('darwin')) +
'\n';
break; break;
case 'win32': case 'win32':
script += script += 'Remove-Extension xdebug' + pipe + '\n';
'if(php -m | findstr -i xdebug) { Disable-PhpExtension xdebug $php_dir }\n'; script += 'Remove-Extension pcov' + pipe + '\n';
script +=
'if(php -m | findstr -i pcov) { Disable-PhpExtension pcov $php_dir }\n';
script +=
'if (Test-Path $ext_dir\\php_xdebug.dll) { Remove-Item $ext_dir\\php_xdebug.dll }' +
(yield utils.suppressOutput('win32')) +
'\n';
script +=
'if (Test-Path $ext_dir\\php_pcov.dll) { Remove-Item $ext_dir\\php_pcov.dll }' +
(yield utils.suppressOutput('win32')) +
'\n';
break; break;
} }
script += yield utils.addLog('$tick', 'none', 'Disabled Xdebug and PCOV', os_version); script += yield utils.addLog('$tick', 'none', 'Disabled Xdebug and PCOV', os_version);
@ -1721,13 +1872,14 @@ 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();
const script = '\n' + (yield utils.stepLog('Setup Coverage', os_version)); const script = '\n' + (yield utils.stepLog('Setup Coverage', os_version));
const pipe = yield utils.suppressOutput(os_version);
switch (coverage_driver) { switch (coverage_driver) {
case 'pcov': case 'pcov':
return script + (yield addCoveragePCOV(version, os_version)); return script + (yield addCoveragePCOV(version, os_version, pipe));
case 'xdebug': case 'xdebug':
return script + (yield addCoverageXdebug(version, os_version)); return script + (yield addCoverageXdebug(version, os_version, pipe));
case 'none': case 'none':
return script + (yield disableCoverage(version, os_version)); return script + (yield disableCoverage(version, os_version, pipe));
default: default:
return ''; return '';
} }
@ -1768,7 +1920,7 @@ const utils = __importStar(__webpack_require__(163));
*/ */
function addINIValuesUnix(ini_values_csv) { function addINIValuesUnix(ini_values_csv) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
const ini_values = yield utils.INIArray(ini_values_csv); const ini_values = yield utils.CSVArray(ini_values_csv);
let script = '\n'; let script = '\n';
yield utils.asyncForEach(ini_values, function (line) { yield utils.asyncForEach(ini_values, function (line) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
@ -1787,7 +1939,7 @@ exports.addINIValuesUnix = addINIValuesUnix;
*/ */
function addINIValuesWindows(ini_values_csv) { function addINIValuesWindows(ini_values_csv) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
const ini_values = yield utils.INIArray(ini_values_csv); const ini_values = yield utils.CSVArray(ini_values_csv);
let script = '\n'; let script = '\n';
yield utils.asyncForEach(ini_values, function (line) { yield utils.asyncForEach(ini_values, function (line) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
@ -1866,6 +2018,7 @@ const core = __importStar(__webpack_require__(470));
const config = __importStar(__webpack_require__(641)); const config = __importStar(__webpack_require__(641));
const coverage = __importStar(__webpack_require__(635)); const coverage = __importStar(__webpack_require__(635));
const extensions = __importStar(__webpack_require__(911)); const extensions = __importStar(__webpack_require__(911));
const tools = __importStar(__webpack_require__(534));
const utils = __importStar(__webpack_require__(163)); const utils = __importStar(__webpack_require__(163));
const matchers = __importStar(__webpack_require__(86)); const matchers = __importStar(__webpack_require__(86));
/** /**
@ -1883,7 +2036,11 @@ function build(filename, version, os_version) {
const ini_values_csv = (yield utils.getInput('ini-values', false)) || const ini_values_csv = (yield utils.getInput('ini-values', false)) ||
(yield utils.getInput('ini-values-csv', false)); (yield utils.getInput('ini-values-csv', false));
const coverage_driver = yield utils.getInput('coverage', false); const coverage_driver = yield utils.getInput('coverage', false);
const setup_matchers = yield utils.getInput('matchers', false); const pecl = yield utils.getInput('pecl', false);
let tools_csv = yield utils.getInput('tools', false);
if (pecl == 'true') {
tools_csv = 'pecl, ' + tools_csv;
}
let script = yield utils.readScript(filename, version, os_version); let script = yield utils.readScript(filename, version, os_version);
if (extension_csv) { if (extension_csv) {
script += yield extensions.addExtension(extension_csv, version, os_version); script += yield extensions.addExtension(extension_csv, version, os_version);
@ -1894,6 +2051,7 @@ function build(filename, version, os_version) {
if (coverage_driver) { if (coverage_driver) {
script += yield coverage.addCoverage(coverage_driver, version, os_version); script += yield coverage.addCoverage(coverage_driver, version, os_version);
} }
script += yield tools.addTools(tools_csv, os_version);
return yield utils.writeScript(filename, script); return yield utils.writeScript(filename, script);
}); });
} }
@ -1906,23 +2064,18 @@ function run() {
try { try {
const os_version = process.platform; const os_version = process.platform;
let version = yield utils.getInput('php-version', true); let version = yield utils.getInput('php-version', true);
version = version.length > 1 ? version : version + '.0'; version = version.length > 1 ? version.slice(0, 3) : version + '.0';
// check the os version and run the respective script // check the os version and run the respective script
let script_path = ''; let script_path = '';
switch (os_version) { switch (os_version) {
case 'darwin': case 'darwin':
case 'linux':
script_path = yield build(os_version + '.sh', version, os_version); script_path = yield build(os_version + '.sh', version, os_version);
yield exec_1.exec('sh ' + script_path + ' ' + version + ' ' + __dirname); yield exec_1.exec('sh ' + script_path + ' ' + version + ' ' + __dirname);
break; break;
case 'linux': {
const pecl = yield utils.getInput('pecl', false);
script_path = yield build(os_version + '.sh', version, os_version);
yield exec_1.exec('sh ' + script_path + ' ' + version + ' ' + pecl);
break;
}
case 'win32': case 'win32':
script_path = yield build('win32.ps1', version, os_version); script_path = yield build('win32.ps1', version, os_version);
yield exec_1.exec('pwsh ' + script_path + ' -version ' + version + ' -dir ' + __dirname); yield exec_1.exec('pwsh ' + script_path + ' ' + version + ' ' + __dirname);
break; break;
} }
yield matchers.addMatchers(); yield matchers.addMatchers();
@ -2184,25 +2337,37 @@ const utils = __importStar(__webpack_require__(163));
* *
* @param extension_csv * @param extension_csv
* @param version * @param version
* @param pipe
*/ */
function addExtensionDarwin(extension_csv, version) { function addExtensionDarwin(extension_csv, version, pipe) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
const extensions = yield utils.extensionArray(extension_csv); const extensions = yield utils.extensionArray(extension_csv);
let script = '\n'; let script = '\n';
yield utils.asyncForEach(extensions, function (extension) { yield utils.asyncForEach(extensions, function (extension) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
extension = extension.toLowerCase(); extension = extension.toLowerCase();
const version_extension = version + extension;
// add script to enable extension is already installed along with php // add script to enable extension is already installed along with php
let install_command = ''; let install_command = '';
switch (version + extension) { switch (true) {
case '5.6xdebug': case /5\.6xdebug/.test(version_extension):
install_command = 'sudo pecl install xdebug-2.5.5 >/dev/null 2>&1'; install_command = 'sudo pecl install xdebug-2.5.5' + pipe;
break; break;
case '5.6redis': case /5\.6redis/.test(version_extension):
install_command = 'sudo pecl install redis-2.2.8 >/dev/null 2>&1'; install_command = 'sudo pecl install redis-2.2.8' + pipe;
break;
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
install_command =
'sh ' +
path.join(__dirname, '../src/scripts/ext/phalcon_darwin.sh') +
' ' +
extension +
' ' +
version +
pipe;
break; break;
default: default:
install_command = 'sudo pecl install ' + extension + ' >/dev/null 2>&1'; install_command = 'sudo pecl install ' + extension + pipe;
break; break;
} }
script += script +=
@ -2223,17 +2388,27 @@ exports.addExtensionDarwin = addExtensionDarwin;
* *
* @param extension_csv * @param extension_csv
* @param version * @param version
* @param pipe
*/ */
function addExtensionWindows(extension_csv, version) { function addExtensionWindows(extension_csv, version, pipe) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
const extensions = yield utils.extensionArray(extension_csv); const extensions = yield utils.extensionArray(extension_csv);
let script = '\n'; let script = '\n';
yield utils.asyncForEach(extensions, function (extension) { yield utils.asyncForEach(extensions, function (extension) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
// add script to enable extension is already installed along with php // add script to enable extension is already installed along with php
switch (version + extension) { const version_extension = version + extension;
case '7.4redis': switch (true) {
script += '\nAdd-Extension ' + extension + ' beta'; // match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
script +=
'\n& ' +
path.join(__dirname, '../src/scripts/ext/phalcon.ps1') +
' ' +
extension +
' ' +
version +
'\n';
break; break;
default: default:
script += '\nAdd-Extension ' + extension; script += '\nAdd-Extension ' + extension;
@ -2250,8 +2425,9 @@ exports.addExtensionWindows = addExtensionWindows;
* *
* @param extension_csv * @param extension_csv
* @param version * @param version
* @param pipe
*/ */
function addExtensionLinux(extension_csv, version) { function addExtensionLinux(extension_csv, version, pipe) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
const extensions = yield utils.extensionArray(extension_csv); const extensions = yield utils.extensionArray(extension_csv);
let script = '\n'; let script = '\n';
@ -2259,42 +2435,28 @@ function addExtensionLinux(extension_csv, version) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
extension = extension.toLowerCase(); extension = extension.toLowerCase();
// add script to enable extension is already installed along with php // add script to enable extension is already installed along with php
const version_extension = version + extension;
let install_command = ''; let install_command = '';
switch (version + extension) { switch (true) {
case '7.4redis': // match 5.6gearman..7.4gearman
install_command = case /^((5\.6)|(7\.[0-4]))gearman$/.test(version_extension):
'sudo DEBIAN_FRONTEND=noninteractive apt-get install -y php7.4-igbinary php7.4-redis >/dev/null 2>&1';
break;
case '7.2phalcon3':
case '7.3phalcon3':
install_command = install_command =
'sh ' + 'sh ' +
path.join(__dirname, '../src/scripts/phalcon.sh') + path.join(__dirname, '../src/scripts/ext/gearman.sh') +
' 3.4.x ' +
version +
' >/dev/null 2>&1';
break;
case '7.2phalcon4':
case '7.3phalcon4':
case '7.4phalcon4':
install_command =
'sh ' +
path.join(__dirname, '../src/scripts/phalcon.sh') +
' master ' +
version +
' >/dev/null 2>&1';
break;
case '7.0gearman':
case '7.1gearman':
case '7.2gearman':
case '7.3gearman':
case '7.4gearman':
install_command =
'sh ' +
path.join(__dirname, '../src/scripts/gearman.sh') +
' ' + ' ' +
version + version +
' >/dev/null 2>&1'; pipe;
break;
// match 7.0phalcon3..7.3phalcon3 and 7.2phalcon4...7.4phalcon4
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
install_command =
'sh ' +
path.join(__dirname, '../src/scripts/ext/phalcon.sh') +
' ' +
extension +
' ' +
version +
pipe;
break; break;
default: default:
install_command = install_command =
@ -2302,9 +2464,10 @@ function addExtensionLinux(extension_csv, version) {
version + version +
'-' + '-' +
extension.replace('pdo_', '').replace('pdo-', '') + extension.replace('pdo_', '').replace('pdo-', '') +
' >/dev/null 2>&1 || sudo pecl install ' + pipe +
' || sudo pecl install ' +
extension + extension +
' >/dev/null 2>&1'; pipe;
break; break;
} }
script += script +=
@ -2330,12 +2493,11 @@ exports.addExtensionLinux = addExtensionLinux;
*/ */
function addExtension(extension_csv, version, os_version, no_step = false) { function addExtension(extension_csv, version, os_version, no_step = false) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
const pipe = yield utils.suppressOutput(os_version);
let script = '\n'; let script = '\n';
switch (no_step) { switch (no_step) {
case true: case true:
script += script += (yield utils.stepLog('Setup Extensions', os_version)) + pipe;
(yield utils.stepLog('Setup Extensions', os_version)) +
(yield utils.suppressOutput(os_version));
break; break;
case false: case false:
default: default:
@ -2344,11 +2506,11 @@ function addExtension(extension_csv, version, os_version, no_step = false) {
} }
switch (os_version) { switch (os_version) {
case 'win32': case 'win32':
return script + (yield addExtensionWindows(extension_csv, version)); return script + (yield addExtensionWindows(extension_csv, version, pipe));
case 'darwin': case 'darwin':
return script + (yield addExtensionDarwin(extension_csv, version)); return script + (yield addExtensionDarwin(extension_csv, version, pipe));
case 'linux': case 'linux':
return script + (yield addExtensionLinux(extension_csv, version)); return script + (yield addExtensionLinux(extension_csv, version, pipe));
default: 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');
} }

View File

@ -22,6 +22,8 @@ jobs:
- uses: actions/cache@v1 - uses: actions/cache@v1
with: with:
path: ${{ steps.composer-cache.outputs.dir }} path: ${{ steps.composer-cache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed.
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer- restore-keys: ${{ runner.os }}-composer-
- name: Install Composer dependencies - name: Install Composer dependencies

View File

@ -24,6 +24,8 @@ jobs:
uses: actions/cache@v1 uses: actions/cache@v1
with: with:
path: ${{ steps.composer-cache.outputs.dir }} path: ${{ steps.composer-cache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed.
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer- restore-keys: ${{ runner.os }}-composer-
- name: Install dependencies - name: Install dependencies

View File

@ -48,6 +48,8 @@ jobs:
uses: actions/cache@v1 uses: actions/cache@v1
with: with:
path: ${{ steps.composer-cache.outputs.dir }} path: ${{ steps.composer-cache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed.
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer- restore-keys: ${{ runner.os }}-composer-
- name: Install Composer dependencies - name: Install Composer dependencies

View File

@ -50,6 +50,8 @@ jobs:
uses: actions/cache@v1 uses: actions/cache@v1
with: with:
path: ${{ steps.composer-cache.outputs.dir }} path: ${{ steps.composer-cache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed.
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer- restore-keys: ${{ runner.os }}-composer-
- name: Install Composer dependencies - name: Install Composer dependencies

View File

@ -26,6 +26,8 @@ jobs:
uses: actions/cache@v1 uses: actions/cache@v1
with: with:
path: ${{ steps.composer-cache.outputs.dir }} path: ${{ steps.composer-cache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed.
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer- restore-keys: ${{ runner.os }}-composer-
- name: Install Composer dependencies - name: Install Composer dependencies

View File

@ -48,6 +48,8 @@ jobs:
uses: actions/cache@v1 uses: actions/cache@v1
with: with:
path: ${{ steps.composer-cache.outputs.dir }} path: ${{ steps.composer-cache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed.
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer- restore-keys: ${{ runner.os }}-composer-
- name: Install Composer dependencies - name: Install Composer dependencies

View File

@ -50,6 +50,8 @@ jobs:
uses: actions/cache@v1 uses: actions/cache@v1
with: with:
path: ${{ steps.composer-cache.outputs.dir }} path: ${{ steps.composer-cache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed.
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer- restore-keys: ${{ runner.os }}-composer-
- name: Install Composer dependencies - name: Install Composer dependencies

View File

@ -26,6 +26,8 @@ jobs:
uses: actions/cache@v1 uses: actions/cache@v1
with: with:
path: ${{ steps.composer-cache.outputs.dir }} path: ${{ steps.composer-cache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed.
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer- restore-keys: ${{ runner.os }}-composer-
- name: Install Composer dependencies - name: Install Composer dependencies

View File

@ -30,6 +30,8 @@ jobs:
fail-fast: false fail-fast: false
matrix: matrix:
php-versions: ['7.2', '7.3', '7.4'] php-versions: ['7.2', '7.3', '7.4']
# For phalcon 3.x, use
# php-versions: ['7.0', '7.1', '7.2', '7.3']
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v1 uses: actions/checkout@v1
@ -46,6 +48,8 @@ jobs:
uses: actions/cache@v1 uses: actions/cache@v1
with: with:
path: ${{ steps.composer-cache.outputs.dir }} path: ${{ steps.composer-cache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed.
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer- restore-keys: ${{ runner.os }}-composer-
- name: Install Composer dependencies - name: Install Composer dependencies

View File

@ -31,6 +31,8 @@ jobs:
fail-fast: false fail-fast: false
matrix: matrix:
php-versions: ['7.2', '7.3', '7.4'] php-versions: ['7.2', '7.3', '7.4']
# For phalcon 3.x, use
# php-versions: ['7.0', '7.1', '7.2', '7.3']
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v1 uses: actions/checkout@v1
@ -47,6 +49,8 @@ jobs:
uses: actions/cache@v1 uses: actions/cache@v1
with: with:
path: ${{ steps.composer-cache.outputs.dir }} path: ${{ steps.composer-cache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed.
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer- restore-keys: ${{ runner.os }}-composer-
- name: Install Composer dependencies - name: Install Composer dependencies

View File

@ -39,6 +39,8 @@ jobs:
uses: actions/cache@v1 uses: actions/cache@v1
with: with:
path: ${{ steps.composer-cache.outputs.dir }} path: ${{ steps.composer-cache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed.
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer- restore-keys: ${{ runner.os }}-composer-
- name: Install yarn dependencies - name: Install yarn dependencies

View File

@ -24,6 +24,8 @@ jobs:
uses: actions/cache@v1 uses: actions/cache@v1
with: with:
path: ${{ steps.composer-cache.outputs.dir }} path: ${{ steps.composer-cache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed.
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer- restore-keys: ${{ runner.os }}-composer-
- name: Install dependencies - name: Install dependencies

View File

@ -26,7 +26,7 @@ jobs:
uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php
with: with:
php-version: ${{ matrix.php-versions }} php-version: ${{ matrix.php-versions }}
extensions: mbstring, xml, ctype, iconv, mysql extensions: mbstring, xml, ctype, iconv, intl, pdo_sqlite, mysql
coverage: xdebug #optional coverage: xdebug #optional
- name: Get composer cache directory - name: Get composer cache directory
id: composer-cache id: composer-cache
@ -35,6 +35,8 @@ jobs:
uses: actions/cache@v1 uses: actions/cache@v1
with: with:
path: ${{ steps.composer-cache.outputs.dir }} path: ${{ steps.composer-cache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed.
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer- restore-keys: ${{ runner.os }}-composer-
- name: Install Composer dependencies - name: Install Composer dependencies
@ -48,6 +50,4 @@ jobs:
env: env:
DATABASE_URL: mysql://root:symfony@127.0.0.1:${{ job.services.mysql.ports['3306'] }}/symfony DATABASE_URL: mysql://root:symfony@127.0.0.1:${{ job.services.mysql.ports['3306'] }}/symfony
- name: Run Tests - name: Run Tests
run: | run: php bin/phpunit --coverage-text
composer require phpunit
php bin/phpunit --coverage-text

View File

@ -26,7 +26,7 @@ jobs:
uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php
with: with:
php-version: ${{ matrix.php-versions }} php-version: ${{ matrix.php-versions }}
extensions: mbstring, xml, ctype, iconv, pgsql extensions: mbstring, xml, ctype, iconv, intl, pdo_sqlite, pgsql
coverage: xdebug #optional coverage: xdebug #optional
- name: Get composer cache directory - name: Get composer cache directory
id: composer-cache id: composer-cache
@ -35,6 +35,8 @@ jobs:
uses: actions/cache@v1 uses: actions/cache@v1
with: with:
path: ${{ steps.composer-cache.outputs.dir }} path: ${{ steps.composer-cache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed.
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer- restore-keys: ${{ runner.os }}-composer-
- name: Install Composer dependencies - name: Install Composer dependencies
@ -48,6 +50,4 @@ jobs:
env: env:
DATABASE_URL: postgres://postgres:postgres@127.0.0.1:${{ job.services.postgres.ports[5432] }}/postgres?charset=UTF-8 DATABASE_URL: postgres://postgres:postgres@127.0.0.1:${{ job.services.postgres.ports[5432] }}/postgres?charset=UTF-8
- name: Run Tests - name: Run Tests
run: | run: php bin/phpunit --coverage-text
composer require phpunit
php bin/phpunit --coverage-text

View File

@ -17,7 +17,7 @@ jobs:
uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php
with: with:
php-version: ${{ matrix.php-versions }} php-version: ${{ matrix.php-versions }}
extensions: mbstring, xml, ctype, iconv extensions: mbstring, xml, ctype, iconv, intl, pdo_sqlite
coverage: xdebug #optional coverage: xdebug #optional
- name: Get composer cache directory - name: Get composer cache directory
id: composer-cache id: composer-cache
@ -26,6 +26,8 @@ jobs:
uses: actions/cache@v1 uses: actions/cache@v1
with: with:
path: ${{ steps.composer-cache.outputs.dir }} path: ${{ steps.composer-cache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed.
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer- restore-keys: ${{ runner.os }}-composer-
- name: Install Composer dependencies - name: Install Composer dependencies
@ -33,6 +35,4 @@ jobs:
composer require symfony/orm-pack composer require symfony/orm-pack
composer install --no-progress --no-suggest --prefer-dist --optimize-autoloader composer install --no-progress --no-suggest --prefer-dist --optimize-autoloader
- name: Run Tests - name: Run Tests
run: | run: php bin/phpunit --coverage-text
composer require phpunit
php bin/phpunit --coverage-text

View File

@ -45,6 +45,8 @@ jobs:
uses: actions/cache@v1 uses: actions/cache@v1
with: with:
path: ${{ steps.composer-cache.outputs.dir }} path: ${{ steps.composer-cache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed.
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer- restore-keys: ${{ runner.os }}-composer-
- name: Install Composer dependencies - name: Install Composer dependencies

View File

@ -45,6 +45,8 @@ jobs:
uses: actions/cache@v1 uses: actions/cache@v1
with: with:
path: ${{ steps.composer-cache.outputs.dir }} path: ${{ steps.composer-cache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed.
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer- restore-keys: ${{ runner.os }}-composer-
- name: Install Composer dependencies - name: Install Composer dependencies

View File

@ -24,6 +24,8 @@ jobs:
uses: actions/cache@v1 uses: actions/cache@v1
with: with:
path: ${{ steps.composer-cache.outputs.dir }} path: ${{ steps.composer-cache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed.
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer- restore-keys: ${{ runner.os }}-composer-
- name: Install dependencies - name: Install dependencies

171
package-lock.json generated
View File

@ -1,6 +1,6 @@
{ {
"name": "setup-php", "name": "setup-php",
"version": "1.6.2", "version": "1.7.0",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {
@ -503,24 +503,24 @@
} }
}, },
"@types/jest": { "@types/jest": {
"version": "24.0.24", "version": "24.0.25",
"resolved": "https://registry.npmjs.org/@types/jest/-/jest-24.0.24.tgz", "resolved": "https://registry.npmjs.org/@types/jest/-/jest-24.0.25.tgz",
"integrity": "sha512-vgaG968EDPSJPMunEDdZvZgvxYSmeH8wKqBlHSkBt1pV2XlLEVDzsj1ZhLuI4iG4Pv841tES61txSBF0obh4CQ==", "integrity": "sha512-hnP1WpjN4KbGEK4dLayul6lgtys6FPz0UfxMeMQCv0M+sTnzN3ConfiO72jHgLxl119guHgI8gLqDOrRLsyp2g==",
"dev": true, "dev": true,
"requires": { "requires": {
"jest-diff": "^24.3.0" "jest-diff": "^24.3.0"
} }
}, },
"@types/json-schema": { "@types/json-schema": {
"version": "7.0.3", "version": "7.0.4",
"resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.3.tgz", "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.4.tgz",
"integrity": "sha512-Il2DtDVRGDcqjDtE+rF8iqg1CArehSK84HZJCT7AMITlyXRBpuPhqGLDQMowraqqu1coEaimg4ZOqggt6L6L+A==", "integrity": "sha512-8+KAKzEvSUdeo+kmqnKrqgeE+LcA0tjYWFY7RPProVYwnqDjukzO+3b6dLD56rYX5TdWejnEOLJYOIeh4CXKuA==",
"dev": true "dev": true
}, },
"@types/node": { "@types/node": {
"version": "12.12.21", "version": "12.12.22",
"resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.21.tgz", "resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.22.tgz",
"integrity": "sha512-8sRGhbpU+ck1n0PGAUgVrWrWdjSW2aqNeyC15W88GRsMpSwzv6RJGlLhE7s2RhVSOdyDmxbqlWSeThq4/7xqlA==", "integrity": "sha512-r5i93jqbPWGXYXxianGATOxTelkp6ih/U0WVnvaqAvTqM+0U6J3kw6Xk6uq/dWNRkEVw/0SLcO5ORXbVNz4FMQ==",
"dev": true "dev": true
}, },
"@types/normalize-package-data": { "@types/normalize-package-data": {
@ -536,9 +536,9 @@
"dev": true "dev": true
}, },
"@types/yargs": { "@types/yargs": {
"version": "13.0.3", "version": "13.0.4",
"resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-13.0.3.tgz", "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-13.0.4.tgz",
"integrity": "sha512-K8/LfZq2duW33XW/tFwEAfnZlqIfVsoyRB3kfXdPXYhl0nfM8mmh7GS0jg7WrX2Dgq/0Ha/pR1PaR+BvmWwjiQ==", "integrity": "sha512-Ke1WmBbIkVM8bpvsNEcGgQM70XcEh/nbpxQhW7FhrsbCsXSY9BmLB1+LHtD7r9zrsOcFlLiF+a/UeJsdfw3C5A==",
"dev": true, "dev": true,
"requires": { "requires": {
"@types/yargs-parser": "*" "@types/yargs-parser": "*"
@ -551,12 +551,12 @@
"dev": true "dev": true
}, },
"@typescript-eslint/eslint-plugin": { "@typescript-eslint/eslint-plugin": {
"version": "2.12.0", "version": "2.14.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-2.12.0.tgz", "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-2.14.0.tgz",
"integrity": "sha512-1t4r9rpLuEwl3hgt90jY18wJHSyb0E3orVL3DaqwmpiSDHmHiSspVsvsFF78BJ/3NNG3qmeso836jpuBWYziAA==", "integrity": "sha512-sneOJ3Hu0m5whJiVIxGBZZZMxMJ7c0LhAJzeMJgHo+n5wFs+/6rSR/gl7crkdR2kNwfOOSdzdc0gMvatG4dX2Q==",
"dev": true, "dev": true,
"requires": { "requires": {
"@typescript-eslint/experimental-utils": "2.12.0", "@typescript-eslint/experimental-utils": "2.14.0",
"eslint-utils": "^1.4.3", "eslint-utils": "^1.4.3",
"functional-red-black-tree": "^1.0.1", "functional-red-black-tree": "^1.0.1",
"regexpp": "^3.0.0", "regexpp": "^3.0.0",
@ -564,32 +564,32 @@
} }
}, },
"@typescript-eslint/experimental-utils": { "@typescript-eslint/experimental-utils": {
"version": "2.12.0", "version": "2.14.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-2.12.0.tgz", "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-2.14.0.tgz",
"integrity": "sha512-jv4gYpw5N5BrWF3ntROvCuLe1IjRenLy5+U57J24NbPGwZFAjhnM45qpq0nDH1y/AZMb3Br25YiNVwyPbz6RkA==", "integrity": "sha512-KcyKS7G6IWnIgl3ZpyxyBCxhkBPV+0a5Jjy2g5HxlrbG2ZLQNFeneIBVXdaBCYOVjvGmGGFKom1kgiAY75SDeQ==",
"dev": true, "dev": true,
"requires": { "requires": {
"@types/json-schema": "^7.0.3", "@types/json-schema": "^7.0.3",
"@typescript-eslint/typescript-estree": "2.12.0", "@typescript-eslint/typescript-estree": "2.14.0",
"eslint-scope": "^5.0.0" "eslint-scope": "^5.0.0"
} }
}, },
"@typescript-eslint/parser": { "@typescript-eslint/parser": {
"version": "2.12.0", "version": "2.14.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-2.12.0.tgz", "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-2.14.0.tgz",
"integrity": "sha512-lPdkwpdzxEfjI8TyTzZqPatkrswLSVu4bqUgnB03fHSOwpC7KSerPgJRgIAf11UGNf7HKjJV6oaPZI4AghLU6g==", "integrity": "sha512-haS+8D35fUydIs+zdSf4BxpOartb/DjrZ2IxQ5sR8zyGfd77uT9ZJZYF8+I0WPhzqHmfafUBx8MYpcp8pfaoSA==",
"dev": true, "dev": true,
"requires": { "requires": {
"@types/eslint-visitor-keys": "^1.0.0", "@types/eslint-visitor-keys": "^1.0.0",
"@typescript-eslint/experimental-utils": "2.12.0", "@typescript-eslint/experimental-utils": "2.14.0",
"@typescript-eslint/typescript-estree": "2.12.0", "@typescript-eslint/typescript-estree": "2.14.0",
"eslint-visitor-keys": "^1.1.0" "eslint-visitor-keys": "^1.1.0"
} }
}, },
"@typescript-eslint/typescript-estree": { "@typescript-eslint/typescript-estree": {
"version": "2.12.0", "version": "2.14.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-2.12.0.tgz", "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-2.14.0.tgz",
"integrity": "sha512-rGehVfjHEn8Frh9UW02ZZIfJs6SIIxIu/K1bbci8rFfDE/1lQ8krIJy5OXOV3DVnNdDPtoiPOdEANkLMrwXbiQ==", "integrity": "sha512-pnLpUcMNG7GfFFfNQbEX6f1aPa5fMnH2G9By+A1yovYI4VIOK2DzkaRuUlIkbagpAcrxQHLqovI1YWqEcXyRnA==",
"dev": true, "dev": true,
"requires": { "requires": {
"debug": "^4.1.1", "debug": "^4.1.1",
@ -729,13 +729,14 @@
"dev": true "dev": true
}, },
"array-includes": { "array-includes": {
"version": "3.1.0", "version": "3.1.1",
"resolved": "https://registry.npmjs.org/array-includes/-/array-includes-3.1.0.tgz", "resolved": "https://registry.npmjs.org/array-includes/-/array-includes-3.1.1.tgz",
"integrity": "sha512-ONOEQoKrvXPKk7Su92Co0YMqYO32FfqJTzkKU9u2UpIXyYZIzLSvpdg4AwvSw4mSUW0czu6inK+zby6Oj6gDjQ==", "integrity": "sha512-c2VXaCHl7zPsvpkFsw4nxvFie4fh1ur9bpcgsVkIjqn0H/Xwdg+7fv3n2r/isyS8EBj5b06M9kHyZuIr4El6WQ==",
"dev": true, "dev": true,
"requires": { "requires": {
"define-properties": "^1.1.3", "define-properties": "^1.1.3",
"es-abstract": "^1.17.0-next.0" "es-abstract": "^1.17.0",
"is-string": "^1.0.5"
} }
}, },
"array-unique": { "array-unique": {
@ -1586,22 +1587,22 @@
} }
}, },
"es-abstract": { "es-abstract": {
"version": "1.17.0-next.1", "version": "1.17.0",
"resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.17.0-next.1.tgz", "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.17.0.tgz",
"integrity": "sha512-7MmGr03N7Rnuid6+wyhD9sHNE2n4tFSwExnU2lQl3lIo2ShXWGePY80zYaoMOmILWv57H0amMjZGHNzzGG70Rw==", "integrity": "sha512-yYkE07YF+6SIBmg1MsJ9dlub5L48Ek7X0qz+c/CPCHS9EBXfESorzng4cJQjJW5/pB6vDF41u7F8vUhLVDqIug==",
"dev": true, "dev": true,
"requires": { "requires": {
"es-to-primitive": "^1.2.1", "es-to-primitive": "^1.2.1",
"function-bind": "^1.1.1", "function-bind": "^1.1.1",
"has": "^1.0.3", "has": "^1.0.3",
"has-symbols": "^1.0.1", "has-symbols": "^1.0.1",
"is-callable": "^1.1.4", "is-callable": "^1.1.5",
"is-regex": "^1.0.4", "is-regex": "^1.0.5",
"object-inspect": "^1.7.0", "object-inspect": "^1.7.0",
"object-keys": "^1.1.1", "object-keys": "^1.1.1",
"object.assign": "^4.1.0", "object.assign": "^4.1.0",
"string.prototype.trimleft": "^2.1.0", "string.prototype.trimleft": "^2.1.1",
"string.prototype.trimright": "^2.1.0" "string.prototype.trimright": "^2.1.1"
} }
}, },
"es-to-primitive": { "es-to-primitive": {
@ -1643,9 +1644,9 @@
} }
}, },
"eslint": { "eslint": {
"version": "6.7.2", "version": "6.8.0",
"resolved": "https://registry.npmjs.org/eslint/-/eslint-6.7.2.tgz", "resolved": "https://registry.npmjs.org/eslint/-/eslint-6.8.0.tgz",
"integrity": "sha512-qMlSWJaCSxDFr8fBPvJM9kJwbazrhNcBU3+DszDW1OlEwKBBRWsJc7NJFelvwQpanHCR14cOLD41x8Eqvo3Nng==", "integrity": "sha512-K+Iayyo2LtyYhDSYwz5D5QdWw0hCacNzyq1Y821Xna2xSJj7cijoLLYmLxTQgcgZ9mC61nryMy9S7GRbYpI5Ig==",
"dev": true, "dev": true,
"requires": { "requires": {
"@babel/code-frame": "^7.0.0", "@babel/code-frame": "^7.0.0",
@ -1696,9 +1697,9 @@
} }
}, },
"eslint-config-prettier": { "eslint-config-prettier": {
"version": "6.7.0", "version": "6.9.0",
"resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-6.7.0.tgz", "resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-6.9.0.tgz",
"integrity": "sha512-FamQVKM3jjUVwhG4hEMnbtsq7xOIDm+SY5iBPfR8gKsJoAB2IQnNF+bk1+8Fy44Nq7PPJaLvkRxILYdJWoguKQ==", "integrity": "sha512-k4E14HBtcLv0uqThaI6I/n1LEqROp8XaPu6SO9Z32u5NlGRC07Enu1Bh2KEFw4FNHbekH8yzbIU9kUGxbiGmCA==",
"dev": true, "dev": true,
"requires": { "requires": {
"get-stdin": "^6.0.0" "get-stdin": "^6.0.0"
@ -1806,9 +1807,9 @@
} }
}, },
"eslint-plugin-jest": { "eslint-plugin-jest": {
"version": "23.1.1", "version": "23.2.0",
"resolved": "https://registry.npmjs.org/eslint-plugin-jest/-/eslint-plugin-jest-23.1.1.tgz", "resolved": "https://registry.npmjs.org/eslint-plugin-jest/-/eslint-plugin-jest-23.2.0.tgz",
"integrity": "sha512-2oPxHKNh4j1zmJ6GaCBuGcb8FVZU7YjFUOJzGOPnl9ic7VA/MGAskArLJiRIlnFUmi1EUxY+UiATAy8dv8s5JA==", "integrity": "sha512-/jbCUW+g0jejXAvsytgcNhii6uEgolt0RO2e4+mhmXybfkcram5V3XIyrHCnUsb0vCmDKgHhJ1lYSm7F3VCEDA==",
"dev": true, "dev": true,
"requires": { "requires": {
"@typescript-eslint/experimental-utils": "^2.5.0" "@typescript-eslint/experimental-utils": "^2.5.0"
@ -2287,14 +2288,12 @@
"balanced-match": { "balanced-match": {
"version": "1.0.0", "version": "1.0.0",
"bundled": true, "bundled": true,
"dev": true, "dev": true
"optional": true
}, },
"brace-expansion": { "brace-expansion": {
"version": "1.1.11", "version": "1.1.11",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"balanced-match": "^1.0.0", "balanced-match": "^1.0.0",
"concat-map": "0.0.1" "concat-map": "0.0.1"
@ -2309,20 +2308,17 @@
"code-point-at": { "code-point-at": {
"version": "1.1.0", "version": "1.1.0",
"bundled": true, "bundled": true,
"dev": true, "dev": true
"optional": true
}, },
"concat-map": { "concat-map": {
"version": "0.0.1", "version": "0.0.1",
"bundled": true, "bundled": true,
"dev": true, "dev": true
"optional": true
}, },
"console-control-strings": { "console-control-strings": {
"version": "1.1.0", "version": "1.1.0",
"bundled": true, "bundled": true,
"dev": true, "dev": true
"optional": true
}, },
"core-util-is": { "core-util-is": {
"version": "1.0.2", "version": "1.0.2",
@ -2439,8 +2435,7 @@
"inherits": { "inherits": {
"version": "2.0.4", "version": "2.0.4",
"bundled": true, "bundled": true,
"dev": true, "dev": true
"optional": true
}, },
"ini": { "ini": {
"version": "1.3.5", "version": "1.3.5",
@ -2452,7 +2447,6 @@
"version": "1.0.0", "version": "1.0.0",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"number-is-nan": "^1.0.0" "number-is-nan": "^1.0.0"
} }
@ -2467,7 +2461,6 @@
"version": "3.0.4", "version": "3.0.4",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"brace-expansion": "^1.1.7" "brace-expansion": "^1.1.7"
} }
@ -2475,14 +2468,12 @@
"minimist": { "minimist": {
"version": "0.0.8", "version": "0.0.8",
"bundled": true, "bundled": true,
"dev": true, "dev": true
"optional": true
}, },
"minipass": { "minipass": {
"version": "2.9.0", "version": "2.9.0",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"safe-buffer": "^5.1.2", "safe-buffer": "^5.1.2",
"yallist": "^3.0.0" "yallist": "^3.0.0"
@ -2501,7 +2492,6 @@
"version": "0.5.1", "version": "0.5.1",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"minimist": "0.0.8" "minimist": "0.0.8"
} }
@ -2591,8 +2581,7 @@
"number-is-nan": { "number-is-nan": {
"version": "1.0.1", "version": "1.0.1",
"bundled": true, "bundled": true,
"dev": true, "dev": true
"optional": true
}, },
"object-assign": { "object-assign": {
"version": "4.1.1", "version": "4.1.1",
@ -2604,7 +2593,6 @@
"version": "1.4.0", "version": "1.4.0",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"wrappy": "1" "wrappy": "1"
} }
@ -2726,7 +2714,6 @@
"version": "1.0.2", "version": "1.0.2",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"code-point-at": "^1.0.0", "code-point-at": "^1.0.0",
"is-fullwidth-code-point": "^1.0.0", "is-fullwidth-code-point": "^1.0.0",
@ -3286,9 +3273,9 @@
"dev": true "dev": true
}, },
"is-callable": { "is-callable": {
"version": "1.1.4", "version": "1.1.5",
"resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.1.4.tgz", "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.1.5.tgz",
"integrity": "sha512-r5p9sxJjYnArLjObpjA4xu5EKI3CuKHkJXMhT7kwbpUyIFD1n5PMAsoPvWnvtZiNz7LjkYDRZhd7FlI0eMijEA==", "integrity": "sha512-ESKv5sMCJB2jnHTWZ3O5itG+O128Hsus4K4Qh1h2/cgn2vbgnLSVqfV46AeJA9D5EeeLa9w81KUXMtn34zhX+Q==",
"dev": true "dev": true
}, },
"is-ci": { "is-ci": {
@ -3434,6 +3421,12 @@
"integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ=", "integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ=",
"dev": true "dev": true
}, },
"is-string": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/is-string/-/is-string-1.0.5.tgz",
"integrity": "sha512-buY6VNRjhQMiF1qWDouloZlQbRhDPCebwxSjxMjxgemYT46YMd2NR0/H+fBhEfWX4A/w9TBJ+ol+okqJKFE6vQ==",
"dev": true
},
"is-symbol": { "is-symbol": {
"version": "1.0.3", "version": "1.0.3",
"resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.3.tgz", "resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.3.tgz",
@ -4892,9 +4885,9 @@
} }
}, },
"psl": { "psl": {
"version": "1.6.0", "version": "1.7.0",
"resolved": "https://registry.npmjs.org/psl/-/psl-1.6.0.tgz", "resolved": "https://registry.npmjs.org/psl/-/psl-1.7.0.tgz",
"integrity": "sha512-SYKKmVel98NCOYXpkwUqZqh0ahZeeKfmisiLIcEZdsb+WbLv02g/dI5BUmZnIyOe7RzZtLax81nnb2HbvC2tzA==", "integrity": "sha512-5NsSEDv8zY70ScRnOTn7bK7eanl2MvFrOrS/R6x+dBt5g1ghnj9Zv90kO8GwT8gxcu2ANyFprnFYB85IogIJOQ==",
"dev": true "dev": true
}, },
"pump": { "pump": {
@ -5152,9 +5145,9 @@
"dev": true "dev": true
}, },
"rxjs": { "rxjs": {
"version": "6.5.3", "version": "6.5.4",
"resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.5.3.tgz", "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.5.4.tgz",
"integrity": "sha512-wuYsAYYFdWTAnAaPoKGNhfpWwKZbJW+HgAJ+mImp+Epl7BG8oNWBCTyRM8gba9k4lk8BgWdoYm21Mo/RYhhbgA==", "integrity": "sha512-naMQXcgEo3csAEGvw/NydRA0fuS2nDZJiw1YUWFKU7aPPAPGZEsD4Iimit96qwCieH6y614MCLYwdkrWx7z/7Q==",
"dev": true, "dev": true,
"requires": { "requires": {
"tslib": "^1.9.0" "tslib": "^1.9.0"
@ -5446,12 +5439,12 @@
"dev": true "dev": true
}, },
"source-map-resolve": { "source-map-resolve": {
"version": "0.5.2", "version": "0.5.3",
"resolved": "https://registry.npmjs.org/source-map-resolve/-/source-map-resolve-0.5.2.tgz", "resolved": "https://registry.npmjs.org/source-map-resolve/-/source-map-resolve-0.5.3.tgz",
"integrity": "sha512-MjqsvNwyz1s0k81Goz/9vRBe9SZdB09Bdw+/zYyO+3CuPk6fouTaxscHkgtE8jKvf01kVfl8riHzERQ/kefaSA==", "integrity": "sha512-Htz+RnsXWk5+P2slx5Jh3Q66vhQj1Cllm0zvnaY98+NFx+Dv2CF/f5O/t8x+KaNdrdIAsruNzoh/KpialbqAnw==",
"dev": true, "dev": true,
"requires": { "requires": {
"atob": "^2.1.1", "atob": "^2.1.2",
"decode-uri-component": "^0.2.0", "decode-uri-component": "^0.2.0",
"resolve-url": "^0.2.1", "resolve-url": "^0.2.1",
"source-map-url": "^0.4.0", "source-map-url": "^0.4.0",
@ -6027,15 +6020,15 @@
"dev": true "dev": true
}, },
"typescript": { "typescript": {
"version": "3.7.3", "version": "3.7.4",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.7.3.tgz", "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.7.4.tgz",
"integrity": "sha512-Mcr/Qk7hXqFBXMN7p7Lusj1ktCBydylfQM/FZCk5glCNQJrCUKPkMHdo9R0MTFWsC/4kPFvDS0fDPvukfCkFsw==", "integrity": "sha512-A25xv5XCtarLwXpcDNZzCGvW2D1S3/bACratYBx2sax8PefsFhlYmkQicKHvpYflFS8if4zne5zT5kpJ7pzuvw==",
"dev": true "dev": true
}, },
"uglify-js": { "uglify-js": {
"version": "3.7.2", "version": "3.7.3",
"resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.7.2.tgz", "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.7.3.tgz",
"integrity": "sha512-uhRwZcANNWVLrxLfNFEdltoPNhECUR3lc+UdJoG9CBpMcSnKyWA94tc3eAujB1GcMY5Uwq8ZMp4qWpxWYDQmaA==", "integrity": "sha512-7tINm46/3puUA4hCkKYo4Xdts+JDaVC9ZPRcG8Xw9R4nhO/gZgUM3TENq8IF4Vatk8qCig4MzP/c8G4u2BkVQg==",
"dev": true, "dev": true,
"optional": true, "optional": true,
"requires": { "requires": {

View File

@ -1,6 +1,6 @@
{ {
"name": "setup-php", "name": "setup-php",
"version": "1.6.2", "version": "1.7.0",
"private": false, "private": false,
"description": "Setup PHP for use with GitHub Actions", "description": "Setup PHP for use with GitHub Actions",
"main": "dist/index.js", "main": "dist/index.js",

View File

@ -8,7 +8,7 @@ import * as utils from './utils';
export async function addINIValuesUnix( export async function addINIValuesUnix(
ini_values_csv: string ini_values_csv: string
): Promise<string> { ): Promise<string> {
const ini_values: Array<string> = await utils.INIArray(ini_values_csv); const ini_values: Array<string> = await utils.CSVArray(ini_values_csv);
let script = '\n'; let script = '\n';
await utils.asyncForEach(ini_values, async function(line: string) { await utils.asyncForEach(ini_values, async function(line: string) {
script += script +=
@ -25,7 +25,7 @@ export async function addINIValuesUnix(
export async function addINIValuesWindows( export async function addINIValuesWindows(
ini_values_csv: string ini_values_csv: string
): Promise<string> { ): Promise<string> {
const ini_values: Array<string> = await utils.INIArray(ini_values_csv); const ini_values: Array<string> = await utils.CSVArray(ini_values_csv);
let script = '\n'; let script = '\n';
await utils.asyncForEach(ini_values, async function(line: string) { await utils.asyncForEach(ini_values, async function(line: string) {
script += script +=

View File

@ -7,10 +7,12 @@ import * as config from './config';
* *
* @param version * @param version
* @param os_version * @param os_version
* @param pipe
*/ */
export async function addCoverageXdebug( export async function addCoverageXdebug(
version: string, version: string,
os_version: string os_version: string,
pipe: string
): Promise<string> { ): Promise<string> {
switch (version) { switch (version) {
case '8.0': case '8.0':
@ -27,7 +29,7 @@ export async function addCoverageXdebug(
default: default:
return ( return (
(await extensions.addExtension('xdebug', version, os_version, true)) + (await extensions.addExtension('xdebug', version, os_version, true)) +
(await utils.suppressOutput(os_version)) + pipe +
'\n' + '\n' +
(await utils.addLog( (await utils.addLog(
'$tick', '$tick',
@ -44,17 +46,19 @@ export async function addCoverageXdebug(
* *
* @param version * @param version
* @param os_version * @param os_version
* @param pipe
*/ */
export async function addCoveragePCOV( export async function addCoveragePCOV(
version: string, version: string,
os_version: string os_version: string,
pipe: string
): Promise<string> { ): Promise<string> {
let script = '\n'; let script = '\n';
switch (version) { switch (version) {
default: default:
script += script +=
(await extensions.addExtension('pcov', version, os_version, true)) + (await extensions.addExtension('pcov', version, os_version, true)) +
(await utils.suppressOutput(os_version)) + pipe +
'\n'; '\n';
script += script +=
(await config.addINIValues('pcov.enabled=1', os_version, true)) + '\n'; (await config.addINIValues('pcov.enabled=1', os_version, true)) + '\n';
@ -62,32 +66,11 @@ export async function addCoveragePCOV(
// add command to disable xdebug and enable pcov // add command to disable xdebug and enable pcov
switch (os_version) { switch (os_version) {
case 'linux': case 'linux':
script +=
'if [ -e /etc/php/' +
version +
'/mods-available/xdebug.ini ]; then sudo phpdismod -v ' +
version +
' xdebug; fi\n';
script += 'sudo sed -i "/xdebug/d" "$ini_file"\n';
script +=
'sudo DEBIAN_FRONTEND=noninteractive apt-fast remove php-xdebug -y ' +
(await utils.suppressOutput('linux')) +
'\n';
break;
case 'darwin': case 'darwin':
script += 'sudo sed -i \'\' "/xdebug/d" "$ini_file"\n'; script += 'remove_extension xdebug' + pipe + '\n';
script +=
'sudo rm -rf "$ext_dir"/xdebug.so ' +
(await utils.suppressOutput('darwin')) +
'\n';
break; break;
case 'win32': case 'win32':
script += script += 'Remove-Extension xdebug' + pipe + '\n';
'if(php -m | findstr -i xdebug) { Disable-PhpExtension xdebug $php_dir }\n';
script +=
'if (Test-Path $ext_dir\\php_xdebug.dll) { Remove-Item $ext_dir\\php_xdebug.dll }' +
(await utils.suppressOutput('win32')) +
'\n';
break; break;
} }
@ -119,58 +102,23 @@ export async function addCoveragePCOV(
* *
* @param version * @param version
* @param os_version * @param os_version
* @param pipe
*/ */
export async function disableCoverage( export async function disableCoverage(
version: string, version: string,
os_version: string os_version: string,
pipe: string
): Promise<string> { ): Promise<string> {
let script = '\n'; let script = '\n';
switch (os_version) { switch (os_version) {
case 'linux': case 'linux':
script +=
'if [ -e /etc/php/' +
version +
'/mods-available/xdebug.ini ]; then sudo phpdismod -v ' +
version +
' xdebug; fi\n';
script +=
'if [ -e /etc/php/' +
version +
'/mods-available/pcov.ini ]; then sudo phpdismod -v ' +
version +
' pcov; fi\n';
script += 'sudo sed -i "/xdebug/d" "$ini_file"\n';
script += 'sudo sed -i "/pcov/d" "$ini_file"\n';
script +=
'sudo DEBIAN_FRONTEND=noninteractive apt-fast remove php-xdebug php-pcov -y ' +
(await utils.suppressOutput('linux')) +
'\n';
break;
case 'darwin': case 'darwin':
script += 'sudo sed -i \'\' "/xdebug/d" "$ini_file"\n'; script += 'remove_extension xdebug' + pipe + '\n';
script += 'sudo sed -i \'\' "/pcov/d" "$ini_file"\n'; script += 'remove_extension pcov' + pipe + '\n';
script +=
'sudo rm -rf "$ext_dir"/xdebug.so ' +
(await utils.suppressOutput('darwin')) +
'\n';
script +=
'sudo rm -rf "$ext_dir"/pcov.so ' +
(await utils.suppressOutput('darwin')) +
'\n';
break; break;
case 'win32': case 'win32':
script += script += 'Remove-Extension xdebug' + pipe + '\n';
'if(php -m | findstr -i xdebug) { Disable-PhpExtension xdebug $php_dir }\n'; script += 'Remove-Extension pcov' + pipe + '\n';
script +=
'if(php -m | findstr -i pcov) { Disable-PhpExtension pcov $php_dir }\n';
script +=
'if (Test-Path $ext_dir\\php_xdebug.dll) { Remove-Item $ext_dir\\php_xdebug.dll }' +
(await utils.suppressOutput('win32')) +
'\n';
script +=
'if (Test-Path $ext_dir\\php_pcov.dll) { Remove-Item $ext_dir\\php_pcov.dll }' +
(await utils.suppressOutput('win32')) +
'\n';
break; break;
} }
script += await utils.addLog( script += await utils.addLog(
@ -198,13 +146,14 @@ export async function addCoverage(
coverage_driver.toLowerCase(); coverage_driver.toLowerCase();
const script: string = const script: string =
'\n' + (await utils.stepLog('Setup Coverage', os_version)); '\n' + (await utils.stepLog('Setup Coverage', os_version));
const pipe: string = await utils.suppressOutput(os_version);
switch (coverage_driver) { switch (coverage_driver) {
case 'pcov': case 'pcov':
return script + (await addCoveragePCOV(version, os_version)); return script + (await addCoveragePCOV(version, os_version, pipe));
case 'xdebug': case 'xdebug':
return script + (await addCoverageXdebug(version, os_version)); return script + (await addCoverageXdebug(version, os_version, pipe));
case 'none': case 'none':
return script + (await disableCoverage(version, os_version)); return script + (await disableCoverage(version, os_version, pipe));
default: default:
return ''; return '';
} }

View File

@ -6,26 +6,39 @@ import * as utils from './utils';
* *
* @param extension_csv * @param extension_csv
* @param version * @param version
* @param pipe
*/ */
export async function addExtensionDarwin( export async function addExtensionDarwin(
extension_csv: string, extension_csv: string,
version: string version: string,
pipe: string
): Promise<string> { ): Promise<string> {
const extensions: Array<string> = await utils.extensionArray(extension_csv); const extensions: Array<string> = await utils.extensionArray(extension_csv);
let script = '\n'; let script = '\n';
await utils.asyncForEach(extensions, async function(extension: string) { await utils.asyncForEach(extensions, async function(extension: string) {
extension = extension.toLowerCase(); extension = extension.toLowerCase();
const version_extension: string = version + extension;
// add script to enable extension is already installed along with php // add script to enable extension is already installed along with php
let install_command = ''; let install_command = '';
switch (version + extension) { switch (true) {
case '5.6xdebug': case /5\.6xdebug/.test(version_extension):
install_command = 'sudo pecl install xdebug-2.5.5 >/dev/null 2>&1'; install_command = 'sudo pecl install xdebug-2.5.5' + pipe;
break; break;
case '5.6redis': case /5\.6redis/.test(version_extension):
install_command = 'sudo pecl install redis-2.2.8 >/dev/null 2>&1'; install_command = 'sudo pecl install redis-2.2.8' + pipe;
break;
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
install_command =
'sh ' +
path.join(__dirname, '../src/scripts/ext/phalcon_darwin.sh') +
' ' +
extension +
' ' +
version +
pipe;
break; break;
default: default:
install_command = 'sudo pecl install ' + extension + ' >/dev/null 2>&1'; install_command = 'sudo pecl install ' + extension + pipe;
break; break;
} }
script += script +=
@ -44,18 +57,29 @@ export async function addExtensionDarwin(
* *
* @param extension_csv * @param extension_csv
* @param version * @param version
* @param pipe
*/ */
export async function addExtensionWindows( export async function addExtensionWindows(
extension_csv: string, extension_csv: string,
version: string version: string,
pipe: string
): Promise<string> { ): Promise<string> {
const extensions: Array<string> = await utils.extensionArray(extension_csv); const extensions: Array<string> = await utils.extensionArray(extension_csv);
let script = '\n'; let script = '\n';
await utils.asyncForEach(extensions, async function(extension: string) { await utils.asyncForEach(extensions, async function(extension: string) {
// add script to enable extension is already installed along with php // add script to enable extension is already installed along with php
switch (version + extension) { const version_extension: string = version + extension;
case '7.4redis': switch (true) {
script += '\nAdd-Extension ' + extension + ' beta'; // match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
script +=
'\n& ' +
path.join(__dirname, '../src/scripts/ext/phalcon.ps1') +
' ' +
extension +
' ' +
version +
'\n';
break; break;
default: default:
script += '\nAdd-Extension ' + extension; script += '\nAdd-Extension ' + extension;
@ -70,53 +94,40 @@ export async function addExtensionWindows(
* *
* @param extension_csv * @param extension_csv
* @param version * @param version
* @param pipe
*/ */
export async function addExtensionLinux( export async function addExtensionLinux(
extension_csv: string, extension_csv: string,
version: string version: string,
pipe: string
): Promise<string> { ): Promise<string> {
const extensions: Array<string> = await utils.extensionArray(extension_csv); const extensions: Array<string> = await utils.extensionArray(extension_csv);
let script = '\n'; let script = '\n';
await utils.asyncForEach(extensions, async function(extension: string) { await utils.asyncForEach(extensions, async function(extension: string) {
extension = extension.toLowerCase(); extension = extension.toLowerCase();
// add script to enable extension is already installed along with php // add script to enable extension is already installed along with php
const version_extension: string = version + extension;
let install_command = ''; let install_command = '';
switch (version + extension) { switch (true) {
case '7.4redis': // match 5.6gearman..7.4gearman
install_command = case /^((5\.6)|(7\.[0-4]))gearman$/.test(version_extension):
'sudo DEBIAN_FRONTEND=noninteractive apt-get install -y php7.4-igbinary php7.4-redis >/dev/null 2>&1';
break;
case '7.2phalcon3':
case '7.3phalcon3':
install_command = install_command =
'sh ' + 'sh ' +
path.join(__dirname, '../src/scripts/phalcon.sh') + path.join(__dirname, '../src/scripts/ext/gearman.sh') +
' 3.4.x ' +
version +
' >/dev/null 2>&1';
break;
case '7.2phalcon4':
case '7.3phalcon4':
case '7.4phalcon4':
install_command =
'sh ' +
path.join(__dirname, '../src/scripts/phalcon.sh') +
' master ' +
version +
' >/dev/null 2>&1';
break;
case '7.0gearman':
case '7.1gearman':
case '7.2gearman':
case '7.3gearman':
case '7.4gearman':
install_command =
'sh ' +
path.join(__dirname, '../src/scripts/gearman.sh') +
' ' + ' ' +
version + version +
' >/dev/null 2>&1'; pipe;
break;
// match 7.0phalcon3..7.3phalcon3 and 7.2phalcon4...7.4phalcon4
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
install_command =
'sh ' +
path.join(__dirname, '../src/scripts/ext/phalcon.sh') +
' ' +
extension +
' ' +
version +
pipe;
break; break;
default: default:
install_command = install_command =
@ -124,9 +135,10 @@ export async function addExtensionLinux(
version + version +
'-' + '-' +
extension.replace('pdo_', '').replace('pdo-', '') + extension.replace('pdo_', '').replace('pdo-', '') +
' >/dev/null 2>&1 || sudo pecl install ' + pipe +
' || sudo pecl install ' +
extension + extension +
' >/dev/null 2>&1'; pipe;
break; break;
} }
script += script +=
@ -154,12 +166,11 @@ export async function addExtension(
os_version: string, os_version: string,
no_step = false no_step = false
): Promise<string> { ): Promise<string> {
const pipe: string = await utils.suppressOutput(os_version);
let script = '\n'; let script = '\n';
switch (no_step) { switch (no_step) {
case true: case true:
script += script += (await utils.stepLog('Setup Extensions', os_version)) + pipe;
(await utils.stepLog('Setup Extensions', os_version)) +
(await utils.suppressOutput(os_version));
break; break;
case false: case false:
default: default:
@ -169,11 +180,11 @@ export async function addExtension(
switch (os_version) { switch (os_version) {
case 'win32': case 'win32':
return script + (await addExtensionWindows(extension_csv, version)); return script + (await addExtensionWindows(extension_csv, version, pipe));
case 'darwin': case 'darwin':
return script + (await addExtensionDarwin(extension_csv, version)); return script + (await addExtensionDarwin(extension_csv, version, pipe));
case 'linux': case 'linux':
return script + (await addExtensionLinux(extension_csv, version)); return script + (await addExtensionLinux(extension_csv, version, pipe));
default: default:
return await utils.log( return await utils.log(
'Platform ' + os_version + ' is not supported', 'Platform ' + os_version + ' is not supported',

View File

@ -3,6 +3,7 @@ import * as core from '@actions/core';
import * as config from './config'; import * as config from './config';
import * as coverage from './coverage'; import * as coverage from './coverage';
import * as extensions from './extensions'; import * as extensions from './extensions';
import * as tools from './tools';
import * as utils from './utils'; import * as utils from './utils';
import * as matchers from './matchers'; import * as matchers from './matchers';
@ -26,7 +27,11 @@ export async function build(
(await utils.getInput('ini-values', false)) || (await utils.getInput('ini-values', false)) ||
(await utils.getInput('ini-values-csv', false)); (await utils.getInput('ini-values-csv', false));
const coverage_driver: string = await utils.getInput('coverage', false); const coverage_driver: string = await utils.getInput('coverage', false);
const setup_matchers: string = await utils.getInput('matchers', false); const pecl: string = await utils.getInput('pecl', false);
let tools_csv: string = await utils.getInput('tools', false);
if (pecl == 'true') {
tools_csv = 'pecl, ' + tools_csv;
}
let script: string = await utils.readScript(filename, version, os_version); let script: string = await utils.readScript(filename, version, os_version);
if (extension_csv) { if (extension_csv) {
@ -38,6 +43,7 @@ export async function build(
if (coverage_driver) { if (coverage_driver) {
script += await coverage.addCoverage(coverage_driver, version, os_version); script += await coverage.addCoverage(coverage_driver, version, os_version);
} }
script += await tools.addTools(tools_csv, os_version);
return await utils.writeScript(filename, script); return await utils.writeScript(filename, script);
} }
@ -49,25 +55,18 @@ export async function run(): Promise<void> {
try { try {
const os_version: string = process.platform; const os_version: string = process.platform;
let version: string = await utils.getInput('php-version', true); let version: string = await utils.getInput('php-version', true);
version = version.length > 1 ? version : version + '.0'; version = version.length > 1 ? version.slice(0, 3) : version + '.0';
// check the os version and run the respective script // check the os version and run the respective script
let script_path = ''; let script_path = '';
switch (os_version) { switch (os_version) {
case 'darwin': case 'darwin':
case 'linux':
script_path = await build(os_version + '.sh', version, os_version); script_path = await build(os_version + '.sh', version, os_version);
await exec('sh ' + script_path + ' ' + version + ' ' + __dirname); await exec('sh ' + script_path + ' ' + version + ' ' + __dirname);
break; break;
case 'linux': {
const pecl: string = await utils.getInput('pecl', false);
script_path = await build(os_version + '.sh', version, os_version);
await exec('sh ' + script_path + ' ' + version + ' ' + pecl);
break;
}
case 'win32': case 'win32':
script_path = await build('win32.ps1', version, os_version); script_path = await build('win32.ps1', version, os_version);
await exec( await exec('pwsh ' + script_path + ' ' + version + ' ' + __dirname);
'pwsh ' + script_path + ' -version ' + version + ' -dir ' + __dirname
);
break; break;
} }
await matchers.addMatchers(); await matchers.addMatchers();

View File

@ -1,116 +0,0 @@
tick="✓"
cross="✗"
step_log() {
message=$1
printf "\n\033[90;1m==> \033[0m\033[37;1m%s\033[0m\n" "$message"
}
add_log() {
mark=$1
subject=$2
message=$3
if [ "$mark" = "$tick" ]; then
printf "\033[32;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s\033[0m\n" "$mark" "$subject" "$message"
else
printf "\033[31;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s\033[0m\n" "$mark" "$subject" "$message"
fi
}
version='7.4.0'
step_log "Setup dependencies"
for package in pkg-config autoconf bison re2c openssl@1.1 krb5 enchant libffi freetype intltool icu4c libiconv t1lib gd libzip gmp tidyp libxml2 libxslt postgresql curl;
do
brew install "$package" >/dev/null 2>&1
add_log "$tick" "$package" "Installed"
done
brew link icu4c gettext --force >/dev/null 2>&1
for package in gettext gmp krb5 icu4c bison openssl@1.1 libxml2 libffi libxslt libiconv pkgconfig enchant krb5 readline libedit freetype;
do
caps_package=$(echo "$package" | tr '[:lower:]' '[:upper:]')
{
echo 'export PATH="/usr/local/opt/'"$package"'/bin:$PATH"'
echo 'export PKG_CONFIG_PATH="/usr/local/opt/'$package'/lib/pkgconfig:$PKG_CONFIG_PATH"'
echo 'export '"$caps_package"'_LIBS="-L/usr/local/opt/'$package'/lib"'
echo 'export '"$caps_package"'_CFLAGS="-I/usr/local/opt/'$package'/include"'
} >> ~/.bash_profile;
done
{
echo 'export ICONV_LIBS="-L/usr/local/opt/libiconv/lib"'
echo 'export ICONV_CFLAGS="-I/usr/local/opt/libiconv/include"'
echo 'export LIBXML_LIBS="-L/usr/local/opt/libxml2/lib"'
echo 'export LIBXML_CFLAGS="-I/usr/local/opt/libxml2/include"'
echo 'export ICU_LIBS="-L/usr/local/opt/icu4c/lib"'
echo 'export ICU_CFLAGS="-I/usr/local/opt/icu4c/include"'
echo 'export OPENSSL_LIBS="-L/usr/local/opt/openssl@1.1/lib -lcrypto"'
echo 'export OPENSSL_CFLAGS="-I/usr/local/opt/openssl@1.1/include"'
echo 'export OPENSSL_ROOT_DIR="/usr/local/opt/openssl@1.1/"'
echo 'export OPENSSL_LIB_DIR="/usr/local/opt/openssl@1.1/lib"'
echo 'export OPENSSL_INCLUDE_DIR="/usr/local/opt/openssl@1.1/include"'
echo 'export PKG_CONFIG="/usr/local/opt/pkgconfig/bin/pkg-config"'
echo 'export EXTRA_LIBS="/usr/local/opt/readline/lib/libhistory.dylib
/usr/local/opt/readline/lib/libreadline.dylib
/usr/local/opt/openssl@1.1/lib/libssl.dylib
/usr/local/opt/openssl@1.1/lib/libcrypto.dylib
/usr/local/opt/icu4c/lib/libicudata.dylib
/usr/local/opt/icu4c/lib/libicui18n.dylib
/usr/local/opt/icu4c/lib/libicuio.dylib
/usr/local/opt/icu4c/lib/libicutu.dylib
/usr/local/opt/icu4c/lib/libicuuc.dylib"'
} >> ~/.bash_profile
config_file=$2/../src/configs/config.yaml
step_log "Setup PHPBrew"
curl -L -O https://github.com/phpbrew/phpbrew/raw/master/phpbrew >/dev/null 2>&1
chmod +x ./phpbrew
sudo mv phpbrew /usr/local/bin/phpbrew
sudo mkdir -p /opt/phpbrew
sudo mkdir -p /usr/local/lib
sudo mkdir -p /usr/local/bin
sudo phpbrew init --root=/opt/phpbrew --config="$config_file" >/dev/null 2>&1
sudo chmod -R 777 /opt/phpbrew
export PHPBREW_ROOT=/opt/phpbrew
export PHPBREW_HOME=/opt/phpbrew
echo "[[ -e ~/.phpbrew/bashrc ]] && source ~/.phpbrew/bashrc" >> ~/.bashrc
add_log "$tick" "PHPBrew" "Installed"
source ~/.bash_profile >/dev/null 2>&1
source ~/.bashrc >/dev/null 2>&1
step_log "Setup PHP and Composer"
phpbrew install -j 6 github:php/php-src@PHP-$version as php-$version +dev >/dev/null 2>&1
phpbrew switch $version
sudo ln -sf /opt/phpbrew/php/php-$version/bin/* /usr/local/bin/
sudo ln -sf /opt/phpbrew/php/php-$version/etc/php.ini /etc/php.ini
ini_file=$(php --ini | grep "Loaded Configuration" | sed -e "s|.*:s*||" | sed "s/ //g")
ext_dir=$(php -i | grep "extension_dir => /opt" | sed -e "s|.*=> s*||")
pecl config-set php_ini "$ini_file" >/dev/null 2>&1
pear config-set php_ini "$ini_file" >/dev/null 2>&1
sudo chmod 777 "$ini_file"
brew install composer >/dev/null 2>&1
add_log "$tick" "PHP" "Installed PHP$version"
add_log "$tick" "Composer" "Installed"
add_extension() {
extension=$1
install_command=$2
prefix=$3
if ! php -m | grep -i -q "$extension" && [ -e "$ext_dir/$extension.so" ]; then
echo "$prefix=$extension" >>"$ini_file" && add_log "$tick" "$extension" "Enabled"
elif php -m | grep -i -q "$extension"; then
add_log "$tick" "$extension" "Enabled"
elif ! php -m | grep -i -q "$extension"; then
exists=$(curl -sL https://pecl.php.net/json.php?package="$extension" -w "%{http_code}" -o /dev/null)
if [ "$exists" = "200" ]; then
(
eval "$install_command" && \
add_log "$tick" "$extension" "Installed and enabled"
) || add_log "$cross" "$extension" "Could not install $extension on PHP$version"
else
if ! php -m | grep -i -q "$extension"; then
add_log "$cross" "$extension" "Could not find $extension for PHP$version on PECL"
fi
fi
fi
}

View File

@ -1,11 +1,10 @@
tick="✓" # Function to log start of a operation
cross="✗"
step_log() { step_log() {
message=$1 message=$1
printf "\n\033[90;1m==> \033[0m\033[37;1m%s\033[0m\n" "$message" printf "\n\033[90;1m==> \033[0m\033[37;1m%s\033[0m\n" "$message"
} }
# Function to log result of a operation
add_log() { add_log() {
mark=$1 mark=$1
subject=$2 subject=$2
@ -17,56 +16,77 @@ add_log() {
fi fi
} }
get_extension_regex() { # Function to setup extensions
extension=$1
case $extension in
"opcache")
echo "^Zend\sOPcache$"
;;
"xdebug")
echo "^Xdebug$"
;;
*)
echo ^"$extension"$
;;
esac
}
step_log "Setup PHP and Composer"
export HOMEBREW_NO_INSTALL_CLEANUP=TRUE
brew tap shivammathur/homebrew-php >/dev/null 2>&1
brew install shivammathur/php/php@"$1" composer >/dev/null 2>&1
brew link --force --overwrite php@"$1" >/dev/null 2>&1
ini_file=$(php -d "date.timezone=UTC" --ini | grep "Loaded Configuration" | sed -e "s|.*:s*||" | sed "s/ //g")
echo "date.timezone=UTC" >> "$ini_file"
ext_dir=$(php -i | grep "extension_dir => /usr" | sed -e "s|.*=> s*||")
sudo chmod 777 "$ini_file"
mkdir -p "$(pecl config-get ext_dir)"
composer global require hirak/prestissimo >/dev/null 2>&1
semver=$(php -v | head -n 1 | cut -f 2 -d ' ')
add_log "$tick" "PHP" "Installed PHP $semver"
add_log "$tick" "Composer" "Installed"
add_extension() { add_extension() {
extension=$1 extension=$1
install_command=$2 install_command=$2
prefix=$3 prefix=$3
extension_regex="$(get_extension_regex "$extension")" if ! php -m | grep -i -q -w "$extension" && [ -e "$ext_dir/$extension.so" ]; then
if ! php -m | grep -i -q "$extension_regex" && [ -e "$ext_dir/$extension.so" ]; then
echo "$prefix=$extension" >>"$ini_file" && add_log "$tick" "$extension" "Enabled" echo "$prefix=$extension" >>"$ini_file" && add_log "$tick" "$extension" "Enabled"
elif php -m | grep -i -q "$extension_regex"; then elif php -m | grep -i -q -w "$extension"; then
add_log "$tick" "$extension" "Enabled" add_log "$tick" "$extension" "Enabled"
elif ! php -m | grep -i -q "$extension_regex"; then elif ! php -m | grep -i -q -w "$extension"; then
exists=$(curl -sL https://pecl.php.net/json.php?package="$extension" -w "%{http_code}" -o /dev/null) exists=$(curl -sL https://pecl.php.net/json.php?package="$extension" -w "%{http_code}" -o /dev/null)
if [ "$exists" = "200" ]; then if [ "$exists" = "200" ] || [[ "$extension" == "phalcon"* ]]; then
( (
eval "$install_command" && \ eval "$install_command" && \
add_log "$tick" "$extension" "Installed and enabled" add_log "$tick" "$extension" "Installed and enabled"
) || add_log "$cross" "$extension" "Could not install $extension on PHP $semver" ) || add_log "$cross" "$extension" "Could not install $extension on PHP $semver"
else else
if ! php -m | grep -i -q "$extension_regex"; then if ! php -m | grep -i -q -w "$extension"; then
add_log "$cross" "$extension" "Could not find $extension for PHP $semver on PECL" add_log "$cross" "$extension" "Could not find $extension for PHP $semver on PECL"
fi fi
fi fi
fi fi
} }
# Function to remove extensions
remove_extension() {
extension=$1
sudo sed -i '' "/$1/d" "$ini_file"
sudo rm -rf "$ext_dir"/"$1".so >/dev/null 2>&1
}
# Function to setup a remote tool
add_tool() {
url=$1
tool=$2
if [ "$tool" = "composer" ]; then
brew install composer >/dev/null 2>&1
else
if [ ! -e /usr/local/bin/"$tool" ]; then
rm -rf /usr/local/bin/"${tool:?}"
fi
sudo curl -o /usr/local/bin/"$tool" -L "$url" >/dev/null 2>&1
sudo chmod a+x /usr/local/bin/"$tool"
fi
add_log "$tick" "$tool" "Added"
}
add_pecl() {
add_log "$tick" "PECL" "Added"
}
# Function to setup PHP and composer
setup_php_and_composer() {
export HOMEBREW_NO_INSTALL_CLEANUP=TRUE
brew tap shivammathur/homebrew-php >/dev/null 2>&1
brew install shivammathur/php/php@"$version" >/dev/null 2>&1
brew link --force --overwrite php@"$version" >/dev/null 2>&1
}
# Variables
tick="✓"
cross="✗"
version=$1
# Setup PHP and composer
step_log "Setup PHP"
setup_php_and_composer
ini_file=$(php -d "date.timezone=UTC" --ini | grep "Loaded Configuration" | sed -e "s|.*:s*||" | sed "s/ //g")
echo "date.timezone=UTC" >> "$ini_file"
ext_dir=$(php -i | grep "extension_dir => /usr" | sed -e "s|.*=> s*||")
sudo chmod 777 "$ini_file"
mkdir -p "$(pecl config-get ext_dir)"
semver=$(php -v | head -n 1 | cut -f 2 -d ' ')
add_log "$tick" "PHP" "Installed PHP $semver"

View File

@ -0,0 +1,27 @@
Param (
[Parameter(Position = 0, Mandatory = $true)]
[ValidateNotNull()]
[ValidateSet('phalcon3', 'phalcon4')]
[string]
$extension,
[Parameter(Position = 1, Mandatory = $true)]
[ValidateNotNull()]
[ValidateLength(1, [int]::MaxValue)]
[string]
$version
)
$tick = ([char]8730)
$domain = 'https://github.com'
$php_dir = 'C:\tools\php'
$ext_dir = $php_dir + '\ext'
$installed = Get-Php -Path $php_dir
$extension_version = $extension.substring($extension.Length - 1)
$nts = if(! $installed.ThreadSafe ) { "_nts" } else { "" }
$match = Invoke-WebRequest -UseBasicParsing -Uri $domain/phalcon/cphalcon/releases | Select-String -Pattern "href=`"(.*phalcon_x64_.*_php${version}_${extension_version}.*[0-9]${nts}.zip)`""
$zip_file = $match.Matches[0].Groups[1].Value
Invoke-WebRequest -UseBasicParsing -Uri $domain/$zip_file -OutFile $ENV:RUNNER_TOOL_CACHE\phalcon.zip >$null 2>&1
Expand-Archive -Path $ENV:RUNNER_TOOL_CACHE\phalcon.zip -DestinationPath $ENV:RUNNER_TOOL_CACHE\phalcon -Force >$null 2>&1
New-Item -ItemType SymbolicLink -Path $ext_dir\php_phalcon.dll -Target $ENV:RUNNER_TOOL_CACHE\phalcon\php_phalcon.dll >$null 2>&1
Install-Phpextension psr -MinimumStability stable -Path $php_dir
Enable-PhpExtension -Extension phalcon -Path $php_dir
printf "\033[%s;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" "32" $tick $extension "Installed and enabled"

View File

@ -1,8 +1,6 @@
ini_file=$(php --ini | grep "Loaded Configuration" | sed -e "s|.*:s*||" | sed "s/ //g") ini_file=$(php --ini | grep "Loaded Configuration" | sed -e "s|.*:s*||" | sed "s/ //g")
ini_dir=$(php --ini | grep in: | sed -e "s|.*:s*||" | sed "s/ //g") find /etc/apt/sources.list.d -type f -name 'ondrej-ubuntu-php*.list' -exec sudo DEBIAN_FRONTEND=noninteractive apt-fast update -o Dir::Etc::sourcelist="{}" ';' >/dev/null 2>&1
if [ ! "$(apt-cache search php"$2"-psr)" ]; then curl -s https://packagecloud.io/install/repositories/phalcon/stable/script.deb.sh | sudo bash
sudo DEBIAN_FRONTEND=noninteractive add-apt-repository ppa:ondrej/php -y >/dev/null 2>&1
fi
sudo DEBIAN_FRONTEND=noninteractive apt-fast install -y php"$2"-dev sudo DEBIAN_FRONTEND=noninteractive apt-fast install -y php"$2"-dev
sudo DEBIAN_FRONTEND=noninteractive apt-fast install -y php"$2"-psr sudo DEBIAN_FRONTEND=noninteractive apt-fast install -y php"$2"-psr
for tool in php-config phpize; do for tool in php-config phpize; do
@ -19,6 +17,6 @@ if [ ! "$(apt-cache search php"$2"-psr)" ]; then
echo "extension=psr.so" >> "$ini_file" echo "extension=psr.so" >> "$ini_file"
fi fi
cd ~ && git clone --depth=1 -v https://github.com/phalcon/cphalcon.git -b "$1" extension_major_version=$(echo "$1" | grep -i -Po '\d')
cd cphalcon/build && sudo ./install --phpize /usr/bin/phpize"$2" --php-config /usr/bin/php-config"$2" extension_version=$(apt-cache policy -- *phalcon | grep -i -Po "$extension_major_version\.\d\.\d.*php$2" | head -n 1)
echo "extension=phalcon.so" | sudo tee "$ini_dir/50-phalcon.ini" sudo DEBIAN_FRONTEND=noninteractive apt-fast -o Dpkg::Options::="--force-overwrite" install -y php"$2"-phalcon="$extension_version"

View File

@ -0,0 +1,5 @@
extension=$1
extension_major=${extension: -1}
php_version=$2
brew tap shivammathur/homebrew-phalcon
brew install phalcon@"$php_version"_"$extension_major"

View File

@ -1,11 +1,10 @@
tick="✓" # Function to log start of a operation
cross="✗"
step_log() { step_log() {
message=$1 message=$1
printf "\n\033[90;1m==> \033[0m\033[37;1m%s\033[0m\n" "$message" printf "\n\033[90;1m==> \033[0m\033[37;1m%s\033[0m\n" "$message"
} }
# Function to log result of a operation
add_log() { add_log() {
mark=$1 mark=$1
subject=$2 subject=$2
@ -17,63 +16,131 @@ add_log() {
fi fi
} }
get_extension_regex() { # Function to update php ppa
extension=$1 update_ppa() {
case $extension in if [ "$ppa_updated" = "false" ]; then
"opcache") find /etc/apt/sources.list.d -type f -name 'ondrej-ubuntu-php*.list' -exec sudo DEBIAN_FRONTEND=noninteractive apt-fast update -o Dir::Etc::sourcelist="{}" ';' >/dev/null 2>&1
echo "^Zend\sOPcache$" ppa_updated="true"
;; fi
"xdebug")
echo "^Xdebug$"
;;
*)
echo ^"$extension"$
;;
esac
} }
# Function to setup extensions
add_extension() {
extension=$1
install_command=$2
prefix=$3
if ! php -m | grep -i -q -w "$extension" && [ -e "$ext_dir/$extension.so" ]; then
echo "$prefix=$extension" >>"$ini_file" && add_log "$tick" "$extension" "Enabled"
elif php -m | grep -i -q -w "$extension"; then
add_log "$tick" "$extension" "Enabled"
elif ! php -m | grep -i -q -w "$extension"; then
(eval "$install_command" && add_log "$tick" "$extension" "Installed and enabled") ||
(update_ppa && eval "$install_command" && add_log "$tick" "$extension" "Installed and enabled") ||
add_log "$cross" "$extension" "Could not install $extension on PHP $semver"
fi
}
# Function to remove extensions
remove_extension() {
extension=$1
if [ -e /etc/php/"$version"/mods-available/"$extension".ini ]; then
sudo phpdismod -v "$version" "$extension"
fi
sudo sed -i "/$extension/d" "$ini_file"
sudo DEBIAN_FRONTEND=noninteractive apt-get remove php-"$extension" -y >/dev/null 2>&1
}
# Function to setup a remote tool
add_tool() {
url=$1
tool=$2
if [ ! -e /usr/local/bin/"$tool" ]; then
rm -rf /usr/local/bin/"${tool:?}"
fi
sudo curl -o /usr/local/bin/"$tool" -L "$url" >/dev/null 2>&1
sudo chmod a+x /usr/local/bin/"$tool"
add_log "$tick" "$tool" "Added"
}
# Function to setup the nightly build from master branch
setup_master() {
tar_file=php_"$version"%2Bubuntu"$(lsb_release -r -s)".tar.xz
install_dir=~/php/"$version"
sudo mkdir -m 777 -p ~/php
$apt_install libicu-dev >/dev/null 2>&1
curl -o "$tar_file" -L https://bintray.com/shivammathur/php/download_file?file_path="$tar_file" >/dev/null 2>&1
sudo tar xf "$tar_file" -C ~/php >/dev/null 2>&1
rm -rf "$tar_file"
sudo ln -sf -S "$version" "$install_dir"/bin/* /usr/bin/
sudo ln -sf "$install_dir"/etc/php.ini /etc/php.ini
}
# Function to setup PECL
add_pecl() {
update_ppa
$apt_install php"$version"-dev php"$version"-xml >/dev/null 2>&1
sudo update-alternatives --set php-config /usr/bin/php-config"$version" >/dev/null 2>&1
sudo update-alternatives --set phpize /usr/bin/phpize"$version" >/dev/null 2>&1
wget https://github.com/pear/pearweb_phars/raw/master/install-pear-nozlib.phar >/dev/null 2>&1
sudo php install-pear-nozlib.phar >/dev/null 2>&1
sudo rm -rf install-pear-nozlib.phar >/dev/null 2>&1
sudo pear config-set php_ini "$ini_file" >/dev/null 2>&1
sudo pear config-set auto_discover 1 >/dev/null 2>&1
sudo pear channel-update pear.php.net >/dev/null 2>&1
add_log "$tick" "PECL" "Added"
}
# Function to switch versions of PHP binaries
switch_version() {
for tool in pear pecl php phar phar.phar php-cgi php-config phpize phpdbg; do
if [ -e "/usr/bin/$tool$version" ]; then
sudo update-alternatives --set $tool /usr/bin/"$tool$version" >/dev/null 2>&1
fi
done
}
# Variables
tick="✓"
cross="✗"
ppa_updated="false"
version=$1
apt_install="sudo DEBIAN_FRONTEND=noninteractive apt-fast install -y"
existing_version=$(php-config --version | cut -c 1-3) existing_version=$(php-config --version | cut -c 1-3)
semver=$(php -v | head -n 1 | cut -f 2 -d ' ' | cut -f 1 -d '-') semver=$(php -v | head -n 1 | cut -f 2 -d ' ' | cut -f 1 -d '-')
step_log "Setup PHP and Composer"
# Setup PHP
step_log "Setup PHP"
sudo mkdir -p /var/run sudo mkdir -p /var/run
sudo mkdir -p /run/php sudo mkdir -p /run/php
find /etc/apt/sources.list.d -type f -name 'ondrej-ubuntu-php*.list' -exec sudo DEBIAN_FRONTEND=noninteractive apt-fast update -o Dir::Etc::sourcelist="{}" ';' >/dev/null 2>&1
if [ "$existing_version" != "$1" ]; then
if [ ! -e "/usr/bin/php$1" ]; then
if [ "$1" = "7.4" ]; then
sudo DEBIAN_FRONTEND=noninteractive apt-fast install -y php"$1" php"$1"-phpdbg php"$1"-xml curl php"$1"-curl >/dev/null 2>&1
elif [ "$1" = "8.0" ]; then
tar_file=php_"$1"%2Bubuntu"$(lsb_release -r -s)".tar.xz
install_dir=~/php/"$1"
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install libicu-dev >/dev/null 2>&1
curl -o "$tar_file" -L https://bintray.com/shivammathur/php/download_file?file_path="$tar_file" >/dev/null 2>&1
sudo mkdir -m 777 -p ~/php
sudo tar xf "$tar_file" -C ~/php >/dev/null 2>&1 && rm -rf "$tar_file"
sudo ln -sf -S "$1" "$install_dir"/bin/* /usr/bin/ && sudo ln -sf "$install_dir"/etc/php.ini /etc/php.ini
else
sudo DEBIAN_FRONTEND=noninteractive apt-fast install -y php"$1" curl php"$1"-curl >/dev/null 2>&1
fi
status="installed"
else
status="switched"
fi
for tool in pear pecl php phar phar.phar php-cgi php-config phpize phpdbg; do if [ "$existing_version" != "$version" ]; then
if [ -e "/usr/bin/$tool$1" ]; then if [ ! -e "/usr/bin/php$version" ]; then
sudo update-alternatives --set $tool /usr/bin/"$tool$1" >/dev/null 2>&1 update_ppa
fi ppa_updated=1
done if [ "$version" = "7.4" ]; then
$apt_install php"$version" php"$version"-phpdbg php"$version"-xml curl php"$version"-curl >/dev/null 2>&1
elif [ "$version" = "8.0" ]; then
setup_master
else
$apt_install php"$version" curl php"$version"-curl >/dev/null 2>&1
fi
status="installed"
else
status="switched"
fi
semver=$(php -v | head -n 1 | cut -f 2 -d ' ' | cut -f 1 -d '-') switch_version
if [ "$1" = "8.0" ]; then
semver=$(php -v | head -n 1 | cut -f 2 -d ' ')
fi
if [ "$status" != "switched" ]; then semver=$(php -v | head -n 1 | cut -f 2 -d ' ' | cut -f 1 -d '-')
status="Installed PHP $semver" if [ "$version" = "8.0" ]; then
else semver=$(php -v | head -n 1 | cut -f 2 -d ' ')
status="Switched to PHP $semver" fi
fi
if [ "$status" != "switched" ]; then
status="Installed PHP $semver"
else
status="Switched to PHP $semver"
fi
else else
status="PHP $semver Found" status="PHP $semver Found"
fi fi
@ -82,45 +149,3 @@ ini_file=$(php --ini | grep "Loaded Configuration" | sed -e "s|.*:s*||" | sed "s
ext_dir=$(php -i | grep "extension_dir => /usr" | sed -e "s|.*=> s*||") ext_dir=$(php -i | grep "extension_dir => /usr" | sed -e "s|.*=> s*||")
sudo chmod 777 "$ini_file" sudo chmod 777 "$ini_file"
add_log "$tick" "PHP" "$status" add_log "$tick" "PHP" "$status"
if [ "$2" = "true" ]; then
sudo DEBIAN_FRONTEND=noninteractive apt-fast install -y php"$1"-dev php"$1"-xml >/dev/null 2>&1
sudo update-alternatives --set php-config /usr/bin/php-config"$1" >/dev/null 2>&1
sudo update-alternatives --set phpize /usr/bin/phpize"$1" >/dev/null 2>&1
wget https://github.com/pear/pearweb_phars/raw/master/install-pear-nozlib.phar >/dev/null 2>&1
sudo php install-pear-nozlib.phar >/dev/null 2>&1
sudo pear config-set php_ini "$ini_file" >/dev/null 2>&1
sudo pear config-set auto_discover 1
sudo pear channel-update pear.php.net
add_log "$tick" "PECL" "Installed"
fi
if [ ! -e "/usr/bin/composer" ]; 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
export COMPOSER_ALLOW_SUPERUSER=1
sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer
fi
rm composer-setup.php
fi
composer global require hirak/prestissimo >/dev/null 2>&1
add_log "$tick" "Composer" "Installed"
add_extension()
{
extension=$1
install_command=$2
prefix=$3
extension_regex="$(get_extension_regex "$extension")"
if ! php -m | grep -i -q "$extension_regex" && [ -e "$ext_dir/$extension.so" ]; then
echo "$prefix=$extension" >> "$ini_file" && add_log "$tick" "$extension" "Enabled"
elif php -m | grep -i -q "$extension_regex"; then
add_log "$tick" "$extension" "Enabled"
elif ! php -m | grep -i -q "$extension_regex"; then
(
eval "$install_command" && \
add_log "$tick" "$extension" "Installed and enabled"
) || add_log "$cross" "$extension" "Could not install $extension on PHP $semver"
fi
}

View File

@ -1,15 +1,16 @@
param ( param (
[Parameter(Mandatory = $true)][string]$version = "7.4", [Parameter(Position = 0, Mandatory = $true)]
[Parameter(Mandatory=$true)][string]$dir [ValidateNotNull()]
[ValidateLength(1, [int]::MaxValue)]
[string]
$version = '7.4',
[Parameter(Position = 1, Mandatory = $true)]
[ValidateNotNull()]
[ValidateLength(1, [int]::MaxValue)]
[string]
$dir
) )
$tick = ([char]8730)
$cross = ([char]10007)
$php_dir = 'C:\tools\php'
$ext_dir = $php_dir + '\ext'
$ProgressPreference = 'SilentlyContinue'
$master_version = '8.0'
Function Step-Log($message) { Function Step-Log($message) {
printf "\n\033[90;1m==> \033[0m\033[37;1m%s \033[0m\n" $message printf "\n\033[90;1m==> \033[0m\033[37;1m%s \033[0m\n" $message
} }
@ -19,50 +20,6 @@ Function Add-Log($mark, $subject, $message) {
printf "\033[%s;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" $code $mark $subject $message printf "\033[%s;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" $code $mark $subject $message
} }
Step-Log "Setup PhpManager"
Install-Module -Name PhpManager -Force -Scope CurrentUser
Add-Log $tick "PhpManager" "Installed"
$installed = $null
if (Test-Path -LiteralPath $php_dir -PathType Container) {
try {
$installed = Get-Php -Path $php_dir
}
catch {
}
}
Step-Log "Setup PHP and Composer"
if ($null -eq $installed -or -not("$($installed.Version).".StartsWith(($version -replace '^(\d+(\.\d+)*).*', '$1.')))) {
$arch='x64'
if ($version -lt '7.0') {
Install-Module -Name VcRedist -Force
$arch='x86'
}
if ($version -eq $master_version) {
$version = 'master'
}
Install-Php -Version $version -Architecture $arch -ThreadSafe $true -InstallVC -Path $php_dir -TimeZone UTC -InitialPhpIni Production -Force >$null 2>&1
$installed = Get-Php -Path $php_dir
$status = "Installed PHP $($installed.FullVersion)"
}
else {
$status = "PHP $($installed.FullVersion) Found"
}
Set-PhpIniKey -Key 'date.timezone' -Value 'UTC' -Path $php_dir
Enable-PhpExtension -Extension openssl, curl, opcache -Path $php_dir
Update-PhpCAInfo -Path $php_dir -Source CurrentUser
Add-Log $tick "PHP" $status
Install-Composer -Scope System -Path $php_dir -PhpPath $php_dir
Add-Log $tick "Composer" "Installed"
if ($version -eq 'master') {
Copy-Item $dir"\..\src\ext\php_pcov.dll" -Destination $ext_dir"\php_pcov.dll"
Set-PhpIniKey -Key 'opcache.jit_buffer_size' -Value '256M' -Path $php_dir
Set-PhpIniKey -Key 'opcache.jit' -Value '1235' -Path $php_dir
}
Function Add-Extension { Function Add-Extension {
Param ( Param (
[Parameter(Position = 0, Mandatory = $true)] [Parameter(Position = 0, Mandatory = $true)]
@ -101,3 +58,104 @@ Function Add-Extension {
Add-Log $cross $extension "Could not install $extension on PHP $($installed.FullVersion)" Add-Log $cross $extension "Could not install $extension on PHP $($installed.FullVersion)"
} }
} }
Function Remove-Extension() {
Param (
[Parameter(Position = 0, Mandatory = $true)]
[ValidateNotNull()]
[ValidateLength(1, [int]::MaxValue)]
[string]
$extension
)
if(php -m | findstr -i $extension) {
Disable-PhpExtension $extension $php_dir
}
if (Test-Path $ext_dir\php_$extension.dll) {
Remove-Item $ext_dir\php_$extension.dll
}
}
# Function to setup a remote tool
Function Add-Tool() {
Param (
[Parameter(Position = 0, Mandatory = $true)]
[ValidateNotNull()]
[ValidateLength(1, [int]::MaxValue)]
[string]
$url,
[Parameter(Position = 1, Mandatory = $true)]
[ValidateNotNull()]
[ValidateLength(1, [int]::MaxValue)]
[string]
$tool
)
if($tool -eq "composer") {
Install-Composer -Scope System -Path $php_dir -PhpPath $php_dir
} else {
if (Test-Path $php_dir\$tool)
{
Remove-Item $php_dir\$tool
}
Invoke-WebRequest -UseBasicParsing -Uri $url -OutFile $php_dir\$tool > $null 2>&1
$bat_content = @()
$bat_content += "@ECHO off"
$bat_content += "setlocal DISABLEDELAYEDEXPANSION"
$bat_content += "SET BIN_TARGET=%~dp0/" + $tool
$bat_content += "php %BIN_TARGET% %*"
Set-Content -Path $php_dir\$tool.bat -Value $bat_content
Add-Content -Path $PsHome\profile.ps1 -Value "New-Alias $tool $php_dir\$tool.bat"
}
Add-Log $tick $tool "Added"
}
Function Add-PECL() {
Add-Log $tick "PECL" "Use extensions input or Install-PhpExtension to setup PECL extensions on windows"
}
# Variables
$tick = ([char]8730)
$cross = ([char]10007)
$php_dir = 'C:\tools\php'
$ext_dir = $php_dir + '\ext'
$ProgressPreference = 'SilentlyContinue'
$master_version = '8.0'
$arch='x64'
Step-Log "Setup PhpManager"
Install-Module -Name PhpManager -Force -Scope CurrentUser
Add-Log $tick "PhpManager" "Installed"
$installed = $null
if (Test-Path -LiteralPath $php_dir -PathType Container) {
try {
$installed = Get-Php -Path $php_dir
}
catch {
}
}
Step-Log "Setup PHP"
if ($null -eq $installed -or -not("$($installed.Version).".StartsWith(($version -replace '^(\d+(\.\d+)*).*', '$1.')))) {
if ($version -lt '7.0') {
Install-Module -Name VcRedist -Force
$arch='x86'
}
if ($version -eq $master_version) {
$version = 'master'
}
Install-Php -Version $version -Architecture $arch -ThreadSafe $true -InstallVC -Path $php_dir -TimeZone UTC -InitialPhpIni Production -Force >$null 2>&1
}
else {
Update-Php $php_dir >$null 2>&1
}
$installed = Get-Php -Path $php_dir
Set-PhpIniKey -Key 'date.timezone' -Value 'UTC' -Path $php_dir
Enable-PhpExtension -Extension openssl, curl, opcache -Path $php_dir
Update-PhpCAInfo -Path $php_dir -Source CurrentUser
if ($version -eq 'master') {
Copy-Item $dir"\..\src\bin\php_pcov.dll" -Destination $ext_dir"\php_pcov.dll"
Set-PhpIniKey -Key 'opcache.jit_buffer_size' -Value '256M' -Path $php_dir
Set-PhpIniKey -Key 'opcache.jit' -Value '1235' -Path $php_dir
}
Add-Log $tick "PHP" "Installed PHP $($installed.FullVersion)"

196
src/tools.ts Normal file
View File

@ -0,0 +1,196 @@
import * as utils from './utils';
export async function getToolCommand(os_version: string): Promise<string> {
switch (os_version) {
case 'linux':
case 'darwin':
return 'add_tool ';
case 'win32':
return 'Add-Tool ';
default:
return await utils.log(
'Platform ' + os_version + ' is not supported',
os_version,
'error'
);
}
}
export async function getPECLCommand(os_version: string): Promise<string> {
switch (os_version) {
case 'linux':
case 'darwin':
return 'add_pecl ';
case 'win32':
return 'Add-PECL ';
default:
return await utils.log(
'Platform ' + os_version + ' is not supported',
os_version,
'error'
);
}
}
export async function linkTool(
tool: string,
os_version: string
): Promise<string> {
switch (os_version) {
case 'linux':
case 'darwin':
return (
'sudo ln -s "$(composer -q global config home)"/vendor/bin/' +
tool +
' /usr/local/bin/' +
tool
);
case 'win32':
return (
'$composer_dir = composer -q global config home | % {$_ -replace "/", "\\"}' +
'\n' +
'Add-Content -Path $PsHome\\profile.ps1 -Value "New-Alias ' +
tool +
' $composer_dir\\vendor\\bin\\' +
tool +
'.bat"'
);
default:
return await utils.log(
'Platform ' + os_version + ' is not supported',
os_version,
'error'
);
}
}
/**
* Setup tools
*
* @param tool_csv
* @param os_version
*/
export async function addTools(
tools_csv: string,
os_version: string
): Promise<string> {
let script = '\n' + (await utils.stepLog('Setup Tools', os_version));
let tools: Array<string> = await utils.CSVArray(tools_csv);
tools = tools.filter(tool => tool !== 'composer');
tools.unshift('composer');
await utils.asyncForEach(tools, async function(tool: string) {
script += '\n';
switch (tool) {
case 'php-cs-fixer':
script +=
(await getToolCommand(os_version)) +
'https://github.com/FriendsOfPHP/PHP-CS-Fixer/releases/latest/download/php-cs-fixer.phar' +
' ' +
'php-cs-fixer';
break;
case 'phpcs':
script +=
(await getToolCommand(os_version)) +
'https://github.com/squizlabs/PHP_CodeSniffer/releases/latest/download/phpcs.phar' +
' ' +
'phpcs';
break;
case 'phpcbf':
script +=
(await getToolCommand(os_version)) +
'https://github.com/squizlabs/PHP_CodeSniffer/releases/latest/download/phpcbf.phar' +
' ' +
'phpcbf';
break;
case 'phpcpd':
script +=
(await getToolCommand(os_version)) +
'https://github.com/sebastianbergmann/phpcpd/releases/latest/download/phpcpd.phar' +
' ' +
'phpcpd';
break;
case 'phpstan':
script +=
(await getToolCommand(os_version)) +
'https://github.com/phpstan/phpstan/releases/latest/download/phpstan.phar' +
' ' +
'phpstan';
break;
case 'phpmd':
script +=
(await getToolCommand(os_version)) +
'https://github.com/phpmd/phpmd/releases/latest/download/phpmd.phar' +
' ' +
'phpmd';
break;
case 'psalm':
script +=
(await getToolCommand(os_version)) +
'https://github.com/vimeo/psalm/releases/latest/download/psalm.phar' +
' ' +
'psalm';
break;
case 'phinx':
script +=
'composer global require robmorgan/phinx' +
(await utils.suppressOutput(os_version)) +
'\n' +
(await linkTool('phinx', os_version)) +
'\n' +
(await utils.addLog('$tick', 'phinx', 'Added', os_version));
break;
case 'composer':
script +=
(await getToolCommand(os_version)) +
'https://github.com/composer/composer/releases/latest/download/composer.phar' +
' ' +
'composer';
break;
case 'codeception':
script +=
(await getToolCommand(os_version)) +
'https://codeception.com/codecept.phar' +
' ' +
'codeception';
break;
case 'phpunit':
script +=
(await getToolCommand(os_version)) +
'https://phar.phpunit.de/phpunit.phar' +
' ' +
'phpunit';
break;
case 'deployer':
script +=
(await getToolCommand(os_version)) +
'https://deployer.org/deployer.phar' +
' ' +
'deployer';
break;
case 'prestissimo':
script +=
'composer global require hirak/prestissimo' +
(await utils.suppressOutput(os_version)) +
'\n' +
(await utils.addLog(
'$tick',
'hirak/prestissimo',
'Added',
os_version
));
break;
case 'pecl':
script += await getPECLCommand(os_version);
break;
default:
script += await utils.log(
'Tool ' + tool + ' is not supported',
os_version,
'error'
);
break;
}
});
return script;
}

View File

@ -191,30 +191,36 @@ export async function extensionArray(
case ' ': case ' ':
return []; return [];
default: default:
return extension_csv.split(',').map(function(extension: string) { return extension_csv
return extension .split(',')
.trim() .map(function(extension: string) {
.replace('php-', '') return extension
.replace('php_', ''); .trim()
}); .replace('php-', '')
.replace('php_', '');
})
.filter(Boolean);
} }
} }
/** /**
* Function to break ini values csv into an array * Function to break csv into an array
* *
* @param ini_values_csv * @param values_csv
* @constructor * @constructor
*/ */
export async function INIArray(ini_values_csv: string): Promise<Array<string>> { export async function CSVArray(values_csv: string): Promise<Array<string>> {
switch (ini_values_csv) { switch (values_csv) {
case '': case '':
case ' ': case ' ':
return []; return [];
default: default:
return ini_values_csv.split(',').map(function(ini_value: string) { return values_csv
return ini_value.trim(); .split(',')
}); .map(function(value: string) {
return value.trim();
})
.filter(Boolean);
} }
} }