Skip to content

Commit

Permalink
Merge pull request shivammathur#263 from shivammathur/develop
Browse files Browse the repository at this point in the history
2.4.1
  • Loading branch information
shivammathur authored Aug 3, 2020
2 parents 7961bc1 + 6d9aef8 commit 9dae796
Show file tree
Hide file tree
Showing 33 changed files with 1,600 additions and 1,547 deletions.
2 changes: 1 addition & 1 deletion .github/SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ The following versions of this project are supported for security updates.
| Version | Supported |
| ------- | ------------------ |
| 1.9.x | :white_check_mark: |
| 2.3.x | :white_check_mark: |
| 2.4.x | :white_check_mark: |

## Supported PHP Versions

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/node-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@ jobs:
- name: Send Coverage
continue-on-error: true
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 }}
run: curl -s https://codecov.io/bash | bash -s -- -t ${{secrets.CODECOV_TOKEN}} -f coverage/clover.xml -n github-actions-codecov-${{ matrix.operating-system }}
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ with:

These tools can be setup globally using the `tools` input.

`blackfire`, `blackfire-player`, `codeception`, `composer`, `composer-normalize`, `composer-prefetcher`, `composer-require-checker`, `composer-unused`, `cs2pr`, `deployer`, `flex`, `infection`, `pecl`, `phan`, `phinx`, `phive`, `phpcbf`, `phpcpd`, `php-config`, `php-cs-fixer`, `phpcs`, `phpize`, `phpmd`, `phpstan`, `phpunit`, `prestissimo`, `psalm`, `symfony`, `vapor-cli`
`blackfire`, `blackfire-player`, `codeception`, `composer`, `composer-normalize`, `composer-prefetcher`, `composer-require-checker`, `composer-unused`, `cs2pr`, `deployer`, `flex`, `grpc_php_plugin`, `infection`, `pecl`, `phan`, `phinx`, `phive`, `phpcbf`, `phpcpd`, `php-config`, `php-cs-fixer`, `phpcs`, `phpize`, `phpmd`, `phpstan`, `phpunit`, `prestissimo`, `protoc`, `psalm`, `symfony`, `vapor-cli`

```yaml
uses: shivammathur/setup-php@v2
Expand Down Expand Up @@ -544,7 +544,7 @@ If your project has node.js dependencies, you can persist npm's or yarn's cache

### Composer GitHub OAuth

If you have a number of workflows which setup multiple tools or have many composer dependencies, you might hit the GitHub's rate limit for composer. To avoid that you can add a `OAuth` token to the composer's config by setting `COMPOSER_TOKEN` environment variable. You can use [`GITHUB_TOKEN`](https://help.github.com/en/actions/configuring-and-managing-workflows/authenticating-with-the-github_token "GITHUB_TOKEN documentation") secret for this purpose.
If you have a number of workflows which setup multiple tools or have many composer dependencies, you might hit the GitHub's rate limit for composer. To avoid that you can add an `OAuth` token to the composer's config by setting `COMPOSER_TOKEN` environment variable. You can use [`GITHUB_TOKEN`](https://help.github.com/en/actions/configuring-and-managing-workflows/authenticating-with-the-github_token "GITHUB_TOKEN documentation") secret for this purpose.

```yaml
- name: Setup PHP
Expand Down Expand Up @@ -634,7 +634,7 @@ Examples of using `setup-php` with various PHP Frameworks and Packages.
## :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](#bookmark-dependencies "Dependencies for this PHP Action"). Their licenses can be found in their respective repositories.
- This project has multiple [dependencies](#package-dependencies "Dependencies for this PHP Action"). Their licenses can be found in their respective repositories.
- The logo for `setup-php` is a derivative work of [php.net logo](https://www.php.net/download-logos.php) and is licensed under the [CC BY-SA 4.0 License](https://creativecommons.org/licenses/by-sa/4.0/ "Creative Commons License").

## :+1: Contributions
Expand Down
97 changes: 41 additions & 56 deletions __tests__/extensions.test.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
import * as extensions from '../src/extensions';

describe('Extension tests', () => {
it('checking getXdebugVersion', async () => {
expect(await extensions.getXdebugVersion('5.3')).toContain('2.2.7');
expect(await extensions.getXdebugVersion('5.4')).toContain('2.4.1');
expect(await extensions.getXdebugVersion('5.5')).toContain('2.5.5');
expect(await extensions.getXdebugVersion('5.6')).toContain('2.5.5');
expect(await extensions.getXdebugVersion('7.0')).toContain('2.7.2');
expect(await extensions.getXdebugVersion('7.2')).toContain('2.9.6');
});
it('checking addExtensionOnWindows', async () => {
let win32: string = await extensions.addExtension(
'Xdebug, pcov, sqlite, :intl, phalcon4, ioncube, oci8, pdo_oci, ast-beta, grpc-1.2.3, inotify-1.2.3alpha2',
Expand All @@ -19,14 +11,19 @@ describe('Extension tests', () => {
expect(win32).toContain('Add-Extension pcov');
expect(win32).toContain('Add-Extension sqlite3');
expect(win32).toContain('Remove-Extension intl');
expect(win32).toContain('phalcon.ps1 phalcon4');
expect(win32).toContain('ioncube.ps1 7.4');
expect(win32).toContain('oci.ps1 oci8 7.4');
expect(win32).toContain('oci.ps1 pdo_oci 7.4');
expect(win32).toContain('Add-Phalcon phalcon4');
expect(win32).toContain('Add-Ioncube');
expect(win32).toContain('Add-OCI oci8');
expect(win32).toContain('Add-OCI pdo_oci');
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('pcov', '5.6', 'win32');
expect(win32).toContain(
'Add-Log "$cross" "pcov" "pcov is not supported on PHP 5.6"'
);

win32 = await extensions.addExtension('mysql', '7.4', 'win32');
expect(win32).toContain('Add-Extension mysqli');
expect(win32).toContain('Add-Extension mysqlnd');
Expand All @@ -46,17 +43,17 @@ describe('Extension tests', () => {
'win32',
true
);
expect(win32).toContain('phalcon.ps1 phalcon3');
expect(win32).toContain('Add-Phalcon phalcon3');
expect(win32).toContain('Add-Extension does_not_exist');

win32 = await extensions.addExtension('xdebug', '7.2', 'fedora');
expect(win32).toContain('Platform fedora is not supported');

win32 = await extensions.addExtension('blackfire', '7.3', 'win32');
expect(win32).toContain('blackfire.ps1 7.3 blackfire');
expect(win32).toContain('Add-Blackfire blackfire');

win32 = await extensions.addExtension('blackfire-1.31.0', '7.3', 'win32');
expect(win32).toContain('blackfire.ps1 7.3 blackfire-1.31.0');
expect(win32).toContain('Add-Blackfire blackfire-1.31.0');
});

it('checking addExtensionOnLinux', async () => {
Expand All @@ -65,7 +62,6 @@ describe('Extension tests', () => {
'7.4',
'linux'
);
expect(linux).toContain('update_extension xdebug 2.9.6');
expect(linux).toContain(
'add_extension_from_source xdebug xdebug/xdebug master --enable-xdebug zend_extension'
);
Expand All @@ -89,39 +85,35 @@ describe('Extension tests', () => {
'sudo $debconf_fix apt-get install -y php8.0-xdebug'
);

linux = await extensions.addExtension('gearman', '7.0', 'linux');
expect(linux).toContain('gearman.sh 7.0');
linux = await extensions.addExtension('gearman', '7.1', 'linux');
expect(linux).toContain('gearman.sh 7.1');

linux = await extensions.addExtension('gearman', '7.2', 'linux');
expect(linux).toContain('gearman.sh 7.2');

linux = await extensions.addExtension('gearman', '7.3', 'linux');
expect(linux).toContain('gearman.sh 7.3');
linux = await extensions.addExtension('pcov', '5.6', 'linux');
expect(linux).toContain(
'add_log "$cross" "pcov" "pcov is not supported on PHP 5.6"'
);

linux = await extensions.addExtension('gearman', '7.0', 'linux');
expect(linux).toContain('add_gearman');
linux = await extensions.addExtension('gearman', '7.4', 'linux');
expect(linux).toContain('gearman.sh 7.4');
expect(linux).toContain('add_gearman');

linux = await extensions.addExtension('xdebug', '7.2', 'fedora');
expect(linux).toContain('Platform fedora is not supported');

linux = await extensions.addExtension('phalcon3, phalcon4', '7.3', 'linux');
expect(linux).toContain('phalcon.sh phalcon3 7.3');
expect(linux).toContain('phalcon.sh phalcon4 7.3');
expect(linux).toContain('add_phalcon phalcon3');
expect(linux).toContain('add_phalcon phalcon4');

linux = await extensions.addExtension('ioncube', '7.3', 'linux');
expect(linux).toContain('ioncube.sh 7.3');
expect(linux).toContain('add_ioncube');

linux = await extensions.addExtension('oci8, pdo_oci', '7.3', 'linux');
expect(linux).toContain('oci.sh oci8 7.3');
expect(linux).toContain('oci.sh pdo_oci 7.3');
expect(linux).toContain('add_oci oci8');
expect(linux).toContain('add_oci pdo_oci');

linux = await extensions.addExtension('blackfire', '7.3', 'linux');
expect(linux).toContain('blackfire.sh 7.3 blackfire');
expect(linux).toContain('add_blackfire blackfire');

linux = await extensions.addExtension('blackfire-1.31.0', '7.3', 'linux');
expect(linux).toContain('blackfire.sh 7.3 blackfire-1.31.0');
expect(linux).toContain('add_blackfire blackfire-1.31.0');
});

it('checking addExtensionOnDarwin', async () => {
Expand All @@ -135,39 +127,32 @@ describe('Extension tests', () => {
expect(darwin).toContain('add_brew_extension grpc');
expect(darwin).toContain('add_brew_extension protobuf');
expect(darwin).toContain('add_brew_extension swoole');
expect(darwin).toContain('sudo pecl install -f sqlite3');
expect(darwin).toContain('pecl_install sqlite3');
expect(darwin).toContain('remove_extension intl');
expect(darwin).toContain('add_unstable_extension ast beta extension');
expect(darwin).toContain('add_pecl_extension grpc 1.2.3 extension');

darwin = await extensions.addExtension('phalcon3', '7.0', 'darwin');
expect(darwin).toContain('phalcon_darwin.sh phalcon3 7.0');
expect(darwin).toContain('add_phalcon phalcon3');

darwin = await extensions.addExtension('phalcon4', '7.3', 'darwin');
expect(darwin).toContain('phalcon_darwin.sh phalcon4 7.3');
expect(darwin).toContain('add_phalcon phalcon4');

darwin = await extensions.addExtension('ioncube', '7.3', 'darwin');
expect(darwin).toContain('ioncube.sh 7.3');
expect(darwin).toContain('add_ioncube');

darwin = await extensions.addExtension('oci8, pdo_oci', '7.3', 'darwin');
expect(darwin).toContain('oci.sh oci8 7.3');
expect(darwin).toContain('oci.sh pdo_oci 7.3');
expect(darwin).toContain('add_oci oci8');
expect(darwin).toContain('add_oci pdo_oci');

darwin = await extensions.addExtension('pcov', '5.6', 'darwin');
expect(darwin).toContain('sudo pecl install -f pcov');
expect(darwin).toContain(
'add_log "$cross" "pcov" "pcov is not supported on PHP 5.6"'
);

darwin = await extensions.addExtension('pcov', '7.2', 'darwin');
expect(darwin).toContain('add_brew_extension 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('add_brew_extension xdebug');

Expand All @@ -178,24 +163,24 @@ describe('Extension tests', () => {
expect(darwin).toContain('add_brew_extension xdebug');

darwin = await extensions.addExtension('redis', '5.6', 'darwin');
expect(darwin).toContain('sudo pecl install -f redis-2.2.8');
expect(darwin).toContain('pecl_install redis-2.2.8');

darwin = await extensions.addExtension('redis', '7.2', 'darwin');
expect(darwin).toContain('sudo pecl install -f redis');
expect(darwin).toContain('pecl_install redis');

darwin = await extensions.addExtension('imagick', '5.6', 'darwin');
expect(darwin).toContain('brew install pkg-config imagemagick');
expect(darwin).toContain('sudo pecl install -f imagick');
expect(darwin).toContain('pecl_install imagick');

darwin = await extensions.addExtension('imagick', '7.4', 'darwin');
expect(darwin).toContain('brew install pkg-config imagemagick');
expect(darwin).toContain('sudo pecl install -f imagick');
expect(darwin).toContain('pecl_install imagick');

darwin = await extensions.addExtension('blackfire', '7.3', 'darwin');
expect(darwin).toContain('blackfire_darwin.sh 7.3 blackfire');
expect(darwin).toContain('add_blackfire blackfire');

darwin = await extensions.addExtension('blackfire-1.31.0', '7.3', 'darwin');
expect(darwin).toContain('blackfire_darwin.sh 7.3 blackfire-1.31.0');
expect(darwin).toContain('add_blackfire blackfire-1.31.0');

darwin = await extensions.addExtension(
'does_not_exist',
Expand Down
19 changes: 18 additions & 1 deletion __tests__/tools.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -402,9 +402,20 @@ describe('Tools tests', () => {
expect(script).toContain('Platform fedora is not supported');
});

it('checking addCustomTool', async () => {
let script: string = await tools.addCustomTool('tool', '1.2.3', 'linux');
expect(script).toContain('tool.sh\nadd_tool 1.2.3');

script = await tools.addCustomTool('tool', '1.2.3', 'darwin');
expect(script).toContain('tool.sh\nadd_tool 1.2.3');

script = await tools.addCustomTool('tool', '1.2.3', 'win32');
expect(script).toContain('tool.ps1\nAdd-Tool 1.2.3');
});

it('checking addTools on linux', async () => {
const script: string = await tools.addTools(
'blackfire, blackfire-player, cs2pr, flex, php-cs-fixer, phplint, phpstan, phpunit, pecl, phinx, phinx:1.2.3, phive, php-config, phpize, symfony, wp-cli',
'blackfire, blackfire-player, cs2pr, flex, grpc_php_plugin, php-cs-fixer, phplint, phpstan, phpunit, pecl, phinx, phinx:1.2.3, phive, php-config, phpize, protoc, symfony, wp-cli',
'7.4',
'linux'
);
Expand Down Expand Up @@ -436,6 +447,8 @@ describe('Tools tests', () => {
expect(script).toContain(
'add_tool https://github.com/wp-cli/builds/blob/gh-pages/phar/wp-cli.phar?raw=true wp-cli'
);
expect(script).toContain('add_protoc latest');
expect(script).toContain('add_grpc_php_plugin latest');
expect(script).toContain('add_pecl');
expect(script).toContain('add_composertool flex flex symfony/');
expect(script).toContain('add_composertool phinx phinx robmorgan/');
Expand All @@ -455,6 +468,7 @@ describe('Tools tests', () => {
'composer-unused',
'cs2pr:1.2.3',
'flex',
'grpc_php_plugin:1.2.3',
'infection',
'phan',
'phan:2.7.2',
Expand All @@ -466,6 +480,7 @@ describe('Tools tests', () => {
'phpcs',
'phpize',
'phpmd',
'protoc:v1.2.3',
'psalm',
'symfony',
'symfony:1.2.3',
Expand Down Expand Up @@ -519,6 +534,8 @@ describe('Tools tests', () => {
expect(script).toContain(
'https://github.com/vimeo/psalm/releases/latest/download/psalm.phar psalm'
);
expect(script).toContain('add_grpc_php_plugin 1.2.3');
expect(script).toContain('add_protoc 1.2.3');
expect(script).toContain('add_composertool vapor-cli vapor-cli laravel/');
expect(script).toContain('add_composertool flex flex symfony/');
expect(script).toContain('add_composertool phinx phinx robmorgan/');
Expand Down
19 changes: 19 additions & 0 deletions __tests__/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,4 +167,23 @@ describe('Utils tests', () => {
'Platform fedora is not supported'
);
});

it('checking getUnsupportedLog', async () => {
expect(await utils.getUnsupportedLog('ext', '5.6', 'linux')).toContain(
'add_log "$cross" "ext" "ext is not supported on PHP 5.6"'
);
});

it('checking joins', async () => {
expect(await utils.joins('a', 'b', 'c')).toBe('a b c');
});

it('checking scriptExtension', async () => {
expect(await utils.scriptExtension('linux')).toBe('.sh');
expect(await utils.scriptExtension('darwin')).toBe('.sh');
expect(await utils.scriptExtension('win32')).toBe('.ps1');
expect(await utils.scriptExtension('fedora')).toContain(
'Platform fedora is not supported'
);
});
});
Loading

0 comments on commit 9dae796

Please sign in to comment.