mirror of
https://github.com/shivammathur/setup-php.git
synced 2025-08-02 11:47:19 +07:00
Compare commits
29 Commits
Author | SHA1 | Date | |
---|---|---|---|
3087ceb811 | |||
05e2b0d1e9 | |||
dd5c977988 | |||
c1c0acc338 | |||
409e055931 | |||
46a875ad7e | |||
7e81c058fb | |||
754ab9515b | |||
f866c880c2 | |||
eb21cb8fb3 | |||
aee6b953c3 | |||
21c3c8db47 | |||
c0e0d9d98e | |||
5ab8ec4a99 | |||
ec3c220bb2 | |||
17d90ace86 | |||
ba5306eea9 | |||
06929bdf4c | |||
e97e822eff | |||
0f97f445fb | |||
507cc5e95d | |||
2a30f9d208 | |||
eaf140ca8b | |||
dcd432d918 | |||
91a03a2865 | |||
ca33947c62 | |||
932b66f3fc | |||
651d2619bb | |||
16f13a69eb |
17
.github/workflows/workflow.yml
vendored
17
.github/workflows/workflow.yml
vendored
@ -1,24 +1,27 @@
|
|||||||
name: Main workflow
|
name: Main workflow
|
||||||
on: [push]
|
on: [push, pull_request]
|
||||||
jobs:
|
jobs:
|
||||||
run:
|
run:
|
||||||
name: Run
|
name: Run
|
||||||
runs-on: ${{ matrix.operating-system }}
|
runs-on: ${{ matrix.operating-system }}
|
||||||
strategy:
|
strategy:
|
||||||
max-parallel: 8
|
fail-fast: false
|
||||||
|
max-parallel: 15
|
||||||
matrix:
|
matrix:
|
||||||
operating-system: [ubuntu-latest, windows-latest, macOS-latest]
|
operating-system: [ubuntu-latest, windows-latest, macOS-latest]
|
||||||
php-versions: ['5.6', '7.0', '7.1', '7.2', '7.3']
|
php-versions: ['5.6', '7.0', '7.1', '7.2', '7.3']
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@master
|
uses: actions/checkout@master
|
||||||
|
with:
|
||||||
|
fetch-depth: 1
|
||||||
|
|
||||||
- name: Set Node.js 10.x
|
- name: Setup Node.js 10.x
|
||||||
uses: actions/setup-node@master
|
uses: actions/setup-node@master
|
||||||
with:
|
with:
|
||||||
version: 10.x
|
node-version: 10.x
|
||||||
|
|
||||||
- name: Installing NPM
|
- name: Installing NPM packages
|
||||||
run: npm install
|
run: npm install
|
||||||
|
|
||||||
- name: Run tests and send coverage
|
- name: Run tests and send coverage
|
||||||
@ -30,8 +33,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
|
||||||
|
115
README.md
115
README.md
@ -7,14 +7,15 @@
|
|||||||
# Setup PHP in GitHub Actions
|
# Setup PHP in GitHub Actions
|
||||||
|
|
||||||
<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" title="GitHub action to 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/blob/master/LICENSE"><img alt="LICENSE" src="https://img.shields.io/badge/license-MIT-428f7e.svg"></a>
|
<a href="https://codecov.io/gh/shivammathur/setup-php" title="Code coverage"><img alt="Codecov Code Coverage" src="https://codecov.io/gh/shivammathur/setup-php/branch/master/graph/badge.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://github.com/shivammathur/setup-php/blob/master/LICENSE" title="license"><img alt="LICENSE" src="https://img.shields.io/badge/license-MIT-428f7e.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="#tada-php-support" title="PHP Versions Supported"><img alt="PHP Versions Supported" src="https://img.shields.io/badge/php-%3E%3D%205.6-8892BF.svg"></a>
|
||||||
<a href="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.patreon.com/shivammathur" title="Support Shivam Mathur on Patreon"><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" title="Contact Shivam Mathur on Codementor"><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 "GitHub 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 "How to use this") section and [examples](#examples "Examples of use") 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,66 @@ 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 "List of PHP versions supported on this GitHub Action")
|
||||||
|
|
||||||
|
```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`.
|
||||||
|
It is much faster than `Xdebug`.
|
||||||
|
If your source code directory is other than `src`, `lib` or, `app`, specify `pcov.directory` 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`.
|
||||||
|
Consider disabling the coverage using this PHP action for these reasons.
|
||||||
|
- You are not generating coverage reports while testing.
|
||||||
|
- It will disable `Xdebug`, which will have a positive impact on PHP performance.
|
||||||
|
- You are using `phpdbg`.
|
||||||
|
|
||||||
|
```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 "Metadata for this GitHub Action") and usage below for more info.
|
||||||
|
|
||||||
### Basic Usage
|
### Basic Usage
|
||||||
|
|
||||||
@ -86,9 +110,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 +142,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
|
||||||
@ -129,13 +153,30 @@ jobs:
|
|||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Examples
|
||||||
|
|
||||||
|
Examples for setting up this GitHub Action with different PHP Frameworks/Packages.
|
||||||
|
|
||||||
|
|Framework/Package|Runs on|Workflow|
|
||||||
|
|--- |--- |--- |
|
||||||
|
|CodeIgniter|`macOS`, `ubuntu` and `windows`|[codeigniter.yml](./examples/codeigniter.yml "GitHub Action for CodeIgniter")|
|
||||||
|
|Laravel with `MySQL` and `Redis`|`ubuntu`|[laravel-mysql.yml](./examples/laravel-mysql.yml "GitHub Action for Laravel with MySQL and Redis")|
|
||||||
|
|Laravel with `PostgreSQL` and `Redis`|`ubuntu`|[laravel-postgres.yml](./examples/laravel-postgres.yml "GitHub Action for Laravel with PostgreSQL and Redis")|
|
||||||
|
|Laravel without services|`macOS`, `ubuntu` and `windows`|[laravel.yml](./examples/laravel.yml "GitHub Action for Laravel without services")|
|
||||||
|
|Slim Framework|`macOS`, `ubuntu` and `windows`|[slim-framework.yml](./examples/slim-framework.yml "GitHub Action for Slim Framework")|
|
||||||
|
|Symfony with `MySQL`|`ubuntu`|[symfony-mysql.yml](./examples/symfony-mysql.yml "GitHub Action for Symfony with MySQL")|
|
||||||
|
|Symfony with `PostgreSQL`|`ubuntu`|[symfony-postgres.yml](./examples/symfony-postgres.yml "GitHub Action for Symfony with PostgreSQL")|
|
||||||
|
|Yii2 Starter Kit with `MySQL`|`ubuntu`|[yii2-mysql.yml](./examples/yii2-mysql.yml "GitHub Action for Yii2 Starter Kit with MySQL")|
|
||||||
|
|Yii2 Starter Kit with `PostgreSQL`|`ubuntu`|[yii2-postgres.yml](./examples/yii2-postgres.yml "GitHub Action for Yii2 Starter Kit with PostgreSQL")|
|
||||||
|
|Zend Framework|`macOS`, `ubuntu` and `windows`|[zend-framework.yml](./examples/zend-framework.yml "GitHub Action for Zend Framework")|
|
||||||
|
|
||||||
## :scroll: License
|
## :scroll: License
|
||||||
|
|
||||||
The scripts and documentation in this project are released under the [MIT License](LICENSE). This project has multiple [dependencies](https://github.com/shivammathur/setup-php/network/dependencies) and their licenses can be found in their respective repositories.
|
The scripts and documentation in this project are released under the [MIT License](LICENSE "License for shivammathur/setup-php"). This project has multiple [dependencies](https://github.com/shivammathur/setup-php/network/dependencies "Dependencies for this PHP Action") and their licenses can be found in their respective repositories.
|
||||||
|
|
||||||
## :+1: Contributions
|
## :+1: Contributions
|
||||||
|
|
||||||
Contributions are welcome! See [Contributor's Guide](.github/CONTRIBUTING.md).
|
Contributions are welcome! See [Contributor's Guide](.github/CONTRIBUTING.md "shivammathur/setup-php contribution guide").
|
||||||
|
|
||||||
## :sparkling_heart: Support this project
|
## :sparkling_heart: Support this project
|
||||||
|
|
||||||
@ -144,14 +185,14 @@ Contributions are welcome! See [Contributor's Guide](.github/CONTRIBUTING.md).
|
|||||||
|
|
||||||
## :bookmark: This action uses the following works
|
## :bookmark: This action uses the following works
|
||||||
|
|
||||||
- [powershell-phpmanager](https://github.com/mlocati/powershell-phpmanager)
|
- [powershell-phpmanager](https://github.com/mlocati/powershell-phpmanager "Package to handle PHP on windows")
|
||||||
- [Homebrew](https://brew.sh/)
|
- [Homebrew](https://brew.sh/ "MacOS package manager")
|
||||||
- [ppa:ondrej/php](https://launchpad.net/~ondrej/+archive/ubuntu/php)
|
- [ppa:ondrej/php](https://launchpad.net/~ondrej/+archive/ubuntu/php "Pre-compiled ubuntu packages")
|
||||||
- [exolnet/homebrew-deprecated](https://github.com/eXolnet/homebrew-deprecated)
|
- [exolnet/homebrew-deprecated](https://github.com/eXolnet/homebrew-deprecated "Pre-compiled deprecated PHP for macOS")
|
||||||
- [phpbrew](https://github.com/phpbrew/phpbrew)
|
- [phpbrew](https://github.com/phpbrew/phpbrew "PHP packages manager")
|
||||||
|
|
||||||
## :bookmark_tabs: Further Reading
|
## :bookmark_tabs: Further Reading
|
||||||
|
|
||||||
- [About GitHub Actions](https://github.com/features/actions)
|
- [About GitHub Actions](https://github.com/features/actions "GitHub Actions")
|
||||||
- [GitHub Actions Syntax](https://help.github.com/en/articles/workflow-syntax-for-github-actions)
|
- [GitHub Actions Syntax](https://help.github.com/en/articles/workflow-syntax-for-github-actions "GitHub Actions Syntax")
|
||||||
- [Other Awesome Actions](https://github.com/sdras/awesome-actions)
|
- [Other Awesome Actions](https://github.com/sdras/awesome-actions "List of Awesome GitHub Actions")
|
||||||
|
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,201 +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 -MinimumStability stable'
|
|
||||||
);
|
|
||||||
expect(win32).toContain(
|
|
||||||
'Install-PhpExtension pcov -MinimumStability stable'
|
|
||||||
);
|
|
||||||
win32 = await features.addExtension('xdebug, pcov', '7.4', 'win32');
|
|
||||||
expect(win32).toContain(
|
|
||||||
'Install-PhpExtension xdebug -MinimumStability alpha'
|
|
||||||
);
|
|
||||||
expect(win32).toContain(
|
|
||||||
'Install-PhpExtension pcov -MinimumStability alpha'
|
|
||||||
);
|
|
||||||
|
|
||||||
win32 = await features.addExtension('does_not_exist', '7.2', 'win32');
|
|
||||||
expect(win32).toContain('Could not find extension: does_not_exist');
|
|
||||||
|
|
||||||
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', '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('xdebug', '5.6', 'darwin');
|
|
||||||
expect(darwin).toContain('sudo pecl install xdebug-2.5.5');
|
|
||||||
|
|
||||||
darwin = await features.addExtension('does_not_exist', '7.2', 'darwin');
|
|
||||||
expect(darwin).toContain('Could not find extension: does_not_exist');
|
|
||||||
|
|
||||||
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');
|
|
||||||
expect(win32).toContain(
|
|
||||||
'Install-PhpExtension xdebug -MinimumStability alpha'
|
|
||||||
);
|
|
||||||
|
|
||||||
win32 = await features.addCoverage('xdebug', '7.3', 'win32');
|
|
||||||
expect(win32).toContain(
|
|
||||||
'Install-PhpExtension xdebug -MinimumStability stable'
|
|
||||||
);
|
|
||||||
|
|
||||||
win32 = await features.addCoverage('pcov', '7.4', 'win32');
|
|
||||||
expect(win32).toContain(
|
|
||||||
'Install-PhpExtension pcov -MinimumStability alpha'
|
|
||||||
);
|
|
||||||
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 -MinimumStability stable'
|
|
||||||
);
|
|
||||||
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(
|
|
||||||
'sudo DEBIAN_FRONTEND=noninteractive apt install -y php7.4-xdebug'
|
|
||||||
);
|
|
||||||
|
|
||||||
linux = await features.addCoverage('pcov', '7.4', 'linux');
|
|
||||||
expect(linux).toContain(
|
|
||||||
'sudo DEBIAN_FRONTEND=noninteractive apt install -y php7.4-pcov'
|
|
||||||
);
|
|
||||||
expect(linux).toContain(
|
|
||||||
"sudo phpdismod xdebug || echo 'xdebug not installed'"
|
|
||||||
);
|
|
||||||
expect(linux).toContain("sudo phpenmod pcov || echo 'pcov not installed'");
|
|
||||||
|
|
||||||
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('sudo pecl install xdebug');
|
|
||||||
|
|
||||||
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('sudo pecl install pcov');
|
|
||||||
expect(darwin).toContain('sudo sed -i \'\' "/xdebug/d" $ini_file\n');
|
|
||||||
|
|
||||||
darwin = await features.addCoverage('', '7.4', 'win32');
|
|
||||||
expect(darwin).toEqual('');
|
|
||||||
});
|
|
||||||
});
|
|
15
__tests__/pecl.test.ts
Normal file
15
__tests__/pecl.test.ts
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
import * as pecl from '../src/pecl';
|
||||||
|
|
||||||
|
let valid_extensions = ['xdebug', 'pcov'];
|
||||||
|
jest.mock('../src/pecl', () => ({
|
||||||
|
checkPECLExtension: jest.fn().mockImplementation(extension => {
|
||||||
|
return valid_extensions.indexOf(extension) !== -1;
|
||||||
|
})
|
||||||
|
}));
|
||||||
|
|
||||||
|
describe('pecl tests', () => {
|
||||||
|
it('checking checkPECLExtension', async () => {
|
||||||
|
expect(await pecl.checkPECLExtension('extensionDoesNotExist')).toBe(false);
|
||||||
|
expect(await pecl.checkPECLExtension('xdebug')).toBe(true);
|
||||||
|
});
|
||||||
|
});
|
@ -1,14 +1,6 @@
|
|||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import * as utils from '../src/utils';
|
import * as utils from '../src/utils';
|
||||||
import * as pecl from '../src/pecl';
|
|
||||||
|
|
||||||
let valid_extensions = ['xdebug', 'pcov'];
|
|
||||||
jest.mock('../src/pecl', () => ({
|
|
||||||
checkPECLExtension: jest.fn().mockImplementation(extension => {
|
|
||||||
return valid_extensions.indexOf(extension) !== -1;
|
|
||||||
})
|
|
||||||
}));
|
|
||||||
|
|
||||||
jest.mock('@actions/core', () => ({
|
jest.mock('@actions/core', () => ({
|
||||||
getInput: jest.fn().mockImplementation(key => {
|
getInput: jest.fn().mockImplementation(key => {
|
||||||
@ -45,24 +37,26 @@ describe('Utils tests', () => {
|
|||||||
|
|
||||||
it('checking readScripts', async () => {
|
it('checking readScripts', async () => {
|
||||||
let rc: string = fs.readFileSync(
|
let rc: string = fs.readFileSync(
|
||||||
path.join(__dirname, '../src/7.4.sh'),
|
path.join(__dirname, '../src/scripts/7.4.sh'),
|
||||||
'utf8'
|
'utf8'
|
||||||
);
|
);
|
||||||
let darwin: string = fs.readFileSync(
|
let darwin: string = fs.readFileSync(
|
||||||
path.join(__dirname, '../src/darwin.sh'),
|
path.join(__dirname, '../src/scripts/darwin.sh'),
|
||||||
'utf8'
|
'utf8'
|
||||||
);
|
);
|
||||||
let linux: string = fs.readFileSync(
|
let linux: string = fs.readFileSync(
|
||||||
path.join(__dirname, '../src/linux.sh'),
|
path.join(__dirname, '../src/scripts/linux.sh'),
|
||||||
'utf8'
|
'utf8'
|
||||||
);
|
);
|
||||||
let win32: string = fs.readFileSync(
|
let win32: string = fs.readFileSync(
|
||||||
path.join(__dirname, '../src/win32.ps1'),
|
path.join(__dirname, '../src/scripts/win32.ps1'),
|
||||||
'utf8'
|
'utf8'
|
||||||
);
|
);
|
||||||
expect(await utils.readScript('darwin.sh', '7.4', 'darwin')).toBe(rc);
|
expect(await utils.readScript('darwin.sh', '7.4', 'darwin')).toBe(rc);
|
||||||
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('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'
|
||||||
@ -88,6 +82,9 @@ describe('Utils tests', () => {
|
|||||||
'c',
|
'c',
|
||||||
'd'
|
'd'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
expect(await utils.extensionArray('')).toEqual([]);
|
||||||
|
expect(await utils.extensionArray(' ')).toEqual([]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('checking INIArray', async () => {
|
it('checking INIArray', async () => {
|
||||||
@ -96,41 +93,69 @@ describe('Utils tests', () => {
|
|||||||
'b=2',
|
'b=2',
|
||||||
'c=3'
|
'c=3'
|
||||||
]);
|
]);
|
||||||
|
expect(await utils.INIArray('')).toEqual([]);
|
||||||
|
expect(await utils.INIArray(' ')).toEqual([]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('checking log', async () => {
|
it('checking log', async () => {
|
||||||
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 -e "\\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 -e "\\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 -e "\\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 -e "\\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 -e "\\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 -e "\\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 checkPECLExtension', async () => {
|
it('checking log with prefix', async () => {
|
||||||
expect(await pecl.checkPECLExtension('extensionDoesNotExist')).toBe(false);
|
let message: string = 'Test message';
|
||||||
expect(await pecl.checkPECLExtension('xdebug')).toBe(true);
|
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 () => {
|
||||||
|
expect(await utils.getExtensionPrefix('extensionDoesNotExist')).toEqual(
|
||||||
|
'extension'
|
||||||
|
);
|
||||||
|
expect(await utils.getExtensionPrefix('xsl')).toEqual('extension');
|
||||||
|
expect(await utils.getExtensionPrefix('xdebug')).toEqual('zend_extension');
|
||||||
|
expect(await utils.getExtensionPrefix('opcache')).toEqual('zend_extension');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -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'
|
||||||
|
25
examples/codeigniter.yml
Normal file
25
examples/codeigniter.yml
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
# GitHub Action for CodeIgniter
|
||||||
|
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
|
||||||
|
run: vendor/bin/phpunit --coverage-text
|
||||||
|
shell: pwsh
|
58
examples/laravel-mysql.yml
Normal file
58
examples/laravel-mysql.yml
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
# GitHub Action for Laravel with MySQL and Redis
|
||||||
|
name: Testing Laravel with MySQL
|
||||||
|
on: [push, pull_request]
|
||||||
|
jobs:
|
||||||
|
laravel:
|
||||||
|
name: Laravel (PHP ${{ matrix.php-versions }})
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
env:
|
||||||
|
DB_PASSWORD: password
|
||||||
|
BROADCAST_DRIVER: log
|
||||||
|
CACHE_DRIVER: redis
|
||||||
|
QUEUE_CONNECTION: redis
|
||||||
|
SESSION_DRIVER: redis
|
||||||
|
services:
|
||||||
|
mysql:
|
||||||
|
image: mysql:5.7
|
||||||
|
env:
|
||||||
|
MYSQL_ALLOW_EMPTY_PASSWORD: false
|
||||||
|
MYSQL_ROOT_PASSWORD: password
|
||||||
|
MYSQL_DATABASE: laravel
|
||||||
|
ports:
|
||||||
|
- 3306
|
||||||
|
options: --health-cmd="mysqladmin ping" --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, 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.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.mysql.ports['3306'] }}
|
||||||
|
- name: Test with phpunit
|
||||||
|
run: vendor/bin/phpunit --coverage-text
|
||||||
|
env:
|
||||||
|
DB_PORT: ${{ job.services.mysql.ports['3306'] }}
|
62
examples/laravel-postgres.yml
Normal file
62
examples/laravel-postgres.yml
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
# GitHub Action for Laravel with PostgreSQL and Redis
|
||||||
|
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] }}
|
33
examples/laravel.yml
Normal file
33
examples/laravel.yml
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
# GitHub Action for Laravel
|
||||||
|
name: 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
|
||||||
|
run: vendor/bin/phpunit --coverage-text
|
||||||
|
shell: pwsh
|
25
examples/slim-framework.yml
Normal file
25
examples/slim-framework.yml
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
# GitHub Action for Slim Framework
|
||||||
|
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
|
||||||
|
run: vendor/bin/phpunit --coverage-text
|
||||||
|
shell: pwsh
|
45
examples/symfony-mysql.yml
Normal file
45
examples/symfony-mysql.yml
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
# GitHub Action for Symfony with MySQL
|
||||||
|
name: Testing Symfony with MySQL
|
||||||
|
on: [push, pull_request]
|
||||||
|
jobs:
|
||||||
|
symfony:
|
||||||
|
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
|
45
examples/symfony-postgres.yml
Normal file
45
examples/symfony-postgres.yml
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
# GitHub Action for Symfony with PostgreSQL
|
||||||
|
name: Testing Symfony with PostgreSQL
|
||||||
|
on: [push, pull_request]
|
||||||
|
jobs:
|
||||||
|
symfony:
|
||||||
|
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
|
30
examples/symfony.yml
Normal file
30
examples/symfony.yml
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
# GitHub Action for Symfony
|
||||||
|
name: Testing Symfony
|
||||||
|
on: [push, pull_request]
|
||||||
|
jobs:
|
||||||
|
symfony:
|
||||||
|
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
|
61
examples/yii2-mysql.yml
Normal file
61
examples/yii2-mysql.yml
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
# GitHub Action for Yii Framework with MySQL
|
||||||
|
name: Testing Yii2 with MySQL
|
||||||
|
on: [push, pull_request]
|
||||||
|
jobs:
|
||||||
|
yii:
|
||||||
|
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:
|
||||||
|
node-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
|
61
examples/yii2-postgres.yml
Normal file
61
examples/yii2-postgres.yml
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
# GitHub Action for Yii Framework with PostgreSQL
|
||||||
|
name: Testing Yii2 with PostgreSQL
|
||||||
|
on: [push, pull_request]
|
||||||
|
jobs:
|
||||||
|
yii:
|
||||||
|
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:
|
||||||
|
node-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
|
27
examples/zend-framework.yml
Normal file
27
examples/zend-framework.yml
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
# GitHub Action for Zend Framework
|
||||||
|
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
|
||||||
|
run: vendor/bin/phpunit --coverage-text
|
||||||
|
shell: pwsh
|
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;
|
245
lib/extensions.js
Normal file
245
lib/extensions.js
Normal file
@ -0,0 +1,245 @@
|
|||||||
|
"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 pecl = __importStar(require("./pecl"));
|
||||||
|
function addExtension(extension_csv, version, os_version, log_prefix = 'Add Extension') {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
switch (os_version) {
|
||||||
|
case 'win32':
|
||||||
|
return yield addExtensionWindows(extension_csv, version, log_prefix);
|
||||||
|
case 'darwin':
|
||||||
|
return yield addExtensionDarwin(extension_csv, version, log_prefix);
|
||||||
|
case 'linux':
|
||||||
|
return yield addExtensionLinux(extension_csv, version, log_prefix);
|
||||||
|
default:
|
||||||
|
return yield utils.log('Platform ' + os_version + ' is not supported', os_version, 'error', log_prefix);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
exports.addExtension = addExtension;
|
||||||
|
/**
|
||||||
|
* Enable extensions which are installed but not enabled on windows
|
||||||
|
*
|
||||||
|
* @param extension
|
||||||
|
*/
|
||||||
|
function enableExtensionWindows(extension, log_prefix) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
return (`try {
|
||||||
|
$exist = Test-Path -Path $ext_dir\\php_${extension}.dll
|
||||||
|
if(!(php -m | findstr -i ${extension}) -and $exist) {
|
||||||
|
Add-Content C:\\tools\\php\\php.ini "${yield utils.getExtensionPrefix(extension)}=php_${extension}.dll"\n` +
|
||||||
|
(yield utils.log('Enabled ' + extension, 'win32', 'success', log_prefix)) +
|
||||||
|
` } elseif(php -m | findstr -i ${extension}) {\n` +
|
||||||
|
(yield utils.log(extension + ' was already enabled', 'win32', 'success', log_prefix)) +
|
||||||
|
` }
|
||||||
|
} catch [Exception] {\n` +
|
||||||
|
(yield utils.log(extension + ' could not be enabled', 'win32', 'error', log_prefix)) +
|
||||||
|
` }\n`);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
exports.enableExtensionWindows = enableExtensionWindows;
|
||||||
|
/**
|
||||||
|
* Enable extensions which are installed but not enabled on unix
|
||||||
|
*
|
||||||
|
* @param extension
|
||||||
|
* @param os_version
|
||||||
|
*/
|
||||||
|
function enableExtensionUnix(extension, os_version, log_prefix) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
return (`if [ ! "$(php -m | grep -i ${extension})" ] && [ -e "$ext_dir/${extension}.so" ]; then
|
||||||
|
echo "${yield utils.getExtensionPrefix(extension)}=${extension}" >> $ini_file\n` +
|
||||||
|
(yield utils.log('Enabled ' + extension, os_version, 'success', log_prefix)) +
|
||||||
|
`;\n elif [ "$(php -m | grep -i ${extension})" ]; then \n` +
|
||||||
|
(yield utils.log(extension + ' was already enabled', os_version, 'success', log_prefix)) +
|
||||||
|
`; fi\n`);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
exports.enableExtensionUnix = enableExtensionUnix;
|
||||||
|
/**
|
||||||
|
* Install and enable extensions for darwin
|
||||||
|
*
|
||||||
|
* @param extension_csv
|
||||||
|
* @param version
|
||||||
|
*/
|
||||||
|
function addExtensionDarwin(extension_csv, version, log_prefix) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
let extensions = yield utils.extensionArray(extension_csv);
|
||||||
|
let script = '\n';
|
||||||
|
yield utils.asyncForEach(extensions, function (extension) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
extension = extension.toLowerCase();
|
||||||
|
// add script to enable extension is already installed along with php
|
||||||
|
script += yield enableExtensionUnix(extension, 'darwin', log_prefix);
|
||||||
|
switch (yield pecl.checkPECLExtension(extension)) {
|
||||||
|
case true:
|
||||||
|
let install_command = '';
|
||||||
|
switch (version + extension) {
|
||||||
|
case '7.4xdebug':
|
||||||
|
install_command =
|
||||||
|
'sh ./xdebug_darwin.sh >/dev/null 2>&1 && echo "zend_extension=xdebug.so" >> $ini_file';
|
||||||
|
break;
|
||||||
|
case '7.4pcov':
|
||||||
|
install_command =
|
||||||
|
'sh ./pcov.sh >/dev/null 2>&1 && echo "extension=pcov.so" >> $ini_file';
|
||||||
|
break;
|
||||||
|
case '5.6xdebug':
|
||||||
|
install_command = 'sudo pecl install xdebug-2.5.5 >/dev/null 2>&1';
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
install_command =
|
||||||
|
'sudo pecl install ' + extension + ' >/dev/null 2>&1';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
script +=
|
||||||
|
'if [ ! "$(php -m | grep -i ' +
|
||||||
|
extension +
|
||||||
|
')" ]; then ' +
|
||||||
|
install_command +
|
||||||
|
' && ' +
|
||||||
|
(yield utils.log('Installed and enabled ' + extension, 'darwin', 'success', log_prefix)) +
|
||||||
|
' || ' +
|
||||||
|
(yield utils.log('Could not install ' + extension + ' on PHP' + version, 'darwin', 'error', log_prefix)) +
|
||||||
|
'; fi\n';
|
||||||
|
break;
|
||||||
|
case false:
|
||||||
|
default:
|
||||||
|
script +=
|
||||||
|
'if [ ! "$(php -m | grep -i ' +
|
||||||
|
extension +
|
||||||
|
')" ]; then \n' +
|
||||||
|
(yield utils.log('Could not find ' + extension + ' for PHP' + version + ' on PECL', 'darwin', 'error', log_prefix)) +
|
||||||
|
'; fi\n';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
return script;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
exports.addExtensionDarwin = addExtensionDarwin;
|
||||||
|
/**
|
||||||
|
* Install and enable extensions for windows
|
||||||
|
*
|
||||||
|
* @param extension_csv
|
||||||
|
* @param version
|
||||||
|
*/
|
||||||
|
function addExtensionWindows(extension_csv, version, log_prefix) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
let extensions = yield utils.extensionArray(extension_csv);
|
||||||
|
let script = '\n';
|
||||||
|
yield utils.asyncForEach(extensions, function (extension) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
extension = extension.toLowerCase();
|
||||||
|
// add script to enable extension is already installed along with php
|
||||||
|
script += yield enableExtensionWindows(extension, log_prefix);
|
||||||
|
switch (yield pecl.checkPECLExtension(extension)) {
|
||||||
|
case true:
|
||||||
|
let install_command = '';
|
||||||
|
switch (version + extension) {
|
||||||
|
case '7.4xdebug':
|
||||||
|
const extension_url = 'https://xdebug.org/files/php_xdebug-2.8.0beta2-7.4-vc15.dll';
|
||||||
|
install_command =
|
||||||
|
'Invoke-WebRequest -Uri ' +
|
||||||
|
extension_url +
|
||||||
|
' -OutFile C:\\tools\\php\\ext\\php_xdebug.dll\n';
|
||||||
|
install_command += 'Enable-PhpExtension xdebug';
|
||||||
|
break;
|
||||||
|
case '7.2xdebug':
|
||||||
|
default:
|
||||||
|
install_command = 'Install-PhpExtension ' + extension;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
script +=
|
||||||
|
'if(!(php -m | findstr -i ' +
|
||||||
|
extension +
|
||||||
|
')) { ' +
|
||||||
|
'try { ' +
|
||||||
|
install_command +
|
||||||
|
'\n' +
|
||||||
|
(yield utils.log('Installed and enabled ' + extension, 'win32', 'success', log_prefix)) +
|
||||||
|
' } catch [Exception] { ' +
|
||||||
|
(yield utils.log('Could not install ' + extension + ' on PHP' + version, 'win32', 'error', log_prefix)) +
|
||||||
|
' } }\n';
|
||||||
|
break;
|
||||||
|
case false:
|
||||||
|
default:
|
||||||
|
script +=
|
||||||
|
'if(!(php -m | findstr -i ' +
|
||||||
|
extension +
|
||||||
|
')) { ' +
|
||||||
|
(yield utils.log('Could not find ' + extension + ' for PHP' + version + ' on PECL', 'win32', 'error', log_prefix)) +
|
||||||
|
' } \n';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
return script;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
exports.addExtensionWindows = addExtensionWindows;
|
||||||
|
/**
|
||||||
|
* Install and enable extensions for linux
|
||||||
|
*
|
||||||
|
* @param extension_csv
|
||||||
|
* @param version
|
||||||
|
*/
|
||||||
|
function addExtensionLinux(extension_csv, version, log_prefix) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
let extensions = yield utils.extensionArray(extension_csv);
|
||||||
|
let script = '\n';
|
||||||
|
yield utils.asyncForEach(extensions, function (extension) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
extension = extension.toLowerCase();
|
||||||
|
// add script to enable extension is already installed along with php
|
||||||
|
script += yield enableExtensionUnix(extension, 'linux', log_prefix);
|
||||||
|
let install_command = '';
|
||||||
|
switch (version + extension) {
|
||||||
|
case '7.4xdebug':
|
||||||
|
install_command =
|
||||||
|
'./xdebug.sh >/dev/null 2>&1 && echo "zend_extension=xdebug.so" >> $ini_file';
|
||||||
|
break;
|
||||||
|
case '7.4pcov':
|
||||||
|
install_command =
|
||||||
|
'./pcov.sh >/dev/null 2>&1 && echo "extension=pcov.so" >> $ini_file';
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
install_command =
|
||||||
|
'sudo DEBIAN_FRONTEND=noninteractive apt install -y php' +
|
||||||
|
version +
|
||||||
|
'-' +
|
||||||
|
extension +
|
||||||
|
' >/dev/null 2>&1';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
script +=
|
||||||
|
'if [ ! "$(php -m | grep -i ' +
|
||||||
|
extension +
|
||||||
|
')" ]; then ' +
|
||||||
|
install_command +
|
||||||
|
' && ' +
|
||||||
|
(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', log_prefix)) +
|
||||||
|
'; fi\n';
|
||||||
|
});
|
||||||
|
});
|
||||||
|
return script;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
exports.addExtensionLinux = addExtensionLinux;
|
295
lib/features.js
295
lib/features.js
@ -1,295 +0,0 @@
|
|||||||
"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 pecl = __importStar(require("./pecl"));
|
|
||||||
function addExtension(extension_csv, version, os_version) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
switch (os_version) {
|
|
||||||
case 'win32':
|
|
||||||
return yield addExtensionWindows(extension_csv, version);
|
|
||||||
case 'darwin':
|
|
||||||
return yield addExtensionDarwin(extension_csv, version);
|
|
||||||
case 'linux':
|
|
||||||
return yield addExtensionLinux(extension_csv, version);
|
|
||||||
default:
|
|
||||||
return yield utils.log('Platform ' + os_version + ' is not supported', os_version, 'error');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
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
|
|
||||||
*
|
|
||||||
* @param extension
|
|
||||||
*/
|
|
||||||
function enableExtensionWindows(extension) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
return (`try {
|
|
||||||
$exist = Test-Path -Path $ext_dir\\php_${extension}.dll
|
|
||||||
if(!(php -m | findstr -i ${extension}) -and $exist) {
|
|
||||||
Enable-PhpExtension ${extension} C:\\tools\\php\n` +
|
|
||||||
(yield utils.log(extension + ' enabled', 'win32', 'success')) +
|
|
||||||
`}
|
|
||||||
} catch [Exception] {\n` +
|
|
||||||
(yield utils.log(extension + ' could not be installed', 'win32', 'error')) +
|
|
||||||
` }\n`);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
exports.enableExtensionWindows = enableExtensionWindows;
|
|
||||||
/**
|
|
||||||
* Enable extensions which are installed but not enabled on unix
|
|
||||||
*
|
|
||||||
* @param extension
|
|
||||||
*/
|
|
||||||
function enableExtensionUnix(extension) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
return (`if [ ! "$(php -m | grep ${extension})" ] && [ -e "$ext_dir/${extension}.so" ]; then
|
|
||||||
echo "extension=${extension}.so" >> 'php -i | grep "Loaded Configuration" | sed -e "s|.*=>\s*||"'\n` +
|
|
||||||
(yield utils.log(extension + ' enabled', 'unix', 'success')) +
|
|
||||||
`; fi\n`);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
exports.enableExtensionUnix = enableExtensionUnix;
|
|
||||||
/**
|
|
||||||
* Install and enable extensions for darwin
|
|
||||||
*
|
|
||||||
* @param extension_csv
|
|
||||||
* @param version
|
|
||||||
*/
|
|
||||||
function addExtensionDarwin(extension_csv, version) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
let extensions = yield utils.extensionArray(extension_csv);
|
|
||||||
let script = '\n';
|
|
||||||
yield utils.asyncForEach(extensions, function (extension) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
extension = extension.toLowerCase();
|
|
||||||
// add script to enable extension is already installed along with php
|
|
||||||
script += yield enableExtensionUnix(extension);
|
|
||||||
switch (yield pecl.checkPECLExtension(extension)) {
|
|
||||||
case true:
|
|
||||||
extension =
|
|
||||||
version === '5.6' && extension === 'xdebug'
|
|
||||||
? 'xdebug-2.5.5'
|
|
||||||
: extension;
|
|
||||||
script +=
|
|
||||||
'if [ ! "$(php -m | grep ' +
|
|
||||||
extension +
|
|
||||||
')" ]; then sudo pecl install ' +
|
|
||||||
extension +
|
|
||||||
' || ' +
|
|
||||||
(yield utils.log("Couldn't install extension: " + extension, 'darwin', 'error')) +
|
|
||||||
'; fi\n';
|
|
||||||
break;
|
|
||||||
case false:
|
|
||||||
default:
|
|
||||||
script +=
|
|
||||||
(yield utils.log('Could not find extension: ' + extension, 'darwin', 'error')) + '\n';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
return script;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
exports.addExtensionDarwin = addExtensionDarwin;
|
|
||||||
/**
|
|
||||||
* Install and enable extensions for windows
|
|
||||||
*
|
|
||||||
* @param extension_csv
|
|
||||||
* @param version
|
|
||||||
*/
|
|
||||||
function addExtensionWindows(extension_csv, version) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
let extensions = yield utils.extensionArray(extension_csv);
|
|
||||||
let script = '\n';
|
|
||||||
yield utils.asyncForEach(extensions, function (extension) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
extension = extension.toLowerCase();
|
|
||||||
// add script to enable extension is already installed along with php
|
|
||||||
script += yield enableExtensionWindows(extension);
|
|
||||||
let extension_version = '';
|
|
||||||
switch (version) {
|
|
||||||
case '7.4':
|
|
||||||
extension_version = 'alpha';
|
|
||||||
break;
|
|
||||||
case '7.2':
|
|
||||||
default:
|
|
||||||
extension_version = 'stable';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
switch (yield pecl.checkPECLExtension(extension)) {
|
|
||||||
case true:
|
|
||||||
script +=
|
|
||||||
'if(!(php -m | findstr -i ' +
|
|
||||||
extension +
|
|
||||||
')) { ' +
|
|
||||||
'try { Install-PhpExtension ' +
|
|
||||||
extension +
|
|
||||||
' -MinimumStability ' +
|
|
||||||
extension_version +
|
|
||||||
' } catch [Exception] { ' +
|
|
||||||
(yield utils.log('Could not install extension: ' + extension, 'win32', 'error')) +
|
|
||||||
' } }\n';
|
|
||||||
break;
|
|
||||||
case false:
|
|
||||||
default:
|
|
||||||
script +=
|
|
||||||
(yield utils.log('Could not find extension: ' + extension, 'win32', 'error')) + '\n';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
return script;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
exports.addExtensionWindows = addExtensionWindows;
|
|
||||||
/**
|
|
||||||
* Install and enable extensions for linux
|
|
||||||
*
|
|
||||||
* @param extension_csv
|
|
||||||
* @param version
|
|
||||||
*/
|
|
||||||
function addExtensionLinux(extension_csv, version) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
let extensions = yield utils.extensionArray(extension_csv);
|
|
||||||
let script = '\n';
|
|
||||||
yield utils.asyncForEach(extensions, function (extension) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
extension = extension.toLowerCase();
|
|
||||||
// add script to enable extension is already installed along with php
|
|
||||||
script += yield enableExtensionUnix(extension);
|
|
||||||
script +=
|
|
||||||
'if [ ! "$(php -m | grep ' +
|
|
||||||
extension +
|
|
||||||
')" ]; then sudo DEBIAN_FRONTEND=noninteractive apt install -y php' +
|
|
||||||
version +
|
|
||||||
'-' +
|
|
||||||
extension +
|
|
||||||
' || ' +
|
|
||||||
(yield utils.log("Couldn't find extension php" + version + '-' + extension, 'linux', 'error')) +
|
|
||||||
'; fi\n';
|
|
||||||
});
|
|
||||||
});
|
|
||||||
return script;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
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(coverage, 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 phpdismod xdebug || echo 'xdebug not installed'\n";
|
|
||||||
script += "sudo phpenmod pcov || echo 'pcov not installed'\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(coverage, 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 -x ./' + 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;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
117
lib/utils.js
117
lib/utils.js
@ -47,6 +47,19 @@ function asyncForEach(array, callback) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
exports.asyncForEach = asyncForEach;
|
exports.asyncForEach = asyncForEach;
|
||||||
|
/**
|
||||||
|
* Copy config
|
||||||
|
*
|
||||||
|
* @param files
|
||||||
|
*/
|
||||||
|
function readFiles74(files) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
yield asyncForEach(files, function (filename) {
|
||||||
|
fs.createReadStream(path.join(__dirname, '../src/' + filename)).pipe(fs.createWriteStream(filename.split('/')[1], { mode: 0o755 }));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
exports.readFiles74 = readFiles74;
|
||||||
/**
|
/**
|
||||||
* Read the scripts
|
* Read the scripts
|
||||||
*
|
*
|
||||||
@ -60,17 +73,32 @@ function readScript(filename, version, os_version) {
|
|||||||
case 'darwin':
|
case 'darwin':
|
||||||
switch (version) {
|
switch (version) {
|
||||||
case '7.4':
|
case '7.4':
|
||||||
return fs.readFileSync(path.join(__dirname, '../src/7.4.sh'), 'utf8');
|
yield readFiles74([
|
||||||
case '7.3':
|
'configs/config.yaml',
|
||||||
default:
|
'scripts/xdebug_darwin.sh',
|
||||||
return fs.readFileSync(path.join(__dirname, '../src/' + filename), 'utf8');
|
'scripts/pcov.sh'
|
||||||
|
]);
|
||||||
|
return fs.readFileSync(path.join(__dirname, '../src/scripts/7.4.sh'), 'utf8');
|
||||||
}
|
}
|
||||||
case 'win32':
|
break;
|
||||||
case 'linux':
|
case 'linux':
|
||||||
return fs.readFileSync(path.join(__dirname, '../src/' + filename), 'utf8');
|
switch (version) {
|
||||||
|
case '7.4':
|
||||||
|
yield readFiles74(['scripts/xdebug.sh', 'scripts/pcov.sh']);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'win32':
|
||||||
|
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;
|
||||||
@ -93,12 +121,18 @@ exports.writeScript = writeScript;
|
|||||||
*/
|
*/
|
||||||
function extensionArray(extension_csv) {
|
function extensionArray(extension_csv) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
return extension_csv.split(',').map(function (extension) {
|
switch (extension_csv) {
|
||||||
return extension
|
case '':
|
||||||
.trim()
|
case ' ':
|
||||||
.replace('php-', '')
|
return [];
|
||||||
.replace('php_', '');
|
default:
|
||||||
});
|
return extension_csv.split(',').map(function (extension) {
|
||||||
|
return extension
|
||||||
|
.trim()
|
||||||
|
.replace('php-', '')
|
||||||
|
.replace('php_', '');
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
exports.extensionArray = extensionArray;
|
exports.extensionArray = extensionArray;
|
||||||
@ -110,14 +144,33 @@ exports.extensionArray = extensionArray;
|
|||||||
*/
|
*/
|
||||||
function INIArray(ini_values_csv) {
|
function INIArray(ini_values_csv) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
return ini_values_csv.split(',').map(function (ini_value) {
|
switch (ini_values_csv) {
|
||||||
return ini_value.trim();
|
case '':
|
||||||
});
|
case ' ':
|
||||||
|
return [];
|
||||||
|
default:
|
||||||
|
return ini_values_csv.split(',').map(function (ini_value) {
|
||||||
|
return ini_value.trim();
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
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 = {
|
||||||
|
error: '31',
|
||||||
|
success: '32',
|
||||||
|
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 = {
|
||||||
@ -125,17 +178,35 @@ 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:
|
||||||
const unix_color = {
|
return ('echo "\\033[' +
|
||||||
error: '31',
|
unix_color[log_type] +
|
||||||
success: '32',
|
';1m' +
|
||||||
warning: '33'
|
prefix +
|
||||||
};
|
message +
|
||||||
return ('echo -e "\\033[' + unix_color[log_type] + ';1m' + message + '\\033[0m"');
|
'\\033[0m"');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
exports.log = log;
|
exports.log = log;
|
||||||
|
function getExtensionPrefix(extension) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
let zend = ['xdebug', 'opcache', 'ioncube', 'eaccelerator'];
|
||||||
|
switch (zend.indexOf(extension)) {
|
||||||
|
case 0:
|
||||||
|
case 1:
|
||||||
|
return 'zend_extension';
|
||||||
|
case -1:
|
||||||
|
default:
|
||||||
|
return 'extension';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
exports.getExtensionPrefix = getExtensionPrefix;
|
||||||
|
2
package-lock.json
generated
2
package-lock.json
generated
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "setup-php",
|
"name": "setup-php",
|
||||||
"version": "1.3.5",
|
"version": "1.4.1",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "setup-php",
|
"name": "setup-php",
|
||||||
"version": "1.3.5",
|
"version": "1.4.1",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "Setup php action",
|
"description": "Setup php action",
|
||||||
"main": "lib/setup-php.js",
|
"main": "lib/setup-php.js",
|
||||||
|
50
src/7.4.sh
50
src/7.4.sh
@ -1,50 +0,0 @@
|
|||||||
brew fetch autoconf& brew fetch automake& brew fetch pcre& brew fetch libtool& brew fetch libpng& brew fetch webp& brew fetch jpeg& brew fetch freetype& brew fetch libxml2& brew fetch pkg-config& brew fetch krb5& brew fetch icu4c& brew fetch re2c& brew fetch bison& brew fetch libzip& brew fetch mcrypt& brew fetch zlib& brew fetch bzip2& brew fetch enchant
|
|
||||||
brew install autoconf automake pcre libtool libpng webp jpeg freetype libxml2 pkg-config krb5 icu4c re2c bison libzip mcrypt zlib bzip2 enchant > /dev/null 2>&1
|
|
||||||
brew link --force gettext
|
|
||||||
brew link --force bison
|
|
||||||
brew link --force openssl
|
|
||||||
brew link --force libxml2
|
|
||||||
brew link --force bzip2
|
|
||||||
echo 'export PATH="/usr/local/opt/bzip2/bin:$PATH"' >> ~/.bash_profile
|
|
||||||
echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.bash_profile
|
|
||||||
echo 'export PATH="/usr/local/opt/krb5/bin:$PATH"' >> ~/.bash_profile
|
|
||||||
echo 'export PATH="/usr/local/opt/krb5/sbin:$PATH"' >> ~/.bash_profile
|
|
||||||
echo 'export PATH="/usr/local/opt/icu4c/bin:$PATH"' >> ~/.bash_profile
|
|
||||||
echo 'export PATH="/usr/local/opt/icu4c/sbin:$PATH"' >> ~/.bash_profile
|
|
||||||
echo 'export PATH="/usr/local/opt/bison/bin:$PATH"' >> ~/.bash_profile
|
|
||||||
echo 'export PATH="/usr/local/opt/libxml2/bin:$PATH"' >> ~/.bash_profile
|
|
||||||
echo 'export PATH="/Users/runner/.phpbrew/php/php-7.4.0RC1/bin:$PATH"' >> ~/.bash_profile
|
|
||||||
source ~/.bash_profile > /dev/null 2>&1
|
|
||||||
export LIBXML_LIBS="-L/usr/local/opt/libxml2/lib"
|
|
||||||
export LIBXML_CFLAGS="-I/usr/local/opt/libxml2/include"
|
|
||||||
export ENCHANT_LIBS="-L/usr/local/opt/enchant/lib"
|
|
||||||
export ENCHANT_CFLAGS="-I/usr/local/opt/enchant/include"
|
|
||||||
export FFI_LIBS="-L/usr/local/opt/libffi/lib"
|
|
||||||
export FFI_CFLAGS="-I/usr/local/opt/libffi/include"
|
|
||||||
export ICU_LIBS="-L/usr/local/opt/icu4c/lib"
|
|
||||||
export ICU_CFLAGS="-I/usr/local/opt/icu4c/include"
|
|
||||||
export KERBEROS_LIBS="-L/usr/local/opt/krb5/lib"
|
|
||||||
export KERBEROS_CFLAGS="-I/usr/local/opt/krb5/include"
|
|
||||||
export OPENSSL_LIBS="-L/usr/local/opt/openssl/lib"
|
|
||||||
export OPENSSL_CFLAGS="-I/usr/local/opt/openssl/include"
|
|
||||||
export READLINE_LIBS="-L/usr/local/opt/readline/lib"
|
|
||||||
export READLINE_CFLAGS="-I/usr/local/opt/readline/include"
|
|
||||||
export BZIP2_LIBS="-L/usr/local/opt/bzip2/lib"
|
|
||||||
export BZIP2_CFLAGS="-I/usr/local/opt/bzip2/include"
|
|
||||||
export PKG_CONFIG_PATH="/usr/local/opt/krb5/lib/pkgconfig:/usr/local/opt/icu4c/lib/pkgconfig:/usr/local/obzip2pt/libffi/lib/pkgconfig:/usr/local/opt/openssl@1.1/lib/pkgconfig:/usr/local/opt/readline/lib/pkgconfig:/usr/local/opt/libxml2/lib/pkgconfig:/usr/local/opt/krb5/lib/pkgconfig:/usr/local/opt/icu4c/lib/pkgconfig:/usr/local/opt/libffi/lib/pkgconfig:/usr/local/opt/libxml2/lib/pkgconfig"
|
|
||||||
cd ~ || echo "could not move to ~"
|
|
||||||
curl -L -O https://github.com/phpbrew/phpbrew/raw/master/phpbrew
|
|
||||||
chmod +x ./phpbrew
|
|
||||||
sudo mv phpbrew /usr/local/bin/phpbrew
|
|
||||||
sudo mkdir -p /opt/phpbrew
|
|
||||||
phpbrew init --root=/opt/phpbrew
|
|
||||||
echo "[[ -e ~/.phpbrew/bashrc ]] && source ~/.phpbrew/bashrc" >> ~/.bashrc
|
|
||||||
source ~/.bashrc
|
|
||||||
phpbrew install -j 10 7.4.0RC2 +default +bz2="$(brew --prefix bzip2)" +zlib="$(brew --prefix zlib)" -openssl -- --with-libxml
|
|
||||||
phpbrew switch php-7.4.0RC2 > /dev/null 2>&1
|
|
||||||
sudo mkdir -p /usr/local/bin
|
|
||||||
sudo ln -sf /Users/runner/.phpbrew/php/php-7.4.0RC2/bin/php /usr/local/bin/php
|
|
||||||
ini_file=$(php --ini | grep "Loaded Configuration" | sed -e "s|.*:s*||" | sed "s/ //g")
|
|
||||||
ext_dir=$(/usr/bin/php -i | grep "extension_dir => /usr" | sed -e "s|.*=> s*||")
|
|
||||||
sudo chmod 777 "$ini_file"
|
|
||||||
brew install composer
|
|
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;
|
||||||
|
}
|
58
src/configs/config.yaml
Normal file
58
src/configs/config.yaml
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
variants:
|
||||||
|
dev:
|
||||||
|
bcmath:
|
||||||
|
calendar:
|
||||||
|
cli:
|
||||||
|
ctype:
|
||||||
|
dom:
|
||||||
|
fileinfo:
|
||||||
|
filter:
|
||||||
|
ipc:
|
||||||
|
iconv:
|
||||||
|
json:
|
||||||
|
mbregex:
|
||||||
|
mbstring:
|
||||||
|
mhash:
|
||||||
|
mcrypt:
|
||||||
|
pcntl:
|
||||||
|
pcre:
|
||||||
|
pdo:
|
||||||
|
phar:
|
||||||
|
posix:
|
||||||
|
sockets:
|
||||||
|
tokenizer:
|
||||||
|
xml:
|
||||||
|
curl:
|
||||||
|
openssl:
|
||||||
|
zip:
|
||||||
|
gd:
|
||||||
|
- --with-freetype
|
||||||
|
- --with-pdo-mysql=mysqlnd
|
||||||
|
- --with-mysqli=mysqlnd
|
||||||
|
- --with-pgsql
|
||||||
|
- --with-pdo-pgsql
|
||||||
|
- --with-gmp=/usr/local/opt/gmp
|
||||||
|
- --with-openssl
|
||||||
|
- --with-pear
|
||||||
|
- --with-zip
|
||||||
|
- --with-libxml
|
||||||
|
- --with-kerberos
|
||||||
|
- --with-gd
|
||||||
|
- --with-ffi
|
||||||
|
- --with-curl
|
||||||
|
- --with-mhash
|
||||||
|
- --with-readline=/usr/local/opt/readline
|
||||||
|
- --with-iconv=/usr/local/opt/libiconv
|
||||||
|
- --with-icu-dir=/usr/local/opt/icu4c
|
||||||
|
- --with-config-file-path=/etc
|
||||||
|
- --enable-intl
|
||||||
|
- --enable-xml
|
||||||
|
- --enable-sysvsem
|
||||||
|
- --enable-sysvshm
|
||||||
|
- --enable-sysvmsg
|
||||||
|
- --enable-phpdbg
|
||||||
|
- --enable-exif
|
||||||
|
- --enable-gd
|
||||||
|
- --enable-soap
|
||||||
|
- --enable-xmlreader
|
||||||
|
- --enable-zend-test=shared
|
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;
|
||||||
|
}
|
@ -1,11 +0,0 @@
|
|||||||
export HOMEBREW_NO_INSTALL_CLEANUP=TRUE
|
|
||||||
brew tap exolnet/homebrew-deprecated > /dev/null 2>&1
|
|
||||||
brew install php@"$1" composer
|
|
||||||
brew link --force --overwrite php@"$1"
|
|
||||||
ini_file=$(php --ini | grep "Loaded Configuration" | sed -e "s|.*:s*||" | sed "s/ //g")
|
|
||||||
ext_dir=$(/usr/bin/php -i | grep "extension_dir => /usr" | sed -e "s|.*=> s*||")
|
|
||||||
sudo chmod 777 "$ini_file"
|
|
||||||
mkdir -p "$(pecl config-get ext_dir)"
|
|
||||||
composer global require hirak/prestissimo
|
|
||||||
php -v
|
|
||||||
composer -V
|
|
BIN
src/ext/php_pcov.dll
Normal file
BIN
src/ext/php_pcov.dll
Normal file
Binary file not shown.
309
src/extensions.ts
Normal file
309
src/extensions.ts
Normal file
@ -0,0 +1,309 @@
|
|||||||
|
import * as utils from './utils';
|
||||||
|
import * as pecl from './pecl';
|
||||||
|
|
||||||
|
export async function addExtension(
|
||||||
|
extension_csv: string,
|
||||||
|
version: string,
|
||||||
|
os_version: string,
|
||||||
|
log_prefix = 'Add Extension'
|
||||||
|
): Promise<string> {
|
||||||
|
switch (os_version) {
|
||||||
|
case 'win32':
|
||||||
|
return await addExtensionWindows(extension_csv, version, log_prefix);
|
||||||
|
case 'darwin':
|
||||||
|
return await addExtensionDarwin(extension_csv, version, log_prefix);
|
||||||
|
case 'linux':
|
||||||
|
return await addExtensionLinux(extension_csv, version, log_prefix);
|
||||||
|
default:
|
||||||
|
return await utils.log(
|
||||||
|
'Platform ' + os_version + ' is not supported',
|
||||||
|
os_version,
|
||||||
|
'error',
|
||||||
|
log_prefix
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enable extensions which are installed but not enabled on windows
|
||||||
|
*
|
||||||
|
* @param extension
|
||||||
|
*/
|
||||||
|
export async function enableExtensionWindows(
|
||||||
|
extension: string,
|
||||||
|
log_prefix: string
|
||||||
|
) {
|
||||||
|
return (
|
||||||
|
`try {
|
||||||
|
$exist = Test-Path -Path $ext_dir\\php_${extension}.dll
|
||||||
|
if(!(php -m | findstr -i ${extension}) -and $exist) {
|
||||||
|
Add-Content C:\\tools\\php\\php.ini "${await utils.getExtensionPrefix(
|
||||||
|
extension
|
||||||
|
)}=php_${extension}.dll"\n` +
|
||||||
|
(await utils.log('Enabled ' + extension, 'win32', 'success', log_prefix)) +
|
||||||
|
` } elseif(php -m | findstr -i ${extension}) {\n` +
|
||||||
|
(await utils.log(
|
||||||
|
extension + ' was already enabled',
|
||||||
|
'win32',
|
||||||
|
'success',
|
||||||
|
log_prefix
|
||||||
|
)) +
|
||||||
|
` }
|
||||||
|
} catch [Exception] {\n` +
|
||||||
|
(await utils.log(
|
||||||
|
extension + ' could not be enabled',
|
||||||
|
'win32',
|
||||||
|
'error',
|
||||||
|
log_prefix
|
||||||
|
)) +
|
||||||
|
` }\n`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enable extensions which are installed but not enabled on unix
|
||||||
|
*
|
||||||
|
* @param extension
|
||||||
|
* @param os_version
|
||||||
|
*/
|
||||||
|
export async function enableExtensionUnix(
|
||||||
|
extension: string,
|
||||||
|
os_version: string,
|
||||||
|
log_prefix: string
|
||||||
|
) {
|
||||||
|
return (
|
||||||
|
`if [ ! "$(php -m | grep -i ${extension})" ] && [ -e "$ext_dir/${extension}.so" ]; then
|
||||||
|
echo "${await utils.getExtensionPrefix(
|
||||||
|
extension
|
||||||
|
)}=${extension}" >> $ini_file\n` +
|
||||||
|
(await utils.log(
|
||||||
|
'Enabled ' + extension,
|
||||||
|
os_version,
|
||||||
|
'success',
|
||||||
|
log_prefix
|
||||||
|
)) +
|
||||||
|
`;\n elif [ "$(php -m | grep -i ${extension})" ]; then \n` +
|
||||||
|
(await utils.log(
|
||||||
|
extension + ' was already enabled',
|
||||||
|
os_version,
|
||||||
|
'success',
|
||||||
|
log_prefix
|
||||||
|
)) +
|
||||||
|
`; fi\n`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Install and enable extensions for darwin
|
||||||
|
*
|
||||||
|
* @param extension_csv
|
||||||
|
* @param version
|
||||||
|
*/
|
||||||
|
export async function addExtensionDarwin(
|
||||||
|
extension_csv: string,
|
||||||
|
version: string,
|
||||||
|
log_prefix: string
|
||||||
|
): Promise<string> {
|
||||||
|
let extensions: Array<string> = await utils.extensionArray(extension_csv);
|
||||||
|
let script: string = '\n';
|
||||||
|
await utils.asyncForEach(extensions, async function(extension: string) {
|
||||||
|
extension = extension.toLowerCase();
|
||||||
|
// add script to enable extension is already installed along with php
|
||||||
|
script += await enableExtensionUnix(extension, 'darwin', log_prefix);
|
||||||
|
switch (await pecl.checkPECLExtension(extension)) {
|
||||||
|
case true:
|
||||||
|
let install_command: string = '';
|
||||||
|
switch (version + extension) {
|
||||||
|
case '7.4xdebug':
|
||||||
|
install_command =
|
||||||
|
'sh ./xdebug_darwin.sh >/dev/null 2>&1 && echo "zend_extension=xdebug.so" >> $ini_file';
|
||||||
|
break;
|
||||||
|
case '7.4pcov':
|
||||||
|
install_command =
|
||||||
|
'sh ./pcov.sh >/dev/null 2>&1 && echo "extension=pcov.so" >> $ini_file';
|
||||||
|
break;
|
||||||
|
case '5.6xdebug':
|
||||||
|
install_command = 'sudo pecl install xdebug-2.5.5 >/dev/null 2>&1';
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
install_command =
|
||||||
|
'sudo pecl install ' + extension + ' >/dev/null 2>&1';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
script +=
|
||||||
|
'if [ ! "$(php -m | grep -i ' +
|
||||||
|
extension +
|
||||||
|
')" ]; then ' +
|
||||||
|
install_command +
|
||||||
|
' && ' +
|
||||||
|
(await utils.log(
|
||||||
|
'Installed and enabled ' + extension,
|
||||||
|
'darwin',
|
||||||
|
'success',
|
||||||
|
log_prefix
|
||||||
|
)) +
|
||||||
|
' || ' +
|
||||||
|
(await utils.log(
|
||||||
|
'Could not install ' + extension + ' on PHP' + version,
|
||||||
|
'darwin',
|
||||||
|
'error',
|
||||||
|
log_prefix
|
||||||
|
)) +
|
||||||
|
'; fi\n';
|
||||||
|
break;
|
||||||
|
case false:
|
||||||
|
default:
|
||||||
|
script +=
|
||||||
|
'if [ ! "$(php -m | grep -i ' +
|
||||||
|
extension +
|
||||||
|
')" ]; then \n' +
|
||||||
|
(await utils.log(
|
||||||
|
'Could not find ' + extension + ' for PHP' + version + ' on PECL',
|
||||||
|
'darwin',
|
||||||
|
'error',
|
||||||
|
log_prefix
|
||||||
|
)) +
|
||||||
|
'; fi\n';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return script;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Install and enable extensions for windows
|
||||||
|
*
|
||||||
|
* @param extension_csv
|
||||||
|
* @param version
|
||||||
|
*/
|
||||||
|
export async function addExtensionWindows(
|
||||||
|
extension_csv: string,
|
||||||
|
version: string,
|
||||||
|
log_prefix: string
|
||||||
|
): Promise<string> {
|
||||||
|
let extensions: Array<string> = await utils.extensionArray(extension_csv);
|
||||||
|
let script: string = '\n';
|
||||||
|
await utils.asyncForEach(extensions, async function(extension: string) {
|
||||||
|
extension = extension.toLowerCase();
|
||||||
|
// add script to enable extension is already installed along with php
|
||||||
|
script += await enableExtensionWindows(extension, log_prefix);
|
||||||
|
|
||||||
|
switch (await pecl.checkPECLExtension(extension)) {
|
||||||
|
case true:
|
||||||
|
let install_command: string = '';
|
||||||
|
switch (version + extension) {
|
||||||
|
case '7.4xdebug':
|
||||||
|
const extension_url: string =
|
||||||
|
'https://xdebug.org/files/php_xdebug-2.8.0beta2-7.4-vc15.dll';
|
||||||
|
install_command =
|
||||||
|
'Invoke-WebRequest -Uri ' +
|
||||||
|
extension_url +
|
||||||
|
' -OutFile C:\\tools\\php\\ext\\php_xdebug.dll\n';
|
||||||
|
install_command += 'Enable-PhpExtension xdebug';
|
||||||
|
break;
|
||||||
|
case '7.2xdebug':
|
||||||
|
default:
|
||||||
|
install_command = 'Install-PhpExtension ' + extension;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
script +=
|
||||||
|
'if(!(php -m | findstr -i ' +
|
||||||
|
extension +
|
||||||
|
')) { ' +
|
||||||
|
'try { ' +
|
||||||
|
install_command +
|
||||||
|
'\n' +
|
||||||
|
(await utils.log(
|
||||||
|
'Installed and enabled ' + extension,
|
||||||
|
'win32',
|
||||||
|
'success',
|
||||||
|
log_prefix
|
||||||
|
)) +
|
||||||
|
' } catch [Exception] { ' +
|
||||||
|
(await utils.log(
|
||||||
|
'Could not install ' + extension + ' on PHP' + version,
|
||||||
|
'win32',
|
||||||
|
'error',
|
||||||
|
log_prefix
|
||||||
|
)) +
|
||||||
|
' } }\n';
|
||||||
|
break;
|
||||||
|
case false:
|
||||||
|
default:
|
||||||
|
script +=
|
||||||
|
'if(!(php -m | findstr -i ' +
|
||||||
|
extension +
|
||||||
|
')) { ' +
|
||||||
|
(await utils.log(
|
||||||
|
'Could not find ' + extension + ' for PHP' + version + ' on PECL',
|
||||||
|
'win32',
|
||||||
|
'error',
|
||||||
|
log_prefix
|
||||||
|
)) +
|
||||||
|
' } \n';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return script;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Install and enable extensions for linux
|
||||||
|
*
|
||||||
|
* @param extension_csv
|
||||||
|
* @param version
|
||||||
|
*/
|
||||||
|
export async function addExtensionLinux(
|
||||||
|
extension_csv: string,
|
||||||
|
version: string,
|
||||||
|
log_prefix: string
|
||||||
|
): Promise<string> {
|
||||||
|
let extensions: Array<string> = await utils.extensionArray(extension_csv);
|
||||||
|
let script: string = '\n';
|
||||||
|
await utils.asyncForEach(extensions, async function(extension: string) {
|
||||||
|
extension = extension.toLowerCase();
|
||||||
|
// add script to enable extension is already installed along with php
|
||||||
|
script += await enableExtensionUnix(extension, 'linux', log_prefix);
|
||||||
|
|
||||||
|
let install_command: string = '';
|
||||||
|
switch (version + extension) {
|
||||||
|
case '7.4xdebug':
|
||||||
|
install_command =
|
||||||
|
'./xdebug.sh >/dev/null 2>&1 && echo "zend_extension=xdebug.so" >> $ini_file';
|
||||||
|
break;
|
||||||
|
case '7.4pcov':
|
||||||
|
install_command =
|
||||||
|
'./pcov.sh >/dev/null 2>&1 && echo "extension=pcov.so" >> $ini_file';
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
install_command =
|
||||||
|
'sudo DEBIAN_FRONTEND=noninteractive apt install -y php' +
|
||||||
|
version +
|
||||||
|
'-' +
|
||||||
|
extension +
|
||||||
|
' >/dev/null 2>&1';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
script +=
|
||||||
|
'if [ ! "$(php -m | grep -i ' +
|
||||||
|
extension +
|
||||||
|
')" ]; then ' +
|
||||||
|
install_command +
|
||||||
|
' && ' +
|
||||||
|
(await utils.log(
|
||||||
|
'Installed and enabled ' + extension,
|
||||||
|
'linux',
|
||||||
|
'success',
|
||||||
|
log_prefix
|
||||||
|
)) +
|
||||||
|
' || ' +
|
||||||
|
(await utils.log(
|
||||||
|
'Could not find php' + version + '-' + extension + ' on APT repository',
|
||||||
|
'linux',
|
||||||
|
'error',
|
||||||
|
log_prefix
|
||||||
|
)) +
|
||||||
|
'; fi\n';
|
||||||
|
});
|
||||||
|
return script;
|
||||||
|
}
|
315
src/features.ts
315
src/features.ts
@ -1,315 +0,0 @@
|
|||||||
import * as utils from './utils';
|
|
||||||
import * as pecl from './pecl';
|
|
||||||
|
|
||||||
export async function addExtension(
|
|
||||||
extension_csv: string,
|
|
||||||
version: string,
|
|
||||||
os_version: string
|
|
||||||
): Promise<string> {
|
|
||||||
switch (os_version) {
|
|
||||||
case 'win32':
|
|
||||||
return await addExtensionWindows(extension_csv, version);
|
|
||||||
case 'darwin':
|
|
||||||
return await addExtensionDarwin(extension_csv, version);
|
|
||||||
case 'linux':
|
|
||||||
return await addExtensionLinux(extension_csv, version);
|
|
||||||
default:
|
|
||||||
return await utils.log(
|
|
||||||
'Platform ' + os_version + ' is not supported',
|
|
||||||
os_version,
|
|
||||||
'error'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Enable extensions which are installed but not enabled on windows
|
|
||||||
*
|
|
||||||
* @param extension
|
|
||||||
*/
|
|
||||||
export async function enableExtensionWindows(extension: string) {
|
|
||||||
return (
|
|
||||||
`try {
|
|
||||||
$exist = Test-Path -Path $ext_dir\\php_${extension}.dll
|
|
||||||
if(!(php -m | findstr -i ${extension}) -and $exist) {
|
|
||||||
Enable-PhpExtension ${extension} C:\\tools\\php\n` +
|
|
||||||
(await utils.log(extension + ' enabled', 'win32', 'success')) +
|
|
||||||
`}
|
|
||||||
} catch [Exception] {\n` +
|
|
||||||
(await utils.log(extension + ' could not be installed', 'win32', 'error')) +
|
|
||||||
` }\n`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Enable extensions which are installed but not enabled on unix
|
|
||||||
*
|
|
||||||
* @param extension
|
|
||||||
*/
|
|
||||||
export async function enableExtensionUnix(extension: string) {
|
|
||||||
return (
|
|
||||||
`if [ ! "$(php -m | grep ${extension})" ] && [ -e "$ext_dir/${extension}.so" ]; then
|
|
||||||
echo "extension=${extension}.so" >> 'php -i | grep "Loaded Configuration" | sed -e "s|.*=>\s*||"'\n` +
|
|
||||||
(await utils.log(extension + ' enabled', 'unix', 'success')) +
|
|
||||||
`; fi\n`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Install and enable extensions for darwin
|
|
||||||
*
|
|
||||||
* @param extension_csv
|
|
||||||
* @param version
|
|
||||||
*/
|
|
||||||
export async function addExtensionDarwin(
|
|
||||||
extension_csv: string,
|
|
||||||
version: string
|
|
||||||
): Promise<string> {
|
|
||||||
let extensions: Array<string> = await utils.extensionArray(extension_csv);
|
|
||||||
let script: string = '\n';
|
|
||||||
await utils.asyncForEach(extensions, async function(extension: string) {
|
|
||||||
extension = extension.toLowerCase();
|
|
||||||
// add script to enable extension is already installed along with php
|
|
||||||
script += await enableExtensionUnix(extension);
|
|
||||||
switch (await pecl.checkPECLExtension(extension)) {
|
|
||||||
case true:
|
|
||||||
extension =
|
|
||||||
version === '5.6' && extension === 'xdebug'
|
|
||||||
? 'xdebug-2.5.5'
|
|
||||||
: extension;
|
|
||||||
script +=
|
|
||||||
'if [ ! "$(php -m | grep ' +
|
|
||||||
extension +
|
|
||||||
')" ]; then sudo pecl install ' +
|
|
||||||
extension +
|
|
||||||
' || ' +
|
|
||||||
(await utils.log(
|
|
||||||
"Couldn't install extension: " + extension,
|
|
||||||
'darwin',
|
|
||||||
'error'
|
|
||||||
)) +
|
|
||||||
'; fi\n';
|
|
||||||
break;
|
|
||||||
case false:
|
|
||||||
default:
|
|
||||||
script +=
|
|
||||||
(await utils.log(
|
|
||||||
'Could not find extension: ' + extension,
|
|
||||||
'darwin',
|
|
||||||
'error'
|
|
||||||
)) + '\n';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return script;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Install and enable extensions for windows
|
|
||||||
*
|
|
||||||
* @param extension_csv
|
|
||||||
* @param version
|
|
||||||
*/
|
|
||||||
export async function addExtensionWindows(
|
|
||||||
extension_csv: string,
|
|
||||||
version: string
|
|
||||||
): Promise<string> {
|
|
||||||
let extensions: Array<string> = await utils.extensionArray(extension_csv);
|
|
||||||
let script: string = '\n';
|
|
||||||
await utils.asyncForEach(extensions, async function(extension: string) {
|
|
||||||
extension = extension.toLowerCase();
|
|
||||||
// add script to enable extension is already installed along with php
|
|
||||||
script += await enableExtensionWindows(extension);
|
|
||||||
let extension_version: string = '';
|
|
||||||
switch (version) {
|
|
||||||
case '7.4':
|
|
||||||
extension_version = 'alpha';
|
|
||||||
break;
|
|
||||||
case '7.2':
|
|
||||||
default:
|
|
||||||
extension_version = 'stable';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (await pecl.checkPECLExtension(extension)) {
|
|
||||||
case true:
|
|
||||||
script +=
|
|
||||||
'if(!(php -m | findstr -i ' +
|
|
||||||
extension +
|
|
||||||
')) { ' +
|
|
||||||
'try { Install-PhpExtension ' +
|
|
||||||
extension +
|
|
||||||
' -MinimumStability ' +
|
|
||||||
extension_version +
|
|
||||||
' } catch [Exception] { ' +
|
|
||||||
(await utils.log(
|
|
||||||
'Could not install extension: ' + extension,
|
|
||||||
'win32',
|
|
||||||
'error'
|
|
||||||
)) +
|
|
||||||
' } }\n';
|
|
||||||
break;
|
|
||||||
case false:
|
|
||||||
default:
|
|
||||||
script +=
|
|
||||||
(await utils.log(
|
|
||||||
'Could not find extension: ' + extension,
|
|
||||||
'win32',
|
|
||||||
'error'
|
|
||||||
)) + '\n';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return script;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Install and enable extensions for linux
|
|
||||||
*
|
|
||||||
* @param extension_csv
|
|
||||||
* @param version
|
|
||||||
*/
|
|
||||||
export async function addExtensionLinux(
|
|
||||||
extension_csv: string,
|
|
||||||
version: string
|
|
||||||
): Promise<string> {
|
|
||||||
let extensions: Array<string> = await utils.extensionArray(extension_csv);
|
|
||||||
let script: string = '\n';
|
|
||||||
await utils.asyncForEach(extensions, async function(extension: string) {
|
|
||||||
extension = extension.toLowerCase();
|
|
||||||
// add script to enable extension is already installed along with php
|
|
||||||
script += await enableExtensionUnix(extension);
|
|
||||||
script +=
|
|
||||||
'if [ ! "$(php -m | grep ' +
|
|
||||||
extension +
|
|
||||||
')" ]; then sudo DEBIAN_FRONTEND=noninteractive apt install -y php' +
|
|
||||||
version +
|
|
||||||
'-' +
|
|
||||||
extension +
|
|
||||||
' || ' +
|
|
||||||
(await utils.log(
|
|
||||||
"Couldn't find extension php" + version + '-' + extension,
|
|
||||||
'linux',
|
|
||||||
'error'
|
|
||||||
)) +
|
|
||||||
'; fi\n';
|
|
||||||
});
|
|
||||||
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(coverage, 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 phpdismod xdebug || echo 'xdebug not installed'\n";
|
|
||||||
script += "sudo phpenmod pcov || echo 'pcov not installed'\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(coverage, 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
|
||||||
@ -22,24 +24,37 @@ async function run() {
|
|||||||
version,
|
version,
|
||||||
os_version
|
os_version
|
||||||
);
|
);
|
||||||
darwin += await features.addExtension(extension_csv, version, os_version);
|
|
||||||
darwin += await features.addINIValues(ini_values_csv, os_version);
|
darwin += await extensions.addExtension(
|
||||||
darwin += await features.addCoverage(coverage, version, os_version);
|
extension_csv,
|
||||||
|
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 -x ./' + version + 'darwin.sh ' + version);
|
await exec('sh ./' + version + 'darwin.sh ' + version);
|
||||||
} else if (os_version == 'win32') {
|
} else if (os_version == 'win32') {
|
||||||
let windows: string = await utils.readScript(
|
let windows: string = await utils.readScript(
|
||||||
'win32.ps1',
|
'win32.ps1',
|
||||||
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') {
|
||||||
@ -48,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;
|
||||||
}
|
}
|
||||||
|
59
src/scripts/7.4.sh
Normal file
59
src/scripts/7.4.sh
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
brew install pkg-config autoconf bison re2c openssl@1.1 krb5 enchant libffi freetype intltool icu4c libiconv t1lib gd libzip gmp tidyp libxml2 libxslt postgresql curl >/dev/null 2>&1
|
||||||
|
brew link icu4c gettext --force >/dev/null 2>&1
|
||||||
|
|
||||||
|
for package in gettext gmp krb5 icu4c bison openssl@1.1 libxml2 libffi libxslt libiconv pkgconfig enchant krb5 readline libedit freetype;
|
||||||
|
do
|
||||||
|
caps_package=$(echo "$package" | tr '[:lower:]' '[:upper:]')
|
||||||
|
{
|
||||||
|
echo 'export PATH="/usr/local/opt/'"$package"'/bin:$PATH"'
|
||||||
|
echo 'export PKG_CONFIG_PATH="/usr/local/opt/'$package'/lib/pkgconfig:$PKG_CONFIG_PATH"'
|
||||||
|
echo 'export '"$caps_package"'_LIBS="-L/usr/local/opt/'$package'/lib"'
|
||||||
|
echo 'export '"$caps_package"'_CFLAGS="-I/usr/local/opt/'$package'/include"'
|
||||||
|
} >> ~/.bash_profile;
|
||||||
|
done
|
||||||
|
{
|
||||||
|
echo 'export ICONV_LIBS="-L/usr/local/opt/libiconv/lib"'
|
||||||
|
echo 'export ICONV_CFLAGS="-I/usr/local/opt/libiconv/include"'
|
||||||
|
echo 'export LIBXML_LIBS="-L/usr/local/opt/libxml2/lib"'
|
||||||
|
echo 'export LIBXML_CFLAGS="-I/usr/local/opt/libxml2/include"'
|
||||||
|
echo 'export ICU_LIBS="-L/usr/local/opt/icu4c/lib"'
|
||||||
|
echo 'export ICU_CFLAGS="-I/usr/local/opt/icu4c/include"'
|
||||||
|
echo 'export OPENSSL_LIBS="-L/usr/local/opt/openssl@1.1/lib -lcrypto"'
|
||||||
|
echo 'export OPENSSL_CFLAGS="-I/usr/local/opt/openssl@1.1/include"'
|
||||||
|
echo 'export OPENSSL_ROOT_DIR="/usr/local/opt/openssl@1.1/"'
|
||||||
|
echo 'export OPENSSL_LIB_DIR="/usr/local/opt/openssl@1.1/lib"'
|
||||||
|
echo 'export OPENSSL_INCLUDE_DIR="/usr/local/opt/openssl@1.1/include"'
|
||||||
|
echo 'export PKG_CONFIG="/usr/local/opt/pkgconfig/bin/pkg-config"'
|
||||||
|
echo 'export EXTRA_LIBS="/usr/local/opt/readline/lib/libhistory.dylib
|
||||||
|
/usr/local/opt/readline/lib/libreadline.dylib
|
||||||
|
/usr/local/opt/openssl@1.1/lib/libssl.dylib
|
||||||
|
/usr/local/opt/openssl@1.1/lib/libcrypto.dylib
|
||||||
|
/usr/local/opt/icu4c/lib/libicudata.dylib
|
||||||
|
/usr/local/opt/icu4c/lib/libicui18n.dylib
|
||||||
|
/usr/local/opt/icu4c/lib/libicuio.dylib
|
||||||
|
/usr/local/opt/icu4c/lib/libicutu.dylib
|
||||||
|
/usr/local/opt/icu4c/lib/libicuuc.dylib"'
|
||||||
|
} >> ~/.bash_profile
|
||||||
|
config_file=$(pwd)/config.yaml
|
||||||
|
curl -L -O https://github.com/phpbrew/phpbrew/raw/master/phpbrew >/dev/null 2>&1
|
||||||
|
chmod +x ./phpbrew
|
||||||
|
sudo mv phpbrew /usr/local/bin/phpbrew
|
||||||
|
sudo mkdir -p /opt/phpbrew
|
||||||
|
sudo mkdir -p /usr/local/lib
|
||||||
|
sudo mkdir -p /usr/local/bin
|
||||||
|
sudo phpbrew init --root=/opt/phpbrew --config="$config_file" >/dev/null 2>&1
|
||||||
|
sudo chmod -R 777 /opt/phpbrew
|
||||||
|
export PHPBREW_ROOT=/opt/phpbrew
|
||||||
|
export PHPBREW_HOME=/opt/phpbrew
|
||||||
|
echo "[[ -e ~/.phpbrew/bashrc ]] && source ~/.phpbrew/bashrc" >> ~/.bashrc
|
||||||
|
source ~/.bash_profile >/dev/null 2>&1
|
||||||
|
source ~/.bashrc >/dev/null 2>&1
|
||||||
|
phpbrew install -j 6 7.4.0RC3 +dev >/dev/null 2>&1
|
||||||
|
phpbrew switch 7.4.0RC3
|
||||||
|
sudo ln -sf /opt/phpbrew/php/php-7.4.0RC3/bin/* /usr/local/bin/
|
||||||
|
sudo ln -sf /opt/phpbrew/php/php-7.4.0RC3/etc/php.ini /etc/php.ini
|
||||||
|
ini_file=$(php --ini | grep "Loaded Configuration" | sed -e "s|.*:s*||" | sed "s/ //g")
|
||||||
|
ext_dir=$(php -i | grep "extension_dir => /opt" | sed -e "s|.*=> s*||")
|
||||||
|
pecl config-set php_ini "$ini_file"
|
||||||
|
sudo chmod 777 "$ini_file"
|
||||||
|
brew install composer
|
13
src/scripts/darwin.sh
Normal file
13
src/scripts/darwin.sh
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
export HOMEBREW_NO_INSTALL_CLEANUP=TRUE
|
||||||
|
if [ "$1" = "5.6" ] || [ "$1" = "7.0" ]; then
|
||||||
|
brew tap exolnet/homebrew-deprecated >/dev/null 2>&1
|
||||||
|
fi
|
||||||
|
brew install php@"$1" composer >/dev/null 2>&1
|
||||||
|
brew link --force --overwrite php@"$1" >/dev/null 2>&1
|
||||||
|
ini_file=$(php --ini | grep "Loaded Configuration" | sed -e "s|.*:s*||" | sed "s/ //g")
|
||||||
|
ext_dir=$(php -i | grep "extension_dir => /usr" | sed -e "s|.*=> s*||")
|
||||||
|
sudo chmod 777 "$ini_file"
|
||||||
|
mkdir -p "$(pecl config-get ext_dir)"
|
||||||
|
composer global require hirak/prestissimo >/dev/null 2>&1
|
||||||
|
php -v
|
||||||
|
composer -V
|
@ -1,34 +1,38 @@
|
|||||||
version=$(php-config --version | cut -c 1-3)
|
version=$(php-config --version | cut -c 1-3)
|
||||||
if [ "$version" != "$1" ]; then
|
if [ "$version" != "$1" ]; then
|
||||||
if [ ! -e "/usr/bin/php$1" ]; then
|
if [ ! -e "/usr/bin/php$1" ]; then
|
||||||
sudo DEBIAN_FRONTEND=noninteractive add-apt-repository ppa:ondrej/php -y > /dev/null 2>&1
|
sudo DEBIAN_FRONTEND=noninteractive add-apt-repository ppa:ondrej/php -y >/dev/null 2>&1
|
||||||
sudo DEBIAN_FRONTEND=noninteractive apt update -y > /dev/null 2>&1
|
sudo DEBIAN_FRONTEND=noninteractive apt update -y >/dev/null 2>&1
|
||||||
sudo DEBIAN_FRONTEND=noninteractive apt install -y php"$1" curl php"$1"-curl;
|
if [ "$1" != "7.4" ]; then
|
||||||
|
sudo DEBIAN_FRONTEND=noninteractive apt install -y php"$1" curl php"$1"-curl >/dev/null 2>&1
|
||||||
|
else
|
||||||
|
sudo DEBIAN_FRONTEND=noninteractive apt install -y php"$1" php"$1"-dev curl php"$1"-curl >/dev/null 2>&1
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
for tool in php phar phar.phar php-cgi php-config phpize; do
|
for tool in php phar phar.phar php-cgi php-config phpize; do
|
||||||
if [ -e "/usr/bin/$tool$1" ]; then
|
if [ -e "/usr/bin/$tool$1" ]; then
|
||||||
sudo update-alternatives --set $tool /usr/bin/"$tool$1";
|
sudo update-alternatives --set $tool /usr/bin/"$tool$1" &
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -e "/usr/bin/composer" ]; then
|
if [ ! -e "/usr/bin/composer" ]; then
|
||||||
EXPECTED_SIGNATURE="$(curl -s https://composer.github.io/installer.sig)"
|
EXPECTED_SIGNATURE="$(curl -s https://composer.github.io/installer.sig)" &
|
||||||
curl -s -L https://getcomposer.org/installer > composer-setup.php
|
curl -s -L https://getcomposer.org/installer > composer-setup.php &
|
||||||
ACTUAL_SIGNATURE="$(php -r "echo hash_file('sha384', 'composer-setup.php');")"
|
ACTUAL_SIGNATURE="$(php -r "echo hash_file('sha384', 'composer-setup.php');")" &
|
||||||
|
|
||||||
if [ "$EXPECTED_SIGNATURE" != "$ACTUAL_SIGNATURE" ]; then
|
if [ "$EXPECTED_SIGNATURE" != "$ACTUAL_SIGNATURE" ]; then
|
||||||
>&2 echo 'ERROR: Invalid installer signature'
|
>&2 echo 'ERROR: Invalid installer signature'
|
||||||
else
|
else
|
||||||
COMPOSER_ALLOW_SUPERUSER=1
|
COMPOSER_ALLOW_SUPERUSER=1
|
||||||
sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer
|
sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer
|
||||||
fi
|
fi
|
||||||
rm composer-setup.php
|
rm composer-setup.php
|
||||||
fi
|
fi
|
||||||
|
|
||||||
composer global require hirak/prestissimo > /dev/null 2>&1
|
composer global require hirak/prestissimo >/dev/null 2>&1
|
||||||
ini_file=$(php --ini | grep "Loaded Configuration" | sed -e "s|.*:s*||" | sed "s/ //g")
|
ini_file=$(php --ini | grep "Loaded Configuration" | sed -e "s|.*:s*||" | sed "s/ //g")
|
||||||
ext_dir=$(/usr/bin/php -i | grep "extension_dir => /usr" | sed -e "s|.*=> s*||")
|
ext_dir=$(php -i | grep "extension_dir => /usr" | sed -e "s|.*=> s*||")
|
||||||
sudo chmod 777 "$ini_file"
|
sudo chmod 777 "$ini_file"
|
||||||
sudo mkdir -p /run/php
|
sudo mkdir -p /run/php
|
||||||
php -v
|
php -v
|
7
src/scripts/pcov.sh
Normal file
7
src/scripts/pcov.sh
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
git clone --depth=1 https://github.com/krakjoe/pcov.git
|
||||||
|
(
|
||||||
|
cd pcov && phpize
|
||||||
|
./configure --enable-pcov
|
||||||
|
make
|
||||||
|
sudo make install
|
||||||
|
)
|
@ -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
|
5
src/scripts/xdebug.sh
Normal file
5
src/scripts/xdebug.sh
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
git clone --depth=1 https://github.com/xdebug/xdebug.git
|
||||||
|
(
|
||||||
|
cd xdebug || echo "cd failed"
|
||||||
|
sudo ./rebuild.sh
|
||||||
|
)
|
8
src/scripts/xdebug_darwin.sh
Normal file
8
src/scripts/xdebug_darwin.sh
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
git clone --depth=1 https://github.com/xdebug/xdebug.git
|
||||||
|
(
|
||||||
|
cd xdebug || echo "cd failed"
|
||||||
|
sudo phpize
|
||||||
|
sudo ./configure
|
||||||
|
sudo make
|
||||||
|
sudo cp modules/xdebug.so "$(php -i | grep "extension_dir => /opt" | sed -e "s|.*=> s*||")"
|
||||||
|
)
|
125
src/utils.ts
125
src/utils.ts
@ -32,6 +32,19 @@ export async function asyncForEach(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Copy config
|
||||||
|
*
|
||||||
|
* @param files
|
||||||
|
*/
|
||||||
|
export async function readFiles74(files: Array<string>) {
|
||||||
|
await asyncForEach(files, function(filename: string) {
|
||||||
|
fs.createReadStream(path.join(__dirname, '../src/' + filename)).pipe(
|
||||||
|
fs.createWriteStream(filename.split('/')[1], {mode: 0o755})
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read the scripts
|
* Read the scripts
|
||||||
*
|
*
|
||||||
@ -48,20 +61,31 @@ export async function readScript(
|
|||||||
case 'darwin':
|
case 'darwin':
|
||||||
switch (version) {
|
switch (version) {
|
||||||
case '7.4':
|
case '7.4':
|
||||||
return fs.readFileSync(path.join(__dirname, '../src/7.4.sh'), 'utf8');
|
await readFiles74([
|
||||||
case '7.3':
|
'configs/config.yaml',
|
||||||
default:
|
'scripts/xdebug_darwin.sh',
|
||||||
|
'scripts/pcov.sh'
|
||||||
|
]);
|
||||||
return fs.readFileSync(
|
return fs.readFileSync(
|
||||||
path.join(__dirname, '../src/' + filename),
|
path.join(__dirname, '../src/scripts/7.4.sh'),
|
||||||
'utf8'
|
'utf8'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
case 'win32':
|
break;
|
||||||
case 'linux':
|
case 'linux':
|
||||||
return fs.readFileSync(
|
switch (version) {
|
||||||
path.join(__dirname, '../src/' + filename),
|
case '7.4':
|
||||||
'utf8'
|
await readFiles74(['scripts/xdebug.sh', 'scripts/pcov.sh']);
|
||||||
);
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'win32':
|
||||||
|
switch (version) {
|
||||||
|
case '7.4':
|
||||||
|
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',
|
||||||
@ -69,6 +93,11 @@ export async function readScript(
|
|||||||
'error'
|
'error'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return fs.readFileSync(
|
||||||
|
path.join(__dirname, '../src/scripts/' + filename),
|
||||||
|
'utf8'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -93,12 +122,18 @@ export async function writeScript(
|
|||||||
export async function extensionArray(
|
export async function extensionArray(
|
||||||
extension_csv: string
|
extension_csv: string
|
||||||
): Promise<Array<string>> {
|
): Promise<Array<string>> {
|
||||||
return extension_csv.split(',').map(function(extension: string) {
|
switch (extension_csv) {
|
||||||
return extension
|
case '':
|
||||||
.trim()
|
case ' ':
|
||||||
.replace('php-', '')
|
return [];
|
||||||
.replace('php_', '');
|
default:
|
||||||
});
|
return extension_csv.split(',').map(function(extension: string) {
|
||||||
|
return extension
|
||||||
|
.trim()
|
||||||
|
.replace('php-', '')
|
||||||
|
.replace('php_', '');
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -108,16 +143,36 @@ export async function extensionArray(
|
|||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
export async function INIArray(ini_values_csv: string): Promise<Array<string>> {
|
export async function INIArray(ini_values_csv: string): Promise<Array<string>> {
|
||||||
return ini_values_csv.split(',').map(function(ini_value: string) {
|
switch (ini_values_csv) {
|
||||||
return ini_value.trim();
|
case '':
|
||||||
});
|
case ' ':
|
||||||
|
return [];
|
||||||
|
default:
|
||||||
|
return ini_values_csv.split(',').map(function(ini_value: string) {
|
||||||
|
return ini_value.trim();
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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 = {
|
||||||
|
error: '31',
|
||||||
|
success: '32',
|
||||||
|
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 = {
|
||||||
@ -125,18 +180,36 @@ 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:
|
||||||
const unix_color: any = {
|
|
||||||
error: '31',
|
|
||||||
success: '32',
|
|
||||||
warning: '33'
|
|
||||||
};
|
|
||||||
return (
|
return (
|
||||||
'echo -e "\\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> {
|
||||||
|
let zend: Array<string> = ['xdebug', 'opcache', 'ioncube', 'eaccelerator'];
|
||||||
|
switch (zend.indexOf(extension)) {
|
||||||
|
case 0:
|
||||||
|
case 1:
|
||||||
|
return 'zend_extension';
|
||||||
|
case -1:
|
||||||
|
default:
|
||||||
|
return 'extension';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user