Skip to content

Commit

Permalink
Merge pull request shivammathur#270 from shivammathur/develop
Browse files Browse the repository at this point in the history
2.4.2
  • Loading branch information
shivammathur committed Aug 10, 2020
2 parents 9dae796 + ee084d3 commit c5e0997
Show file tree
Hide file tree
Showing 16 changed files with 363 additions and 378 deletions.
70 changes: 25 additions & 45 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ with:

- Extensions which cannot be added or removed gracefully leave an error message in the logs, the action is not interrupted.

- These extensions have custom support - `gearman` on `Ubuntu`, `blackfire`, `ioncube`, `oci8`, `pdo_oci`, `phalcon3` and `phalcon4` on all supported OS.
- These extensions have custom support - `cubrid`, `pdo_cubrid` and `gearman` on `Ubuntu`, and `blackfire`, `ioncube`, `oci8`, `pdo_oci`, `phalcon3` and `phalcon4` on all supported OS.

## :wrench: Tools Support

Expand Down Expand Up @@ -178,7 +178,7 @@ with:
```

**Notes**
- Both agent `blackfire-agent` and client `blackfire` are setup when `blackfire` is specified in tools input.
- Latest versions of both agent `blackfire-agent` and client `blackfire` are setup when `blackfire` is specified in tools input.
- Tools which cannot be setup gracefully leave an error message in the logs, the action is not interrupted.

## :signal_strength: Coverage Support
Expand Down Expand Up @@ -455,45 +455,8 @@ To debug any issues, you can use the `verbose` tag instead of `v2`.

### Cache Extensions

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.

```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: extcache
uses: shivammathur/cache-extensions@v1
with:
php-version: ${{ matrix.php-versions }}
extensions: ${{ env.extensions }}
key: ${{ env.key }}
- name: Cache extensions
uses: actions/cache@v2
with:
path: ${{ steps.extcache.outputs.dir }}
key: ${{ steps.extcache.outputs.key }}
restore-keys: ${{ steps.extcache.outputs.key }}
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: ${{ env.extensions }}
```

**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.
You can cache PHP extensions using `shivammathur/cache-extensions` and `action/cache` 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.
Refer to [`shivammathur/cache-extensions`](https://github.com/shivammathur/cache-extensions "GitHub Action to cache php extensions") for details.

### Cache Composer Dependencies

Expand Down Expand Up @@ -646,9 +609,23 @@ Examples of using `setup-php` with various PHP Frameworks and Packages.

## :sparkling_heart: Support This Project

If this action helped you.
**Thanks for supporting this project**

- Sponsor the project by subscribing on [Patreon](https://www.patreon.com/shivammathur "Shivam Mathur Patreon") or by contributing using [Paypal](https://www.paypal.me/shivammathur "Shivam Mathur PayPal"). This project is also available as part of the [Tidelift Subscription](https://tidelift.com/subscription/pkg/npm-setup-php?utm_source=npm-setup-php&utm_medium=referral&utm_campaign=enterprise&utm_term=repo "Tidelift Subscription for setup-php") to support delivering enterprise-level maintenance.
<p>
<a href="https://www.jetbrains.com/?from=setup-php">
<img src="https://shivammathur.com/jetbrains.svg" alt="JetBrains" width="150" height="85">
</a>
<img src="https://shivammathur.com/blank.svg" alt="spacer" width="40" height="85">
<a href="https://tidelift.com/subscription/pkg/npm-setup-php">
<img src="https://shivammathur.com/tidelift.png" alt="Tidelift" width="100" height="85">
</a>
</p>

*If this action helped you*

- Sponsor the project by contributing using [Paypal](https://www.paypal.me/shivammathur "Shivam Mathur PayPal") or by subscribing on [Patreon](https://www.patreon.com/shivammathur "Shivam Mathur Patreon").
- If you have an open-source support program, please [contact](mailto:[email protected]) to sponsor this project.
- This project is also available as part of the [Tidelift Subscription](https://tidelift.com/subscription/pkg/npm-setup-php?utm_source=npm-setup-php&utm_medium=referral&utm_campaign=enterprise&utm_term=repo "Tidelift Subscription for setup-php") to support delivering enterprise-level maintenance.
- Please star the project and dependencies. If you blog, please share your experience of using this action with the community.

## :package: Dependencies
Expand All @@ -658,9 +635,12 @@ If this action helped you.
- [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 on MacOS")
- [shivammathur/composer-cache](https://github.com/shivammathur/composer-cache "Cache composer releases")
- [shivammathur/homebrew-extensions](https://github.com/shivammathur/homebrew-extensions "Tap for PHP extensions on MacOS")
- [shivammathur/php-builder](https://github.com/shivammathur/php-builder "Nightly PHP package")
- [shivammathur/homebrew-php](https://github.com/shivammathur/homebrew-php "Tap for PHP builds on MacOS")
- [shivammathur/php-builder](https://github.com/shivammathur/php-builder "Nightly PHP package for Ubuntu")
- [shivammathur/php-builder-windows](https://github.com/shivammathur/php-builder-windows "Nightly PHP package for Windows")
- [shivammathur/php-ubuntu](https://github.com/shivammathur/php-ubuntu "Cache stable PHP Packages for Ubuntu")
- [shivammathur/php5-darwin](https://github.com/shivammathur/php5-darwin "Scripts to setup PHP5 versions on darwin")
- [shivammathur/php5-ubuntu](https://github.com/shivammathur/php5-ubuntu "Scripts to setup PHP5 versions on ubuntu")

Expand Down
9 changes: 7 additions & 2 deletions __tests__/extensions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ describe('Extension tests', () => {
expect(win32).toContain('Remove-Extension intl');
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-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');
Expand Down Expand Up @@ -95,6 +95,11 @@ describe('Extension tests', () => {
linux = await extensions.addExtension('gearman', '7.4', 'linux');
expect(linux).toContain('add_gearman');

linux = await extensions.addExtension('pdo_cubrid', '7.0', 'linux');
expect(linux).toContain('add_cubrid pdo_cubrid');
linux = await extensions.addExtension('cubrid', '7.4', 'linux');
expect(linux).toContain('add_cubrid cubrid');

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

Expand Down
34 changes: 7 additions & 27 deletions __tests__/tools.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,6 @@ httpm.HttpClient.prototype.get = jest.fn().mockImplementation(() => {
});

describe('Tools tests', () => {
it('checking getCommand', async () => {
expect(await tools.getCommand('linux', 'tool')).toBe('add_tool ');
expect(await tools.getCommand('darwin', 'tool')).toBe('add_tool ');
expect(await tools.getCommand('win32', 'tool')).toBe('Add-Tool ');
expect(await tools.getCommand('fedora', 'tool')).toContain(
'Platform fedora is not supported'
);
});

it('checking parseToolVersion', async () => {
expect(await tools.getToolVersion('latest')).toBe('latest');
expect(await tools.getToolVersion('1.2.3')).toBe('1.2.3');
Expand Down Expand Up @@ -402,17 +393,6 @@ 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, grpc_php_plugin, php-cs-fixer, phplint, phpstan, phpunit, pecl, phinx, phinx:1.2.3, phive, php-config, phpize, protoc, symfony, wp-cli',
Expand All @@ -424,7 +404,7 @@ describe('Tools tests', () => {
'add_tool https://get.blackfire.io/blackfire-player.phar blackfire-player'
);
expect(script).toContain(
'add_tool https://getcomposer.org/composer-stable.phar composer'
'add_tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-stable.phar,https://getcomposer.org/composer-stable.phar composer'
);
expect(script).toContain(
'add_tool https://github.com/staabm/annotate-pull-request-from-checkstyle/releases/latest/download/cs2pr cs2pr'
Expand Down Expand Up @@ -499,7 +479,7 @@ describe('Tools tests', () => {
'add_tool https://get.blackfire.io/blackfire-player.phar blackfire-player'
);
expect(script).toContain(
'add_tool https://getcomposer.org/composer-stable.phar composer'
'add_tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-stable.phar,https://getcomposer.org/composer-stable.phar composer'
);
expect(script).toContain(
'add_tool https://github.com/ergebnis/composer-normalize/releases/latest/download/composer-normalize.phar composer-normalize'
Expand Down Expand Up @@ -590,7 +570,7 @@ describe('Tools tests', () => {
'Add-Tool https://get.blackfire.io/blackfire-player-v1.8.1.phar blackfire-player'
);
expect(script).toContain(
'Add-Tool https://getcomposer.org/composer-stable.phar composer'
'Add-Tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-stable.phar,https://getcomposer.org/composer-stable.phar composer'
);
expect(script).toContain(
'Add-Tool https://github.com/staabm/annotate-pull-request-from-checkstyle/releases/latest/download/cs2pr cs2pr'
Expand Down Expand Up @@ -631,7 +611,7 @@ describe('Tools tests', () => {
);

expect(script).toContain(
'Add-Tool https://getcomposer.org/composer-stable.phar composer'
'Add-Tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-stable.phar,https://getcomposer.org/composer-stable.phar composer'
);
expect(script).toContain('Add-Composertool prestissimo prestissimo hirak/');
expect(script).toContain('Add-Composertool phinx phinx robmorgan/');
Expand All @@ -649,20 +629,20 @@ describe('Tools tests', () => {
);

expect(script).toContain(
'add_tool https://getcomposer.org/composer-1.phar composer'
'add_tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-1.phar,https://getcomposer.org/composer-1.phar composer'
);

script = await tools.addTools('composer:preview', '7.4', 'linux');
expect(script).toContain(
'add_tool https://getcomposer.org/composer-preview.phar composer'
'add_tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-preview.phar,https://getcomposer.org/composer-preview.phar composer'
);
script = await tools.addTools(
'composer:v1, composer:preview, composer:snapshot',
'7.4',
'linux'
);
expect(script).toContain(
'add_tool https://getcomposer.org/composer.phar composer'
'add_tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-snapshot.phar,https://getcomposer.org/composer.phar composer'
);
});
});
22 changes: 22 additions & 0 deletions __tests__/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,15 @@ describe('Utils tests', () => {
);
});

it('checking getCommand', async () => {
expect(await utils.getCommand('linux', 'tool')).toBe('add_tool ');
expect(await utils.getCommand('darwin', 'tool')).toBe('add_tool ');
expect(await utils.getCommand('win32', 'tool')).toBe('Add-Tool ');
expect(await utils.getCommand('fedora', 'tool')).toContain(
'Platform fedora is not supported'
);
});

it('checking joins', async () => {
expect(await utils.joins('a', 'b', 'c')).toBe('a b c');
});
Expand All @@ -186,4 +195,17 @@ describe('Utils tests', () => {
'Platform fedora is not supported'
);
});

it('checking customPackage', async () => {
const script_path: string = path.join('ext', 'pkg.sh');
expect(await utils.customPackage('pkg', 'ext', '1.2.3', 'linux')).toContain(
script_path + '\nadd_pkg 1.2.3'
);
expect(
await utils.customPackage('pdo_pkg', 'ext', '1.2.3', 'linux')
).toContain(script_path + '\nadd_pkg 1.2.3');
expect(
await utils.customPackage('pkg8', 'ext', '1.2.3', 'linux')
).toContain(script_path + '\nadd_pkg 1.2.3');
});
});
Loading

0 comments on commit c5e0997

Please sign in to comment.