Skip to content

Commit

Permalink
Merge pull request #235 from shivammathur/develop
Browse files Browse the repository at this point in the history
2.3.1
  • Loading branch information
shivammathur committed Jun 22, 2020
2 parents 70954fb + 248d04f commit dd27d4e
Show file tree
Hide file tree
Showing 39 changed files with 498 additions and 492 deletions.
88 changes: 0 additions & 88 deletions .github/workflows/experimental-workflow.yml

This file was deleted.

10 changes: 5 additions & 5 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
fail-fast: false
matrix:
operating-system: [ubuntu-20.04, ubuntu-18.04, ubuntu-16.04, windows-latest, macos-latest]
php-versions: ['5.3', '5.4', '5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4']
php-versions: ['5.3', '5.4', '5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0']
env:
extensions: xml, opcache, xdebug, pcov
key: cache-v2
Expand All @@ -33,7 +33,7 @@ jobs:
uses: actions/checkout@v2

- name: Setup cache environment
id: cache-env
id: extcache
uses: shivammathur/cache-extensions@develop
with:
php-version: ${{ matrix.php-versions }}
Expand All @@ -43,9 +43,9 @@ jobs:
- name: Cache extensions
uses: actions/cache@v2
with:
path: ${{ steps.cache-env.outputs.dir }}
key: ${{ steps.cache-env.outputs.key }}
restore-keys: ${{ steps.cache-env.outputs.key }}
path: ${{ steps.extcache.outputs.dir }}
key: ${{ steps.extcache.outputs.key }}
restore-keys: ${{ steps.extcache.outputs.key }}

- name: Setup PHP with extensions and custom config
run: node dist/index.js
Expand Down
21 changes: 11 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ with:
### Xdebug

Specify `coverage: xdebug` to use `Xdebug`.
Runs on all [PHP versions supported](#tada-php-support "List of PHP versions supported on this GitHub Action") except `8.0`.
Runs on all [PHP versions supported](#tada-php-support "List of PHP versions supported on this GitHub Action").

```yaml
uses: shivammathur/setup-php@v2
Expand Down Expand Up @@ -338,7 +338,8 @@ steps:
> Setup PHP on a self-hosted runner.

- 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.
- 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.
- To setup the runner directly on the host OS or in a virtual machine, 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.
- If your workflow uses [services](https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idservices "GitHub Actions Services"), then setup the runner on a Linux host or in a Linux virtual machine. GitHub Actions does not support nested virtualization on Linux, so services will not work in a dockerized container.

Specify the environment variable `runner` with the value `self-hosted`. Without this your workflow will fail.

Expand Down Expand Up @@ -470,7 +471,7 @@ steps:
uses: actions/checkout@v2
- name: Setup cache environment
id: cache-env
id: extcache
uses: shivammathur/cache-extensions@v1
with:
php-version: ${{ matrix.php-versions }}
Expand All @@ -480,9 +481,9 @@ steps:
- name: Cache extensions
uses: actions/cache@v2
with:
path: ${{ steps.cache-env.outputs.dir }}
key: ${{ steps.cache-env.outputs.key }}
restore-keys: ${{ steps.cache-env.outputs.key }}
path: ${{ steps.extcache.outputs.dir }}
key: ${{ steps.extcache.outputs.key }}
restore-keys: ${{ steps.extcache.outputs.key }}
- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand All @@ -499,13 +500,13 @@ If your project uses composer, you can persist composer's internal cache directo

```yaml
- name: Get composer cache directory
id: composer-cache
id: composercache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache dependencies
uses: actions/cache@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
path: ${{ steps.composercache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
Expand All @@ -527,13 +528,13 @@ If your project has node.js dependencies, you can persist npm's or yarn's cache

```yaml
- name: Get node.js cache directory
id: node-cache-dir
id: nodecache
run: echo "::set-output name=dir::$(npm config get cache)" # Use $(yarn cache dir) for yarn
- name: Cache dependencies
uses: actions/cache@v2
with:
path: ${{ steps.node-cache-dir.outputs.dir }}
path: ${{ steps.nodecache.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} # Use '**/yarn.lock' for yarn
restore-keys: ${{ runner.os }}-node-
```
Expand Down
39 changes: 16 additions & 23 deletions __tests__/coverage.test.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
import * as coverage from '../src/coverage';

jest.mock('../src/extensions', () => ({
addExtension: jest.fn().mockImplementation(extension => {
return 'add_extension ' + extension + '\n';
})
}));

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

win32 = await coverage.addCoverage('pcov', '7.0', 'win32');
Expand All @@ -33,22 +27,30 @@ describe('Config tests', () => {

it('checking addCoverage with Xdebug on windows', async () => {
const win32: string = await coverage.addCoverage('xdebug', '7.4', 'win32');
expect(win32).toContain('add_extension xdebug');
expect(win32).toContain('Add-Extension xdebug');
});

it('checking addCoverage with Xdebug on windows', async () => {
const win32: string = await coverage.addCoverage('xdebug', '8.0', 'win32');
expect(win32).toContain('Xdebug currently only supports PHP 7.4 or lower');
it('checking addCoverage with Xdebug on linux', async () => {
const linux: string = await coverage.addCoverage('xdebug', '8.0', 'linux');
expect(linux).toContain('add_extension xdebug');
});

it('checking addCoverage with Xdebug on linux', async () => {
const linux: string = await coverage.addCoverage('xdebug', '7.4', 'linux');
it('checking addCoverage with Xdebug3 on linux', async () => {
const linux: string = await coverage.addCoverage('xdebug3', '7.4', 'linux');
expect(linux).toContain('add_extension_from_source xdebug');
expect(linux).toContain('echo "xdebug.mode=coverage"');
});

it('checking addCoverage with Xdebug3 on linux', async () => {
const linux: string = await coverage.addCoverage('xdebug3', '8.0', 'linux');
expect(linux).toContain('add_extension xdebug');
expect(linux).toContain('echo "xdebug.mode=coverage"');
});

it('checking addCoverage with Xdebug on linux', async () => {
const linux: string = await coverage.addCoverage('xdebug', '8.0', 'linux');
expect(linux).toContain('Xdebug currently only supports PHP 7.4 or lower');
expect(linux).toContain('add_extension xdebug');
expect(linux).toContain('echo "xdebug.mode=coverage"');
});

it('checking addCoverage with Xdebug on darwin', async () => {
Expand All @@ -60,15 +62,6 @@ describe('Config tests', () => {
expect(darwin).toContain('add_extension xdebug');
});

it('checking addCoverage with Xdebug on darwin', async () => {
const darwin: string = await coverage.addCoverage(
'xdebug',
'8.0',
'darwin'
);
expect(darwin).toContain('Xdebug currently only supports PHP 7.4 or lower');
});

it('checking disableCoverage windows', async () => {
const win32 = await coverage.addCoverage('none', '7.4', 'win32');
expect(win32).toContain('Remove-Extension xdebug');
Expand Down
30 changes: 22 additions & 8 deletions __tests__/extensions.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
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.9.6');
});
it('checking addExtensionOnWindows', async () => {
let win32: string = await extensions.addExtension(
'Xdebug, pcov, sqlite, :intl, phalcon4, ast-beta, grpc-1.2.3, inotify-1.2.3alpha2',
Expand Down Expand Up @@ -50,11 +56,14 @@ describe('Extension tests', () => {

it('checking addExtensionOnLinux', async () => {
let linux: string = await extensions.addExtension(
'Xdebug, pcov, sqlite, :intl, ast, uopz, ast-beta, pdo_mysql, pdo-odbc, xdebug-alpha, grpc-1.2.3',
'Xdebug, xdebug3, pcov, sqlite, :intl, ast, uopz, ast-beta, pdo_mysql, pdo-odbc, xdebug-alpha, grpc-1.2.3',
'7.4',
'linux'
);
expect(linux).toContain('update_extension xdebug 2.9.3');
expect(linux).toContain('update_extension xdebug 2.9.6');
expect(linux).toContain(
'add_extension_from_source xdebug xdebug/xdebug master --enable-xdebug zend_extension'
);
expect(linux).toContain('sudo $debconf_fix apt-get install -y php7.4-pcov');
expect(linux).toContain(
'sudo $debconf_fix apt-get install -y php7.4-sqlite3'
Expand All @@ -70,6 +79,11 @@ describe('Extension tests', () => {
'add_unstable_extension xdebug alpha zend_extension'
);

linux = await extensions.addExtension('xdebug3', '8.0', 'linux');
expect(linux).toContain(
'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');
Expand Down Expand Up @@ -104,8 +118,8 @@ describe('Extension tests', () => {
'7.2',
'darwin'
);
expect(darwin).toContain('sudo pecl install -f xdebug');
expect(darwin).toContain('sudo pecl install -f pcov');
expect(darwin).toContain('add_brew_extension xdebug');
expect(darwin).toContain('add_brew_extension pcov');
expect(darwin).toContain('sudo pecl install -f sqlite3');
expect(darwin).toContain('remove_extension intl');
expect(darwin).toContain('add_unstable_extension ast beta extension');
Expand All @@ -121,7 +135,7 @@ describe('Extension tests', () => {
expect(darwin).toContain('sudo pecl install -f pcov');

darwin = await extensions.addExtension('pcov', '7.2', 'darwin');
expect(darwin).toContain('sudo pecl install -f pcov');
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');
Expand All @@ -133,13 +147,13 @@ describe('Extension tests', () => {
expect(darwin).toContain('sudo pecl install -f xdebug-2.5.5');

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

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

darwin = await extensions.addExtension('xdebug', '7.2', 'darwin');
expect(darwin).toContain('sudo pecl install -f xdebug');
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');
Expand Down
1 change: 1 addition & 0 deletions __tests__/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ describe('Utils tests', () => {
);
expect(await utils.getExtensionPrefix('xsl')).toEqual('extension');
expect(await utils.getExtensionPrefix('xdebug')).toEqual('zend_extension');
expect(await utils.getExtensionPrefix('xdebug3')).toEqual('zend_extension');
expect(await utils.getExtensionPrefix('opcache')).toEqual('zend_extension');
});

Expand Down
Loading

0 comments on commit dd27d4e

Please sign in to comment.