diff --git a/.github/workflows/experimental-workflow.yml b/.github/workflows/experimental-workflow.yml index e1816394..62c5cc5f 100644 --- a/.github/workflows/experimental-workflow.yml +++ b/.github/workflows/experimental-workflow.yml @@ -27,6 +27,9 @@ jobs: matrix: operating-system: [ubuntu-latest, windows-latest, macos-latest] php-versions: ['8.0'] + env: + extensions: xml, opcache, xdebug, pcov + key: cache-v1 steps: - name: Checkout uses: actions/checkout@v2 @@ -53,12 +56,27 @@ jobs: timeout-minutes: 1 run: curl -s https://codecov.io/bash | bash -s -- -t ${{secrets.CODECOV_TOKEN}} -f coverage/clover.xml -n github-actions-codecov-${{ matrix.operating-system }}-php${{ matrix.php-versions }} + - name: Setup cache environment + id: cache-env + uses: shivammathur/cache-extensions@v1 + with: + php-version: ${{ matrix.php-versions }} + extensions: ${{ env.extensions }} + key: ${{ env.key }} + + - name: Cache extensions + uses: actions/cache@v1 + with: + path: ${{ steps.cache-env.outputs.dir }} + key: ${{ steps.cache-env.outputs.key }} + restore-keys: ${{ steps.cache-env.outputs.key }} + - name: Setup PHP with extensions and custom config run: node dist/index.js env: php-version: ${{ matrix.php-versions }} - extensions: xml, opcache, xdebug, pcov #optional - ini-values: post_max_size=256M, short_open_tag=On, date.timezone=Asia/Kolkata #optional + extensions: ${{ env.extensions }} + ini-values: post_max_size=256M, short_open_tag=On, date.timezone=Asia/Kolkata coverage: pcov - name: Testing PHP version diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 35927cc6..b9a5ee79 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -24,7 +24,10 @@ jobs: fail-fast: false matrix: operating-system: [ubuntu-latest, windows-latest, macos-latest] - php-versions: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4'] + php-versions: ['5.3', '5.4', '5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4'] + env: + extensions: xml, opcache, xdebug, pcov + key: cache-v1 steps: - name: Checkout uses: actions/checkout@v2 @@ -51,12 +54,27 @@ jobs: timeout-minutes: 1 run: curl -s https://codecov.io/bash | bash -s -- -t ${{secrets.CODECOV_TOKEN}} -f coverage/clover.xml -n github-actions-codecov-${{ matrix.operating-system }}-php${{ matrix.php-versions }} + - name: Setup cache environment + id: cache-env + uses: shivammathur/cache-extensions@v1 + with: + php-version: ${{ matrix.php-versions }} + extensions: ${{ env.extensions }} + key: ${{ env.key }} + + - name: Cache extensions + uses: actions/cache@v1 + with: + path: ${{ steps.cache-env.outputs.dir }} + key: ${{ steps.cache-env.outputs.key }} + restore-keys: ${{ steps.cache-env.outputs.key }} + - name: Setup PHP with extensions and custom config run: node dist/index.js env: php-version: ${{ matrix.php-versions }} - extensions: xml, opcache, xdebug, pcov #optional - ini-values: post_max_size=256M, short_open_tag=On, date.timezone=Asia/Kolkata #optional + extensions: ${{ env.extensions }} + ini-values: post_max_size=256M, short_open_tag=On, date.timezone=Asia/Kolkata - name: Testing PHP version run: | diff --git a/README.md b/README.md index f5598e4d..aad4b8ff 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ GitHub Actions status Codecov Code Coverage LICENSE - PHP Versions Supported + PHP Versions Supported

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. @@ -24,25 +24,32 @@ Setup PHP with required extensions, php.ini configuration, code-coverage support - [Coverage support](#signal_strength-coverage-support) - [Xdebug](#xdebug) - [PCOV](#pcov) - - [Disable coverage](#disable-coverage) + - [Disable Coverage](#disable-coverage) - [Usage](#memo-usage) + - [Inputs](#inputs) - [Basic Setup](#basic-setup) - [Matrix Setup](#matrix-setup) - - [Experimental Setup](#experimental-setup) - - [Thread Safe Setup](#thread-safe-setup) - - [Cache dependencies](#cache-dependencies) + - [Experimental Setup](#experimental-setup) + - [Thread Safe Setup](#thread-safe-setup) + - [Force Update](#force-update) + - [Verbose Setup](#verbose-setup) + - [Cache Extensions](#cache-extensions) + - [Cache Composer Dependencies](#cache-composer-dependencies) - [Problem Matchers](#problem-matchers) - [Examples](#examples) - [License](#scroll-license) - [Contributions](#1-contributions) -- [Support this project](#sparkling_heart-support-this-project) -- [This action uses the following works](#bookmark-this-action-uses-the-following-works) +- [Support This Project](#sparkling_heart-support-this-project) +- [Dependencies](#bookmark-dependencies) - [Further Reading](#bookmark_tabs-further-reading) ## :tada: PHP Support |PHP Version|Stability|Release Support| |--- |--- |--- | +|5.3|`Stable`|`End of life`| +|5.4|`Stable`|`End of life`| +|5.5|`Stable`|`End of life`| |5.6|`Stable`|`End of life`| |7.0|`Stable`|`End of life`| |7.1|`Stable`|`End of life`| @@ -64,10 +71,41 @@ Setup PHP with required extensions, php.ini configuration, code-coverage 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` in the tools input. + +```yaml +uses: shivammathur/setup-php@v2 +with: + php-version: '7.4' + tools: pecl + extensions: swoole +``` + - On `windows` extensions which have `windows` binary 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 on `PECL` which do not have a latest stable version, their pre-release versions can be installed by suffixing the extension with its state i.e `alpha`, `beta`, `devel` or `snapshot` separated by a `-` like `msgpack-beta`. + +- Specific versions of PECL extensions can be installed by suffixing the extension with the version. This is useful for installing old versions of extensions which support end of life PHP versions. + +```yaml +uses: shivammathur/setup-php@v2 +with: + php-version: '7.4' + tools: pecl + extensions: pcov-1.0.6 +``` + +- Pre-release versions of PECL extensions can be installed by suffixing the extension with its state i.e `alpha`, `beta`, `devel` or `snapshot`. + +```yaml +uses: shivammathur/setup-php@v2 +with: + php-version: '7.4' + tools: pecl + extensions: xdebug-beta +``` + - Extensions which cannot be installed gracefully leave an error message in the logs, the action is not interrupted. ## :wrench: Tools Support @@ -77,7 +115,7 @@ These tools can be setup globally using the `tools` input. `codeception`, `composer`, `composer-prefetcher`, `cs2pr`, `deployer`, `pecl`, `phinx`, `phive`, `phpcbf`, `phpcpd`, `php-config`, `php-cs-fixer`, `phpcs`, `phpize`, `phpmd`, `phpstan`, `phpunit`, `prestissimo`, `psalm`, `symfony` ```yaml -uses: shivammathur/setup-php@v1 +uses: shivammathur/setup-php@v2 with: php-version: '7.4' tools: php-cs-fixer, phpunit @@ -87,7 +125,7 @@ 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 +uses: shivammathur/setup-php@v2 with: php-version: '7.4' tools: php-cs-fixer:2.15.5, phpunit:8.5.1 @@ -95,7 +133,7 @@ with: **Note** - `composer` is setup by default. -- Specifying version for `composer` and `pecl` has no effect, latest version of both tools will be setup. +- Specifying version for `composer` and `pecl` has no effect, latest versions of both tools which are compatible with the PHP version 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. @@ -107,7 +145,7 @@ Specify `coverage: xdebug` to use `Xdebug`. Runs on all [PHP versions supported](#tada-php-support "List of PHP versions supported on this GitHub Action") except `8.0`. ```yaml -uses: shivammathur/setup-php@v1 +uses: shivammathur/setup-php@v2 with: php-version: '7.4' coverage: xdebug @@ -120,18 +158,17 @@ It is much faster than `Xdebug`. `PCOV` needs `PHP >= 7.1`. If your source code directory is other than `src`, `lib` or, `app`, specify `pcov.directory` using the `ini-values` input. - ```yaml -uses: shivammathur/setup-php@v1 +uses: shivammathur/setup-php@v2 with: php-version: '7.4' ini-values: pcov.directory=api #optional, see above for usage. coverage: pcov ``` -### Disable coverage +### Disable Coverage -Specify `coverage: none` to disable both `Xdebug` and `PCOV`. +Specify `coverage: none` to remove both `Xdebug` and `PCOV`. Consider disabling the coverage using this PHP action for these reasons. - You are not generating coverage reports while testing. @@ -139,7 +176,7 @@ Consider disabling the coverage using this PHP action for these reasons. - You are using `phpdbg` for running your tests. ```yaml -uses: shivammathur/setup-php@v1 +uses: shivammathur/setup-php@v2 with: php-version: '7.4' coverage: none @@ -147,15 +184,38 @@ with: ## :memo: Usage -Inputs supported by this GitHub Action. +### Inputs -- php-version `required` -- extensions `optional` -- ini-values `optional` -- coverage `optional` -- tools `optional` +#### `php-version` (required) -See [action.yml](action.yml "Metadata for this GitHub Action") and usage below for more info. +- Specify the PHP version you want to setup. +- Accepts a `string`. For example `'7.4'`. +- See [PHP support](#tada-php-support) for supported PHP versions. + +#### `extensions` (optional) + +- Specify the extensions you want to setup. +- Accepts a `string` in csv-format. For example `mbstring, zip`. +- See [PHP extension support](#heavy_plus_sign-php-extension-support) for more info. + +#### `ini-values` (optional) + +- Specify the values you want to add to `php.ini`. +- Accepts a `string` in csv-format. For example `post_max_size=256M, short_open_tag=On`. + +#### `coverage` (optional) + +- Specify the code coverage driver you want to setup. +- Accepts `xdebug`, `pcov` or `none`. +- See [coverage support](#signal_strength-coverage-support) for more info. + +#### `tools` (optional) + +- Specify the tools you want to setup. +- Accepts a `string` in csv-format. For example `phpunit, phpcs` +- See [tools Support](#wrench-tools-support) for tools supported. + +See below for more info. ### Basic Setup @@ -167,13 +227,13 @@ steps: uses: actions/checkout@v2 - name: Setup PHP - uses: shivammathur/setup-php@v1 + uses: shivammathur/setup-php@v2 with: php-version: '7.4' - extensions: mbstring, intl #optional, setup extensions - ini-values: post_max_size=256M, short_open_tag=On #optional, setup php.ini configuration - coverage: xdebug #optional, setup coverage driver - tools: php-cs-fixer, phpunit #optional, setup tools globally + extensions: mbstring, intl + ini-values: post_max_size=256M, short_open_tag=On + coverage: xdebug + tools: php-cs-fixer, phpunit ``` ### Matrix Setup @@ -194,13 +254,13 @@ jobs: uses: actions/checkout@v2 - name: Setup PHP - uses: shivammathur/setup-php@v1 + uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php-versions }} - extensions: mbstring, intl #optional, setup extensions - ini-values: post_max_size=256M, short_open_tag=On #optional, setup php.ini configuration - coverage: xdebug #optional, setup coverage driver - tools: php-cs-fixer, phpunit #optional, setup tools globally + extensions: mbstring, intl + ini-values: post_max_size=256M, short_open_tag=On + coverage: xdebug + tools: php-cs-fixer, phpunit ``` ### Experimental Setup @@ -219,13 +279,13 @@ steps: uses: actions/checkout@v2 - name: Setup PHP - uses: shivammathur/setup-php@v1 + uses: shivammathur/setup-php@v2 with: php-version: '8.0' - extensions: mbstring #optional, setup extensions - 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. - tools: php-cs-fixer, phpunit #optional, setup tools globally + extensions: mbstring + ini-values: opcache.jit_buffer_size=256M, opcache.jit=1235, pcre.jit=1 + coverage: pcov + tools: php-cs-fixer, phpunit ``` ### Thread Safe Setup @@ -244,14 +304,79 @@ jobs: uses: actions/checkout@v2 - name: Setup PHP - uses: shivammathur/setup-php@v1 + uses: shivammathur/setup-php@v2 with: php-version: '7.4' env: PHPTS: ts # specify ts or nts ``` -### Cache dependencies +### Force Update + +- PHP versions which are pre-installed on the GitHub Actions runner are not updated to their latest patch release by default. +- You can specify the `update` environment variable to `true` to force update to the latest release. + +```yaml +- name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '7.4' + env: + update: true # specify true or false +``` + +### Verbose Setup + +- To debug any issues, you can use the `verbose` tag instead of `v2`. + +```yaml +- name: Setup PHP + uses: shivammathur/setup-php@verbose + with: + php-version: '7.4' +``` + +### Cache Extensions + +You can persist PHP extensions you setup using the [`shivammathur/cache-extensions`](https://github.com/shivammathur/cache-extensions "GitHub Action to cache php extensions") and [`action/cache`](https://github.com/actions/cache "GitHub Action to cache files") GitHub Actions. Extensions which take very long to setup if cached are available in the next workflow run and enabled directly which reduces the workflow execution time. + +```yaml +runs-on: ${{ matrix.operating-system }} +strategy: + matrix: + operating-system: [ubuntu-latest, windows-latest, macos-latest] + php-versions: ['7.2', '7.3', '7.4'] +name: PHP ${{ matrix.php-versions }} Test on ${{ matrix.operating-system }} +env: + extensions: intl, pcov + key: cache-v1 # can be any string, change to clear the extension cache. +steps: +- name: Checkout + uses: actions/checkout@v2 + +- name: Setup cache environment + id: cache-env + uses: shivammathur/cache-extensions@v1 + with: + php-version: ${{ matrix.php-versions }} + extensions: ${{ env.extensions }} + key: ${{ env.key }} + +- name: Cache extensions + uses: actions/cache@v1 + with: + path: ${{ steps.cache-env.outputs.dir }} + key: ${{ steps.cache-env.outputs.key }} + restore-keys: ${{ steps.cache-env.outputs.key }} + +- name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-versions }} + extensions: ${{ env.extensions }} +``` + +### Cache Composer Dependencies You can persist composer's internal cache directory using the [`action/cache`](https://github.com/actions/cache "GitHub Action to cache files") GitHub Action. Dependencies cached are loaded directly instead of downloading them while installation. The files cached are available across check-runs and will reduce the workflow execution time. @@ -281,16 +406,25 @@ key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} ### Problem Matchers +#### PHP + +Setup problem matchers for your `PHP` output by adding this step after the `setup-php` step. This will scan the logs for PHP errors and warnings, and surface them prominently in the GitHub Actions UI by creating annotations and log file decorations. + +```yaml +- name: Setup Problem Matchers for PHP + run: echo "::add-matcher::${{ runner.tool_cache }}/php.json" +``` + #### PHPUnit -You can setup problem matchers for your `PHPUnit` output by adding this step after the `setup-php` step. This will scan the logs for failing tests and surface that information prominently in the GitHub Actions UI by creating annotations and log file decorations. +Setup problem matchers for your `PHPUnit` output by adding this step after the `setup-php` step. This will scan the logs for failing tests and surface that information prominently in the GitHub Actions UI by creating annotations and log file decorations. ```yaml - name: Setup Problem Matchers for PHPUnit run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" ``` -#### Other tools +#### Other Tools For tools that support `checkstyle` reporting like `phpstan`, `psalm`, `php-cs-fixer` and `phpcs` you can use `cs2pr` to annotate your code. For examples refer to [cs2pr documentation](https://github.com/staabm/annotate-pull-request-from-checkstyle). @@ -299,7 +433,7 @@ For examples refer to [cs2pr documentation](https://github.com/staabm/annotate-p ```yaml - name: Setup PHP - uses: shivammathur/setup-php@v1 + uses: shivammathur/setup-php@v2 with: php-version: '7.4' tools: cs2pr, phpstan @@ -338,13 +472,13 @@ Examples for setting up this GitHub Action with different PHP Frameworks/Package ## :scroll: License -The scripts and documentation in this project are released under the [MIT License](LICENSE "License for shivammathur/setup-php"). This project has multiple [dependencies](https://github.com/shivammathur/setup-php/network/dependencies "Dependencies for this PHP Action") and uses [various works](#bookmark-this-action-uses-the-following-works "Tools used by this action"). Their licenses can be found in their respective repositories. +The scripts and documentation in this project are released under the [MIT License](LICENSE "License for shivammathur/setup-php"). This project has multiple [dependencies](#dependencies "Dependencies for this PHP Action"). Their licenses can be found in their respective repositories. ## :+1: Contributions Contributions are welcome! See [Contributor's Guide](.github/CONTRIBUTING.md "shivammathur/setup-php contribution guide"). If you face any issues while using this or want to suggest a feature/improvement, create an issue [here](https://github.com/shivammathur/setup-php/issues "Issues reported"). -## :sparkling_heart: Support this project +## :sparkling_heart: Support This Project If this action helped you. @@ -353,12 +487,16 @@ If this action helped you. - I maintain this in my free time, please support me with a [Patreon](https://www.patreon.com/shivammathur "Shivam Mathur Patreon") subscription or a one time contribution using [Paypal](https://www.paypal.me/shivammathur "Shivam Mathur PayPal"). - If you need any help using this, please contact me using [Codementor](https://www.codementor.io/shivammathur "Shivam Mathur Codementor") -## :bookmark: This action uses the following works +## :bookmark: Dependencies -- [ppa:ondrej/php](https://launchpad.net/~ondrej/+archive/ubuntu/php "Pre-compiled ubuntu packages") -- [shivammathur/php-builder](https://github.com/shivammathur/php-builder "Pre-compiled nightly PHP builds") +- [Node.js dependencies](https://github.com/shivammathur/setup-php/network/dependencies "Node.js dependencies") +- [gplessis/dotdeb-php](https://github.com/gplessis/dotdeb-php "Packaging for end of life PHP versions") - [mlocati/powershell-phpmanager](https://github.com/mlocati/powershell-phpmanager "Package to handle PHP on windows") +- [ppa:ondrej/php](https://launchpad.net/~ondrej/+archive/ubuntu/php "Packaging active PHP packages") +- [shivammathur/cache-extensions](https://github.com/shivammathur/cache-extensions "GitHub action to help with caching PHP extensions") - [shivammathur/homebrew-php](https://github.com/shivammathur/homebrew-php "Tap for PHP builds for MacOS") +- [shivammathur/php-builder](https://github.com/shivammathur/php-builder "Nightly PHP package") +- [shivammathur/php5-ubuntu](https://github.com/shivammathur/php5-ubuntu "Scripts to setup PHP5 versions") ## :bookmark_tabs: Further Reading diff --git a/__tests__/extensions.test.ts b/__tests__/extensions.test.ts index e83efbf7..3ef06a23 100644 --- a/__tests__/extensions.test.ts +++ b/__tests__/extensions.test.ts @@ -3,7 +3,7 @@ import * as extensions from '../src/extensions'; describe('Extension tests', () => { it('checking addExtensionOnWindows', async () => { let win32: string = await extensions.addExtension( - 'xdebug, pcov, phalcon4, ast-beta', + 'xdebug, pcov, phalcon4, ast-beta, grpc-1.2.3, inotify-1.2.3alpha2', '7.4', 'win32' ); @@ -11,6 +11,8 @@ describe('Extension tests', () => { expect(win32).toContain('Add-Extension pcov'); expect(win32).toContain('phalcon.ps1 phalcon4'); expect(win32).toContain('Add-Extension ast beta'); + expect(win32).toContain('Add-Extension grpc stable 1.2.3'); + expect(win32).toContain('Add-Extension inotify alpha 1.2.3'); win32 = await extensions.addExtension( 'phalcon3, does_not_exist', @@ -27,15 +29,16 @@ describe('Extension tests', () => { it('checking addExtensionOnLinux', async () => { let linux: string = await extensions.addExtension( - 'xdebug, pcov, ast-beta, xdebug-alpha', + 'xdebug, pcov, ast-beta, xdebug-alpha, grpc-1.2.3', '7.4', 'linux' ); - expect(linux).toContain('update_extension xdebug 2.9.0'); + expect(linux).toContain('update_extension xdebug 2.9.1'); expect(linux).toContain( 'sudo DEBIAN_FRONTEND=noninteractive apt-get install -y php7.4-pcov' ); expect(linux).toContain('add_unstable_extension ast beta extension'); + expect(linux).toContain('add_pecl_extension grpc 1.2.3'); expect(linux).toContain( 'add_unstable_extension xdebug alpha zend_extension' ); @@ -64,13 +67,14 @@ describe('Extension tests', () => { it('checking addExtensionOnDarwin', async () => { let darwin: string = await extensions.addExtension( - 'xdebug, pcov, ast-beta', + 'xdebug, pcov, ast-beta, grpc-1.2.3', '7.2', 'darwin' ); expect(darwin).toContain('sudo pecl install -f xdebug'); expect(darwin).toContain('sudo pecl install -f pcov'); expect(darwin).toContain('add_unstable_extension ast beta extension'); + expect(darwin).toContain('sudo pecl install -f grpc-1.2.3'); darwin = await extensions.addExtension('phalcon3', '7.0', 'darwin'); expect(darwin).toContain('phalcon_darwin.sh phalcon3 7.0'); @@ -84,6 +88,15 @@ describe('Extension tests', () => { darwin = await extensions.addExtension('pcov', '7.2', 'darwin'); expect(darwin).toContain('sudo pecl install -f pcov'); + darwin = await extensions.addExtension('xdebug', '5.3', 'darwin'); + expect(darwin).toContain('sudo pecl install -f xdebug-2.2.7'); + + darwin = await extensions.addExtension('xdebug', '5.4', 'darwin'); + expect(darwin).toContain('sudo pecl install -f xdebug-2.4.1'); + + darwin = await extensions.addExtension('xdebug', '5.5', 'darwin'); + expect(darwin).toContain('sudo pecl install -f xdebug-2.5.5'); + darwin = await extensions.addExtension('xdebug', '5.6', 'darwin'); expect(darwin).toContain('sudo pecl install -f xdebug-2.5.5'); diff --git a/__tests__/install.test.ts b/__tests__/install.test.ts index 45119282..f48dcd2b 100644 --- a/__tests__/install.test.ts +++ b/__tests__/install.test.ts @@ -46,7 +46,7 @@ jest.mock('../src/install', () => ({ case 'darwin': case 'linux': script = await install.build(os_version + '.sh', version, os_version); - script += 'sh script.sh ' + version + ' ' + __dirname; + script += 'bash script.sh ' + version + ' ' + __dirname; break; case 'win32': script = await install.build(os_version + '.sh', version, os_version); @@ -117,7 +117,7 @@ describe('Install', () => { // @ts-ignore let script: string = await install.run(); expect(script).toContain('initial script'); - expect(script).toContain('sh script.sh 7.3 '); + expect(script).toContain('bash script.sh 7.3 '); setEnv('7.3', 'linux', 'a, b', 'a=b', 'x', 'phpunit', 'true'); // @ts-ignore @@ -126,7 +126,7 @@ describe('Install', () => { expect(script).toContain('install extensions'); expect(script).toContain('edit php.ini'); expect(script).toContain('set coverage driver'); - expect(script).toContain('sh script.sh 7.3'); + expect(script).toContain('bash script.sh 7.3'); expect(script).toContain('add_tool'); setEnv('7.3', 'linux', 'a, b', 'a=b', 'x', 'phpunit', ''); @@ -136,7 +136,7 @@ describe('Install', () => { expect(script).toContain('install extensions'); expect(script).toContain('edit php.ini'); expect(script).toContain('set coverage driver'); - expect(script).toContain('sh script.sh 7.3'); + expect(script).toContain('bash script.sh 7.3'); expect(script).toContain('add_tool'); }); @@ -145,7 +145,7 @@ describe('Install', () => { // @ts-ignore let script: string = await install.run(); expect(script).toContain('initial script'); - expect(script).toContain('sh script.sh 7.3 ' + __dirname); + expect(script).toContain('bash script.sh 7.3 ' + __dirname); setEnv('7.3', 'darwin', 'a, b', 'a=b', 'x', '', ''); // @ts-ignore @@ -154,7 +154,7 @@ describe('Install', () => { expect(script).toContain('install extensions'); expect(script).toContain('edit php.ini'); expect(script).toContain('set coverage driver'); - expect(script).toContain('sh script.sh 7.3 ' + __dirname); + expect(script).toContain('bash script.sh 7.3 ' + __dirname); }); it('Test malformed version inputs', async () => { @@ -162,18 +162,18 @@ describe('Install', () => { // @ts-ignore let script: string = await install.run(); expect(script).toContain('initial script'); - expect(script).toContain('sh script.sh 7.4 ' + __dirname); + expect(script).toContain('bash 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); + expect(script).toContain('bash 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); + expect(script).toContain('bash script.sh 8.0 ' + __dirname); }); }); diff --git a/__tests__/matchers.test.ts b/__tests__/matchers.test.ts index 1d55d6f0..25534c36 100644 --- a/__tests__/matchers.test.ts +++ b/__tests__/matchers.test.ts @@ -18,10 +18,10 @@ describe('Matchers', () => { process.env['RUNNER_TOOL_CACHE'] = __dirname; await matchers.addMatchers(); const spy = jest.spyOn(io, 'cp'); - expect(spy).toHaveBeenCalledTimes(1); + expect(spy).toHaveBeenCalledTimes(2); }); - it('Test Regex', async () => { + it('Test PHPUnit Regex', async () => { const regex1 = /^\d+\)\s.*$/; const regex2 = /^(.*Failed\sasserting\sthat.*)$/; const regex3 = /^\s*$/; @@ -31,4 +31,21 @@ describe('Matchers', () => { expect(regex3.test('\n')).toBe(true); expect(regex4.test('/path/to/file.php:42')).toBe(true); }); + + it('Test PHP Regex', async () => { + const regex1 = /^(.*error):\s+\s+(.+) in (.+) on line (\d+)$/; + const regex2 = /^(.*Warning|.*Deprecated|.*Notice):\s+\s+(.+) in (.+) on line (\d+)$/; + expect( + regex1.test('PHP Parse error: error_message in file.php on line 10') + ).toBe(true); + expect( + regex2.test('PHP Notice: info_message in file.php on line 10') + ).toBe(true); + expect( + regex2.test('PHP Warning: warning_message in file.php on line 10') + ).toBe(true); + expect( + regex2.test('PHP Deprecated: deprecated_message in file.php on line 10') + ).toBe(true); + }); }); diff --git a/__tests__/tools.test.ts b/__tests__/tools.test.ts index 6c7394dd..c6aadaa1 100644 --- a/__tests__/tools.test.ts +++ b/__tests__/tools.test.ts @@ -107,22 +107,13 @@ describe('Tools tests', () => { }); it('checking getCodeceptionUriBuilder', async () => { - expect(await tools.getCodeceptionUriBuilder('3.2.1', '5.6', 'php56')).toBe( + expect(await tools.getCodeceptionUriBuilder('3.2.1', 'php56')).toBe( 'releases/3.2.1/php56/codecept.phar' ); - expect(await tools.getCodeceptionUriBuilder('3.2.1', '7.0', 'php54')).toBe( + expect(await tools.getCodeceptionUriBuilder('3.2.1', '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( + expect(await tools.getCodeceptionUriBuilder('3.2.1', '')).toBe( 'releases/3.2.1/codecept.phar' ); }); @@ -146,17 +137,59 @@ describe('Tools tests', () => { 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.0.0', '7.4')).toBe( + 'releases/4.0.0/codecept.phar' ); - expect(await tools.getCodeceptionUri('4.3.2', '5.6')).toBe( - 'releases/4.3.2/php56/codecept.phar' + expect(await tools.getCodeceptionUri('4.0.0', '5.6')).toBe( + 'releases/4.0.0/php56/codecept.phar' ); - expect(await tools.getCodeceptionUri('3.2.1', '7.4')).toBe( - 'releases/3.2.1/codecept.phar' + expect(await tools.getCodeceptionUri('4.0.0', '7.1')).toBe( + 'releases/4.0.0/php56/codecept.phar' ); - expect(await tools.getCodeceptionUri('4.3.2', '7.4')).toBe( - 'releases/4.3.2/codecept.phar' + expect(await tools.getCodeceptionUri('3.1.0', '7.4')).toBe( + 'releases/3.1.0/codecept.phar' + ); + expect(await tools.getCodeceptionUri('3.1.0', '5.6')).toBe( + 'releases/3.1.0/php54/codecept.phar' + ); + expect(await tools.getCodeceptionUri('2.5.4', '7.4')).toBe( + 'releases/2.5.4/codecept.phar' + ); + expect(await tools.getCodeceptionUri('2.5.4', '5.6')).toBe( + 'releases/2.5.4/php54/codecept.phar' + ); + expect(await tools.getCodeceptionUri('2.3.4', '7.4')).toBe( + 'releases/2.3.4/codecept.phar' + ); + expect(await tools.getCodeceptionUri('2.3.4', '5.4')).toBe( + 'releases/2.3.4/php54/codecept.phar' + ); + expect(await tools.getCodeceptionUri('2.2.4', '5.6')).toBe( + 'releases/2.2.4/codecept.phar' + ); + expect(await tools.getCodeceptionUri('2.2.4', '7.4')).toBe( + 'releases/2.2.4/codecept.phar' + ); + expect(await tools.getCodeceptionUri('2.2.4', '5.4')).toBe( + 'releases/2.2.4/php54/codecept.phar' + ); + expect(await tools.getCodeceptionUri('2.1.7', '5.6')).toBe( + 'releases/2.1.7/codecept.phar' + ); + expect(await tools.getCodeceptionUri('2.1.7', '5.4')).toBe( + 'releases/2.1.7/php54/codecept.phar' + ); + expect(await tools.getCodeceptionUri('2.1.5', '5.4')).toBe( + 'releases/2.1.5/codecept.phar' + ); + expect(await tools.getCodeceptionUri('2.1.5', '7.4')).toBe( + 'releases/2.1.5/codecept.phar' + ); + expect(await tools.getCodeceptionUri('1.6.9', '7.4')).toBe( + 'releases/1.6.9/codecept.phar' + ); + expect(await tools.getCodeceptionUri('1.5.0', '7.4')).toBe( + 'releases/1.5.0/codecept.phar' ); }); diff --git a/action.yml b/action.yml index cabc7b4f..e9511e58 100644 --- a/action.yml +++ b/action.yml @@ -20,18 +20,8 @@ inputs: tools: description: 'Setup popular tools globally.' required: false - # Deprecated options, do not use. Will not be supported in v2 which will be released around February 1, 2020. - extension-csv: - description: 'Deprecated! Use extensions instead.' - deprecationMessage: 'The extension-csv property will not be supported in v2. Use extensions instead.' - required: false - ini-values-csv: - description: 'Deprecated! 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.' + update: + description: 'Update PHP if already installed.' required: false runs: using: 'node12' diff --git a/dist/index.js b/dist/index.js index 5525fcea..17eec80a 100644 --- a/dist/index.js +++ b/dist/index.js @@ -964,9 +964,10 @@ const io = __importStar(__webpack_require__(1)); */ function addMatchers() { return __awaiter(this, void 0, void 0, function* () { - const config_path = path.join(__dirname, '..', 'src', 'configs', 'phpunit.json'); + const config_path = path.join(__dirname, '..', 'src', 'configs'); const runner_dir = yield utils.getInput('RUNNER_TOOL_CACHE', false); - yield io.cp(config_path, runner_dir); + yield io.cp(path.join(config_path, 'phpunit.json'), runner_dir); + yield io.cp(path.join(config_path, 'php.json'), runner_dir); }); } exports.addMatchers = addMatchers; @@ -1703,20 +1704,13 @@ exports.getUri = getUri; * Helper function to get the codeception url * * @param version - * @param php_version * @param suffix */ -function getCodeceptionUriBuilder(version, php_version, suffix) { +function getCodeceptionUriBuilder(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('/'); - } + return ['releases', version, suffix, 'codecept.phar'] + .filter(Boolean) + .join('/'); }); } exports.getCodeceptionUriBuilder = getCodeceptionUriBuilder; @@ -1728,19 +1722,55 @@ exports.getCodeceptionUriBuilder = getCodeceptionUriBuilder; */ function getCodeceptionUri(version, php_version) { return __awaiter(this, void 0, void 0, function* () { + const codecept = yield getCodeceptionUriBuilder(version, ''); + const codecept54 = yield getCodeceptionUriBuilder(version, 'php54'); + const codecept56 = yield getCodeceptionUriBuilder(version, 'php56'); + // Refer to https://codeception.com/builds switch (true) { case /latest/.test(version): switch (true) { - case /^5\.6$|^7\.[0|1]$/.test(php_version): + case /5\.6|7\.[0|1]/.test(php_version): return 'php56/codecept.phar'; - case /^7\.[2-4]$/.test(php_version): + 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'); + case /(^[4-9]|\d{2,})\..*/.test(version): + switch (true) { + case /5\.6|7\.[0|1]/.test(php_version): + return codecept56; + case /7\.[2-4]/.test(php_version): + default: + return codecept; + } + case /(^2\.[4-5]\.\d+|^3\.[0-1]\.\d+).*/.test(version): + switch (true) { + case /5\.6/.test(php_version): + return codecept54; + case /7\.[0-4]/.test(php_version): + default: + return codecept; + } + case /^2\.3\.\d+.*/.test(version): + switch (true) { + case /5\.[4-6]/.test(php_version): + return codecept54; + case /^7\.[0-4]$/.test(php_version): + default: + return codecept; + } + case /(^2\.(1\.([6-9]|\d{2,}))|^2\.2\.\d+).*/.test(version): + switch (true) { + case /5\.[4-5]/.test(php_version): + return codecept54; + case /5.6|7\.[0-4]/.test(php_version): + default: + return codecept; + } + case /(^2\.(1\.[0-5]|0\.\d+)|^1\.[6-8]\.\d+).*/.test(version): + return codecept; default: - return yield getCodeceptionUriBuilder(version, php_version, 'php54'); + return yield codecept; } }); } @@ -2104,7 +2134,7 @@ exports.addCoverageXdebug = addCoverageXdebug; function addCoveragePCOV(version, os_version, pipe) { return __awaiter(this, void 0, void 0, function* () { let script = '\n'; - switch (version) { + switch (true) { default: script += (yield extensions.addExtension('pcov', version, os_version, true)) + @@ -2126,8 +2156,7 @@ function addCoveragePCOV(version, os_version, pipe) { script += yield utils.addLog('$tick', 'coverage: pcov', 'PCOV enabled as coverage driver', os_version); // version is not supported break; - case '5.6': - case '7.0': + case /5\.[3-6]|7\.0/.test(version): script += yield utils.addLog('$cross', 'pcov', 'PHP 7.1 or newer is required', os_version); break; } @@ -2332,15 +2361,14 @@ function build(filename, version, os_version) { return __awaiter(this, void 0, void 0, function* () { // taking inputs const extension_csv = (yield utils.getInput('extensions', false)) || - (yield utils.getInput('extension', false)) || - (yield utils.getInput('extension-csv', false)); - const ini_values_csv = (yield utils.getInput('ini-values', false)) || - (yield utils.getInput('ini-values-csv', false)); + (yield utils.getInput('extension', false)); + const ini_values_csv = yield utils.getInput('ini-values', false); const coverage_driver = yield utils.getInput('coverage', false); const pecl = yield utils.getInput('pecl', false); let tools_csv = yield utils.getInput('tools', false); if (pecl == 'true' || - /.*-(beta|alpha|devel|snapshot).*/.test(extension_csv)) { + /.*-(beta|alpha|devel|snapshot).*/.test(extension_csv) || + /.*-(\d+\.\d+\.\d+).*/.test(extension_csv)) { tools_csv = 'pecl, ' + tools_csv; } let script = yield utils.readScript(filename, version, os_version); @@ -2364,16 +2392,16 @@ exports.build = build; function run() { return __awaiter(this, void 0, void 0, function* () { try { - const os_version = process.platform; let version = yield utils.getInput('php-version', true); version = version.length > 1 ? version.slice(0, 3) : version + '.0'; + const os_version = process.platform; // check the os version and run the respective script let script_path = ''; switch (os_version) { case 'darwin': case 'linux': script_path = yield build(os_version + '.sh', version, os_version); - yield exec_1.exec('sh ' + script_path + ' ' + version + ' ' + __dirname); + yield exec_1.exec('bash ' + script_path + ' ' + version + ' ' + __dirname); break; case 'win32': script_path = yield build('win32.ps1', version, os_version); @@ -2649,21 +2677,27 @@ function addExtensionDarwin(extension_csv, version, pipe) { return __awaiter(this, void 0, void 0, function* () { extension = extension.toLowerCase(); const version_extension = version + extension; - const [extension_name, stability] = extension.split('-'); - const prefix = yield utils.getExtensionPrefix(extension_name); + const [ext_name, ext_version] = extension.split('-'); + const prefix = yield utils.getExtensionPrefix(ext_name); let install_command = ''; switch (true) { // match pre-release versions case /.*-(beta|alpha|devel|snapshot)/.test(version_extension): script += '\nadd_unstable_extension ' + - extension_name + + ext_name + ' ' + - stability + + ext_version + ' ' + prefix; return; - case /5\.6xdebug/.test(version_extension): + case /5\.3xdebug/.test(version_extension): + install_command = 'sudo pecl install -f xdebug-2.2.7' + pipe; + break; + case /5\.4xdebug/.test(version_extension): + install_command = 'sudo pecl install -f xdebug-2.4.1' + pipe; + break; + case /5\.[5-6]xdebug/.test(version_extension): install_command = 'sudo pecl install -f xdebug-2.5.5' + pipe; break; case /7\.0xdebug/.test(version_extension): @@ -2680,15 +2714,14 @@ function addExtensionDarwin(extension_csv, version, pipe) { pipe; break; case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension): - install_command = + script += 'sh ' + path.join(__dirname, '../src/scripts/ext/phalcon_darwin.sh') + ' ' + extension + ' ' + - version + - pipe; - break; + version; + return; default: install_command = 'sudo pecl install -f ' + extension + pipe; break; @@ -2720,13 +2753,23 @@ function addExtensionWindows(extension_csv, version, pipe) { yield utils.asyncForEach(extensions, function (extension) { return __awaiter(this, void 0, void 0, function* () { extension = extension.toLowerCase(); - const [extension_name, stability] = extension.split('-'); + const [ext_name, ext_version] = extension.split('-'); const version_extension = version + extension; + let matches; switch (true) { // match pre-release versions case /.*-(beta|alpha|devel|snapshot)/.test(version_extension): - script += '\nAdd-Extension ' + extension_name + ' ' + stability; + script += '\nAdd-Extension ' + ext_name + ' ' + ext_version; break; + // match exact versions + case /.*-\d+\.\d+\.\d+$/.test(version_extension): + script += '\nAdd-Extension ' + ext_name + ' stable ' + ext_version; + return; + case /.*-(\d+\.\d+\.\d)+(beta|alpha|devel|snapshot)\d*/.test(version_extension): + matches = /.*-(\d+\.\d+\.\d)+(beta|alpha|devel|snapshot)\d*/.exec(version_extension); + script += + '\nAdd-Extension ' + ext_name + ' ' + matches[2] + ' ' + matches[1]; + return; // match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4 case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension): script += @@ -2763,20 +2806,24 @@ function addExtensionLinux(extension_csv, version, pipe) { return __awaiter(this, void 0, void 0, function* () { extension = extension.toLowerCase(); const version_extension = version + extension; - const [extension_name, stability] = extension.split('-'); - const prefix = yield utils.getExtensionPrefix(extension_name); + const [ext_name, ext_version] = extension.split('-'); + const prefix = yield utils.getExtensionPrefix(ext_name); let install_command = ''; switch (true) { // match pre-release versions case /.*-(beta|alpha|devel|snapshot)/.test(version_extension): script += '\nadd_unstable_extension ' + - extension_name + + ext_name + ' ' + - stability + + ext_version + ' ' + prefix; return; + // match exact versions + case /.*-\d+\.\d+\.\d+.*/.test(version_extension): + script += '\nadd_pecl_extension ' + ext_name + ' ' + ext_version; + return; // match 5.6gearman..7.4gearman case /^((5\.6)|(7\.[0-4]))gearman$/.test(version_extension): install_command = @@ -2799,7 +2846,7 @@ function addExtensionLinux(extension_csv, version, pipe) { // match 7.0xdebug..7.4xdebug case /^7\.[0-4]xdebug$/.test(version_extension): script += - '\nupdate_extension xdebug 2.9.0' + + '\nupdate_extension xdebug 2.9.1' + pipe + '\n' + (yield utils.addLog('$tick', 'xdebug', 'Enabled', 'linux')); diff --git a/examples/bedrock.yml b/examples/bedrock.yml index 4b8f25e8..9d79b781 100644 --- a/examples/bedrock.yml +++ b/examples/bedrock.yml @@ -13,7 +13,7 @@ jobs: - name: Checkout uses: actions/checkout@v2 - name: Setup PHP, with composer and extensions - uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php + uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php with: php-version: ${{ matrix.php-versions }} - name: Get composer cache directory diff --git a/examples/cakephp-mysql.yml b/examples/cakephp-mysql.yml index 478d6ba3..4065d798 100644 --- a/examples/cakephp-mysql.yml +++ b/examples/cakephp-mysql.yml @@ -27,7 +27,7 @@ jobs: - name: Checkout uses: actions/checkout@v2 - name: Setup PHP - uses: shivammathur/setup-php@v1 + uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php-versions }} # You can also use ext-apcu or ext-memcached instead of ext-redis @@ -63,7 +63,7 @@ jobs: - name: Checkout uses: actions/checkout@v2 - name: Setup PHP - uses: shivammathur/setup-php@v1 + uses: shivammathur/setup-php@v2 with: php-version: '7.3' extensions: mbstring, intl @@ -90,7 +90,7 @@ jobs: - name: Checkout uses: actions/checkout@v2 - name: Setup PHP - uses: shivammathur/setup-php@v1 + uses: shivammathur/setup-php@v2 with: php-version: '7.3' extensions: mbstring, intl diff --git a/examples/cakephp-postgres.yml b/examples/cakephp-postgres.yml index 22743e5b..21aeaa8a 100644 --- a/examples/cakephp-postgres.yml +++ b/examples/cakephp-postgres.yml @@ -27,7 +27,7 @@ jobs: - name: Checkout uses: actions/checkout@v2 - name: Setup PHP - uses: shivammathur/setup-php@v1 + uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php-versions }} # You can also use ext-apcu or ext-memcached instead of ext-redis @@ -63,7 +63,7 @@ jobs: - name: Checkout uses: actions/checkout@v2 - name: Setup PHP - uses: shivammathur/setup-php@v1 + uses: shivammathur/setup-php@v2 with: php-version: '7.3' extensions: mbstring, intl @@ -90,7 +90,7 @@ jobs: - name: Checkout uses: actions/checkout@v2 - name: Setup PHP - uses: shivammathur/setup-php@v1 + uses: shivammathur/setup-php@v2 with: php-version: '7.3' extensions: mbstring, intl diff --git a/examples/cakephp.yml b/examples/cakephp.yml index 14a252cf..65e011b8 100644 --- a/examples/cakephp.yml +++ b/examples/cakephp.yml @@ -13,7 +13,7 @@ jobs: - name: Checkout uses: actions/checkout@v2 - name: Setup PHP - uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php + uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php with: php-version: ${{ matrix.php-versions }} extensions: mbstring, intl, pdo_sqlite, pdo_mysql @@ -43,7 +43,7 @@ jobs: - name: Checkout uses: actions/checkout@v2 - name: Setup PHP - uses: shivammathur/setup-php@v1 + uses: shivammathur/setup-php@v2 with: php-version: '7.3' extensions: mbstring, intl @@ -70,7 +70,7 @@ jobs: - name: Checkout uses: actions/checkout@v2 - name: Setup PHP - uses: shivammathur/setup-php@v1 + uses: shivammathur/setup-php@v2 with: php-version: '7.3' extensions: mbstring, intl diff --git a/examples/codeigniter.yml b/examples/codeigniter.yml index 2c0c535d..3d3bb03d 100644 --- a/examples/codeigniter.yml +++ b/examples/codeigniter.yml @@ -12,7 +12,7 @@ jobs: - name: Checkout uses: actions/checkout@v2 - name: Setup PHP, with composer and extensions - uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php + uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php with: php-version: ${{ matrix.php-versions }} extensions: mbstring, intl, curl, dom diff --git a/examples/laravel-mysql.yml b/examples/laravel-mysql.yml index 5de24522..981e3a28 100644 --- a/examples/laravel-mysql.yml +++ b/examples/laravel-mysql.yml @@ -36,7 +36,7 @@ jobs: - name: Checkout uses: actions/checkout@v2 - name: Setup PHP, with composer and extensions - uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php + uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php with: php-version: ${{ matrix.php-versions }} extensions: mbstring, dom, fileinfo, mysql diff --git a/examples/laravel-postgres.yml b/examples/laravel-postgres.yml index 2107dfa8..e0b00391 100644 --- a/examples/laravel-postgres.yml +++ b/examples/laravel-postgres.yml @@ -38,7 +38,7 @@ jobs: - name: Checkout uses: actions/checkout@v2 - name: Setup PHP, with composer and extensions - uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php + uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php with: php-version: ${{ matrix.php-versions }} extensions: mbstring, dom, fileinfo, pgsql diff --git a/examples/laravel.yml b/examples/laravel.yml index d5b84465..68480c3f 100644 --- a/examples/laravel.yml +++ b/examples/laravel.yml @@ -14,7 +14,7 @@ jobs: - name: Checkout uses: actions/checkout@v2 - name: Setup PHP, with composer and extensions - uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php + uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php with: php-version: ${{ matrix.php-versions }} extensions: mbstring, dom, fileinfo diff --git a/examples/lumen-mysql.yml b/examples/lumen-mysql.yml index d358e500..a3cf2572 100644 --- a/examples/lumen-mysql.yml +++ b/examples/lumen-mysql.yml @@ -36,7 +36,7 @@ jobs: - name: Checkout uses: actions/checkout@v2 - name: Setup PHP, with composer and extensions - uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php + uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php with: php-version: ${{ matrix.php-versions }} extensions: mbstring, dom, fileinfo, mysql diff --git a/examples/lumen-postgres.yml b/examples/lumen-postgres.yml index 9117c37f..609cecd5 100644 --- a/examples/lumen-postgres.yml +++ b/examples/lumen-postgres.yml @@ -38,7 +38,7 @@ jobs: - name: Checkout uses: actions/checkout@v2 - name: Setup PHP, with composer and extensions - uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php + uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php with: php-version: ${{ matrix.php-versions }} extensions: mbstring, dom, fileinfo, pgsql diff --git a/examples/lumen.yml b/examples/lumen.yml index 0b7ae9bc..6c3f7b17 100644 --- a/examples/lumen.yml +++ b/examples/lumen.yml @@ -14,7 +14,7 @@ jobs: - name: Checkout uses: actions/checkout@v2 - name: Setup PHP, with composer and extensions - uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php + uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php with: php-version: ${{ matrix.php-versions }} extensions: mbstring, dom, fileinfo, mysql diff --git a/examples/phalcon-mysql.yml b/examples/phalcon-mysql.yml index 9e4ffb18..e422d0db 100644 --- a/examples/phalcon-mysql.yml +++ b/examples/phalcon-mysql.yml @@ -36,7 +36,7 @@ jobs: - name: Checkout uses: actions/checkout@v2 - name: Setup PHP, with composer and extensions - uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php + uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php with: php-version: ${{ matrix.php-versions }} extensions: mbstring, dom, zip, phalcon4, mysql #use phalcon3 for the phalcon 3.x. diff --git a/examples/phalcon-postgres.yml b/examples/phalcon-postgres.yml index 68856472..321502d8 100644 --- a/examples/phalcon-postgres.yml +++ b/examples/phalcon-postgres.yml @@ -37,7 +37,7 @@ jobs: - name: Checkout uses: actions/checkout@v2 - name: Setup PHP, with composer and extensions - uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php + uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php with: php-version: ${{ matrix.php-versions }} extensions: mbstring, dom, zip, phalcon4, pgsql #use phalcon3 for the phalcon 3.x diff --git a/examples/sage.yml b/examples/sage.yml index 24326acc..3863b3a7 100644 --- a/examples/sage.yml +++ b/examples/sage.yml @@ -18,7 +18,7 @@ jobs: with: node-version: ${{ matrix.node-versions }} - name: Setup PHP, with composer and extensions - uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php + uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php with: php-version: ${{ matrix.php-versions }} extensions: mbstring diff --git a/examples/slim-framework.yml b/examples/slim-framework.yml index bea31160..329ed8b0 100644 --- a/examples/slim-framework.yml +++ b/examples/slim-framework.yml @@ -12,7 +12,7 @@ jobs: - name: Checkout uses: actions/checkout@v2 - name: Setup PHP, with composer and extensions - uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php + uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php with: php-version: ${{ matrix.php-versions }} extensions: mbstring, simplexml, dom diff --git a/examples/symfony-mysql.yml b/examples/symfony-mysql.yml index ecee71e1..98ff0fae 100644 --- a/examples/symfony-mysql.yml +++ b/examples/symfony-mysql.yml @@ -23,7 +23,7 @@ jobs: - name: Checkout uses: actions/checkout@v2 - name: Setup PHP, with composer and extensions - uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php + uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php with: php-version: ${{ matrix.php-versions }} extensions: mbstring, xml, ctype, iconv, intl, pdo_sqlite, mysql diff --git a/examples/symfony-postgres.yml b/examples/symfony-postgres.yml index 8a0a40df..e3638ea2 100644 --- a/examples/symfony-postgres.yml +++ b/examples/symfony-postgres.yml @@ -23,7 +23,7 @@ jobs: - name: Checkout uses: actions/checkout@v2 - name: Setup PHP, with composer and extensions - uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php + uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php with: php-version: ${{ matrix.php-versions }} extensions: mbstring, xml, ctype, iconv, intl, pdo_sqlite, pgsql diff --git a/examples/symfony.yml b/examples/symfony.yml index f171e9b6..6c9a0d70 100644 --- a/examples/symfony.yml +++ b/examples/symfony.yml @@ -14,7 +14,7 @@ jobs: - name: Checkout uses: actions/checkout@v2 - name: Setup PHP, with composer and extensions - uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php + uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php with: php-version: ${{ matrix.php-versions }} extensions: mbstring, xml, ctype, iconv, intl, pdo_sqlite diff --git a/examples/yii2-mysql.yml b/examples/yii2-mysql.yml index 81e4b406..1f33bd63 100644 --- a/examples/yii2-mysql.yml +++ b/examples/yii2-mysql.yml @@ -33,7 +33,7 @@ jobs: with: node-version: 10.x - name: Setup PHP, with composer and extensions - uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php + uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php with: php-version: ${{ matrix.php-versions }} extensions: mbstring, intl, gd, imagick, zip, dom, mysql diff --git a/examples/yii2-postgres.yml b/examples/yii2-postgres.yml index 7301f3dc..b3465faf 100644 --- a/examples/yii2-postgres.yml +++ b/examples/yii2-postgres.yml @@ -33,7 +33,7 @@ jobs: with: node-version: 10.x - name: Setup PHP, with composer and extensions - uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php + uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php with: php-version: ${{ matrix.php-versions }} extensions: mbstring, intl, gd, imagick, zip, dom, pgsql diff --git a/examples/zend-framework.yml b/examples/zend-framework.yml index 150ee631..3a4921b6 100644 --- a/examples/zend-framework.yml +++ b/examples/zend-framework.yml @@ -12,7 +12,7 @@ jobs: - name: Checkout uses: actions/checkout@v2 - name: Setup PHP, with composer and extensions - uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php + uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php with: php-version: ${{ matrix.php-versions }} extensions: mbstring, bcmath, curl, intl diff --git a/package-lock.json b/package-lock.json index 860ea479..23b022ad 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "setup-php", - "version": "1.8.2", + "version": "2.0.0", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -284,9 +284,9 @@ "dev": true }, "@cnakazawa/watch": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/@cnakazawa/watch/-/watch-1.0.3.tgz", - "integrity": "sha512-r5160ogAvGyHsal38Kux7YYtodEKOj89RGb28ht1jh3SJb08VwRwAKKJL0bGb04Zd/3r9FL3BFIc3bBidYffCA==", + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/@cnakazawa/watch/-/watch-1.0.4.tgz", + "integrity": "sha512-v9kIhKwjeZThiWrLmj0y17CWoyddASLj9O2yvbZkbvw/N3rWOYy9zkV66ursAoVr0mV15bL8g0c4QZUE6cdDoQ==", "dev": true, "requires": { "exec-sh": "^0.3.2", @@ -425,9 +425,9 @@ }, "dependencies": { "rimraf": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.1.tgz", - "integrity": "sha512-IQ4ikL8SjBiEDZfk+DFVwqRK8md24RWMEJkdSlgNLkyyAImcjf8SWvU1qFMDOb4igBClbTQ/ugPqXcRwdFTxZw==", + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", + "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", "dev": true, "requires": { "glob": "^7.1.3" @@ -584,9 +584,9 @@ } }, "@types/babel__core": { - "version": "7.1.3", - "resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.1.3.tgz", - "integrity": "sha512-8fBo0UR2CcwWxeX7WIIgJ7lXjasFxoYgRnFHUj+hRvKkpiBJbxhdAPTCY6/ZKM0uxANFVzt4yObSLuTiTnazDA==", + "version": "7.1.4", + "resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.1.4.tgz", + "integrity": "sha512-c/5MuRz5HM4aizqL5ViYfW4iEnmfPcfbH4Xa6GgLT21dMc1NGeNnuS6egHheOmP+kCJ9CAzC4pv4SDCWTnRkbg==", "dev": true, "requires": { "@babel/parser": "^7.1.0", @@ -662,9 +662,9 @@ } }, "@types/jest": { - "version": "25.1.1", - "resolved": "https://registry.npmjs.org/@types/jest/-/jest-25.1.1.tgz", - "integrity": "sha512-bKSZJYZJLzwaoVYNN4W3A0RvKNYsrLm5tsuXaMlfYDxKf4gY2sFrMYneCugNQWGg1gjPW+FHBwNrwPzEi4sIsw==", + "version": "25.1.2", + "resolved": "https://registry.npmjs.org/@types/jest/-/jest-25.1.2.tgz", + "integrity": "sha512-EsPIgEsonlXmYV7GzUqcvORsSS9Gqxw/OvkGwHfAdpjduNRxMlhsav0O5Kb0zijc/eXSO/uW6SJt9nwull8AUQ==", "dev": true, "requires": { "jest-diff": "^25.1.0", @@ -678,9 +678,9 @@ "dev": true }, "@types/node": { - "version": "13.7.0", - "resolved": "https://registry.npmjs.org/@types/node/-/node-13.7.0.tgz", - "integrity": "sha512-GnZbirvmqZUzMgkFn70c74OQpTTUcCzlhQliTzYjQMqg+hVKcDnxdL19Ne3UdYzdMA/+W3eb646FWn/ZaT1NfQ==", + "version": "13.7.1", + "resolved": "https://registry.npmjs.org/@types/node/-/node-13.7.1.tgz", + "integrity": "sha512-Zq8gcQGmn4txQEJeiXo/KiLpon8TzAl0kmKH4zdWctPj05nWwp1ClMdAVEloqrQKfaC48PNLdgN/aVaLqUrluA==", "dev": true }, "@types/parse-json": { @@ -711,12 +711,12 @@ "dev": true }, "@typescript-eslint/eslint-plugin": { - "version": "2.18.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-2.18.0.tgz", - "integrity": "sha512-kuO8WQjV+RCZvAXVRJfXWiJ8iYEtfHlKgcqqqXg9uUkIolEHuUaMmm8/lcO4xwCOtaw6mY0gStn2Lg4/eUXXYQ==", + "version": "2.19.2", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-2.19.2.tgz", + "integrity": "sha512-HX2qOq2GOV04HNrmKnTpSIpHjfl7iwdXe3u/Nvt+/cpmdvzYvY0NHSiTkYN257jHnq4OM/yo+OsFgati+7LqJA==", "dev": true, "requires": { - "@typescript-eslint/experimental-utils": "2.18.0", + "@typescript-eslint/experimental-utils": "2.19.2", "eslint-utils": "^1.4.3", "functional-red-black-tree": "^1.0.1", "regexpp": "^3.0.0", @@ -724,32 +724,32 @@ } }, "@typescript-eslint/experimental-utils": { - "version": "2.18.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-2.18.0.tgz", - "integrity": "sha512-J6MopKPHuJYmQUkANLip7g9I82ZLe1naCbxZZW3O2sIxTiq/9YYoOELEKY7oPg0hJ0V/AQ225h2z0Yp+RRMXhw==", + "version": "2.19.2", + "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-2.19.2.tgz", + "integrity": "sha512-B88QuwT1wMJR750YvTJBNjMZwmiPpbmKYLm1yI7PCc3x0NariqPwqaPsoJRwU9DmUi0cd9dkhz1IqEnwfD+P1A==", "dev": true, "requires": { "@types/json-schema": "^7.0.3", - "@typescript-eslint/typescript-estree": "2.18.0", + "@typescript-eslint/typescript-estree": "2.19.2", "eslint-scope": "^5.0.0" } }, "@typescript-eslint/parser": { - "version": "2.18.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-2.18.0.tgz", - "integrity": "sha512-SJJPxFMEYEWkM6pGfcnjLU+NJIPo+Ko1QrCBL+i0+zV30ggLD90huEmMMhKLHBpESWy9lVEeWlQibweNQzyc+A==", + "version": "2.19.2", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-2.19.2.tgz", + "integrity": "sha512-8uwnYGKqX9wWHGPGdLB9sk9+12sjcdqEEYKGgbS8A0IvYX59h01o8os5qXUHMq2na8vpDRaV0suTLM7S8wraTA==", "dev": true, "requires": { "@types/eslint-visitor-keys": "^1.0.0", - "@typescript-eslint/experimental-utils": "2.18.0", - "@typescript-eslint/typescript-estree": "2.18.0", + "@typescript-eslint/experimental-utils": "2.19.2", + "@typescript-eslint/typescript-estree": "2.19.2", "eslint-visitor-keys": "^1.1.0" } }, "@typescript-eslint/typescript-estree": { - "version": "2.18.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-2.18.0.tgz", - "integrity": "sha512-gVHylf7FDb8VSi2ypFuEL3hOtoC4HkZZ5dOjXvVjoyKdRrvXAOPSzpNRnKMfaUUEiSLP8UF9j9X9EDLxC0lfZg==", + "version": "2.19.2", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-2.19.2.tgz", + "integrity": "sha512-Xu/qa0MDk6upQWqE4Qy2X16Xg8Vi32tQS2PR0AvnT/ZYS4YGDvtn2MStOh5y8Zy2mg4NuL06KUHlvCh95j9C6Q==", "dev": true, "requires": { "debug": "^4.1.1", @@ -762,9 +762,9 @@ } }, "@zeit/ncc": { - "version": "0.21.0", - "resolved": "https://registry.npmjs.org/@zeit/ncc/-/ncc-0.21.0.tgz", - "integrity": "sha512-RUMdvVK/w78oo+yBjruZltt0kJXYar2un/1bYQ2LuHG7GmFVm+QjxzEmySwREctaJdEnBvlMdUNWd9hXHxEI3g==", + "version": "0.21.1", + "resolved": "https://registry.npmjs.org/@zeit/ncc/-/ncc-0.21.1.tgz", + "integrity": "sha512-M9WzgquSOt2nsjRkYM9LRylBLmmlwNCwYbm3Up3PDEshfvdmIfqpFNSK8EJvR18NwZjGHE5z2avlDtYQx2JQnw==", "dev": true }, "abab": { @@ -1324,9 +1324,9 @@ } }, "compare-versions": { - "version": "3.5.1", - "resolved": "https://registry.npmjs.org/compare-versions/-/compare-versions-3.5.1.tgz", - "integrity": "sha512-9fGPIB7C6AyM18CJJBHt5EnCZDG3oiTJYy0NjfIAGjKpzv0tkxWko7TNQHF5ymqm7IH03tqmeuBxtvD+Izh6mg==", + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/compare-versions/-/compare-versions-3.6.0.tgz", + "integrity": "sha512-W6Af2Iw1z4CB7q4uU4hv646dW9GQuBM+YpC0UvUCWSD8w90SJjp+ujJuXaEMtAXBtSqGfMPuFOVn4/+FlaqfBA==", "dev": true }, "component-emitter": { @@ -1649,9 +1649,9 @@ "dev": true }, "escodegen": { - "version": "1.13.0", - "resolved": "https://registry.npmjs.org/escodegen/-/escodegen-1.13.0.tgz", - "integrity": "sha512-eYk2dCkxR07DsHA/X2hRBj0CFAZeri/LyDMc0C8JT1Hqi6JnVpMhJ7XFITbb0+yZS3lVkaPL2oCkZ3AVmeVbMw==", + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/escodegen/-/escodegen-1.14.1.tgz", + "integrity": "sha512-Bmt7NcRySdIfNPfU2ZoXDrrXsG9ZjvDxcAlMfDUgRBjLOWTuIACXPBFJH7Z+cLb40JeQco5toikyc9t9P8E9SQ==", "dev": true, "requires": { "esprima": "^4.0.1", @@ -1875,13 +1875,12 @@ } }, "eslint-plugin-jest": { - "version": "23.6.0", - "resolved": "https://registry.npmjs.org/eslint-plugin-jest/-/eslint-plugin-jest-23.6.0.tgz", - "integrity": "sha512-GH8AhcFXspOLqak7fqnddLXEJsrFyvgO8Bm60SexvKSn1+3rWYESnCiWUOCUcBTprNSDSE4CtAZdM4EyV6gPPw==", + "version": "23.7.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-jest/-/eslint-plugin-jest-23.7.0.tgz", + "integrity": "sha512-zkiyGlvJeHNjAEz8FaIxTXNblJJ/zj3waNbYbgflK7K6uy0cpE5zJBt/JpJtOBGM/UGkC6BqsQ4n0y7kQ2HA8w==", "dev": true, "requires": { - "@typescript-eslint/experimental-utils": "^2.5.0", - "micromatch": "^4.0.2" + "@typescript-eslint/experimental-utils": "^2.5.0" } }, "eslint-plugin-prettier": { @@ -1936,9 +1935,9 @@ "dev": true }, "esquery": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.0.1.tgz", - "integrity": "sha512-SmiyZ5zIWH9VM+SRUReLS5Q8a7GxtRdxEBVZpm98rJM7Sb+A9DVCndXfkeFUd3byderg+EbDkfnevfCwynWaNA==", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.1.0.tgz", + "integrity": "sha512-MxYW9xKmROWF672KqjO75sszsA8Mxhw06YFeS5VHlB98KDHbOSurm3ArsjO60Eaf3QmGMCP1yn+0JQkNLo/97Q==", "dev": true, "requires": { "estraverse": "^4.0.0" @@ -2537,9 +2536,9 @@ "dev": true }, "husky": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/husky/-/husky-4.2.1.tgz", - "integrity": "sha512-Qa0lRreeIf4Tl92sSs42ER6qc3hzoyQPPorzOrFWfPEVbdi6LuvJEqWKPk905fOWIR76iBpp7ECZNIwk+a8xuQ==", + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/husky/-/husky-4.2.3.tgz", + "integrity": "sha512-VxTsSTRwYveKXN4SaH1/FefRJYCtx+wx04sSVcOpD7N2zjoHxa+cEJ07Qg5NmV3HAK+IRKOyNVpi2YBIVccIfQ==", "dev": true, "requires": { "chalk": "^3.0.0", @@ -3036,9 +3035,9 @@ "dev": true }, "istanbul-lib-instrument": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/istanbul-lib-instrument/-/istanbul-lib-instrument-4.0.0.tgz", - "integrity": "sha512-Nm4wVHdo7ZXSG30KjZ2Wl5SU/Bw7bDx1PdaiIFzEStdjs0H12mOTncn1GVYuqQSaZxpg87VGBRsVRPGD2cD1AQ==", + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/istanbul-lib-instrument/-/istanbul-lib-instrument-4.0.1.tgz", + "integrity": "sha512-imIchxnodll7pvQBYOqUu88EufLCU56LMeFPZZM/fJZ1irYcYdqroaV+ACK1Ila8ls09iEYArp+nqyC6lW1Vfg==", "dev": true, "requires": { "@babel/core": "^7.7.5", @@ -3557,9 +3556,9 @@ }, "dependencies": { "semver": { - "version": "7.1.2", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.1.2.tgz", - "integrity": "sha512-BJs9T/H8sEVHbeigqzIEo57Iu/3DG6c4QoqTfbQB3BPA4zgzAomh/Fk9E7QtjWQ8mx2dgA9YCfSF4y9k9bHNpQ==", + "version": "7.1.3", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.1.3.tgz", + "integrity": "sha512-ekM0zfiA9SCBlsKa2X1hxyxiI4L3B6EbVJkkdgQXnSEEaHlGdvyodMruTiulSRWMMB4NeIuYNMC9rTKTz97GxA==", "dev": true } } @@ -3819,9 +3818,9 @@ } }, "make-dir": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.0.0.tgz", - "integrity": "sha512-grNJDhb8b1Jm1qeqW5R/O63wUo4UXo2v2HMic6YT9i/HBlF93S8jkMgH7yugvY9ABDShH4VZMn8I+U8+fCNegw==", + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.0.2.tgz", + "integrity": "sha512-rYKABKutXa6vXTXhoV18cBE7PaewPXHe/Bdq4v+ZLMhxbWApkFFplT0LcbMW+6BbjnQXzZ/sAvSE/JdguApG5w==", "dev": true, "requires": { "semver": "^6.0.0" @@ -4390,13 +4389,13 @@ "dev": true }, "prompts": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/prompts/-/prompts-2.3.0.tgz", - "integrity": "sha512-NfbbPPg/74fT7wk2XYQ7hAIp9zJyZp5Fu19iRbORqqy1BhtrkZ0fPafBU+7bmn8ie69DpT0R6QpJIN2oisYjJg==", + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/prompts/-/prompts-2.3.1.tgz", + "integrity": "sha512-qIP2lQyCwYbdzcqHIUi2HAxiWixhoM9OdLCWf8txXsapC/X9YdsCoeyRIXE/GP+Q0J37Q7+XN/MFqbUa7IzXNA==", "dev": true, "requires": { "kleur": "^3.0.3", - "sisteransi": "^1.0.3" + "sisteransi": "^1.0.4" } }, "psl": { @@ -4504,9 +4503,9 @@ "dev": true }, "request": { - "version": "2.88.0", - "resolved": "https://registry.npmjs.org/request/-/request-2.88.0.tgz", - "integrity": "sha512-NAqBSrijGLZdM0WZNsInLJpkJokL72XYjUpnB0iwsRgxh7dB6COrHnTBNwN0E+lHDAJzu7kLAkDeY08z2/A0hg==", + "version": "2.88.2", + "resolved": "https://registry.npmjs.org/request/-/request-2.88.2.tgz", + "integrity": "sha512-MsvtOrfG9ZcrOwAW+Qi+F6HbD0CWXEh9ou77uOb7FM2WPhwT7smM833PzanhJLsgXjN89Ir6V2PczXNnMpwKhw==", "dev": true, "requires": { "aws-sign2": "~0.7.0", @@ -4516,7 +4515,7 @@ "extend": "~3.0.2", "forever-agent": "~0.6.1", "form-data": "~2.3.2", - "har-validator": "~5.1.0", + "har-validator": "~5.1.3", "http-signature": "~1.2.0", "is-typedarray": "~1.0.0", "isstream": "~0.1.2", @@ -4526,25 +4525,19 @@ "performance-now": "^2.1.0", "qs": "~6.5.2", "safe-buffer": "^5.1.2", - "tough-cookie": "~2.4.3", + "tough-cookie": "~2.5.0", "tunnel-agent": "^0.6.0", "uuid": "^3.3.2" }, "dependencies": { - "punycode": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz", - "integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4=", - "dev": true - }, "tough-cookie": { - "version": "2.4.3", - "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.4.3.tgz", - "integrity": "sha512-Q5srk/4vDM54WJsJio3XNn6K2sCG+CQ8G5Wz6bZhRZoAe/+TxjWB/GlFAnYEbkYVlON9FMk/fE3h2RLpPXo4lQ==", + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.5.0.tgz", + "integrity": "sha512-nlLsUzgm1kfLXSXfRZMc1KLAugd4hqJHDTvc2hDIwS3mZAfMEuMbc03SujMF+GEcpaX/qboeycw6iO8JwVv2+g==", "dev": true, "requires": { - "psl": "^1.1.24", - "punycode": "^1.4.1" + "psl": "^1.1.28", + "punycode": "^2.1.1" } } } @@ -4594,9 +4587,9 @@ "dev": true }, "resolve": { - "version": "1.15.0", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.15.0.tgz", - "integrity": "sha512-+hTmAldEGE80U2wJJDC1lebb5jWqvTYAfm3YZ1ckk1gBr0MnCqUKlwK1e+anaFljIl+F5tR5IoZcm4ZDA1zMQw==", + "version": "1.15.1", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.15.1.tgz", + "integrity": "sha512-84oo6ZTtoTUpjgNEr5SJyzQhzL72gaRodsSfyxC/AXRvwu0Yse9H8eF9IpGo7b8YetZhlI6v7ZQ6bKBFV/6S7w==", "dev": true, "requires": { "path-parse": "^1.0.6" @@ -5350,9 +5343,9 @@ } }, "supports-hyperlinks": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/supports-hyperlinks/-/supports-hyperlinks-2.0.0.tgz", - "integrity": "sha512-bFhn0MQ8qefLyJ3K7PpHiPUTuTVPWw6RXfaMeV6xgJLXtBbszyboz1bvGTVv4R0YpQm2DqlXXn0fFHhxUHVE5w==", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/supports-hyperlinks/-/supports-hyperlinks-2.1.0.tgz", + "integrity": "sha512-zoE5/e+dnEijk6ASB6/qrK+oYdm2do1hjoLWrqUC/8WEIW1gbxFcKuBof7sW8ArN6e+AYvsE8HBGiVRWL/F5CA==", "dev": true, "requires": { "has-flag": "^4.0.0", @@ -5524,9 +5517,9 @@ } }, "ts-jest": { - "version": "25.1.0", - "resolved": "https://registry.npmjs.org/ts-jest/-/ts-jest-25.1.0.tgz", - "integrity": "sha512-1Lf576ulKhbxX5og+tG8udVg/5cgcMLPBxp1iCqbbf6VvUK4gEsgAtzMjl8u98izhLrzKMPB0LxCBKEZ5l19Hw==", + "version": "25.2.0", + "resolved": "https://registry.npmjs.org/ts-jest/-/ts-jest-25.2.0.tgz", + "integrity": "sha512-VaRdb0da46eorLfuHEFf0G3d+jeREcV+Wb/SvW71S4y9Oe8SHWU+m1WY/3RaMknrBsnvmVH0/rRjT8dkgeffNQ==", "dev": true, "requires": { "bs-logger": "0.x", @@ -5728,9 +5721,9 @@ "dev": true }, "v8-to-istanbul": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/v8-to-istanbul/-/v8-to-istanbul-4.0.1.tgz", - "integrity": "sha512-x0yZvZAkjJwdD3fPiJzYP37aod0ati4LlmD2RmpKjqewjKAov/u/ytZ8ViIZb07cN4cePKzl9ijiUi7C1LQ8hQ==", + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/v8-to-istanbul/-/v8-to-istanbul-4.1.2.tgz", + "integrity": "sha512-G9R+Hpw0ITAmPSr47lSlc5A1uekSYzXxTMlFxso2xoffwo4jQnzbv1p9yXIinO8UMZKfAFewaCHwWvnH4Jb4Ug==", "dev": true, "requires": { "@types/istanbul-lib-coverage": "^2.0.1", diff --git a/package.json b/package.json index 1ffed5cb..2b98dbb6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "setup-php", - "version": "1.8.2", + "version": "2.0.0", "private": false, "description": "Setup PHP for use with GitHub Actions", "main": "dist/index.js", @@ -30,21 +30,21 @@ "fs": "0.0.1-security" }, "devDependencies": { - "@types/jest": "^25.1.1", - "@types/node": "^13.7.0", - "@typescript-eslint/eslint-plugin": "^2.18.0", - "@typescript-eslint/parser": "^2.18.0", - "@zeit/ncc": "^0.21.0", + "@types/jest": "^25.1.2", + "@types/node": "^13.7.1", + "@typescript-eslint/eslint-plugin": "^2.19.2", + "@typescript-eslint/parser": "^2.19.2", + "@zeit/ncc": "^0.21.1", "eslint": "^6.8.0", "eslint-config-prettier": "^6.10.0", "eslint-plugin-import": "^2.20.1", - "eslint-plugin-jest": "^23.6.0", + "eslint-plugin-jest": "^23.7.0", "eslint-plugin-prettier": "^3.1.2", - "husky": "^4.2.1", + "husky": "^4.2.3", "jest": "^25.1.0", "jest-circus": "^25.1.0", "prettier": "^1.19.1", - "ts-jest": "^25.1.0", + "ts-jest": "^25.2.0", "typescript": "^3.7.5" }, "husky": { diff --git a/src/configs/php.json b/src/configs/php.json new file mode 100644 index 00000000..1f0ee8b2 --- /dev/null +++ b/src/configs/php.json @@ -0,0 +1,29 @@ +{ + "problemMatcher": [ + { + "owner": "php_native_error", + "severity": "error", + "pattern": [ + { + "regexp": "^(.*error):\\s+\\s+(.+) in (.+) on line (\\d+)$", + "code": 1, + "message": 2, + "file": 3, + "line": 4 + } + ] + }, { + "owner": "php_native_warning", + "severity": "warning", + "pattern": [ + { + "regexp": "^(.*Warning|.*Deprecated|.*Notice):\\s+\\s+(.+) in (.+) on line (\\d+)$", + "code": 1, + "message": 2, + "file": 3, + "line": 4 + } + ] + } + ] +} diff --git a/src/coverage.ts b/src/coverage.ts index 74bc5ab8..f4fdb1af 100644 --- a/src/coverage.ts +++ b/src/coverage.ts @@ -54,7 +54,7 @@ export async function addCoveragePCOV( pipe: string ): Promise { let script = '\n'; - switch (version) { + switch (true) { default: script += (await extensions.addExtension('pcov', version, os_version, true)) + @@ -83,8 +83,8 @@ export async function addCoveragePCOV( ); // version is not supported break; - case '5.6': - case '7.0': + + case /5\.[3-6]|7\.0/.test(version): script += await utils.addLog( '$cross', 'pcov', diff --git a/src/extensions.ts b/src/extensions.ts index 86cb4144..62f68d13 100644 --- a/src/extensions.ts +++ b/src/extensions.ts @@ -18,21 +18,27 @@ export async function addExtensionDarwin( await utils.asyncForEach(extensions, async function(extension: string) { extension = extension.toLowerCase(); const version_extension: string = version + extension; - const [extension_name, stability]: string[] = extension.split('-'); - const prefix = await utils.getExtensionPrefix(extension_name); + const [ext_name, ext_version]: string[] = extension.split('-'); + const prefix = await utils.getExtensionPrefix(ext_name); let install_command = ''; switch (true) { // match pre-release versions case /.*-(beta|alpha|devel|snapshot)/.test(version_extension): script += '\nadd_unstable_extension ' + - extension_name + + ext_name + ' ' + - stability + + ext_version + ' ' + prefix; return; - case /5\.6xdebug/.test(version_extension): + case /5\.3xdebug/.test(version_extension): + install_command = 'sudo pecl install -f xdebug-2.2.7' + pipe; + break; + case /5\.4xdebug/.test(version_extension): + install_command = 'sudo pecl install -f xdebug-2.4.1' + pipe; + break; + case /5\.[5-6]xdebug/.test(version_extension): install_command = 'sudo pecl install -f xdebug-2.5.5' + pipe; break; case /7\.0xdebug/.test(version_extension): @@ -49,15 +55,14 @@ export async function addExtensionDarwin( pipe; break; case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension): - install_command = + script += 'sh ' + path.join(__dirname, '../src/scripts/ext/phalcon_darwin.sh') + ' ' + extension + ' ' + - version + - pipe; - break; + version; + return; default: install_command = 'sudo pecl install -f ' + extension + pipe; break; @@ -89,13 +94,27 @@ export async function addExtensionWindows( let script = '\n'; await utils.asyncForEach(extensions, async function(extension: string) { extension = extension.toLowerCase(); - const [extension_name, stability]: string[] = extension.split('-'); + const [ext_name, ext_version]: string[] = extension.split('-'); const version_extension: string = version + extension; + let matches: RegExpExecArray; switch (true) { // match pre-release versions case /.*-(beta|alpha|devel|snapshot)/.test(version_extension): - script += '\nAdd-Extension ' + extension_name + ' ' + stability; + script += '\nAdd-Extension ' + ext_name + ' ' + ext_version; break; + // match exact versions + case /.*-\d+\.\d+\.\d+$/.test(version_extension): + script += '\nAdd-Extension ' + ext_name + ' stable ' + ext_version; + return; + case /.*-(\d+\.\d+\.\d)+(beta|alpha|devel|snapshot)\d*/.test( + version_extension + ): + matches = /.*-(\d+\.\d+\.\d)+(beta|alpha|devel|snapshot)\d*/.exec( + version_extension + ) as RegExpExecArray; + script += + '\nAdd-Extension ' + ext_name + ' ' + matches[2] + ' ' + matches[1]; + return; // match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4 case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension): script += @@ -132,20 +151,24 @@ export async function addExtensionLinux( await utils.asyncForEach(extensions, async function(extension: string) { extension = extension.toLowerCase(); const version_extension: string = version + extension; - const [extension_name, stability]: string[] = extension.split('-'); - const prefix = await utils.getExtensionPrefix(extension_name); + const [ext_name, ext_version]: string[] = extension.split('-'); + const prefix = await utils.getExtensionPrefix(ext_name); let install_command = ''; switch (true) { // match pre-release versions case /.*-(beta|alpha|devel|snapshot)/.test(version_extension): script += '\nadd_unstable_extension ' + - extension_name + + ext_name + ' ' + - stability + + ext_version + ' ' + prefix; return; + // match exact versions + case /.*-\d+\.\d+\.\d+.*/.test(version_extension): + script += '\nadd_pecl_extension ' + ext_name + ' ' + ext_version; + return; // match 5.6gearman..7.4gearman case /^((5\.6)|(7\.[0-4]))gearman$/.test(version_extension): install_command = @@ -168,7 +191,7 @@ export async function addExtensionLinux( // match 7.0xdebug..7.4xdebug case /^7\.[0-4]xdebug$/.test(version_extension): script += - '\nupdate_extension xdebug 2.9.0' + + '\nupdate_extension xdebug 2.9.1' + pipe + '\n' + (await utils.addLog('$tick', 'xdebug', 'Enabled', 'linux')); diff --git a/src/install.ts b/src/install.ts index c908b8ec..9f6a214a 100644 --- a/src/install.ts +++ b/src/install.ts @@ -22,17 +22,15 @@ export async function build( // taking inputs const extension_csv: string = (await utils.getInput('extensions', false)) || - (await utils.getInput('extension', false)) || - (await utils.getInput('extension-csv', false)); - const ini_values_csv: string = - (await utils.getInput('ini-values', false)) || - (await utils.getInput('ini-values-csv', false)); + (await utils.getInput('extension', false)); + const ini_values_csv: string = await utils.getInput('ini-values', false); const coverage_driver: string = await utils.getInput('coverage', false); const pecl: string = await utils.getInput('pecl', false); let tools_csv: string = await utils.getInput('tools', false); if ( pecl == 'true' || - /.*-(beta|alpha|devel|snapshot).*/.test(extension_csv) + /.*-(beta|alpha|devel|snapshot).*/.test(extension_csv) || + /.*-(\d+\.\d+\.\d+).*/.test(extension_csv) ) { tools_csv = 'pecl, ' + tools_csv; } @@ -58,16 +56,17 @@ export async function build( */ export async function run(): Promise { try { - const os_version: string = process.platform; let version: string = await utils.getInput('php-version', true); version = version.length > 1 ? version.slice(0, 3) : version + '.0'; + const os_version: string = process.platform; + // check the os version and run the respective script let script_path = ''; switch (os_version) { case 'darwin': case 'linux': script_path = await build(os_version + '.sh', version, os_version); - await exec('sh ' + script_path + ' ' + version + ' ' + __dirname); + await exec('bash ' + script_path + ' ' + version + ' ' + __dirname); break; case 'win32': script_path = await build('win32.ps1', version, os_version); diff --git a/src/matchers.ts b/src/matchers.ts index 500f2101..03b1bfd8 100644 --- a/src/matchers.ts +++ b/src/matchers.ts @@ -6,13 +6,8 @@ import * as io from '@actions/io'; * Cache json files for problem matchers */ export async function addMatchers(): Promise { - const config_path = path.join( - __dirname, - '..', - 'src', - 'configs', - 'phpunit.json' - ); + const config_path = path.join(__dirname, '..', 'src', 'configs'); const runner_dir: string = await utils.getInput('RUNNER_TOOL_CACHE', false); - await io.cp(config_path, runner_dir); + await io.cp(path.join(config_path, 'phpunit.json'), runner_dir); + await io.cp(path.join(config_path, 'php.json'), runner_dir); } diff --git a/src/scripts/darwin.sh b/src/scripts/darwin.sh index d2972565..ca5a2ca8 100644 --- a/src/scripts/darwin.sh +++ b/src/scripts/darwin.sh @@ -29,12 +29,18 @@ add_extension() { 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" + echo "$prefix=$ext_dir/$extension.so" >>"$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" >/dev/null 2>&1 && add_log "$tick" "$extension" "Installed and enabled") || - add_log "$cross" "$extension" "Could not install $extension on PHP $semver" + if [[ "$version" =~ $old_versions ]]; then + (sudo port install php"$nodot_version"-"$extension" >/dev/null 2>&1 && add_log "$tick" "$extension" "Installed and enabled") || + (eval "$install_command" >/dev/null 2>&1 && echo "$prefix=$ext_dir/$extension.so" >>"$ini_file" && add_log "$tick" "$extension" "Installed and enabled") || + add_log "$cross" "$extension" "Could not install $extension on PHP $semver" + else + (eval "$install_command" >/dev/null 2>&1 && add_log "$tick" "$extension" "Installed and enabled") || + add_log "$cross" "$extension" "Could not install $extension on PHP $semver" + fi fi } @@ -96,12 +102,13 @@ add_tool() { if [ "$status_code" = "200" ]; then sudo chmod a+x "$tool_path" if [ "$tool" = "phive" ]; then - add_extension curl >/dev/null 2>&1 - add_extension mbstring >/dev/null 2>&1 - add_extension xml >/dev/null 2>&1 + add_extension curl "sudo pecl install -f curl" extension >/dev/null 2>&1 + add_extension mbstring "sudo pecl install -f mbstring" extension >/dev/null 2>&1 + add_extension xml "sudo pecl install -f xml" extension >/dev/null 2>&1 elif [ "$tool" = "cs2pr" ]; then sudo sed -i '' 's/exit(9)/exit(0)/' "$tool_path" - tr -d '\r' < "$tool_path" | sudo tee "$tool_path" >/dev/null 2>&1 + tr -d '\r' < "$tool_path" | sudo tee "$tool_path.tmp" >/dev/null 2>&1 && sudo mv "$tool_path.tmp" "$tool_path" + sudo chmod a+x "$tool_path" fi add_log "$tick" "$tool" "Added" else @@ -124,11 +131,13 @@ add_composer_tool() { # Function to configure PECL configure_pecl() { - for tool in pear pecl; do - sudo "$tool" config-set php_ini "$ini_file" >/dev/null 2>&1 - sudo "$tool" config-set auto_discover 1 >/dev/null 2>&1 - sudo "$tool" channel-update "$tool".php.net >/dev/null 2>&1 - done + if [[ ! "$version" =~ $old_versions ]]; then + for tool in pear pecl; do + sudo "$tool" config-set php_ini "$ini_file" >/dev/null 2>&1 + sudo "$tool" config-set auto_discover 1 >/dev/null 2>&1 + sudo "$tool" channel-update "$tool".php.net >/dev/null 2>&1 + done + fi } # Function to log PECL, it is installed along with PHP @@ -136,27 +145,81 @@ 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 +# Function to add PECL when macports is used +add_pecl_old() { + pecl_version='master' + if [ "$1" = "53" ]; then + pecl_version='v1.9.5' + fi + curl -o pear.phar -sSL https://github.com/pear/pearweb_phars/raw/$pecl_version/install-pear-nozlib.phar + sudo php pear.phar -d /opt/local/lib/php$1 -b /usr/local/bin && rm -rf pear.phar +} + +add_macports() { + uri=$(curl -sSL https://github.com/macports/macports-base/releases | grep -Eo "(\/.*Catalina.pkg)" | head -n 1) + curl -o port.pkg -sSL https://github.com"$uri" + sudo installer -pkg port.pkg -target / && rm -rf port.pkg +} + +sync_macports() { + while true; do + status=0 + sudo port sync || status=$? + if [[ "$status" -eq 0 ]]; then + break + fi + sleep 2 + done +} + +port_setup_php() { + sudo port install php$1 php$1-curl php$1-mbstring php$1-xmlrpc php$1-openssl php$1-opcache + sudo cp /opt/local/etc/php$1/php.ini-development /opt/local/etc/php$1/php.ini + sudo port select --set php php$1 + sudo ln -sf /opt/local/bin/* /usr/local/bin + add_pecl_old "$1" } # Variables tick="✓" cross="✗" version=$1 +nodot_version=${1/./} +old_versions="5.[3-5]" +existing_version=$(php-config --version | cut -c 1-3) +[[ -z "${update}" ]] && update='false' || update="${update}" -# Setup PHP and composer +# Setup PHP step_log "Setup PHP" -setup_php_and_composer +if [[ "$version" =~ $old_versions ]]; then + export PATH="/opt/local/bin:/opt/local/sbin:$PATH" + export TERM=xterm + step_log "Setup Macports" + add_macports >/dev/null 2>&1 + add_log "$tick" "Macports" "Installed" + sync_macports >/dev/null 2>&1 + add_log "$tick" "Macports" "Synced" + step_log "Setup PHP" + port_setup_php $nodot_version >/dev/null 2>&1 + status="Installed" +elif [ "$existing_version" != "$version" ] || [ "$update" = "true" ]; then + export HOMEBREW_NO_INSTALL_CLEANUP=TRUE >/dev/null 2>&1 + 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 + if [ "$update" = "true" ]; then + status="Updated to" + else + status="Installed" + fi +else + status="Found" +fi 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)" +echo "date.timezone=UTC" >>"$ini_file" +ext_dir=$(php -i | grep -Ei "extension_dir => /(usr|opt)" | sed -e "s|.*=> s*||") +sudo mkdir -p "$ext_dir" semver=$(php -v | head -n 1 | cut -f 2 -d ' ') -add_log "$tick" "PHP" "Installed PHP $semver" configure_pecl +add_log "$tick" "PHP" "$status PHP $semver" \ No newline at end of file diff --git a/src/scripts/ext/extensions.sh b/src/scripts/ext/extensions.sh deleted file mode 100644 index af88bcae..00000000 --- a/src/scripts/ext/extensions.sh +++ /dev/null @@ -1,15 +0,0 @@ -php_h="https://raw.githubusercontent.com/php/php-src/PHP-$2/main/php.h" -os=$(uname -s) -if [ "$os" = "Linux" ]; then - apiv=$(curl -sSL --retry 5 "$php_h" | grep "PHP_API_VERSION" | cut -d' ' -f 3) - dir="/usr/lib/php/$apiv" - sudo mkdir -p "$dir" && sudo chown -R "$USER":"$(id -g -n)" /usr/lib/php -elif [ "$os" = "Darwin" ]; then - apiv=$(curl -sSL --retry 5 "$php_h" | grep "PHP_API_VERSION" | cut -d' ' -f 3) - dir="/usr/local/lib/php/pecl/$apiv" -else - dir='C:\\tools\\php\\ext' -fi -hash=$(echo -n "$1" | openssl dgst -sha256 | cut -d ' ' -f 2) -echo "::set-output name=ext_dir::$dir" -echo "::set-output name=ext_hash::$hash" \ No newline at end of file diff --git a/src/scripts/ext/phalcon_darwin.sh b/src/scripts/ext/phalcon_darwin.sh index 8869c304..0297eed2 100644 --- a/src/scripts/ext/phalcon_darwin.sh +++ b/src/scripts/ext/phalcon_darwin.sh @@ -1,17 +1,43 @@ +# Function to log result of a operation +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 +} + +# Function to install phalcon +install_phalcon() { + ( + brew tap shivammathur/homebrew-phalcon >/dev/null 2>&1 + brew install phalcon@"$php_version"_"$extension_major" >/dev/null 2>&1 + sudo cp /usr/local/opt/psr@"$php_version"/psr.so "$ext_dir" >/dev/null 2>&1 + sudo cp /usr/local/opt/phalcon@"$php_version"_"$extension_major"/phalcon.so "$ext_dir" >/dev/null 2>&1 + add_log "$tick" "$extension" "Installed and enabled" + ) || add_log "$cross" "$extension" "Could not install $extension on PHP $semver" +} + +tick="✓" +cross="✗" extension=$1 extension_major=${extension: -1} php_version=$2 +semver=$(php -v | head -n 1 | cut -f 2 -d ' ') ini_file=$(php -d "date.timezone=UTC" --ini | grep "Loaded Configuration" | sed -e "s|.*:s*||" | sed "s/ //g") ext_dir=$(php -i | grep "extension_dir => /usr" | sed -e "s|.*=> s*||") if [ -e "$ext_dir/psr.so" ] && [ -e "$ext_dir/phalcon.so" ]; then - echo "extension=psr" >>"$ini_file" - echo "extension=phalcon" >>"$ini_file" - phalcon_version=$(php -d="extension=phalcon" -r "echo phpversion('phalcon');" | cut -d'.' -f 1) + phalcon_version=$(php -d="extension=psr.so" -d="extension=phalcon.so" -r "echo phpversion('phalcon');" | cut -d'.' -f 1) if [ "$phalcon_version" != "$extension_major" ]; then - brew tap shivammathur/homebrew-phalcon - brew install phalcon@"$php_version"_"$extension_major" + install_phalcon + else + echo "extension=psr.so" >>"$ini_file" + echo "extension=phalcon.so" >>"$ini_file" + add_log "$tick" "$extension" "Enabled" fi else - brew tap shivammathur/homebrew-phalcon - brew install phalcon@"$php_version"_"$extension_major" -fi \ No newline at end of file + install_phalcon +fi diff --git a/src/scripts/linux.sh b/src/scripts/linux.sh index e75e88f5..aa9400f9 100644 --- a/src/scripts/linux.sh +++ b/src/scripts/linux.sh @@ -19,11 +19,17 @@ add_log() { # Function to update php ppa update_ppa() { if [ "$ppa_updated" = "false" ]; then - 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 - ppa_updated="true" + if [[ "$version" =~ $old_versions ]]; then + ppa="dotdeb-ubuntu-php*.list" + else + ppa="ondrej-ubuntu-php*.list" + fi + find /etc/apt/sources.list.d -type f -name "$ppa" -exec sudo "$debconf_fix" apt-fast update -o Dir::Etc::sourcelist="{}" ';' >/dev/null 2>&1 + echo "true" fi } +# Function to configure PECL configure_pecl() { if [ "$pecl_config" = "false" ] && [ -e /usr/bin/pecl ]; then for tool in pear pecl; do @@ -53,15 +59,18 @@ add_extension() { extension=$1 install_command=$2 prefix=$3 + if [[ "$version" =~ $old_versions ]]; then + install_command="ppa_updated=$(update_ppa) && ${install_command/5\.[4-5]-$extension/5-$extension=$release_version}" + fi if ! php -m | grep -i -q -w "$extension" && [ -e "$ext_dir/$extension.so" ]; then # shellcheck disable=SC2046 - $apt_install $(apt-cache depends php"$version"-"$extension" | awk '/Depends:/{print$2}') >/dev/null 2>&1 - echo "$prefix=$extension" >>"$ini_file" && add_log "$tick" "$extension" "Enabled" + $apt_install $(apt-cache depends php"$version"-"$extension" 2>/dev/null | awk '/Depends:/{print$2}') >/dev/null 2>&1 + echo "$prefix=$extension.so" >>"$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") || + (eval "$install_command" >/dev/null 2>&1 && add_log "$tick" "$extension" "Installed and enabled") || + (ppa_updated=$(update_ppa) && eval "$install_command" >/dev/null 2>&1 && add_log "$tick" "$extension" "Installed and enabled") || (sudo pecl install -f "$extension" >/dev/null 2>&1 && add_log "$tick" "$extension" "Installed and enabled") || add_log "$cross" "$extension" "Could not install $extension on PHP $semver" fi @@ -72,7 +81,7 @@ add_extension() { delete_extension() { extension=$1 sudo sed -i "/$extension/d" "$ini_file" - sudo rm -rf /etc/php/"$version"/cli/conf.d/*"$extension"* >/dev/null 2>&1 + sudo rm -rf "$scan_dir"/*"$extension"* >/dev/null 2>&1 sudo rm -rf "$ext_dir"/"$extension".so >/dev/null 2>&1 } @@ -89,6 +98,7 @@ remove_extension() { add_pecl_extension() { extension=$1 pecl_version=$2 + delete_extension "$extension" (sudo pecl install -f "$extension-$pecl_version" >/dev/null 2>&1 && add_log "$tick" "$extension" "Installed and enabled") || add_log "$cross" "$extension" "Could not install $extension-$pecl_version on PHP $semver" @@ -103,7 +113,7 @@ add_unstable_extension() { if ! php -m | grep -i -q -w "$extension" && [ -e "$ext_dir/$extension.so" ]; then extension_version=$(php -d="$prefix=$extension" -r "echo phpversion('$extension');") if [ "$extension_version" = "$pecl_version" ]; then - echo "$prefix=$extension" >>"$ini_file" && add_log "$tick" "$extension" "Enabled" + echo "$prefix=$extension.so" >>"$ini_file" && add_log "$tick" "$extension" "Enabled" else delete_extension "$extension" add_pecl_extension "$extension" "$pecl_version" @@ -130,7 +140,7 @@ update_extension() { if [ "$final_version" != "$current_version" ]; then version_exists=$(apt-cache policy -- *"$extension" | grep "$final_version") if [ -z "$version_exists" ]; then - update_ppa + ppa_updated=$(update_ppa) fi $apt_install php"$version"-"$extension" fi @@ -152,9 +162,9 @@ add_tool() { elif [ "$tool" = "cs2pr" ]; then sudo sed -i 's/\r$//; s/exit(9)/exit(0)/' "$tool_path" elif [ "$tool" = "phive" ]; then - add_extension curl >/dev/null 2>&1 - add_extension mbstring >/dev/null 2>&1 - add_extension xml >/dev/null 2>&1 + add_extension curl "$apt_install php$version-curl" extension >/dev/null 2>&1 + add_extension mbstring "$apt_install php$version-mbstring" extension >/dev/null 2>&1 + add_extension xml "$apt_install php$version-xml" extension >/dev/null 2>&1 fi add_log "$tick" "$tool" "Added" else @@ -190,13 +200,29 @@ setup_master() { 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 + curl -SLO https://dl.bintray.com/shivammathur/php/"$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 PHP 5.3, PHP 5.4 and PHP 5.5 +setup_old_versions() { + ( + cd /tmp || exit + curl -SLO https://dl.bintray.com/shivammathur/php/php-"$version".tar.xz >/dev/null 2>&1 + sudo tar xf php-"$version".tar.xz >/dev/null 2>&1 + cd php-"$version" || exit + sudo chmod a+x ./*.sh + ./install.sh >/dev/null 2>&1 + ./post-install.sh >/dev/null 2>&1 + ) + sudo rm -rf /tmp/php-"$version" + configure_pecl + release_version=$(php -v | head -n 1 | cut -d' ' -f 2) +} + # Function to setup PECL add_pecl() { add_devtools @@ -222,46 +248,60 @@ cross="✗" ppa_updated="false" pecl_config="false" version=$1 -apt_install="sudo DEBIAN_FRONTEND=noninteractive apt-fast install -y" +old_versions="5.[4-5]" +debconf_fix="DEBIAN_FRONTEND=noninteractive" +apt_install="sudo $debconf_fix apt-fast install -y" existing_version=$(php-config --version | cut -c 1-3) +[[ -z "${update}" ]] && update='false' || update="${update}" # Setup PHP step_log "Setup PHP" -sudo mkdir -p /var/run -sudo mkdir -p /run/php +sudo mkdir -p /var/run /run/php if [ "$existing_version" != "$version" ]; then if [ ! -e "/usr/bin/php$version" ]; then - update_ppa if [ "$version" = "8.0" ]; then setup_master + elif [[ "$version" =~ $old_versions ]] || [ "$version" = "5.3" ]; then + setup_old_versions else + version_exists=$(apt-cache policy -- php"$version" | grep "$version") + if [ -z "$version_exists" ]; then + ppa_updated=$(update_ppa) + fi $apt_install php"$version" php"$version"-curl php"$version"-mbstring php"$version"-xml >/dev/null 2>&1 fi - status="installed" + status="Installed" else - status="switched" + if [ "$update" = "true" ]; then + $apt_install php"$version" >/dev/null 2>&1 + status="Updated to" + else + status="Switched to" + fi fi - switch_version - - if [ "$version" = "8.0" ]; then - semver=$(php -v | head -n 1 | cut -f 2 -d ' ') - else - semver=$(php -v | head -n 1 | cut -f 2 -d ' ' | cut -f 1 -d '-') + # PHP 5.3 is switched by install script, for rest switch_version + if [ "$version" != "5.3" ]; then + switch_version fi - if [ "$status" != "switched" ]; then - status="Installed PHP $semver" - else - status="Switched to PHP $semver" - fi else - semver=$(php -v | head -n 1 | cut -f 2 -d ' ' | cut -f 1 -d '-') - status="PHP $semver Found" + if [ "$update" = "true" ]; then + $apt_install php"$version" >/dev/null 2>&1 + status="Updated to" + else + status="Found" + fi +fi + +semver=$(php -v | head -n 1 | cut -f 2 -d ' ') +if [ ! "$version" = "8.0" ]; then + semver=$(echo "$semver" | cut -f 1 -d '-') fi ini_file=$(php --ini | grep "Loaded Configuration" | sed -e "s|.*:s*||" | sed "s/ //g") -ext_dir=$(php -i | grep "extension_dir => /usr" | sed -e "s|.*=> s*||") +ext_dir=$(php -i | grep "extension_dir => /" | sed -e "s|.*=> s*||") +scan_dir=$(php --ini | grep additional | sed -e "s|.*: s*||") sudo chmod 777 "$ini_file" -add_log "$tick" "PHP" "$status" +add_log "$tick" "PHP" "$status PHP $semver" diff --git a/src/scripts/win32.ps1 b/src/scripts/win32.ps1 index 082fbe94..6f990a6b 100644 --- a/src/scripts/win32.ps1 +++ b/src/scripts/win32.ps1 @@ -31,7 +31,12 @@ Function Add-Extension { [ValidateNotNull()] [ValidateSet('stable', 'beta', 'alpha', 'devel', 'snapshot')] [string] - $mininum_stability = 'stable' + $mininum_stability = 'stable', + [Parameter(Position = 2, Mandatory = $false)] + [ValidateNotNull()] + [ValidatePattern('^\d+(\.\d+){0,2}$')] + [string] + $extension_version = '' ) try { $extension_info = Get-PhpExtension -Path $php_dir | Where-Object { $_.Name -eq $extension -or $_.Handle -eq $extension } @@ -50,7 +55,12 @@ Function Add-Extension { } } else { - Install-PhpExtension -Extension $extension -MinimumStability $mininum_stability -Path $php_dir + if($extension_version -ne '') { + Install-PhpExtension -Extension $extension -Version $extension_version -MinimumStability $mininum_stability -Path $php_dir + } else { + Install-PhpExtension -Extension $extension -MinimumStability $mininum_stability -Path $php_dir + } + Add-Log $tick $extension "Installed and enabled" } } @@ -91,10 +101,7 @@ Function Add-Tool() { if (Test-Path $php_dir\$tool) { Remove-Item $php_dir\$tool } - if ($tool -eq "composer") { - Install-Composer -Scope System -Path $php_dir -PhpPath $php_dir - composer -q global config process-timeout 0 - } elseif ($tool -eq "symfony") { + if ($tool -eq "symfony") { Invoke-WebRequest -UseBasicParsing -Uri $url -OutFile $php_dir\$tool.exe Add-Content -Path $PsHome\profile.ps1 -Value "New-Alias $tool $php_dir\$tool.exe" > $null 2>&1 } else { @@ -113,9 +120,10 @@ Function Add-Tool() { Add-Extension curl >$null 2>&1 Add-Extension mbstring >$null 2>&1 Add-Extension xml >$null 2>&1 - } - if($tool -eq "cs2pr") { + } elseif($tool -eq "cs2pr") { (Get-Content $php_dir/cs2pr).replace('exit(9)', 'exit(0)') | Set-Content $php_dir/cs2pr + } elseif($tool -eq "composer") { + composer -q global config process-timeout 0 } if (((Get-ChildItem -Path $php_dir/* | Where-Object Name -Match "^$tool(.exe|.phar)*$").Count -gt 0)) { Add-Log $tick $tool "Added" @@ -194,15 +202,22 @@ if ($null -eq $installed -or -not("$($installed.Version).".StartsWith(($version Install-Php -Version $version -Architecture $arch -ThreadSafe $ts -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) { + if((Test-Path env:update) -and $env:update -eq 'true') { + Update-Php $php_dir > $null 2>&1 + $status = "Updated to" + } else { $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 +if($version -lt "5.5") { + Add-Extension openssl >$null 2>&1 + Add-Extension curl >$null 2>&1 +} else { + Enable-PhpExtension -Extension openssl, curl, opcache -Path $php_dir +} Update-PhpCAInfo -Path $php_dir -Source CurrentUser if ($version -eq 'master') { if($installed.ThreadSafe) { diff --git a/src/tools.ts b/src/tools.ts index 0b816983..69b0fcff 100644 --- a/src/tools.ts +++ b/src/tools.ts @@ -138,23 +138,15 @@ export async function getUri( * 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 { - 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('/'); - } + return ['releases', version, suffix, 'codecept.phar'] + .filter(Boolean) + .join('/'); } /** @@ -167,19 +159,55 @@ export async function getCodeceptionUri( version: string, php_version: string ): Promise { + const codecept: string = await getCodeceptionUriBuilder(version, ''); + const codecept54: string = await getCodeceptionUriBuilder(version, 'php54'); + const codecept56: string = await getCodeceptionUriBuilder(version, 'php56'); + // Refer to https://codeception.com/builds switch (true) { case /latest/.test(version): switch (true) { - case /^5\.6$|^7\.[0|1]$/.test(php_version): + case /5\.6|7\.[0|1]/.test(php_version): return 'php56/codecept.phar'; - case /^7\.[2-4]$/.test(php_version): + 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'); + case /(^[4-9]|\d{2,})\..*/.test(version): + switch (true) { + case /5\.6|7\.[0|1]/.test(php_version): + return codecept56; + case /7\.[2-4]/.test(php_version): + default: + return codecept; + } + case /(^2\.[4-5]\.\d+|^3\.[0-1]\.\d+).*/.test(version): + switch (true) { + case /5\.6/.test(php_version): + return codecept54; + case /7\.[0-4]/.test(php_version): + default: + return codecept; + } + case /^2\.3\.\d+.*/.test(version): + switch (true) { + case /5\.[4-6]/.test(php_version): + return codecept54; + case /^7\.[0-4]$/.test(php_version): + default: + return codecept; + } + case /(^2\.(1\.([6-9]|\d{2,}))|^2\.2\.\d+).*/.test(version): + switch (true) { + case /5\.[4-5]/.test(php_version): + return codecept54; + case /5.6|7\.[0-4]/.test(php_version): + default: + return codecept; + } + case /(^2\.(1\.[0-5]|0\.\d+)|^1\.[6-8]\.\d+).*/.test(version): + return codecept; default: - return await getCodeceptionUriBuilder(version, php_version, 'php54'); + return await codecept; } } diff --git a/update.zip b/update.zip deleted file mode 100644 index f4bdf08b..00000000 Binary files a/update.zip and /dev/null differ