mirror of
https://github.com/shivammathur/setup-php.git
synced 2025-08-03 20:25:32 +07:00
Compare commits
13 Commits
Author | SHA1 | Date | |
---|---|---|---|
409e055931 | |||
46a875ad7e | |||
7e81c058fb | |||
754ab9515b | |||
f866c880c2 | |||
eb21cb8fb3 | |||
aee6b953c3 | |||
21c3c8db47 | |||
c0e0d9d98e | |||
5ab8ec4a99 | |||
ec3c220bb2 | |||
17d90ace86 | |||
ba5306eea9 |
4
.github/workflows/workflow.yml
vendored
4
.github/workflows/workflow.yml
vendored
@ -30,8 +30,8 @@ jobs:
|
|||||||
run: node lib/install.js
|
run: node lib/install.js
|
||||||
env:
|
env:
|
||||||
php-version: ${{ matrix.php-versions }}
|
php-version: ${{ matrix.php-versions }}
|
||||||
extension-csv: "mbstring, xdebug, pcov" #optional
|
extension-csv: mbstring, xdebug, pcov #optional
|
||||||
ini-values-csv: "post_max_size=256M, short_open_tag=On, date.timezone=Asia/Kolkata" #optional
|
ini-values-csv: post_max_size=256M, short_open_tag=On, date.timezone=Asia/Kolkata #optional
|
||||||
|
|
||||||
- name: Testing PHP version
|
- name: Testing PHP version
|
||||||
run: php -v
|
run: php -v
|
||||||
|
80
README.md
80
README.md
@ -8,13 +8,14 @@
|
|||||||
|
|
||||||
<p align="left">
|
<p align="left">
|
||||||
<a href="https://github.com/shivammathur/setup-php"><img alt="GitHub Actions status" src="https://github.com/shivammathur/setup-php/workflows/Main%20workflow/badge.svg"></a>
|
<a href="https://github.com/shivammathur/setup-php"><img alt="GitHub Actions status" src="https://github.com/shivammathur/setup-php/workflows/Main%20workflow/badge.svg"></a>
|
||||||
|
<a href="https://codecov.io/gh/shivammathur/setup-php"><img alt="Codecov Code Coverage" src="https://codecov.io/gh/shivammathur/setup-php/branch/master/graph/badge.svg"></a>
|
||||||
<a href="https://github.com/shivammathur/setup-php/blob/master/LICENSE"><img alt="LICENSE" src="https://img.shields.io/badge/license-MIT-428f7e.svg"></a>
|
<a href="https://github.com/shivammathur/setup-php/blob/master/LICENSE"><img alt="LICENSE" src="https://img.shields.io/badge/license-MIT-428f7e.svg"></a>
|
||||||
<a href="#tada-php-support"><img alt="PHP Versions Supported" src="https://img.shields.io/badge/php-%3E%3D%205.6-8892BF.svg"></a>
|
<a href="#tada-php-support"><img alt="PHP Versions Supported" src="https://img.shields.io/badge/php-%3E%3D%205.6-8892BF.svg"></a>
|
||||||
<a href="https://www.patreon.com/shivammathur"><img alt="Support me on Patreon" src="https://shivammathur.com/badges/patreon.svg"></a> <a href="https://www.paypal.me/shivammathur"><img alt="Support me on Paypal" src="https://shivammathur.com/badges/paypal.svg"></a>
|
<a href="https://www.patreon.com/shivammathur"><img alt="Support me on Patreon" src="https://shivammathur.com/badges/patreon.svg"></a> <a href="https://www.paypal.me/shivammathur"><img alt="Support me on PayPal" src="https://shivammathur.com/badges/paypal.svg"></a>
|
||||||
<a href="https://www.codementor.io/shivammathur?utm_source=github&utm_medium=button&utm_term=shivammathur&utm_campaign=github"><img alt="Get Help on codementor" src="https://cdn.codementor.io/badges/get_help_github.svg"></a>
|
<a href="https://www.codementor.io/shivammathur?utm_source=github&utm_medium=button&utm_term=shivammathur&utm_campaign=github"><img alt="Contact me on Codementor" src="https://cdn.codementor.io/badges/contact_me_github.svg"></a>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
Setup PHP with required extensions, php.ini configuration and composer in [GitHub Actions](https://github.com/features/actions). This action can be added as a step in your action workflow and it will setup the PHP environment you need to test your application. Refer to [Usage](#memo-usage) section to see how to use this.
|
Setup PHP with required extensions, php.ini configuration and composer in [GitHub Actions](https://github.com/features/actions). This action can be added as a step in your action workflow and it will setup the PHP environment you need to test your application. Refer to [Usage](#memo-usage) section and [examples](#examples) to see how to use this.
|
||||||
|
|
||||||
## :tada: PHP Support
|
## :tada: PHP Support
|
||||||
|
|
||||||
@ -25,7 +26,7 @@ Setup PHP with required extensions, php.ini configuration and composer in [GitHu
|
|||||||
|7.1|`Stable`|`Security fixes only`|
|
|7.1|`Stable`|`Security fixes only`|
|
||||||
|7.2|`Stable`|`Active`|
|
|7.2|`Stable`|`Active`|
|
||||||
|7.3|`Stable`|`Active`|
|
|7.3|`Stable`|`Active`|
|
||||||
|7.4|`Beta`/`RC`|`Active`|
|
|7.4|`RC3`|`Active`|
|
||||||
|
|
||||||
**Note:** PHP 7.4 is currently in development, do not use in production/release branches.
|
**Note:** PHP 7.4 is currently in development, do not use in production/release branches.
|
||||||
|
|
||||||
@ -39,43 +40,60 @@ Setup PHP with required extensions, php.ini configuration and composer in [GitHu
|
|||||||
|Ubuntu 16.04|`ubuntu-16.04`|
|
|Ubuntu 16.04|`ubuntu-16.04`|
|
||||||
|macOS X Mojave 10.14|`macOS-latest` or `macOS-10.14`|
|
|macOS X Mojave 10.14|`macOS-latest` or `macOS-10.14`|
|
||||||
|
|
||||||
|
|
||||||
## :wrench: PHP Extension Support
|
## :wrench: PHP Extension Support
|
||||||
- On `ubuntu` extensions which have the package in apt are installed.
|
- On `ubuntu` extensions which have the package in apt are installed.
|
||||||
- On `windows` and `macOS` PECL extensions are installed.
|
- On `windows` and `macOS` PECL extensions are 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 interruped.
|
- Extensions which cannot be installed gracefully leave an error message in the logs, the action is not interrupted.
|
||||||
|
|
||||||
## :signal_strength: Coverage support
|
## :signal_strength: Coverage support
|
||||||
- Specify `coverage: xdebug` to use `Xdebug`.
|
|
||||||
- Runs on all [PHP versions supported](#tada-php-support)
|
### Xdebug
|
||||||
```
|
|
||||||
|
Specify `coverage: xdebug` to use `Xdebug`.
|
||||||
|
Runs on all [PHP versions supported](#tada-php-support)
|
||||||
|
|
||||||
|
```yaml
|
||||||
uses: shivammathur/setup-php@master
|
uses: shivammathur/setup-php@master
|
||||||
with:
|
with:
|
||||||
php-version: 7.3
|
php-version: '7.3'
|
||||||
coverage: xdebug
|
coverage: xdebug
|
||||||
```
|
```
|
||||||
- Specify `coverage: pcov` to use `PCOV`. `PCOV` is way faster than `Xdebug`
|
|
||||||
- For `pcov.directory` to be other than `src`, `lib` or, `app`, specify it using the `ini-values-csv` input.
|
### PCOV
|
||||||
- `PCOV` needs `PHPUnit >= 8.0` and `PHP >= 7.1`, `PHPUnit` needs `PHP >= 7.2`. So use `PHP >= 7.2` with `PCOV`
|
|
||||||
```
|
Specify `coverage: pcov` to use `PCOV`. `PCOV` is way faster than `Xdebug`.
|
||||||
|
For `pcov.directory` to be other than `src`, `lib` or, `app`, specify it using the `ini-values-csv` input.
|
||||||
|
`PCOV` needs `PHPUnit >= 8.0` and `PHP >= 7.1`, `PHPUnit` needs `PHP >= 7.2`. So use `PHP >= 7.2` with `PCOV`
|
||||||
|
|
||||||
|
```yaml
|
||||||
uses: shivammathur/setup-php@master
|
uses: shivammathur/setup-php@master
|
||||||
with:
|
with:
|
||||||
php-version: 7.3
|
php-version: '7.3'
|
||||||
ini-values-csv: 'pcov.directory=api' #optional, see above for usage.
|
ini-values-csv: pcov.directory=api #optional, see above for usage.
|
||||||
coverage: pcov
|
coverage: pcov
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Disable coverage
|
||||||
|
Specify `coverage: none` to disable both `Xdebug` and `PCOV`.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
uses: shivammathur/setup-php@master
|
||||||
|
with:
|
||||||
|
php-version: '7.3'
|
||||||
|
coverage: none
|
||||||
|
```
|
||||||
|
|
||||||
## :memo: Usage
|
## :memo: Usage
|
||||||
|
|
||||||
Inputs supported by this GitHub Action.
|
Inputs supported by this GitHub Action.
|
||||||
|
|
||||||
- php-version
|
- php-version `required`
|
||||||
- extension-csv (optional)
|
- extension-csv `optional`
|
||||||
- ini-values-csv (optional)
|
- ini-values-csv `optional`
|
||||||
- coverage (optional)
|
- coverage `optional`
|
||||||
|
|
||||||
See [action.yml](action.yml) for more info
|
See [action.yml](action.yml) and usage below for more info.
|
||||||
|
|
||||||
### Basic Usage
|
### Basic Usage
|
||||||
|
|
||||||
@ -86,9 +104,9 @@ steps:
|
|||||||
- name: Installing PHP
|
- name: Installing PHP
|
||||||
uses: shivammathur/setup-php@master
|
uses: shivammathur/setup-php@master
|
||||||
with:
|
with:
|
||||||
php-version: 7.3
|
php-version: '7.3'
|
||||||
extension-csv: mbstring, xdebug #optional
|
extension-csv: mbstring, xdebug #optional
|
||||||
ini-values-csv: "post_max_size=256M, short_open_tag=On" #optional
|
ini-values-csv: post_max_size=256M, short_open_tag=On #optional
|
||||||
coverage: xdebug #optional
|
coverage: xdebug #optional
|
||||||
- name: Check PHP Version
|
- name: Check PHP Version
|
||||||
run: php -v
|
run: php -v
|
||||||
@ -118,7 +136,7 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
php-version: ${{ matrix.php-versions }}
|
php-version: ${{ matrix.php-versions }}
|
||||||
extension-csv: mbstring, xdebug #optional
|
extension-csv: mbstring, xdebug #optional
|
||||||
ini-values-csv: "post_max_size=256M, short_open_tag=On" #optional
|
ini-values-csv: post_max_size=256M, short_open_tag=On #optional
|
||||||
coverage: xdebug #optional
|
coverage: xdebug #optional
|
||||||
- name: Check PHP Version
|
- name: Check PHP Version
|
||||||
run: php -v
|
run: php -v
|
||||||
@ -131,8 +149,20 @@ jobs:
|
|||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
|
||||||
- [Laravel](./example/laravel.yml)
|
Examples for setting up this GitHub Action with different PHP Frameworks/Packages.
|
||||||
|
|
||||||
|
|Framework/Package|Workflow|
|
||||||
|
|--- |--- |
|
||||||
|
|CodeIgniter|[codeigniter.yml](./examples/codeigniter.yml)|
|
||||||
|
|Laravel `MySQL` `Redis`|[laravel-mysql.yml](./examples/laravel-mysql.yml)|
|
||||||
|
|Laravel `PostgreSQL` `Redis`|[laravel-postgres.yml](./examples/laravel-postgres.yml)|
|
||||||
|
|Laravel|[laravel.yml](./examples/laravel.yml)|
|
||||||
|
|Slim Framework|[slim-framework.yml](./examples/slim-framework.yml)|
|
||||||
|
|Symfony `MySQL`|[symfony-mysql.yml](./examples/symfony-mysql.yml)|
|
||||||
|
|Symfony `PostgreSQL`|[symfony-postgres.yml](./examples/symfony-postgres.yml)|
|
||||||
|
|Yii2 Starter Kit `MySQL`|[yii2-mysql.yml](./examples/yii2-mysql.yml)|
|
||||||
|
|Yii2 Starter Kit `PostgreSQL`|[yii2-postgres.yml](./examples/yii2-postgres.yml)|
|
||||||
|
|Zend Framework|[zend-framework.yml](./examples/zend-framework.yml)|
|
||||||
|
|
||||||
## :scroll: License
|
## :scroll: License
|
||||||
|
|
||||||
|
57
__tests__/config.test.ts
Normal file
57
__tests__/config.test.ts
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
import * as config from '../src/config';
|
||||||
|
|
||||||
|
describe('Config tests', () => {
|
||||||
|
it('checking addINIValuesOnWindows', async () => {
|
||||||
|
let win32: string = await config.addINIValues(
|
||||||
|
'post_max_size=256M, short_open_tag=On, date.timezone=Asia/Kolkata',
|
||||||
|
'win32'
|
||||||
|
);
|
||||||
|
expect(win32).toContain(
|
||||||
|
'Add-Content C:\\tools\\php\\php.ini "post_max_size=256M"'
|
||||||
|
);
|
||||||
|
expect(win32).toContain(
|
||||||
|
'Add-Content C:\\tools\\php\\php.ini "short_open_tag=On"'
|
||||||
|
);
|
||||||
|
expect(win32).toContain(
|
||||||
|
'Add-Content C:\\tools\\php\\php.ini "date.timezone=Asia/Kolkata"'
|
||||||
|
);
|
||||||
|
|
||||||
|
win32 = await config.addINIValues(
|
||||||
|
'post_max_size=256M, short_open_tag=On, date.timezone=Asia/Kolkata',
|
||||||
|
'fedora'
|
||||||
|
);
|
||||||
|
expect(win32).toContain('Platform fedora is not supported');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('checking addINIValuesOnLinux', async () => {
|
||||||
|
let linux: string = await config.addINIValues(
|
||||||
|
'post_max_size=256M, short_open_tag=On, date.timezone=Asia/Kolkata',
|
||||||
|
'linux'
|
||||||
|
);
|
||||||
|
expect(linux).toContain('echo "post_max_size=256M" >> $ini_file');
|
||||||
|
expect(linux).toContain('echo "short_open_tag=On" >> $ini_file');
|
||||||
|
expect(linux).toContain('echo "date.timezone=Asia/Kolkata" >> $ini_file');
|
||||||
|
|
||||||
|
linux = await config.addINIValues(
|
||||||
|
'post_max_size=256M, short_open_tag=On, date.timezone=Asia/Kolkata',
|
||||||
|
'fedora'
|
||||||
|
);
|
||||||
|
expect(linux).toContain('Platform fedora is not supported');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('checking addINIValuesOnDarwin', async () => {
|
||||||
|
let darwin: string = await config.addINIValues(
|
||||||
|
'post_max_size=256M, short_open_tag=On, date.timezone=Asia/Kolkata',
|
||||||
|
'darwin'
|
||||||
|
);
|
||||||
|
expect(darwin).toContain('echo "post_max_size=256M" >> $ini_file');
|
||||||
|
expect(darwin).toContain('echo "short_open_tag=On" >> $ini_file');
|
||||||
|
expect(darwin).toContain('echo "date.timezone=Asia/Kolkata" >> $ini_file');
|
||||||
|
|
||||||
|
darwin = await config.addINIValues(
|
||||||
|
'post_max_size=256M, short_open_tag=On, date.timezone=Asia/Kolkata',
|
||||||
|
'fedora'
|
||||||
|
);
|
||||||
|
expect(darwin).toContain('Platform fedora is not supported');
|
||||||
|
});
|
||||||
|
});
|
80
__tests__/coverage.test.ts
Normal file
80
__tests__/coverage.test.ts
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
import * as config from '../src/config';
|
||||||
|
import * as coverage from '../src/coverage';
|
||||||
|
import * as extensions from '../src/coverage';
|
||||||
|
|
||||||
|
jest.mock('../src/extensions', () => ({
|
||||||
|
addExtension: jest.fn().mockImplementation(extension => {
|
||||||
|
return 'addExtension ' + extension + '\n';
|
||||||
|
})
|
||||||
|
}));
|
||||||
|
|
||||||
|
describe('Config tests', () => {
|
||||||
|
it('checking addCoverage with PCOV on windows', async () => {
|
||||||
|
let win32: string = await coverage.addCoverage('pcov', '7.4', 'win32');
|
||||||
|
expect(win32).toContain('addExtension pcov');
|
||||||
|
expect(win32).toContain(
|
||||||
|
'if(php -m | findstr -i xdebug) { Disable-PhpExtension xdebug C:\\tools\\php'
|
||||||
|
);
|
||||||
|
|
||||||
|
win32 = await coverage.addCoverage('pcov', '7.0', 'win32');
|
||||||
|
expect(win32).toContain('PCOV requires PHP 7.1 or newer');
|
||||||
|
|
||||||
|
win32 = await coverage.addCoverage('pcov', '5.6', 'win32');
|
||||||
|
expect(win32).toContain('PCOV requires PHP 7.1 or newer');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('checking addCoverage with PCOV on linux', async () => {
|
||||||
|
let linux: string = await coverage.addCoverage('pcov', '7.4', 'linux');
|
||||||
|
expect(linux).toContain('addExtension pcov');
|
||||||
|
expect(linux).toContain('sudo sed -i "/xdebug/d" $ini_file');
|
||||||
|
expect(linux).toContain('sudo phpdismod xdebug');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('checking addCoverage with PCOV on darwin', async () => {
|
||||||
|
let darwin: string = await coverage.addCoverage('pcov', '7.4', 'darwin');
|
||||||
|
expect(darwin).toContain('addExtension pcov');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('checking addCoverage with Xdebug on windows', async () => {
|
||||||
|
let win32: string = await coverage.addCoverage('xdebug', '7.3', 'win32');
|
||||||
|
expect(win32).toContain('addExtension xdebug');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('checking addCoverage with Xdebug on linux', async () => {
|
||||||
|
let linux: string = await coverage.addCoverage('xdebug', '7.4', 'linux');
|
||||||
|
expect(linux).toContain('addExtension xdebug');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('checking addCoverage with Xdebug on darwin', async () => {
|
||||||
|
let darwin: string = await coverage.addCoverage('xdebug', '7.4', 'darwin');
|
||||||
|
expect(darwin).toContain('addExtension xdebug');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('checking disableCoverage windows', async () => {
|
||||||
|
let win32 = await coverage.addCoverage('none', '7.4', 'win32');
|
||||||
|
expect(win32).toContain('Disable-PhpExtension xdebug');
|
||||||
|
expect(win32).toContain('Disable-PhpExtension pcov');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('checking disableCoverage on linux', async () => {
|
||||||
|
let linux: string = await coverage.addCoverage('none', '7.4', 'linux');
|
||||||
|
expect(linux).toContain('sudo phpdismod xdebug');
|
||||||
|
expect(linux).toContain('sudo phpdismod pcov');
|
||||||
|
expect(linux).toContain('sudo sed -i "/xdebug/d" $ini_file');
|
||||||
|
expect(linux).toContain('sudo sed -i "/pcov/d" $ini_file');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('checking disableCoverage on darwin', async () => {
|
||||||
|
let darwin: string = await coverage.addCoverage('none', '7.4', 'darwin');
|
||||||
|
expect(darwin).toContain('sudo sed -i \'\' "/xdebug/d" $ini_file');
|
||||||
|
expect(darwin).toContain('sudo sed -i \'\' "/pcov/d" $ini_file');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('checking no or invalid coverage driver', async () => {
|
||||||
|
let nocov: string = await coverage.addCoverage('nocov', '7.x', 'any');
|
||||||
|
expect(nocov).toEqual('');
|
||||||
|
|
||||||
|
nocov = await coverage.addCoverage('', '7.x', 'any');
|
||||||
|
expect(nocov).toEqual('');
|
||||||
|
});
|
||||||
|
});
|
92
__tests__/extensions.test.ts
Normal file
92
__tests__/extensions.test.ts
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
import * as extensions from '../src/extensions';
|
||||||
|
|
||||||
|
let valid_extensions = ['xdebug', 'pcov'];
|
||||||
|
jest.mock('../src/pecl', () => ({
|
||||||
|
checkPECLExtension: jest.fn().mockImplementation(extension => {
|
||||||
|
return valid_extensions.indexOf(extension) !== -1;
|
||||||
|
})
|
||||||
|
}));
|
||||||
|
|
||||||
|
describe('Extension tests', () => {
|
||||||
|
it('checking addExtensionOnWindows', async () => {
|
||||||
|
let win32: string = await extensions.addExtension(
|
||||||
|
'xdebug, pcov',
|
||||||
|
'7.2',
|
||||||
|
'win32'
|
||||||
|
);
|
||||||
|
expect(win32).toContain('Install-PhpExtension xdebug');
|
||||||
|
expect(win32).toContain('Install-PhpExtension pcov');
|
||||||
|
win32 = await extensions.addExtension('xdebug, pcov', '7.4', 'win32');
|
||||||
|
const extension_url: string =
|
||||||
|
'https://xdebug.org/files/php_xdebug-2.8.0beta2-7.4-vc15.dll';
|
||||||
|
expect(win32).toContain(
|
||||||
|
'Invoke-WebRequest -Uri ' +
|
||||||
|
extension_url +
|
||||||
|
' -OutFile C:\\tools\\php\\ext\\php_xdebug.dll'
|
||||||
|
);
|
||||||
|
expect(win32).toContain('Install-PhpExtension pcov');
|
||||||
|
|
||||||
|
win32 = await extensions.addExtension('does_not_exist', '7.2', 'win32');
|
||||||
|
expect(win32).toContain('Could not find does_not_exist for PHP7.2 on PECL');
|
||||||
|
|
||||||
|
win32 = await extensions.addExtension('xdebug', '7.2', 'fedora');
|
||||||
|
expect(win32).toContain('Platform fedora is not supported');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('checking addExtensionOnLinux', async () => {
|
||||||
|
let linux: string = await extensions.addExtension(
|
||||||
|
'xdebug, pcov',
|
||||||
|
'7.2',
|
||||||
|
'linux'
|
||||||
|
);
|
||||||
|
expect(linux).toContain(
|
||||||
|
'sudo DEBIAN_FRONTEND=noninteractive apt install -y php7.2-xdebug'
|
||||||
|
);
|
||||||
|
expect(linux).toContain(
|
||||||
|
'sudo DEBIAN_FRONTEND=noninteractive apt install -y php7.2-pcov'
|
||||||
|
);
|
||||||
|
|
||||||
|
linux = await extensions.addExtension('xdebug, pcov', '7.4', 'linux');
|
||||||
|
expect(linux).toContain('./xdebug.sh');
|
||||||
|
expect(linux).toContain('./pcov.sh');
|
||||||
|
|
||||||
|
linux = await extensions.addExtension('xdebug', '7.2', 'fedora');
|
||||||
|
expect(linux).toContain('Platform fedora is not supported');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('checking addExtensionOnDarwin', async () => {
|
||||||
|
let darwin: string = await extensions.addExtension(
|
||||||
|
'xdebug, pcov',
|
||||||
|
'7.2',
|
||||||
|
'darwin'
|
||||||
|
);
|
||||||
|
expect(darwin).toContain('sudo pecl install xdebug');
|
||||||
|
expect(darwin).toContain('sudo pecl install pcov');
|
||||||
|
|
||||||
|
darwin = await extensions.addExtension('pcov', '5.6', 'darwin');
|
||||||
|
expect(darwin).toContain('sudo pecl install pcov');
|
||||||
|
|
||||||
|
darwin = await extensions.addExtension('pcov', '7.2', 'darwin');
|
||||||
|
expect(darwin).toContain('sudo pecl install pcov');
|
||||||
|
|
||||||
|
darwin = await extensions.addExtension('xdebug', '5.6', 'darwin');
|
||||||
|
expect(darwin).toContain('sudo pecl install xdebug-2.5.5');
|
||||||
|
|
||||||
|
darwin = await extensions.addExtension('xdebug', '7.4', 'darwin');
|
||||||
|
expect(darwin).toContain('sh ./xdebug_darwin.sh');
|
||||||
|
|
||||||
|
darwin = await extensions.addExtension('pcov', '7.4', 'darwin');
|
||||||
|
expect(darwin).toContain('sh ./pcov.sh');
|
||||||
|
|
||||||
|
darwin = await extensions.addExtension('xdebug', '7.2', 'darwin');
|
||||||
|
expect(darwin).toContain('sudo pecl install xdebug');
|
||||||
|
|
||||||
|
darwin = await extensions.addExtension('does_not_exist', '7.2', 'darwin');
|
||||||
|
expect(darwin).toContain(
|
||||||
|
'Could not find does_not_exist for PHP7.2 on PECL'
|
||||||
|
);
|
||||||
|
|
||||||
|
darwin = await extensions.addExtension('xdebug', '7.2', 'fedora');
|
||||||
|
expect(darwin).toContain('Platform fedora is not supported');
|
||||||
|
});
|
||||||
|
});
|
@ -1,211 +0,0 @@
|
|||||||
import * as features from '../src/features';
|
|
||||||
|
|
||||||
let valid_extensions = ['xdebug', 'pcov'];
|
|
||||||
jest.mock('../src/pecl', () => ({
|
|
||||||
checkPECLExtension: jest.fn().mockImplementation(extension => {
|
|
||||||
return valid_extensions.indexOf(extension) !== -1;
|
|
||||||
})
|
|
||||||
}));
|
|
||||||
|
|
||||||
describe('Features tests', () => {
|
|
||||||
it('checking addExtensionOnWindows', async () => {
|
|
||||||
let win32: string = await features.addExtension(
|
|
||||||
'xdebug, pcov',
|
|
||||||
'7.2',
|
|
||||||
'win32'
|
|
||||||
);
|
|
||||||
expect(win32).toContain('Install-PhpExtension xdebug');
|
|
||||||
expect(win32).toContain('Install-PhpExtension pcov');
|
|
||||||
win32 = await features.addExtension('xdebug, pcov', '7.4', 'win32');
|
|
||||||
const extension_url: string =
|
|
||||||
'https://xdebug.org/files/php_xdebug-2.8.0beta2-7.4-vc15.dll';
|
|
||||||
expect(win32).toContain(
|
|
||||||
'Invoke-WebRequest -Uri ' +
|
|
||||||
extension_url +
|
|
||||||
' -OutFile C:\\tools\\php\\ext\\php_xdebug.dll'
|
|
||||||
);
|
|
||||||
expect(win32).toContain('Install-PhpExtension pcov');
|
|
||||||
|
|
||||||
win32 = await features.addExtension('does_not_exist', '7.2', 'win32');
|
|
||||||
expect(win32).toContain('Could not find does_not_exist for PHP7.2 on PECL');
|
|
||||||
|
|
||||||
win32 = await features.addExtension('xdebug', '7.2', 'fedora');
|
|
||||||
expect(win32).toContain('Platform fedora is not supported');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('checking addExtensionOnLinux', async () => {
|
|
||||||
let linux: string = await features.addExtension(
|
|
||||||
'xdebug, pcov',
|
|
||||||
'7.2',
|
|
||||||
'linux'
|
|
||||||
);
|
|
||||||
expect(linux).toContain(
|
|
||||||
'sudo DEBIAN_FRONTEND=noninteractive apt install -y php7.2-xdebug'
|
|
||||||
);
|
|
||||||
expect(linux).toContain(
|
|
||||||
'sudo DEBIAN_FRONTEND=noninteractive apt install -y php7.2-pcov'
|
|
||||||
);
|
|
||||||
|
|
||||||
linux = await features.addExtension('xdebug, pcov', '7.4', 'linux');
|
|
||||||
expect(linux).toContain('./xdebug.sh');
|
|
||||||
expect(linux).toContain('./pcov.sh');
|
|
||||||
|
|
||||||
linux = await features.addExtension('xdebug', '7.2', 'fedora');
|
|
||||||
expect(linux).toContain('Platform fedora is not supported');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('checking addExtensionOnDarwin', async () => {
|
|
||||||
let darwin: string = await features.addExtension(
|
|
||||||
'xdebug, pcov',
|
|
||||||
'7.2',
|
|
||||||
'darwin'
|
|
||||||
);
|
|
||||||
expect(darwin).toContain('sudo pecl install xdebug');
|
|
||||||
expect(darwin).toContain('sudo pecl install pcov');
|
|
||||||
|
|
||||||
darwin = await features.addExtension('pcov', '5.6', 'darwin');
|
|
||||||
expect(darwin).toContain('sudo pecl install pcov');
|
|
||||||
|
|
||||||
darwin = await features.addExtension('pcov', '7.2', 'darwin');
|
|
||||||
expect(darwin).toContain('sudo pecl install pcov');
|
|
||||||
|
|
||||||
darwin = await features.addExtension('xdebug', '5.6', 'darwin');
|
|
||||||
expect(darwin).toContain('sudo pecl install xdebug-2.5.5');
|
|
||||||
|
|
||||||
darwin = await features.addExtension('xdebug', '7.4', 'darwin');
|
|
||||||
expect(darwin).toContain('sh ./xdebug_darwin.sh');
|
|
||||||
|
|
||||||
darwin = await features.addExtension('pcov', '7.4', 'darwin');
|
|
||||||
expect(darwin).toContain('sh ./pcov.sh');
|
|
||||||
|
|
||||||
darwin = await features.addExtension('xdebug', '7.2', 'darwin');
|
|
||||||
expect(darwin).toContain('sudo pecl install xdebug');
|
|
||||||
|
|
||||||
darwin = await features.addExtension('does_not_exist', '7.2', 'darwin');
|
|
||||||
expect(darwin).toContain(
|
|
||||||
'Could not find does_not_exist for PHP7.2 on PECL'
|
|
||||||
);
|
|
||||||
|
|
||||||
darwin = await features.addExtension('xdebug', '7.2', 'fedora');
|
|
||||||
expect(darwin).toContain('Platform fedora is not supported');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('checking addINIValuesOnWindows', async () => {
|
|
||||||
let win32: string = await features.addINIValues(
|
|
||||||
'post_max_size=256M, short_open_tag=On, date.timezone=Asia/Kolkata',
|
|
||||||
'win32'
|
|
||||||
);
|
|
||||||
expect(win32).toContain(
|
|
||||||
'Add-Content C:\\tools\\php\\php.ini "post_max_size=256M"'
|
|
||||||
);
|
|
||||||
expect(win32).toContain(
|
|
||||||
'Add-Content C:\\tools\\php\\php.ini "short_open_tag=On"'
|
|
||||||
);
|
|
||||||
expect(win32).toContain(
|
|
||||||
'Add-Content C:\\tools\\php\\php.ini "date.timezone=Asia/Kolkata"'
|
|
||||||
);
|
|
||||||
|
|
||||||
win32 = await features.addINIValues(
|
|
||||||
'post_max_size=256M, short_open_tag=On, date.timezone=Asia/Kolkata',
|
|
||||||
'fedora'
|
|
||||||
);
|
|
||||||
expect(win32).toContain('Platform fedora is not supported');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('checking addINIValuesOnLinux', async () => {
|
|
||||||
let linux: string = await features.addINIValues(
|
|
||||||
'post_max_size=256M, short_open_tag=On, date.timezone=Asia/Kolkata',
|
|
||||||
'linux'
|
|
||||||
);
|
|
||||||
expect(linux).toContain('echo "post_max_size=256M" >> $ini_file');
|
|
||||||
expect(linux).toContain('echo "short_open_tag=On" >> $ini_file');
|
|
||||||
expect(linux).toContain('echo "date.timezone=Asia/Kolkata" >> $ini_file');
|
|
||||||
|
|
||||||
linux = await features.addINIValues(
|
|
||||||
'post_max_size=256M, short_open_tag=On, date.timezone=Asia/Kolkata',
|
|
||||||
'fedora'
|
|
||||||
);
|
|
||||||
expect(linux).toContain('Platform fedora is not supported');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('checking addINIValuesOnDarwin', async () => {
|
|
||||||
let darwin: string = await features.addINIValues(
|
|
||||||
'post_max_size=256M, short_open_tag=On, date.timezone=Asia/Kolkata',
|
|
||||||
'darwin'
|
|
||||||
);
|
|
||||||
expect(darwin).toContain('echo "post_max_size=256M" >> $ini_file');
|
|
||||||
expect(darwin).toContain('echo "short_open_tag=On" >> $ini_file');
|
|
||||||
expect(darwin).toContain('echo "date.timezone=Asia/Kolkata" >> $ini_file');
|
|
||||||
|
|
||||||
darwin = await features.addINIValues(
|
|
||||||
'post_max_size=256M, short_open_tag=On, date.timezone=Asia/Kolkata',
|
|
||||||
'fedora'
|
|
||||||
);
|
|
||||||
expect(darwin).toContain('Platform fedora is not supported');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('checking addCoverage on windows', async () => {
|
|
||||||
let win32: string = await features.addCoverage('xdebug', '7.4', 'win32');
|
|
||||||
const extension_url: string =
|
|
||||||
'https://xdebug.org/files/php_xdebug-2.8.0beta2-7.4-vc15.dll';
|
|
||||||
expect(win32).toContain(
|
|
||||||
'Invoke-WebRequest -Uri ' +
|
|
||||||
extension_url +
|
|
||||||
' -OutFile C:\\tools\\php\\ext\\php_xdebug.dll'
|
|
||||||
);
|
|
||||||
|
|
||||||
win32 = await features.addCoverage('xdebug', '7.3', 'win32');
|
|
||||||
expect(win32).toContain('Install-PhpExtension xdebug');
|
|
||||||
|
|
||||||
win32 = await features.addCoverage('pcov', '7.4', 'win32');
|
|
||||||
expect(win32).toContain('Install-PhpExtension pcov');
|
|
||||||
expect(win32).toContain(
|
|
||||||
'if(php -m | findstr -i xdebug) { Disable-PhpExtension xdebug C:\\tools\\php'
|
|
||||||
);
|
|
||||||
|
|
||||||
win32 = await features.addCoverage('pcov', '7.3', 'win32');
|
|
||||||
expect(win32).toContain('Install-PhpExtension pcov');
|
|
||||||
expect(win32).toContain(
|
|
||||||
'if(php -m | findstr -i xdebug) { Disable-PhpExtension xdebug C:\\tools\\php'
|
|
||||||
);
|
|
||||||
|
|
||||||
win32 = await features.addCoverage('nocov', '7.3', 'win32');
|
|
||||||
expect(win32).toContain('');
|
|
||||||
|
|
||||||
win32 = await features.addCoverage('pcov', '7.0', 'win32');
|
|
||||||
expect(win32).toContain('pcov requires php 7.1 or newer');
|
|
||||||
|
|
||||||
win32 = await features.addCoverage('pcov', '5.6', 'win32');
|
|
||||||
expect(win32).toContain('pcov requires php 7.1 or newer');
|
|
||||||
|
|
||||||
win32 = await features.addCoverage('', '7.4', 'win32');
|
|
||||||
expect(win32).toEqual('');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('checking addCoverage on linux', async () => {
|
|
||||||
let linux: string = await features.addCoverage('xdebug', '7.4', 'linux');
|
|
||||||
expect(linux).toContain('./xdebug.sh');
|
|
||||||
|
|
||||||
linux = await features.addCoverage('pcov', '7.4', 'linux');
|
|
||||||
expect(linux).toContain('./pcov.sh');
|
|
||||||
expect(linux).toContain('sudo sed -i "/xdebug/d" $ini_file');
|
|
||||||
|
|
||||||
linux = await features.addCoverage('', '7.4', 'linux');
|
|
||||||
expect(linux).toEqual('');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('checking addCoverage on darwin', async () => {
|
|
||||||
let darwin: string = await features.addCoverage('xdebug', '7.4', 'darwin');
|
|
||||||
expect(darwin).toContain('sh ./xdebug_darwin.sh');
|
|
||||||
|
|
||||||
darwin = await features.addCoverage('xdebug', '5.6', 'darwin');
|
|
||||||
expect(darwin).toContain('sudo pecl install xdebug-2.5.5');
|
|
||||||
|
|
||||||
darwin = await features.addCoverage('pcov', '7.4', 'darwin');
|
|
||||||
expect(darwin).toContain('sh ./pcov.sh');
|
|
||||||
expect(darwin).toContain('sudo sed -i \'\' "/xdebug/d" $ini_file\n');
|
|
||||||
|
|
||||||
darwin = await features.addCoverage('', '7.4', 'win32');
|
|
||||||
expect(darwin).toEqual('');
|
|
||||||
});
|
|
||||||
});
|
|
@ -56,6 +56,7 @@ describe('Utils tests', () => {
|
|||||||
expect(await utils.readScript('darwin.sh', '7.3', 'darwin')).toBe(darwin);
|
expect(await utils.readScript('darwin.sh', '7.3', 'darwin')).toBe(darwin);
|
||||||
expect(await utils.readScript('linux.sh', '7.4', 'linux')).toBe(linux);
|
expect(await utils.readScript('linux.sh', '7.4', 'linux')).toBe(linux);
|
||||||
expect(await utils.readScript('linux.sh', '7.3', 'linux')).toBe(linux);
|
expect(await utils.readScript('linux.sh', '7.3', 'linux')).toBe(linux);
|
||||||
|
expect(await utils.readScript('win32.ps1', '7.4', 'win32')).toBe(win32);
|
||||||
expect(await utils.readScript('win32.ps1', '7.3', 'win32')).toBe(win32);
|
expect(await utils.readScript('win32.ps1', '7.3', 'win32')).toBe(win32);
|
||||||
expect(await utils.readScript('fedora.sh', '7.3', 'fedora')).toContain(
|
expect(await utils.readScript('fedora.sh', '7.3', 'fedora')).toContain(
|
||||||
'Platform fedora is not supported'
|
'Platform fedora is not supported'
|
||||||
@ -81,6 +82,7 @@ describe('Utils tests', () => {
|
|||||||
'c',
|
'c',
|
||||||
'd'
|
'd'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
expect(await utils.extensionArray('')).toEqual([]);
|
expect(await utils.extensionArray('')).toEqual([]);
|
||||||
expect(await utils.extensionArray(' ')).toEqual([]);
|
expect(await utils.extensionArray(' ')).toEqual([]);
|
||||||
});
|
});
|
||||||
@ -99,31 +101,53 @@ describe('Utils tests', () => {
|
|||||||
let message: string = 'Test message';
|
let message: string = 'Test message';
|
||||||
|
|
||||||
let warning_log: string = await utils.log(message, 'win32', 'warning');
|
let warning_log: string = await utils.log(message, 'win32', 'warning');
|
||||||
// expect(warning_log).toEqual(
|
expect(warning_log).toEqual(
|
||||||
// "Write-Host '" + message + "' -ForegroundColor yellow"
|
"Write-Host '" + message + "' -ForegroundColor yellow"
|
||||||
// );
|
);
|
||||||
warning_log = await utils.log(message, 'linux', 'warning');
|
warning_log = await utils.log(message, 'linux', 'warning');
|
||||||
expect(warning_log).toEqual('echo "\\033[33;1m' + message + '\\033[0m"');
|
expect(warning_log).toEqual('echo "\\033[33;1m' + message + '\\033[0m"');
|
||||||
warning_log = await utils.log(message, 'darwin', 'warning');
|
warning_log = await utils.log(message, 'darwin', 'warning');
|
||||||
expect(warning_log).toEqual('echo "\\033[33;1m' + message + '\\033[0m"');
|
expect(warning_log).toEqual('echo "\\033[33;1m' + message + '\\033[0m"');
|
||||||
|
|
||||||
let error_log: string = await utils.log(message, 'win32', 'error');
|
let error_log: string = await utils.log(message, 'win32', 'error');
|
||||||
// expect(error_log).toEqual(
|
expect(error_log).toEqual(
|
||||||
// "Write-Host '" + message + "' -ForegroundColor red"
|
"Write-Host '" + message + "' -ForegroundColor red"
|
||||||
// );
|
);
|
||||||
error_log = await utils.log(message, 'linux', 'error');
|
error_log = await utils.log(message, 'linux', 'error');
|
||||||
expect(error_log).toEqual('echo "\\033[31;1m' + message + '\\033[0m"');
|
expect(error_log).toEqual('echo "\\033[31;1m' + message + '\\033[0m"');
|
||||||
error_log = await utils.log(message, 'darwin', 'error');
|
error_log = await utils.log(message, 'darwin', 'error');
|
||||||
expect(error_log).toEqual('echo "\\033[31;1m' + message + '\\033[0m"');
|
expect(error_log).toEqual('echo "\\033[31;1m' + message + '\\033[0m"');
|
||||||
|
|
||||||
let success_log: string = await utils.log(message, 'win32', 'success');
|
let success_log: string = await utils.log(message, 'win32', 'success');
|
||||||
// expect(success_log).toEqual(
|
expect(success_log).toEqual(
|
||||||
// "Write-Host '" + message + "' -ForegroundColor green"
|
"Write-Host '" + message + "' -ForegroundColor green"
|
||||||
// );
|
);
|
||||||
success_log = await utils.log(message, 'linux', 'success');
|
success_log = await utils.log(message, 'linux', 'success');
|
||||||
expect(success_log).toEqual('echo "\\033[32;1m' + message + '\\033[0m"');
|
expect(success_log).toEqual('echo "\\033[32;1m' + message + '\\033[0m"');
|
||||||
success_log = await utils.log(message, 'darwin', 'success');
|
success_log = await utils.log(message, 'darwin', 'success');
|
||||||
expect(success_log).toEqual('echo "\\033[32;1m' + message + '\\033[0m"');
|
expect(success_log).toEqual('echo "\\033[32;1m' + message + '\\033[0m"');
|
||||||
|
|
||||||
|
success_log = await utils.log(message, 'win32', 'success', 'Test win');
|
||||||
|
expect(success_log).toEqual(
|
||||||
|
"Write-Host 'Test win: " + message + "' -ForegroundColor green"
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('checking log with prefix', async () => {
|
||||||
|
let message: string = 'Test message';
|
||||||
|
let prefix_log: string = await utils.log(
|
||||||
|
message,
|
||||||
|
'linux',
|
||||||
|
'success',
|
||||||
|
'Test Prefix'
|
||||||
|
);
|
||||||
|
expect(prefix_log).toEqual(
|
||||||
|
'echo "\\033[32;1mTest Prefix: ' + message + '\\033[0m"'
|
||||||
|
);
|
||||||
|
prefix_log = await utils.log(message, 'darwin', 'success', 'Test');
|
||||||
|
expect(prefix_log).toEqual(
|
||||||
|
'echo "\\033[32;1mTest: ' + message + '\\033[0m"'
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('checking getExtensionPrefix', async () => {
|
it('checking getExtensionPrefix', async () => {
|
||||||
|
@ -15,7 +15,7 @@ inputs:
|
|||||||
description: '(Optional) Custom values you want to set in php.ini'
|
description: '(Optional) Custom values you want to set in php.ini'
|
||||||
required: false
|
required: false
|
||||||
coverage:
|
coverage:
|
||||||
description: '(Optional) Driver to calculate code coverage (Accepts: xdebug and pcov)'
|
description: '(Optional) Driver to calculate code coverage (Accepts: xdebug, pcov and none)'
|
||||||
required: false
|
required: false
|
||||||
runs:
|
runs:
|
||||||
using: 'node12'
|
using: 'node12'
|
||||||
|
27
examples/codeigniter.yml
Normal file
27
examples/codeigniter.yml
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
name: Testing CodeIgniter
|
||||||
|
on: [push, pull_request]
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
strategy:
|
||||||
|
max-parallel: 6
|
||||||
|
matrix:
|
||||||
|
operating-system: [ubuntu-latest, windows-latest, macOS-latest]
|
||||||
|
php-versions: ['7.2', '7.3']
|
||||||
|
runs-on: ${{ matrix.operating-system }}
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@master
|
||||||
|
- name: Setup PHP, with composer and extensions
|
||||||
|
uses: shivammathur/setup-php@master #https://github.com/shivammathur/setup-php
|
||||||
|
with:
|
||||||
|
php-version: ${{ matrix.php-versions }}
|
||||||
|
extension-csv: mbstring, intl, curl, dom
|
||||||
|
coverage: xdebug #optional
|
||||||
|
- name: Install dependencies
|
||||||
|
run: composer install --no-progress --no-suggest --prefer-dist --optimize-autoloader
|
||||||
|
- name: Test with phpunit in windows
|
||||||
|
if: matrix.operating-system == 'windows-latest'
|
||||||
|
run: .\vendor\bin\phpunit --coverage-text
|
||||||
|
- name: Test with phpunit
|
||||||
|
if: matrix.operating-system != 'windows-latest'
|
||||||
|
run: vendor/bin/phpunit --coverage-text
|
@ -1,11 +1,8 @@
|
|||||||
name: Laravel
|
name: Testing Laravel with MySQL
|
||||||
|
|
||||||
on: [push, pull_request]
|
on: [push, pull_request]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
laravel:
|
||||||
phpunit:
|
name: Laravel (PHP ${{ matrix.php-versions }})
|
||||||
name: PHPUnit (PHP ${{ matrix.php-versions }} on ${{ matrix.operating-system }})
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
env:
|
env:
|
||||||
DB_PASSWORD: password
|
DB_PASSWORD: password
|
||||||
@ -30,29 +27,31 @@ jobs:
|
|||||||
options: --health-cmd="redis-cli ping" --health-interval=10s --health-timeout=5s --health-retries=3
|
options: --health-cmd="redis-cli ping" --health-interval=10s --health-timeout=5s --health-retries=3
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
max-parallel: 15
|
max-parallel: 3
|
||||||
matrix:
|
matrix:
|
||||||
operating-system: [ubuntu-latest, windows-latest, macOS-latest]
|
php-versions: ['7.2', '7.3', '7.4']
|
||||||
php-versions: ['7.2', '7.3']
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v1
|
uses: actions/checkout@v1
|
||||||
- name: Install PHP
|
- name: Setup PHP, with composer and extensions
|
||||||
uses: shivammathur/setup-php@master #https://github.com/shivammathur/setup-php
|
uses: shivammathur/setup-php@master #https://github.com/shivammathur/setup-php
|
||||||
with:
|
with:
|
||||||
php-version: ${{ matrix.php-versions }}
|
php-version: ${{ matrix.php-versions }}
|
||||||
extension-csv: mbstring, xdebug #optional
|
extension-csv: mbstring, dom, fileinfo, mysql
|
||||||
ini-values-csv: "post_max_size=256M, short_open_tag=On" #optional
|
coverage: xdebug #optional
|
||||||
coverage: xdebug #optional
|
|
||||||
- name: Install Composer dependencies
|
- name: Install Composer dependencies
|
||||||
run: composer install --no-progress --no-suggest --prefer-dist --optimize-autoloader
|
run: composer install --no-progress --no-suggest --prefer-dist --optimize-autoloader
|
||||||
- name: Prepare the application
|
- name: Prepare the application
|
||||||
run: |
|
run: |
|
||||||
cp .env.example .env
|
php -r "file_exists('.env') || copy('.env.example', '.env');"
|
||||||
php artisan key:generate
|
php artisan key:generate
|
||||||
- name: Clear Config
|
- name: Clear Config
|
||||||
run: php artisan config:clear
|
run: php artisan config:clear
|
||||||
- name: Run Migration
|
- name: Run Migration
|
||||||
run: php artisan migrate -v
|
run: php artisan migrate -v
|
||||||
|
env:
|
||||||
|
DB_PORT: ${{ job.services.mysql.ports['3306'] }}
|
||||||
|
- name: Test with phpunit
|
||||||
|
run: vendor/bin/phpunit --coverage-text
|
||||||
env:
|
env:
|
||||||
DB_PORT: ${{ job.services.mysql.ports['3306'] }}
|
DB_PORT: ${{ job.services.mysql.ports['3306'] }}
|
61
examples/laravel-postgres.yml
Normal file
61
examples/laravel-postgres.yml
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
name: Testing Laravel with PostgreSQL
|
||||||
|
on: [push, pull_request]
|
||||||
|
jobs:
|
||||||
|
laravel:
|
||||||
|
name: Laravel (PHP ${{ matrix.php-versions }})
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
env:
|
||||||
|
BROADCAST_DRIVER: log
|
||||||
|
CACHE_DRIVER: redis
|
||||||
|
QUEUE_CONNECTION: redis
|
||||||
|
SESSION_DRIVER: redis
|
||||||
|
DB_CONNECTION: pgsql
|
||||||
|
DB_HOST: localhost
|
||||||
|
DB_PASSWORD: postgres
|
||||||
|
DB_USERNAME: postgres
|
||||||
|
DB_DATABASE: postgres
|
||||||
|
services:
|
||||||
|
postgres:
|
||||||
|
image: postgres:10.8
|
||||||
|
env:
|
||||||
|
POSTGRES_USER: postgres
|
||||||
|
POSTGRES_PASSWORD: postgres
|
||||||
|
POSTGRES_DB: postgres
|
||||||
|
ports:
|
||||||
|
- 5432/tcp
|
||||||
|
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 3
|
||||||
|
redis:
|
||||||
|
image: redis
|
||||||
|
ports:
|
||||||
|
- 6379/tcp
|
||||||
|
options: --health-cmd="redis-cli ping" --health-interval=10s --health-timeout=5s --health-retries=3
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
max-parallel: 3
|
||||||
|
matrix:
|
||||||
|
php-versions: ['7.2', '7.3', '7.4']
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v1
|
||||||
|
- name: Setup PHP, with composer and extensions
|
||||||
|
uses: shivammathur/setup-php@master #https://github.com/shivammathur/setup-php
|
||||||
|
with:
|
||||||
|
php-version: ${{ matrix.php-versions }}
|
||||||
|
extension-csv: mbstring, dom, fileinfo, pgsql
|
||||||
|
coverage: xdebug #optional
|
||||||
|
- name: Install Composer dependencies
|
||||||
|
run: composer install --no-progress --no-suggest --prefer-dist --optimize-autoloader
|
||||||
|
- name: Prepare the application
|
||||||
|
run: |
|
||||||
|
php -r "file_exists('.env') || copy('.env.example', '.env');"
|
||||||
|
php artisan key:generate
|
||||||
|
- name: Clear Config
|
||||||
|
run: php artisan config:clear
|
||||||
|
- name: Run Migration
|
||||||
|
run: php artisan migrate -v
|
||||||
|
env:
|
||||||
|
DB_PORT: ${{ job.services.postgres.ports[5432] }}
|
||||||
|
- name: Test with phpunit
|
||||||
|
run: vendor/bin/phpunit --coverage-text
|
||||||
|
env:
|
||||||
|
DB_PORT: ${{ job.services.postgres.ports[5432] }}
|
35
examples/laravel.yml
Normal file
35
examples/laravel.yml
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
name: Unit Testing Laravel
|
||||||
|
on: [push, pull_request]
|
||||||
|
jobs:
|
||||||
|
laravel:
|
||||||
|
name: Laravel (PHP ${{ matrix.php-versions }} on ${{ matrix.operating-system }})
|
||||||
|
runs-on: ${{ matrix.operating-system }}
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
max-parallel: 6
|
||||||
|
matrix:
|
||||||
|
operating-system: [ubuntu-latest, windows-latest, macOS-latest]
|
||||||
|
php-versions: ['7.2', '7.3']
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v1
|
||||||
|
- name: Setup PHP, with composer and extensions
|
||||||
|
uses: shivammathur/setup-php@master #https://github.com/shivammathur/setup-php
|
||||||
|
with:
|
||||||
|
php-version: ${{ matrix.php-versions }}
|
||||||
|
extension-csv: mbstring, dom, fileinfo
|
||||||
|
coverage: xdebug #optional
|
||||||
|
- name: Install Composer dependencies
|
||||||
|
run: composer install --no-progress --no-suggest --prefer-dist --optimize-autoloader
|
||||||
|
- name: Prepare the application
|
||||||
|
run: |
|
||||||
|
php -r "file_exists('.env') || copy('.env.example', '.env');"
|
||||||
|
php artisan key:generate
|
||||||
|
- name: Clear Config
|
||||||
|
run: php artisan config:clear
|
||||||
|
- name: Test with phpunit in windows
|
||||||
|
if: matrix.operating-system == 'windows-latest'
|
||||||
|
run: .\vendor\bin\phpunit --coverage-text
|
||||||
|
- name: Test with phpunit
|
||||||
|
if: matrix.operating-system != 'windows-latest'
|
||||||
|
run: vendor/bin/phpunit --coverage-text
|
27
examples/slim-framework.yml
Normal file
27
examples/slim-framework.yml
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
name: Testing Slim Framework
|
||||||
|
on: [push, pull_request]
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
strategy:
|
||||||
|
max-parallel: 6
|
||||||
|
matrix:
|
||||||
|
operating-system: [ubuntu-latest, windows-latest, macOS-latest]
|
||||||
|
php-versions: ['7.2', '7.3']
|
||||||
|
runs-on: ${{ matrix.operating-system }}
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@master
|
||||||
|
- name: Setup PHP, with composer and extensions
|
||||||
|
uses: shivammathur/setup-php@master #https://github.com/shivammathur/setup-php
|
||||||
|
with:
|
||||||
|
php-version: ${{ matrix.php-versions }}
|
||||||
|
extension-csv: mbstring, simplexml, dom
|
||||||
|
coverage: xdebug #optional
|
||||||
|
- name: Install dependencies
|
||||||
|
run: composer install --no-progress --no-suggest --prefer-dist --optimize-autoloader
|
||||||
|
- name: Test with phpunit in windows
|
||||||
|
if: matrix.operating-system == 'windows-latest'
|
||||||
|
run: .\vendor\bin\phpunit --coverage-text
|
||||||
|
- name: Test with phpunit
|
||||||
|
if: matrix.operating-system != 'windows-latest'
|
||||||
|
run: vendor/bin/phpunit --coverage-text
|
44
examples/symfony-mysql.yml
Normal file
44
examples/symfony-mysql.yml
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
name: Testing Symfony with MySQL
|
||||||
|
on: [push, pull_request]
|
||||||
|
jobs:
|
||||||
|
laravel:
|
||||||
|
name: Symfony (PHP ${{ matrix.php-versions }})
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
services:
|
||||||
|
mysql:
|
||||||
|
image: mysql:5.7
|
||||||
|
env:
|
||||||
|
MYSQL_ALLOW_EMPTY_PASSWORD: false
|
||||||
|
MYSQL_ROOT_PASSWORD: symfony
|
||||||
|
MYSQL_DATABASE: symfony
|
||||||
|
ports:
|
||||||
|
- 3306
|
||||||
|
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
max-parallel: 3
|
||||||
|
matrix:
|
||||||
|
php-versions: ['7.3']
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v1
|
||||||
|
- name: Setup PHP, with composer and extensions
|
||||||
|
uses: shivammathur/setup-php@master #https://github.com/shivammathur/setup-php
|
||||||
|
with:
|
||||||
|
php-version: ${{ matrix.php-versions }}
|
||||||
|
extension-csv: mbstring, xml, ctype, iconv, mysql
|
||||||
|
coverage: xdebug #optional
|
||||||
|
- name: Install Composer dependencies
|
||||||
|
run: |
|
||||||
|
composer install --no-progress --no-suggest --prefer-dist --optimize-autoloader
|
||||||
|
- name: Run Migration
|
||||||
|
run: |
|
||||||
|
composer require symfony/orm-pack
|
||||||
|
php bin/console doctrine:schema:update --force || echo "No migrations found or schema update failed"
|
||||||
|
php bin/console doctrine:migrations:migrate || echo "No migrations found or migration failed"
|
||||||
|
env:
|
||||||
|
DATABASE_URL: mysql://root:symfony@127.0.0.1:${{ job.services.mysql.ports['3306'] }}/symfony
|
||||||
|
- name: Run Tests
|
||||||
|
run: |
|
||||||
|
composer require phpunit
|
||||||
|
php bin/phpunit --coverage-text
|
44
examples/symfony-postgres.yml
Normal file
44
examples/symfony-postgres.yml
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
name: Testing Symfony with PostgreSQL
|
||||||
|
on: [push, pull_request]
|
||||||
|
jobs:
|
||||||
|
laravel:
|
||||||
|
name: Symfony (PHP ${{ matrix.php-versions }})
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
services:
|
||||||
|
postgres:
|
||||||
|
image: postgres:10.8
|
||||||
|
env:
|
||||||
|
POSTGRES_USER: postgres
|
||||||
|
POSTGRES_PASSWORD: postgres
|
||||||
|
POSTGRES_DB: postgres
|
||||||
|
ports:
|
||||||
|
- 5432/tcp
|
||||||
|
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 3
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
max-parallel: 3
|
||||||
|
matrix:
|
||||||
|
php-versions: ['7.3']
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v1
|
||||||
|
- name: Setup PHP, with composer and extensions
|
||||||
|
uses: shivammathur/setup-php@master #https://github.com/shivammathur/setup-php
|
||||||
|
with:
|
||||||
|
php-version: ${{ matrix.php-versions }}
|
||||||
|
extension-csv: mbstring, xml, ctype, iconv, pgsql
|
||||||
|
coverage: xdebug #optional
|
||||||
|
- name: Install Composer dependencies
|
||||||
|
run: |
|
||||||
|
composer install --no-progress --no-suggest --prefer-dist --optimize-autoloader
|
||||||
|
- name: Run Migration
|
||||||
|
run: |
|
||||||
|
composer require symfony/orm-pack
|
||||||
|
php bin/console doctrine:schema:update --force || echo "No migrations found or schema update failed"
|
||||||
|
php bin/console doctrine:migrations:migrate || echo "No migrations found or migration failed"
|
||||||
|
env:
|
||||||
|
DATABASE_URL: postgres://postgres:postgres@127.0.0.1:${{ job.services.postgres.ports[5432] }}/postgres?charset=UTF-8
|
||||||
|
- name: Run Tests
|
||||||
|
run: |
|
||||||
|
composer require phpunit
|
||||||
|
php bin/phpunit --coverage-text
|
29
examples/symfony.yml
Normal file
29
examples/symfony.yml
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
name: Unit Testing Symfony
|
||||||
|
on: [push, pull_request]
|
||||||
|
jobs:
|
||||||
|
laravel:
|
||||||
|
name: Symfony (PHP ${{ matrix.php-versions }} on ${{ matrix.operating-system }})
|
||||||
|
runs-on: ${{ matrix.operating-system }}
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
max-parallel: 3
|
||||||
|
matrix:
|
||||||
|
operating-system: [ubuntu-latest, windows-latest, macOS-latest]
|
||||||
|
php-versions: ['7.3']
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v1
|
||||||
|
- name: Setup PHP, with composer and extensions
|
||||||
|
uses: shivammathur/setup-php@master #https://github.com/shivammathur/setup-php
|
||||||
|
with:
|
||||||
|
php-version: ${{ matrix.php-versions }}
|
||||||
|
extension-csv: mbstring, xml, ctype, iconv
|
||||||
|
coverage: xdebug #optional
|
||||||
|
- name: Install Composer dependencies
|
||||||
|
run: |
|
||||||
|
composer require symfony/orm-pack
|
||||||
|
composer install --no-progress --no-suggest --prefer-dist --optimize-autoloader
|
||||||
|
- name: Run Tests
|
||||||
|
run: |
|
||||||
|
composer require phpunit
|
||||||
|
php bin/phpunit --coverage-text
|
60
examples/yii2-mysql.yml
Normal file
60
examples/yii2-mysql.yml
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
name: Testing Yii2 with MySQL
|
||||||
|
on: [push, pull_request]
|
||||||
|
jobs:
|
||||||
|
laravel:
|
||||||
|
name: Yii2 (PHP ${{ matrix.php-versions }})
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
env:
|
||||||
|
DB_USERNAME: root
|
||||||
|
DB_PASSWORD: yii
|
||||||
|
TEST_DB_USERNAME: root
|
||||||
|
TEST_DB_PASSWORD: yii
|
||||||
|
DB_CHARSET: utf8
|
||||||
|
services:
|
||||||
|
mysql:
|
||||||
|
image: mysql:5.7
|
||||||
|
env:
|
||||||
|
MYSQL_ALLOW_EMPTY_PASSWORD: false
|
||||||
|
MYSQL_ROOT_PASSWORD: yii
|
||||||
|
MYSQL_DATABASE: yii
|
||||||
|
ports:
|
||||||
|
- 3306
|
||||||
|
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
max-parallel: 3
|
||||||
|
matrix:
|
||||||
|
php-versions: ['7.2', '7.3', '7.4']
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v1
|
||||||
|
- name: Set Node.js 10.x
|
||||||
|
uses: actions/setup-node@master
|
||||||
|
with:
|
||||||
|
version: 10.x
|
||||||
|
- name: Setup PHP, with composer and extensions
|
||||||
|
uses: shivammathur/setup-php@master #https://github.com/shivammathur/setup-php
|
||||||
|
with:
|
||||||
|
php-version: ${{ matrix.php-versions }}
|
||||||
|
extension-csv: mbstring, intl, gd, imagick, zip, dom, mysql
|
||||||
|
coverage: xdebug #optional
|
||||||
|
- name: Install Composer dependencies
|
||||||
|
run: composer install --no-progress --no-suggest --prefer-dist --optimize-autoloader
|
||||||
|
- name: Prepare the application
|
||||||
|
run: |
|
||||||
|
php -r "file_exists('.env') || copy('.env.dist', '.env');"
|
||||||
|
php console/yii app/setup
|
||||||
|
npm install --development
|
||||||
|
npm run build
|
||||||
|
env:
|
||||||
|
DB_DSN: mysql:host=127.0.0.1;port=${{ job.services.mysql.ports['3306'] }};dbname=yii
|
||||||
|
TEST_DB_DSN: mysql:host=127.0.0.1;port=${{ job.services.mysql.ports['3306'] }};dbname=yii
|
||||||
|
- name: Run Tests
|
||||||
|
run: |
|
||||||
|
vendor/bin/codecept build
|
||||||
|
php tests/bin/yii app/setup --interactive=0
|
||||||
|
nohup php -S localhost:8080 > yii.log 2>&1 &
|
||||||
|
vendor/bin/codecept run
|
||||||
|
env:
|
||||||
|
DB_DSN: mysql:host=127.0.0.1;port=${{ job.services.mysql.ports['3306'] }};dbname=yii
|
||||||
|
TEST_DB_DSN: mysql:host=127.0.0.1;port=${{ job.services.mysql.ports['3306'] }};dbname=yii
|
60
examples/yii2-postgres.yml
Normal file
60
examples/yii2-postgres.yml
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
name: Testing Yii2 with PostgreSQL
|
||||||
|
on: [push, pull_request]
|
||||||
|
jobs:
|
||||||
|
laravel:
|
||||||
|
name: Yii2 (PHP ${{ matrix.php-versions }})
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
env:
|
||||||
|
DB_USERNAME: postgres
|
||||||
|
DB_PASSWORD: postgres
|
||||||
|
TEST_DB_USERNAME: postgres
|
||||||
|
TEST_DB_PASSWORD: postgres
|
||||||
|
DB_CHARSET: utf8
|
||||||
|
services:
|
||||||
|
postgres:
|
||||||
|
image: postgres:10.8
|
||||||
|
env:
|
||||||
|
POSTGRES_USER: postgres
|
||||||
|
POSTGRES_PASSWORD: postgres
|
||||||
|
POSTGRES_DB: postgres
|
||||||
|
ports:
|
||||||
|
- 5432/tcp
|
||||||
|
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 3
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
max-parallel: 3
|
||||||
|
matrix:
|
||||||
|
php-versions: ['7.2', '7.3', '7.4']
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v1
|
||||||
|
- name: Set Node.js 10.x
|
||||||
|
uses: actions/setup-node@master
|
||||||
|
with:
|
||||||
|
version: 10.x
|
||||||
|
- name: Setup PHP, with composer and extensions
|
||||||
|
uses: shivammathur/setup-php@master #https://github.com/shivammathur/setup-php
|
||||||
|
with:
|
||||||
|
php-version: ${{ matrix.php-versions }}
|
||||||
|
extension-csv: mbstring, intl, gd, imagick, zip, dom, pgsql
|
||||||
|
coverage: xdebug #optional
|
||||||
|
- name: Install Composer dependencies
|
||||||
|
run: composer install --no-progress --no-suggest --prefer-dist --optimize-autoloader
|
||||||
|
- name: Prepare the application
|
||||||
|
run: |
|
||||||
|
php -r "file_exists('.env') || copy('.env.dist', '.env');"
|
||||||
|
php console/yii app/setup
|
||||||
|
npm install --development
|
||||||
|
npm run build
|
||||||
|
env:
|
||||||
|
DB_DSN: pgsql:host=127.0.0.1;port=${{ job.services.postgres.ports['5432'] }};dbname=postgres
|
||||||
|
TEST_DB_DSN: pgsql:host=127.0.0.1;port=${{ job.services.postgres.ports['5432'] }};dbname=postgres
|
||||||
|
- name: Run Tests
|
||||||
|
run: |
|
||||||
|
vendor/bin/codecept build
|
||||||
|
php tests/bin/yii app/setup --interactive=0
|
||||||
|
nohup php -S localhost:8080 > yii.log 2>&1 &
|
||||||
|
vendor/bin/codecept run
|
||||||
|
env:
|
||||||
|
DB_DSN: pgsql:host=127.0.0.1;port=${{ job.services.postgres.ports['5432'] }};dbname=postgres
|
||||||
|
TEST_DB_DSN: pgsql:host=127.0.0.1;port=${{ job.services.postgres.ports['5432'] }};dbname=postgres
|
29
examples/zend-framework.yml
Normal file
29
examples/zend-framework.yml
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
name: Testing Zend Framework
|
||||||
|
on: [push, pull_request]
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
strategy:
|
||||||
|
max-parallel: 6
|
||||||
|
matrix:
|
||||||
|
operating-system: [ubuntu-latest, windows-latest, macOS-latest]
|
||||||
|
php-versions: ['7.2', '7.3']
|
||||||
|
runs-on: ${{ matrix.operating-system }}
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@master
|
||||||
|
- name: Setup PHP, with composer and extensions
|
||||||
|
uses: shivammathur/setup-php@master #https://github.com/shivammathur/setup-php
|
||||||
|
with:
|
||||||
|
php-version: ${{ matrix.php-versions }}
|
||||||
|
extension-csv: mbstring, bcmath, curl, intl
|
||||||
|
coverage: xdebug #optional
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
composer install --no-progress --no-suggest --prefer-dist --optimize-autoloader
|
||||||
|
composer require --dev phpunit/phpunit squizlabs/php_codesniffer zendframework/zend-test
|
||||||
|
- name: Test with phpunit in windows
|
||||||
|
if: matrix.operating-system == 'windows-latest'
|
||||||
|
run: .\vendor\bin\phpunit --coverage-text
|
||||||
|
- name: Test with phpunit
|
||||||
|
if: matrix.operating-system != 'windows-latest'
|
||||||
|
run: vendor/bin/phpunit --coverage-text
|
77
lib/config.js
Normal file
77
lib/config.js
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
"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(require("./utils"));
|
||||||
|
/**
|
||||||
|
* Function to add custom ini values
|
||||||
|
*
|
||||||
|
* @param ini_values_csv
|
||||||
|
* @param os_version
|
||||||
|
*/
|
||||||
|
function addINIValues(ini_values_csv, os_version) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
switch (os_version) {
|
||||||
|
case 'win32':
|
||||||
|
return yield addINIValuesWindows(ini_values_csv);
|
||||||
|
case 'darwin':
|
||||||
|
case 'linux':
|
||||||
|
return yield addINIValuesUnix(ini_values_csv);
|
||||||
|
default:
|
||||||
|
return yield utils.log('Platform ' + os_version + ' is not supported', os_version, 'error', 'Add Config');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
exports.addINIValues = addINIValues;
|
||||||
|
/**
|
||||||
|
* Add script to set custom ini values for unix
|
||||||
|
*
|
||||||
|
* @param ini_values_csv
|
||||||
|
*/
|
||||||
|
function addINIValuesUnix(ini_values_csv) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
let script = '\n';
|
||||||
|
let ini_values = yield utils.INIArray(ini_values_csv);
|
||||||
|
yield utils.asyncForEach(ini_values, function (ini_value) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
// add script to set ini value
|
||||||
|
script += 'echo "' + ini_value + '" >> $ini_file\n';
|
||||||
|
});
|
||||||
|
});
|
||||||
|
return script;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
exports.addINIValuesUnix = addINIValuesUnix;
|
||||||
|
/**
|
||||||
|
* Add script to set custom ini values for windows
|
||||||
|
*
|
||||||
|
* @param ini_values_csv
|
||||||
|
*/
|
||||||
|
function addINIValuesWindows(ini_values_csv) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
let script = '\n';
|
||||||
|
let ini_values = yield utils.INIArray(ini_values_csv);
|
||||||
|
yield utils.asyncForEach(ini_values, function (ini_value) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
// add script to set ini value
|
||||||
|
script += 'Add-Content C:\\tools\\php\\php.ini "' + ini_value + '"\n';
|
||||||
|
});
|
||||||
|
});
|
||||||
|
return script;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
exports.addINIValuesWindows = addINIValuesWindows;
|
115
lib/coverage.js
Normal file
115
lib/coverage.js
Normal file
@ -0,0 +1,115 @@
|
|||||||
|
"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(require("./utils"));
|
||||||
|
const extensions = __importStar(require("./extensions"));
|
||||||
|
const config = __importStar(require("./config"));
|
||||||
|
function addCoverage(coverage_driver, version, os_version) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
coverage_driver.toLowerCase();
|
||||||
|
switch (coverage_driver) {
|
||||||
|
case 'pcov':
|
||||||
|
return addCoveragePCOV(version, os_version);
|
||||||
|
case 'xdebug':
|
||||||
|
return addCoverageXdebug(version, os_version);
|
||||||
|
case 'none':
|
||||||
|
return disableCoverage(version, os_version);
|
||||||
|
default:
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
exports.addCoverage = addCoverage;
|
||||||
|
function addCoverageXdebug(version, os_version) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
let script = '\n';
|
||||||
|
script += yield extensions.addExtension('xdebug', version, os_version, 'Set Coverage Driver');
|
||||||
|
script += yield utils.log('Xdebug enabled as coverage driver', os_version, 'success', 'Set Coverage Driver');
|
||||||
|
return script;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
exports.addCoverageXdebug = addCoverageXdebug;
|
||||||
|
function addCoveragePCOV(version, os_version) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
let script = '\n';
|
||||||
|
switch (version) {
|
||||||
|
default:
|
||||||
|
script += yield extensions.addExtension('pcov', version, os_version, 'Set Coverage Driver');
|
||||||
|
script += yield config.addINIValues('pcov.enabled=1', os_version);
|
||||||
|
// add command to disable xdebug and enable pcov
|
||||||
|
switch (os_version) {
|
||||||
|
case 'linux':
|
||||||
|
script +=
|
||||||
|
'if [ -e /etc/php/' +
|
||||||
|
version +
|
||||||
|
'/mods-available/xdebug.ini ]; then sudo phpdismod xdebug; fi\n';
|
||||||
|
script += 'sudo sed -i "/xdebug/d" $ini_file\n';
|
||||||
|
break;
|
||||||
|
case 'darwin':
|
||||||
|
script += 'sudo sed -i \'\' "/xdebug/d" $ini_file\n';
|
||||||
|
break;
|
||||||
|
case 'win32':
|
||||||
|
script +=
|
||||||
|
'if(php -m | findstr -i xdebug) { Disable-PhpExtension xdebug C:\\tools\\php }\n';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// success
|
||||||
|
script += yield utils.log('PCOV enabled as coverage driver', os_version, 'success', 'Set Coverage Driver');
|
||||||
|
// version is not supported
|
||||||
|
break;
|
||||||
|
case '5.6':
|
||||||
|
case '7.0':
|
||||||
|
script += yield utils.log('PCOV requires PHP 7.1 or newer', os_version, 'warning', 'Set Coverage Driver');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return script;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
exports.addCoveragePCOV = addCoveragePCOV;
|
||||||
|
function disableCoverage(version, os_version) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
let script = '\n';
|
||||||
|
switch (os_version) {
|
||||||
|
case 'linux':
|
||||||
|
script +=
|
||||||
|
'if [ -e /etc/php/' +
|
||||||
|
version +
|
||||||
|
'/mods-available/xdebug.ini ]; then sudo phpdismod xdebug; fi\n';
|
||||||
|
script +=
|
||||||
|
'if [ -e /etc/php/' +
|
||||||
|
version +
|
||||||
|
'/mods-available/pcov.ini ]; then sudo phpdismod pcov; fi\n';
|
||||||
|
script += 'sudo sed -i "/xdebug/d" $ini_file\n';
|
||||||
|
script += 'sudo sed -i "/pcov/d" $ini_file\n';
|
||||||
|
break;
|
||||||
|
case 'darwin':
|
||||||
|
script += 'sudo sed -i \'\' "/xdebug/d" $ini_file\n';
|
||||||
|
script += 'sudo sed -i \'\' "/pcov/d" $ini_file\n';
|
||||||
|
break;
|
||||||
|
case 'win32':
|
||||||
|
script +=
|
||||||
|
'if(php -m | findstr -i xdebug) { Disable-PhpExtension xdebug C:\\tools\\php }\n';
|
||||||
|
script +=
|
||||||
|
'if(php -m | findstr -i pcov) { Disable-PhpExtension pcov C:\\tools\\php }\n';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
script += yield utils.log('Disabled Xdebug and PCOV', os_version, 'success', 'Set Coverage Driver');
|
||||||
|
return script;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
exports.disableCoverage = disableCoverage;
|
@ -18,52 +18,38 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
const utils = __importStar(require("./utils"));
|
const utils = __importStar(require("./utils"));
|
||||||
const pecl = __importStar(require("./pecl"));
|
const pecl = __importStar(require("./pecl"));
|
||||||
function addExtension(extension_csv, version, os_version) {
|
function addExtension(extension_csv, version, os_version, log_prefix = 'Add Extension') {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
switch (os_version) {
|
switch (os_version) {
|
||||||
case 'win32':
|
case 'win32':
|
||||||
return yield addExtensionWindows(extension_csv, version);
|
return yield addExtensionWindows(extension_csv, version, log_prefix);
|
||||||
case 'darwin':
|
case 'darwin':
|
||||||
return yield addExtensionDarwin(extension_csv, version);
|
return yield addExtensionDarwin(extension_csv, version, log_prefix);
|
||||||
case 'linux':
|
case 'linux':
|
||||||
return yield addExtensionLinux(extension_csv, version);
|
return yield addExtensionLinux(extension_csv, version, log_prefix);
|
||||||
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', log_prefix);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
exports.addExtension = addExtension;
|
exports.addExtension = addExtension;
|
||||||
function addINIValues(ini_values_csv, os_version) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
switch (os_version) {
|
|
||||||
case 'win32':
|
|
||||||
return yield addINIValuesWindows(ini_values_csv);
|
|
||||||
case 'darwin':
|
|
||||||
case 'linux':
|
|
||||||
return yield addINIValuesUnix(ini_values_csv);
|
|
||||||
default:
|
|
||||||
return yield utils.log('Platform ' + os_version + ' is not supported', os_version, 'error');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
exports.addINIValues = addINIValues;
|
|
||||||
/**
|
/**
|
||||||
* Enable extensions which are installed but not enabled on windows
|
* Enable extensions which are installed but not enabled on windows
|
||||||
*
|
*
|
||||||
* @param extension
|
* @param extension
|
||||||
*/
|
*/
|
||||||
function enableExtensionWindows(extension) {
|
function enableExtensionWindows(extension, log_prefix) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
return (`try {
|
return (`try {
|
||||||
$exist = Test-Path -Path $ext_dir\\php_${extension}.dll
|
$exist = Test-Path -Path $ext_dir\\php_${extension}.dll
|
||||||
if(!(php -m | findstr -i ${extension}) -and $exist) {
|
if(!(php -m | findstr -i ${extension}) -and $exist) {
|
||||||
Add-Content C:\\tools\\php\\php.ini "${yield utils.getExtensionPrefix(extension)}=php_${extension}.dll"\n` +
|
Add-Content C:\\tools\\php\\php.ini "${yield utils.getExtensionPrefix(extension)}=php_${extension}.dll"\n` +
|
||||||
(yield utils.log('Enabled ' + extension, 'win32', 'success')) +
|
(yield utils.log('Enabled ' + extension, 'win32', 'success', log_prefix)) +
|
||||||
` } elseif(php -m | findstr -i ${extension}) {\n` +
|
` } elseif(php -m | findstr -i ${extension}) {\n` +
|
||||||
(yield utils.log('Extension ' + extension + ' was already enabled', 'win32', 'success')) +
|
(yield utils.log(extension + ' was already enabled', 'win32', 'success', log_prefix)) +
|
||||||
` }
|
` }
|
||||||
} catch [Exception] {\n` +
|
} catch [Exception] {\n` +
|
||||||
(yield utils.log(extension + ' could not be enabled', 'win32', 'error')) +
|
(yield utils.log(extension + ' could not be enabled', 'win32', 'error', log_prefix)) +
|
||||||
` }\n`);
|
` }\n`);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -74,13 +60,13 @@ exports.enableExtensionWindows = enableExtensionWindows;
|
|||||||
* @param extension
|
* @param extension
|
||||||
* @param os_version
|
* @param os_version
|
||||||
*/
|
*/
|
||||||
function enableExtensionUnix(extension, os_version) {
|
function enableExtensionUnix(extension, os_version, log_prefix) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
return (`if [ ! "$(php -m | grep -i ${extension})" ] && [ -e "$ext_dir/${extension}.so" ]; then
|
return (`if [ ! "$(php -m | grep -i ${extension})" ] && [ -e "$ext_dir/${extension}.so" ]; then
|
||||||
echo "${yield utils.getExtensionPrefix(extension)}=${extension}" >> 'php -i | grep "Loaded Configuration" | sed -e "s|.*=>\s*||"'\n` +
|
echo "${yield utils.getExtensionPrefix(extension)}=${extension}" >> 'php -i | grep "Loaded Configuration" | sed -e "s|.*=>\s*||"'\n` +
|
||||||
(yield utils.log('Enabled ' + extension, os_version, 'success')) +
|
(yield utils.log('Enabled ' + extension, os_version, 'success', log_prefix)) +
|
||||||
`;\n elif [ "$(php -m | grep -i ${extension})" ]; then \n` +
|
`;\n elif [ "$(php -m | grep -i ${extension})" ]; then \n` +
|
||||||
(yield utils.log('Extension ' + extension + ' was already enabled', os_version, 'success')) +
|
(yield utils.log(extension + ' was already enabled', os_version, 'success', log_prefix)) +
|
||||||
`; fi\n`);
|
`; fi\n`);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -91,7 +77,7 @@ exports.enableExtensionUnix = enableExtensionUnix;
|
|||||||
* @param extension_csv
|
* @param extension_csv
|
||||||
* @param version
|
* @param version
|
||||||
*/
|
*/
|
||||||
function addExtensionDarwin(extension_csv, version) {
|
function addExtensionDarwin(extension_csv, version, log_prefix) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
let extensions = yield utils.extensionArray(extension_csv);
|
let extensions = yield utils.extensionArray(extension_csv);
|
||||||
let script = '\n';
|
let script = '\n';
|
||||||
@ -99,7 +85,7 @@ function addExtensionDarwin(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
|
||||||
script += yield enableExtensionUnix(extension, 'darwin');
|
script += yield enableExtensionUnix(extension, 'darwin', log_prefix);
|
||||||
switch (yield pecl.checkPECLExtension(extension)) {
|
switch (yield pecl.checkPECLExtension(extension)) {
|
||||||
case true:
|
case true:
|
||||||
let install_command = '';
|
let install_command = '';
|
||||||
@ -126,9 +112,9 @@ function addExtensionDarwin(extension_csv, version) {
|
|||||||
')" ]; then ' +
|
')" ]; then ' +
|
||||||
install_command +
|
install_command +
|
||||||
' && ' +
|
' && ' +
|
||||||
(yield utils.log('Installed and enabled ' + extension, 'darwin', 'success')) +
|
(yield utils.log('Installed and enabled ' + extension, 'darwin', 'success', log_prefix)) +
|
||||||
' || ' +
|
' || ' +
|
||||||
(yield utils.log('Could not install ' + extension + ' on PHP' + version, 'darwin', 'error')) +
|
(yield utils.log('Could not install ' + extension + ' on PHP' + version, 'darwin', 'error', log_prefix)) +
|
||||||
'; fi\n';
|
'; fi\n';
|
||||||
break;
|
break;
|
||||||
case false:
|
case false:
|
||||||
@ -137,7 +123,7 @@ function addExtensionDarwin(extension_csv, version) {
|
|||||||
'if [ ! "$(php -m | grep -i ' +
|
'if [ ! "$(php -m | grep -i ' +
|
||||||
extension +
|
extension +
|
||||||
')" ]; then \n' +
|
')" ]; then \n' +
|
||||||
(yield utils.log('Could not find ' + extension + ' for PHP' + version + ' on PECL', 'darwin', 'error')) +
|
(yield utils.log('Could not find ' + extension + ' for PHP' + version + ' on PECL', 'darwin', 'error', log_prefix)) +
|
||||||
'; fi\n';
|
'; fi\n';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -153,7 +139,7 @@ exports.addExtensionDarwin = addExtensionDarwin;
|
|||||||
* @param extension_csv
|
* @param extension_csv
|
||||||
* @param version
|
* @param version
|
||||||
*/
|
*/
|
||||||
function addExtensionWindows(extension_csv, version) {
|
function addExtensionWindows(extension_csv, version, log_prefix) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
let extensions = yield utils.extensionArray(extension_csv);
|
let extensions = yield utils.extensionArray(extension_csv);
|
||||||
let script = '\n';
|
let script = '\n';
|
||||||
@ -161,7 +147,7 @@ function addExtensionWindows(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
|
||||||
script += yield enableExtensionWindows(extension);
|
script += yield enableExtensionWindows(extension, log_prefix);
|
||||||
switch (yield pecl.checkPECLExtension(extension)) {
|
switch (yield pecl.checkPECLExtension(extension)) {
|
||||||
case true:
|
case true:
|
||||||
let install_command = '';
|
let install_command = '';
|
||||||
@ -186,9 +172,9 @@ function addExtensionWindows(extension_csv, version) {
|
|||||||
'try { ' +
|
'try { ' +
|
||||||
install_command +
|
install_command +
|
||||||
'\n' +
|
'\n' +
|
||||||
(yield utils.log('Installed and enabled ' + extension, 'win32', 'success')) +
|
(yield utils.log('Installed and enabled ' + extension, 'win32', 'success', log_prefix)) +
|
||||||
' } catch [Exception] { ' +
|
' } catch [Exception] { ' +
|
||||||
(yield utils.log('Could not install ' + extension + ' on PHP' + version, 'win32', 'error')) +
|
(yield utils.log('Could not install ' + extension + ' on PHP' + version, 'win32', 'error', log_prefix)) +
|
||||||
' } }\n';
|
' } }\n';
|
||||||
break;
|
break;
|
||||||
case false:
|
case false:
|
||||||
@ -197,7 +183,7 @@ function addExtensionWindows(extension_csv, version) {
|
|||||||
'if(!(php -m | findstr -i ' +
|
'if(!(php -m | findstr -i ' +
|
||||||
extension +
|
extension +
|
||||||
')) { ' +
|
')) { ' +
|
||||||
(yield utils.log('Could not find ' + extension + ' for PHP' + version + ' on PECL', 'win32', 'error')) +
|
(yield utils.log('Could not find ' + extension + ' for PHP' + version + ' on PECL', 'win32', 'error', log_prefix)) +
|
||||||
' } \n';
|
' } \n';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -213,7 +199,7 @@ exports.addExtensionWindows = addExtensionWindows;
|
|||||||
* @param extension_csv
|
* @param extension_csv
|
||||||
* @param version
|
* @param version
|
||||||
*/
|
*/
|
||||||
function addExtensionLinux(extension_csv, version) {
|
function addExtensionLinux(extension_csv, version, log_prefix) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
let extensions = yield utils.extensionArray(extension_csv);
|
let extensions = yield utils.extensionArray(extension_csv);
|
||||||
let script = '\n';
|
let script = '\n';
|
||||||
@ -221,7 +207,7 @@ 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
|
||||||
script += yield enableExtensionUnix(extension, 'linux');
|
script += yield enableExtensionUnix(extension, 'linux', log_prefix);
|
||||||
let install_command = '';
|
let install_command = '';
|
||||||
switch (version + extension) {
|
switch (version + extension) {
|
||||||
case '7.4xdebug':
|
case '7.4xdebug':
|
||||||
@ -247,9 +233,9 @@ function addExtensionLinux(extension_csv, version) {
|
|||||||
')" ]; then ' +
|
')" ]; then ' +
|
||||||
install_command +
|
install_command +
|
||||||
' && ' +
|
' && ' +
|
||||||
(yield utils.log('Installed and enabled ' + extension, 'linux', 'success')) +
|
(yield utils.log('Installed and enabled ' + extension, 'linux', 'success', log_prefix)) +
|
||||||
' || ' +
|
' || ' +
|
||||||
(yield utils.log('Could not find php' + version + '-' + extension + ' on APT repository', 'linux', 'error')) +
|
(yield utils.log('Could not find php' + version + '-' + extension + ' on APT repository', 'linux', 'error', log_prefix)) +
|
||||||
'; fi\n';
|
'; fi\n';
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -257,90 +243,3 @@ function addExtensionLinux(extension_csv, version) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
exports.addExtensionLinux = addExtensionLinux;
|
exports.addExtensionLinux = addExtensionLinux;
|
||||||
/**
|
|
||||||
* Add script to set custom ini values for unix
|
|
||||||
*
|
|
||||||
* @param ini_values_csv
|
|
||||||
*/
|
|
||||||
function addINIValuesUnix(ini_values_csv) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
let script = '\n';
|
|
||||||
let ini_values = yield utils.INIArray(ini_values_csv);
|
|
||||||
yield utils.asyncForEach(ini_values, function (ini_value) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
// add script to set ini value
|
|
||||||
script += 'echo "' + ini_value + '" >> $ini_file\n';
|
|
||||||
});
|
|
||||||
});
|
|
||||||
return script;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
exports.addINIValuesUnix = addINIValuesUnix;
|
|
||||||
/**
|
|
||||||
* Add script to set custom ini values for windows
|
|
||||||
*
|
|
||||||
* @param ini_values_csv
|
|
||||||
*/
|
|
||||||
function addINIValuesWindows(ini_values_csv) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
let script = '\n';
|
|
||||||
let ini_values = yield utils.INIArray(ini_values_csv);
|
|
||||||
yield utils.asyncForEach(ini_values, function (ini_value) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
// add script to set ini value
|
|
||||||
script += 'Add-Content C:\\tools\\php\\php.ini "' + ini_value + '"\n';
|
|
||||||
});
|
|
||||||
});
|
|
||||||
return script;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
exports.addINIValuesWindows = addINIValuesWindows;
|
|
||||||
function addCoverage(coverage, version, os_version) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
let script = '';
|
|
||||||
script += '\n';
|
|
||||||
coverage = coverage.toLowerCase();
|
|
||||||
// pcov
|
|
||||||
switch (coverage) {
|
|
||||||
case 'pcov':
|
|
||||||
// if version is 7.1 or newer
|
|
||||||
switch (version) {
|
|
||||||
default:
|
|
||||||
script += yield addExtension('pcov', version, os_version);
|
|
||||||
script += yield addINIValues('pcov.enabled=1', os_version);
|
|
||||||
// add command to disable xdebug and enable pcov
|
|
||||||
switch (os_version) {
|
|
||||||
case 'linux':
|
|
||||||
script += 'sudo sed -i "/xdebug/d" $ini_file\n';
|
|
||||||
break;
|
|
||||||
case 'darwin':
|
|
||||||
script += 'sudo sed -i \'\' "/xdebug/d" $ini_file\n';
|
|
||||||
break;
|
|
||||||
case 'win32':
|
|
||||||
script +=
|
|
||||||
'if(php -m | findstr -i xdebug) { Disable-PhpExtension xdebug C:\\tools\\php }\n';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
// success
|
|
||||||
script += yield utils.log('pcov enabled as coverage driver', os_version, 'success');
|
|
||||||
// version is not supported
|
|
||||||
break;
|
|
||||||
case '5.6':
|
|
||||||
case '7.0':
|
|
||||||
script += yield utils.log('pcov requires php 7.1 or newer', os_version, 'warning');
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
//xdebug
|
|
||||||
case 'xdebug':
|
|
||||||
script += yield addExtension('xdebug', version, os_version);
|
|
||||||
script += yield utils.log('Xdebug enabled as coverage driver', os_version, 'success');
|
|
||||||
break;
|
|
||||||
// unknown coverage driver
|
|
||||||
default:
|
|
||||||
script = '';
|
|
||||||
}
|
|
||||||
return script;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
exports.addCoverage = addCoverage;
|
|
@ -19,7 +19,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|||||||
const exec_1 = require("@actions/exec/lib/exec");
|
const exec_1 = require("@actions/exec/lib/exec");
|
||||||
const core = __importStar(require("@actions/core"));
|
const core = __importStar(require("@actions/core"));
|
||||||
const utils = __importStar(require("./utils"));
|
const utils = __importStar(require("./utils"));
|
||||||
const features = __importStar(require("./features"));
|
const extensions = __importStar(require("./extensions"));
|
||||||
|
const config = __importStar(require("./config"));
|
||||||
|
const coverage = __importStar(require("./coverage"));
|
||||||
/**
|
/**
|
||||||
* Run the script
|
* Run the script
|
||||||
*/
|
*/
|
||||||
@ -30,30 +32,30 @@ function run() {
|
|||||||
let version = yield utils.getInput('php-version', true);
|
let version = yield utils.getInput('php-version', true);
|
||||||
let extension_csv = yield utils.getInput('extension-csv', false);
|
let extension_csv = yield utils.getInput('extension-csv', false);
|
||||||
let ini_values_csv = yield utils.getInput('ini-values-csv', false);
|
let ini_values_csv = yield utils.getInput('ini-values-csv', false);
|
||||||
let coverage = yield utils.getInput('coverage', false);
|
let coverage_driver = yield utils.getInput('coverage', false);
|
||||||
let os_version = process.platform;
|
let os_version = process.platform;
|
||||||
// check the os version and run the respective script
|
// check the os version and run the respective script
|
||||||
if (os_version == 'darwin') {
|
if (os_version == 'darwin') {
|
||||||
let darwin = yield utils.readScript('darwin.sh', version, os_version);
|
let darwin = yield utils.readScript('darwin.sh', version, os_version);
|
||||||
darwin += yield features.addExtension(extension_csv, version, os_version);
|
darwin += yield extensions.addExtension(extension_csv, version, os_version);
|
||||||
darwin += yield features.addINIValues(ini_values_csv, os_version);
|
darwin += yield config.addINIValues(ini_values_csv, os_version);
|
||||||
darwin += yield features.addCoverage(coverage, version, os_version);
|
darwin += yield coverage.addCoverage(coverage_driver, version, os_version);
|
||||||
yield utils.writeScript('darwin.sh', version, darwin);
|
yield utils.writeScript('darwin.sh', version, darwin);
|
||||||
yield exec_1.exec('sh ./' + version + 'darwin.sh ' + version);
|
yield exec_1.exec('sh ./' + version + 'darwin.sh ' + version);
|
||||||
}
|
}
|
||||||
else if (os_version == 'win32') {
|
else if (os_version == 'win32') {
|
||||||
let windows = yield utils.readScript('win32.ps1', version, os_version);
|
let windows = yield utils.readScript('win32.ps1', version, os_version);
|
||||||
windows += yield features.addExtension(extension_csv, version, os_version);
|
windows += yield extensions.addExtension(extension_csv, version, os_version);
|
||||||
windows += yield features.addINIValues(ini_values_csv, os_version);
|
windows += yield config.addINIValues(ini_values_csv, os_version);
|
||||||
windows += yield features.addCoverage(coverage, version, os_version);
|
windows += yield coverage.addCoverage(coverage_driver, version, os_version);
|
||||||
yield utils.writeScript('win32.ps1', version, windows);
|
yield utils.writeScript('win32.ps1', version, windows);
|
||||||
yield exec_1.exec('powershell .\\' + version + 'win32.ps1 -version ' + version);
|
yield exec_1.exec('powershell .\\' + version + 'win32.ps1 -version ' + version);
|
||||||
}
|
}
|
||||||
else if (os_version == 'linux') {
|
else if (os_version == 'linux') {
|
||||||
let linux = yield utils.readScript('linux.sh', version, os_version);
|
let linux = yield utils.readScript('linux.sh', version, os_version);
|
||||||
linux += yield features.addExtension(extension_csv, version, os_version);
|
linux += yield extensions.addExtension(extension_csv, version, os_version);
|
||||||
linux += yield features.addINIValues(ini_values_csv, os_version);
|
linux += yield config.addINIValues(ini_values_csv, os_version);
|
||||||
linux += yield features.addCoverage(coverage, version, os_version);
|
linux += yield coverage.addCoverage(coverage_driver, version, os_version);
|
||||||
yield utils.writeScript('linux.sh', version, linux);
|
yield utils.writeScript('linux.sh', version, linux);
|
||||||
yield exec_1.exec('./' + version + 'linux.sh ' + version);
|
yield exec_1.exec('./' + version + 'linux.sh ' + version);
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ function checkPECLExtension(extension) {
|
|||||||
allowRetries: true,
|
allowRetries: true,
|
||||||
maxRetries: 2
|
maxRetries: 2
|
||||||
});
|
});
|
||||||
const response = yield http.get('https://pecl.php.net/package/' + extension);
|
const response = yield http.get('https://pecl.php.net/json.php?package=' + extension);
|
||||||
return response.message.statusCode === 200;
|
return response.message.statusCode === 200;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
43
lib/utils.js
43
lib/utils.js
@ -79,24 +79,26 @@ function readScript(filename, version, os_version) {
|
|||||||
'scripts/pcov.sh'
|
'scripts/pcov.sh'
|
||||||
]);
|
]);
|
||||||
return fs.readFileSync(path.join(__dirname, '../src/scripts/7.4.sh'), 'utf8');
|
return fs.readFileSync(path.join(__dirname, '../src/scripts/7.4.sh'), 'utf8');
|
||||||
case '7.3':
|
|
||||||
default:
|
|
||||||
return fs.readFileSync(path.join(__dirname, '../src/scripts/' + filename), 'utf8');
|
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
case 'linux':
|
case 'linux':
|
||||||
switch (version) {
|
switch (version) {
|
||||||
case '7.4':
|
case '7.4':
|
||||||
yield readFiles74(['scripts/xdebug.sh', 'scripts/pcov.sh']);
|
yield readFiles74(['scripts/xdebug.sh', 'scripts/pcov.sh']);
|
||||||
return fs.readFileSync(path.join(__dirname, '../src/scripts/' + filename), 'utf8');
|
break;
|
||||||
case '7.3':
|
|
||||||
default:
|
|
||||||
return fs.readFileSync(path.join(__dirname, '../src/scripts/' + filename), 'utf8');
|
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
case 'win32':
|
case 'win32':
|
||||||
return fs.readFileSync(path.join(__dirname, '../src/scripts/' + filename), 'utf8');
|
switch (version) {
|
||||||
|
case '7.4':
|
||||||
|
yield readFiles74(['ext/php_pcov.dll']);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
return yield log('Platform ' + os_version + ' is not supported', os_version, 'error');
|
return yield log('Platform ' + os_version + ' is not supported', os_version, 'error');
|
||||||
}
|
}
|
||||||
|
return fs.readFileSync(path.join(__dirname, '../src/scripts/' + filename), 'utf8');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
exports.readScript = readScript;
|
exports.readScript = readScript;
|
||||||
@ -154,13 +156,21 @@ function INIArray(ini_values_csv) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
exports.INIArray = INIArray;
|
exports.INIArray = INIArray;
|
||||||
function log(message, os_version, log_type) {
|
function log(message, os_version, log_type, prefix = '') {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
const unix_color = {
|
const unix_color = {
|
||||||
error: '31',
|
error: '31',
|
||||||
success: '32',
|
success: '32',
|
||||||
warning: '33'
|
warning: '33'
|
||||||
};
|
};
|
||||||
|
switch (prefix) {
|
||||||
|
case '':
|
||||||
|
prefix = prefix;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
prefix = prefix + ': ';
|
||||||
|
break;
|
||||||
|
}
|
||||||
switch (os_version) {
|
switch (os_version) {
|
||||||
case 'win32':
|
case 'win32':
|
||||||
const color = {
|
const color = {
|
||||||
@ -168,18 +178,27 @@ function log(message, os_version, log_type) {
|
|||||||
success: 'green',
|
success: 'green',
|
||||||
warning: 'yellow'
|
warning: 'yellow'
|
||||||
};
|
};
|
||||||
return "Write-Host '" + message + "' -ForegroundColor " + color[log_type];
|
return ("Write-Host '" +
|
||||||
|
prefix +
|
||||||
|
message +
|
||||||
|
"' -ForegroundColor " +
|
||||||
|
color[log_type]);
|
||||||
case 'linux':
|
case 'linux':
|
||||||
case 'darwin':
|
case 'darwin':
|
||||||
default:
|
default:
|
||||||
return ('echo "\\033[' + unix_color[log_type] + ';1m' + message + '\\033[0m"');
|
return ('echo "\\033[' +
|
||||||
|
unix_color[log_type] +
|
||||||
|
';1m' +
|
||||||
|
prefix +
|
||||||
|
message +
|
||||||
|
'\\033[0m"');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
exports.log = log;
|
exports.log = log;
|
||||||
function getExtensionPrefix(extension) {
|
function getExtensionPrefix(extension) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
let zend = ['xdebug', 'opcache'];
|
let zend = ['xdebug', 'opcache', 'ioncube', 'eaccelerator'];
|
||||||
switch (zend.indexOf(extension)) {
|
switch (zend.indexOf(extension)) {
|
||||||
case 0:
|
case 0:
|
||||||
case 1:
|
case 1:
|
||||||
|
2
package-lock.json
generated
2
package-lock.json
generated
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "setup-php",
|
"name": "setup-php",
|
||||||
"version": "1.3.7",
|
"version": "1.4.0",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "setup-php",
|
"name": "setup-php",
|
||||||
"version": "1.3.7",
|
"version": "1.4.0",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "Setup php action",
|
"description": "Setup php action",
|
||||||
"main": "lib/setup-php.js",
|
"main": "lib/setup-php.js",
|
||||||
|
58
src/config.ts
Normal file
58
src/config.ts
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
import * as utils from './utils';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function to add custom ini values
|
||||||
|
*
|
||||||
|
* @param ini_values_csv
|
||||||
|
* @param os_version
|
||||||
|
*/
|
||||||
|
export async function addINIValues(ini_values_csv: string, os_version: string) {
|
||||||
|
switch (os_version) {
|
||||||
|
case 'win32':
|
||||||
|
return await addINIValuesWindows(ini_values_csv);
|
||||||
|
case 'darwin':
|
||||||
|
case 'linux':
|
||||||
|
return await addINIValuesUnix(ini_values_csv);
|
||||||
|
default:
|
||||||
|
return await utils.log(
|
||||||
|
'Platform ' + os_version + ' is not supported',
|
||||||
|
os_version,
|
||||||
|
'error',
|
||||||
|
'Add Config'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add script to set custom ini values for unix
|
||||||
|
*
|
||||||
|
* @param ini_values_csv
|
||||||
|
*/
|
||||||
|
export async function addINIValuesUnix(
|
||||||
|
ini_values_csv: string
|
||||||
|
): Promise<string> {
|
||||||
|
let script: string = '\n';
|
||||||
|
let ini_values: Array<string> = await utils.INIArray(ini_values_csv);
|
||||||
|
await utils.asyncForEach(ini_values, async function(ini_value: string) {
|
||||||
|
// add script to set ini value
|
||||||
|
script += 'echo "' + ini_value + '" >> $ini_file\n';
|
||||||
|
});
|
||||||
|
return script;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add script to set custom ini values for windows
|
||||||
|
*
|
||||||
|
* @param ini_values_csv
|
||||||
|
*/
|
||||||
|
export async function addINIValuesWindows(
|
||||||
|
ini_values_csv: string
|
||||||
|
): Promise<string> {
|
||||||
|
let script: string = '\n';
|
||||||
|
let ini_values: Array<string> = await utils.INIArray(ini_values_csv);
|
||||||
|
await utils.asyncForEach(ini_values, async function(ini_value: string) {
|
||||||
|
// add script to set ini value
|
||||||
|
script += 'Add-Content C:\\tools\\php\\php.ini "' + ini_value + '"\n';
|
||||||
|
});
|
||||||
|
return script;
|
||||||
|
}
|
129
src/coverage.ts
Normal file
129
src/coverage.ts
Normal file
@ -0,0 +1,129 @@
|
|||||||
|
import * as utils from './utils';
|
||||||
|
import * as pecl from './pecl';
|
||||||
|
import * as extensions from './extensions';
|
||||||
|
import * as config from './config';
|
||||||
|
|
||||||
|
export async function addCoverage(
|
||||||
|
coverage_driver: string,
|
||||||
|
version: string,
|
||||||
|
os_version: string
|
||||||
|
): Promise<string> {
|
||||||
|
coverage_driver.toLowerCase();
|
||||||
|
switch (coverage_driver) {
|
||||||
|
case 'pcov':
|
||||||
|
return addCoveragePCOV(version, os_version);
|
||||||
|
case 'xdebug':
|
||||||
|
return addCoverageXdebug(version, os_version);
|
||||||
|
case 'none':
|
||||||
|
return disableCoverage(version, os_version);
|
||||||
|
default:
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function addCoverageXdebug(version: string, os_version: string) {
|
||||||
|
let script: string = '\n';
|
||||||
|
script += await extensions.addExtension(
|
||||||
|
'xdebug',
|
||||||
|
version,
|
||||||
|
os_version,
|
||||||
|
'Set Coverage Driver'
|
||||||
|
);
|
||||||
|
script += await utils.log(
|
||||||
|
'Xdebug enabled as coverage driver',
|
||||||
|
os_version,
|
||||||
|
'success',
|
||||||
|
'Set Coverage Driver'
|
||||||
|
);
|
||||||
|
|
||||||
|
return script;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function addCoveragePCOV(version: string, os_version: string) {
|
||||||
|
let script: string = '\n';
|
||||||
|
switch (version) {
|
||||||
|
default:
|
||||||
|
script += await extensions.addExtension(
|
||||||
|
'pcov',
|
||||||
|
version,
|
||||||
|
os_version,
|
||||||
|
'Set Coverage Driver'
|
||||||
|
);
|
||||||
|
script += await config.addINIValues('pcov.enabled=1', os_version);
|
||||||
|
|
||||||
|
// add command to disable xdebug and enable pcov
|
||||||
|
switch (os_version) {
|
||||||
|
case 'linux':
|
||||||
|
script +=
|
||||||
|
'if [ -e /etc/php/' +
|
||||||
|
version +
|
||||||
|
'/mods-available/xdebug.ini ]; then sudo phpdismod xdebug; fi\n';
|
||||||
|
script += 'sudo sed -i "/xdebug/d" $ini_file\n';
|
||||||
|
break;
|
||||||
|
case 'darwin':
|
||||||
|
script += 'sudo sed -i \'\' "/xdebug/d" $ini_file\n';
|
||||||
|
break;
|
||||||
|
case 'win32':
|
||||||
|
script +=
|
||||||
|
'if(php -m | findstr -i xdebug) { Disable-PhpExtension xdebug C:\\tools\\php }\n';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// success
|
||||||
|
script += await utils.log(
|
||||||
|
'PCOV enabled as coverage driver',
|
||||||
|
os_version,
|
||||||
|
'success',
|
||||||
|
'Set Coverage Driver'
|
||||||
|
);
|
||||||
|
// version is not supported
|
||||||
|
break;
|
||||||
|
case '5.6':
|
||||||
|
case '7.0':
|
||||||
|
script += await utils.log(
|
||||||
|
'PCOV requires PHP 7.1 or newer',
|
||||||
|
os_version,
|
||||||
|
'warning',
|
||||||
|
'Set Coverage Driver'
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return script;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function disableCoverage(version: string, os_version: string) {
|
||||||
|
let script: string = '\n';
|
||||||
|
switch (os_version) {
|
||||||
|
case 'linux':
|
||||||
|
script +=
|
||||||
|
'if [ -e /etc/php/' +
|
||||||
|
version +
|
||||||
|
'/mods-available/xdebug.ini ]; then sudo phpdismod xdebug; fi\n';
|
||||||
|
script +=
|
||||||
|
'if [ -e /etc/php/' +
|
||||||
|
version +
|
||||||
|
'/mods-available/pcov.ini ]; then sudo phpdismod pcov; fi\n';
|
||||||
|
script += 'sudo sed -i "/xdebug/d" $ini_file\n';
|
||||||
|
script += 'sudo sed -i "/pcov/d" $ini_file\n';
|
||||||
|
break;
|
||||||
|
case 'darwin':
|
||||||
|
script += 'sudo sed -i \'\' "/xdebug/d" $ini_file\n';
|
||||||
|
script += 'sudo sed -i \'\' "/pcov/d" $ini_file\n';
|
||||||
|
break;
|
||||||
|
case 'win32':
|
||||||
|
script +=
|
||||||
|
'if(php -m | findstr -i xdebug) { Disable-PhpExtension xdebug C:\\tools\\php }\n';
|
||||||
|
script +=
|
||||||
|
'if(php -m | findstr -i pcov) { Disable-PhpExtension pcov C:\\tools\\php }\n';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
script += await utils.log(
|
||||||
|
'Disabled Xdebug and PCOV',
|
||||||
|
os_version,
|
||||||
|
'success',
|
||||||
|
'Set Coverage Driver'
|
||||||
|
);
|
||||||
|
|
||||||
|
return script;
|
||||||
|
}
|
BIN
src/ext/php_pcov.dll
Normal file
BIN
src/ext/php_pcov.dll
Normal file
Binary file not shown.
@ -4,36 +4,22 @@ import * as pecl from './pecl';
|
|||||||
export async function addExtension(
|
export async function addExtension(
|
||||||
extension_csv: string,
|
extension_csv: string,
|
||||||
version: string,
|
version: string,
|
||||||
os_version: string
|
os_version: string,
|
||||||
|
log_prefix = 'Add Extension'
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
switch (os_version) {
|
switch (os_version) {
|
||||||
case 'win32':
|
case 'win32':
|
||||||
return await addExtensionWindows(extension_csv, version);
|
return await addExtensionWindows(extension_csv, version, log_prefix);
|
||||||
case 'darwin':
|
case 'darwin':
|
||||||
return await addExtensionDarwin(extension_csv, version);
|
return await addExtensionDarwin(extension_csv, version, log_prefix);
|
||||||
case 'linux':
|
case 'linux':
|
||||||
return await addExtensionLinux(extension_csv, version);
|
return await addExtensionLinux(extension_csv, version, log_prefix);
|
||||||
default:
|
default:
|
||||||
return await utils.log(
|
return await utils.log(
|
||||||
'Platform ' + os_version + ' is not supported',
|
'Platform ' + os_version + ' is not supported',
|
||||||
os_version,
|
os_version,
|
||||||
'error'
|
'error',
|
||||||
);
|
log_prefix
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function addINIValues(ini_values_csv: string, os_version: string) {
|
|
||||||
switch (os_version) {
|
|
||||||
case 'win32':
|
|
||||||
return await addINIValuesWindows(ini_values_csv);
|
|
||||||
case 'darwin':
|
|
||||||
case 'linux':
|
|
||||||
return await addINIValuesUnix(ini_values_csv);
|
|
||||||
default:
|
|
||||||
return await utils.log(
|
|
||||||
'Platform ' + os_version + ' is not supported',
|
|
||||||
os_version,
|
|
||||||
'error'
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -43,7 +29,10 @@ export async function addINIValues(ini_values_csv: string, os_version: string) {
|
|||||||
*
|
*
|
||||||
* @param extension
|
* @param extension
|
||||||
*/
|
*/
|
||||||
export async function enableExtensionWindows(extension: string) {
|
export async function enableExtensionWindows(
|
||||||
|
extension: string,
|
||||||
|
log_prefix: string
|
||||||
|
) {
|
||||||
return (
|
return (
|
||||||
`try {
|
`try {
|
||||||
$exist = Test-Path -Path $ext_dir\\php_${extension}.dll
|
$exist = Test-Path -Path $ext_dir\\php_${extension}.dll
|
||||||
@ -51,16 +40,22 @@ export async function enableExtensionWindows(extension: string) {
|
|||||||
Add-Content C:\\tools\\php\\php.ini "${await utils.getExtensionPrefix(
|
Add-Content C:\\tools\\php\\php.ini "${await utils.getExtensionPrefix(
|
||||||
extension
|
extension
|
||||||
)}=php_${extension}.dll"\n` +
|
)}=php_${extension}.dll"\n` +
|
||||||
(await utils.log('Enabled ' + extension, 'win32', 'success')) +
|
(await utils.log('Enabled ' + extension, 'win32', 'success', log_prefix)) +
|
||||||
` } elseif(php -m | findstr -i ${extension}) {\n` +
|
` } elseif(php -m | findstr -i ${extension}) {\n` +
|
||||||
(await utils.log(
|
(await utils.log(
|
||||||
'Extension ' + extension + ' was already enabled',
|
extension + ' was already enabled',
|
||||||
'win32',
|
'win32',
|
||||||
'success'
|
'success',
|
||||||
|
log_prefix
|
||||||
)) +
|
)) +
|
||||||
` }
|
` }
|
||||||
} catch [Exception] {\n` +
|
} catch [Exception] {\n` +
|
||||||
(await utils.log(extension + ' could not be enabled', 'win32', 'error')) +
|
(await utils.log(
|
||||||
|
extension + ' could not be enabled',
|
||||||
|
'win32',
|
||||||
|
'error',
|
||||||
|
log_prefix
|
||||||
|
)) +
|
||||||
` }\n`
|
` }\n`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -73,19 +68,26 @@ export async function enableExtensionWindows(extension: string) {
|
|||||||
*/
|
*/
|
||||||
export async function enableExtensionUnix(
|
export async function enableExtensionUnix(
|
||||||
extension: string,
|
extension: string,
|
||||||
os_version: string
|
os_version: string,
|
||||||
|
log_prefix: string
|
||||||
) {
|
) {
|
||||||
return (
|
return (
|
||||||
`if [ ! "$(php -m | grep -i ${extension})" ] && [ -e "$ext_dir/${extension}.so" ]; then
|
`if [ ! "$(php -m | grep -i ${extension})" ] && [ -e "$ext_dir/${extension}.so" ]; then
|
||||||
echo "${await utils.getExtensionPrefix(
|
echo "${await utils.getExtensionPrefix(
|
||||||
extension
|
extension
|
||||||
)}=${extension}" >> 'php -i | grep "Loaded Configuration" | sed -e "s|.*=>\s*||"'\n` +
|
)}=${extension}" >> 'php -i | grep "Loaded Configuration" | sed -e "s|.*=>\s*||"'\n` +
|
||||||
(await utils.log('Enabled ' + extension, os_version, 'success')) +
|
(await utils.log(
|
||||||
|
'Enabled ' + extension,
|
||||||
|
os_version,
|
||||||
|
'success',
|
||||||
|
log_prefix
|
||||||
|
)) +
|
||||||
`;\n elif [ "$(php -m | grep -i ${extension})" ]; then \n` +
|
`;\n elif [ "$(php -m | grep -i ${extension})" ]; then \n` +
|
||||||
(await utils.log(
|
(await utils.log(
|
||||||
'Extension ' + extension + ' was already enabled',
|
extension + ' was already enabled',
|
||||||
os_version,
|
os_version,
|
||||||
'success'
|
'success',
|
||||||
|
log_prefix
|
||||||
)) +
|
)) +
|
||||||
`; fi\n`
|
`; fi\n`
|
||||||
);
|
);
|
||||||
@ -99,14 +101,15 @@ export async function enableExtensionUnix(
|
|||||||
*/
|
*/
|
||||||
export async function addExtensionDarwin(
|
export async function addExtensionDarwin(
|
||||||
extension_csv: string,
|
extension_csv: string,
|
||||||
version: string
|
version: string,
|
||||||
|
log_prefix: string
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
let extensions: Array<string> = await utils.extensionArray(extension_csv);
|
let extensions: Array<string> = await utils.extensionArray(extension_csv);
|
||||||
let script: string = '\n';
|
let script: string = '\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
|
||||||
script += await enableExtensionUnix(extension, 'darwin');
|
script += await enableExtensionUnix(extension, 'darwin', log_prefix);
|
||||||
switch (await pecl.checkPECLExtension(extension)) {
|
switch (await pecl.checkPECLExtension(extension)) {
|
||||||
case true:
|
case true:
|
||||||
let install_command: string = '';
|
let install_command: string = '';
|
||||||
@ -136,13 +139,15 @@ export async function addExtensionDarwin(
|
|||||||
(await utils.log(
|
(await utils.log(
|
||||||
'Installed and enabled ' + extension,
|
'Installed and enabled ' + extension,
|
||||||
'darwin',
|
'darwin',
|
||||||
'success'
|
'success',
|
||||||
|
log_prefix
|
||||||
)) +
|
)) +
|
||||||
' || ' +
|
' || ' +
|
||||||
(await utils.log(
|
(await utils.log(
|
||||||
'Could not install ' + extension + ' on PHP' + version,
|
'Could not install ' + extension + ' on PHP' + version,
|
||||||
'darwin',
|
'darwin',
|
||||||
'error'
|
'error',
|
||||||
|
log_prefix
|
||||||
)) +
|
)) +
|
||||||
'; fi\n';
|
'; fi\n';
|
||||||
break;
|
break;
|
||||||
@ -155,7 +160,8 @@ export async function addExtensionDarwin(
|
|||||||
(await utils.log(
|
(await utils.log(
|
||||||
'Could not find ' + extension + ' for PHP' + version + ' on PECL',
|
'Could not find ' + extension + ' for PHP' + version + ' on PECL',
|
||||||
'darwin',
|
'darwin',
|
||||||
'error'
|
'error',
|
||||||
|
log_prefix
|
||||||
)) +
|
)) +
|
||||||
'; fi\n';
|
'; fi\n';
|
||||||
break;
|
break;
|
||||||
@ -172,14 +178,15 @@ export async function addExtensionDarwin(
|
|||||||
*/
|
*/
|
||||||
export async function addExtensionWindows(
|
export async function addExtensionWindows(
|
||||||
extension_csv: string,
|
extension_csv: string,
|
||||||
version: string
|
version: string,
|
||||||
|
log_prefix: string
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
let extensions: Array<string> = await utils.extensionArray(extension_csv);
|
let extensions: Array<string> = await utils.extensionArray(extension_csv);
|
||||||
let script: string = '\n';
|
let script: string = '\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
|
||||||
script += await enableExtensionWindows(extension);
|
script += await enableExtensionWindows(extension, log_prefix);
|
||||||
|
|
||||||
switch (await pecl.checkPECLExtension(extension)) {
|
switch (await pecl.checkPECLExtension(extension)) {
|
||||||
case true:
|
case true:
|
||||||
@ -209,13 +216,15 @@ export async function addExtensionWindows(
|
|||||||
(await utils.log(
|
(await utils.log(
|
||||||
'Installed and enabled ' + extension,
|
'Installed and enabled ' + extension,
|
||||||
'win32',
|
'win32',
|
||||||
'success'
|
'success',
|
||||||
|
log_prefix
|
||||||
)) +
|
)) +
|
||||||
' } catch [Exception] { ' +
|
' } catch [Exception] { ' +
|
||||||
(await utils.log(
|
(await utils.log(
|
||||||
'Could not install ' + extension + ' on PHP' + version,
|
'Could not install ' + extension + ' on PHP' + version,
|
||||||
'win32',
|
'win32',
|
||||||
'error'
|
'error',
|
||||||
|
log_prefix
|
||||||
)) +
|
)) +
|
||||||
' } }\n';
|
' } }\n';
|
||||||
break;
|
break;
|
||||||
@ -228,7 +237,8 @@ export async function addExtensionWindows(
|
|||||||
(await utils.log(
|
(await utils.log(
|
||||||
'Could not find ' + extension + ' for PHP' + version + ' on PECL',
|
'Could not find ' + extension + ' for PHP' + version + ' on PECL',
|
||||||
'win32',
|
'win32',
|
||||||
'error'
|
'error',
|
||||||
|
log_prefix
|
||||||
)) +
|
)) +
|
||||||
' } \n';
|
' } \n';
|
||||||
break;
|
break;
|
||||||
@ -245,14 +255,15 @@ export async function addExtensionWindows(
|
|||||||
*/
|
*/
|
||||||
export async function addExtensionLinux(
|
export async function addExtensionLinux(
|
||||||
extension_csv: string,
|
extension_csv: string,
|
||||||
version: string
|
version: string,
|
||||||
|
log_prefix: string
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
let extensions: Array<string> = await utils.extensionArray(extension_csv);
|
let extensions: Array<string> = await utils.extensionArray(extension_csv);
|
||||||
let script: string = '\n';
|
let script: string = '\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
|
||||||
script += await enableExtensionUnix(extension, 'linux');
|
script += await enableExtensionUnix(extension, 'linux', log_prefix);
|
||||||
|
|
||||||
let install_command: string = '';
|
let install_command: string = '';
|
||||||
switch (version + extension) {
|
switch (version + extension) {
|
||||||
@ -282,114 +293,17 @@ export async function addExtensionLinux(
|
|||||||
(await utils.log(
|
(await utils.log(
|
||||||
'Installed and enabled ' + extension,
|
'Installed and enabled ' + extension,
|
||||||
'linux',
|
'linux',
|
||||||
'success'
|
'success',
|
||||||
|
log_prefix
|
||||||
)) +
|
)) +
|
||||||
' || ' +
|
' || ' +
|
||||||
(await utils.log(
|
(await utils.log(
|
||||||
'Could not find php' + version + '-' + extension + ' on APT repository',
|
'Could not find php' + version + '-' + extension + ' on APT repository',
|
||||||
'linux',
|
'linux',
|
||||||
'error'
|
'error',
|
||||||
|
log_prefix
|
||||||
)) +
|
)) +
|
||||||
'; fi\n';
|
'; fi\n';
|
||||||
});
|
});
|
||||||
return script;
|
return script;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Add script to set custom ini values for unix
|
|
||||||
*
|
|
||||||
* @param ini_values_csv
|
|
||||||
*/
|
|
||||||
export async function addINIValuesUnix(
|
|
||||||
ini_values_csv: string
|
|
||||||
): Promise<string> {
|
|
||||||
let script: string = '\n';
|
|
||||||
let ini_values: Array<string> = await utils.INIArray(ini_values_csv);
|
|
||||||
await utils.asyncForEach(ini_values, async function(ini_value: string) {
|
|
||||||
// add script to set ini value
|
|
||||||
script += 'echo "' + ini_value + '" >> $ini_file\n';
|
|
||||||
});
|
|
||||||
return script;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add script to set custom ini values for windows
|
|
||||||
*
|
|
||||||
* @param ini_values_csv
|
|
||||||
*/
|
|
||||||
export async function addINIValuesWindows(
|
|
||||||
ini_values_csv: string
|
|
||||||
): Promise<string> {
|
|
||||||
let script: string = '\n';
|
|
||||||
let ini_values: Array<string> = await utils.INIArray(ini_values_csv);
|
|
||||||
await utils.asyncForEach(ini_values, async function(ini_value: string) {
|
|
||||||
// add script to set ini value
|
|
||||||
script += 'Add-Content C:\\tools\\php\\php.ini "' + ini_value + '"\n';
|
|
||||||
});
|
|
||||||
return script;
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function addCoverage(
|
|
||||||
coverage: string,
|
|
||||||
version: string,
|
|
||||||
os_version: string
|
|
||||||
): Promise<string> {
|
|
||||||
let script: string = '';
|
|
||||||
script += '\n';
|
|
||||||
coverage = coverage.toLowerCase();
|
|
||||||
// pcov
|
|
||||||
switch (coverage) {
|
|
||||||
case 'pcov':
|
|
||||||
// if version is 7.1 or newer
|
|
||||||
switch (version) {
|
|
||||||
default:
|
|
||||||
script += await addExtension('pcov', version, os_version);
|
|
||||||
script += await addINIValues('pcov.enabled=1', os_version);
|
|
||||||
|
|
||||||
// add command to disable xdebug and enable pcov
|
|
||||||
switch (os_version) {
|
|
||||||
case 'linux':
|
|
||||||
script += 'sudo sed -i "/xdebug/d" $ini_file\n';
|
|
||||||
break;
|
|
||||||
case 'darwin':
|
|
||||||
script += 'sudo sed -i \'\' "/xdebug/d" $ini_file\n';
|
|
||||||
break;
|
|
||||||
case 'win32':
|
|
||||||
script +=
|
|
||||||
'if(php -m | findstr -i xdebug) { Disable-PhpExtension xdebug C:\\tools\\php }\n';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// success
|
|
||||||
script += await utils.log(
|
|
||||||
'pcov enabled as coverage driver',
|
|
||||||
os_version,
|
|
||||||
'success'
|
|
||||||
);
|
|
||||||
// version is not supported
|
|
||||||
break;
|
|
||||||
case '5.6':
|
|
||||||
case '7.0':
|
|
||||||
script += await utils.log(
|
|
||||||
'pcov requires php 7.1 or newer',
|
|
||||||
os_version,
|
|
||||||
'warning'
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
//xdebug
|
|
||||||
case 'xdebug':
|
|
||||||
script += await addExtension('xdebug', version, os_version);
|
|
||||||
script += await utils.log(
|
|
||||||
'Xdebug enabled as coverage driver',
|
|
||||||
os_version,
|
|
||||||
'success'
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
// unknown coverage driver
|
|
||||||
default:
|
|
||||||
script = '';
|
|
||||||
}
|
|
||||||
return script;
|
|
||||||
}
|
|
@ -1,7 +1,9 @@
|
|||||||
import {exec} from '@actions/exec/lib/exec';
|
import {exec} from '@actions/exec/lib/exec';
|
||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
import * as utils from './utils';
|
import * as utils from './utils';
|
||||||
import * as features from './features';
|
import * as extensions from './extensions';
|
||||||
|
import * as config from './config';
|
||||||
|
import * as coverage from './coverage';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Run the script
|
* Run the script
|
||||||
@ -12,7 +14,7 @@ async function run() {
|
|||||||
let version: string = await utils.getInput('php-version', true);
|
let version: string = await utils.getInput('php-version', true);
|
||||||
let extension_csv: string = await utils.getInput('extension-csv', false);
|
let extension_csv: string = await utils.getInput('extension-csv', false);
|
||||||
let ini_values_csv: string = await utils.getInput('ini-values-csv', false);
|
let ini_values_csv: string = await utils.getInput('ini-values-csv', false);
|
||||||
let coverage: string = await utils.getInput('coverage', false);
|
let coverage_driver: string = await utils.getInput('coverage', false);
|
||||||
|
|
||||||
let os_version: string = process.platform;
|
let os_version: string = process.platform;
|
||||||
// check the os version and run the respective script
|
// check the os version and run the respective script
|
||||||
@ -23,9 +25,17 @@ async function run() {
|
|||||||
os_version
|
os_version
|
||||||
);
|
);
|
||||||
|
|
||||||
darwin += await features.addExtension(extension_csv, version, os_version);
|
darwin += await extensions.addExtension(
|
||||||
darwin += await features.addINIValues(ini_values_csv, os_version);
|
extension_csv,
|
||||||
darwin += await features.addCoverage(coverage, version, os_version);
|
version,
|
||||||
|
os_version
|
||||||
|
);
|
||||||
|
darwin += await config.addINIValues(ini_values_csv, os_version);
|
||||||
|
darwin += await coverage.addCoverage(
|
||||||
|
coverage_driver,
|
||||||
|
version,
|
||||||
|
os_version
|
||||||
|
);
|
||||||
await utils.writeScript('darwin.sh', version, darwin);
|
await utils.writeScript('darwin.sh', version, darwin);
|
||||||
await exec('sh ./' + version + 'darwin.sh ' + version);
|
await exec('sh ./' + version + 'darwin.sh ' + version);
|
||||||
} else if (os_version == 'win32') {
|
} else if (os_version == 'win32') {
|
||||||
@ -34,13 +44,17 @@ async function run() {
|
|||||||
version,
|
version,
|
||||||
os_version
|
os_version
|
||||||
);
|
);
|
||||||
windows += await features.addExtension(
|
windows += await extensions.addExtension(
|
||||||
extension_csv,
|
extension_csv,
|
||||||
version,
|
version,
|
||||||
os_version
|
os_version
|
||||||
);
|
);
|
||||||
windows += await features.addINIValues(ini_values_csv, os_version);
|
windows += await config.addINIValues(ini_values_csv, os_version);
|
||||||
windows += await features.addCoverage(coverage, version, os_version);
|
windows += await coverage.addCoverage(
|
||||||
|
coverage_driver,
|
||||||
|
version,
|
||||||
|
os_version
|
||||||
|
);
|
||||||
await utils.writeScript('win32.ps1', version, windows);
|
await utils.writeScript('win32.ps1', version, windows);
|
||||||
await exec('powershell .\\' + version + 'win32.ps1 -version ' + version);
|
await exec('powershell .\\' + version + 'win32.ps1 -version ' + version);
|
||||||
} else if (os_version == 'linux') {
|
} else if (os_version == 'linux') {
|
||||||
@ -49,9 +63,13 @@ async function run() {
|
|||||||
version,
|
version,
|
||||||
os_version
|
os_version
|
||||||
);
|
);
|
||||||
linux += await features.addExtension(extension_csv, version, os_version);
|
linux += await extensions.addExtension(
|
||||||
linux += await features.addINIValues(ini_values_csv, os_version);
|
extension_csv,
|
||||||
linux += await features.addCoverage(coverage, version, os_version);
|
version,
|
||||||
|
os_version
|
||||||
|
);
|
||||||
|
linux += await config.addINIValues(ini_values_csv, os_version);
|
||||||
|
linux += await coverage.addCoverage(coverage_driver, version, os_version);
|
||||||
await utils.writeScript('linux.sh', version, linux);
|
await utils.writeScript('linux.sh', version, linux);
|
||||||
await exec('./' + version + 'linux.sh ' + version);
|
await exec('./' + version + 'linux.sh ' + version);
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ export async function checkPECLExtension(extension: string): Promise<boolean> {
|
|||||||
maxRetries: 2
|
maxRetries: 2
|
||||||
});
|
});
|
||||||
const response: hc.HttpClientResponse = await http.get(
|
const response: hc.HttpClientResponse = await http.get(
|
||||||
'https://pecl.php.net/package/' + extension
|
'https://pecl.php.net/json.php?package=' + extension
|
||||||
);
|
);
|
||||||
return response.message.statusCode === 200;
|
return response.message.statusCode === 200;
|
||||||
}
|
}
|
||||||
|
@ -6,36 +6,38 @@ if($version -eq '7.4') {
|
|||||||
$version = '7.4RC'
|
$version = '7.4RC'
|
||||||
}
|
}
|
||||||
|
|
||||||
echo "Installing PhpManager"
|
Write-Host "Installing PhpManager" -ForegroundColor Blue
|
||||||
Install-Module -Name PhpManager -Force -Scope CurrentUser
|
Install-Module -Name PhpManager -Force -Scope CurrentUser
|
||||||
|
|
||||||
$installed = $($(php -v)[0] -join '')[4..6] -join ''
|
$installed = $($(php -v)[0] -join '')[4..6] -join ''
|
||||||
if($installed -ne $version) {
|
if($installed -ne $version) {
|
||||||
if($version -lt '7.0') {
|
if($version -lt '7.0') {
|
||||||
echo "Installing VcRedist"
|
Write-Host "Installing VcRedist"
|
||||||
Install-Module -Name VcRedist -Force
|
Install-Module -Name VcRedist -Force
|
||||||
}
|
}
|
||||||
echo "Installing PHP"
|
Write-Host "Installing PHP" -ForegroundColor Blue
|
||||||
Uninstall-Php C:\tools\php
|
Uninstall-Php C:\tools\php
|
||||||
Install-Php -Version $version -Architecture x86 -ThreadSafe $true -InstallVC -Path C:\tools\php$version -TimeZone UTC -InitialPhpIni Production -Force
|
Install-Php -Version $version -Architecture x86 -ThreadSafe $true -InstallVC -Path C:\tools\php$version -TimeZone UTC -InitialPhpIni Production -Force
|
||||||
echo "Switch PHP"
|
Write-Host "Switch PHP" -ForegroundColor Blue
|
||||||
(Get-PhpSwitcher).targets
|
(Get-PhpSwitcher).targets
|
||||||
Initialize-PhpSwitcher -Alias C:\tools\php -Scope CurrentUser -Force
|
Initialize-PhpSwitcher -Alias C:\tools\php -Scope CurrentUser -Force
|
||||||
Add-PhpToSwitcher -Name $version -Path C:\tools\php$version -Force
|
Add-PhpToSwitcher -Name $version -Path C:\tools\php$version -Force
|
||||||
Switch-Php $version -Force
|
Switch-Php $version -Force
|
||||||
}
|
}
|
||||||
|
|
||||||
echo "Housekeeping in PHP.ini, enabling openssl"
|
Write-Host "Housekeeping in PHP.ini, enabling openssl" -ForegroundColor Blue
|
||||||
|
$ext_dir = "C:\tools\php\ext"
|
||||||
Add-Content C:\tools\php\php.ini "date.timezone = 'UTC'"
|
Add-Content C:\tools\php\php.ini "date.timezone = 'UTC'"
|
||||||
Set-PhpIniKey extension_dir C:\tools\php\ext
|
Set-PhpIniKey extension_dir $ext_dir
|
||||||
|
|
||||||
if($version -lt '7.4') {
|
if($version -lt '7.4') {
|
||||||
Enable-PhpExtension openssl
|
Enable-PhpExtension openssl
|
||||||
} else {
|
} else {
|
||||||
Add-Content C:\tools\php\php.ini "extension=php_openssl.dll"
|
Add-Content C:\tools\php\php.ini "extension=php_openssl.dll"
|
||||||
|
Copy-Item "php_pcov.dll" -Destination $ext_dir"\php_pcov.dll"
|
||||||
}
|
}
|
||||||
|
|
||||||
echo "Installing Composer"
|
Write-Host "Installing Composer" -ForegroundColor Blue
|
||||||
Install-Composer -Scope System -Path C:\tools\php
|
Install-Composer -Scope System -Path C:\tools\php
|
||||||
$ext_dir = Get-PhpIniKey extension_dir
|
|
||||||
php -v
|
php -v
|
||||||
composer -V
|
composer -V
|
62
src/utils.ts
62
src/utils.ts
@ -70,33 +70,22 @@ export async function readScript(
|
|||||||
path.join(__dirname, '../src/scripts/7.4.sh'),
|
path.join(__dirname, '../src/scripts/7.4.sh'),
|
||||||
'utf8'
|
'utf8'
|
||||||
);
|
);
|
||||||
case '7.3':
|
|
||||||
default:
|
|
||||||
return fs.readFileSync(
|
|
||||||
path.join(__dirname, '../src/scripts/' + filename),
|
|
||||||
'utf8'
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
case 'linux':
|
case 'linux':
|
||||||
switch (version) {
|
switch (version) {
|
||||||
case '7.4':
|
case '7.4':
|
||||||
await readFiles74(['scripts/xdebug.sh', 'scripts/pcov.sh']);
|
await readFiles74(['scripts/xdebug.sh', 'scripts/pcov.sh']);
|
||||||
return fs.readFileSync(
|
break;
|
||||||
path.join(__dirname, '../src/scripts/' + filename),
|
|
||||||
'utf8'
|
|
||||||
);
|
|
||||||
case '7.3':
|
|
||||||
default:
|
|
||||||
return fs.readFileSync(
|
|
||||||
path.join(__dirname, '../src/scripts/' + filename),
|
|
||||||
'utf8'
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
case 'win32':
|
case 'win32':
|
||||||
return fs.readFileSync(
|
switch (version) {
|
||||||
path.join(__dirname, '../src/scripts/' + filename),
|
case '7.4':
|
||||||
'utf8'
|
await readFiles74(['ext/php_pcov.dll']);
|
||||||
);
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
return await log(
|
return await log(
|
||||||
'Platform ' + os_version + ' is not supported',
|
'Platform ' + os_version + ' is not supported',
|
||||||
@ -104,6 +93,11 @@ export async function readScript(
|
|||||||
'error'
|
'error'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return fs.readFileSync(
|
||||||
|
path.join(__dirname, '../src/scripts/' + filename),
|
||||||
|
'utf8'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -163,13 +157,22 @@ export async function INIArray(ini_values_csv: string): Promise<Array<string>> {
|
|||||||
export async function log(
|
export async function log(
|
||||||
message: string,
|
message: string,
|
||||||
os_version: string,
|
os_version: string,
|
||||||
log_type: string
|
log_type: string,
|
||||||
|
prefix = ''
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
const unix_color: any = {
|
const unix_color: any = {
|
||||||
error: '31',
|
error: '31',
|
||||||
success: '32',
|
success: '32',
|
||||||
warning: '33'
|
warning: '33'
|
||||||
};
|
};
|
||||||
|
switch (prefix) {
|
||||||
|
case '':
|
||||||
|
prefix = prefix;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
prefix = prefix + ': ';
|
||||||
|
break;
|
||||||
|
}
|
||||||
switch (os_version) {
|
switch (os_version) {
|
||||||
case 'win32':
|
case 'win32':
|
||||||
const color: any = {
|
const color: any = {
|
||||||
@ -177,19 +180,30 @@ export async function log(
|
|||||||
success: 'green',
|
success: 'green',
|
||||||
warning: 'yellow'
|
warning: 'yellow'
|
||||||
};
|
};
|
||||||
return "Write-Host '" + message + "' -ForegroundColor " + color[log_type];
|
return (
|
||||||
|
"Write-Host '" +
|
||||||
|
prefix +
|
||||||
|
message +
|
||||||
|
"' -ForegroundColor " +
|
||||||
|
color[log_type]
|
||||||
|
);
|
||||||
|
|
||||||
case 'linux':
|
case 'linux':
|
||||||
case 'darwin':
|
case 'darwin':
|
||||||
default:
|
default:
|
||||||
return (
|
return (
|
||||||
'echo "\\033[' + unix_color[log_type] + ';1m' + message + '\\033[0m"'
|
'echo "\\033[' +
|
||||||
|
unix_color[log_type] +
|
||||||
|
';1m' +
|
||||||
|
prefix +
|
||||||
|
message +
|
||||||
|
'\\033[0m"'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getExtensionPrefix(extension: string): Promise<string> {
|
export async function getExtensionPrefix(extension: string): Promise<string> {
|
||||||
let zend: Array<string> = ['xdebug', 'opcache'];
|
let zend: Array<string> = ['xdebug', 'opcache', 'ioncube', 'eaccelerator'];
|
||||||
switch (zend.indexOf(extension)) {
|
switch (zend.indexOf(extension)) {
|
||||||
case 0:
|
case 0:
|
||||||
case 1:
|
case 1:
|
||||||
|
Reference in New Issue
Block a user