Compare commits

..

43 Commits
1.6.2 ... 1.7.3

Author SHA1 Message Date
8489dbf4de Merge pull request #152 from shivammathur/develop
1.7.3
2020-01-17 17:16:16 +05:30
f23ae2e6f7 Fix xdebug and phalcon logs on linux 2020-01-17 16:53:12 +05:30
d2b233e45f Bump version to 1.7.3 2020-01-17 13:45:04 +05:30
320474a245 Add support for phpize and php-config 2020-01-17 13:21:39 +05:30
65ccfb36dc Fix extensions.ts 2020-01-17 06:07:33 +05:30
88fb99b592 Fix logs on windows for pre-installed version 2020-01-16 10:16:44 +05:30
9e7bc5c91f Fix phalcon.ps1 2020-01-16 09:23:04 +05:30
ca2f547a35 Fix log for composer on darwin 2020-01-16 09:06:55 +05:30
9f21c80d24 Install phalcon v4 from PECL on windows 2020-01-16 09:04:43 +05:30
c4317135df Disable composer process-timeout 2020-01-14 12:06:52 +05:30
a2dd688679 Improve test workflows 2020-01-14 11:42:08 +05:30
bd214a2dca Update old Xdebug version for coverage: xdebug 2020-01-14 11:02:17 +05:30
2ee4653d1c Merge pull request #145 from shivammathur/develop
Improve remove_extensions in linux
2020-01-10 07:10:05 +05:30
0b3e0f451d Bump version to 1.7.2 2020-01-10 06:50:19 +05:30
0bfa897634 Improve remove_extensions in linux 2020-01-10 06:30:41 +05:30
71db1e2cf1 Merge pull request #144 from shivammathur/develop
1.7.1
2020-01-09 03:56:18 +05:30
16d1cd4766 Sort tools in README 2020-01-09 03:45:19 +05:30
1193cd100b Bump version to 1.7.1 2020-01-09 03:28:45 +05:30
e839a77d8c Update default packages in linux 2020-01-08 22:07:21 +05:30
552df3f2b0 Add CakePHP examples with services 2020-01-08 12:58:21 +05:30
3109c941eb Update examples 2020-01-08 11:35:32 +05:30
aa8706a5bf Update warnings in actions.yml 2020-01-08 11:12:36 +05:30
9afdee42e8 Add support to specify version of tools 2020-01-08 10:45:30 +05:30
aa0e9403d8 Merge pull request #138 from PrisisForks/feature/automatic-composer-prefetcher
narrowspark/automatic-composer-prefetcher as a alternative to prestissimo
2020-01-04 13:04:02 +05:30
5b00f068f3 feat : narrowspark/automatic-composer-prefetcher as a alternative to prestissimo 2020-01-04 07:39:39 +01:00
8f39d3eddd Add CakePHP example 2020-01-03 08:25:42 +05:30
9d87d1fd14 Update LICENSE 2020-01-01 22:38:51 +05:30
07ae2343d0 Update actions/checkout to v2 2020-01-01 22:36:25 +05:30
7b8bf7af6a Merge pull request #134 from shivammathur/develop
1.7.0 Hotfix
2020-01-01 16:22:07 +05:30
0ac6f76d36 Fix setup order 2020-01-01 16:05:01 +05:30
6c6203b683 Improve ext-phalcon linux script and readme 2019-12-31 13:47:06 +05:30
0c9f8a8e7e Merge pull request #133 from shivammathur/develop
1.7.0
2019-12-31 06:54:06 +05:30
1705daea72 Bump version to 1.7.0 2019-12-31 06:30:11 +05:30
58fbc33c3a Use tap shivammathur/homebrew-phalcon on darwin 2019-12-31 05:49:48 +05:30
3f42b7d5fb Link tools installed using composer 2019-12-31 05:20:47 +05:30
dd4f0db7bf Update to latest version on windows. Fixes #132 2019-12-29 00:38:06 +05:30
7d026bfa6b Update symfony examples 2019-12-28 02:18:01 +05:30
6a70f864ec Improve tools support 2019-12-28 01:03:57 +05:30
8e1cde2d0a Improve examples and documentation 2019-12-28 00:23:51 +05:30
de32d8b95f Add tools support 2019-12-27 13:11:17 +05:30
273096b82f Refactor coverage and extension code 2019-12-26 20:21:39 +05:30
4c045616f4 Improve support for ext-phalcon and refactor extensions.ts 2019-12-25 03:47:26 +05:30
935e74fb40 Refactor scripts and fix reading php-version 2019-12-22 10:19:53 +05:30
53 changed files with 3503 additions and 1132 deletions

View File

@ -29,9 +29,7 @@ jobs:
php-versions: ['8.0'] php-versions: ['8.0']
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v1 uses: actions/checkout@v2
with:
fetch-depth: 1
- name: Setup Node.js 12.x - name: Setup Node.js 12.x
uses: actions/setup-node@v1 uses: actions/setup-node@v1

View File

@ -27,9 +27,7 @@ jobs:
php-versions: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4'] php-versions: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4']
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v1 uses: actions/checkout@v2
with:
fetch-depth: 1
- name: Setup Node.js 12.x - name: Setup Node.js 12.x
uses: actions/setup-node@v1 uses: actions/setup-node@v1

View File

@ -1,7 +1,7 @@
The MIT License (MIT) The MIT License (MIT)
Copyright (c) 2019 shivammathur and contributors Copyright (c) 2019-2020 shivammathur and contributors
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal

View File

@ -13,13 +13,14 @@
<a href="#tada-php-support" title="PHP Versions Supported"><img alt="PHP Versions Supported" src="https://img.shields.io/badge/php-%3E%3D%205.6-8892BF.svg"></a> <a href="#tada-php-support" title="PHP Versions Supported"><img alt="PHP Versions Supported" src="https://img.shields.io/badge/php-%3E%3D%205.6-8892BF.svg"></a>
</p> </p>
Setup PHP with required extensions, php.ini configuration, code-coverage support and composer in [GitHub Actions](https://github.com/features/actions "GitHub Actions"). This action gives you a cross platform interface to setup the PHP environment you need to test your application. Refer to [Usage](#memo-usage "How to use this") section and [examples](#examples "Examples of use") to see how to use this. Setup PHP with required extensions, php.ini configuration, code-coverage support and various tools like composer in [GitHub Actions](https://github.com/features/actions "GitHub Actions"). This action gives you a cross platform interface to setup the PHP environment you need to test your application. Refer to [Usage](#memo-usage "How to use this") section and [examples](#examples "Examples of use") to see how to use this.
## Contents ## Contents
- [PHP Support](#tada-php-support) - [PHP Support](#tada-php-support)
- [OS/Platform Support](#cloud-osplatform-support) - [OS/Platform Support](#cloud-osplatform-support)
- [PHP Extension Support](#wrench-php-extension-support) - [PHP Extension Support](#heavy_plus_sign-php-extension-support)
- [Tools Support](#wrench-tools-support)
- [Coverage support](#signal_strength-coverage-support) - [Coverage support](#signal_strength-coverage-support)
- [Xdebug](#xdebug) - [Xdebug](#xdebug)
- [PCOV](#pcov) - [PCOV](#pcov)
@ -49,7 +50,7 @@ Setup PHP with required extensions, php.ini configuration, code-coverage support
|7.4|`Stable`|`Active`| |7.4|`Stable`|`Active`|
|8.0|`Experimental`|`In development`| |8.0|`Experimental`|`In development`|
**Note:** Specifying `8.0` in `php-version` input installs a nightly build of `PHP 8.0.0-dev` with `PHP JIT` support. See [experimental setup](#experimental-setup) for more information. **Note:** Specifying `8.0` in `php-version` input installs a nightly build of `PHP 8.0.0-dev` with `PHP JIT`, `Union Types v2` and other [new features](https://wiki.php.net/rfc#php_80 "New features implemented in PHP 8"). See [experimental setup](#experimental-setup) for more information.
## :cloud: OS/Platform Support ## :cloud: OS/Platform Support
@ -60,13 +61,42 @@ Setup PHP with required extensions, php.ini configuration, code-coverage support
|Ubuntu 16.04|`ubuntu-16.04`| |Ubuntu 16.04|`ubuntu-16.04`|
|macOS X Catalina 10.15|`macOS-latest` or `macOS-10.15`| |macOS X Catalina 10.15|`macOS-latest` or `macOS-10.15`|
## :wrench: PHP Extension Support ## :heavy_plus_sign: PHP Extension Support
- On `ubuntu` by default extensions which are available as a package can be installed. If the extension is not available as a package but it is on `PECL`, it can be installed by specifying `pecl: true`. - On `ubuntu` by default extensions which are available as a package can be installed. If the extension is not available as a package but it is on `PECL`, it can be installed by specifying `pecl` in the tools input.
- On `windows` extensions which have `windows` binary on `PECL` can be installed. - On `windows` extensions which have `windows` binary on `PECL` can be installed.
- On `macOS` extensions which are on `PECL` can be installed. - On `macOS` extensions which are on `PECL` can be installed.
- Extensions which are installed along with PHP if specified are enabled. - Extensions which are installed along with PHP if specified are enabled.
- Extensions which cannot be installed gracefully leave an error message in the logs, the action is not interrupted. - Extensions which cannot be installed gracefully leave an error message in the logs, the action is not interrupted.
## :wrench: Tools Support
These tools can be setup globally using the `tools` input.
`codeception`, `composer`, `composer-prefetcher`, `deployer`, `pecl`, `phinx`, `phpcbf`, `phpcpd`, `php-config`, `php-cs-fixer`, `phpcs`, `phpize`, `phpmd`, `phpstan`, `phpunit`, `prestissimo`, `psalm`
```yaml
uses: shivammathur/setup-php@v1
with:
php-version: '7.4'
tools: php-cs-fixer, phpunit
```
To setup a particular version of a tool, specify it in the form `tool:version`.
Version should be in semver format and a valid release of the tool.
```yaml
uses: shivammathur/setup-php@v1
with:
php-version: '7.4'
tools: php-cs-fixer:2.15.5, phpunit:8.5.1
```
**Note**
- `composer` is setup by default.
- Specifying version for `composer` and `pecl` has no effect, latest version of both tools will be setup.
- If the version specified for the tool is not in semver format, latest version of the tool will be setup.
- Tools which cannot be installed gracefully leave an error message in the logs, the action is not interrupted.
## :signal_strength: Coverage support ## :signal_strength: Coverage support
### Xdebug ### Xdebug
@ -103,7 +133,7 @@ Specify `coverage: none` to disable both `Xdebug` and `PCOV`.
Consider disabling the coverage using this PHP action for these reasons. Consider disabling the coverage using this PHP action for these reasons.
- You are not generating coverage reports while testing. - You are not generating coverage reports while testing.
- It will disable `Xdebug`, which will have a positive impact on PHP performance. - It will remove `Xdebug`, which will have a positive impact on PHP performance.
- You are using `phpdbg` for running your tests. - You are using `phpdbg` for running your tests.
```yaml ```yaml
@ -121,7 +151,7 @@ Inputs supported by this GitHub Action.
- extensions `optional` - extensions `optional`
- ini-values `optional` - ini-values `optional`
- coverage `optional` - coverage `optional`
- pecl `optional` - tools `optional`
See [action.yml](action.yml "Metadata for this GitHub Action") and usage below for more info. See [action.yml](action.yml "Metadata for this GitHub Action") and usage below for more info.
@ -132,7 +162,7 @@ See [action.yml](action.yml "Metadata for this GitHub Action") and usage below f
```yaml ```yaml
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v1 uses: actions/checkout@v2
- name: Setup PHP - name: Setup PHP
uses: shivammathur/setup-php@v1 uses: shivammathur/setup-php@v1
@ -141,7 +171,7 @@ steps:
extensions: mbstring, intl #optional, setup extensions extensions: mbstring, intl #optional, setup extensions
ini-values: post_max_size=256M, short_open_tag=On #optional, setup php.ini configuration ini-values: post_max_size=256M, short_open_tag=On #optional, setup php.ini configuration
coverage: xdebug #optional, setup coverage driver coverage: xdebug #optional, setup coverage driver
pecl: false #optional, setup PECL tools: php-cs-fixer, phpunit #optional, setup tools globally
``` ```
### Matrix Setup ### Matrix Setup
@ -159,7 +189,7 @@ jobs:
name: PHP ${{ matrix.php-versions }} Test on ${{ matrix.operating-system }} name: PHP ${{ matrix.php-versions }} Test on ${{ matrix.operating-system }}
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v1 uses: actions/checkout@v2
- name: Setup PHP - name: Setup PHP
uses: shivammathur/setup-php@v1 uses: shivammathur/setup-php@v1
@ -168,7 +198,7 @@ jobs:
extensions: mbstring, intl #optional, setup extensions extensions: mbstring, intl #optional, setup extensions
ini-values: post_max_size=256M, short_open_tag=On #optional, setup php.ini configuration ini-values: post_max_size=256M, short_open_tag=On #optional, setup php.ini configuration
coverage: xdebug #optional, setup coverage driver coverage: xdebug #optional, setup coverage driver
pecl: false #optional, setup PECL tools: php-cs-fixer, phpunit #optional, setup tools globally
``` ```
### Experimental Setup ### Experimental Setup
@ -179,11 +209,12 @@ jobs:
- `PECL` is installed by default with this version on `ubuntu`. - `PECL` is installed by default with this version on `ubuntu`.
- Some extensions might not support this version currently. - Some extensions might not support this version currently.
- Refer to this [RFC](https://wiki.php.net/rfc/jit "PHP JIT RFC configuration") for configuring `PHP JIT` on this version. - Refer to this [RFC](https://wiki.php.net/rfc/jit "PHP JIT RFC configuration") for configuring `PHP JIT` on this version.
- Refer to this [list of RFCs](https://wiki.php.net/rfc#php_80 "List of RFCs implemented in PHP8") implemented in this version.
```yaml ```yaml
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v1 uses: actions/checkout@v2
- name: Setup PHP - name: Setup PHP
uses: shivammathur/setup-php@v1 uses: shivammathur/setup-php@v1
@ -192,6 +223,7 @@ steps:
extensions: mbstring #optional, setup extensions extensions: mbstring #optional, setup extensions
ini-values: opcache.jit_buffer_size=256M, opcache.jit=1235, pcre.jit=1 #optional, setup php.ini configuration ini-values: opcache.jit_buffer_size=256M, opcache.jit=1235, pcre.jit=1 #optional, setup php.ini configuration
coverage: pcov #optional, setup PCOV, Xdebug does not support this version yet. coverage: pcov #optional, setup PCOV, Xdebug does not support this version yet.
tools: php-cs-fixer, phpunit #optional, setup tools globally
``` ```
### Cache dependencies ### Cache dependencies
@ -216,6 +248,12 @@ You can persist composer's internal cache directory using the [`action/cache`](h
run: composer install --prefer-dist run: composer install --prefer-dist
``` ```
In the above example, if you support a range of `composer` dependencies and do not commit `composer.lock`, you can use the hash of `composer.json` as the key for your cache.
```yaml
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
```
### Problem Matchers ### Problem Matchers
You can setup problem matchers for your `PHPUnit` output. This will scan the errors in your tests and surface that information prominently in the GitHub Actions UI by creating annotations and log file decorations. You can setup problem matchers for your `PHPUnit` output. This will scan the errors in your tests and surface that information prominently in the GitHub Actions UI by creating annotations and log file decorations.
@ -231,6 +269,9 @@ Examples for setting up this GitHub Action with different PHP Frameworks/Package
|Framework/Package|Runs on|Workflow| |Framework/Package|Runs on|Workflow|
|--- |--- |--- | |--- |--- |--- |
|CakePHP with `MySQL` and `Redis`|`ubuntu`|[cakephp-mysql.yml](./examples/cakephp-mysql.yml "GitHub Action for CakePHP with MySQL and Redis")|
|CakePHP with `PostgreSQL` and `Redis`|`ubuntu`|[cakephp-postgres.yml](./examples/cakephp-postgres.yml "GitHub Action for CakePHP with Postgres and Redis")|
|CakePHP without services|`macOS`, `ubuntu` and `windows`|[cakephp.yml](./examples/cakephp.yml "GitHub Action for CakePHP without services")|
|CodeIgniter|`macOS`, `ubuntu` and `windows`|[codeigniter.yml](./examples/codeigniter.yml "GitHub Action for CodeIgniter")| |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 `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 with `PostgreSQL` and `Redis`|`ubuntu`|[laravel-postgres.yml](./examples/laravel-postgres.yml "GitHub Action for Laravel with PostgreSQL and Redis")|

View File

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

View File

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

View File

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

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

@ -0,0 +1,384 @@
import * as tools from '../src/tools';
describe('Tools tests', () => {
it('checking getCommand', async () => {
expect(await tools.getArchiveCommand('linux')).toBe('add_tool ');
expect(await tools.getArchiveCommand('darwin')).toBe('add_tool ');
expect(await tools.getArchiveCommand('win32')).toBe('Add-Tool ');
expect(await tools.getArchiveCommand('fedora')).toContain(
'Platform fedora is not supported'
);
});
it('checking getCommand', async () => {
expect(await tools.getPackageCommand('linux')).toBe('add_composer_tool ');
expect(await tools.getPackageCommand('darwin')).toBe('add_composer_tool ');
expect(await tools.getPackageCommand('win32')).toBe('Add-Composer-Tool ');
expect(await tools.getPackageCommand('fedora')).toContain(
'Platform fedora is not supported'
);
});
it('checking getPECLCommand', async () => {
expect(await tools.getPECLCommand('linux')).toBe('add_pecl ');
expect(await tools.getPECLCommand('darwin')).toBe('add_pecl ');
expect(await tools.getPECLCommand('win32')).toBe('Add-PECL ');
expect(await tools.getPECLCommand('fedora')).toContain(
'Platform fedora is not supported'
);
});
it('checking parseToolVersion', async () => {
expect(await tools.getToolVersion('latest')).toBe('latest');
expect(await tools.getToolVersion('1.2.3')).toBe('1.2.3');
expect(await tools.getToolVersion('^1.2.3')).toBe('1.2.3');
expect(await tools.getToolVersion('>=1.2.3')).toBe('1.2.3');
expect(await tools.getToolVersion('>1.2.3')).toBe('1.2.3');
expect(await tools.getToolVersion('1.2.3-ALPHA')).toBe('1.2.3-ALPHA');
expect(await tools.getToolVersion('1.2.3-alpha')).toBe('1.2.3-alpha');
expect(await tools.getToolVersion('1.2.3-beta')).toBe('1.2.3-beta');
expect(await tools.getToolVersion('1.2.3-rc')).toBe('1.2.3-rc');
expect(await tools.getToolVersion('1.2.3-dev')).toBe('1.2.3-dev');
expect(await tools.getToolVersion('1.2.3-alpha1')).toBe('1.2.3-alpha1');
expect(await tools.getToolVersion('1.2.3-alpha.1')).toBe('1.2.3-alpha.1');
});
it('checking parseToolVersion', async () => {
expect(await tools.parseTool('phpunit')).toStrictEqual({
name: 'phpunit',
version: 'latest'
});
expect(await tools.parseTool('phpunit:1.2.3')).toStrictEqual({
name: 'phpunit',
version: '1.2.3'
});
expect(await tools.parseTool('phpunit:^1.2.3')).toStrictEqual({
name: 'phpunit',
version: '1.2.3'
});
expect(await tools.parseTool('phpunit:>=1.2.3')).toStrictEqual({
name: 'phpunit',
version: '1.2.3'
});
expect(await tools.parseTool('phpunit:>1.2.3')).toStrictEqual({
name: 'phpunit',
version: '1.2.3'
});
expect(await tools.parseTool('phpunit:1.2.3-ALPHA')).toStrictEqual({
name: 'phpunit',
version: '1.2.3-ALPHA'
});
expect(await tools.parseTool('phpunit:1.2.3-alpha')).toStrictEqual({
name: 'phpunit',
version: '1.2.3-alpha'
});
expect(await tools.parseTool('phpunit:1.2.3-beta')).toStrictEqual({
name: 'phpunit',
version: '1.2.3-beta'
});
expect(await tools.parseTool('phpunit:1.2.3-rc')).toStrictEqual({
name: 'phpunit',
version: '1.2.3-rc'
});
expect(await tools.parseTool('phpunit:1.2.3-dev')).toStrictEqual({
name: 'phpunit',
version: '1.2.3-dev'
});
expect(await tools.parseTool('phpunit:1.2.3-alpha1')).toStrictEqual({
name: 'phpunit',
version: '1.2.3-alpha1'
});
expect(await tools.parseTool('phpunit:1.2.3-alpha.1')).toStrictEqual({
name: 'phpunit',
version: '1.2.3-alpha.1'
});
});
it('checking getUri', async () => {
expect(
await tools.getUri('tool', 'latest', 'releases', '', 'download')
).toBe('releases/latest/download/tool.phar');
expect(
await tools.getUri('tool', '1.2.3', 'releases', '', 'download')
).toBe('releases/download/1.2.3/tool.phar');
expect(
await tools.getUri('tool', '1.2.3', 'releases', 'v', 'download')
).toBe('releases/download/v1.2.3/tool.phar');
});
it('checking getCodeceptionUriBuilder', async () => {
expect(await tools.getCodeceptionUriBuilder('3.2.1', '5.6', 'php56')).toBe(
'releases/3.2.1/php56/codecept.phar'
);
expect(await tools.getCodeceptionUriBuilder('3.2.1', '7.0', 'php54')).toBe(
'releases/3.2.1/php54/codecept.phar'
);
expect(await tools.getCodeceptionUriBuilder('3.2.1', '7.1', 'php56')).toBe(
'releases/3.2.1/php56/codecept.phar'
);
expect(await tools.getCodeceptionUriBuilder('3.2.1', '7.2', 'php56')).toBe(
'releases/3.2.1/codecept.phar'
);
expect(await tools.getCodeceptionUriBuilder('3.2.1', '7.3', 'php56')).toBe(
'releases/3.2.1/codecept.phar'
);
expect(await tools.getCodeceptionUriBuilder('3.2.1', '7.4', 'php56')).toBe(
'releases/3.2.1/codecept.phar'
);
});
it('checking getCodeceptionUri', async () => {
expect(await tools.getCodeceptionUri('latest', '5.6')).toBe(
'php56/codecept.phar'
);
expect(await tools.getCodeceptionUri('latest', '7.0')).toBe(
'php56/codecept.phar'
);
expect(await tools.getCodeceptionUri('latest', '7.1')).toBe(
'php56/codecept.phar'
);
expect(await tools.getCodeceptionUri('latest', '7.2')).toBe(
'codecept.phar'
);
expect(await tools.getCodeceptionUri('latest', '7.3')).toBe(
'codecept.phar'
);
expect(await tools.getCodeceptionUri('latest', '7.4')).toBe(
'codecept.phar'
);
expect(await tools.getCodeceptionUri('3.2.1', '5.6')).toBe(
'releases/3.2.1/php54/codecept.phar'
);
expect(await tools.getCodeceptionUri('4.3.2', '5.6')).toBe(
'releases/4.3.2/php56/codecept.phar'
);
expect(await tools.getCodeceptionUri('3.2.1', '7.4')).toBe(
'releases/3.2.1/codecept.phar'
);
expect(await tools.getCodeceptionUri('4.3.2', '7.4')).toBe(
'releases/4.3.2/codecept.phar'
);
});
it('checking getPhpunitUri', async () => {
expect(await tools.getPhpunitUrl('tool', 'latest')).toBe(
'https://phar.phpunit.de/tool.phar'
);
expect(await tools.getPhpunitUrl('tool', '1.2.3')).toBe(
'https://phar.phpunit.de/tool-1.2.3.phar'
);
});
it('checking getDeployerUri', async () => {
expect(await tools.getDeployerUrl('latest')).toBe(
'https://deployer.org/deployer.phar'
);
expect(await tools.getDeployerUrl('1.2.3')).toBe(
'https://deployer.org/releases/v1.2.3/deployer.phar'
);
});
it('checking getDeployerUri', async () => {
expect(await tools.addComposer(['a', 'b'])).toStrictEqual([
'composer',
'a',
'b'
]);
expect(await tools.addComposer(['a', 'b', 'composer'])).toStrictEqual([
'composer',
'a',
'b'
]);
expect(
await tools.addComposer(['a', 'b', 'composer:1.2.3'])
).toStrictEqual(['composer', 'a', 'b']);
});
it('checking getCleanedToolsList', async () => {
const tools_list: string[] = await tools.getCleanedToolsList(
'tool, composer:1.2.3, robmorgan/phinx, hirak/prestissimo, narrowspark/automatic-composer-prefetcher'
);
expect(tools_list).toStrictEqual([
'composer',
'tool',
'phinx',
'prestissimo',
'composer-prefetcher'
]);
});
it('checking addArchive', async () => {
let script: string = await tools.addArchive(
'tool',
'1.2.3',
'https://tool.com/tool.phar',
'linux'
);
expect(script).toContain('add_tool https://tool.com/tool.phar tool');
script = await tools.addArchive(
'tool',
'1.2.3',
'https://tool.com/tool.phar',
'darwin'
);
expect(script).toContain('add_tool https://tool.com/tool.phar tool');
script = await tools.addArchive(
'tool',
'1.2.3',
'https://tool.com/tool.phar',
'win32'
);
expect(script).toContain('Add-Tool https://tool.com/tool.phar tool');
script = await tools.addArchive(
'tool',
'1.2.3',
'https://tool.com/tool.phar',
'fedora'
);
expect(script).toContain('Platform fedora is not supported');
});
it('checking addDevTools', async () => {
let script: string = await tools.addDevTools('phpize', 'linux');
expect(script).toContain('add_devtools');
expect(script).toContain('add_log "$tick" "phpize" "Added"');
script = await tools.addDevTools('php-config', 'linux');
expect(script).toContain('add_devtools');
expect(script).toContain('add_log "$tick" "php-config" "Added"');
script = await tools.addDevTools('phpize', 'darwin');
expect(script).toContain('add_log "$tick" "phpize" "Added"');
script = await tools.addDevTools('php-config', 'darwin');
expect(script).toContain('add_log "$tick" "php-config" "Added"');
script = await tools.addDevTools('phpize', 'win32');
expect(script).toContain(
'Add-Log "$cross" "phpize" "phpize is not a windows tool"'
);
script = await tools.addDevTools('php-config', 'win32');
expect(script).toContain(
'Add-Log "$cross" "php-config" "php-config is not a windows tool"'
);
script = await tools.addDevTools('tool', 'fedora');
expect(script).toContain('Platform fedora is not supported');
});
it('checking addPackage', async () => {
let script: string = await tools.addPackage(
'tool',
'tool:1.2.3',
'user/',
'linux'
);
expect(script).toContain('add_composer_tool tool tool:1.2.3 user/');
script = await tools.addPackage('tool', 'tool:1.2.3', 'user/', 'darwin');
expect(script).toContain('add_composer_tool tool tool:1.2.3 user/');
script = await tools.addPackage('tool', 'tool:1.2.3', 'user/', 'win32');
expect(script).toContain('Add-Composer-Tool tool tool:1.2.3 user/');
script = await tools.addPackage('tool', 'tool:1.2.3', 'user/', 'fedora');
expect(script).toContain('Platform fedora is not supported');
});
it('checking addTools on linux', async () => {
const script: string = await tools.addTools(
'php-cs-fixer, phpstan, phpunit, pecl, phinx, phinx:1.2.3, php-config, phpize',
'7.4',
'linux'
);
expect(script).toContain(
'add_tool https://github.com/composer/composer/releases/latest/download/composer.phar composer'
);
expect(script).toContain(
'add_tool https://github.com/FriendsOfPHP/PHP-CS-Fixer/releases/latest/download/php-cs-fixer.phar php-cs-fixer'
);
expect(script).toContain(
'add_tool https://github.com/phpstan/phpstan/releases/latest/download/phpstan.phar phpstan'
);
expect(script).toContain(
'add_tool https://phar.phpunit.de/phpunit.phar phpunit'
);
expect(script).toContain('add_pecl');
expect(script).toContain('add_composer_tool phinx phinx robmorgan/');
expect(script).toContain('add_composer_tool phinx phinx:1.2.3 robmorgan/');
expect(script).toContain('add_devtools');
expect(script).toContain('add_log "$tick" "php-config" "Added"');
expect(script).toContain('add_log "$tick" "phpize" "Added"');
});
it('checking addTools on darwin', async () => {
const script: string = await tools.addTools(
'phpcs, phpcbf, phpcpd, phpmd, psalm, phinx, composer-prefetcher:1.2.3, phpize, php-config',
'7.4',
'darwin'
);
expect(script).toContain(
'add_tool https://github.com/composer/composer/releases/latest/download/composer.phar composer'
);
expect(script).toContain(
'add_tool https://github.com/squizlabs/PHP_CodeSniffer/releases/latest/download/phpcs.phar phpcs'
);
expect(script).toContain(
'add_tool https://github.com/squizlabs/PHP_CodeSniffer/releases/latest/download/phpcbf.phar phpcbf'
);
expect(script).toContain(
'add_tool https://phar.phpunit.de/phpcpd.phar phpcpd'
);
expect(script).toContain(
'add_tool https://github.com/phpmd/phpmd/releases/latest/download/phpmd.phar phpmd'
);
expect(script).toContain(
'https://github.com/vimeo/psalm/releases/latest/download/psalm.phar psalm'
);
expect(script).toContain('add_composer_tool phinx phinx robmorgan/');
expect(script).toContain(
'add_composer_tool composer-prefetcher composer-prefetcher:1.2.3 narrowspark/automatic-'
);
expect(script).toContain('add_log "$tick" "phpize" "Added"');
expect(script).toContain('add_log "$tick" "php-config" "Added"');
});
it('checking addTools on windows', async () => {
const script: string = await tools.addTools(
'codeception, deployer, prestissimo, phpmd, phinx, php-config, phpize, does_not_exit',
'7.4',
'win32'
);
expect(script).toContain(
'Add-Tool https://github.com/composer/composer/releases/latest/download/composer.phar composer'
);
expect(script).toContain(
'Add-Tool https://deployer.org/deployer.phar deployer'
);
expect(script).toContain(
'Add-Composer-Tool prestissimo prestissimo hirak/'
);
expect(script).toContain('Add-Composer-Tool phinx phinx robmorgan/');
expect(script).toContain('phpize is not a windows tool');
expect(script).toContain('php-config is not a windows tool');
expect(script).toContain('Tool does_not_exit is not supported');
expect(script).toContain('Tool does_not_exit is not supported');
});
it('checking addTools with composer tool using user/tool as input', async () => {
const script: string = await tools.addTools(
'hirak/prestissimo, narrowspark/automatic-composer-prefetcher, robmorgan/phinx',
'7.4',
'win32'
);
expect(script).toContain(
'Add-Tool https://github.com/composer/composer/releases/latest/download/composer.phar composer'
);
expect(script).toContain(
'Add-Composer-Tool prestissimo prestissimo hirak/'
);
expect(script).toContain('Add-Composer-Tool phinx phinx robmorgan/');
expect(script).toContain(
'Add-Composer-Tool composer-prefetcher composer-prefetcher narrowspark/automatic-'
);
});
});

View File

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

View File

@ -17,17 +17,21 @@ inputs:
coverage: coverage:
description: 'Setup code coverage driver.' description: 'Setup code coverage driver.'
required: false required: false
pecl: tools:
description: 'Setup PECL on ubuntu' description: 'Setup popular tools globally.'
required: false required: false
# Deprecated options, do not use. Will not be supported after February 1, 2020. # Deprecated options, do not use. Will not be supported in v2 which will be released around February 1, 2020.
extension-csv: extension-csv:
description: 'Deprecated! Use extensions instead.' description: 'Deprecated! Use extensions instead.'
deprecationMessage: 'The extension-csv property will not be supported after February 1, 2020. Use extensions instead.' deprecationMessage: 'The extension-csv property will not be supported in v2. Use extensions instead.'
required: false required: false
ini-values-csv: ini-values-csv:
description: 'Deprecated! Use ini-values instead.' description: 'Deprecated! Use ini-values instead.'
deprecationMessage: 'The ini-values-csv property will not be supported after February 1, 2020. Use ini-values instead.' deprecationMessage: 'The ini-values-csv property will not be supported in v2. Use ini-values instead.'
required: false
pecl:
description: 'Deprecated! Use tools instead to setup PECL.'
deprecationMessage: 'The pecl property will not be supported in v2. Specify pecl in tools instead.'
required: false required: false
runs: runs:
using: 'node12' using: 'node12'

683
dist/index.js vendored
View File

@ -1172,36 +1172,42 @@ function extensionArray(extension_csv) {
case ' ': case ' ':
return []; return [];
default: default:
return extension_csv.split(',').map(function (extension) { return extension_csv
.split(',')
.map(function (extension) {
return extension return extension
.trim() .trim()
.replace('php-', '') .replace('php-', '')
.replace('php_', ''); .replace('php_', '');
}); })
.filter(Boolean);
} }
}); });
} }
exports.extensionArray = extensionArray; exports.extensionArray = extensionArray;
/** /**
* Function to break ini values csv into an array * Function to break csv into an array
* *
* @param ini_values_csv * @param values_csv
* @constructor * @constructor
*/ */
function INIArray(ini_values_csv) { function CSVArray(values_csv) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
switch (ini_values_csv) { switch (values_csv) {
case '': case '':
case ' ': case ' ':
return []; return [];
default: default:
return ini_values_csv.split(',').map(function (ini_value) { return values_csv
return ini_value.trim(); .split(',')
}); .map(function (value) {
return value.trim();
})
.filter(Boolean);
} }
}); });
} }
exports.INIArray = INIArray; exports.CSVArray = CSVArray;
/** /**
* Function to get prefix required to load an extension. * Function to get prefix required to load an extension.
* *
@ -1291,13 +1297,20 @@ class Command {
let cmdStr = CMD_STRING + this.command; let cmdStr = CMD_STRING + this.command;
if (this.properties && Object.keys(this.properties).length > 0) { if (this.properties && Object.keys(this.properties).length > 0) {
cmdStr += ' '; cmdStr += ' ';
let first = true;
for (const key in this.properties) { for (const key in this.properties) {
if (this.properties.hasOwnProperty(key)) { if (this.properties.hasOwnProperty(key)) {
const val = this.properties[key]; const val = this.properties[key];
if (val) { if (val) {
if (first) {
first = false;
}
else {
cmdStr += ',';
}
// safely append the val - avoid blowing up when attempting to // safely append the val - avoid blowing up when attempting to
// call .replace() if message is not a string for some reason // call .replace() if message is not a string for some reason
cmdStr += `${key}=${escape(`${val || ''}`)},`; cmdStr += `${key}=${escape(`${val || ''}`)}`;
} }
} }
} }
@ -1524,6 +1537,417 @@ function getState(name) {
exports.getState = getState; exports.getState = getState;
//# sourceMappingURL=core.js.map //# sourceMappingURL=core.js.map
/***/ }),
/***/ 534:
/***/ (function(__unusedmodule, exports, __webpack_require__) {
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const utils = __importStar(__webpack_require__(163));
/**
* Function to get command to setup tool
*
* @param os_version
*/
function getArchiveCommand(os_version) {
return __awaiter(this, void 0, void 0, function* () {
switch (os_version) {
case 'linux':
case 'darwin':
return 'add_tool ';
case 'win32':
return 'Add-Tool ';
default:
return yield utils.log('Platform ' + os_version + ' is not supported', os_version, 'error');
}
});
}
exports.getArchiveCommand = getArchiveCommand;
/**
* Function to get command to setup tools using composer
*
* @param os_version
*/
function getPackageCommand(os_version) {
return __awaiter(this, void 0, void 0, function* () {
switch (os_version) {
case 'linux':
case 'darwin':
return 'add_composer_tool ';
case 'win32':
return 'Add-Composer-Tool ';
default:
return yield utils.log('Platform ' + os_version + ' is not supported', os_version, 'error');
}
});
}
exports.getPackageCommand = getPackageCommand;
/**
*
* Function to get command to setup PECL
*
* @param os_version
*/
function getPECLCommand(os_version) {
return __awaiter(this, void 0, void 0, function* () {
switch (os_version) {
case 'linux':
case 'darwin':
return 'add_pecl ';
case 'win32':
return 'Add-PECL ';
default:
return yield utils.log('Platform ' + os_version + ' is not supported', os_version, 'error');
}
});
}
exports.getPECLCommand = getPECLCommand;
/**
* Function to get tool version
*
* @param version
*/
function getToolVersion(version) {
return __awaiter(this, void 0, void 0, function* () {
// semver_regex - https://semver.org/
const semver_regex = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/;
version = version.replace(/[><=^]*/, '');
switch (true) {
case semver_regex.test(version):
return version;
default:
return 'latest';
}
});
}
exports.getToolVersion = getToolVersion;
/**
* Function to parse tool:version
*
* @param release
*/
function parseTool(release) {
return __awaiter(this, void 0, void 0, function* () {
const parts = release.split(':');
const tool = parts[0];
const version = parts[1];
switch (version) {
case undefined:
return {
name: tool,
version: 'latest'
};
default:
return {
name: tool,
version: yield getToolVersion(parts[1])
};
}
});
}
exports.parseTool = parseTool;
/**
* Function to get the url of tool with the given version
*
* @param version
* @param prefix
* @param version_prefix
* @param verb
*/
function getUri(tool, version, prefix, version_prefix, verb) {
return __awaiter(this, void 0, void 0, function* () {
switch (version) {
case 'latest':
return [prefix, version, verb, tool + '.phar'].filter(Boolean).join('/');
default:
return [prefix, verb, version_prefix + version, tool + '.phar']
.filter(Boolean)
.join('/');
}
});
}
exports.getUri = getUri;
/**
* Helper function to get the codeception url
*
* @param version
* @param php_version
* @param suffix
*/
function getCodeceptionUriBuilder(version, php_version, suffix) {
return __awaiter(this, void 0, void 0, function* () {
switch (true) {
case /^5\.6$|^7\.[0|1]$/.test(php_version):
return ['releases', version, suffix, 'codecept.phar']
.filter(Boolean)
.join('/');
case /^7\.[2-4]$/.test(php_version):
default:
return ['releases', version, 'codecept.phar'].filter(Boolean).join('/');
}
});
}
exports.getCodeceptionUriBuilder = getCodeceptionUriBuilder;
/**
* Function to get the codeception url
*
* @param version
* @param php_version
*/
function getCodeceptionUri(version, php_version) {
return __awaiter(this, void 0, void 0, function* () {
switch (true) {
case /latest/.test(version):
switch (true) {
case /^5\.6$|^7\.[0|1]$/.test(php_version):
return 'php56/codecept.phar';
case /^7\.[2-4]$/.test(php_version):
default:
return 'codecept.phar';
}
case /([4-9]|\d{2,})\..*/.test(version):
return yield getCodeceptionUriBuilder(version, php_version, 'php56');
default:
return yield getCodeceptionUriBuilder(version, php_version, 'php54');
}
});
}
exports.getCodeceptionUri = getCodeceptionUri;
/**
* Function to get the PHPUnit url
*
* @param version
*/
function getPhpunitUrl(tool, version) {
return __awaiter(this, void 0, void 0, function* () {
const phpunit = 'https://phar.phpunit.de';
switch (version) {
case 'latest':
return phpunit + '/' + tool + '.phar';
default:
return phpunit + '/' + tool + '-' + version + '.phar';
}
});
}
exports.getPhpunitUrl = getPhpunitUrl;
/**
* Function to get the Deployer url
*
* @param version
*/
function getDeployerUrl(version) {
return __awaiter(this, void 0, void 0, function* () {
const deployer = 'https://deployer.org';
switch (version) {
case 'latest':
return deployer + '/deployer.phar';
default:
return deployer + '/releases/v' + version + '/deployer.phar';
}
});
}
exports.getDeployerUrl = getDeployerUrl;
/**
* Function to add/move composer in the tools list
*
* @param tools
*/
function addComposer(tools_list) {
return __awaiter(this, void 0, void 0, function* () {
const regex = /^composer($|:.*)/;
const composer = tools_list.filter(tool => regex.test(tool))[0];
switch (composer) {
case undefined:
break;
default:
tools_list = tools_list.filter(tool => !regex.test(tool));
break;
}
tools_list.unshift('composer');
return tools_list;
});
}
exports.addComposer = addComposer;
/**
* Function to get Tools list after cleanup
*
* @param tools_csv
*/
function getCleanedToolsList(tools_csv) {
return __awaiter(this, void 0, void 0, function* () {
let tools_list = yield utils.CSVArray(tools_csv);
tools_list = yield addComposer(tools_list);
tools_list = tools_list
.map(function (extension) {
return extension
.trim()
.replace(/robmorgan\/|hirak\/|narrowspark\/automatic-/, '');
})
.filter(Boolean);
return [...new Set(tools_list)];
});
}
exports.getCleanedToolsList = getCleanedToolsList;
/**
* Helper function to get script to setup a tool using a phar url
*
* @param tool
* @param version
* @param url
* @param os_version
*/
function addArchive(tool, version, url, os_version) {
return __awaiter(this, void 0, void 0, function* () {
return (yield getArchiveCommand(os_version)) + url + ' ' + tool;
});
}
exports.addArchive = addArchive;
/**
* Function to get the script to setup php-config and phpize
*
* @param tool
* @param os_version
*/
function addDevTools(tool, os_version) {
return __awaiter(this, void 0, void 0, function* () {
switch (os_version) {
case 'linux':
return ('add_devtools' +
'\n' +
(yield utils.addLog('$tick', tool, 'Added', 'linux')));
case 'darwin':
return yield utils.addLog('$tick', tool, 'Added', 'darwin');
case 'win32':
return yield utils.addLog('$cross', tool, tool + ' is not a windows tool', 'win32');
default:
return yield utils.log('Platform ' + os_version + ' is not supported', os_version, 'error');
}
});
}
exports.addDevTools = addDevTools;
/**
* Helper function to get script to setup a tool using composer
*
* @param tool
* @param release
* @param prefix
* @param os_version
*/
function addPackage(tool, release, prefix, os_version) {
return __awaiter(this, void 0, void 0, function* () {
const tool_command = yield getPackageCommand(os_version);
return tool_command + tool + ' ' + release + ' ' + prefix;
});
}
exports.addPackage = addPackage;
/**
* Setup tools
*
* @param tool_csv
* @param os_version
*/
function addTools(tools_csv, php_version, os_version) {
return __awaiter(this, void 0, void 0, function* () {
let script = '\n' + (yield utils.stepLog('Setup Tools', os_version));
const tools_list = yield getCleanedToolsList(tools_csv);
yield utils.asyncForEach(tools_list, function (release) {
return __awaiter(this, void 0, void 0, function* () {
const tool_data = yield parseTool(release);
const tool = tool_data.name;
const version = tool_data.version;
const github = 'https://github.com/';
let uri = yield getUri(tool, version, 'releases', '', 'download');
script += '\n';
let url = '';
switch (tool) {
case 'php-cs-fixer':
uri = yield getUri(tool, version, 'releases', 'v', 'download');
url = github + 'FriendsOfPHP/PHP-CS-Fixer/' + uri;
script += yield addArchive(tool, version, url, os_version);
break;
case 'phpcs':
case 'phpcbf':
url = github + 'squizlabs/PHP_CodeSniffer/' + uri;
script += yield addArchive(tool, version, url, os_version);
break;
case 'phpstan':
url = github + 'phpstan/phpstan/' + uri;
script += yield addArchive(tool, version, url, os_version);
break;
case 'phpmd':
url = github + 'phpmd/phpmd/' + uri;
script += yield addArchive(tool, version, url, os_version);
break;
case 'psalm':
url = github + 'vimeo/psalm/' + uri;
script += yield addArchive(tool, version, url, os_version);
break;
case 'composer':
url =
github + 'composer/composer/releases/latest/download/composer.phar';
script += yield addArchive(tool, version, url, os_version);
break;
case 'codeception':
url =
'https://codeception.com/' +
(yield getCodeceptionUri(version, php_version));
script += yield addArchive(tool, version, url, os_version);
break;
case 'phpcpd':
case 'phpunit':
url = yield getPhpunitUrl(tool, version);
script += yield addArchive(tool, version, url, os_version);
break;
case 'deployer':
url = yield getDeployerUrl(version);
script += yield addArchive(tool, version, url, os_version);
break;
case 'phinx':
script += yield addPackage(tool, release, 'robmorgan/', os_version);
break;
case 'prestissimo':
script += yield addPackage(tool, release, 'hirak/', os_version);
break;
case 'composer-prefetcher':
script += yield addPackage(tool, release, 'narrowspark/automatic-', os_version);
break;
case 'pecl':
script += yield getPECLCommand(os_version);
break;
case 'php-config':
case 'phpize':
script += yield addDevTools(tool, os_version);
break;
default:
script += yield utils.addLog('$cross', tool, 'Tool ' + tool + ' is not supported', os_version);
break;
}
});
});
return script;
});
}
exports.addTools = addTools;
/***/ }), /***/ }),
/***/ 614: /***/ 614:
@ -1570,8 +1994,9 @@ const config = __importStar(__webpack_require__(641));
* *
* @param version * @param version
* @param os_version * @param os_version
* @param pipe
*/ */
function addCoverageXdebug(version, os_version) { function addCoverageXdebug(version, os_version, pipe) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
switch (version) { switch (version) {
case '8.0': case '8.0':
@ -1580,7 +2005,7 @@ function addCoverageXdebug(version, os_version) {
case '7.4': case '7.4':
default: default:
return ((yield extensions.addExtension('xdebug', version, os_version, true)) + return ((yield extensions.addExtension('xdebug', version, os_version, true)) +
(yield utils.suppressOutput(os_version)) + pipe +
'\n' + '\n' +
(yield utils.addLog('$tick', 'xdebug', 'Xdebug enabled as coverage driver', os_version))); (yield utils.addLog('$tick', 'xdebug', 'Xdebug enabled as coverage driver', os_version)));
} }
@ -1592,47 +2017,27 @@ exports.addCoverageXdebug = addCoverageXdebug;
* *
* @param version * @param version
* @param os_version * @param os_version
* @param pipe
*/ */
function addCoveragePCOV(version, os_version) { function addCoveragePCOV(version, os_version, pipe) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
let script = '\n'; let script = '\n';
switch (version) { switch (version) {
default: default:
script += script +=
(yield extensions.addExtension('pcov', version, os_version, true)) + (yield extensions.addExtension('pcov', version, os_version, true)) +
(yield utils.suppressOutput(os_version)) + pipe +
'\n'; '\n';
script += script +=
(yield config.addINIValues('pcov.enabled=1', os_version, true)) + '\n'; (yield config.addINIValues('pcov.enabled=1', os_version, true)) + '\n';
// add command to disable xdebug and enable pcov // add command to disable xdebug and enable pcov
switch (os_version) { switch (os_version) {
case 'linux': case 'linux':
script +=
'if [ -e /etc/php/' +
version +
'/mods-available/xdebug.ini ]; then sudo phpdismod -v ' +
version +
' xdebug; fi\n';
script += 'sudo sed -i "/xdebug/d" "$ini_file"\n';
script +=
'sudo DEBIAN_FRONTEND=noninteractive apt-fast remove php-xdebug -y ' +
(yield utils.suppressOutput('linux')) +
'\n';
break;
case 'darwin': case 'darwin':
script += 'sudo sed -i \'\' "/xdebug/d" "$ini_file"\n'; script += 'remove_extension xdebug' + pipe + '\n';
script +=
'sudo rm -rf "$ext_dir"/xdebug.so ' +
(yield utils.suppressOutput('darwin')) +
'\n';
break; break;
case 'win32': case 'win32':
script += script += 'Remove-Extension xdebug' + pipe + '\n';
'if(php -m | findstr -i xdebug) { Disable-PhpExtension xdebug $php_dir }\n';
script +=
'if (Test-Path $ext_dir\\php_xdebug.dll) { Remove-Item $ext_dir\\php_xdebug.dll }' +
(yield utils.suppressOutput('win32')) +
'\n';
break; break;
} }
// success // success
@ -1653,56 +2058,20 @@ exports.addCoveragePCOV = addCoveragePCOV;
* *
* @param version * @param version
* @param os_version * @param os_version
* @param pipe
*/ */
function disableCoverage(version, os_version) { function disableCoverage(version, os_version, pipe) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
let script = '\n'; let script = '\n';
switch (os_version) { switch (os_version) {
case 'linux': case 'linux':
script +=
'if [ -e /etc/php/' +
version +
'/mods-available/xdebug.ini ]; then sudo phpdismod -v ' +
version +
' xdebug; fi\n';
script +=
'if [ -e /etc/php/' +
version +
'/mods-available/pcov.ini ]; then sudo phpdismod -v ' +
version +
' pcov; fi\n';
script += 'sudo sed -i "/xdebug/d" "$ini_file"\n';
script += 'sudo sed -i "/pcov/d" "$ini_file"\n';
script +=
'sudo DEBIAN_FRONTEND=noninteractive apt-fast remove php-xdebug php-pcov -y ' +
(yield utils.suppressOutput('linux')) +
'\n';
break;
case 'darwin': case 'darwin':
script += 'sudo sed -i \'\' "/xdebug/d" "$ini_file"\n'; script += 'remove_extension xdebug' + pipe + '\n';
script += 'sudo sed -i \'\' "/pcov/d" "$ini_file"\n'; script += 'remove_extension pcov' + pipe + '\n';
script +=
'sudo rm -rf "$ext_dir"/xdebug.so ' +
(yield utils.suppressOutput('darwin')) +
'\n';
script +=
'sudo rm -rf "$ext_dir"/pcov.so ' +
(yield utils.suppressOutput('darwin')) +
'\n';
break; break;
case 'win32': case 'win32':
script += script += 'Remove-Extension xdebug' + pipe + '\n';
'if(php -m | findstr -i xdebug) { Disable-PhpExtension xdebug $php_dir }\n'; script += 'Remove-Extension pcov' + pipe + '\n';
script +=
'if(php -m | findstr -i pcov) { Disable-PhpExtension pcov $php_dir }\n';
script +=
'if (Test-Path $ext_dir\\php_xdebug.dll) { Remove-Item $ext_dir\\php_xdebug.dll }' +
(yield utils.suppressOutput('win32')) +
'\n';
script +=
'if (Test-Path $ext_dir\\php_pcov.dll) { Remove-Item $ext_dir\\php_pcov.dll }' +
(yield utils.suppressOutput('win32')) +
'\n';
break; break;
} }
script += yield utils.addLog('$tick', 'none', 'Disabled Xdebug and PCOV', os_version); script += yield utils.addLog('$tick', 'none', 'Disabled Xdebug and PCOV', os_version);
@ -1721,13 +2090,14 @@ function addCoverage(coverage_driver, version, os_version) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
coverage_driver.toLowerCase(); coverage_driver.toLowerCase();
const script = '\n' + (yield utils.stepLog('Setup Coverage', os_version)); const script = '\n' + (yield utils.stepLog('Setup Coverage', os_version));
const pipe = yield utils.suppressOutput(os_version);
switch (coverage_driver) { switch (coverage_driver) {
case 'pcov': case 'pcov':
return script + (yield addCoveragePCOV(version, os_version)); return script + (yield addCoveragePCOV(version, os_version, pipe));
case 'xdebug': case 'xdebug':
return script + (yield addCoverageXdebug(version, os_version)); return script + (yield addCoverageXdebug(version, os_version, pipe));
case 'none': case 'none':
return script + (yield disableCoverage(version, os_version)); return script + (yield disableCoverage(version, os_version, pipe));
default: default:
return ''; return '';
} }
@ -1768,7 +2138,7 @@ const utils = __importStar(__webpack_require__(163));
*/ */
function addINIValuesUnix(ini_values_csv) { function addINIValuesUnix(ini_values_csv) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
const ini_values = yield utils.INIArray(ini_values_csv); const ini_values = yield utils.CSVArray(ini_values_csv);
let script = '\n'; let script = '\n';
yield utils.asyncForEach(ini_values, function (line) { yield utils.asyncForEach(ini_values, function (line) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
@ -1787,7 +2157,7 @@ exports.addINIValuesUnix = addINIValuesUnix;
*/ */
function addINIValuesWindows(ini_values_csv) { function addINIValuesWindows(ini_values_csv) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
const ini_values = yield utils.INIArray(ini_values_csv); const ini_values = yield utils.CSVArray(ini_values_csv);
let script = '\n'; let script = '\n';
yield utils.asyncForEach(ini_values, function (line) { yield utils.asyncForEach(ini_values, function (line) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
@ -1866,6 +2236,7 @@ const core = __importStar(__webpack_require__(470));
const config = __importStar(__webpack_require__(641)); const config = __importStar(__webpack_require__(641));
const coverage = __importStar(__webpack_require__(635)); const coverage = __importStar(__webpack_require__(635));
const extensions = __importStar(__webpack_require__(911)); const extensions = __importStar(__webpack_require__(911));
const tools = __importStar(__webpack_require__(534));
const utils = __importStar(__webpack_require__(163)); const utils = __importStar(__webpack_require__(163));
const matchers = __importStar(__webpack_require__(86)); const matchers = __importStar(__webpack_require__(86));
/** /**
@ -1883,8 +2254,13 @@ function build(filename, version, os_version) {
const ini_values_csv = (yield utils.getInput('ini-values', false)) || const ini_values_csv = (yield utils.getInput('ini-values', false)) ||
(yield utils.getInput('ini-values-csv', false)); (yield utils.getInput('ini-values-csv', false));
const coverage_driver = yield utils.getInput('coverage', false); const coverage_driver = yield utils.getInput('coverage', false);
const setup_matchers = yield utils.getInput('matchers', false); const pecl = yield utils.getInput('pecl', false);
let tools_csv = yield utils.getInput('tools', false);
if (pecl == 'true') {
tools_csv = 'pecl, ' + tools_csv;
}
let script = yield utils.readScript(filename, version, os_version); let script = yield utils.readScript(filename, version, os_version);
script += yield tools.addTools(tools_csv, version, os_version);
if (extension_csv) { if (extension_csv) {
script += yield extensions.addExtension(extension_csv, version, os_version); script += yield extensions.addExtension(extension_csv, version, os_version);
} }
@ -1906,23 +2282,18 @@ function run() {
try { try {
const os_version = process.platform; const os_version = process.platform;
let version = yield utils.getInput('php-version', true); let version = yield utils.getInput('php-version', true);
version = version.length > 1 ? version : version + '.0'; version = version.length > 1 ? version.slice(0, 3) : version + '.0';
// check the os version and run the respective script // check the os version and run the respective script
let script_path = ''; let script_path = '';
switch (os_version) { switch (os_version) {
case 'darwin': case 'darwin':
case 'linux':
script_path = yield build(os_version + '.sh', version, os_version); script_path = yield build(os_version + '.sh', version, os_version);
yield exec_1.exec('sh ' + script_path + ' ' + version + ' ' + __dirname); yield exec_1.exec('sh ' + script_path + ' ' + version + ' ' + __dirname);
break; break;
case 'linux': {
const pecl = yield utils.getInput('pecl', false);
script_path = yield build(os_version + '.sh', version, os_version);
yield exec_1.exec('sh ' + script_path + ' ' + version + ' ' + pecl);
break;
}
case 'win32': case 'win32':
script_path = yield build('win32.ps1', version, os_version); script_path = yield build('win32.ps1', version, os_version);
yield exec_1.exec('pwsh ' + script_path + ' -version ' + version + ' -dir ' + __dirname); yield exec_1.exec('pwsh ' + script_path + ' ' + version + ' ' + __dirname);
break; break;
} }
yield matchers.addMatchers(); yield matchers.addMatchers();
@ -2184,25 +2555,40 @@ const utils = __importStar(__webpack_require__(163));
* *
* @param extension_csv * @param extension_csv
* @param version * @param version
* @param pipe
*/ */
function addExtensionDarwin(extension_csv, version) { function addExtensionDarwin(extension_csv, version, pipe) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
const extensions = yield utils.extensionArray(extension_csv); const extensions = yield utils.extensionArray(extension_csv);
let script = '\n'; let script = '\n';
yield utils.asyncForEach(extensions, function (extension) { yield utils.asyncForEach(extensions, function (extension) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
extension = extension.toLowerCase(); extension = extension.toLowerCase();
const version_extension = version + extension;
// add script to enable extension is already installed along with php // add script to enable extension is already installed along with php
let install_command = ''; let install_command = '';
switch (version + extension) { switch (true) {
case '5.6xdebug': case /5\.6xdebug/.test(version_extension):
install_command = 'sudo pecl install xdebug-2.5.5 >/dev/null 2>&1'; install_command = 'sudo pecl install xdebug-2.5.5' + pipe;
break; break;
case '5.6redis': case /7\.0xdebug/.test(version_extension):
install_command = 'sudo pecl install redis-2.2.8 >/dev/null 2>&1'; install_command = 'sudo pecl install xdebug-2.9.0' + pipe;
break;
case /5\.6redis/.test(version_extension):
install_command = 'sudo pecl install redis-2.2.8' + pipe;
break;
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
install_command =
'sh ' +
path.join(__dirname, '../src/scripts/ext/phalcon_darwin.sh') +
' ' +
extension +
' ' +
version +
pipe;
break; break;
default: default:
install_command = 'sudo pecl install ' + extension + ' >/dev/null 2>&1'; install_command = 'sudo pecl install ' + extension + pipe;
break; break;
} }
script += script +=
@ -2223,17 +2609,27 @@ exports.addExtensionDarwin = addExtensionDarwin;
* *
* @param extension_csv * @param extension_csv
* @param version * @param version
* @param pipe
*/ */
function addExtensionWindows(extension_csv, version) { function addExtensionWindows(extension_csv, version, pipe) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
const extensions = yield utils.extensionArray(extension_csv); const extensions = yield utils.extensionArray(extension_csv);
let script = '\n'; let script = '\n';
yield utils.asyncForEach(extensions, function (extension) { yield utils.asyncForEach(extensions, function (extension) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
// add script to enable extension is already installed along with php // add script to enable extension is already installed along with php
switch (version + extension) { const version_extension = version + extension;
case '7.4redis': switch (true) {
script += '\nAdd-Extension ' + extension + ' beta'; // match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
script +=
'\n& ' +
path.join(__dirname, '../src/scripts/ext/phalcon.ps1') +
' ' +
extension +
' ' +
version +
'\n';
break; break;
default: default:
script += '\nAdd-Extension ' + extension; script += '\nAdd-Extension ' + extension;
@ -2250,8 +2646,9 @@ exports.addExtensionWindows = addExtensionWindows;
* *
* @param extension_csv * @param extension_csv
* @param version * @param version
* @param pipe
*/ */
function addExtensionLinux(extension_csv, version) { function addExtensionLinux(extension_csv, version, pipe) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
const extensions = yield utils.extensionArray(extension_csv); const extensions = yield utils.extensionArray(extension_csv);
let script = '\n'; let script = '\n';
@ -2259,52 +2656,49 @@ function addExtensionLinux(extension_csv, version) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
extension = extension.toLowerCase(); extension = extension.toLowerCase();
// add script to enable extension is already installed along with php // add script to enable extension is already installed along with php
const version_extension = version + extension;
let install_command = ''; let install_command = '';
switch (version + extension) { switch (true) {
case '7.4redis': // match 5.6gearman..7.4gearman
install_command = case /^((5\.6)|(7\.[0-4]))gearman$/.test(version_extension):
'sudo DEBIAN_FRONTEND=noninteractive apt-get install -y php7.4-igbinary php7.4-redis >/dev/null 2>&1';
break;
case '7.2phalcon3':
case '7.3phalcon3':
install_command = install_command =
'sh ' + 'sh ' +
path.join(__dirname, '../src/scripts/phalcon.sh') + path.join(__dirname, '../src/scripts/ext/gearman.sh') +
' 3.4.x ' +
version +
' >/dev/null 2>&1';
break;
case '7.2phalcon4':
case '7.3phalcon4':
case '7.4phalcon4':
install_command =
'sh ' +
path.join(__dirname, '../src/scripts/phalcon.sh') +
' master ' +
version +
' >/dev/null 2>&1';
break;
case '7.0gearman':
case '7.1gearman':
case '7.2gearman':
case '7.3gearman':
case '7.4gearman':
install_command =
'sh ' +
path.join(__dirname, '../src/scripts/gearman.sh') +
' ' + ' ' +
version + version +
' >/dev/null 2>&1'; pipe;
break; break;
// match 7.0xdebug..7.4xdebug
case /^7\.[0-4]xdebug$/.test(version_extension):
script +=
'\nupdate_extension xdebug 2.9.0' +
pipe +
'\n' +
(yield utils.addLog('$tick', 'xdebug', 'Enabled', 'linux'));
return;
// match 7.0phalcon3..7.3phalcon3 and 7.2phalcon4...7.4phalcon4
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
script +=
'\nsh ' +
path.join(__dirname, '../src/scripts/ext/phalcon.sh') +
' ' +
extension +
' ' +
version +
pipe +
'\n' +
(yield utils.addLog('$tick', extension, 'Installed and enabled', 'linux'));
return;
default: default:
install_command = install_command =
'sudo DEBIAN_FRONTEND=noninteractive apt-get install -y php' + 'sudo DEBIAN_FRONTEND=noninteractive apt-get install -y php' +
version + version +
'-' + '-' +
extension.replace('pdo_', '').replace('pdo-', '') + extension.replace('pdo_', '').replace('pdo-', '') +
' >/dev/null 2>&1 || sudo pecl install ' + pipe +
' || sudo pecl install ' +
extension + extension +
' >/dev/null 2>&1'; pipe;
break; break;
} }
script += script +=
@ -2330,12 +2724,11 @@ exports.addExtensionLinux = addExtensionLinux;
*/ */
function addExtension(extension_csv, version, os_version, no_step = false) { function addExtension(extension_csv, version, os_version, no_step = false) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
const pipe = yield utils.suppressOutput(os_version);
let script = '\n'; let script = '\n';
switch (no_step) { switch (no_step) {
case true: case true:
script += script += (yield utils.stepLog('Setup Extensions', os_version)) + pipe;
(yield utils.stepLog('Setup Extensions', os_version)) +
(yield utils.suppressOutput(os_version));
break; break;
case false: case false:
default: default:
@ -2344,11 +2737,11 @@ function addExtension(extension_csv, version, os_version, no_step = false) {
} }
switch (os_version) { switch (os_version) {
case 'win32': case 'win32':
return script + (yield addExtensionWindows(extension_csv, version)); return script + (yield addExtensionWindows(extension_csv, version, pipe));
case 'darwin': case 'darwin':
return script + (yield addExtensionDarwin(extension_csv, version)); return script + (yield addExtensionDarwin(extension_csv, version, pipe));
case 'linux': case 'linux':
return script + (yield addExtensionLinux(extension_csv, version)); return script + (yield addExtensionLinux(extension_csv, version, pipe));
default: default:
return yield utils.log('Platform ' + os_version + ' is not supported', os_version, 'error'); return yield utils.log('Platform ' + os_version + ' is not supported', os_version, 'error');
} }

View File

@ -11,7 +11,7 @@ jobs:
php-versions: ['7.1', '7.2', '7.3', '7.4'] php-versions: ['7.1', '7.2', '7.3', '7.4']
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v1 uses: actions/checkout@v2
- name: Setup PHP, with composer and extensions - name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php
with: with:
@ -22,6 +22,8 @@ jobs:
- uses: actions/cache@v1 - uses: actions/cache@v1
with: with:
path: ${{ steps.composer-cache.outputs.dir }} path: ${{ steps.composer-cache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed.
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer- restore-keys: ${{ runner.os }}-composer-
- name: Install Composer dependencies - name: Install Composer dependencies

112
examples/cakephp-mysql.yml Normal file
View File

@ -0,0 +1,112 @@
# GitHub Action for CakePHP with MySQL and Redis
# Tested with https://github.com/cakephp/app
name: Testing CakePHP with MySQL
on: [push, pull_request]
jobs:
tests:
strategy:
matrix:
php-versions: ['7.2', '7.3', '7.4']
runs-on: ubuntu-latest
services:
mysql:
image: mysql:5.7
env:
MYSQL_ALLOW_EMPTY_PASSWORD: false
MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: cakephp
ports:
- 3306/tcp
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
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup PHP
uses: shivammathur/setup-php@v1
with:
php-version: ${{ matrix.php-versions }}
# You can also use ext-apcu or ext-memcached instead of ext-redis
# Install memcached if using ext-memcached
extensions: mbstring, intl, redis, pdo_mysql
coverage: pcov
- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache composer dependencies
uses: actions/cache@v1
with:
path: ${{ steps.composer-cache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed.
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Install dependencies
run: |
composer install --no-progress --no-suggest --prefer-dist --optimize-autoloader
composer run-script post-install-cmd --no-interaction
# Add a step to run migrations if required
- name: Test with phpunit
run: vendor/bin/phpunit --coverage-text
env:
REDIS_PORT: ${{ job.services.redis.ports['6379'] }}
DB_DSN: "mysql://root:password@127.0.0.1:${{ job.services.mysql.ports['3306'] }}/cakephp?init[]=SET sql_mode = \"STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION\""
coding-standard:
name: Coding Standard
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup PHP
uses: shivammathur/setup-php@v1
with:
php-version: '7.3'
extensions: mbstring, intl
- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache composer dependencies
uses: actions/cache@v1
with:
path: ${{ steps.composer-cache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed.
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Install dependencies
run: composer install --no-progress --no-suggest --prefer-dist --optimize-autoloader
- name: PHP CodeSniffer
run: composer cs-check
static-analysis:
name: Static Analysis
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup PHP
uses: shivammathur/setup-php@v1
with:
php-version: '7.3'
extensions: mbstring, intl
tools: phpstan
- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache composer dependencies
uses: actions/cache@v1
with:
path: ${{ steps.composer-cache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed.
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Install dependencies
run: composer install --no-progress --no-suggest --prefer-dist --optimize-autoloader
- name: Static Analysis using PHPStan
run: phpstan analyse --no-progress src/

View File

@ -0,0 +1,112 @@
# GitHub Action for CakePHP with PostgreSQL and Redis
# Tested with https://github.com/cakephp/app
name: Testing CakePHP with PostgreSQL
on: [push, pull_request]
jobs:
tests:
strategy:
matrix:
php-versions: ['7.2', '7.3', '7.4']
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
redis:
image: redis
ports:
- 6379/tcp
options: --health-cmd="redis-cli ping" --health-interval=10s --health-timeout=5s --health-retries=3
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup PHP
uses: shivammathur/setup-php@v1
with:
php-version: ${{ matrix.php-versions }}
# You can also use ext-apcu or ext-memcached instead of ext-redis
# Install memcached if using ext-memcached
extensions: mbstring, intl, redis, pdo_pgsql
coverage: pcov
- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache composer dependencies
uses: actions/cache@v1
with:
path: ${{ steps.composer-cache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed.
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Install dependencies
run: |
composer install --no-progress --no-suggest --prefer-dist --optimize-autoloader
composer run-script post-install-cmd --no-interaction
# Add a step to run migrations if required
- name: Test with phpunit
run: vendor/bin/phpunit --coverage-text
env:
REDIS_PORT: ${{ job.services.redis.ports['6379'] }}
DB_DSN: postgres://postgres@127.0.0.1:${{ job.services.postgres.ports['5432'] }}/postgres
coding-standard:
name: Coding Standard
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup PHP
uses: shivammathur/setup-php@v1
with:
php-version: '7.3'
extensions: mbstring, intl
- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache composer dependencies
uses: actions/cache@v1
with:
path: ${{ steps.composer-cache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed.
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Install dependencies
run: composer install --no-progress --no-suggest --prefer-dist --optimize-autoloader
- name: PHP CodeSniffer
run: composer cs-check
static-analysis:
name: Static Analysis
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup PHP
uses: shivammathur/setup-php@v1
with:
php-version: '7.3'
extensions: mbstring, intl
tools: phpstan
- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache composer dependencies
uses: actions/cache@v1
with:
path: ${{ steps.composer-cache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed.
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Install dependencies
run: composer install --no-progress --no-suggest --prefer-dist --optimize-autoloader
- name: Static Analysis using PHPStan
run: phpstan analyse --no-progress src/

92
examples/cakephp.yml Normal file
View File

@ -0,0 +1,92 @@
# GitHub Action for CakePHP
# Tested with https://github.com/cakephp/app
name: Testing CakePHP
on: [push, pull_request]
jobs:
tests:
strategy:
matrix:
operating-system: [ubuntu-latest, windows-latest, macOS-latest]
php-versions: ['7.2', '7.3', '7.4']
runs-on: ${{ matrix.operating-system }}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup PHP
uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php
with:
php-version: ${{ matrix.php-versions }}
extensions: mbstring, intl, pdo_sqlite, pdo_mysql
coverage: pcov #optional
- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache composer dependencies
uses: actions/cache@v1
with:
path: ${{ steps.composer-cache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed.
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Install dependencies
run: |
composer install --no-progress --no-suggest --prefer-dist --optimize-autoloader
composer run-script post-install-cmd --no-interaction
- name: Test with phpunit
run: vendor/bin/phpunit --coverage-text
coding-standard:
name: Coding Standard
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup PHP
uses: shivammathur/setup-php@v1
with:
php-version: '7.3'
extensions: mbstring, intl
- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache composer dependencies
uses: actions/cache@v1
with:
path: ${{ steps.composer-cache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed.
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Install dependencies
run: composer install --no-progress --no-suggest --prefer-dist --optimize-autoloader
- name: PHP CodeSniffer
run: composer cs-check
static-analysis:
name: Static Analysis
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup PHP
uses: shivammathur/setup-php@v1
with:
php-version: '7.3'
extensions: mbstring, intl
tools: phpstan
- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache composer dependencies
uses: actions/cache@v1
with:
path: ${{ steps.composer-cache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed.
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Install dependencies
run: composer install --no-progress --no-suggest --prefer-dist --optimize-autoloader
- name: Static Analysis using PHPStan
run: phpstan analyse --no-progress src/

View File

@ -10,7 +10,7 @@ jobs:
runs-on: ${{ matrix.operating-system }} runs-on: ${{ matrix.operating-system }}
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v1 uses: actions/checkout@v2
- name: Setup PHP, with composer and extensions - name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php
with: with:
@ -24,6 +24,8 @@ jobs:
uses: actions/cache@v1 uses: actions/cache@v1
with: with:
path: ${{ steps.composer-cache.outputs.dir }} path: ${{ steps.composer-cache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed.
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer- restore-keys: ${{ runner.os }}-composer-
- name: Install dependencies - name: Install dependencies

View File

@ -21,7 +21,7 @@ jobs:
MYSQL_ROOT_PASSWORD: password MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: laravel MYSQL_DATABASE: laravel
ports: ports:
- 3306 - 3306/tcp
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
redis: redis:
image: redis image: redis
@ -34,7 +34,7 @@ jobs:
php-versions: ['7.2', '7.3', '7.4'] php-versions: ['7.2', '7.3', '7.4']
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v1 uses: actions/checkout@v2
- name: Setup PHP, with composer and extensions - name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php
with: with:
@ -48,6 +48,8 @@ jobs:
uses: actions/cache@v1 uses: actions/cache@v1
with: with:
path: ${{ steps.composer-cache.outputs.dir }} path: ${{ steps.composer-cache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed.
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer- restore-keys: ${{ runner.os }}-composer-
- name: Install Composer dependencies - name: Install Composer dependencies
@ -62,7 +64,9 @@ jobs:
run: php artisan migrate -v run: php artisan migrate -v
env: env:
DB_PORT: ${{ job.services.mysql.ports['3306'] }} DB_PORT: ${{ job.services.mysql.ports['3306'] }}
REDIS_PORT: ${{ job.services.redis.ports['6379'] }}
- name: Test with phpunit - name: Test with phpunit
run: vendor/bin/phpunit --coverage-text run: vendor/bin/phpunit --coverage-text
env: env:
DB_PORT: ${{ job.services.mysql.ports['3306'] }} DB_PORT: ${{ job.services.mysql.ports['3306'] }}
REDIS_PORT: ${{ job.services.redis.ports['6379'] }}

View File

@ -36,7 +36,7 @@ jobs:
php-versions: ['7.2', '7.3', '7.4'] php-versions: ['7.2', '7.3', '7.4']
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v1 uses: actions/checkout@v2
- name: Setup PHP, with composer and extensions - name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php
with: with:
@ -50,6 +50,8 @@ jobs:
uses: actions/cache@v1 uses: actions/cache@v1
with: with:
path: ${{ steps.composer-cache.outputs.dir }} path: ${{ steps.composer-cache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed.
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer- restore-keys: ${{ runner.os }}-composer-
- name: Install Composer dependencies - name: Install Composer dependencies
@ -64,7 +66,9 @@ jobs:
run: php artisan migrate -v run: php artisan migrate -v
env: env:
DB_PORT: ${{ job.services.postgres.ports[5432] }} DB_PORT: ${{ job.services.postgres.ports[5432] }}
REDIS_PORT: ${{ job.services.redis.ports['6379'] }}
- name: Test with phpunit - name: Test with phpunit
run: vendor/bin/phpunit --coverage-text run: vendor/bin/phpunit --coverage-text
env: env:
DB_PORT: ${{ job.services.postgres.ports[5432] }} DB_PORT: ${{ job.services.postgres.ports[5432] }}
REDIS_PORT: ${{ job.services.redis.ports['6379'] }}

View File

@ -12,7 +12,7 @@ jobs:
php-versions: ['7.2', '7.3', '7.4'] php-versions: ['7.2', '7.3', '7.4']
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v1 uses: actions/checkout@v2
- name: Setup PHP, with composer and extensions - name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php
with: with:
@ -26,6 +26,8 @@ jobs:
uses: actions/cache@v1 uses: actions/cache@v1
with: with:
path: ${{ steps.composer-cache.outputs.dir }} path: ${{ steps.composer-cache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed.
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer- restore-keys: ${{ runner.os }}-composer-
- name: Install Composer dependencies - name: Install Composer dependencies

View File

@ -21,7 +21,7 @@ jobs:
MYSQL_ROOT_PASSWORD: password MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: lumen MYSQL_DATABASE: lumen
ports: ports:
- 3306 - 3306/tcp
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
redis: redis:
image: redis image: redis
@ -34,7 +34,7 @@ jobs:
php-versions: ['7.2', '7.3', '7.4'] php-versions: ['7.2', '7.3', '7.4']
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v1 uses: actions/checkout@v2
- name: Setup PHP, with composer and extensions - name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php
with: with:
@ -48,6 +48,8 @@ jobs:
uses: actions/cache@v1 uses: actions/cache@v1
with: with:
path: ${{ steps.composer-cache.outputs.dir }} path: ${{ steps.composer-cache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed.
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer- restore-keys: ${{ runner.os }}-composer-
- name: Install Composer dependencies - name: Install Composer dependencies
@ -62,7 +64,9 @@ jobs:
run: php artisan migrate -v run: php artisan migrate -v
env: env:
DB_PORT: ${{ job.services.mysql.ports['3306'] }} DB_PORT: ${{ job.services.mysql.ports['3306'] }}
REDIS_PORT: ${{ job.services.redis.ports['6379'] }}
- name: Test with phpunit - name: Test with phpunit
run: vendor/bin/phpunit --coverage-text run: vendor/bin/phpunit --coverage-text
env: env:
DB_PORT: ${{ job.services.mysql.ports['3306'] }} DB_PORT: ${{ job.services.mysql.ports['3306'] }}
REDIS_PORT: ${{ job.services.redis.ports['6379'] }}

View File

@ -36,7 +36,7 @@ jobs:
php-versions: ['7.2', '7.3', '7.4'] php-versions: ['7.2', '7.3', '7.4']
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v1 uses: actions/checkout@v2
- name: Setup PHP, with composer and extensions - name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php
with: with:
@ -50,6 +50,8 @@ jobs:
uses: actions/cache@v1 uses: actions/cache@v1
with: with:
path: ${{ steps.composer-cache.outputs.dir }} path: ${{ steps.composer-cache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed.
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer- restore-keys: ${{ runner.os }}-composer-
- name: Install Composer dependencies - name: Install Composer dependencies
@ -64,7 +66,9 @@ jobs:
run: php artisan migrate -v run: php artisan migrate -v
env: env:
DB_PORT: ${{ job.services.postgres.ports[5432] }} DB_PORT: ${{ job.services.postgres.ports[5432] }}
REDIS_PORT: ${{ job.services.redis.ports['6379'] }}
- name: Test with phpunit - name: Test with phpunit
run: vendor/bin/phpunit --coverage-text run: vendor/bin/phpunit --coverage-text
env: env:
DB_PORT: ${{ job.services.postgres.ports[5432] }} DB_PORT: ${{ job.services.postgres.ports[5432] }}
REDIS_PORT: ${{ job.services.redis.ports['6379'] }}

View File

@ -12,7 +12,7 @@ jobs:
php-versions: ['7.2', '7.3', '7.4'] php-versions: ['7.2', '7.3', '7.4']
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v1 uses: actions/checkout@v2
- name: Setup PHP, with composer and extensions - name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php
with: with:
@ -26,6 +26,8 @@ jobs:
uses: actions/cache@v1 uses: actions/cache@v1
with: with:
path: ${{ steps.composer-cache.outputs.dir }} path: ${{ steps.composer-cache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed.
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer- restore-keys: ${{ runner.os }}-composer-
- name: Install Composer dependencies - name: Install Composer dependencies

View File

@ -24,15 +24,17 @@ jobs:
MYSQL_ROOT_PASSWORD: password MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: phalcon MYSQL_DATABASE: phalcon
ports: ports:
- 3306 - 3306/tcp
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
php-versions: ['7.2', '7.3', '7.4'] php-versions: ['7.2', '7.3', '7.4']
# For phalcon 3.x, use
# php-versions: ['7.0', '7.1', '7.2', '7.3']
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v1 uses: actions/checkout@v2
- name: Setup PHP, with composer and extensions - name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php
with: with:
@ -46,6 +48,8 @@ jobs:
uses: actions/cache@v1 uses: actions/cache@v1
with: with:
path: ${{ steps.composer-cache.outputs.dir }} path: ${{ steps.composer-cache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed.
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer- restore-keys: ${{ runner.os }}-composer-
- name: Install Composer dependencies - name: Install Composer dependencies

View File

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

View File

@ -12,7 +12,7 @@ jobs:
node-versions: ['8', '10'] node-versions: ['8', '10']
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v1 uses: actions/checkout@v2
- name: Setup Node.js - name: Setup Node.js
uses: actions/setup-node@v1 uses: actions/setup-node@v1
with: with:
@ -39,6 +39,8 @@ jobs:
uses: actions/cache@v1 uses: actions/cache@v1
with: with:
path: ${{ steps.composer-cache.outputs.dir }} path: ${{ steps.composer-cache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed.
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer- restore-keys: ${{ runner.os }}-composer-
- name: Install yarn dependencies - name: Install yarn dependencies

View File

@ -10,7 +10,7 @@ jobs:
runs-on: ${{ matrix.operating-system }} runs-on: ${{ matrix.operating-system }}
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v1 uses: actions/checkout@v2
- name: Setup PHP, with composer and extensions - name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php
with: with:
@ -24,6 +24,8 @@ jobs:
uses: actions/cache@v1 uses: actions/cache@v1
with: with:
path: ${{ steps.composer-cache.outputs.dir }} path: ${{ steps.composer-cache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed.
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer- restore-keys: ${{ runner.os }}-composer-
- name: Install dependencies - name: Install dependencies

View File

@ -13,7 +13,7 @@ jobs:
MYSQL_ROOT_PASSWORD: symfony MYSQL_ROOT_PASSWORD: symfony
MYSQL_DATABASE: symfony MYSQL_DATABASE: symfony
ports: ports:
- 3306 - 3306/tcp
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
strategy: strategy:
fail-fast: false fail-fast: false
@ -21,12 +21,12 @@ jobs:
php-versions: ['7.3', '7.4'] php-versions: ['7.3', '7.4']
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v1 uses: actions/checkout@v2
- name: Setup PHP, with composer and extensions - name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php
with: with:
php-version: ${{ matrix.php-versions }} php-version: ${{ matrix.php-versions }}
extensions: mbstring, xml, ctype, iconv, mysql extensions: mbstring, xml, ctype, iconv, intl, pdo_sqlite, mysql
coverage: xdebug #optional coverage: xdebug #optional
- name: Get composer cache directory - name: Get composer cache directory
id: composer-cache id: composer-cache
@ -35,6 +35,8 @@ jobs:
uses: actions/cache@v1 uses: actions/cache@v1
with: with:
path: ${{ steps.composer-cache.outputs.dir }} path: ${{ steps.composer-cache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed.
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer- restore-keys: ${{ runner.os }}-composer-
- name: Install Composer dependencies - name: Install Composer dependencies
@ -48,6 +50,4 @@ jobs:
env: env:
DATABASE_URL: mysql://root:symfony@127.0.0.1:${{ job.services.mysql.ports['3306'] }}/symfony DATABASE_URL: mysql://root:symfony@127.0.0.1:${{ job.services.mysql.ports['3306'] }}/symfony
- name: Run Tests - name: Run Tests
run: | run: php bin/phpunit --coverage-text
composer require phpunit
php bin/phpunit --coverage-text

View File

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

View File

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

View File

@ -19,7 +19,7 @@ jobs:
MYSQL_ROOT_PASSWORD: yii MYSQL_ROOT_PASSWORD: yii
MYSQL_DATABASE: yii MYSQL_DATABASE: yii
ports: ports:
- 3306 - 3306/tcp
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
strategy: strategy:
fail-fast: false fail-fast: false
@ -27,7 +27,7 @@ jobs:
php-versions: ['7.2', '7.3', '7.4'] php-versions: ['7.2', '7.3', '7.4']
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v1 uses: actions/checkout@v2
- name: Set Node.js 10.x - name: Set Node.js 10.x
uses: actions/setup-node@v1 uses: actions/setup-node@v1
with: with:
@ -45,6 +45,8 @@ jobs:
uses: actions/cache@v1 uses: actions/cache@v1
with: with:
path: ${{ steps.composer-cache.outputs.dir }} path: ${{ steps.composer-cache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed.
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer- restore-keys: ${{ runner.os }}-composer-
- name: Install Composer dependencies - name: Install Composer dependencies

View File

@ -27,7 +27,7 @@ jobs:
php-versions: ['7.2', '7.3', '7.4'] php-versions: ['7.2', '7.3', '7.4']
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v1 uses: actions/checkout@v2
- name: Set Node.js 10.x - name: Set Node.js 10.x
uses: actions/setup-node@v1 uses: actions/setup-node@v1
with: with:
@ -45,6 +45,8 @@ jobs:
uses: actions/cache@v1 uses: actions/cache@v1
with: with:
path: ${{ steps.composer-cache.outputs.dir }} path: ${{ steps.composer-cache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed.
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer- restore-keys: ${{ runner.os }}-composer-
- name: Install Composer dependencies - name: Install Composer dependencies

View File

@ -10,7 +10,7 @@ jobs:
runs-on: ${{ matrix.operating-system }} runs-on: ${{ matrix.operating-system }}
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v1 uses: actions/checkout@v2
- name: Setup PHP, with composer and extensions - name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php
with: with:
@ -24,6 +24,8 @@ jobs:
uses: actions/cache@v1 uses: actions/cache@v1
with: with:
path: ${{ steps.composer-cache.outputs.dir }} path: ${{ steps.composer-cache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed.
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer- restore-keys: ${{ runner.os }}-composer-
- name: Install dependencies - name: Install dependencies

1375
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
{ {
"name": "setup-php", "name": "setup-php",
"version": "1.6.2", "version": "1.7.3",
"private": false, "private": false,
"description": "Setup PHP for use with GitHub Actions", "description": "Setup PHP for use with GitHub Actions",
"main": "dist/index.js", "main": "dist/index.js",
@ -34,7 +34,7 @@
"@types/node": "^12.12.16", "@types/node": "^12.12.16",
"@typescript-eslint/eslint-plugin": "^2.11.0", "@typescript-eslint/eslint-plugin": "^2.11.0",
"@typescript-eslint/parser": "^2.11.0", "@typescript-eslint/parser": "^2.11.0",
"@zeit/ncc": "^0.20.5", "@zeit/ncc": "^0.21.0",
"eslint": "^6.6.0", "eslint": "^6.6.0",
"eslint-config-prettier": "^6.5.0", "eslint-config-prettier": "^6.5.0",
"eslint-plugin-import": "^2.19.1", "eslint-plugin-import": "^2.19.1",

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -0,0 +1,22 @@
ini_file=$(php --ini | grep "Loaded Configuration" | sed -e "s|.*:s*||" | sed "s/ //g")
find /etc/apt/sources.list.d -type f -name 'ondrej-ubuntu-php*.list' -exec sudo DEBIAN_FRONTEND=noninteractive apt-fast update -o Dir::Etc::sourcelist="{}" ';' >/dev/null 2>&1
curl -s https://packagecloud.io/install/repositories/phalcon/stable/script.deb.sh | sudo bash
sudo DEBIAN_FRONTEND=noninteractive apt-fast install -y php"$2"-psr
if [ ! "$(apt-cache search php"$2"-psr)" ]; then
sudo DEBIAN_FRONTEND=noninteractive apt-fast install -y php"$2"-dev
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
cd ~ && git clone --depth=1 https://github.com/jbboehr/php-psr.git
cd php-psr && sudo /usr/bin/phpize"$2"
./configure --with-php-config=/usr/bin/php-config"$2"
make -j2 && sudo make -j2 install
echo "extension=psr.so" >> "$ini_file"
fi
extension_major_version=$(echo "$1" | grep -i -Po '\d')
extension_version=$(apt-cache policy -- *phalcon | grep -i -Po "$extension_major_version\.\d\.\d.*php$2" | head -n 1)
sudo DEBIAN_FRONTEND=noninteractive apt-fast -o Dpkg::Options::="--force-overwrite" install -y php"$2"-phalcon="$extension_version"

View File

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

View File

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

View File

@ -1,24 +0,0 @@
ini_file=$(php --ini | grep "Loaded Configuration" | sed -e "s|.*:s*||" | sed "s/ //g")
ini_dir=$(php --ini | grep in: | sed -e "s|.*:s*||" | sed "s/ //g")
if [ ! "$(apt-cache search php"$2"-psr)" ]; then
sudo DEBIAN_FRONTEND=noninteractive add-apt-repository ppa:ondrej/php -y >/dev/null 2>&1
fi
sudo DEBIAN_FRONTEND=noninteractive apt-fast install -y php"$2"-dev
sudo DEBIAN_FRONTEND=noninteractive apt-fast install -y php"$2"-psr
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
if [ ! "$(apt-cache search php"$2"-psr)" ]; then
cd ~ && git clone --depth=1 https://github.com/jbboehr/php-psr.git
cd php-psr && sudo /usr/bin/phpize"$2"
./configure --with-php-config=/usr/bin/php-config"$2"
make -j2 && sudo make -j2 install
echo "extension=psr.so" >> "$ini_file"
fi
cd ~ && 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" | sudo tee "$ini_dir/50-phalcon.ini"

View File

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

422
src/tools.ts Normal file
View File

@ -0,0 +1,422 @@
import * as utils from './utils';
/**
* Function to get command to setup tool
*
* @param os_version
*/
export async function getArchiveCommand(os_version: string): Promise<string> {
switch (os_version) {
case 'linux':
case 'darwin':
return 'add_tool ';
case 'win32':
return 'Add-Tool ';
default:
return await utils.log(
'Platform ' + os_version + ' is not supported',
os_version,
'error'
);
}
}
/**
* Function to get command to setup tools using composer
*
* @param os_version
*/
export async function getPackageCommand(os_version: string): Promise<string> {
switch (os_version) {
case 'linux':
case 'darwin':
return 'add_composer_tool ';
case 'win32':
return 'Add-Composer-Tool ';
default:
return await utils.log(
'Platform ' + os_version + ' is not supported',
os_version,
'error'
);
}
}
/**
*
* Function to get command to setup PECL
*
* @param os_version
*/
export async function getPECLCommand(os_version: string): Promise<string> {
switch (os_version) {
case 'linux':
case 'darwin':
return 'add_pecl ';
case 'win32':
return 'Add-PECL ';
default:
return await utils.log(
'Platform ' + os_version + ' is not supported',
os_version,
'error'
);
}
}
/**
* Function to get tool version
*
* @param version
*/
export async function getToolVersion(version: string): Promise<string> {
// semver_regex - https://semver.org/
const semver_regex = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/;
version = version.replace(/[><=^]*/, '');
switch (true) {
case semver_regex.test(version):
return version;
default:
return 'latest';
}
}
/**
* Function to parse tool:version
*
* @param release
*/
export async function parseTool(
release: string
): Promise<{name: string; version: string}> {
const parts: string[] = release.split(':');
const tool: string = parts[0];
const version: string | undefined = parts[1];
switch (version) {
case undefined:
return {
name: tool,
version: 'latest'
};
default:
return {
name: tool,
version: await getToolVersion(parts[1])
};
}
}
/**
* Function to get the url of tool with the given version
*
* @param version
* @param prefix
* @param version_prefix
* @param verb
*/
export async function getUri(
tool: string,
version: string,
prefix: string,
version_prefix: string,
verb: string
): Promise<string> {
switch (version) {
case 'latest':
return [prefix, version, verb, tool + '.phar'].filter(Boolean).join('/');
default:
return [prefix, verb, version_prefix + version, tool + '.phar']
.filter(Boolean)
.join('/');
}
}
/**
* Helper function to get the codeception url
*
* @param version
* @param php_version
* @param suffix
*/
export async function getCodeceptionUriBuilder(
version: string,
php_version: string,
suffix: string
): Promise<string> {
switch (true) {
case /^5\.6$|^7\.[0|1]$/.test(php_version):
return ['releases', version, suffix, 'codecept.phar']
.filter(Boolean)
.join('/');
case /^7\.[2-4]$/.test(php_version):
default:
return ['releases', version, 'codecept.phar'].filter(Boolean).join('/');
}
}
/**
* Function to get the codeception url
*
* @param version
* @param php_version
*/
export async function getCodeceptionUri(
version: string,
php_version: string
): Promise<string> {
switch (true) {
case /latest/.test(version):
switch (true) {
case /^5\.6$|^7\.[0|1]$/.test(php_version):
return 'php56/codecept.phar';
case /^7\.[2-4]$/.test(php_version):
default:
return 'codecept.phar';
}
case /([4-9]|\d{2,})\..*/.test(version):
return await getCodeceptionUriBuilder(version, php_version, 'php56');
default:
return await getCodeceptionUriBuilder(version, php_version, 'php54');
}
}
/**
* Function to get the PHPUnit url
*
* @param version
*/
export async function getPhpunitUrl(
tool: string,
version: string
): Promise<string> {
const phpunit = 'https://phar.phpunit.de';
switch (version) {
case 'latest':
return phpunit + '/' + tool + '.phar';
default:
return phpunit + '/' + tool + '-' + version + '.phar';
}
}
/**
* Function to get the Deployer url
*
* @param version
*/
export async function getDeployerUrl(version: string): Promise<string> {
const deployer = 'https://deployer.org';
switch (version) {
case 'latest':
return deployer + '/deployer.phar';
default:
return deployer + '/releases/v' + version + '/deployer.phar';
}
}
/**
* Function to add/move composer in the tools list
*
* @param tools
*/
export async function addComposer(tools_list: string[]): Promise<string[]> {
const regex = /^composer($|:.*)/;
const composer: string = tools_list.filter(tool => regex.test(tool))[0];
switch (composer) {
case undefined:
break;
default:
tools_list = tools_list.filter(tool => !regex.test(tool));
break;
}
tools_list.unshift('composer');
return tools_list;
}
/**
* Function to get Tools list after cleanup
*
* @param tools_csv
*/
export async function getCleanedToolsList(
tools_csv: string
): Promise<string[]> {
let tools_list: string[] = await utils.CSVArray(tools_csv);
tools_list = await addComposer(tools_list);
tools_list = tools_list
.map(function(extension: string) {
return extension
.trim()
.replace(/robmorgan\/|hirak\/|narrowspark\/automatic-/, '');
})
.filter(Boolean);
return [...new Set(tools_list)];
}
/**
* Helper function to get script to setup a tool using a phar url
*
* @param tool
* @param version
* @param url
* @param os_version
*/
export async function addArchive(
tool: string,
version: string,
url: string,
os_version: string
): Promise<string> {
return (await getArchiveCommand(os_version)) + url + ' ' + tool;
}
/**
* Function to get the script to setup php-config and phpize
*
* @param tool
* @param os_version
*/
export async function addDevTools(
tool: string,
os_version: string
): Promise<string> {
switch (os_version) {
case 'linux':
return (
'add_devtools' +
'\n' +
(await utils.addLog('$tick', tool, 'Added', 'linux'))
);
case 'darwin':
return await utils.addLog('$tick', tool, 'Added', 'darwin');
case 'win32':
return await utils.addLog(
'$cross',
tool,
tool + ' is not a windows tool',
'win32'
);
default:
return await utils.log(
'Platform ' + os_version + ' is not supported',
os_version,
'error'
);
}
}
/**
* Helper function to get script to setup a tool using composer
*
* @param tool
* @param release
* @param prefix
* @param os_version
*/
export async function addPackage(
tool: string,
release: string,
prefix: string,
os_version: string
): Promise<string> {
const tool_command = await getPackageCommand(os_version);
return tool_command + tool + ' ' + release + ' ' + prefix;
}
/**
* Setup tools
*
* @param tool_csv
* @param os_version
*/
export async function addTools(
tools_csv: string,
php_version: string,
os_version: string
): Promise<string> {
let script = '\n' + (await utils.stepLog('Setup Tools', os_version));
const tools_list: Array<string> = await getCleanedToolsList(tools_csv);
await utils.asyncForEach(tools_list, async function(release: string) {
const tool_data: {name: string; version: string} = await parseTool(release);
const tool: string = tool_data.name;
const version: string = tool_data.version;
const github = 'https://github.com/';
let uri: string = await getUri(tool, version, 'releases', '', 'download');
script += '\n';
let url = '';
switch (tool) {
case 'php-cs-fixer':
uri = await getUri(tool, version, 'releases', 'v', 'download');
url = github + 'FriendsOfPHP/PHP-CS-Fixer/' + uri;
script += await addArchive(tool, version, url, os_version);
break;
case 'phpcs':
case 'phpcbf':
url = github + 'squizlabs/PHP_CodeSniffer/' + uri;
script += await addArchive(tool, version, url, os_version);
break;
case 'phpstan':
url = github + 'phpstan/phpstan/' + uri;
script += await addArchive(tool, version, url, os_version);
break;
case 'phpmd':
url = github + 'phpmd/phpmd/' + uri;
script += await addArchive(tool, version, url, os_version);
break;
case 'psalm':
url = github + 'vimeo/psalm/' + uri;
script += await addArchive(tool, version, url, os_version);
break;
case 'composer':
url =
github + 'composer/composer/releases/latest/download/composer.phar';
script += await addArchive(tool, version, url, os_version);
break;
case 'codeception':
url =
'https://codeception.com/' +
(await getCodeceptionUri(version, php_version));
script += await addArchive(tool, version, url, os_version);
break;
case 'phpcpd':
case 'phpunit':
url = await getPhpunitUrl(tool, version);
script += await addArchive(tool, version, url, os_version);
break;
case 'deployer':
url = await getDeployerUrl(version);
script += await addArchive(tool, version, url, os_version);
break;
case 'phinx':
script += await addPackage(tool, release, 'robmorgan/', os_version);
break;
case 'prestissimo':
script += await addPackage(tool, release, 'hirak/', os_version);
break;
case 'composer-prefetcher':
script += await addPackage(
tool,
release,
'narrowspark/automatic-',
os_version
);
break;
case 'pecl':
script += await getPECLCommand(os_version);
break;
case 'php-config':
case 'phpize':
script += await addDevTools(tool, os_version);
break;
default:
script += await utils.addLog(
'$cross',
tool,
'Tool ' + tool + ' is not supported',
os_version
);
break;
}
});
return script;
}

View File

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