Compare commits

...

20 Commits
1.3.8 ... 1.4.3

Author SHA1 Message Date
ffc5b0249d Merge pull request #60 from shivammathur/develop
Release 1.4.3
2019-10-17 22:12:11 +05:30
a6aaa1db78 Improve Logs and tests 2019-10-17 21:39:01 +05:30
62beed29e3 Merge pull request #59 from shivammathur/develop
Release 1.4.2
2019-10-14 08:55:35 +05:30
fce9311522 Add support for phalcon 2019-10-14 08:35:38 +05:30
b2e7a49dd5 Add lumen examples and fix laravel examples 2019-10-13 05:27:58 +05:30
99bbaa2a58 Improve documentation 2019-10-11 23:09:05 +05:30
f7f5b1a7e1 Specify version in phpenmod and phpdismod 2019-10-11 13:14:59 +05:30
e755fb7a69 Refactor installation scripts 2019-10-11 12:48:49 +05:30
3087ceb811 Merge pull request #58 from shivammathur/develop
Fix enableExtensionUnix
2019-10-10 22:10:37 +05:30
05e2b0d1e9 Fix enableExtensionUnix 2019-10-10 21:21:50 +05:30
dd5c977988 Merge pull request #57 from shivammathur/develop
Fix scripts, README and examples
2019-10-10 19:55:19 +05:30
c1c0acc338 Fix scripts, README and examples 2019-10-10 19:45:43 +05:30
409e055931 Merge pull request #55 from shivammathur/develop
Improve code and examples
2019-10-08 19:41:46 +05:30
46a875ad7e Improve code and examples 2019-10-08 18:31:45 +05:30
7e81c058fb Merge pull request #54 from shivammathur/develop
Add option to disable coverage drivers
2019-10-05 15:32:11 +05:30
754ab9515b Add option to disable coverage drivers 2019-10-05 15:00:00 +05:30
f866c880c2 Merge pull request #52 from shivammathur/develop
Fix links in README. Broken in #51
2019-10-05 07:01:38 +05:30
eb21cb8fb3 Fix links in README. Broken in #51 2019-10-05 07:00:06 +05:30
aee6b953c3 Merge pull request #51 from shivammathur/develop
Fix examples and add coverage badge
2019-10-05 06:54:59 +05:30
21c3c8db47 Fix examples and add coverage badge 2019-10-05 06:44:08 +05:30
52 changed files with 2488 additions and 1423 deletions

View File

@ -1,24 +1,27 @@
name: Main workflow
on: [push]
on: [push, pull_request]
jobs:
run:
name: Run
runs-on: ${{ matrix.operating-system }}
strategy:
max-parallel: 8
fail-fast: false
max-parallel: 15
matrix:
operating-system: [ubuntu-latest, windows-latest, macOS-latest]
php-versions: ['5.6', '7.0', '7.1', '7.2', '7.3']
steps:
- name: Checkout
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
with:
version: 10.x
node-version: 10.x
- name: Installing NPM
- name: Installing NPM packages
run: npm install
- name: Run tests and send coverage
@ -30,8 +33,8 @@ jobs:
run: node lib/install.js
env:
php-version: ${{ matrix.php-versions }}
extension-csv: "mbstring, xdebug, pcov" #optional
ini-values-csv: "post_max_size=256M, short_open_tag=On, date.timezone=Asia/Kolkata" #optional
extension-csv: mbstring, xdebug, pcov #optional
ini-values-csv: post_max_size=256M, short_open_tag=On, date.timezone=Asia/Kolkata #optional
- name: Testing PHP version
run: php -v

120
README.md
View File

@ -4,17 +4,18 @@
</a>
</p>
# Setup PHP in GitHub Actions
<h1 align="center">Setup PHP in GitHub Actions</h1>
<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/blob/master/LICENSE"><img alt="LICENSE" src="https://img.shields.io/badge/license-MIT-428f7e.svg"></a>
<a href="#tada-php-support"><img alt="PHP Versions Supported" src="https://img.shields.io/badge/php-%3E%3D%205.6-8892BF.svg"></a>
<a href="https://www.patreon.com/shivammathur"><img alt="Support me on Patreon" src="https://shivammathur.com/badges/patreon.svg"></a> <a href="https://www.paypal.me/shivammathur"><img alt="Support me on PayPal" src="https://shivammathur.com/badges/paypal.svg"></a>
<a href="https://www.codementor.io/shivammathur?utm_source=github&utm_medium=button&utm_term=shivammathur&utm_campaign=github"><img alt="Contact me on Codementor" src="https://cdn.codementor.io/badges/contact_me_github.svg"></a>
<p align="center">
<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://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="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="#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.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>
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
@ -25,7 +26,7 @@ Setup PHP with required extensions, php.ini configuration and composer in [GitHu
|7.1|`Stable`|`Security fixes only`|
|7.2|`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.
@ -39,7 +40,6 @@ Setup PHP with required extensions, php.ini configuration and composer in [GitHu
|Ubuntu 16.04|`ubuntu-16.04`|
|macOS X Mojave 10.14|`macOS-latest` or `macOS-10.14`|
## :wrench: PHP Extension Support
- On `ubuntu` extensions which have the package in apt are installed.
- On `windows` and `macOS` PECL extensions are installed.
@ -47,25 +47,50 @@ Setup PHP with required extensions, php.ini configuration and composer in [GitHu
- Extensions which cannot be installed gracefully leave an error message in the logs, the action is not interrupted.
## :signal_strength: Coverage support
- Specify `coverage: xdebug` to use `Xdebug`.
- 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
with:
php-version: 7.3
php-version: '7.3'
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` needs `PHPUnit >= 8.0` and `PHP >= 7.1`, `PHPUnit` needs `PHP >= 7.2`. So use `PHP >= 7.2` with `PCOV`
```
### PCOV
Specify `coverage: pcov` to use `PCOV`.
It is much faster than `Xdebug`.
`PCOV` needs `PHP >= 7.1`
If your source code directory is other than `src`, `lib` or, `app`, specify `pcov.directory` using the `ini-values-csv` input.
```yaml
uses: shivammathur/setup-php@master
with:
php-version: 7.3
ini-values-csv: 'pcov.directory=api' #optional, see above for usage.
php-version: '7.3'
ini-values-csv: pcov.directory=api #optional, see above for usage.
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
Inputs supported by this GitHub Action.
@ -75,7 +100,7 @@ Inputs supported by this GitHub Action.
- ini-values-csv `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
@ -86,9 +111,9 @@ steps:
- name: Installing PHP
uses: shivammathur/setup-php@master
with:
php-version: 7.3
php-version: '7.3'
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
- name: Check PHP Version
run: php -v
@ -118,50 +143,61 @@ jobs:
with:
php-version: ${{ matrix.php-versions }}
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
- name: Check PHP Version
run: php -v
- name: Check Composer Version
run: composer -V
- name: Check PHP Extensions
run: php -m
run: php -m
```
### Examples
Examples for setting up this GitHub Action with different PHP Frameworks/Packages.
**Note:** Make sure you add steps to run your tests after the setup steps given in these examples.
- [Laravel with MySQL](./example/laravel-mysql.yml)
- [Laravel with PostgreSQL](./example/laravel-postgres.yml)
- [Slim Framework](./example/slim-framework.yml)
|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")|
|Lumen with `MySQL` and `Redis`|`ubuntu`|[lumen-mysql.yml](./examples/lumen-mysql.yml "GitHub Action for Lumen with MySQL and Redis")|
|Lumen with `PostgreSQL` and `Redis`|`ubuntu`|[lumen-postgres.yml](./examples/lumen-postgres.yml "GitHub Action for Lumen with PostgreSQL and Redis")|
|Lumen without services|`macOS`, `ubuntu` and `windows`|[lumen.yml](./examples/lumen.yml "GitHub Action for Lumen without services")|
|Phalcon with `MySQL`|`ubuntu`|[phalcon-mysql.yml](./examples/phalcon-mysql.yml "GitHub Action for Phalcon with MySQL")|
|Phalcon with `PostgreSQL`|`ubuntu`|[phalcon-postgres.yml](./examples/phalcon-postgres.yml "GitHub Action for Phalcon with PostgreSQL")|
|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
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
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
- Please star the project and share it among your developer friends.
- Please star the project and share it.
- Consider supporting on <a href="https://www.patreon.com/shivammathur"><img alt="Support me on Patreon" src="https://shivammathur.com/badges/patreon.svg"></a> and <a href="https://www.paypal.me/shivammathur"><img alt="Support me on Paypal" src="https://shivammathur.com/badges/paypal.svg"></a>.
## :bookmark: This action uses the following works
- [powershell-phpmanager](https://github.com/mlocati/powershell-phpmanager)
- [Homebrew](https://brew.sh/)
- [ppa:ondrej/php](https://launchpad.net/~ondrej/+archive/ubuntu/php)
- [exolnet/homebrew-deprecated](https://github.com/eXolnet/homebrew-deprecated)
- [phpbrew](https://github.com/phpbrew/phpbrew)
- [powershell-phpmanager](https://github.com/mlocati/powershell-phpmanager "Package to handle PHP on windows")
- [Homebrew](https://brew.sh/ "MacOS package manager")
- [ppa:ondrej/php](https://launchpad.net/~ondrej/+archive/ubuntu/php "Pre-compiled ubuntu packages")
- [exolnet/homebrew-deprecated](https://github.com/eXolnet/homebrew-deprecated "Pre-compiled deprecated PHP for macOS")
- [phpbrew](https://github.com/phpbrew/phpbrew "PHP packages manager")
## :bookmark_tabs: Further Reading
- [About GitHub Actions](https://github.com/features/actions)
- [GitHub Actions Syntax](https://help.github.com/en/articles/workflow-syntax-for-github-actions)
- [Other Awesome Actions](https://github.com/sdras/awesome-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")
- [Other Awesome Actions](https://github.com/sdras/awesome-actions "List of Awesome GitHub Actions")

52
__tests__/config.test.ts Normal file
View File

@ -0,0 +1,52 @@
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\nshort_open_tag=On\ndate.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',
true
);
expect(linux).toContain(
'echo "post_max_size=256M\nshort_open_tag=On\ndate.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\nshort_open_tag=On\ndate.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');
});
});

View 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('PHP 7.1 or newer is required');
win32 = await coverage.addCoverage('pcov', '5.6', 'win32');
expect(win32).toContain('PHP 7.1 or newer is required');
});
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 -v 7.4 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 -v 7.4 xdebug');
expect(linux).toContain('sudo phpdismod -v 7.4 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('');
});
});

View File

@ -0,0 +1,103 @@
import * as extensions from '../src/extensions';
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',
true
);
expect(win32).toContain(
'Add-Extension does_not_exist "Install-PhpExtension does_not_exist" extension'
);
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('phalcon3, phalcon4', '7.2', 'linux');
expect(linux).toContain('./phalcon.sh master 7.2');
expect(linux).toContain('./phalcon.sh 4.0.x 7.2');
linux = await extensions.addExtension('phalcon3, phalcon4', '7.3', 'linux');
expect(linux).toContain('./phalcon.sh master 7.3');
expect(linux).toContain('./phalcon.sh 4.0.x 7.3');
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',
false
);
expect(darwin).toContain('add_extension does_not_exist');
darwin = await extensions.addExtension('xdebug', '7.2', 'fedora');
expect(darwin).toContain('Platform fedora is not supported');
});
});

View File

@ -1,211 +0,0 @@
import * as features from '../src/features';
let valid_extensions = ['xdebug', 'pcov'];
jest.mock('../src/pecl', () => ({
checkPECLExtension: jest.fn().mockImplementation(extension => {
return valid_extensions.indexOf(extension) !== -1;
})
}));
describe('Features tests', () => {
it('checking addExtensionOnWindows', async () => {
let win32: string = await features.addExtension(
'xdebug, pcov',
'7.2',
'win32'
);
expect(win32).toContain('Install-PhpExtension xdebug');
expect(win32).toContain('Install-PhpExtension pcov');
win32 = await features.addExtension('xdebug, pcov', '7.4', 'win32');
const extension_url: string =
'https://xdebug.org/files/php_xdebug-2.8.0beta2-7.4-vc15.dll';
expect(win32).toContain(
'Invoke-WebRequest -Uri ' +
extension_url +
' -OutFile C:\\tools\\php\\ext\\php_xdebug.dll'
);
expect(win32).toContain('Install-PhpExtension pcov');
win32 = await features.addExtension('does_not_exist', '7.2', 'win32');
expect(win32).toContain('Could not find does_not_exist for PHP7.2 on PECL');
win32 = await features.addExtension('xdebug', '7.2', 'fedora');
expect(win32).toContain('Platform fedora is not supported');
});
it('checking addExtensionOnLinux', async () => {
let linux: string = await features.addExtension(
'xdebug, pcov',
'7.2',
'linux'
);
expect(linux).toContain(
'sudo DEBIAN_FRONTEND=noninteractive apt install -y php7.2-xdebug'
);
expect(linux).toContain(
'sudo DEBIAN_FRONTEND=noninteractive apt install -y php7.2-pcov'
);
linux = await features.addExtension('xdebug, pcov', '7.4', 'linux');
expect(linux).toContain('./xdebug.sh');
expect(linux).toContain('./pcov.sh');
linux = await features.addExtension('xdebug', '7.2', 'fedora');
expect(linux).toContain('Platform fedora is not supported');
});
it('checking addExtensionOnDarwin', async () => {
let darwin: string = await features.addExtension(
'xdebug, pcov',
'7.2',
'darwin'
);
expect(darwin).toContain('sudo pecl install xdebug');
expect(darwin).toContain('sudo pecl install pcov');
darwin = await features.addExtension('pcov', '5.6', 'darwin');
expect(darwin).toContain('sudo pecl install pcov');
darwin = await features.addExtension('pcov', '7.2', 'darwin');
expect(darwin).toContain('sudo pecl install pcov');
darwin = await features.addExtension('xdebug', '5.6', 'darwin');
expect(darwin).toContain('sudo pecl install xdebug-2.5.5');
darwin = await features.addExtension('xdebug', '7.4', 'darwin');
expect(darwin).toContain('sh ./xdebug_darwin.sh');
darwin = await features.addExtension('pcov', '7.4', 'darwin');
expect(darwin).toContain('sh ./pcov.sh');
darwin = await features.addExtension('xdebug', '7.2', 'darwin');
expect(darwin).toContain('sudo pecl install xdebug');
darwin = await features.addExtension('does_not_exist', '7.2', 'darwin');
expect(darwin).toContain(
'Could not find does_not_exist for PHP7.2 on PECL'
);
darwin = await features.addExtension('xdebug', '7.2', 'fedora');
expect(darwin).toContain('Platform fedora is not supported');
});
it('checking addINIValuesOnWindows', async () => {
let win32: string = await features.addINIValues(
'post_max_size=256M, short_open_tag=On, date.timezone=Asia/Kolkata',
'win32'
);
expect(win32).toContain(
'Add-Content C:\\tools\\php\\php.ini "post_max_size=256M"'
);
expect(win32).toContain(
'Add-Content C:\\tools\\php\\php.ini "short_open_tag=On"'
);
expect(win32).toContain(
'Add-Content C:\\tools\\php\\php.ini "date.timezone=Asia/Kolkata"'
);
win32 = await features.addINIValues(
'post_max_size=256M, short_open_tag=On, date.timezone=Asia/Kolkata',
'fedora'
);
expect(win32).toContain('Platform fedora is not supported');
});
it('checking addINIValuesOnLinux', async () => {
let linux: string = await features.addINIValues(
'post_max_size=256M, short_open_tag=On, date.timezone=Asia/Kolkata',
'linux'
);
expect(linux).toContain('echo "post_max_size=256M" >> $ini_file');
expect(linux).toContain('echo "short_open_tag=On" >> $ini_file');
expect(linux).toContain('echo "date.timezone=Asia/Kolkata" >> $ini_file');
linux = await features.addINIValues(
'post_max_size=256M, short_open_tag=On, date.timezone=Asia/Kolkata',
'fedora'
);
expect(linux).toContain('Platform fedora is not supported');
});
it('checking addINIValuesOnDarwin', async () => {
let darwin: string = await features.addINIValues(
'post_max_size=256M, short_open_tag=On, date.timezone=Asia/Kolkata',
'darwin'
);
expect(darwin).toContain('echo "post_max_size=256M" >> $ini_file');
expect(darwin).toContain('echo "short_open_tag=On" >> $ini_file');
expect(darwin).toContain('echo "date.timezone=Asia/Kolkata" >> $ini_file');
darwin = await features.addINIValues(
'post_max_size=256M, short_open_tag=On, date.timezone=Asia/Kolkata',
'fedora'
);
expect(darwin).toContain('Platform fedora is not supported');
});
it('checking addCoverage on windows', async () => {
let win32: string = await features.addCoverage('xdebug', '7.4', 'win32');
const extension_url: string =
'https://xdebug.org/files/php_xdebug-2.8.0beta2-7.4-vc15.dll';
expect(win32).toContain(
'Invoke-WebRequest -Uri ' +
extension_url +
' -OutFile C:\\tools\\php\\ext\\php_xdebug.dll'
);
win32 = await features.addCoverage('xdebug', '7.3', 'win32');
expect(win32).toContain('Install-PhpExtension xdebug');
win32 = await features.addCoverage('pcov', '7.4', 'win32');
expect(win32).toContain('Install-PhpExtension pcov');
expect(win32).toContain(
'if(php -m | findstr -i xdebug) { Disable-PhpExtension xdebug C:\\tools\\php'
);
win32 = await features.addCoverage('pcov', '7.3', 'win32');
expect(win32).toContain('Install-PhpExtension pcov');
expect(win32).toContain(
'if(php -m | findstr -i xdebug) { Disable-PhpExtension xdebug C:\\tools\\php'
);
win32 = await features.addCoverage('nocov', '7.3', 'win32');
expect(win32).toContain('');
win32 = await features.addCoverage('pcov', '7.0', 'win32');
expect(win32).toContain('PCOV requires PHP 7.1 or newer');
win32 = await features.addCoverage('pcov', '5.6', 'win32');
expect(win32).toContain('PCOV requires PHP 7.1 or newer');
win32 = await features.addCoverage('', '7.4', 'win32');
expect(win32).toEqual('');
});
it('checking addCoverage on linux', async () => {
let linux: string = await features.addCoverage('xdebug', '7.4', 'linux');
expect(linux).toContain('./xdebug.sh');
linux = await features.addCoverage('pcov', '7.4', 'linux');
expect(linux).toContain('./pcov.sh');
expect(linux).toContain('sudo sed -i "/xdebug/d" $ini_file');
expect(linux).toContain('sudo phpdismod xdebug');
linux = await features.addCoverage('', '7.4', 'linux');
expect(linux).toEqual('');
});
it('checking addCoverage on darwin', async () => {
let darwin: string = await features.addCoverage('xdebug', '7.4', 'darwin');
expect(darwin).toContain('sh ./xdebug_darwin.sh');
darwin = await features.addCoverage('xdebug', '5.6', 'darwin');
expect(darwin).toContain('sudo pecl install xdebug-2.5.5');
darwin = await features.addCoverage('pcov', '7.4', 'darwin');
expect(darwin).toContain('sh ./pcov.sh');
darwin = await features.addCoverage('', '7.4', 'win32');
expect(darwin).toEqual('');
});
});

View File

@ -1,15 +0,0 @@
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);
});
});

View File

@ -61,6 +61,11 @@ describe('Utils tests', () => {
expect(await utils.readScript('fedora.sh', '7.3', 'fedora')).toContain(
'Platform fedora is not supported'
);
await cleanup('./config.yaml');
await cleanup('./pcov.sh');
await cleanup('./phalcon.sh');
await cleanup('./php_pcov.dll');
await cleanup('./xdebug_darwin.sh');
});
it('checking writeScripts', async () => {
@ -82,6 +87,7 @@ describe('Utils tests', () => {
'c',
'd'
]);
expect(await utils.extensionArray('')).toEqual([]);
expect(await utils.extensionArray(' ')).toEqual([]);
});
@ -100,53 +106,48 @@ describe('Utils tests', () => {
let message: string = 'Test message';
let warning_log: string = await utils.log(message, 'win32', 'warning');
expect(warning_log).toEqual(
"Write-Host '" + message + "' -ForegroundColor yellow"
);
expect(warning_log).toEqual('printf "\\033[33;1m' + message + ' \\033[0m"');
warning_log = await utils.log(message, 'linux', 'warning');
expect(warning_log).toEqual('echo "\\033[33;1m' + message + '\\033[0m"');
warning_log = await utils.log(message, 'darwin', 'warning');
expect(warning_log).toEqual('echo "\\033[33;1m' + message + '\\033[0m"');
let error_log: string = await utils.log(message, 'win32', 'error');
expect(error_log).toEqual(
"Write-Host '" + message + "' -ForegroundColor red"
);
expect(error_log).toEqual('printf "\\033[31;1m' + message + ' \\033[0m"');
error_log = await utils.log(message, 'linux', 'error');
expect(error_log).toEqual('echo "\\033[31;1m' + message + '\\033[0m"');
error_log = await utils.log(message, 'darwin', 'error');
expect(error_log).toEqual('echo "\\033[31;1m' + message + '\\033[0m"');
let success_log: string = await utils.log(message, 'win32', 'success');
expect(success_log).toEqual(
"Write-Host '" + message + "' -ForegroundColor green"
);
expect(success_log).toEqual('printf "\\033[32;1m' + message + ' \\033[0m"');
success_log = await utils.log(message, 'linux', 'success');
expect(success_log).toEqual('echo "\\033[32;1m' + message + '\\033[0m"');
success_log = await utils.log(message, 'darwin', 'success');
expect(success_log).toEqual('echo "\\033[32;1m' + message + '\\033[0m"');
success_log = await utils.log(message, 'win32', 'success', 'Test win');
expect(success_log).toEqual(
"Write-Host 'Test win: " + message + "' -ForegroundColor green"
);
});
let step_log: string = await utils.stepLog(message, 'win32');
expect(step_log).toEqual('Step-Log "Test message"');
step_log = await utils.stepLog(message, 'linux');
expect(step_log).toEqual('step_log "Test message"');
step_log = await utils.stepLog(message, 'darwin');
expect(step_log).toEqual('step_log "Test message"');
step_log = await utils.stepLog(message, 'fedora');
expect(step_log).toContain('Platform fedora is not supported');
it('checking log with prefix', async () => {
let message: string = 'Test message';
let prefix_log: string = await utils.log(
message,
'linux',
'success',
'Test Prefix'
);
expect(prefix_log).toEqual(
'echo "\\033[32;1mTest Prefix: ' + message + '\\033[0m"'
);
prefix_log = await utils.log(message, 'darwin', 'success', 'Test');
expect(prefix_log).toEqual(
'echo "\\033[32;1mTest: ' + message + '\\033[0m"'
let add_log: string = await utils.addLog(
'tick',
'xdebug',
'enabled',
'win32'
);
expect(add_log).toEqual('Add-Log "tick" "xdebug" "enabled"');
add_log = await utils.addLog('tick', 'xdebug', 'enabled', 'linux');
expect(add_log).toEqual('add_log "tick" "xdebug" "enabled"');
add_log = await utils.addLog('tick', 'xdebug', 'enabled', 'darwin');
expect(add_log).toEqual('add_log "tick" "xdebug" "enabled"');
add_log = await utils.addLog('tick', 'xdebug', 'enabled', 'fedora');
expect(add_log).toContain('Platform fedora is not supported');
});
it('checking getExtensionPrefix', async () => {
@ -157,4 +158,13 @@ describe('Utils tests', () => {
expect(await utils.getExtensionPrefix('xdebug')).toEqual('zend_extension');
expect(await utils.getExtensionPrefix('opcache')).toEqual('zend_extension');
});
it('checking suppressOutput', async () => {
expect(await utils.suppressOutput('win32')).toEqual(' >$null 2>&1');
expect(await utils.suppressOutput('linux')).toEqual(' >/dev/null 2>&1');
expect(await utils.suppressOutput('darwin')).toEqual(' >/dev/null 2>&1');
expect(await utils.suppressOutput('fedora')).toContain(
'Platform fedora is not supported'
);
});
});

View File

@ -1,21 +1,21 @@
name: 'Setup PHP Action'
author: shivammathur
description: 'Setup a PHP environment with composer and add it to the PATH'
description: 'GitHub action to setup PHP with required extensions, php.ini configuration, code-coverage support and composer'
branding:
icon: 'activity'
color: 'purple'
inputs:
php-version:
description: 'PHP version to be installed.'
description: 'PHP version you want to install.'
required: true
extension-csv:
description: '(Optional) Comma seperated list of PHP extensions to be installed.'
description: '(Optional) PHP extensions you want to install.'
required: false
ini-values-csv:
description: '(Optional) Custom values you want to set in php.ini'
description: '(Optional) Custom values you want to set in php.ini.'
required: false
coverage:
description: '(Optional) Driver to calculate code coverage (Accepts: xdebug and pcov)'
description: '(Optional) Code coverage driver you want to install. (Accepts: xdebug, pcov and none)'
required: false
runs:
using: 'node12'

25
examples/codeigniter.yml Normal file
View 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

View File

@ -1,10 +1,13 @@
# 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 }} on ${{ matrix.operating-system }})
name: Laravel (PHP ${{ matrix.php-versions }})
runs-on: ubuntu-latest
env:
env:
DB_DATABASE: laravel
DB_USERNAME: root
DB_PASSWORD: password
BROADCAST_DRIVER: log
CACHE_DRIVER: redis
@ -27,10 +30,9 @@ jobs:
options: --health-cmd="redis-cli ping" --health-interval=10s --health-timeout=5s --health-retries=3
strategy:
fail-fast: false
max-parallel: 15
max-parallel: 3
matrix:
operating-system: [ubuntu-latest, windows-latest, macOS-latest]
php-versions: ['7.2', '7.3']
php-versions: ['7.2', '7.3', '7.4']
steps:
- name: Checkout
uses: actions/checkout@v1
@ -38,17 +40,21 @@ jobs:
uses: shivammathur/setup-php@master #https://github.com/shivammathur/setup-php
with:
php-version: ${{ matrix.php-versions }}
extension-csv: mbstring #optional
coverage: xdebug #optional
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: |
cp .env.example .env
php -r "file_exists('.env') || copy('.env.example', '.env');"
php artisan key:generate
- name: Clear Config
run: php artisan config:clear
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'] }}

View File

@ -1,14 +1,20 @@
# 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 }} on ${{ matrix.operating-system }})
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
@ -26,10 +32,9 @@ jobs:
options: --health-cmd="redis-cli ping" --health-interval=10s --health-timeout=5s --health-retries=3
strategy:
fail-fast: false
max-parallel: 15
max-parallel: 3
matrix:
operating-system: [ubuntu-latest, windows-latest, macOS-latest]
php-versions: ['7.2', '7.3']
php-versions: ['7.2', '7.3', '7.4']
steps:
- name: Checkout
uses: actions/checkout@v1
@ -37,18 +42,21 @@ jobs:
uses: shivammathur/setup-php@master #https://github.com/shivammathur/setup-php
with:
php-version: ${{ matrix.php-versions }}
extension-csv: mbstring #optional
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: |
cp .env.example .env
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:
POSTGRES_HOST: localhost
POSTGRES_PORT: ${{ job.services.postgres.ports[5432] }}
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
View 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

60
examples/lumen-mysql.yml Normal file
View File

@ -0,0 +1,60 @@
# GitHub Action for Lumen with MySQL and Redis
name: Testing Lumen with MySQL
on: [push, pull_request]
jobs:
lumen:
name: Lumen (PHP ${{ matrix.php-versions }})
runs-on: ubuntu-latest
env:
DB_DATABASE: lumen
DB_USERNAME: root
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: lumen
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']
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
composer require predis/predis illuminate/redis
- name: Prepare the application
run: php -r "file_exists('.env') || copy('.env.example', '.env');"
- name: Register Redis as service provider
run: sed -i '$i\$app->register(Illuminate\\Redis\\RedisServiceProvider::class);' bootstrap/app.php
- 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'] }}

View File

@ -0,0 +1,62 @@
# GitHub Action for Lumen with PostgreSQL and Redis
name: Testing Lumen with PostgreSQL
on: [push, pull_request]
jobs:
laravel:
name: Lumen (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']
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
composer require predis/predis illuminate/redis
- name: Prepare the application
run: php -r "file_exists('.env') || copy('.env.example', '.env');"
- name: Register Redis as service provider
run: sed -i '$i\$app->register(Illuminate\\Redis\\RedisServiceProvider::class);' bootstrap/app.php
- 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] }}

29
examples/lumen.yml Normal file
View File

@ -0,0 +1,29 @@
# GitHub Action for Lumen
name: Unit Testing Lumen
on: [push, pull_request]
jobs:
lumen:
name: Lumen (PHP ${{ matrix.php-versions }} on ${{ matrix.operating-system }})
runs-on: ${{ matrix.operating-system }}
strategy:
fail-fast: false
max-parallel: 9
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, 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');"
- name: Test with phpunit
run: vendor/bin/phpunit --coverage-text
shell: pwsh

View File

@ -0,0 +1,60 @@
# GitHub Action for Phalcon with MySQL
## Notes
## Make sure you have .env.example or .env file in your project
## and you have loaded Dotenv (https://github.com/vlucas/phpdotenv)
name: Testing Phalcon with MySQL
on: [push, pull_request]
jobs:
phalcon:
name: Phalcon (PHP ${{ matrix.php-versions }})
runs-on: ubuntu-latest
env:
DB_ADAPTER: mysql
DB_HOST: 127.0.0.1
DB_NAME: phalcon
DB_USERNAME: root
DB_PASSWORD: password
CODECEPTION_URL: 127.0.0.1
CODECEPTION_PORT: 8888
services:
mysql:
image: mysql:5.7
env:
MYSQL_ALLOW_EMPTY_PASSWORD: false
MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: phalcon
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']
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, phalcon4, mysql #use phalcon3 for the phalcon 3.x.
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');"
- name: Run Migration
run: |
if [ ! -e phinx.yml ]; then vendor/bin/phinx init; fi
vendor/bin/phinx migrate
vendor/bin/phinx seed:run
env:
DB_PORT: ${{ job.services.mysql.ports['3306'] }}
- name: Run Tests
run: |
(cd public && nohup php -S $CODECEPTION_URL:$CODECEPTION_PORT > phalcon.log 2>&1 &)
vendor/bin/codecept build
vendor/bin/codecept run
env:
DB_PORT: ${{ job.services.mysql.ports['3306'] }}

View File

@ -0,0 +1,61 @@
# GitHub Action for Phalcon with PostgreSQL
## Notes
## Make sure you have .env.example or .env file in your project
## and you have loaded Dotenv (https://github.com/vlucas/phpdotenv)
name: Testing Phalcon with PostgreSQL
on: [push, pull_request]
jobs:
phalcon:
name: Phalcon (PHP ${{ matrix.php-versions }})
runs-on: ubuntu-latest
env:
DB_ADAPTER: pgsql
DB_HOST: 127.0.0.1
DB_NAME: postgres
DB_USERNAME: postgres
DB_PASSWORD: postgres
CODECEPTION_URL: 127.0.0.1
CODECEPTION_PORT: 8888
DB_CONNECTION: pgsql
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']
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, phalcon4, pgsql #use phalcon3 for the phalcon 3.x
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');"
- name: Run Migration
run: |
if [ ! -e phinx.yml ]; then vendor/bin/phinx init; fi
vendor/bin/phinx migrate
vendor/bin/phinx seed:run
env:
DB_PORT: ${{ job.services.postgres.ports['5432'] }}
- name: Run Tests
run: |
(cd public && nohup php -S $CODECEPTION_URL:$CODECEPTION_PORT > phalcon.log 2>&1 &)
vendor/bin/codecept build
vendor/bin/codecept run
env:
DB_PORT: ${{ job.services.postgres.ports['5432'] }}

View File

@ -1,3 +1,4 @@
# GitHub Action for Slim Framework
name: Testing Slim Framework
on: [push, pull_request]
jobs:
@ -6,7 +7,7 @@ jobs:
max-parallel: 6
matrix:
operating-system: [ubuntu-latest, windows-latest, macOS-latest]
php-versions: [7.2, 7.3]
php-versions: ['7.2', '7.3']
runs-on: ${{ matrix.operating-system }}
steps:
- name: Checkout
@ -15,7 +16,10 @@ jobs:
uses: shivammathur/setup-php@master #https://github.com/shivammathur/setup-php
with:
php-version: ${{ matrix.php-versions }}
extension-csv: 'mbstring'
coverage: 'xdebug'
extension-csv: mbstring, simplexml, dom
coverage: xdebug #optional
- name: Install dependencies
run: composer install --no-progress --no-suggest --prefer-dist --optimize-autoloader
run: composer install --no-progress --no-suggest --prefer-dist --optimize-autoloader
- name: Test with phpunit
run: vendor/bin/phpunit --coverage-text
shell: pwsh

View 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

View 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
View 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
View 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

View 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

View 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

93
lib/config.js Normal file
View File

@ -0,0 +1,93 @@
"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, no_step = false) {
return __awaiter(this, void 0, void 0, function* () {
let script = '\n';
switch (no_step) {
case true:
script +=
(yield utils.stepLog('Add php.ini values', os_version)) +
(yield utils.suppressOutput(os_version)) +
'\n';
break;
case false:
default:
script += (yield utils.stepLog('Add php.ini values', os_version)) + '\n';
break;
}
switch (os_version) {
case 'win32':
return script + (yield addINIValuesWindows(ini_values_csv));
case 'darwin':
case 'linux':
return script + (yield addINIValuesUnix(ini_values_csv));
default:
return yield utils.log('Platform ' + os_version + ' is not supported', os_version, 'error');
}
});
}
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 ini_values = yield utils.INIArray(ini_values_csv);
let script = '\n';
yield utils.asyncForEach(ini_values, function (line) {
return __awaiter(this, void 0, void 0, function* () {
script +=
(yield utils.addLog('$tick', line, 'Added to php.ini', 'linux')) + '\n';
});
});
return 'echo "' + ini_values.join('\n') + '" >> $ini_file' + 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 ini_values = yield utils.INIArray(ini_values_csv);
let script = '\n';
yield utils.asyncForEach(ini_values, function (line) {
return __awaiter(this, void 0, void 0, function* () {
script +=
(yield utils.addLog('$tick', line, 'Added to php.ini', 'win32')) + '\n';
});
});
return ('Add-Content C:\\tools\\php\\php.ini "' +
ini_values.join('\n') +
'"' +
script);
});
}
exports.addINIValuesWindows = addINIValuesWindows;

151
lib/coverage.js Normal file
View File

@ -0,0 +1,151 @@
"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 to set coverage driver
*
* @param coverage_driver
* @param version
* @param os_version
*/
function addCoverage(coverage_driver, version, os_version) {
return __awaiter(this, void 0, void 0, function* () {
coverage_driver.toLowerCase();
let script = '\n' + (yield utils.stepLog('Setup Coverage', os_version));
switch (coverage_driver) {
case 'pcov':
return script + (yield addCoveragePCOV(version, os_version));
case 'xdebug':
return script + (yield addCoverageXdebug(version, os_version));
case 'none':
return script + (yield disableCoverage(version, os_version));
default:
return '';
}
});
}
exports.addCoverage = addCoverage;
/**
* Function to setup Xdebug
*
* @param version
* @param os_version
*/
function addCoverageXdebug(version, os_version) {
return __awaiter(this, void 0, void 0, function* () {
return ((yield extensions.addExtension('xdebug', version, os_version, true)) +
(yield utils.suppressOutput(os_version)) +
'\n' +
(yield utils.addLog('$tick', 'xdebug', 'Xdebug enabled as coverage driver', os_version)));
});
}
exports.addCoverageXdebug = addCoverageXdebug;
/**
* Function to setup PCOV
*
* @param version
* @param os_version
*/
function addCoveragePCOV(version, os_version) {
return __awaiter(this, void 0, void 0, function* () {
let script = '\n';
switch (version) {
default:
script +=
(yield extensions.addExtension('pcov', version, os_version, true)) +
(yield utils.suppressOutput(os_version)) +
'\n';
script +=
(yield config.addINIValues('pcov.enabled=1', os_version, true)) + '\n';
// 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 -v ' +
version +
' 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.addLog('$tick', 'coverage: pcov', 'PCOV enabled as coverage driver', os_version);
// version is not supported
break;
case '5.6':
case '7.0':
script += yield utils.addLog('$cross', 'pcov', 'PHP 7.1 or newer is required', os_version);
break;
}
return script;
});
}
exports.addCoveragePCOV = addCoveragePCOV;
/**
* Function to disable Xdebug and PCOV
*
* @param version
* @param os_version
*/
function disableCoverage(version, os_version) {
return __awaiter(this, void 0, void 0, function* () {
let script = '\n';
switch (os_version) {
case 'linux':
script +=
'if [ -e /etc/php/' +
version +
'/mods-available/xdebug.ini ]; then sudo phpdismod -v ' +
version +
' xdebug; fi\n';
script +=
'if [ -e /etc/php/' +
version +
'/mods-available/pcov.ini ]; then sudo phpdismod -v ' +
version +
' pcov; fi\n';
script += 'sudo sed -i "/xdebug/d" $ini_file\n';
script += 'sudo sed -i "/pcov/d" $ini_file\n';
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.addLog('$tick', 'none', 'Disabled Xdebug and PCOV', os_version);
return script;
});
}
exports.disableCoverage = disableCoverage;

194
lib/extensions.js Normal file
View File

@ -0,0 +1,194 @@
"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"));
/**
* Install and enable extensions
*
* @param extension_csv
* @param version
* @param os_version
* @param log_prefix
*/
function addExtension(extension_csv, version, os_version, no_step = false) {
return __awaiter(this, void 0, void 0, function* () {
let script = '\n';
switch (no_step) {
case true:
script +=
(yield utils.stepLog('Setup Extensions', os_version)) +
(yield utils.suppressOutput(os_version));
break;
case false:
default:
script += yield utils.stepLog('Setup Extensions', os_version);
break;
}
switch (os_version) {
case 'win32':
return script + (yield addExtensionWindows(extension_csv, version));
case 'darwin':
return script + (yield addExtensionDarwin(extension_csv, version));
case 'linux':
return script + (yield addExtensionLinux(extension_csv, version));
default:
return yield utils.log('Platform ' + os_version + ' is not supported', os_version, 'error');
}
});
}
exports.addExtension = addExtension;
/**
* 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
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 +=
'\nadd_extension ' +
extension +
' "' +
install_command +
'" ' +
(yield utils.getExtensionPrefix(extension));
});
});
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
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 +=
'\nAdd-Extension ' +
extension +
' "' +
install_command +
'" ' +
(yield utils.getExtensionPrefix(extension));
});
});
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
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;
case '7.2phalcon3':
case '7.3phalcon3':
install_command = './phalcon.sh master ' + version + ' >/dev/null 2>&1';
break;
case '7.2phalcon4':
case '7.3phalcon4':
install_command = './phalcon.sh 4.0.x ' + version + ' >/dev/null 2>&1';
break;
default:
install_command =
'sudo DEBIAN_FRONTEND=noninteractive apt install -y php' +
version +
'-' +
extension +
' >/dev/null 2>&1';
break;
}
script +=
'\nadd_extension ' +
extension +
' "' +
install_command +
'" ' +
(yield utils.getExtensionPrefix(extension));
});
});
return script;
});
}
exports.addExtensionLinux = addExtensionLinux;

View File

@ -1,350 +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, 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;
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;
/**
* 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}" >> 'php -i | grep "Loaded Configuration" | sed -e "s|.*=>\s*||"'\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;
/**
* Add script to set custom ini values for unix
*
* @param ini_values_csv
*/
function addINIValuesUnix(ini_values_csv) {
return __awaiter(this, void 0, void 0, function* () {
let script = '\n';
let ini_values = yield utils.INIArray(ini_values_csv);
yield utils.asyncForEach(ini_values, function (ini_value) {
return __awaiter(this, void 0, void 0, function* () {
// add script to set ini value
script += 'echo "' + ini_value + '" >> $ini_file\n';
});
});
return script;
});
}
exports.addINIValuesUnix = addINIValuesUnix;
/**
* Add script to set custom ini values for windows
*
* @param ini_values_csv
*/
function addINIValuesWindows(ini_values_csv) {
return __awaiter(this, void 0, void 0, function* () {
let script = '\n';
let ini_values = yield utils.INIArray(ini_values_csv);
yield utils.asyncForEach(ini_values, function (ini_value) {
return __awaiter(this, void 0, void 0, function* () {
// add script to set ini value
script += 'Add-Content C:\\tools\\php\\php.ini "' + ini_value + '"\n';
});
});
return script;
});
}
exports.addINIValuesWindows = addINIValuesWindows;
function addCoverage(coverage, version, os_version) {
return __awaiter(this, void 0, void 0, function* () {
let script = '';
script += '\n';
coverage = coverage.toLowerCase();
// pcov
switch (coverage) {
case 'pcov':
// if version is 7.1 or newer
switch (version) {
default:
script += yield addExtension('pcov', version, os_version, 'Set Coverage Driver');
script += yield addINIValues('pcov.enabled=1', os_version);
// add command to disable xdebug and enable pcov
switch (os_version) {
case 'linux':
script +=
'if [ -e /etc/php/' +
version +
'/mods-available/xdebug.ini ]; then sudo phpdismod xdebug; fi\n';
script += 'sudo sed -i "/xdebug/d" $ini_file\n';
break;
case 'darwin':
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;
}
break;
//xdebug
case 'xdebug':
script += yield addExtension('xdebug', version, os_version, 'Set Coverage Driver');
script += yield utils.log('Xdebug enabled as coverage driver', os_version, 'success', 'Set Coverage Driver');
break;
// unknown coverage driver
default:
script = '';
}
return script;
});
}
exports.addCoverage = addCoverage;

View File

@ -19,51 +19,61 @@ Object.defineProperty(exports, "__esModule", { value: true });
const exec_1 = require("@actions/exec/lib/exec");
const core = __importStar(require("@actions/core"));
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"));
/**
* Build the script
*
* @param filename
* @param version
* @param os_version
*/
function build(filename, version, os_version) {
return __awaiter(this, void 0, void 0, function* () {
// taking inputs
let extension_csv = yield utils.getInput('extension-csv', false);
let ini_values_csv = yield utils.getInput('ini-values-csv', false);
let coverage_driver = yield utils.getInput('coverage', false);
let script = yield utils.readScript(filename, version, os_version);
if (extension_csv) {
script += yield extensions.addExtension(extension_csv, version, os_version);
}
if (ini_values_csv) {
script += yield config.addINIValues(ini_values_csv, os_version);
}
if (coverage_driver) {
script += yield coverage.addCoverage(coverage_driver, version, os_version);
}
yield utils.writeScript(filename, version, script);
});
}
/**
* Run the script
*/
function run() {
return __awaiter(this, void 0, void 0, function* () {
try {
// taking inputs
let version = yield utils.getInput('php-version', true);
let extension_csv = yield utils.getInput('extension-csv', false);
let ini_values_csv = yield utils.getInput('ini-values-csv', false);
let coverage = yield utils.getInput('coverage', false);
let os_version = process.platform;
let version = yield utils.getInput('php-version', true);
// check the os version and run the respective script
if (os_version == 'darwin') {
let darwin = yield utils.readScript('darwin.sh', version, os_version);
darwin += yield features.addExtension(extension_csv, version, os_version);
darwin += yield features.addINIValues(ini_values_csv, os_version);
darwin += yield features.addCoverage(coverage, version, os_version);
yield utils.writeScript('darwin.sh', version, darwin);
yield build('darwin.sh', version, os_version);
yield exec_1.exec('sh ./' + version + 'darwin.sh ' + version);
}
else if (os_version == 'win32') {
let windows = yield utils.readScript('win32.ps1', version, os_version);
windows += yield features.addExtension(extension_csv, version, os_version);
windows += yield features.addINIValues(ini_values_csv, os_version);
windows += yield features.addCoverage(coverage, version, os_version);
yield utils.writeScript('win32.ps1', version, windows);
yield build('win32.ps1', version, os_version);
yield exec_1.exec('powershell .\\' + version + 'win32.ps1 -version ' + version);
}
else if (os_version == 'linux') {
let linux = yield utils.readScript('linux.sh', version, os_version);
linux += yield features.addExtension(extension_csv, version, os_version);
linux += yield features.addINIValues(ini_values_csv, os_version);
linux += yield features.addCoverage(coverage, version, os_version);
yield utils.writeScript('linux.sh', version, linux);
yield build('linux.sh', version, os_version);
yield exec_1.exec('./' + version + 'linux.sh ' + version);
}
}
catch (err) {
core.setFailed(err.message);
catch (error) {
core.setFailed(error.message);
}
});
}
// call the run function
run().then(function () {
console.log('done');
});
run();

View File

@ -28,7 +28,7 @@ function checkPECLExtension(extension) {
allowRetries: true,
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;
});
}

View File

@ -19,6 +19,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
const fs = __importStar(require("fs"));
const path = __importStar(require("path"));
const core = __importStar(require("@actions/core"));
/**
* Function to get inputs from both with and env annotations.
*
* @param name
* @param mandatory
*/
function getInput(name, mandatory) {
return __awaiter(this, void 0, void 0, function* () {
let input = process.env[name];
@ -52,14 +58,14 @@ exports.asyncForEach = asyncForEach;
*
* @param files
*/
function readFiles74(files) {
function moveFiles(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;
exports.moveFiles = moveFiles;
/**
* Read the scripts
*
@ -73,7 +79,7 @@ function readScript(filename, version, os_version) {
case 'darwin':
switch (version) {
case '7.4':
yield readFiles74([
yield moveFiles([
'configs/config.yaml',
'scripts/xdebug_darwin.sh',
'scripts/pcov.sh'
@ -82,16 +88,18 @@ function readScript(filename, version, os_version) {
}
break;
case 'linux':
let files = ['scripts/phalcon.sh'];
switch (version) {
case '7.4':
yield readFiles74(['scripts/xdebug.sh', 'scripts/pcov.sh']);
files = files.concat(['scripts/xdebug.sh', 'scripts/pcov.sh']);
break;
}
yield moveFiles(files);
break;
case 'win32':
switch (version) {
case '7.4':
yield readFiles74(['ext/php_pcov.dll']);
yield moveFiles(['ext/php_pcov.dll']);
break;
}
break;
@ -117,6 +125,7 @@ function writeScript(filename, version, script) {
exports.writeScript = writeScript;
/**
* Function to break extension csv into an array
*
* @param extension_csv
*/
function extensionArray(extension_csv) {
@ -156,46 +165,77 @@ function INIArray(ini_values_csv) {
});
}
exports.INIArray = INIArray;
function log(message, os_version, log_type, prefix = '') {
/**
* Function to log a step
*
* @param message
* @param os_version
*/
function stepLog(message, os_version) {
return __awaiter(this, void 0, void 0, function* () {
const unix_color = {
switch (os_version) {
case 'win32':
return 'Step-Log "' + message + '"';
case 'linux':
case 'darwin':
return 'step_log "' + message + '"';
default:
return yield log('Platform ' + os_version + ' is not supported', os_version, 'error');
}
});
}
exports.stepLog = stepLog;
/**
* Function to log a result
* @param mark
* @param subject
* @param message
*/
function addLog(mark, subject, message, os_version) {
return __awaiter(this, void 0, void 0, function* () {
switch (os_version) {
case 'win32':
return 'Add-Log "' + mark + '" "' + subject + '" "' + message + '"';
case 'linux':
case 'darwin':
return 'add_log "' + mark + '" "' + subject + '" "' + message + '"';
default:
return yield log('Platform ' + os_version + ' is not supported', os_version, 'error');
}
});
}
exports.addLog = addLog;
/**
* Log to console
*
* @param message
* @param os_version
* @param log_type
* @param prefix
*/
function log(message, os_version, log_type) {
return __awaiter(this, void 0, void 0, function* () {
const color = {
error: '31',
success: '32',
warning: '33'
};
switch (prefix) {
case '':
prefix = prefix;
break;
default:
prefix = prefix + ': ';
break;
}
switch (os_version) {
case 'win32':
const color = {
error: 'red',
success: 'green',
warning: 'yellow'
};
return ("Write-Host '" +
prefix +
message +
"' -ForegroundColor " +
color[log_type]);
return ('printf "\\033[' + color[log_type] + ';1m' + message + ' \\033[0m"');
case 'linux':
case 'darwin':
default:
return ('echo "\\033[' +
unix_color[log_type] +
';1m' +
prefix +
message +
'\\033[0m"');
return 'echo "\\033[' + color[log_type] + ';1m' + message + '\\033[0m"';
}
});
}
exports.log = log;
/**
* Function to get prefix required to load an extension.
*
* @param extension
*/
function getExtensionPrefix(extension) {
return __awaiter(this, void 0, void 0, function* () {
let zend = ['xdebug', 'opcache', 'ioncube', 'eaccelerator'];
@ -210,3 +250,22 @@ function getExtensionPrefix(extension) {
});
}
exports.getExtensionPrefix = getExtensionPrefix;
/**
* Function to get the suffix to suppress console output
*
* @param os_version
*/
function suppressOutput(os_version) {
return __awaiter(this, void 0, void 0, function* () {
switch (os_version) {
case 'win32':
return ' >$null 2>&1';
case 'linux':
case 'darwin':
return ' >/dev/null 2>&1';
default:
return yield log('Platform ' + os_version + ' is not supported', os_version, 'error');
}
});
}
exports.suppressOutput = suppressOutput;

40
node_modules/@actions/core/README.md generated vendored
View File

@ -4,45 +4,53 @@
## Usage
#### Inputs/Outputs
You can use this library to get inputs or set outputs:
### Import the package
```js
// javascript
const core = require('@actions/core');
const myInput = core.getInput('inputName', { required: true });
// typescript
import * as core from '@actions/core';
```
// Do stuff
#### Inputs/Outputs
Action inputs can be read with `getInput`. Outputs can be set with `setOutput` which makes them available to be mapped into inputs of other actions to ensure they are decoupled.
```js
const myInput = core.getInput('inputName', { required: true });
core.setOutput('outputKey', 'outputVal');
```
#### Exporting variables
You can also export variables for future steps. Variables get set in the environment.
Since each step runs in a separate process, you can use `exportVariable` to add it to this step and future steps environment blocks.
```js
const core = require('@actions/core');
// Do stuff
core.exportVariable('envVar', 'Val');
```
#### Setting a secret
Setting a secret registers the secret with the runner to ensure it is masked in logs.
```js
core.setSecret('myPassword');
```
#### PATH Manipulation
You can explicitly add items to the path for all remaining steps in a workflow:
To make a tool's path available in the path for the remainder of the job (without altering the machine or containers state), use `addPath`. The runner will prepend the path given to the jobs PATH.
```js
const core = require('@actions/core');
core.addPath('pathToTool');
core.addPath('/path/to/mytool');
```
#### Exit codes
You should use this library to set the failing exit code for your action:
You should use this library to set the failing exit code for your action. If status is not set and the script runs to completion, that will lead to a success.
```js
const core = require('@actions/core');
@ -55,6 +63,8 @@ catch (err) {
core.setFailed(`Action failed with error ${err}`);
}
Note that `setNeutral` is not yet implemented in actions V2 but equivalent functionality is being planned.
```
#### Logging

View File

@ -19,17 +19,16 @@ export declare enum ExitCode {
Failure = 1
}
/**
* sets env variable for this action and future actions in the job
* Sets env variable for this action and future actions in the job
* @param name the name of the variable to set
* @param val the value of the variable
*/
export declare function exportVariable(name: string, val: string): void;
/**
* exports the variable and registers a secret which will get masked from logs
* @param name the name of the variable to set
* @param val value of the secret
* Registers a secret which will get masked from logs
* @param secret value of the secret
*/
export declare function exportSecret(name: string, val: string): void;
export declare function setSecret(secret: string): void;
/**
* Prepends inputPath to the PATH (for this action and future actions)
* @param inputPath

View File

@ -30,7 +30,7 @@ var ExitCode;
// Variables
//-----------------------------------------------------------------------
/**
* sets env variable for this action and future actions in the job
* Sets env variable for this action and future actions in the job
* @param name the name of the variable to set
* @param val the value of the variable
*/
@ -40,18 +40,13 @@ function exportVariable(name, val) {
}
exports.exportVariable = exportVariable;
/**
* exports the variable and registers a secret which will get masked from logs
* @param name the name of the variable to set
* @param val value of the secret
* Registers a secret which will get masked from logs
* @param secret value of the secret
*/
function exportSecret(name, val) {
exportVariable(name, val);
// the runner will error with not implemented
// leaving the function but raising the error earlier
command_1.issueCommand('set-secret', {}, val);
throw new Error('Not implemented.');
function setSecret(secret) {
command_1.issueCommand('add-mask', {}, secret);
}
exports.exportSecret = exportSecret;
exports.setSecret = setSecret;
/**
* Prepends inputPath to the PATH (for this action and future actions)
* @param inputPath

View File

@ -1 +1 @@
{"version":3,"file":"core.js","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,uCAA6C;AAE7C,yBAAwB;AACxB,6BAA4B;AAU5B;;GAEG;AACH,IAAY,QAUX;AAVD,WAAY,QAAQ;IAClB;;OAEG;IACH,6CAAW,CAAA;IAEX;;OAEG;IACH,6CAAW,CAAA;AACb,CAAC,EAVW,QAAQ,GAAR,gBAAQ,KAAR,gBAAQ,QAUnB;AAED,yEAAyE;AACzE,YAAY;AACZ,yEAAyE;AAEzE;;;;GAIG;AACH,SAAgB,cAAc,CAAC,IAAY,EAAE,GAAW;IACtD,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,GAAG,CAAA;IACvB,sBAAY,CAAC,SAAS,EAAE,EAAC,IAAI,EAAC,EAAE,GAAG,CAAC,CAAA;AACtC,CAAC;AAHD,wCAGC;AAED;;;;GAIG;AACH,SAAgB,YAAY,CAAC,IAAY,EAAE,GAAW;IACpD,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,CAAA;IAEzB,6CAA6C;IAC7C,qDAAqD;IACrD,sBAAY,CAAC,YAAY,EAAE,EAAE,EAAE,GAAG,CAAC,CAAA;IACnC,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAA;AACrC,CAAC;AAPD,oCAOC;AAED;;;GAGG;AACH,SAAgB,OAAO,CAAC,SAAiB;IACvC,sBAAY,CAAC,UAAU,EAAE,EAAE,EAAE,SAAS,CAAC,CAAA;IACvC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,GAAG,SAAS,GAAG,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAA;AAC7E,CAAC;AAHD,0BAGC;AAED;;;;;;GAMG;AACH,SAAgB,QAAQ,CAAC,IAAY,EAAE,OAAsB;IAC3D,MAAM,GAAG,GACP,OAAO,CAAC,GAAG,CAAC,SAAS,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,IAAI,EAAE,CAAA;IACrE,IAAI,OAAO,IAAI,OAAO,CAAC,QAAQ,IAAI,CAAC,GAAG,EAAE;QACvC,MAAM,IAAI,KAAK,CAAC,oCAAoC,IAAI,EAAE,CAAC,CAAA;KAC5D;IAED,OAAO,GAAG,CAAC,IAAI,EAAE,CAAA;AACnB,CAAC;AARD,4BAQC;AAED;;;;;GAKG;AACH,SAAgB,SAAS,CAAC,IAAY,EAAE,KAAa;IACnD,sBAAY,CAAC,YAAY,EAAE,EAAC,IAAI,EAAC,EAAE,KAAK,CAAC,CAAA;AAC3C,CAAC;AAFD,8BAEC;AAED,yEAAyE;AACzE,UAAU;AACV,yEAAyE;AAEzE;;;;GAIG;AACH,SAAgB,SAAS,CAAC,OAAe;IACvC,OAAO,CAAC,QAAQ,GAAG,QAAQ,CAAC,OAAO,CAAA;IACnC,KAAK,CAAC,OAAO,CAAC,CAAA;AAChB,CAAC;AAHD,8BAGC;AAED,yEAAyE;AACzE,mBAAmB;AACnB,yEAAyE;AAEzE;;;GAGG;AACH,SAAgB,KAAK,CAAC,OAAe;IACnC,sBAAY,CAAC,OAAO,EAAE,EAAE,EAAE,OAAO,CAAC,CAAA;AACpC,CAAC;AAFD,sBAEC;AAED;;;GAGG;AACH,SAAgB,KAAK,CAAC,OAAe;IACnC,eAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;AACzB,CAAC;AAFD,sBAEC;AAED;;;GAGG;AACH,SAAgB,OAAO,CAAC,OAAe;IACrC,eAAK,CAAC,SAAS,EAAE,OAAO,CAAC,CAAA;AAC3B,CAAC;AAFD,0BAEC;AAED;;;GAGG;AACH,SAAgB,IAAI,CAAC,OAAe;IAClC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,GAAG,EAAE,CAAC,GAAG,CAAC,CAAA;AACxC,CAAC;AAFD,oBAEC;AAED;;;;;;GAMG;AACH,SAAgB,UAAU,CAAC,IAAY;IACrC,eAAK,CAAC,OAAO,EAAE,IAAI,CAAC,CAAA;AACtB,CAAC;AAFD,gCAEC;AAED;;GAEG;AACH,SAAgB,QAAQ;IACtB,eAAK,CAAC,UAAU,CAAC,CAAA;AACnB,CAAC;AAFD,4BAEC;AAED;;;;;;;GAOG;AACH,SAAsB,KAAK,CAAI,IAAY,EAAE,EAAoB;;QAC/D,UAAU,CAAC,IAAI,CAAC,CAAA;QAEhB,IAAI,MAAS,CAAA;QAEb,IAAI;YACF,MAAM,GAAG,MAAM,EAAE,EAAE,CAAA;SACpB;gBAAS;YACR,QAAQ,EAAE,CAAA;SACX;QAED,OAAO,MAAM,CAAA;IACf,CAAC;CAAA;AAZD,sBAYC"}
{"version":3,"file":"core.js","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,uCAA6C;AAE7C,yBAAwB;AACxB,6BAA4B;AAU5B;;GAEG;AACH,IAAY,QAUX;AAVD,WAAY,QAAQ;IAClB;;OAEG;IACH,6CAAW,CAAA;IAEX;;OAEG;IACH,6CAAW,CAAA;AACb,CAAC,EAVW,QAAQ,GAAR,gBAAQ,KAAR,gBAAQ,QAUnB;AAED,yEAAyE;AACzE,YAAY;AACZ,yEAAyE;AAEzE;;;;GAIG;AACH,SAAgB,cAAc,CAAC,IAAY,EAAE,GAAW;IACtD,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,GAAG,CAAA;IACvB,sBAAY,CAAC,SAAS,EAAE,EAAC,IAAI,EAAC,EAAE,GAAG,CAAC,CAAA;AACtC,CAAC;AAHD,wCAGC;AAED;;;GAGG;AACH,SAAgB,SAAS,CAAC,MAAc;IACtC,sBAAY,CAAC,UAAU,EAAE,EAAE,EAAE,MAAM,CAAC,CAAA;AACtC,CAAC;AAFD,8BAEC;AAED;;;GAGG;AACH,SAAgB,OAAO,CAAC,SAAiB;IACvC,sBAAY,CAAC,UAAU,EAAE,EAAE,EAAE,SAAS,CAAC,CAAA;IACvC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,GAAG,SAAS,GAAG,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAA;AAC7E,CAAC;AAHD,0BAGC;AAED;;;;;;GAMG;AACH,SAAgB,QAAQ,CAAC,IAAY,EAAE,OAAsB;IAC3D,MAAM,GAAG,GACP,OAAO,CAAC,GAAG,CAAC,SAAS,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,IAAI,EAAE,CAAA;IACrE,IAAI,OAAO,IAAI,OAAO,CAAC,QAAQ,IAAI,CAAC,GAAG,EAAE;QACvC,MAAM,IAAI,KAAK,CAAC,oCAAoC,IAAI,EAAE,CAAC,CAAA;KAC5D;IAED,OAAO,GAAG,CAAC,IAAI,EAAE,CAAA;AACnB,CAAC;AARD,4BAQC;AAED;;;;;GAKG;AACH,SAAgB,SAAS,CAAC,IAAY,EAAE,KAAa;IACnD,sBAAY,CAAC,YAAY,EAAE,EAAC,IAAI,EAAC,EAAE,KAAK,CAAC,CAAA;AAC3C,CAAC;AAFD,8BAEC;AAED,yEAAyE;AACzE,UAAU;AACV,yEAAyE;AAEzE;;;;GAIG;AACH,SAAgB,SAAS,CAAC,OAAe;IACvC,OAAO,CAAC,QAAQ,GAAG,QAAQ,CAAC,OAAO,CAAA;IACnC,KAAK,CAAC,OAAO,CAAC,CAAA;AAChB,CAAC;AAHD,8BAGC;AAED,yEAAyE;AACzE,mBAAmB;AACnB,yEAAyE;AAEzE;;;GAGG;AACH,SAAgB,KAAK,CAAC,OAAe;IACnC,sBAAY,CAAC,OAAO,EAAE,EAAE,EAAE,OAAO,CAAC,CAAA;AACpC,CAAC;AAFD,sBAEC;AAED;;;GAGG;AACH,SAAgB,KAAK,CAAC,OAAe;IACnC,eAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;AACzB,CAAC;AAFD,sBAEC;AAED;;;GAGG;AACH,SAAgB,OAAO,CAAC,OAAe;IACrC,eAAK,CAAC,SAAS,EAAE,OAAO,CAAC,CAAA;AAC3B,CAAC;AAFD,0BAEC;AAED;;;GAGG;AACH,SAAgB,IAAI,CAAC,OAAe;IAClC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,GAAG,EAAE,CAAC,GAAG,CAAC,CAAA;AACxC,CAAC;AAFD,oBAEC;AAED;;;;;;GAMG;AACH,SAAgB,UAAU,CAAC,IAAY;IACrC,eAAK,CAAC,OAAO,EAAE,IAAI,CAAC,CAAA;AACtB,CAAC;AAFD,gCAEC;AAED;;GAEG;AACH,SAAgB,QAAQ;IACtB,eAAK,CAAC,UAAU,CAAC,CAAA;AACnB,CAAC;AAFD,4BAEC;AAED;;;;;;;GAOG;AACH,SAAsB,KAAK,CAAI,IAAY,EAAE,EAAoB;;QAC/D,UAAU,CAAC,IAAI,CAAC,CAAA;QAEhB,IAAI,MAAS,CAAA;QAEb,IAAI;YACF,MAAM,GAAG,MAAM,EAAE,EAAE,CAAA;SACpB;gBAAS;YACR,QAAQ,EAAE,CAAA;SACX;QAED,OAAO,MAAM,CAAA;IACf,CAAC;CAAA;AAZD,sBAYC"}

View File

@ -1,33 +1,33 @@
{
"_args": [
[
"@actions/core@1.1.1",
"@actions/core@1.1.3",
"E:\\python\\setup-php"
]
],
"_from": "@actions/core@1.1.1",
"_id": "@actions/core@1.1.1",
"_from": "@actions/core@1.1.3",
"_id": "@actions/core@1.1.3",
"_inBundle": false,
"_integrity": "sha512-O5G6EmlzTVsng7VSpNtszIoQq6kOgMGNTFB/hmwKNNA4V71JyxImCIrL27vVHCt2Cb3ImkaCr6o27C2MV9Ylwg==",
"_integrity": "sha512-2BIib53Jh4Cfm+1XNuZYYGTeRo8yiWEAUMoliMh1qQGMaqTF4VUlhhcsBylTu4qWmUx45DrY0y0XskimAHSqhw==",
"_location": "/@actions/core",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "@actions/core@1.1.1",
"raw": "@actions/core@1.1.3",
"name": "@actions/core",
"escapedName": "@actions%2fcore",
"scope": "@actions",
"rawSpec": "1.1.1",
"rawSpec": "1.1.3",
"saveSpec": null,
"fetchSpec": "1.1.1"
"fetchSpec": "1.1.3"
},
"_requiredBy": [
"/",
"/@actions/tool-cache"
],
"_resolved": "https://registry.npmjs.org/@actions/core/-/core-1.1.1.tgz",
"_spec": "1.1.1",
"_resolved": "https://registry.npmjs.org/@actions/core/-/core-1.1.3.tgz",
"_spec": "1.1.3",
"_where": "E:\\python\\setup-php",
"bugs": {
"url": "https://github.com/actions/toolkit/issues"
@ -57,11 +57,12 @@
},
"repository": {
"type": "git",
"url": "git+https://github.com/actions/toolkit.git"
"url": "git+https://github.com/actions/toolkit.git",
"directory": "packages/core"
},
"scripts": {
"test": "echo \"Error: run tests from root\" && exit 1",
"tsc": "tsc"
},
"version": "1.1.1"
"version": "1.1.3"
}

View File

@ -22,7 +22,6 @@
"fetchSpec": "1.5.0"
},
"_requiredBy": [
"/",
"/@actions/tool-cache"
],
"_resolved": "https://registry.npmjs.org/typed-rest-client/-/typed-rest-client-1.5.0.tgz",

120
package-lock.json generated
View File

@ -1,13 +1,13 @@
{
"name": "setup-php",
"version": "1.3.8",
"version": "1.4.3",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"@actions/core": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.1.1.tgz",
"integrity": "sha512-O5G6EmlzTVsng7VSpNtszIoQq6kOgMGNTFB/hmwKNNA4V71JyxImCIrL27vVHCt2Cb3ImkaCr6o27C2MV9Ylwg=="
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.1.3.tgz",
"integrity": "sha512-2BIib53Jh4Cfm+1XNuZYYGTeRo8yiWEAUMoliMh1qQGMaqTF4VUlhhcsBylTu4qWmUx45DrY0y0XskimAHSqhw=="
},
"@actions/exec": {
"version": "1.0.1",
@ -42,18 +42,18 @@
}
},
"@babel/core": {
"version": "7.6.2",
"resolved": "https://registry.npmjs.org/@babel/core/-/core-7.6.2.tgz",
"integrity": "sha512-l8zto/fuoZIbncm+01p8zPSDZu/VuuJhAfA7d/AbzM09WR7iVhavvfNDYCNpo1VvLk6E6xgAoP9P+/EMJHuRkQ==",
"version": "7.6.4",
"resolved": "https://registry.npmjs.org/@babel/core/-/core-7.6.4.tgz",
"integrity": "sha512-Rm0HGw101GY8FTzpWSyRbki/jzq+/PkNQJ+nSulrdY6gFGOsNseCqD6KHRYe2E+EdzuBdr2pxCp6s4Uk6eJ+XQ==",
"dev": true,
"requires": {
"@babel/code-frame": "^7.5.5",
"@babel/generator": "^7.6.2",
"@babel/generator": "^7.6.4",
"@babel/helpers": "^7.6.2",
"@babel/parser": "^7.6.2",
"@babel/parser": "^7.6.4",
"@babel/template": "^7.6.0",
"@babel/traverse": "^7.6.2",
"@babel/types": "^7.6.0",
"@babel/traverse": "^7.6.3",
"@babel/types": "^7.6.3",
"convert-source-map": "^1.1.0",
"debug": "^4.1.0",
"json5": "^2.1.0",
@ -93,12 +93,12 @@
}
},
"@babel/generator": {
"version": "7.6.2",
"resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.6.2.tgz",
"integrity": "sha512-j8iHaIW4gGPnViaIHI7e9t/Hl8qLjERI6DcV9kEpAIDJsAOrcnXqRS7t+QbhL76pwbtqP+QCQLL0z1CyVmtjjQ==",
"version": "7.6.4",
"resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.6.4.tgz",
"integrity": "sha512-jsBuXkFoZxk0yWLyGI9llT9oiQ2FeTASmRFE32U+aaDTfoE92t78eroO7PTpU/OrYq38hlcDM6vbfLDaOLy+7w==",
"dev": true,
"requires": {
"@babel/types": "^7.6.0",
"@babel/types": "^7.6.3",
"jsesc": "^2.5.1",
"lodash": "^4.17.13",
"source-map": "^0.5.0"
@ -170,9 +170,9 @@
}
},
"@babel/parser": {
"version": "7.6.2",
"resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.6.2.tgz",
"integrity": "sha512-mdFqWrSPCmikBoaBYMuBulzTIKuXVPtEISFbRRVNwMWpCms/hmE2kRq0bblUHaNRKrjRlmVbx1sDHmjmRgD2Xg==",
"version": "7.6.4",
"resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.6.4.tgz",
"integrity": "sha512-D8RHPW5qd0Vbyo3qb+YjO5nvUVRTXFLQ/FsDxJU2Nqz4uB5EnUN0ZQSEYpvTIbRuttig1XbHWU5oMeQwQSAA+A==",
"dev": true
},
"@babel/plugin-syntax-object-rest-spread": {
@ -196,17 +196,17 @@
}
},
"@babel/traverse": {
"version": "7.6.2",
"resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.6.2.tgz",
"integrity": "sha512-8fRE76xNwNttVEF2TwxJDGBLWthUkHWSldmfuBzVRmEDWOtu4XdINTgN7TDWzuLg4bbeIMLvfMFD9we5YcWkRQ==",
"version": "7.6.3",
"resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.6.3.tgz",
"integrity": "sha512-unn7P4LGsijIxaAJo/wpoU11zN+2IaClkQAxcJWBNCMS6cmVh802IyLHNkAjQ0iYnRS3nnxk5O3fuXW28IMxTw==",
"dev": true,
"requires": {
"@babel/code-frame": "^7.5.5",
"@babel/generator": "^7.6.2",
"@babel/generator": "^7.6.3",
"@babel/helper-function-name": "^7.1.0",
"@babel/helper-split-export-declaration": "^7.4.4",
"@babel/parser": "^7.6.2",
"@babel/types": "^7.6.0",
"@babel/parser": "^7.6.3",
"@babel/types": "^7.6.3",
"debug": "^4.1.0",
"globals": "^11.1.0",
"lodash": "^4.17.13"
@ -230,9 +230,9 @@
}
},
"@babel/types": {
"version": "7.6.1",
"resolved": "https://registry.npmjs.org/@babel/types/-/types-7.6.1.tgz",
"integrity": "sha512-X7gdiuaCmA0uRjCmRtYJNAVCc/q+5xSgsfKJHqMN4iNLILX39677fJE1O40arPMh0TTtS9ItH67yre6c7k6t0g==",
"version": "7.6.3",
"resolved": "https://registry.npmjs.org/@babel/types/-/types-7.6.3.tgz",
"integrity": "sha512-CqbcpTxMcpuQTMhjI37ZHVgjBkysg5icREQIEZ0eG1yCNwg3oy+5AaLiOKmjsCj6nqOsa6Hf0ObjRVwokb7srA==",
"dev": true,
"requires": {
"esutils": "^2.0.2",
@ -525,9 +525,9 @@
}
},
"@types/jest": {
"version": "24.0.18",
"resolved": "https://registry.npmjs.org/@types/jest/-/jest-24.0.18.tgz",
"integrity": "sha512-jcDDXdjTcrQzdN06+TSVsPPqxvsZA/5QkYfIZlq1JMw7FdP5AZylbOc+6B/cuDurctRe+MziUMtQ3xQdrbjqyQ==",
"version": "24.0.19",
"resolved": "https://registry.npmjs.org/@types/jest/-/jest-24.0.19.tgz",
"integrity": "sha512-YYiqfSjocv7lk5H/T+v5MjATYjaTMsUkbDnjGqSMoO88jWdtJXJV4ST/7DKZcoMHMBvB2SeSfyOzZfkxXHR5xg==",
"dev": true,
"requires": {
"@types/jest-diff": "*"
@ -540,9 +540,9 @@
"dev": true
},
"@types/node": {
"version": "12.7.7",
"resolved": "https://registry.npmjs.org/@types/node/-/node-12.7.7.tgz",
"integrity": "sha512-4jUncNe2tj1nmrO/34PsRpZqYVnRV1svbU78cKhuQKkMntKB/AmdLyGgswcZKjFHEHGpiY8pVD8CuVI55nP54w==",
"version": "12.11.1",
"resolved": "https://registry.npmjs.org/@types/node/-/node-12.11.1.tgz",
"integrity": "sha512-TJtwsqZ39pqcljJpajeoofYRfeZ7/I/OMUQ5pR4q5wOKf2ocrUvBAZUMhWsOvKx3dVc/aaV5GluBivt0sWqA5A==",
"dev": true
},
"@types/normalize-package-data": {
@ -558,9 +558,9 @@
"dev": true
},
"@types/yargs": {
"version": "13.0.2",
"resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-13.0.2.tgz",
"integrity": "sha512-lwwgizwk/bIIU+3ELORkyuOgDjCh7zuWDFqRtPPhhVgq9N1F7CvLNKg1TX4f2duwtKQ0p044Au9r1PLIXHrIzQ==",
"version": "13.0.3",
"resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-13.0.3.tgz",
"integrity": "sha512-K8/LfZq2duW33XW/tFwEAfnZlqIfVsoyRB3kfXdPXYhl0nfM8mmh7GS0jg7WrX2Dgq/0Ha/pR1PaR+BvmWwjiQ==",
"dev": true,
"requires": {
"@types/yargs-parser": "*"
@ -1370,9 +1370,9 @@
}
},
"es-abstract": {
"version": "1.14.2",
"resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.14.2.tgz",
"integrity": "sha512-DgoQmbpFNOofkjJtKwr87Ma5EW4Dc8fWhD0R+ndq7Oc456ivUfGOOP6oAZTTKl5/CcNMP+EN+e3/iUzgE0veZg==",
"version": "1.15.0",
"resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.15.0.tgz",
"integrity": "sha512-bhkEqWJ2t2lMeaJDuk7okMkJWI/yqgH/EoGwpcvv0XW9RWQsRspI4wt6xuyuvMvvQE3gg/D9HXppgk21w78GyQ==",
"dev": true,
"requires": {
"es-to-primitive": "^1.2.0",
@ -1383,8 +1383,8 @@
"is-regex": "^1.0.4",
"object-inspect": "^1.6.0",
"object-keys": "^1.1.1",
"string.prototype.trimleft": "^2.0.0",
"string.prototype.trimright": "^2.0.0"
"string.prototype.trimleft": "^2.1.0",
"string.prototype.trimright": "^2.1.0"
}
},
"es-to-primitive": {
@ -2342,9 +2342,9 @@
"dev": true
},
"handlebars": {
"version": "4.3.1",
"resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.3.1.tgz",
"integrity": "sha512-c0HoNHzDiHpBt4Kqe99N8tdLPKAnGCQ73gYMPWtAYM4PwGnf7xl8PBUHJqh9ijlzt2uQKaSRxbXRt+rZ7M2/kA==",
"version": "4.4.3",
"resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.4.3.tgz",
"integrity": "sha512-B0W4A2U1ww3q7VVthTKfh+epHx+q4mCt6iK+zEAzbMBpWQAwxCeKxEGpj/1oQTpzPXDNSOG7hmG14TsISH50yw==",
"dev": true,
"requires": {
"neo-async": "^2.6.0",
@ -2423,9 +2423,9 @@
}
},
"hosted-git-info": {
"version": "2.8.4",
"resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.4.tgz",
"integrity": "sha512-pzXIvANXEFrc5oFFXRMkbLPQ2rXRoDERwDLyrcUxGhaZhgP54BBSl9Oheh7Vv0T090cszWBxPjkQQ5Sq1PbBRQ==",
"version": "2.8.5",
"resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.5.tgz",
"integrity": "sha512-kssjab8CvdXfcXMXVcvsXum4Hwdq9XGtRD3TteMEvEbq0LXyiNQr6AprqKqfeaDXze7SxWvRxdpwE6ku7ikLkg==",
"dev": true
},
"html-encoding-sniffer": {
@ -3389,9 +3389,9 @@
"dev": true
},
"json5": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/json5/-/json5-2.1.0.tgz",
"integrity": "sha512-8Mh9h6xViijj36g7Dxi+Y4S6hNGV96vcJZr/SrlHh1LR/pEn/8j/+qIBbs44YKl69Lrfctp4QD+AdWLTMqEZAQ==",
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/json5/-/json5-2.1.1.tgz",
"integrity": "sha512-l+3HXD0GEI3huGq1njuqtzYK8OYJyXMkOLtQ53pjWh89tvWS2h6l+1zMkYWqlb57+SiQodKZyvMEFb2X+KrFhQ==",
"dev": true,
"requires": {
"minimist": "^1.2.0"
@ -4150,9 +4150,9 @@
"dev": true
},
"react-is": {
"version": "16.9.0",
"resolved": "https://registry.npmjs.org/react-is/-/react-is-16.9.0.tgz",
"integrity": "sha512-tJBzzzIgnnRfEm046qRcURvwQnZVXmuCbscxUO5RWrGTXpon2d4c8mI0D8WE6ydVIm29JiLB6+RslkIvym9Rjw==",
"version": "16.10.2",
"resolved": "https://registry.npmjs.org/react-is/-/react-is-16.10.2.tgz",
"integrity": "sha512-INBT1QEgtcCCgvccr5/86CfD71fw9EPmDxgiJX4I2Ddr6ZsV6iFXsuby+qWJPtmNuMY0zByTsG4468P7nHuNWA==",
"dev": true
},
"read-pkg": {
@ -5015,19 +5015,19 @@
}
},
"typescript": {
"version": "3.6.3",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.6.3.tgz",
"integrity": "sha512-N7bceJL1CtRQ2RiG0AQME13ksR7DiuQh/QehubYcghzv20tnh+MQnQIuJddTmsbqYj+dztchykemz0zFzlvdQw==",
"version": "3.6.4",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.6.4.tgz",
"integrity": "sha512-unoCll1+l+YK4i4F8f22TaNVPRHcD9PA3yCuZ8g5e0qGqlVlJ/8FSateOLLSagn+Yg5+ZwuPkL8LFUc0Jcvksg==",
"dev": true
},
"uglify-js": {
"version": "3.6.0",
"resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.6.0.tgz",
"integrity": "sha512-W+jrUHJr3DXKhrsS7NUVxn3zqMOFn0hL/Ei6v0anCIMoKC93TjcflTagwIHLW7SfMFfiQuktQyFVCFHGUE0+yg==",
"version": "3.6.2",
"resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.6.2.tgz",
"integrity": "sha512-+gh/xFte41GPrgSMJ/oJVq15zYmqr74pY9VoM69UzMzq9NFk4YDylclb1/bhEzZSaUQjbW5RvniHeq1cdtRYjw==",
"dev": true,
"optional": true,
"requires": {
"commander": "~2.20.0",
"commander": "2.20.0",
"source-map": "~0.6.1"
}
},

View File

@ -1,6 +1,6 @@
{
"name": "setup-php",
"version": "1.3.8",
"version": "1.4.3",
"private": false,
"description": "Setup php action",
"main": "lib/setup-php.js",
@ -24,8 +24,7 @@
"dependencies": {
"@actions/core": "^1.0.0",
"@actions/tool-cache": "^1.0.0",
"fs": "0.0.1-security",
"typed-rest-client": "^1.5.0"
"fs": "0.0.1-security"
},
"devDependencies": {
"@types/jest": "^24.0.18",

79
src/config.ts Normal file
View File

@ -0,0 +1,79 @@
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,
no_step = false
): Promise<string> {
let script: string = '\n';
switch (no_step) {
case true:
script +=
(await utils.stepLog('Add php.ini values', os_version)) +
(await utils.suppressOutput(os_version)) +
'\n';
break;
case false:
default:
script += (await utils.stepLog('Add php.ini values', os_version)) + '\n';
break;
}
switch (os_version) {
case 'win32':
return script + (await addINIValuesWindows(ini_values_csv));
case 'darwin':
case 'linux':
return script + (await addINIValuesUnix(ini_values_csv));
default:
return await utils.log(
'Platform ' + os_version + ' is not supported',
os_version,
'error'
);
}
}
/**
* Add script to set custom ini values for unix
*
* @param ini_values_csv
*/
export async function addINIValuesUnix(
ini_values_csv: string
): Promise<string> {
let ini_values: Array<string> = await utils.INIArray(ini_values_csv);
let script: string = '\n';
await utils.asyncForEach(ini_values, async function(line: string) {
script +=
(await utils.addLog('$tick', line, 'Added to php.ini', 'linux')) + '\n';
});
return 'echo "' + ini_values.join('\n') + '" >> $ini_file' + 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 ini_values: Array<string> = await utils.INIArray(ini_values_csv);
let script: string = '\n';
await utils.asyncForEach(ini_values, async function(line: string) {
script +=
(await utils.addLog('$tick', line, 'Added to php.ini', 'win32')) + '\n';
});
return (
'Add-Content C:\\tools\\php\\php.ini "' +
ini_values.join('\n') +
'"' +
script
);
}

156
src/coverage.ts Normal file
View File

@ -0,0 +1,156 @@
import * as utils from './utils';
import * as extensions from './extensions';
import * as config from './config';
/**
* Function to set coverage driver
*
* @param coverage_driver
* @param version
* @param os_version
*/
export async function addCoverage(
coverage_driver: string,
version: string,
os_version: string
): Promise<string> {
coverage_driver.toLowerCase();
let script: string =
'\n' + (await utils.stepLog('Setup Coverage', os_version));
switch (coverage_driver) {
case 'pcov':
return script + (await addCoveragePCOV(version, os_version));
case 'xdebug':
return script + (await addCoverageXdebug(version, os_version));
case 'none':
return script + (await disableCoverage(version, os_version));
default:
return '';
}
}
/**
* Function to setup Xdebug
*
* @param version
* @param os_version
*/
export async function addCoverageXdebug(version: string, os_version: string) {
return (
(await extensions.addExtension('xdebug', version, os_version, true)) +
(await utils.suppressOutput(os_version)) +
'\n' +
(await utils.addLog(
'$tick',
'xdebug',
'Xdebug enabled as coverage driver',
os_version
))
);
}
/**
* Function to setup PCOV
*
* @param version
* @param os_version
*/
export async function addCoveragePCOV(version: string, os_version: string) {
let script: string = '\n';
switch (version) {
default:
script +=
(await extensions.addExtension('pcov', version, os_version, true)) +
(await utils.suppressOutput(os_version)) +
'\n';
script +=
(await config.addINIValues('pcov.enabled=1', os_version, true)) + '\n';
// 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 -v ' +
version +
' 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.addLog(
'$tick',
'coverage: pcov',
'PCOV enabled as coverage driver',
os_version
);
// version is not supported
break;
case '5.6':
case '7.0':
script += await utils.addLog(
'$cross',
'pcov',
'PHP 7.1 or newer is required',
os_version
);
break;
}
return script;
}
/**
* Function to disable Xdebug and PCOV
*
* @param version
* @param os_version
*/
export async function disableCoverage(version: string, os_version: string) {
let script: string = '\n';
switch (os_version) {
case 'linux':
script +=
'if [ -e /etc/php/' +
version +
'/mods-available/xdebug.ini ]; then sudo phpdismod -v ' +
version +
' xdebug; fi\n';
script +=
'if [ -e /etc/php/' +
version +
'/mods-available/pcov.ini ]; then sudo phpdismod -v ' +
version +
' pcov; fi\n';
script += 'sudo sed -i "/xdebug/d" $ini_file\n';
script += 'sudo sed -i "/pcov/d" $ini_file\n';
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.addLog(
'$tick',
'none',
'Disabled Xdebug and PCOV',
os_version
);
return script;
}

184
src/extensions.ts Normal file
View File

@ -0,0 +1,184 @@
import * as utils from './utils';
/**
* Install and enable extensions
*
* @param extension_csv
* @param version
* @param os_version
* @param log_prefix
*/
export async function addExtension(
extension_csv: string,
version: string,
os_version: string,
no_step = false
): Promise<string> {
let script: string = '\n';
switch (no_step) {
case true:
script +=
(await utils.stepLog('Setup Extensions', os_version)) +
(await utils.suppressOutput(os_version));
break;
case false:
default:
script += await utils.stepLog('Setup Extensions', os_version);
break;
}
switch (os_version) {
case 'win32':
return script + (await addExtensionWindows(extension_csv, version));
case 'darwin':
return script + (await addExtensionDarwin(extension_csv, version));
case 'linux':
return script + (await addExtensionLinux(extension_csv, version));
default:
return await utils.log(
'Platform ' + os_version + ' is not supported',
os_version,
'error'
);
}
}
/**
* 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
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 +=
'\nadd_extension ' +
extension +
' "' +
install_command +
'" ' +
(await utils.getExtensionPrefix(extension));
});
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
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 +=
'\nAdd-Extension ' +
extension +
' "' +
install_command +
'" ' +
(await utils.getExtensionPrefix(extension));
});
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
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;
case '7.2phalcon3':
case '7.3phalcon3':
install_command = './phalcon.sh master ' + version + ' >/dev/null 2>&1';
break;
case '7.2phalcon4':
case '7.3phalcon4':
install_command = './phalcon.sh 4.0.x ' + version + ' >/dev/null 2>&1';
break;
default:
install_command =
'sudo DEBIAN_FRONTEND=noninteractive apt install -y php' +
version +
'-' +
extension +
' >/dev/null 2>&1';
break;
}
script +=
'\nadd_extension ' +
extension +
' "' +
install_command +
'" ' +
(await utils.getExtensionPrefix(extension));
});
return script;
}

View File

@ -1,442 +0,0 @@
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
);
}
}
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'
);
}
}
/**
* 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}" >> 'php -i | grep "Loaded Configuration" | sed -e "s|.*=>\s*||"'\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;
}
/**
* Add script to set custom ini values for unix
*
* @param ini_values_csv
*/
export async function addINIValuesUnix(
ini_values_csv: string
): Promise<string> {
let script: string = '\n';
let ini_values: Array<string> = await utils.INIArray(ini_values_csv);
await utils.asyncForEach(ini_values, async function(ini_value: string) {
// add script to set ini value
script += 'echo "' + ini_value + '" >> $ini_file\n';
});
return script;
}
/**
* Add script to set custom ini values for windows
*
* @param ini_values_csv
*/
export async function addINIValuesWindows(
ini_values_csv: string
): Promise<string> {
let script: string = '\n';
let ini_values: Array<string> = await utils.INIArray(ini_values_csv);
await utils.asyncForEach(ini_values, async function(ini_value: string) {
// add script to set ini value
script += 'Add-Content C:\\tools\\php\\php.ini "' + ini_value + '"\n';
});
return script;
}
export async function addCoverage(
coverage: string,
version: string,
os_version: string
): Promise<string> {
let script: string = '';
script += '\n';
coverage = coverage.toLowerCase();
// pcov
switch (coverage) {
case 'pcov':
// if version is 7.1 or newer
switch (version) {
default:
script += await addExtension(
'pcov',
version,
os_version,
'Set Coverage Driver'
);
script += await addINIValues('pcov.enabled=1', os_version);
// add command to disable xdebug and enable pcov
switch (os_version) {
case 'linux':
script +=
'if [ -e /etc/php/' +
version +
'/mods-available/xdebug.ini ]; then sudo phpdismod xdebug; fi\n';
script += 'sudo sed -i "/xdebug/d" $ini_file\n';
break;
case 'darwin':
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;
}
break;
//xdebug
case 'xdebug':
script += await addExtension(
'xdebug',
version,
os_version,
'Set Coverage Driver'
);
script += await utils.log(
'Xdebug enabled as coverage driver',
os_version,
'success',
'Set Coverage Driver'
);
break;
// unknown coverage driver
default:
script = '';
}
return script;
}

View File

@ -1,66 +1,58 @@
import {exec} from '@actions/exec/lib/exec';
import * as core from '@actions/core';
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';
/**
* Build the script
*
* @param filename
* @param version
* @param os_version
*/
async function build(filename: string, version: string, os_version: string) {
// taking inputs
let extension_csv: string = await utils.getInput('extension-csv', false);
let ini_values_csv: string = await utils.getInput('ini-values-csv', false);
let coverage_driver: string = await utils.getInput('coverage', false);
let script: string = await utils.readScript(filename, version, os_version);
if (extension_csv) {
script += await extensions.addExtension(extension_csv, version, os_version);
}
if (ini_values_csv) {
script += await config.addINIValues(ini_values_csv, os_version);
}
if (coverage_driver) {
script += await coverage.addCoverage(coverage_driver, version, os_version);
}
await utils.writeScript(filename, version, script);
}
/**
* Run the script
*/
async function run() {
try {
// taking inputs
let version: string = await utils.getInput('php-version', true);
let extension_csv: string = await utils.getInput('extension-csv', false);
let ini_values_csv: string = await utils.getInput('ini-values-csv', false);
let coverage: string = await utils.getInput('coverage', false);
let os_version: string = process.platform;
let version: string = await utils.getInput('php-version', true);
// check the os version and run the respective script
if (os_version == 'darwin') {
let darwin: string = await utils.readScript(
'darwin.sh',
version,
os_version
);
darwin += await features.addExtension(extension_csv, version, os_version);
darwin += await features.addINIValues(ini_values_csv, os_version);
darwin += await features.addCoverage(coverage, version, os_version);
await utils.writeScript('darwin.sh', version, darwin);
await build('darwin.sh', version, os_version);
await exec('sh ./' + version + 'darwin.sh ' + version);
} else if (os_version == 'win32') {
let windows: string = await utils.readScript(
'win32.ps1',
version,
os_version
);
windows += await features.addExtension(
extension_csv,
version,
os_version
);
windows += await features.addINIValues(ini_values_csv, os_version);
windows += await features.addCoverage(coverage, version, os_version);
await utils.writeScript('win32.ps1', version, windows);
await build('win32.ps1', version, os_version);
await exec('powershell .\\' + version + 'win32.ps1 -version ' + version);
} else if (os_version == 'linux') {
let linux: string = await utils.readScript(
'linux.sh',
version,
os_version
);
linux += await features.addExtension(extension_csv, version, os_version);
linux += await features.addINIValues(ini_values_csv, os_version);
linux += await features.addCoverage(coverage, version, os_version);
await utils.writeScript('linux.sh', version, linux);
await build('linux.sh', version, os_version);
await exec('./' + version + 'linux.sh ' + version);
}
} catch (err) {
core.setFailed(err.message);
} catch (error) {
core.setFailed(error.message);
}
}
// call the run function
run().then(function() {
console.log('done');
});
run();

View File

@ -1,17 +0,0 @@
import * as hc from 'typed-rest-client/HttpClient';
/**
* Function to check if PECL extension exists
*
* @param extension
*/
export async function checkPECLExtension(extension: string): Promise<boolean> {
const http: hc.HttpClient = new hc.HttpClient('shivammathur/php-setup', [], {
allowRetries: true,
maxRetries: 2
});
const response: hc.HttpClientResponse = await http.get(
'https://pecl.php.net/package/' + extension
);
return response.message.statusCode === 200;
}

View File

@ -1,4 +1,28 @@
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
tick="✓"
cross="✗"
step_log() {
message=$1
printf "\n\033[90;1m==> \033[0m\033[37;1m%s\033[0m\n" "$message"
}
add_log() {
mark=$1
subject=$2
message=$3
if [ "$mark" = "$tick" ]; then
printf "\033[32;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s\033[0m\n" "$mark" "$subject" "$message"
else
printf "\033[31;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s\033[0m\n" "$mark" "$subject" "$message"
fi
}
version='7.4.0RC3'
step_log "Setup dependencies"
for package in pkg-config autoconf bison re2c openssl@1.1 krb5 enchant libffi freetype intltool icu4c libiconv t1lib gd libzip gmp tidyp libxml2 libxslt postgresql curl;
do
brew install "$package" >/dev/null 2>&1
add_log "$tick" "$package" "Installed"
done
brew link icu4c gettext --force >/dev/null 2>&1
for package in gettext gmp krb5 icu4c bison openssl@1.1 libxml2 libffi libxslt libiconv pkgconfig enchant krb5 readline libedit freetype;
@ -35,6 +59,8 @@ echo 'export EXTRA_LIBS="/usr/local/opt/readline/lib/libhistory.dylib
/usr/local/opt/icu4c/lib/libicuuc.dylib"'
} >> ~/.bash_profile
config_file=$(pwd)/config.yaml
step_log "Setup PHPBrew"
curl -L -O https://github.com/phpbrew/phpbrew/raw/master/phpbrew >/dev/null 2>&1
chmod +x ./phpbrew
sudo mv phpbrew /usr/local/bin/phpbrew
@ -46,14 +72,44 @@ sudo chmod -R 777 /opt/phpbrew
export PHPBREW_ROOT=/opt/phpbrew
export PHPBREW_HOME=/opt/phpbrew
echo "[[ -e ~/.phpbrew/bashrc ]] && source ~/.phpbrew/bashrc" >> ~/.bashrc
add_log "$tick" "PHPBrew" "Installed"
source ~/.bash_profile >/dev/null 2>&1
source ~/.bashrc >/dev/null 2>&1
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
step_log "Setup PHP and Composer"
phpbrew install -j 6 $version +dev >/dev/null 2>&1
phpbrew switch $version
sudo ln -sf /opt/phpbrew/php/php-$version/bin/* /usr/local/bin/
sudo ln -sf /opt/phpbrew/php/php-$version/etc/php.ini /etc/php.ini
ini_file=$(php --ini | grep "Loaded Configuration" | sed -e "s|.*:s*||" | sed "s/ //g")
ext_dir=$(php -i | grep "extension_dir => /opt" | sed -e "s|.*=> s*||")
pecl config-set php_ini "$ini_file"
pecl config-set php_ini "$ini_file" >/dev/null 2>&1
sudo chmod 777 "$ini_file"
brew install composer
brew install composer >/dev/null 2>&1
add_log "$tick" "PHP" "Installed PHP$version"
add_log "$tick" "Composer" "Installed"
add_extension() {
extension=$1
install_command=$2
prefix=$3
if ! php -m | grep -i -q "$extension" && [ -e "$ext_dir/$extension.so" ]; then
echo "$prefix=$extension" >>"$ini_file" && add_log "$tick" "$extension" "Enabled"
elif php -m | grep -i -q "$extension"; then
add_log "$tick" "$extension" "Enabled"
elif ! php -m | grep -i -q "$extension"; then
exists=$(curl -sL https://pecl.php.net/json.php?package="$extension" -w "%{http_code}" -o /dev/null)
if [ "$exists" = "200" ]; then
(
eval "$install_command" && \
add_log "$tick" "$extension" "Installed and enabled"
) || add_log "$cross" "$extension" "Could not install $extension on PHP$version"
else
if ! php -m | grep -i -q "$extension"; then
add_log "$cross" "$extension" "Could not find $extension for PHP$version on PECL"
fi
fi
fi
}

View File

@ -1,11 +1,58 @@
tick="✓"
cross="✗"
step_log() {
message=$1
printf "\n\033[90;1m==> \033[0m\033[37;1m%s\033[0m\n" "$message"
}
add_log() {
mark=$1
subject=$2
message=$3
if [ "$mark" = "$tick" ]; then
printf "\033[32;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s\033[0m\n" "$mark" "$subject" "$message"
else
printf "\033[31;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s\033[0m\n" "$mark" "$subject" "$message"
fi
}
version=$1
export HOMEBREW_NO_INSTALL_CLEANUP=TRUE
brew tap exolnet/homebrew-deprecated >/dev/null 2>&1
if [ "$1" = "5.6" ] || [ "$1" = "7.0" ]; then
brew tap exolnet/homebrew-deprecated >/dev/null 2>&1
fi
step_log "Setup PHP and Composer"
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=$(/usr/bin/php -i | grep "extension_dir => /usr" | sed -e "s|.*=> s*||")
ini_file=$(php -d "date.timezone=UTC" --ini | grep "Loaded Configuration" | sed -e "s|.*:s*||" | sed "s/ //g")
echo "date.timezone=UTC" >> "$ini_file"
ext_dir=$(php -i | grep "extension_dir => /usr" | sed -e "s|.*=> s*||")
sudo chmod 777 "$ini_file"
mkdir -p "$(pecl config-get ext_dir)"
composer global require hirak/prestissimo >/dev/null 2>&1
php -v
composer -V
add_log "$tick" "PHP" "Installed PHP$version"
add_log "$tick" "Composer" "Installed"
add_extension() {
extension=$1
install_command=$2
prefix=$3
if ! php -m | grep -i -q "$extension" && [ -e "$ext_dir/$extension.so" ]; then
echo "$prefix=$extension" >>"$ini_file" && add_log $tick "$extension" "Enabled"
elif php -m | grep -i -q "$extension"; then
add_log "$tick" "$extension" "Enabled"
elif ! php -m | grep -i -q "$extension"; then
exists=$(curl -sL https://pecl.php.net/json.php?package="$extension" -w "%{http_code}" -o /dev/null)
if [ "$exists" = "200" ]; then
(
eval "$install_command" && \
add_log "$tick" "$extension" "Installed and enabled"
) || add_log "$cross" "$extension" "Could not install $extension on PHP$version"
else
if ! php -m | grep -i -q "$extension"; then
add_log "$cross" "$extension" "Could not find $extension for PHP$version on PECL"
fi
fi
fi
}

View File

@ -1,40 +1,77 @@
version=$(php-config --version | cut -c 1-3)
if [ "$version" != "$1" ]; then
tick="✓"
cross="✗"
step_log() {
message=$1
printf "\n\033[90;1m==> \033[0m\033[37;1m%s\033[0m\n" "$message"
}
add_log() {
mark=$1
subject=$2
message=$3
if [ "$mark" = "$tick" ]; then
printf "\033[32;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s\033[0m\n" "$mark" "$subject" "$message"
else
printf "\033[31;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s\033[0m\n" "$mark" "$subject" "$message"
fi
}
existing_version=$(php-config --version | cut -c 1-3)
version=$1
status="Switched to PHP$version"
step_log "Setup PHP and Composer"
if [ "$existing_version" != "$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 apt update -y >/dev/null 2>&1
sudo DEBIAN_FRONTEND=noninteractive apt install -y php"$1" curl php"$1"-curl >/dev/null 2>&1
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
status="Installed PHP$version"
fi
for tool in php phar phar.phar php-cgi php-config phpize; do
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" >/dev/null 2>&1 &
fi
done
fi
if [ ! -e "/usr/bin/composer" ]; then
EXPECTED_SIGNATURE="$(curl -s https://composer.github.io/installer.sig)"
curl -s -L https://getcomposer.org/installer > composer-setup.php
ACTUAL_SIGNATURE="$(php -r "echo hash_file('sha384', 'composer-setup.php');")"
if [ "$EXPECTED_SIGNATURE" != "$ACTUAL_SIGNATURE" ]; then
>&2 echo 'ERROR: Invalid installer signature'
else
COMPOSER_ALLOW_SUPERUSER=1
sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer
fi
rm composer-setup.php
fi
composer global require hirak/prestissimo >/dev/null 2>&1
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"
sudo mkdir -p /run/php
php -v
composer -V
add_log "$tick" "PHP" "$status"
if [ ! -e "/usr/bin/composer" ]; then
curl -s -L https://getcomposer.org/installer > composer-setup.php
if [ "$(curl -s https://composer.github.io/installer.sig)" != "$(php -r "echo hash_file('sha384', 'composer-setup.php');")" ]; then
>&2 echo 'ERROR: Invalid installer signature'
else
export COMPOSER_ALLOW_SUPERUSER=1
sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer
fi
rm composer-setup.php
fi
composer global require hirak/prestissimo >/dev/null 2>&1
add_log "$tick" "Composer" "Installed"
add_extension()
{
extension=$1
install_command=$2
prefix=$3
if ! php -m | grep -i -q "$extension" && [ -e "$ext_dir/$extension.so" ]; then
echo "$prefix=$extension" >> "$ini_file" && add_log "$tick" "$extension" "Enabled"
elif php -m | grep -i -q "$extension"; then
add_log "$tick" "$extension" "Enabled"
elif ! php -m | grep -i -q "$extension"; then
(
eval "$install_command" && \
add_log "$tick" "$extension" "Installed and enabled"
) || add_log "$cross" "$extension" "Could not find php$version-$extension"
fi
}

19
src/scripts/phalcon.sh Normal file
View File

@ -0,0 +1,19 @@
ini_file=$(php --ini | grep "Loaded Configuration" | sed -e "s|.*:s*||" | sed "s/ //g")
sudo DEBIAN_FRONTEND=noninteractive apt install php"$2"-dev php-pear -y
for tool in php-config phpize; do
if [ -e "/usr/bin/$tool$2" ]; then
sudo update-alternatives --set $tool /usr/bin/"$tool$2" &
fi
done
sudo pecl config-set php_ini "$ini_file"
sudo pear config-set php_ini "$ini_file"
sudo pecl install psr
if [ "$1" = "master" ]; then
sudo DEBIAN_FRONTEND=noninteractive apt install php"$2"-phalcon -y
else
git clone --depth=1 -v https://github.com/phalcon/cphalcon.git -b "$1"
(
cd cphalcon/build && sudo ./install --phpize /usr/bin/phpize"$2" --php-config /usr/bin/php-config"$2"
echo "extension=phalcon.so" >> "$ini_file"
)
fi

View File

@ -2,42 +2,90 @@ param (
[Parameter(Mandatory=$true)][string]$version = "7.3"
)
$tick = ([char]8730)
$cross = ([char]10007)
Function Step-Log($message) {
printf "\n\033[90;1m==> \033[0m\033[37;1m%s \033[0m" $message
}
Function Add-Log($mark, $subject, $message) {
$code = if($mark -eq $cross) {"31"} else {"32"}
printf "\033[%s;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s \033[0m" $code $mark $subject $message
}
if($version -eq '7.4') {
$version = '7.4RC'
}
echo "Installing PhpManager"
Step-Log "Setup PhpManager"
Install-Module -Name PhpManager -Force -Scope CurrentUser
printf "\n"
Add-Log $tick "PhpManager" "Installed"
$installed = $($(php -v)[0] -join '')[4..6] -join ''
Step-Log "Setup PHP and Composer"
$status = "Switched to PHP$version"
if($installed -ne $version) {
if($version -lt '7.0') {
echo "Installing VcRedist"
Install-Module -Name VcRedist -Force
}
echo "Installing 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
echo "Switch PHP"
Install-Php -Version $version -Architecture x86 -ThreadSafe $true -InstallVC -Path C:\tools\php$version -TimeZone UTC -InitialPhpIni Production -Force >$null 2>&1
(Get-PhpSwitcher).targets
Initialize-PhpSwitcher -Alias C:\tools\php -Scope CurrentUser -Force
Add-PhpToSwitcher -Name $version -Path C:\tools\php$version -Force
Switch-Php $version -Force
$status = "Installed PHP$version"
}
echo "Housekeeping in PHP.ini, enabling openssl"
$ext_dir = "C:\tools\php\ext"
Add-Content C:\tools\php\php.ini "date.timezone = 'UTC'"
Set-PhpIniKey extension_dir $ext_dir
if($version -lt '7.4') {
Enable-PhpExtension openssl
} else {
Add-Content C:\tools\php\php.ini "extension=php_openssl.dll"
Copy-Item "php_pcov.dll" -Destination $ext_dir"\php_pcov.dll"
}
Add-Log $tick "PHP" $status
echo "Installing Composer"
Install-Composer -Scope System -Path C:\tools\php
php -v
composer -V
Add-Log $tick "Composer" "Installed"
Function Add-Extension($extension, $install_command, $prefix)
{
try {
$exist = Test-Path -Path C:\tools\php\ext\php_$extension.dll
if(!(php -m | findstr -i ${extension}) -and $exist) {
Add-Content C:\tools\php\php.ini "$prefix=php_$extension.dll"
Add-Log $tick $extension "Enabled"
} elseif(php -m | findstr -i $extension) {
Add-Log $tick $extension "Enabled"
}
} catch [Exception] {
Add-Log $cross $extension "Could not enable"
}
$status = 404
try {
$status = (Invoke-WebRequest -Uri "https://pecl.php.net/json.php?package=$extension" -UseBasicParsing -DisableKeepAlive).StatusCode
} catch [Exception] {
$status = 500
}
if($status -eq 200) {
if(!(php -m | findstr -i $extension)) {
try {
Invoke-Expression $install_command
Add-Log $tick $extension "Installed and enabled"
} catch [Exception] {
Add-Log $cross $extension "Could not install on PHP$version"
}
}
} else {
if(!(php -m | findstr -i $extension)) {
Add-Log $cross $extension "Could not find $extension for PHP$version on PECL"
}
}
}

View File

@ -2,6 +2,12 @@ import * as fs from 'fs';
import * as path from 'path';
import * as core from '@actions/core';
/**
* Function to get inputs from both with and env annotations.
*
* @param name
* @param mandatory
*/
export async function getInput(
name: string,
mandatory: boolean
@ -37,7 +43,7 @@ export async function asyncForEach(
*
* @param files
*/
export async function readFiles74(files: Array<string>) {
export async function moveFiles(files: Array<string>) {
await asyncForEach(files, function(filename: string) {
fs.createReadStream(path.join(__dirname, '../src/' + filename)).pipe(
fs.createWriteStream(filename.split('/')[1], {mode: 0o755})
@ -61,7 +67,7 @@ export async function readScript(
case 'darwin':
switch (version) {
case '7.4':
await readFiles74([
await moveFiles([
'configs/config.yaml',
'scripts/xdebug_darwin.sh',
'scripts/pcov.sh'
@ -73,16 +79,18 @@ export async function readScript(
}
break;
case 'linux':
let files: Array<string> = ['scripts/phalcon.sh'];
switch (version) {
case '7.4':
await readFiles74(['scripts/xdebug.sh', 'scripts/pcov.sh']);
files = files.concat(['scripts/xdebug.sh', 'scripts/pcov.sh']);
break;
}
await moveFiles(files);
break;
case 'win32':
switch (version) {
case '7.4':
await readFiles74(['ext/php_pcov.dll']);
await moveFiles(['ext/php_pcov.dll']);
break;
}
break;
@ -117,6 +125,7 @@ export async function writeScript(
/**
* Function to break extension csv into an array
*
* @param extension_csv
*/
export async function extensionArray(
@ -154,54 +163,95 @@ export async function INIArray(ini_values_csv: string): Promise<Array<string>> {
}
}
/**
* Function to log a step
*
* @param message
* @param os_version
*/
export async function stepLog(
message: string,
os_version: string
): Promise<string> {
switch (os_version) {
case 'win32':
return 'Step-Log "' + message + '"';
case 'linux':
case 'darwin':
return 'step_log "' + message + '"';
default:
return await log(
'Platform ' + os_version + ' is not supported',
os_version,
'error'
);
}
}
/**
* Function to log a result
* @param mark
* @param subject
* @param message
*/
export async function addLog(
mark: string,
subject: string,
message: string,
os_version: string
): Promise<string> {
switch (os_version) {
case 'win32':
return 'Add-Log "' + mark + '" "' + subject + '" "' + message + '"';
case 'linux':
case 'darwin':
return 'add_log "' + mark + '" "' + subject + '" "' + message + '"';
default:
return await log(
'Platform ' + os_version + ' is not supported',
os_version,
'error'
);
}
}
/**
* Log to console
*
* @param message
* @param os_version
* @param log_type
* @param prefix
*/
export async function log(
message: string,
os_version: string,
log_type: string,
prefix = ''
log_type: string
): Promise<string> {
const unix_color: any = {
const color: any = {
error: '31',
success: '32',
warning: '33'
};
switch (prefix) {
case '':
prefix = prefix;
break;
default:
prefix = prefix + ': ';
break;
}
switch (os_version) {
case 'win32':
const color: any = {
error: 'red',
success: 'green',
warning: 'yellow'
};
return (
"Write-Host '" +
prefix +
message +
"' -ForegroundColor " +
color[log_type]
'printf "\\033[' + color[log_type] + ';1m' + message + ' \\033[0m"'
);
case 'linux':
case 'darwin':
default:
return (
'echo "\\033[' +
unix_color[log_type] +
';1m' +
prefix +
message +
'\\033[0m"'
);
return 'echo "\\033[' + color[log_type] + ';1m' + message + '\\033[0m"';
}
}
/**
* Function to get prefix required to load an extension.
*
* @param extension
*/
export async function getExtensionPrefix(extension: string): Promise<string> {
let zend: Array<string> = ['xdebug', 'opcache', 'ioncube', 'eaccelerator'];
switch (zend.indexOf(extension)) {
@ -213,3 +263,24 @@ export async function getExtensionPrefix(extension: string): Promise<string> {
return 'extension';
}
}
/**
* Function to get the suffix to suppress console output
*
* @param os_version
*/
export async function suppressOutput(os_version: string): Promise<string> {
switch (os_version) {
case 'win32':
return ' >$null 2>&1';
case 'linux':
case 'darwin':
return ' >/dev/null 2>&1';
default:
return await log(
'Platform ' + os_version + ' is not supported',
os_version,
'error'
);
}
}