Skip to content

Commit

Permalink
Merge pull request #156 from shivammathur/develop
Browse files Browse the repository at this point in the history
1.7.4
  • Loading branch information
shivammathur authored Jan 21, 2020
2 parents 8489dbf + 4733517 commit 4f0d810
Show file tree
Hide file tree
Showing 26 changed files with 371 additions and 143 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/experimental-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
strategy:
fail-fast: false
matrix:
operating-system: [ubuntu-latest, windows-latest, macOS-latest]
operating-system: [ubuntu-latest, windows-latest, macos-latest]
php-versions: ['8.0']
steps:
- name: Checkout
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
strategy:
fail-fast: false
matrix:
operating-system: [ubuntu-latest, windows-latest, macOS-latest]
operating-system: [ubuntu-latest, windows-latest, macos-latest]
php-versions: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4']
steps:
- name: Checkout
Expand Down
32 changes: 28 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ Setup PHP with required extensions, php.ini configuration, code-coverage support
- [Usage](#memo-usage)
- [Basic Setup](#basic-setup)
- [Matrix Setup](#matrix-setup)
- [Experimental Setup](#experimental-setup)
- [Experimental Setup](#experimental-setup)
- [Thread Safe Setup](#thread-safe-setup)
- [Cache dependencies](#cache-dependencies)
- [Problem Matchers](#problem-matchers)
- [Examples](#examples)
Expand Down Expand Up @@ -59,7 +60,7 @@ Setup PHP with required extensions, php.ini configuration, code-coverage support
|Windows Server 2019|`windows-latest` or `windows-2019`|
|Ubuntu 18.04|`ubuntu-latest` or `ubuntu-18.04`|
|Ubuntu 16.04|`ubuntu-16.04`|
|macOS X Catalina 10.15|`macOS-latest` or `macOS-10.15`|
|macOS X Catalina 10.15|`macos-latest` or `macOS-10.15`|

## :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.
Expand All @@ -72,7 +73,7 @@ Setup PHP with required extensions, php.ini configuration, code-coverage support

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

`codeception`, `composer`, `composer-prefetcher`, `deployer`, `pecl`, `phinx`, `phpcbf`, `phpcpd`, `php-config`, `php-cs-fixer`, `phpcs`, `phpize`, `phpmd`, `phpstan`, `phpunit`, `prestissimo`, `psalm`
`codeception`, `composer`, `composer-prefetcher`, `deployer`, `pecl`, `phinx`, `phive`, `phpcbf`, `phpcpd`, `php-config`, `php-cs-fixer`, `phpcs`, `phpize`, `phpmd`, `phpstan`, `phpunit`, `prestissimo`, `psalm`

```yaml
uses: shivammathur/setup-php@v1
Expand Down Expand Up @@ -184,7 +185,7 @@ jobs:
runs-on: ${{ matrix.operating-system }}
strategy:
matrix:
operating-system: [ubuntu-latest, windows-latest, macOS-latest]
operating-system: [ubuntu-latest, windows-latest, macos-latest]
php-versions: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4']
name: PHP ${{ matrix.php-versions }} Test on ${{ matrix.operating-system }}
steps:
Expand Down Expand Up @@ -226,6 +227,29 @@ steps:
tools: php-cs-fixer, phpunit #optional, setup tools globally
```

### Thread Safe Setup

- `NTS` versions are setup by default.
- On `ubuntu` and `macOS` only NTS versions are supported.
- On `windows` both `TS` and `NTS` versions are supported.

```yaml
jobs:
run:
runs-on: windows-latest
name: Setup PHP TS on Windows
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup PHP
uses: shivammathur/setup-php@v1
with:
php-version: '7.4'
env:
PHPTS: ts # specify ts or nts
```

### Cache 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.
Expand Down
31 changes: 15 additions & 16 deletions __tests__/extensions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,30 +41,21 @@ describe('Extension tests', () => {
linux = await extensions.addExtension('gearman', '7.1', 'linux');
expect(linux).toContain('gearman.sh 7.1');

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

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

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

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');
});

it('checking addExtensionOnDarwin', async () => {
Expand Down Expand Up @@ -103,6 +94,14 @@ describe('Extension tests', () => {
darwin = await extensions.addExtension('redis', '7.2', 'darwin');
expect(darwin).toContain('sudo 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 imagick');

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

darwin = await extensions.addExtension(
'does_not_exist',
'7.2',
Expand Down
30 changes: 27 additions & 3 deletions __tests__/tools.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,18 @@ describe('Tools tests', () => {
);
});

it('checking addPhive', async () => {
let script: string = await tools.addPhive('1.2.3', 'linux');
expect(script).toContain(
'add_tool https://github.com/phar-io/phive/releases/download/1.2.3/phive-1.2.3.phar phive'
);

script = await tools.addPhive('latest', 'win32');
expect(script).toContain(
'Add-Tool https://phar.io/releases/phive.phar phive'
);
});

it('checking getPhpunitUri', async () => {
expect(await tools.getPhpunitUrl('tool', 'latest')).toBe(
'https://phar.phpunit.de/tool.phar'
Expand Down Expand Up @@ -289,7 +301,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, php-config, phpize',
'php-cs-fixer, phpstan, phpunit, pecl, phinx, phinx:1.2.3, phive, php-config, phpize',
'7.4',
'linux'
);
Expand All @@ -302,6 +314,9 @@ describe('Tools tests', () => {
expect(script).toContain(
'add_tool https://github.com/phpstan/phpstan/releases/latest/download/phpstan.phar phpstan'
);
expect(script).toContain(
'add_tool https://phar.io/releases/phive.phar phive'
);
expect(script).toContain(
'add_tool https://phar.phpunit.de/phpunit.phar phpunit'
);
Expand All @@ -314,7 +329,7 @@ describe('Tools tests', () => {
});
it('checking addTools on darwin', async () => {
const script: string = await tools.addTools(
'phpcs, phpcbf, phpcpd, phpmd, psalm, phinx, composer-prefetcher:1.2.3, phpize, php-config',
'phpcs, phpcbf, phpcpd, phpmd, psalm, phinx, phive:1.2.3, composer-prefetcher:1.2.3, phpize, php-config',
'7.4',
'darwin'
);
Expand All @@ -337,6 +352,9 @@ describe('Tools tests', () => {
'https://github.com/vimeo/psalm/releases/latest/download/psalm.phar psalm'
);
expect(script).toContain('add_composer_tool phinx phinx robmorgan/');
expect(script).toContain(
'add_tool https://github.com/phar-io/phive/releases/download/1.2.3/phive-1.2.3.phar phive'
);
expect(script).toContain(
'add_composer_tool composer-prefetcher composer-prefetcher:1.2.3 narrowspark/automatic-'
);
Expand All @@ -345,7 +363,7 @@ describe('Tools tests', () => {
});
it('checking addTools on windows', async () => {
const script: string = await tools.addTools(
'codeception, deployer, prestissimo, phpmd, phinx, php-config, phpize, does_not_exit',
'codeception, deployer, prestissimo, phpmd, phinx, phive:0.13.2, php-config, phpize, does_not_exit',
'7.4',
'win32'
);
Expand All @@ -358,7 +376,13 @@ describe('Tools tests', () => {
expect(script).toContain(
'Add-Composer-Tool prestissimo prestissimo hirak/'
);
expect(script).toContain(
'Add-Tool https://github.com/phpmd/phpmd/releases/latest/download/phpmd.phar phpmd'
);
expect(script).toContain('Add-Composer-Tool phinx phinx robmorgan/');
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('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
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: 'Setup PHP Action'
author: shivammathur
description: 'GitHub action to setup PHP with required extensions, php.ini configuration, code-coverage support and composer'
description: 'Setup PHP in GitHub Actions with required extensions, php.ini configuration, code-coverage support and various tools like composer'
branding:
color: 'purple'
inputs:
Expand Down
54 changes: 43 additions & 11 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1731,6 +1731,31 @@ function getCodeceptionUri(version, php_version) {
});
}
exports.getCodeceptionUri = getCodeceptionUri;
/**
* Helper function to get script to setup phive
*
* @param tool
* @param version
* @param url
* @param os_version
*/
function addPhive(version, os_version) {
return __awaiter(this, void 0, void 0, function* () {
switch (version) {
case 'latest':
return ((yield getArchiveCommand(os_version)) +
'https://phar.io/releases/phive.phar phive');
default:
return ((yield getArchiveCommand(os_version)) +
'https://github.com/phar-io/phive/releases/download/' +
version +
'/phive-' +
version +
'.phar phive');
}
});
}
exports.addPhive = addPhive;
/**
* Function to get the PHPUnit url
*
Expand Down Expand Up @@ -1888,6 +1913,9 @@ function addTools(tools_csv, php_version, os_version) {
url = github + 'squizlabs/PHP_CodeSniffer/' + uri;
script += yield addArchive(tool, version, url, os_version);
break;
case 'phive':
script += yield addPhive(version, os_version);
break;
case 'phpstan':
url = github + 'phpstan/phpstan/' + uri;
script += yield addArchive(tool, version, url, os_version);
Expand Down Expand Up @@ -2577,6 +2605,13 @@ function addExtensionDarwin(extension_csv, version, pipe) {
case /5\.6redis/.test(version_extension):
install_command = 'sudo pecl install redis-2.2.8' + pipe;
break;
case /[5-9]\.\dimagick/.test(version_extension):
install_command =
'brew install pkg-config imagemagick' +
pipe +
' && sudo pecl install imagick' +
pipe;
break;
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
install_command =
'sh ' +
Expand Down Expand Up @@ -2668,26 +2703,23 @@ function addExtensionLinux(extension_csv, version, pipe) {
version +
pipe;
break;
// match 7.0xdebug..7.4xdebug
case /^7\.[0-4]xdebug$/.test(version_extension):
script +=
'\nupdate_extension xdebug 2.9.0' +
pipe +
'\n' +
(yield utils.addLog('$tick', 'xdebug', 'Enabled', 'linux'));
return;
// match 7.0phalcon3..7.3phalcon3 and 7.2phalcon4...7.4phalcon4
// match 7.0phalcon3...7.3phalcon3 or 7.2phalcon4...7.4phalcon4
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
script +=
'\nsh ' +
path.join(__dirname, '../src/scripts/ext/phalcon.sh') +
' ' +
extension +
' ' +
version +
version;
return;
// match 7.0xdebug..7.4xdebug
case /^7\.[0-4]xdebug$/.test(version_extension):
script +=
'\nupdate_extension xdebug 2.9.0' +
pipe +
'\n' +
(yield utils.addLog('$tick', extension, 'Installed and enabled', 'linux'));
(yield utils.addLog('$tick', 'xdebug', 'Enabled', 'linux'));
return;
default:
install_command =
Expand Down
2 changes: 1 addition & 1 deletion examples/cakephp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
tests:
strategy:
matrix:
operating-system: [ubuntu-latest, windows-latest, macOS-latest]
operating-system: [ubuntu-latest, windows-latest, macos-latest]
php-versions: ['7.2', '7.3', '7.4']
runs-on: ${{ matrix.operating-system }}
steps:
Expand Down
2 changes: 1 addition & 1 deletion examples/codeigniter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ jobs:
build:
strategy:
matrix:
operating-system: [ubuntu-latest, windows-latest, macOS-latest]
operating-system: [ubuntu-latest, windows-latest, macos-latest]
php-versions: ['7.2', '7.3', '7.4']
runs-on: ${{ matrix.operating-system }}
steps:
Expand Down
2 changes: 1 addition & 1 deletion examples/laravel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
strategy:
fail-fast: false
matrix:
operating-system: [ubuntu-latest, windows-latest, macOS-latest]
operating-system: [ubuntu-latest, windows-latest, macos-latest]
php-versions: ['7.2', '7.3', '7.4']
steps:
- name: Checkout
Expand Down
2 changes: 1 addition & 1 deletion examples/lumen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
strategy:
fail-fast: false
matrix:
operating-system: [ubuntu-latest, windows-latest, macOS-latest]
operating-system: [ubuntu-latest, windows-latest, macos-latest]
php-versions: ['7.2', '7.3', '7.4']
steps:
- name: Checkout
Expand Down
2 changes: 1 addition & 1 deletion examples/slim-framework.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ jobs:
build:
strategy:
matrix:
operating-system: [ubuntu-latest, windows-latest, macOS-latest]
operating-system: [ubuntu-latest, windows-latest, macos-latest]
php-versions: ['7.2', '7.3', '7.4']
runs-on: ${{ matrix.operating-system }}
steps:
Expand Down
2 changes: 1 addition & 1 deletion examples/symfony.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
strategy:
fail-fast: false
matrix:
operating-system: [ubuntu-latest, windows-latest, macOS-latest]
operating-system: [ubuntu-latest, windows-latest, macos-latest]
php-versions: ['7.3', '7.4']
steps:
- name: Checkout
Expand Down
2 changes: 1 addition & 1 deletion examples/zend-framework.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ jobs:
build:
strategy:
matrix:
operating-system: [ubuntu-latest, windows-latest, macOS-latest]
operating-system: [ubuntu-latest, windows-latest, macos-latest]
php-versions: ['7.2', '7.3', '7.4']
runs-on: ${{ matrix.operating-system }}
steps:
Expand Down
Loading

0 comments on commit 4f0d810

Please sign in to comment.