Skip to content

Commit

Permalink
Merge pull request shivammathur#167 from shivammathur/develop
Browse files Browse the repository at this point in the history
1.8.0
  • Loading branch information
shivammathur authored Jan 26, 2020
2 parents e01b2f0 + 4eeaf5f commit d384d9f
Show file tree
Hide file tree
Showing 16 changed files with 294 additions and 122 deletions.
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,14 @@ Setup PHP with required extensions, php.ini configuration, code-coverage support
- 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`.
- Extensions which cannot be installed gracefully leave an error message in the logs, the action is not interrupted.

## :wrench: Tools Support

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

`codeception`, `composer`, `composer-prefetcher`, `deployer`, `pecl`, `phinx`, `phive`, `phpcbf`, `phpcpd`, `php-config`, `php-cs-fixer`, `phpcs`, `phpize`, `phpmd`, `phpstan`, `phpunit`, `prestissimo`, `psalm`
`codeception`, `composer`, `composer-prefetcher`, `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
Expand Down Expand Up @@ -280,7 +281,7 @@ key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}

### Problem Matchers

You can setup problem matchers for your `PHPUnit` output. This will scan the errors in your tests and surface that information prominently in the GitHub Actions UI by creating annotations and log file decorations.
You can setup problem matchers for your `PHPUnit` output 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
Expand Down Expand Up @@ -327,10 +328,10 @@ Contributions are welcome! See [Contributor's Guide](.github/CONTRIBUTING.md "sh

If this action helped you.

- Please star the project and share it, this helps reach more people.
- If you blog, write about your experience using this.
- Support this project on <a href="https://www.patreon.com/shivammathur"><img alt="Patreon" src="https://shivammathur.com/badges/patreon.svg"></a> or using <a href="https://www.paypal.me/shivammathur"><img alt="Paypal" src="https://shivammathur.com/badges/paypal.svg"></a>.
- If you need any help using this, reach out here <a href="https://www.codementor.io/shivammathur?utm_source=github&utm_medium=button&utm_term=shivammathur&utm_campaign=github" title="Contact Shivam Mathur on Codementor"><img alt="Contact me on Codementor" src="https://cdn.codementor.io/badges/contact_me_github.svg"></a>
- Please star the project and share it with the community.
- If you blog, write about your experience while using this action.
- 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

Expand Down
2 changes: 1 addition & 1 deletion __tests__/coverage.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jest.mock('../src/extensions', () => ({

describe('Config tests', () => {
it('checking addCoverage with PCOV on windows', async () => {
let win32: string = await coverage.addCoverage('pcov', '7.4', 'win32');
let win32: string = await coverage.addCoverage('PCOV', '7.4', 'win32');
expect(win32).toContain('add_extension pcov');
expect(win32).toContain('Remove-Extension xdebug');

Expand Down
33 changes: 18 additions & 15 deletions __tests__/extensions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ import * as extensions from '../src/extensions';
describe('Extension tests', () => {
it('checking addExtensionOnWindows', async () => {
let win32: string = await extensions.addExtension(
'xdebug, pcov, phalcon4',
'xdebug, pcov, phalcon4, ast-beta',
'7.4',
'win32'
);
expect(win32).toContain('Add-Extension xdebug');
expect(win32).toContain('Add-Extension pcov');
expect(win32).toContain('phalcon.ps1 phalcon4');
expect(win32).toContain('Add-Extension ast beta');

win32 = await extensions.addExtension(
'phalcon3, does_not_exist',
Expand All @@ -26,15 +27,16 @@ describe('Extension tests', () => {

it('checking addExtensionOnLinux', async () => {
let linux: string = await extensions.addExtension(
'xdebug, pcov',
'xdebug, pcov, ast-beta',
'7.4',
'linux'
);
expect(linux).toContain('update_extension xdebug 2.9.0');
expect(linux).toContain(
'sudo DEBIAN_FRONTEND=noninteractive apt-get install -y php7.4-pcov'
);
expect(linux).toContain('pecl install pcov');
expect(linux).toContain('pecl install -f pcov');
expect(linux).toContain('install_extension ast-beta');

linux = await extensions.addExtension('gearman', '7.0', 'linux');
expect(linux).toContain('gearman.sh 7.0');
Expand All @@ -60,12 +62,13 @@ describe('Extension tests', () => {

it('checking addExtensionOnDarwin', async () => {
let darwin: string = await extensions.addExtension(
'xdebug, pcov',
'xdebug, pcov, ast-beta',
'7.2',
'darwin'
);
expect(darwin).toContain('sudo pecl install xdebug');
expect(darwin).toContain('sudo pecl install pcov');
expect(darwin).toContain('sudo pecl install -f xdebug');
expect(darwin).toContain('sudo pecl install -f pcov');
expect(darwin).toContain('install_extension ast-beta');

darwin = await extensions.addExtension('phalcon3', '7.0', 'darwin');
expect(darwin).toContain('phalcon_darwin.sh phalcon3 7.0');
Expand All @@ -74,33 +77,33 @@ describe('Extension tests', () => {
expect(darwin).toContain('phalcon_darwin.sh phalcon4 7.3');

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

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

darwin = await extensions.addExtension('xdebug', '5.6', 'darwin');
expect(darwin).toContain('sudo pecl install xdebug-2.5.5');
expect(darwin).toContain('sudo pecl install -f xdebug-2.5.5');

darwin = await extensions.addExtension('xdebug', '7.0', 'darwin');
expect(darwin).toContain('sudo pecl install xdebug-2.9.0');
expect(darwin).toContain('sudo pecl install -f xdebug-2.9.0');

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

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

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

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

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

darwin = await extensions.addExtension(
'does_not_exist',
Expand Down
2 changes: 1 addition & 1 deletion __tests__/matchers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe('Matchers', () => {

it('Test Regex', async () => {
const regex1 = /^\d+\)\s.*$/;
const regex2 = /^(.*)$/;
const regex2 = /^(.*Failed\sasserting\sthat.*)$/;
const regex3 = /^\s*$/;
const regex4 = /^(.*):(\d+)$/;
expect(regex1.test('1) Tests\\Test::it_tests')).toBe(true);
Expand Down
42 changes: 39 additions & 3 deletions __tests__/tools.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,30 @@ describe('Tools tests', () => {
).toStrictEqual(['composer', 'a', 'b']);
});

it('checking getSymfonyUri', async () => {
expect(await tools.getSymfonyUri('latest', 'linux')).toContain(
'releases/latest/download/symfony_linux_amd64'
);
expect(await tools.getSymfonyUri('1.2.3', 'linux')).toContain(
'releases/download/v1.2.3/symfony_linux_amd64'
);
expect(await tools.getSymfonyUri('latest', 'darwin')).toContain(
'releases/latest/download/symfony_darwin_amd64'
);
expect(await tools.getSymfonyUri('1.2.3', 'darwin')).toContain(
'releases/download/v1.2.3/symfony_darwin_amd64'
);
expect(await tools.getSymfonyUri('latest', 'win32')).toContain(
'releases/latest/download/symfony_windows_amd64'
);
expect(await tools.getSymfonyUri('1.2.3', 'win32')).toContain(
'releases/download/v1.2.3/symfony_windows_amd64'
);
expect(await tools.getSymfonyUri('1.2.3', 'fedora')).toContain(
'Platform fedora is not supported'
);
});

it('checking getCleanedToolsList', async () => {
const tools_list: string[] = await tools.getCleanedToolsList(
'tool, composer:1.2.3, robmorgan/phinx, hirak/prestissimo, narrowspark/automatic-composer-prefetcher'
Expand Down Expand Up @@ -301,7 +325,7 @@ describe('Tools tests', () => {

it('checking addTools on linux', async () => {
const script: string = await tools.addTools(
'php-cs-fixer, phpstan, phpunit, pecl, phinx, phinx:1.2.3, phive, php-config, phpize',
'php-cs-fixer, phpstan, phpunit, pecl, phinx, phinx:1.2.3, phive, php-config, phpize, symfony',
'7.4',
'linux'
);
Expand All @@ -320,6 +344,9 @@ describe('Tools tests', () => {
expect(script).toContain(
'add_tool https://phar.phpunit.de/phpunit.phar phpunit'
);
expect(script).toContain(
'add_tool https://github.com/symfony/cli/releases/latest/download/symfony_linux_amd64 symfony'
);
expect(script).toContain('add_pecl');
expect(script).toContain('add_composer_tool phinx phinx robmorgan/');
expect(script).toContain('add_composer_tool phinx phinx:1.2.3 robmorgan/');
Expand All @@ -329,7 +356,7 @@ describe('Tools tests', () => {
});
it('checking addTools on darwin', async () => {
const script: string = await tools.addTools(
'phpcs, phpcbf, phpcpd, phpmd, psalm, phinx, phive:1.2.3, composer-prefetcher:1.2.3, phpize, php-config',
'phpcs, phpcbf, phpcpd, phpmd, psalm, phinx, phive:1.2.3, composer-prefetcher:1.2.3, phpize, php-config, symfony, symfony:1.2.3',
'7.4',
'darwin'
);
Expand Down Expand Up @@ -358,12 +385,18 @@ describe('Tools tests', () => {
expect(script).toContain(
'add_composer_tool composer-prefetcher composer-prefetcher:1.2.3 narrowspark/automatic-'
);
expect(script).toContain(
'add_tool https://github.com/symfony/cli/releases/latest/download/symfony_darwin_amd64 symfony'
);
expect(script).toContain(
'add_tool https://github.com/symfony/cli/releases/download/v1.2.3/symfony_darwin_amd64 symfony'
);
expect(script).toContain('add_log "$tick" "phpize" "Added"');
expect(script).toContain('add_log "$tick" "php-config" "Added"');
});
it('checking addTools on windows', async () => {
const script: string = await tools.addTools(
'codeception, deployer, prestissimo, phpmd, phinx, phive:0.13.2, php-config, phpize, does_not_exit',
'codeception, deployer, prestissimo, phpmd, phinx, phive:0.13.2, php-config, phpize, symfony, does_not_exit',
'7.4',
'win32'
);
Expand All @@ -383,6 +416,9 @@ describe('Tools tests', () => {
expect(script).toContain(
'Add-Tool https://github.com/phar-io/phive/releases/download/0.13.2/phive-0.13.2.phar phive'
);
expect(script).toContain(
'Add-Tool https://github.com/symfony/cli/releases/latest/download/symfony_windows_amd64.exe symfony'
);
expect(script).toContain('phpize is not a windows tool');
expect(script).toContain('php-config is not a windows tool');
expect(script).toContain('Tool does_not_exit is not supported');
Expand Down
Loading

0 comments on commit d384d9f

Please sign in to comment.