Skip to content

Commit 241b510

Browse files
committed
Merge pull request #219 from shivammathur/develop
2.2.0
2 parents dccdb5a + dd070ac commit 241b510

21 files changed

+2591
-1249
lines changed

.prettierrc.json

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
{
2+
"arrowParens": "avoid",
3+
"bracketSpacing": false,
4+
"endOfLine": "auto",
5+
"parser": "typescript",
26
"printWidth": 80,
3-
"tabWidth": 2,
4-
"useTabs": false,
57
"semi": true,
68
"singleQuote": true,
9+
"tabWidth": 2,
710
"trailingComma": "none",
8-
"bracketSpacing": false,
9-
"arrowParens": "avoid",
10-
"parser": "typescript"
11-
}
11+
"useTabs": false
12+
}

README.md

Lines changed: 108 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ Setup PHP with required extensions, php.ini configuration, code-coverage support
3030
- [Basic Setup](#basic-setup)
3131
- [Matrix Setup](#matrix-setup)
3232
- [Experimental Setup](#experimental-setup)
33+
- [Self Hosted Setup](#self-hosted-setup)
34+
- [Local Testing Setup](#local-testing-setup)
3335
- [Thread Safe Setup](#thread-safe-setup)
3436
- [Force Update](#force-update)
3537
- [Verbose Setup](#verbose-setup)
@@ -47,18 +49,18 @@ Setup PHP with required extensions, php.ini configuration, code-coverage support
4749

4850
## :tada: PHP Support
4951

50-
|PHP Version|Stability|Release Support|
51-
|--- |--- |--- |
52-
|5.3|`Stable`|`End of life`|
53-
|5.4|`Stable`|`End of life`|
54-
|5.5|`Stable`|`End of life`|
55-
|5.6|`Stable`|`End of life`|
56-
|7.0|`Stable`|`End of life`|
57-
|7.1|`Stable`|`End of life`|
58-
|7.2|`Stable`|`Security fixes only`|
59-
|7.3|`Stable`|`Active`|
60-
|7.4|`Stable`|`Active`|
61-
|8.0|`Experimental`|`In development`|
52+
|PHP Version|Stability|Release Support|Runner Support|
53+
|--- |--- |--- |--- |
54+
|`5.3`|`Stable`|`End of life`|`GitHub`|
55+
|`5.4`|`Stable`|`End of life`|`GitHub`|
56+
|`5.5`|`Stable`|`End of life`|`GitHub`|
57+
|`5.6`|`Stable`|`End of life`|`GitHub`, `self-hosted`|
58+
|`7.0`|`Stable`|`End of life`|`GitHub`, `self-hosted`|
59+
|`7.1`|`Stable`|`End of life`|`GitHub`, `self-hosted`|
60+
|`7.2`|`Stable`|`Security fixes only`|`GitHub`, `self-hosted`|
61+
|`7.3`|`Stable`|`Active`|`GitHub`, `self-hosted`|
62+
|`7.4`|`Stable`|`Active`|`GitHub`, `self-hosted`|
63+
|`8.0`|`Experimental`|`In development`|`GitHub`, `self-hosted`|
6264

6365
**Note:** Specifying `8.0` in `php-version` input installs a nightly build of `PHP 8.0.0-dev` with `PHP JIT`, `Union Types v2` and other [new features](https://wiki.php.net/rfc#php_80 "New features implemented in PHP 8"). See [experimental setup](#experimental-setup) for more information.
6466

@@ -69,9 +71,13 @@ Setup PHP with required extensions, php.ini configuration, code-coverage support
6971
|Windows Server 2019|`windows-latest` or `windows-2019`|
7072
|Ubuntu 18.04|`ubuntu-latest` or `ubuntu-18.04`|
7173
|Ubuntu 16.04|`ubuntu-16.04`|
72-
|macOS X Catalina 10.15|`macos-latest` or `macos-10.15`|
74+
|MacOS X Catalina 10.15|`macos-latest` or `macos-10.15`|
75+
|Self Hosted|`self-hosted`|
76+
77+
**Note:** Refer to the [self-hosted setup](#self-hosted-setup) to use the action on self-hosted runners.
7378

7479
## :heavy_plus_sign: PHP Extension Support
80+
7581
- On `ubuntu` by default extensions which are available as a package can be installed. PECL extensions if not available as a package can be installed by specifying `pecl` in the tools input.
7682

7783
```yaml
@@ -108,15 +114,24 @@ with:
108114
extensions: xdebug-beta
109115
```
110116

111-
- Extensions which cannot be setup gracefully leave an error message in the logs, the action is not interrupted.
117+
- Non-default extensions can be removed by prefixing it with a `:`.
118+
119+
```yaml
120+
uses: shivammathur/setup-php@v2
121+
with:
122+
php-version: '7.4'
123+
extensions: :opcache
124+
```
125+
126+
- Extensions which cannot be added or removed gracefully leave an error message in the logs, the action is not interrupted.
112127

113128
- These extensions have custom support - `gearman` on ubuntu, `blackfire`, `phalcon3` and `phalcon4` on all supported OS.
114129

115130
## :wrench: Tools Support
116131

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

119-
`blackfire`, `blackfire-player`, `codeception`, `composer`, `composer-prefetcher`, `cs2pr`, `deployer`, `flex`, `pecl`, `phinx`, `phive`, `phpcbf`, `phpcpd`, `php-config`, `php-cs-fixer`, `phpcs`, `phpize`, `phpmd`, `phpstan`, `phpunit`, `prestissimo`, `psalm`, `symfony`
134+
`blackfire`, `blackfire-player`, `codeception`, `composer`, `composer-prefetcher`, `cs2pr`, `deployer`, `flex`, `infection`, `pecl`, `phinx`, `phive`, `phpcbf`, `phpcpd`, `php-config`, `php-cs-fixer`, `phpcs`, `phpize`, `phpmd`, `phpstan`, `phpunit`, `prestissimo`, `psalm`, `symfony`, `vapor-cli`
120135

121136
```yaml
122137
uses: shivammathur/setup-php@v2
@@ -140,7 +155,7 @@ with:
140155
- Specifying version for `composer` and `pecl` has no effect, latest versions of both tools which are compatible with the PHP version will be setup.
141156
- Both agent and client will be setup when `blackfire` is specified.
142157
- If the version specified for the tool is not in semver format, latest version of the tool will be setup.
143-
- Tools which cannot be installed gracefully leave an error message in the logs, the action is not interrupted.
158+
- Tools which cannot be setup gracefully leave an error message in the logs, the action is not interrupted.
144159

145160
## :signal_strength: Coverage support
146161

@@ -200,8 +215,9 @@ with:
200215

201216
#### `extensions` (optional)
202217

203-
- Specify the extensions you want to setup.
204-
- Accepts a `string` in csv-format. For example `mbstring, zip`.
218+
- Specify the extensions you want to add or remove.
219+
- Accepts a `string` in csv-format. For example `mbstring, :opcache`.
220+
- Non-default extensions prefixed with `:` are removed.
205221
- See [PHP extension support](#heavy_plus_sign-php-extension-support) for more info.
206222

207223
#### `ini-values` (optional)
@@ -294,11 +310,76 @@ steps:
294310
tools: php-cs-fixer, phpunit
295311
```
296312

313+
### Self Hosted Setup
314+
315+
> Setup PHP on a self-hosted runner.
316+
317+
- `PHP 5.6` and newer versions are supported on self-hosted runners.
318+
- `Windows 7` and newer, `Windows Server 2012 R2` and newer, `Ubuntu 18.04`, `Ubuntu 16.04` and `MacOS X Catalina 10.15` are supported.
319+
- To setup a dockerized self-hosted runner, refer to this [guide](https://github.com/shivammathur/setup-php/wiki/Dockerized-self-hosted-runner-on-Ubuntu) to setup in an `Ubuntu` container and refer to this [guide](https://github.com/shivammathur/setup-php/wiki/Dockerized-self-hosted-runner-on-Windows) to setup in a `Windows` container.
320+
- To setup the runner directly on the host OS or in a VM, follow this [requirements guide](https://github.com/shivammathur/setup-php/wiki/Requirements-for-self-hosted-runners "Requirements guide for self-hosted runner to run setup-php") before setting up the self-hosted runner.
321+
322+
Specify the environment variable `runner` with the value `self-hosted`. Without this your workflow will fail.
323+
324+
```yaml
325+
jobs:
326+
run:
327+
runs-on: self-hosted
328+
strategy:
329+
matrix:
330+
php-versions: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0']
331+
name: PHP ${{ matrix.php-versions }}
332+
steps:
333+
- name: Checkout
334+
uses: actions/checkout@v2
335+
336+
- name: Setup PHP
337+
uses: shivammathur/setup-php@v2
338+
with:
339+
php-version: ${{ matrix.php-versions }}
340+
env:
341+
runner: self-hosted # Specify the runner.
342+
```
343+
344+
### Local Testing Setup
345+
346+
> Test your `Ubuntu` workflow locally using [`nektos/act`](https://github.com/nektos/act "Project to test GitHub Actions locally").
347+
348+
```yaml
349+
jobs:
350+
run:
351+
runs-on: ubuntu-latest
352+
name: PHP 7.4 Test
353+
steps:
354+
- name: Checkout
355+
uses: actions/checkout@v2
356+
357+
- name: Setup PHP
358+
uses: shivammathur/setup-php@v2
359+
with:
360+
php-version: 7.4
361+
```
362+
363+
Run the workflow locally with `act` using [`shivammathur/node`](https://github.com/shivammathur/node-docker "Docker image to run setup-php") docker image.
364+
365+
```bash
366+
# For runs-on: ubuntu-latest
367+
act -P ubuntu-latest=shivammathur/node:latest
368+
369+
# For runs-on: ubuntu-18.04
370+
act -P ubuntu-18.04=shivammathur/node:latest
371+
372+
# For runs-on: ubuntu-16.04
373+
act -P ubuntu-16.04=shivammathur/node:xenial
374+
```
375+
297376
### Thread Safe Setup
298377

378+
> Setup both `TS` and `NTS` PHP on `Windows`.
379+
299380
- `NTS` versions are setup by default.
300-
- On `ubuntu` and `macOS` only `NTS` versions are supported.
301-
- On `windows` both `TS` and `NTS` versions are supported.
381+
- On `Ubuntu` and `macOS` only `NTS` versions are supported.
382+
- On `Windows` both `TS` and `NTS` versions are supported.
302383

303384
```yaml
304385
jobs:
@@ -314,11 +395,13 @@ jobs:
314395
with:
315396
php-version: '7.4'
316397
env:
317-
PHPTS: ts # specify ts or nts
398+
phpts: ts # specify ts or nts
318399
```
319400

320401
### Force Update
321402

403+
> Update to latest patch of PHP versions.
404+
322405
- Pre-installed PHP versions on the GitHub Actions runner are not updated to their latest patch release by default.
323406
- You can specify the `update` environment variable to `true` to force update to the latest release.
324407

@@ -333,6 +416,8 @@ jobs:
333416

334417
### Verbose Setup
335418

419+
> Debug your workflow
420+
336421
To debug any issues, you can use the `verbose` tag instead of `v2`.
337422

338423
```yaml
@@ -344,7 +429,7 @@ To debug any issues, you can use the `verbose` tag instead of `v2`.
344429

345430
### Cache Extensions
346431

347-
You can cache PHP extensions using [`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.
432+
You can cache PHP extensions using [`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 when cached are available in the next workflow run and are enabled directly. This reduces the workflow execution time.
348433

349434
```yaml
350435
runs-on: ${{ matrix.operating-system }}
@@ -382,7 +467,7 @@ steps:
382467
extensions: ${{ env.extensions }}
383468
```
384469

385-
**Note:** If you setup both `TS` and `NTS` PHP versions on `windows`, add `${{ env.PHPTS }}` to `key` and `restore-keys` inputs in `actions/cache` step.
470+
**Note:** If you setup both `TS` and `NTS` PHP versions on `windows`, add `${{ env.phpts }}` to `key` and `restore-keys` inputs in `actions/cache` step.
386471

387472
### Cache Composer Dependencies
388473

__tests__/extensions.test.ts

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@ import * as extensions from '../src/extensions';
33
describe('Extension tests', () => {
44
it('checking addExtensionOnWindows', async () => {
55
let win32: string = await extensions.addExtension(
6-
'Xdebug, pcov, sqlite, phalcon4, ast-beta, grpc-1.2.3, inotify-1.2.3alpha2',
6+
'Xdebug, pcov, sqlite, :intl, phalcon4, ast-beta, grpc-1.2.3, inotify-1.2.3alpha2',
77
'7.4',
88
'win32'
99
);
1010
expect(win32).toContain('Add-Extension xdebug');
1111
expect(win32).toContain('Add-Extension pcov');
1212
expect(win32).toContain('Add-Extension sqlite3');
13+
expect(win32).toContain('Remove-Extension intl');
1314
expect(win32).toContain('phalcon.ps1 phalcon4');
1415
expect(win32).toContain('Add-Extension ast beta');
1516
expect(win32).toContain('Add-Extension grpc stable 1.2.3');
@@ -41,15 +42,15 @@ describe('Extension tests', () => {
4142
expect(win32).toContain('Platform fedora is not supported');
4243

4344
win32 = await extensions.addExtension('blackfire', '7.3', 'win32');
44-
expect(win32).toContain('blackfire.ps1 7.3 1.31.0');
45+
expect(win32).toContain('blackfire.ps1 7.3 blackfire');
4546

4647
win32 = await extensions.addExtension('blackfire-1.31.0', '7.3', 'win32');
47-
expect(win32).toContain('blackfire.ps1 7.3 1.31.0');
48+
expect(win32).toContain('blackfire.ps1 7.3 blackfire-1.31.0');
4849
});
4950

5051
it('checking addExtensionOnLinux', async () => {
5152
let linux: string = await extensions.addExtension(
52-
'Xdebug, pcov, sqlite, ast, uopz, ast-beta, pdo_mysql, pdo-odbc, xdebug-alpha, grpc-1.2.3',
53+
'Xdebug, pcov, sqlite, :intl, ast, uopz, ast-beta, pdo_mysql, pdo-odbc, xdebug-alpha, grpc-1.2.3',
5354
'7.4',
5455
'linux'
5556
);
@@ -58,6 +59,7 @@ describe('Extension tests', () => {
5859
expect(linux).toContain(
5960
'sudo $debconf_fix apt-get install -y php7.4-sqlite3'
6061
);
62+
expect(linux).toContain('remove_extension intl');
6163
expect(linux).toContain('sudo $debconf_fix apt-get install -y php-ast');
6264
expect(linux).toContain('sudo $debconf_fix apt-get install -y php-uopz');
6365
expect(linux).toContain('add_unstable_extension ast beta extension');
@@ -90,21 +92,22 @@ describe('Extension tests', () => {
9092
expect(linux).toContain('phalcon.sh phalcon4 7.3');
9193

9294
linux = await extensions.addExtension('blackfire', '7.3', 'linux');
93-
expect(linux).toContain('blackfire.sh 7.3 1.31.0');
95+
expect(linux).toContain('blackfire.sh 7.3 blackfire');
9496

9597
linux = await extensions.addExtension('blackfire-1.31.0', '7.3', 'linux');
96-
expect(linux).toContain('blackfire.sh 7.3 1.31.0');
98+
expect(linux).toContain('blackfire.sh 7.3 blackfire-1.31.0');
9799
});
98100

99101
it('checking addExtensionOnDarwin', async () => {
100102
let darwin: string = await extensions.addExtension(
101-
'Xdebug, pcov, sqlite, ast-beta, grpc-1.2.3',
103+
'Xdebug, pcov, sqlite, :intl, ast-beta, grpc-1.2.3',
102104
'7.2',
103105
'darwin'
104106
);
105107
expect(darwin).toContain('sudo pecl install -f xdebug');
106108
expect(darwin).toContain('sudo pecl install -f pcov');
107109
expect(darwin).toContain('sudo pecl install -f sqlite3');
110+
expect(darwin).toContain('remove_extension intl');
108111
expect(darwin).toContain('add_unstable_extension ast beta extension');
109112
expect(darwin).toContain('add_pecl_extension grpc 1.2.3 extension');
110113

@@ -153,10 +156,10 @@ describe('Extension tests', () => {
153156
expect(darwin).toContain('sudo pecl install -f imagick');
154157

155158
darwin = await extensions.addExtension('blackfire', '7.3', 'darwin');
156-
expect(darwin).toContain('blackfire_darwin.sh 7.3 1.31.0');
159+
expect(darwin).toContain('blackfire_darwin.sh 7.3 blackfire');
157160

158161
darwin = await extensions.addExtension('blackfire-1.31.0', '7.3', 'darwin');
159-
expect(darwin).toContain('blackfire_darwin.sh 7.3 1.31.0');
162+
expect(darwin).toContain('blackfire_darwin.sh 7.3 blackfire-1.31.0');
160163

161164
darwin = await extensions.addExtension(
162165
'does_not_exist',

__tests__/tools.test.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ describe('Tools tests', () => {
391391
});
392392
it('checking addTools on darwin', async () => {
393393
const script: string = await tools.addTools(
394-
'blackfire, blackfire-player, flex, phpcs, phpcbf, phpcpd, phpmd, psalm, phinx, phive:1.2.3, cs2pr:1.2.3, composer-prefetcher:1.2.3, phpize, php-config, symfony, symfony:1.2.3, wp-cli',
394+
'blackfire, blackfire-player, flex, infection, phpcs, phpcbf, phpcpd, phpmd, psalm, phinx, vapor-cli, phive:1.2.3, cs2pr:1.2.3, composer-prefetcher:1.2.3, phpize, php-config, symfony, symfony:1.2.3, wp-cli',
395395
'7.4',
396396
'darwin'
397397
);
@@ -405,6 +405,9 @@ describe('Tools tests', () => {
405405
expect(script).toContain(
406406
'add_tool https://github.com/staabm/annotate-pull-request-from-checkstyle/releases/download/1.2.3/cs2pr cs2pr'
407407
);
408+
expect(script).toContain(
409+
'add_tool https://github.com/infection/infection/releases/latest/download/infection.phar infection'
410+
);
408411
expect(script).toContain(
409412
'add_tool https://github.com/squizlabs/PHP_CodeSniffer/releases/latest/download/phpcs.phar phpcs'
410413
);
@@ -420,6 +423,7 @@ describe('Tools tests', () => {
420423
expect(script).toContain(
421424
'https://github.com/vimeo/psalm/releases/latest/download/psalm.phar psalm'
422425
);
426+
expect(script).toContain('add_composertool vapor-cli vapor-cli laravel/');
423427
expect(script).toContain('add_composertool flex flex symfony/');
424428
expect(script).toContain('add_composertool phinx phinx robmorgan/');
425429
expect(script).toContain(
@@ -446,7 +450,7 @@ describe('Tools tests', () => {
446450
'7.4',
447451
'win32'
448452
);
449-
expect(script).toContain('Add-Blackfire 1.32.0');
453+
expect(script).toContain('Add-Blackfire');
450454
expect(script).toContain(
451455
'Add-Tool https://get.blackfire.io/blackfire-player-v1.8.1.phar blackfire-player'
452456
);

0 commit comments

Comments
 (0)