mirror of
https://github.com/shivammathur/setup-php.git
synced 2025-08-15 10:04:41 +07:00
Compare commits
14 Commits
Author | SHA1 | Date | |
---|---|---|---|
0da52b1327 | |||
3579c7ef28 | |||
d9cf6f5ad6 | |||
ea50c7c0a2 | |||
6ca549dcaa | |||
d3760be2cc | |||
3454287b87 | |||
88c7757dc8 | |||
48cfea3f3e | |||
43cfa2b1a8 | |||
76cecacc5e | |||
d6e173ffc6 | |||
26701f2ec8 | |||
e934fe28b8 |
10
.github/workflows/experimental-workflow.yml
vendored
10
.github/workflows/experimental-workflow.yml
vendored
@ -2,19 +2,13 @@ name: Experimental workflow
|
|||||||
on:
|
on:
|
||||||
pull_request:
|
pull_request:
|
||||||
branches:
|
branches:
|
||||||
- nightly
|
- releases/v1
|
||||||
- master
|
|
||||||
- develop
|
|
||||||
- verbose
|
|
||||||
paths-ignore:
|
paths-ignore:
|
||||||
- '**.md'
|
- '**.md'
|
||||||
- 'examples/**'
|
- 'examples/**'
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- nightly
|
- releases/v1
|
||||||
- master
|
|
||||||
- develop
|
|
||||||
- verbose
|
|
||||||
paths-ignore:
|
paths-ignore:
|
||||||
- '**.md'
|
- '**.md'
|
||||||
- 'examples/**'
|
- 'examples/**'
|
||||||
|
8
.github/workflows/workflow.yml
vendored
8
.github/workflows/workflow.yml
vendored
@ -2,17 +2,13 @@ name: Main workflow
|
|||||||
on:
|
on:
|
||||||
pull_request:
|
pull_request:
|
||||||
branches:
|
branches:
|
||||||
- master
|
- releases/v1
|
||||||
- develop
|
|
||||||
- verbose
|
|
||||||
paths-ignore:
|
paths-ignore:
|
||||||
- '**.md'
|
- '**.md'
|
||||||
- 'examples/**'
|
- 'examples/**'
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- master
|
- releases/v1
|
||||||
- develop
|
|
||||||
- verbose
|
|
||||||
paths-ignore:
|
paths-ignore:
|
||||||
- '**.md'
|
- '**.md'
|
||||||
- 'examples/**'
|
- 'examples/**'
|
||||||
|
24
README.md
24
README.md
@ -74,7 +74,7 @@ Setup PHP with required extensions, php.ini configuration, code-coverage support
|
|||||||
|
|
||||||
These tools can be setup globally using the `tools` input.
|
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`, `symfony`
|
`codeception`, `composer`, `composer-prefetcher`, `cs2pr`, `deployer`, `pecl`, `phinx`, `phive`, `phpcbf`, `phpcpd`, `php-config`, `php-cs-fixer`, `phpcs`, `phpize`, `phpmd`, `phpstan`, `phpunit`, `prestissimo`, `psalm`, `symfony`
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
uses: shivammathur/setup-php@v1
|
uses: shivammathur/setup-php@v1
|
||||||
@ -115,7 +115,7 @@ with:
|
|||||||
|
|
||||||
### PCOV
|
### PCOV
|
||||||
|
|
||||||
Specify `coverage: pcov` to use `PCOV`.
|
Specify `coverage: pcov` to use `PCOV` and disable `Xdebug`.
|
||||||
It is much faster than `Xdebug`.
|
It is much faster than `Xdebug`.
|
||||||
`PCOV` needs `PHP >= 7.1`.
|
`PCOV` needs `PHP >= 7.1`.
|
||||||
If your source code directory is other than `src`, `lib` or, `app`, specify `pcov.directory` using the `ini-values` input.
|
If your source code directory is other than `src`, `lib` or, `app`, specify `pcov.directory` using the `ini-values` input.
|
||||||
@ -281,6 +281,8 @@ key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
|
|||||||
|
|
||||||
### Problem Matchers
|
### Problem Matchers
|
||||||
|
|
||||||
|
#### PHPUnit
|
||||||
|
|
||||||
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.
|
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
|
```yaml
|
||||||
@ -288,6 +290,24 @@ You can setup problem matchers for your `PHPUnit` output by adding this step aft
|
|||||||
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
|
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### Other tools
|
||||||
|
|
||||||
|
For tools that support `checkstyle` reporting like `phpstan`, `psalm`, `php-cs-fixer` and `phpcs` you can use `cs2pr` to annotate your code.
|
||||||
|
For examples refer to [cs2pr documentation](https://github.com/staabm/annotate-pull-request-from-checkstyle).
|
||||||
|
|
||||||
|
> Here is an example with `phpstan`.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
- name: Setup PHP
|
||||||
|
uses: shivammathur/setup-php@v1
|
||||||
|
with:
|
||||||
|
php-version: '7.4'
|
||||||
|
tools: cs2pr, phpstan
|
||||||
|
|
||||||
|
- name: PHPStan
|
||||||
|
run: phpstan analyse src --error-format=checkstyle | cs2pr
|
||||||
|
```
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
|
||||||
Examples for setting up this GitHub Action with different PHP Frameworks/Packages.
|
Examples for setting up this GitHub Action with different PHP Frameworks/Packages.
|
||||||
|
@ -27,7 +27,7 @@ describe('Extension tests', () => {
|
|||||||
|
|
||||||
it('checking addExtensionOnLinux', async () => {
|
it('checking addExtensionOnLinux', async () => {
|
||||||
let linux: string = await extensions.addExtension(
|
let linux: string = await extensions.addExtension(
|
||||||
'xdebug, pcov, ast-beta',
|
'xdebug, pcov, ast-beta, xdebug-alpha',
|
||||||
'7.4',
|
'7.4',
|
||||||
'linux'
|
'linux'
|
||||||
);
|
);
|
||||||
@ -35,8 +35,10 @@ describe('Extension tests', () => {
|
|||||||
expect(linux).toContain(
|
expect(linux).toContain(
|
||||||
'sudo DEBIAN_FRONTEND=noninteractive apt-get install -y php7.4-pcov'
|
'sudo DEBIAN_FRONTEND=noninteractive apt-get install -y php7.4-pcov'
|
||||||
);
|
);
|
||||||
expect(linux).toContain('pecl install -f pcov');
|
expect(linux).toContain('add_unstable_extension ast beta extension');
|
||||||
expect(linux).toContain('install_extension ast-beta');
|
expect(linux).toContain(
|
||||||
|
'add_unstable_extension xdebug alpha zend_extension'
|
||||||
|
);
|
||||||
|
|
||||||
linux = await extensions.addExtension('gearman', '7.0', 'linux');
|
linux = await extensions.addExtension('gearman', '7.0', 'linux');
|
||||||
expect(linux).toContain('gearman.sh 7.0');
|
expect(linux).toContain('gearman.sh 7.0');
|
||||||
@ -68,7 +70,7 @@ describe('Extension tests', () => {
|
|||||||
);
|
);
|
||||||
expect(darwin).toContain('sudo pecl install -f xdebug');
|
expect(darwin).toContain('sudo pecl install -f xdebug');
|
||||||
expect(darwin).toContain('sudo pecl install -f pcov');
|
expect(darwin).toContain('sudo pecl install -f pcov');
|
||||||
expect(darwin).toContain('install_extension ast-beta');
|
expect(darwin).toContain('add_unstable_extension ast beta extension');
|
||||||
|
|
||||||
darwin = await extensions.addExtension('phalcon3', '7.0', 'darwin');
|
darwin = await extensions.addExtension('phalcon3', '7.0', 'darwin');
|
||||||
expect(darwin).toContain('phalcon_darwin.sh phalcon3 7.0');
|
expect(darwin).toContain('phalcon_darwin.sh phalcon3 7.0');
|
||||||
|
@ -2,28 +2,34 @@ import * as tools from '../src/tools';
|
|||||||
|
|
||||||
describe('Tools tests', () => {
|
describe('Tools tests', () => {
|
||||||
it('checking getCommand', async () => {
|
it('checking getCommand', async () => {
|
||||||
expect(await tools.getArchiveCommand('linux')).toBe('add_tool ');
|
expect(await tools.getCommand('linux', 'tool')).toBe('add_tool ');
|
||||||
expect(await tools.getArchiveCommand('darwin')).toBe('add_tool ');
|
expect(await tools.getCommand('darwin', 'tool')).toBe('add_tool ');
|
||||||
expect(await tools.getArchiveCommand('win32')).toBe('Add-Tool ');
|
expect(await tools.getCommand('win32', 'tool')).toBe('Add-Tool ');
|
||||||
expect(await tools.getArchiveCommand('fedora')).toContain(
|
expect(await tools.getCommand('fedora', 'tool')).toContain(
|
||||||
'Platform fedora is not supported'
|
'Platform fedora is not supported'
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('checking getCommand', async () => {
|
it('checking getCommand', async () => {
|
||||||
expect(await tools.getPackageCommand('linux')).toBe('add_composer_tool ');
|
expect(await tools.getCommand('linux', 'composertool')).toBe(
|
||||||
expect(await tools.getPackageCommand('darwin')).toBe('add_composer_tool ');
|
'add_composertool '
|
||||||
expect(await tools.getPackageCommand('win32')).toBe('Add-Composer-Tool ');
|
);
|
||||||
expect(await tools.getPackageCommand('fedora')).toContain(
|
expect(await tools.getCommand('darwin', 'composertool')).toBe(
|
||||||
|
'add_composertool '
|
||||||
|
);
|
||||||
|
expect(await tools.getCommand('win32', 'composertool')).toBe(
|
||||||
|
'Add-Composertool '
|
||||||
|
);
|
||||||
|
expect(await tools.getCommand('fedora', 'composertool')).toContain(
|
||||||
'Platform fedora is not supported'
|
'Platform fedora is not supported'
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('checking getPECLCommand', async () => {
|
it('checking getCommand', async () => {
|
||||||
expect(await tools.getPECLCommand('linux')).toBe('add_pecl ');
|
expect(await tools.getCommand('linux', 'pecl')).toBe('add_pecl ');
|
||||||
expect(await tools.getPECLCommand('darwin')).toBe('add_pecl ');
|
expect(await tools.getCommand('darwin', 'pecl')).toBe('add_pecl ');
|
||||||
expect(await tools.getPECLCommand('win32')).toBe('Add-PECL ');
|
expect(await tools.getCommand('win32', 'pecl')).toBe('Add-Pecl ');
|
||||||
expect(await tools.getPECLCommand('fedora')).toContain(
|
expect(await tools.getCommand('fedora', 'pecl')).toContain(
|
||||||
'Platform fedora is not supported'
|
'Platform fedora is not supported'
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@ -96,33 +102,24 @@ describe('Tools tests', () => {
|
|||||||
|
|
||||||
it('checking getUri', async () => {
|
it('checking getUri', async () => {
|
||||||
expect(
|
expect(
|
||||||
await tools.getUri('tool', 'latest', 'releases', '', 'download')
|
await tools.getUri('tool', '.phar', 'latest', 'releases', '', 'download')
|
||||||
).toBe('releases/latest/download/tool.phar');
|
).toBe('releases/latest/download/tool.phar');
|
||||||
expect(
|
expect(
|
||||||
await tools.getUri('tool', '1.2.3', 'releases', '', 'download')
|
await tools.getUri('tool', '.phar', '1.2.3', 'releases', '', 'download')
|
||||||
).toBe('releases/download/1.2.3/tool.phar');
|
).toBe('releases/download/1.2.3/tool.phar');
|
||||||
expect(
|
expect(
|
||||||
await tools.getUri('tool', '1.2.3', 'releases', 'v', 'download')
|
await tools.getUri('tool', '.phar', '1.2.3', 'releases', 'v', 'download')
|
||||||
).toBe('releases/download/v1.2.3/tool.phar');
|
).toBe('releases/download/v1.2.3/tool.phar');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('checking getCodeceptionUriBuilder', async () => {
|
it('checking getCodeceptionUriBuilder', async () => {
|
||||||
expect(await tools.getCodeceptionUriBuilder('3.2.1', '5.6', 'php56')).toBe(
|
expect(await tools.getCodeceptionUriBuilder('3.2.1', 'php56')).toBe(
|
||||||
'releases/3.2.1/php56/codecept.phar'
|
'releases/3.2.1/php56/codecept.phar'
|
||||||
);
|
);
|
||||||
expect(await tools.getCodeceptionUriBuilder('3.2.1', '7.0', 'php54')).toBe(
|
expect(await tools.getCodeceptionUriBuilder('3.2.1', 'php54')).toBe(
|
||||||
'releases/3.2.1/php54/codecept.phar'
|
'releases/3.2.1/php54/codecept.phar'
|
||||||
);
|
);
|
||||||
expect(await tools.getCodeceptionUriBuilder('3.2.1', '7.1', 'php56')).toBe(
|
expect(await tools.getCodeceptionUriBuilder('3.2.1', '')).toBe(
|
||||||
'releases/3.2.1/php56/codecept.phar'
|
|
||||||
);
|
|
||||||
expect(await tools.getCodeceptionUriBuilder('3.2.1', '7.2', 'php56')).toBe(
|
|
||||||
'releases/3.2.1/codecept.phar'
|
|
||||||
);
|
|
||||||
expect(await tools.getCodeceptionUriBuilder('3.2.1', '7.3', 'php56')).toBe(
|
|
||||||
'releases/3.2.1/codecept.phar'
|
|
||||||
);
|
|
||||||
expect(await tools.getCodeceptionUriBuilder('3.2.1', '7.4', 'php56')).toBe(
|
|
||||||
'releases/3.2.1/codecept.phar'
|
'releases/3.2.1/codecept.phar'
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@ -146,17 +143,59 @@ describe('Tools tests', () => {
|
|||||||
expect(await tools.getCodeceptionUri('latest', '7.4')).toBe(
|
expect(await tools.getCodeceptionUri('latest', '7.4')).toBe(
|
||||||
'codecept.phar'
|
'codecept.phar'
|
||||||
);
|
);
|
||||||
expect(await tools.getCodeceptionUri('3.2.1', '5.6')).toBe(
|
expect(await tools.getCodeceptionUri('4.0.0', '7.4')).toBe(
|
||||||
'releases/3.2.1/php54/codecept.phar'
|
'releases/4.0.0/codecept.phar'
|
||||||
);
|
);
|
||||||
expect(await tools.getCodeceptionUri('4.3.2', '5.6')).toBe(
|
expect(await tools.getCodeceptionUri('4.0.0', '5.6')).toBe(
|
||||||
'releases/4.3.2/php56/codecept.phar'
|
'releases/4.0.0/php56/codecept.phar'
|
||||||
);
|
);
|
||||||
expect(await tools.getCodeceptionUri('3.2.1', '7.4')).toBe(
|
expect(await tools.getCodeceptionUri('4.0.0', '7.1')).toBe(
|
||||||
'releases/3.2.1/codecept.phar'
|
'releases/4.0.0/php56/codecept.phar'
|
||||||
);
|
);
|
||||||
expect(await tools.getCodeceptionUri('4.3.2', '7.4')).toBe(
|
expect(await tools.getCodeceptionUri('3.1.0', '7.4')).toBe(
|
||||||
'releases/4.3.2/codecept.phar'
|
'releases/3.1.0/codecept.phar'
|
||||||
|
);
|
||||||
|
expect(await tools.getCodeceptionUri('3.1.0', '5.6')).toBe(
|
||||||
|
'releases/3.1.0/php54/codecept.phar'
|
||||||
|
);
|
||||||
|
expect(await tools.getCodeceptionUri('2.5.4', '7.4')).toBe(
|
||||||
|
'releases/2.5.4/codecept.phar'
|
||||||
|
);
|
||||||
|
expect(await tools.getCodeceptionUri('2.5.4', '5.6')).toBe(
|
||||||
|
'releases/2.5.4/php54/codecept.phar'
|
||||||
|
);
|
||||||
|
expect(await tools.getCodeceptionUri('2.3.4', '7.4')).toBe(
|
||||||
|
'releases/2.3.4/codecept.phar'
|
||||||
|
);
|
||||||
|
expect(await tools.getCodeceptionUri('2.3.4', '5.4')).toBe(
|
||||||
|
'releases/2.3.4/php54/codecept.phar'
|
||||||
|
);
|
||||||
|
expect(await tools.getCodeceptionUri('2.2.4', '5.6')).toBe(
|
||||||
|
'releases/2.2.4/codecept.phar'
|
||||||
|
);
|
||||||
|
expect(await tools.getCodeceptionUri('2.2.4', '7.4')).toBe(
|
||||||
|
'releases/2.2.4/codecept.phar'
|
||||||
|
);
|
||||||
|
expect(await tools.getCodeceptionUri('2.2.4', '5.4')).toBe(
|
||||||
|
'releases/2.2.4/php54/codecept.phar'
|
||||||
|
);
|
||||||
|
expect(await tools.getCodeceptionUri('2.1.7', '5.6')).toBe(
|
||||||
|
'releases/2.1.7/codecept.phar'
|
||||||
|
);
|
||||||
|
expect(await tools.getCodeceptionUri('2.1.7', '5.4')).toBe(
|
||||||
|
'releases/2.1.7/php54/codecept.phar'
|
||||||
|
);
|
||||||
|
expect(await tools.getCodeceptionUri('2.1.5', '5.4')).toBe(
|
||||||
|
'releases/2.1.5/codecept.phar'
|
||||||
|
);
|
||||||
|
expect(await tools.getCodeceptionUri('2.1.5', '7.4')).toBe(
|
||||||
|
'releases/2.1.5/codecept.phar'
|
||||||
|
);
|
||||||
|
expect(await tools.getCodeceptionUri('1.6.9', '7.4')).toBe(
|
||||||
|
'releases/1.6.9/codecept.phar'
|
||||||
|
);
|
||||||
|
expect(await tools.getCodeceptionUri('1.5.0', '7.4')).toBe(
|
||||||
|
'releases/1.5.0/codecept.phar'
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -173,11 +212,11 @@ describe('Tools tests', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('checking getPhpunitUri', async () => {
|
it('checking getPhpunitUri', async () => {
|
||||||
expect(await tools.getPhpunitUrl('tool', 'latest')).toBe(
|
expect(await tools.getPharUrl('domain', 'tool', '', 'latest')).toBe(
|
||||||
'https://phar.phpunit.de/tool.phar'
|
'domain/tool.phar'
|
||||||
);
|
);
|
||||||
expect(await tools.getPhpunitUrl('tool', '1.2.3')).toBe(
|
expect(await tools.getPharUrl('domain', 'tool', 'v', '1.2.3')).toBe(
|
||||||
'https://phar.phpunit.de/tool-1.2.3.phar'
|
'domain/tool-v1.2.3.phar'
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -190,7 +229,7 @@ describe('Tools tests', () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('checking getDeployerUri', async () => {
|
it('checking addComposer', async () => {
|
||||||
expect(await tools.addComposer(['a', 'b'])).toStrictEqual([
|
expect(await tools.addComposer(['a', 'b'])).toStrictEqual([
|
||||||
'composer',
|
'composer',
|
||||||
'a',
|
'a',
|
||||||
@ -311,13 +350,13 @@ describe('Tools tests', () => {
|
|||||||
'user/',
|
'user/',
|
||||||
'linux'
|
'linux'
|
||||||
);
|
);
|
||||||
expect(script).toContain('add_composer_tool tool tool:1.2.3 user/');
|
expect(script).toContain('add_composertool tool tool:1.2.3 user/');
|
||||||
|
|
||||||
script = await tools.addPackage('tool', 'tool:1.2.3', 'user/', 'darwin');
|
script = await tools.addPackage('tool', 'tool:1.2.3', 'user/', 'darwin');
|
||||||
expect(script).toContain('add_composer_tool tool tool:1.2.3 user/');
|
expect(script).toContain('add_composertool tool tool:1.2.3 user/');
|
||||||
|
|
||||||
script = await tools.addPackage('tool', 'tool:1.2.3', 'user/', 'win32');
|
script = await tools.addPackage('tool', 'tool:1.2.3', 'user/', 'win32');
|
||||||
expect(script).toContain('Add-Composer-Tool tool tool:1.2.3 user/');
|
expect(script).toContain('Add-Composertool tool tool:1.2.3 user/');
|
||||||
|
|
||||||
script = await tools.addPackage('tool', 'tool:1.2.3', 'user/', 'fedora');
|
script = await tools.addPackage('tool', 'tool:1.2.3', 'user/', 'fedora');
|
||||||
expect(script).toContain('Platform fedora is not supported');
|
expect(script).toContain('Platform fedora is not supported');
|
||||||
@ -325,12 +364,15 @@ describe('Tools tests', () => {
|
|||||||
|
|
||||||
it('checking addTools on linux', async () => {
|
it('checking addTools on linux', async () => {
|
||||||
const script: string = await tools.addTools(
|
const script: string = await tools.addTools(
|
||||||
'php-cs-fixer, phpstan, phpunit, pecl, phinx, phinx:1.2.3, phive, php-config, phpize, symfony',
|
'cs2pr, php-cs-fixer, phpstan, phpunit, pecl, phinx, phinx:1.2.3, phive, php-config, phpize, symfony',
|
||||||
'7.4',
|
'7.4',
|
||||||
'linux'
|
'linux'
|
||||||
);
|
);
|
||||||
expect(script).toContain(
|
expect(script).toContain(
|
||||||
'add_tool https://github.com/composer/composer/releases/latest/download/composer.phar composer'
|
'add_tool 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'
|
||||||
);
|
);
|
||||||
expect(script).toContain(
|
expect(script).toContain(
|
||||||
'add_tool https://github.com/FriendsOfPHP/PHP-CS-Fixer/releases/latest/download/php-cs-fixer.phar php-cs-fixer'
|
'add_tool https://github.com/FriendsOfPHP/PHP-CS-Fixer/releases/latest/download/php-cs-fixer.phar php-cs-fixer'
|
||||||
@ -348,20 +390,23 @@ describe('Tools tests', () => {
|
|||||||
'add_tool https://github.com/symfony/cli/releases/latest/download/symfony_linux_amd64 symfony'
|
'add_tool https://github.com/symfony/cli/releases/latest/download/symfony_linux_amd64 symfony'
|
||||||
);
|
);
|
||||||
expect(script).toContain('add_pecl');
|
expect(script).toContain('add_pecl');
|
||||||
expect(script).toContain('add_composer_tool phinx phinx robmorgan/');
|
expect(script).toContain('add_composertool phinx phinx robmorgan/');
|
||||||
expect(script).toContain('add_composer_tool phinx phinx:1.2.3 robmorgan/');
|
expect(script).toContain('add_composertool phinx phinx:1.2.3 robmorgan/');
|
||||||
expect(script).toContain('add_devtools');
|
expect(script).toContain('add_devtools');
|
||||||
expect(script).toContain('add_log "$tick" "php-config" "Added"');
|
expect(script).toContain('add_log "$tick" "php-config" "Added"');
|
||||||
expect(script).toContain('add_log "$tick" "phpize" "Added"');
|
expect(script).toContain('add_log "$tick" "phpize" "Added"');
|
||||||
});
|
});
|
||||||
it('checking addTools on darwin', async () => {
|
it('checking addTools on darwin', async () => {
|
||||||
const script: string = await tools.addTools(
|
const script: string = await tools.addTools(
|
||||||
'phpcs, phpcbf, phpcpd, phpmd, psalm, phinx, phive:1.2.3, composer-prefetcher:1.2.3, phpize, php-config, symfony, symfony:1.2.3',
|
'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',
|
||||||
'7.4',
|
'7.4',
|
||||||
'darwin'
|
'darwin'
|
||||||
);
|
);
|
||||||
expect(script).toContain(
|
expect(script).toContain(
|
||||||
'add_tool https://github.com/composer/composer/releases/latest/download/composer.phar composer'
|
'add_tool https://getcomposer.org/composer-stable.phar composer'
|
||||||
|
);
|
||||||
|
expect(script).toContain(
|
||||||
|
'add_tool https://github.com/staabm/annotate-pull-request-from-checkstyle/releases/download/1.2.3/cs2pr cs2pr'
|
||||||
);
|
);
|
||||||
expect(script).toContain(
|
expect(script).toContain(
|
||||||
'add_tool https://github.com/squizlabs/PHP_CodeSniffer/releases/latest/download/phpcs.phar phpcs'
|
'add_tool https://github.com/squizlabs/PHP_CodeSniffer/releases/latest/download/phpcs.phar phpcs'
|
||||||
@ -378,12 +423,12 @@ describe('Tools tests', () => {
|
|||||||
expect(script).toContain(
|
expect(script).toContain(
|
||||||
'https://github.com/vimeo/psalm/releases/latest/download/psalm.phar psalm'
|
'https://github.com/vimeo/psalm/releases/latest/download/psalm.phar psalm'
|
||||||
);
|
);
|
||||||
expect(script).toContain('add_composer_tool phinx phinx robmorgan/');
|
expect(script).toContain('add_composertool phinx phinx robmorgan/');
|
||||||
expect(script).toContain(
|
expect(script).toContain(
|
||||||
'add_tool https://github.com/phar-io/phive/releases/download/1.2.3/phive-1.2.3.phar phive'
|
'add_tool https://github.com/phar-io/phive/releases/download/1.2.3/phive-1.2.3.phar phive'
|
||||||
);
|
);
|
||||||
expect(script).toContain(
|
expect(script).toContain(
|
||||||
'add_composer_tool composer-prefetcher composer-prefetcher:1.2.3 narrowspark/automatic-'
|
'add_composertool composer-prefetcher composer-prefetcher:1.2.3 narrowspark/automatic-'
|
||||||
);
|
);
|
||||||
expect(script).toContain(
|
expect(script).toContain(
|
||||||
'add_tool https://github.com/symfony/cli/releases/latest/download/symfony_darwin_amd64 symfony'
|
'add_tool https://github.com/symfony/cli/releases/latest/download/symfony_darwin_amd64 symfony'
|
||||||
@ -396,23 +441,24 @@ describe('Tools tests', () => {
|
|||||||
});
|
});
|
||||||
it('checking addTools on windows', async () => {
|
it('checking addTools on windows', async () => {
|
||||||
const script: string = await tools.addTools(
|
const script: string = await tools.addTools(
|
||||||
'codeception, deployer, prestissimo, phpmd, phinx, phive:0.13.2, php-config, phpize, symfony, does_not_exit',
|
'codeception, cs2pr, deployer, prestissimo, phpmd, phinx, phive:0.13.2, php-config, phpize, symfony, does_not_exit',
|
||||||
'7.4',
|
'7.4',
|
||||||
'win32'
|
'win32'
|
||||||
);
|
);
|
||||||
expect(script).toContain(
|
expect(script).toContain(
|
||||||
'Add-Tool https://github.com/composer/composer/releases/latest/download/composer.phar composer'
|
'Add-Tool 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'
|
||||||
);
|
);
|
||||||
expect(script).toContain(
|
expect(script).toContain(
|
||||||
'Add-Tool https://deployer.org/deployer.phar deployer'
|
'Add-Tool https://deployer.org/deployer.phar deployer'
|
||||||
);
|
);
|
||||||
expect(script).toContain(
|
expect(script).toContain('Add-Composertool prestissimo prestissimo hirak/');
|
||||||
'Add-Composer-Tool prestissimo prestissimo hirak/'
|
|
||||||
);
|
|
||||||
expect(script).toContain(
|
expect(script).toContain(
|
||||||
'Add-Tool https://github.com/phpmd/phpmd/releases/latest/download/phpmd.phar phpmd'
|
'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-Composertool phinx phinx robmorgan/');
|
||||||
expect(script).toContain(
|
expect(script).toContain(
|
||||||
'Add-Tool https://github.com/phar-io/phive/releases/download/0.13.2/phive-0.13.2.phar phive'
|
'Add-Tool https://github.com/phar-io/phive/releases/download/0.13.2/phive-0.13.2.phar phive'
|
||||||
);
|
);
|
||||||
@ -431,14 +477,12 @@ describe('Tools tests', () => {
|
|||||||
'win32'
|
'win32'
|
||||||
);
|
);
|
||||||
expect(script).toContain(
|
expect(script).toContain(
|
||||||
'Add-Tool https://github.com/composer/composer/releases/latest/download/composer.phar composer'
|
'Add-Tool https://getcomposer.org/composer-stable.phar composer'
|
||||||
);
|
);
|
||||||
|
expect(script).toContain('Add-Composertool prestissimo prestissimo hirak/');
|
||||||
|
expect(script).toContain('Add-Composertool phinx phinx robmorgan/');
|
||||||
expect(script).toContain(
|
expect(script).toContain(
|
||||||
'Add-Composer-Tool prestissimo prestissimo hirak/'
|
'Add-Composertool composer-prefetcher composer-prefetcher narrowspark/automatic-'
|
||||||
);
|
|
||||||
expect(script).toContain('Add-Composer-Tool phinx phinx robmorgan/');
|
|
||||||
expect(script).toContain(
|
|
||||||
'Add-Composer-Tool composer-prefetcher composer-prefetcher narrowspark/automatic-'
|
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -3,6 +3,7 @@ author: shivammathur
|
|||||||
description: 'Setup PHP with required extensions, php.ini configuration, code-coverage support and various tools like composer'
|
description: 'Setup PHP with required extensions, php.ini configuration, code-coverage support and various tools like composer'
|
||||||
branding:
|
branding:
|
||||||
color: 'purple'
|
color: 'purple'
|
||||||
|
icon: 'play-circle'
|
||||||
inputs:
|
inputs:
|
||||||
php-version:
|
php-version:
|
||||||
description: 'Setup PHP version.'
|
description: 'Setup PHP version.'
|
||||||
@ -20,18 +21,17 @@ inputs:
|
|||||||
tools:
|
tools:
|
||||||
description: 'Setup popular tools globally.'
|
description: 'Setup popular tools globally.'
|
||||||
required: false
|
required: false
|
||||||
# Deprecated options, do not use. Will not be supported in v2 which will be released around February 1, 2020.
|
|
||||||
extension-csv:
|
extension-csv:
|
||||||
description: 'Deprecated! Use extensions instead.'
|
description: 'Deprecated! Use extensions instead.'
|
||||||
deprecationMessage: 'The extension-csv property will not be supported in v2. Use extensions instead.'
|
deprecationMessage: 'The extension-csv property is deprecated. Use extensions instead.'
|
||||||
required: false
|
required: false
|
||||||
ini-values-csv:
|
ini-values-csv:
|
||||||
description: 'Deprecated! Use ini-values instead.'
|
description: 'Deprecated! Use ini-values instead.'
|
||||||
deprecationMessage: 'The ini-values-csv property will not be supported in v2. Use ini-values instead.'
|
deprecationMessage: 'The ini-values-csv property is deprecated. Use ini-values instead.'
|
||||||
required: false
|
required: false
|
||||||
pecl:
|
pecl:
|
||||||
description: 'Deprecated! Use tools instead to setup PECL.'
|
description: 'Deprecated! Use tools instead to setup PECL.'
|
||||||
deprecationMessage: 'The pecl property will not be supported in v2. Specify pecl in tools instead.'
|
deprecationMessage: 'The pecl property is deprecated. Specify pecl in tools instead.'
|
||||||
required: false
|
required: false
|
||||||
runs:
|
runs:
|
||||||
using: 'node12'
|
using: 'node12'
|
||||||
|
204
dist/index.js
vendored
204
dist/index.js
vendored
@ -1452,6 +1452,13 @@ exports.setFailed = setFailed;
|
|||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
// Logging Commands
|
// Logging Commands
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
|
/**
|
||||||
|
* Gets whether Actions Step Debug is on or not
|
||||||
|
*/
|
||||||
|
function isDebug() {
|
||||||
|
return process.env['RUNNER_DEBUG'] === '1';
|
||||||
|
}
|
||||||
|
exports.isDebug = isDebug;
|
||||||
/**
|
/**
|
||||||
* Writes debug message to user log
|
* Writes debug message to user log
|
||||||
* @param message debug message
|
* @param message debug message
|
||||||
@ -1575,63 +1582,24 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
const utils = __importStar(__webpack_require__(163));
|
const utils = __importStar(__webpack_require__(163));
|
||||||
/**
|
/**
|
||||||
* Function to get command to setup tool
|
* Function to get command to setup tools
|
||||||
*
|
*
|
||||||
* @param os_version
|
* @param os_version
|
||||||
*/
|
*/
|
||||||
function getArchiveCommand(os_version) {
|
function getCommand(os_version, suffix) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
switch (os_version) {
|
switch (os_version) {
|
||||||
case 'linux':
|
case 'linux':
|
||||||
case 'darwin':
|
case 'darwin':
|
||||||
return 'add_tool ';
|
return 'add_' + suffix + ' ';
|
||||||
case 'win32':
|
case 'win32':
|
||||||
return 'Add-Tool ';
|
return 'Add-' + suffix.charAt(0).toUpperCase() + suffix.slice(1) + ' ';
|
||||||
default:
|
default:
|
||||||
return yield utils.log('Platform ' + os_version + ' is not supported', os_version, 'error');
|
return yield utils.log('Platform ' + os_version + ' is not supported', os_version, 'error');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
exports.getArchiveCommand = getArchiveCommand;
|
exports.getCommand = getCommand;
|
||||||
/**
|
|
||||||
* Function to get command to setup tools using composer
|
|
||||||
*
|
|
||||||
* @param os_version
|
|
||||||
*/
|
|
||||||
function getPackageCommand(os_version) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
switch (os_version) {
|
|
||||||
case 'linux':
|
|
||||||
case 'darwin':
|
|
||||||
return 'add_composer_tool ';
|
|
||||||
case 'win32':
|
|
||||||
return 'Add-Composer-Tool ';
|
|
||||||
default:
|
|
||||||
return yield utils.log('Platform ' + os_version + ' is not supported', os_version, 'error');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
exports.getPackageCommand = getPackageCommand;
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* Function to get command to setup PECL
|
|
||||||
*
|
|
||||||
* @param os_version
|
|
||||||
*/
|
|
||||||
function getPECLCommand(os_version) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
switch (os_version) {
|
|
||||||
case 'linux':
|
|
||||||
case 'darwin':
|
|
||||||
return 'add_pecl ';
|
|
||||||
case 'win32':
|
|
||||||
return 'Add-PECL ';
|
|
||||||
default:
|
|
||||||
return yield utils.log('Platform ' + os_version + ' is not supported', os_version, 'error');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
exports.getPECLCommand = getPECLCommand;
|
|
||||||
/**
|
/**
|
||||||
* Function to get tool version
|
* Function to get tool version
|
||||||
*
|
*
|
||||||
@ -1684,13 +1652,15 @@ exports.parseTool = parseTool;
|
|||||||
* @param version_prefix
|
* @param version_prefix
|
||||||
* @param verb
|
* @param verb
|
||||||
*/
|
*/
|
||||||
function getUri(tool, version, prefix, version_prefix, verb) {
|
function getUri(tool, extension, version, prefix, version_prefix, verb) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
switch (version) {
|
switch (version) {
|
||||||
case 'latest':
|
case 'latest':
|
||||||
return [prefix, version, verb, tool + '.phar'].filter(Boolean).join('/');
|
return [prefix, version, verb, tool + extension]
|
||||||
|
.filter(Boolean)
|
||||||
|
.join('/');
|
||||||
default:
|
default:
|
||||||
return [prefix, verb, version_prefix + version, tool + '.phar']
|
return [prefix, verb, version_prefix + version, tool + extension]
|
||||||
.filter(Boolean)
|
.filter(Boolean)
|
||||||
.join('/');
|
.join('/');
|
||||||
}
|
}
|
||||||
@ -1701,20 +1671,13 @@ exports.getUri = getUri;
|
|||||||
* Helper function to get the codeception url
|
* Helper function to get the codeception url
|
||||||
*
|
*
|
||||||
* @param version
|
* @param version
|
||||||
* @param php_version
|
|
||||||
* @param suffix
|
* @param suffix
|
||||||
*/
|
*/
|
||||||
function getCodeceptionUriBuilder(version, php_version, suffix) {
|
function getCodeceptionUriBuilder(version, suffix) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
switch (true) {
|
return ['releases', version, suffix, 'codecept.phar']
|
||||||
case /^5\.6$|^7\.[0|1]$/.test(php_version):
|
.filter(Boolean)
|
||||||
return ['releases', version, suffix, 'codecept.phar']
|
.join('/');
|
||||||
.filter(Boolean)
|
|
||||||
.join('/');
|
|
||||||
case /^7\.[2-4]$/.test(php_version):
|
|
||||||
default:
|
|
||||||
return ['releases', version, 'codecept.phar'].filter(Boolean).join('/');
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
exports.getCodeceptionUriBuilder = getCodeceptionUriBuilder;
|
exports.getCodeceptionUriBuilder = getCodeceptionUriBuilder;
|
||||||
@ -1726,19 +1689,55 @@ exports.getCodeceptionUriBuilder = getCodeceptionUriBuilder;
|
|||||||
*/
|
*/
|
||||||
function getCodeceptionUri(version, php_version) {
|
function getCodeceptionUri(version, php_version) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
const codecept = yield getCodeceptionUriBuilder(version, '');
|
||||||
|
const codecept54 = yield getCodeceptionUriBuilder(version, 'php54');
|
||||||
|
const codecept56 = yield getCodeceptionUriBuilder(version, 'php56');
|
||||||
|
// Refer to https://codeception.com/builds
|
||||||
switch (true) {
|
switch (true) {
|
||||||
case /latest/.test(version):
|
case /latest/.test(version):
|
||||||
switch (true) {
|
switch (true) {
|
||||||
case /^5\.6$|^7\.[0|1]$/.test(php_version):
|
case /5\.6|7\.[0|1]/.test(php_version):
|
||||||
return 'php56/codecept.phar';
|
return 'php56/codecept.phar';
|
||||||
case /^7\.[2-4]$/.test(php_version):
|
case /7\.[2-4]/.test(php_version):
|
||||||
default:
|
default:
|
||||||
return 'codecept.phar';
|
return 'codecept.phar';
|
||||||
}
|
}
|
||||||
case /([4-9]|\d{2,})\..*/.test(version):
|
case /(^[4-9]|\d{2,})\..*/.test(version):
|
||||||
return yield getCodeceptionUriBuilder(version, php_version, 'php56');
|
switch (true) {
|
||||||
|
case /5\.6|7\.[0|1]/.test(php_version):
|
||||||
|
return codecept56;
|
||||||
|
case /7\.[2-4]/.test(php_version):
|
||||||
|
default:
|
||||||
|
return codecept;
|
||||||
|
}
|
||||||
|
case /(^2\.[4-5]\.\d+|^3\.[0-1]\.\d+).*/.test(version):
|
||||||
|
switch (true) {
|
||||||
|
case /5\.6/.test(php_version):
|
||||||
|
return codecept54;
|
||||||
|
case /7\.[0-4]/.test(php_version):
|
||||||
|
default:
|
||||||
|
return codecept;
|
||||||
|
}
|
||||||
|
case /^2\.3\.\d+.*/.test(version):
|
||||||
|
switch (true) {
|
||||||
|
case /5\.[4-6]/.test(php_version):
|
||||||
|
return codecept54;
|
||||||
|
case /^7\.[0-4]$/.test(php_version):
|
||||||
|
default:
|
||||||
|
return codecept;
|
||||||
|
}
|
||||||
|
case /(^2\.(1\.([6-9]|\d{2,}))|^2\.2\.\d+).*/.test(version):
|
||||||
|
switch (true) {
|
||||||
|
case /5\.[4-5]/.test(php_version):
|
||||||
|
return codecept54;
|
||||||
|
case /5.6|7\.[0-4]/.test(php_version):
|
||||||
|
default:
|
||||||
|
return codecept;
|
||||||
|
}
|
||||||
|
case /(^2\.(1\.[0-5]|0\.\d+)|^1\.[6-8]\.\d+).*/.test(version):
|
||||||
|
return codecept;
|
||||||
default:
|
default:
|
||||||
return yield getCodeceptionUriBuilder(version, php_version, 'php54');
|
return yield codecept;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -1755,10 +1754,10 @@ function addPhive(version, os_version) {
|
|||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
switch (version) {
|
switch (version) {
|
||||||
case 'latest':
|
case 'latest':
|
||||||
return ((yield getArchiveCommand(os_version)) +
|
return ((yield getCommand(os_version, 'tool')) +
|
||||||
'https://phar.io/releases/phive.phar phive');
|
'https://phar.io/releases/phive.phar phive');
|
||||||
default:
|
default:
|
||||||
return ((yield getArchiveCommand(os_version)) +
|
return ((yield getCommand(os_version, 'tool')) +
|
||||||
'https://github.com/phar-io/phive/releases/download/' +
|
'https://github.com/phar-io/phive/releases/download/' +
|
||||||
version +
|
version +
|
||||||
'/phive-' +
|
'/phive-' +
|
||||||
@ -1769,22 +1768,21 @@ function addPhive(version, os_version) {
|
|||||||
}
|
}
|
||||||
exports.addPhive = addPhive;
|
exports.addPhive = addPhive;
|
||||||
/**
|
/**
|
||||||
* Function to get the PHPUnit url
|
* Function to get the phar url in domain/tool-version.phar format
|
||||||
*
|
*
|
||||||
* @param version
|
* @param version
|
||||||
*/
|
*/
|
||||||
function getPhpunitUrl(tool, version) {
|
function getPharUrl(domain, tool, prefix, version) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
const phpunit = 'https://phar.phpunit.de';
|
|
||||||
switch (version) {
|
switch (version) {
|
||||||
case 'latest':
|
case 'latest':
|
||||||
return phpunit + '/' + tool + '.phar';
|
return domain + '/' + tool + '.phar';
|
||||||
default:
|
default:
|
||||||
return phpunit + '/' + tool + '-' + version + '.phar';
|
return domain + '/' + tool + '-' + prefix + version + '.phar';
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
exports.getPhpunitUrl = getPhpunitUrl;
|
exports.getPharUrl = getPharUrl;
|
||||||
/**
|
/**
|
||||||
* Function to get the Deployer url
|
* Function to get the Deployer url
|
||||||
*
|
*
|
||||||
@ -1882,7 +1880,7 @@ exports.getCleanedToolsList = getCleanedToolsList;
|
|||||||
*/
|
*/
|
||||||
function addArchive(tool, version, url, os_version) {
|
function addArchive(tool, version, url, os_version) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
return (yield getArchiveCommand(os_version)) + url + ' ' + tool;
|
return (yield getCommand(os_version, 'tool')) + url + ' ' + tool;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
exports.addArchive = addArchive;
|
exports.addArchive = addArchive;
|
||||||
@ -1919,7 +1917,7 @@ exports.addDevTools = addDevTools;
|
|||||||
*/
|
*/
|
||||||
function addPackage(tool, release, prefix, os_version) {
|
function addPackage(tool, release, prefix, os_version) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
const tool_command = yield getPackageCommand(os_version);
|
const tool_command = yield getCommand(os_version, 'composertool');
|
||||||
return tool_command + tool + ' ' + release + ' ' + prefix;
|
return tool_command + tool + ' ' + release + ' ' + prefix;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -1940,12 +1938,17 @@ function addTools(tools_csv, php_version, os_version) {
|
|||||||
const tool = tool_data.name;
|
const tool = tool_data.name;
|
||||||
const version = tool_data.version;
|
const version = tool_data.version;
|
||||||
const github = 'https://github.com/';
|
const github = 'https://github.com/';
|
||||||
let uri = yield getUri(tool, version, 'releases', '', 'download');
|
let uri = yield getUri(tool, '.phar', version, 'releases', '', 'download');
|
||||||
script += '\n';
|
script += '\n';
|
||||||
let url = '';
|
let url = '';
|
||||||
switch (tool) {
|
switch (tool) {
|
||||||
|
case 'cs2pr':
|
||||||
|
uri = yield getUri(tool, '', version, 'releases', '', 'download');
|
||||||
|
url = github + 'staabm/annotate-pull-request-from-checkstyle/' + uri;
|
||||||
|
script += yield addArchive(tool, version, url, os_version);
|
||||||
|
break;
|
||||||
case 'php-cs-fixer':
|
case 'php-cs-fixer':
|
||||||
uri = yield getUri(tool, version, 'releases', 'v', 'download');
|
uri = yield getUri(tool, '.phar', version, 'releases', 'v', 'download');
|
||||||
url = github + 'FriendsOfPHP/PHP-CS-Fixer/' + uri;
|
url = github + 'FriendsOfPHP/PHP-CS-Fixer/' + uri;
|
||||||
script += yield addArchive(tool, version, url, os_version);
|
script += yield addArchive(tool, version, url, os_version);
|
||||||
break;
|
break;
|
||||||
@ -1970,8 +1973,10 @@ function addTools(tools_csv, php_version, os_version) {
|
|||||||
script += yield addArchive(tool, version, url, os_version);
|
script += yield addArchive(tool, version, url, os_version);
|
||||||
break;
|
break;
|
||||||
case 'composer':
|
case 'composer':
|
||||||
url =
|
// If RC is released as latest release, switch to getcomposer.
|
||||||
github + 'composer/composer/releases/latest/download/composer.phar';
|
// Prefered source is GitHub as it is faster.
|
||||||
|
// url = github + 'composer/composer/releases/latest/download/composer.phar';
|
||||||
|
url = 'https://getcomposer.org/composer-stable.phar';
|
||||||
script += yield addArchive(tool, version, url, os_version);
|
script += yield addArchive(tool, version, url, os_version);
|
||||||
break;
|
break;
|
||||||
case 'codeception':
|
case 'codeception':
|
||||||
@ -1982,7 +1987,7 @@ function addTools(tools_csv, php_version, os_version) {
|
|||||||
break;
|
break;
|
||||||
case 'phpcpd':
|
case 'phpcpd':
|
||||||
case 'phpunit':
|
case 'phpunit':
|
||||||
url = yield getPhpunitUrl(tool, version);
|
url = yield getPharUrl('https://phar.phpunit.de', tool, '', version);
|
||||||
script += yield addArchive(tool, version, url, os_version);
|
script += yield addArchive(tool, version, url, os_version);
|
||||||
break;
|
break;
|
||||||
case 'deployer':
|
case 'deployer':
|
||||||
@ -1999,7 +2004,7 @@ function addTools(tools_csv, php_version, os_version) {
|
|||||||
script += yield addPackage(tool, release, 'narrowspark/automatic-', os_version);
|
script += yield addPackage(tool, release, 'narrowspark/automatic-', os_version);
|
||||||
break;
|
break;
|
||||||
case 'pecl':
|
case 'pecl':
|
||||||
script += yield getPECLCommand(os_version);
|
script += yield getCommand(os_version, 'pecl');
|
||||||
break;
|
break;
|
||||||
case 'php-config':
|
case 'php-config':
|
||||||
case 'phpize':
|
case 'phpize':
|
||||||
@ -2642,12 +2647,20 @@ function addExtensionDarwin(extension_csv, version, pipe) {
|
|||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
extension = extension.toLowerCase();
|
extension = extension.toLowerCase();
|
||||||
const version_extension = version + extension;
|
const version_extension = version + extension;
|
||||||
|
const [extension_name, stability] = extension.split('-');
|
||||||
|
const prefix = yield utils.getExtensionPrefix(extension_name);
|
||||||
let install_command = '';
|
let install_command = '';
|
||||||
switch (true) {
|
switch (true) {
|
||||||
// match pre-release versions
|
// match pre-release versions
|
||||||
case /.*-(beta|alpha|devel|snapshot)/.test(version_extension):
|
case /.*-(beta|alpha|devel|snapshot)/.test(version_extension):
|
||||||
install_command = 'install_extension ' + extension + pipe;
|
script +=
|
||||||
break;
|
'\nadd_unstable_extension ' +
|
||||||
|
extension_name +
|
||||||
|
' ' +
|
||||||
|
stability +
|
||||||
|
' ' +
|
||||||
|
prefix;
|
||||||
|
return;
|
||||||
case /5\.6xdebug/.test(version_extension):
|
case /5\.6xdebug/.test(version_extension):
|
||||||
install_command = 'sudo pecl install -f xdebug-2.5.5' + pipe;
|
install_command = 'sudo pecl install -f xdebug-2.5.5' + pipe;
|
||||||
break;
|
break;
|
||||||
@ -2665,15 +2678,14 @@ function addExtensionDarwin(extension_csv, version, pipe) {
|
|||||||
pipe;
|
pipe;
|
||||||
break;
|
break;
|
||||||
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
|
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
|
||||||
install_command =
|
script +=
|
||||||
'sh ' +
|
'sh ' +
|
||||||
path.join(__dirname, '../src/scripts/ext/phalcon_darwin.sh') +
|
path.join(__dirname, '../src/scripts/ext/phalcon_darwin.sh') +
|
||||||
' ' +
|
' ' +
|
||||||
extension +
|
extension +
|
||||||
' ' +
|
' ' +
|
||||||
version +
|
version;
|
||||||
pipe;
|
return;
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
install_command = 'sudo pecl install -f ' + extension + pipe;
|
install_command = 'sudo pecl install -f ' + extension + pipe;
|
||||||
break;
|
break;
|
||||||
@ -2748,12 +2760,20 @@ function addExtensionLinux(extension_csv, version, pipe) {
|
|||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
extension = extension.toLowerCase();
|
extension = extension.toLowerCase();
|
||||||
const version_extension = version + extension;
|
const version_extension = version + extension;
|
||||||
|
const [extension_name, stability] = extension.split('-');
|
||||||
|
const prefix = yield utils.getExtensionPrefix(extension_name);
|
||||||
let install_command = '';
|
let install_command = '';
|
||||||
switch (true) {
|
switch (true) {
|
||||||
// match pre-release versions
|
// match pre-release versions
|
||||||
case /.*-(beta|alpha|devel|snapshot)/.test(version_extension):
|
case /.*-(beta|alpha|devel|snapshot)/.test(version_extension):
|
||||||
install_command = 'install_extension ' + extension + pipe;
|
script +=
|
||||||
break;
|
'\nadd_unstable_extension ' +
|
||||||
|
extension_name +
|
||||||
|
' ' +
|
||||||
|
stability +
|
||||||
|
' ' +
|
||||||
|
prefix;
|
||||||
|
return;
|
||||||
// match 5.6gearman..7.4gearman
|
// match 5.6gearman..7.4gearman
|
||||||
case /^((5\.6)|(7\.[0-4]))gearman$/.test(version_extension):
|
case /^((5\.6)|(7\.[0-4]))gearman$/.test(version_extension):
|
||||||
install_command =
|
install_command =
|
||||||
@ -2787,19 +2807,11 @@ function addExtensionLinux(extension_csv, version, pipe) {
|
|||||||
version +
|
version +
|
||||||
'-' +
|
'-' +
|
||||||
extension.replace('pdo_', '').replace('pdo-', '') +
|
extension.replace('pdo_', '').replace('pdo-', '') +
|
||||||
pipe +
|
|
||||||
' || sudo pecl install -f ' +
|
|
||||||
extension +
|
|
||||||
pipe;
|
pipe;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
script +=
|
script +=
|
||||||
'\nadd_extension ' +
|
'\nadd_extension ' + extension + ' "' + install_command + '" ' + prefix;
|
||||||
extension +
|
|
||||||
' "' +
|
|
||||||
install_command +
|
|
||||||
'" ' +
|
|
||||||
(yield utils.getExtensionPrefix(extension));
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
return script;
|
return script;
|
||||||
|
@ -34,6 +34,8 @@ jobs:
|
|||||||
# Install memcached if using ext-memcached
|
# Install memcached if using ext-memcached
|
||||||
extensions: mbstring, intl, redis, pdo_mysql
|
extensions: mbstring, intl, redis, pdo_mysql
|
||||||
coverage: pcov
|
coverage: pcov
|
||||||
|
- name: Start mysql service
|
||||||
|
run: sudo /etc/init.d/mysql start
|
||||||
- name: Get composer cache directory
|
- name: Get composer cache directory
|
||||||
id: composer-cache
|
id: composer-cache
|
||||||
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
||||||
|
@ -41,6 +41,8 @@ jobs:
|
|||||||
php-version: ${{ matrix.php-versions }}
|
php-version: ${{ matrix.php-versions }}
|
||||||
extensions: mbstring, dom, fileinfo, mysql
|
extensions: mbstring, dom, fileinfo, mysql
|
||||||
coverage: xdebug #optional
|
coverage: xdebug #optional
|
||||||
|
- name: Start mysql service
|
||||||
|
run: sudo /etc/init.d/mysql start
|
||||||
- name: Get composer cache directory
|
- name: Get composer cache directory
|
||||||
id: composer-cache
|
id: composer-cache
|
||||||
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
||||||
|
@ -41,6 +41,8 @@ jobs:
|
|||||||
php-version: ${{ matrix.php-versions }}
|
php-version: ${{ matrix.php-versions }}
|
||||||
extensions: mbstring, dom, fileinfo, mysql
|
extensions: mbstring, dom, fileinfo, mysql
|
||||||
coverage: xdebug #optional
|
coverage: xdebug #optional
|
||||||
|
- name: Start mysql service
|
||||||
|
run: sudo /etc/init.d/mysql start
|
||||||
- name: Get composer cache directory
|
- name: Get composer cache directory
|
||||||
id: composer-cache
|
id: composer-cache
|
||||||
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
||||||
|
@ -41,6 +41,8 @@ jobs:
|
|||||||
php-version: ${{ matrix.php-versions }}
|
php-version: ${{ matrix.php-versions }}
|
||||||
extensions: mbstring, dom, zip, phalcon4, mysql #use phalcon3 for the phalcon 3.x.
|
extensions: mbstring, dom, zip, phalcon4, mysql #use phalcon3 for the phalcon 3.x.
|
||||||
coverage: xdebug #optional
|
coverage: xdebug #optional
|
||||||
|
- name: Start mysql service
|
||||||
|
run: sudo /etc/init.d/mysql start
|
||||||
- name: Get composer cache directory
|
- name: Get composer cache directory
|
||||||
id: composer-cache
|
id: composer-cache
|
||||||
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
||||||
|
@ -28,6 +28,8 @@ jobs:
|
|||||||
php-version: ${{ matrix.php-versions }}
|
php-version: ${{ matrix.php-versions }}
|
||||||
extensions: mbstring, xml, ctype, iconv, intl, pdo_sqlite, mysql
|
extensions: mbstring, xml, ctype, iconv, intl, pdo_sqlite, mysql
|
||||||
coverage: xdebug #optional
|
coverage: xdebug #optional
|
||||||
|
- name: Start mysql service
|
||||||
|
run: sudo /etc/init.d/mysql start
|
||||||
- name: Get composer cache directory
|
- name: Get composer cache directory
|
||||||
id: composer-cache
|
id: composer-cache
|
||||||
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
||||||
|
@ -38,6 +38,8 @@ jobs:
|
|||||||
php-version: ${{ matrix.php-versions }}
|
php-version: ${{ matrix.php-versions }}
|
||||||
extensions: mbstring, intl, gd, imagick, zip, dom, mysql
|
extensions: mbstring, intl, gd, imagick, zip, dom, mysql
|
||||||
coverage: xdebug #optional
|
coverage: xdebug #optional
|
||||||
|
- name: Start mysql service
|
||||||
|
run: sudo /etc/init.d/mysql start
|
||||||
- name: Get composer cache directory
|
- name: Get composer cache directory
|
||||||
id: composer-cache
|
id: composer-cache
|
||||||
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
||||||
|
3904
package-lock.json
generated
3904
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
40
package.json
40
package.json
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "setup-php",
|
"name": "setup-php",
|
||||||
"version": "1.8.0",
|
"version": "1.8.4",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "Setup PHP for use with GitHub Actions",
|
"description": "Setup PHP for use with GitHub Actions",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
@ -24,28 +24,28 @@
|
|||||||
"author": "shivammathur",
|
"author": "shivammathur",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^1.2.0",
|
"@actions/core": "^1.2.3",
|
||||||
"@actions/exec": "^1.0.2",
|
"@actions/exec": "^1.0.3",
|
||||||
"@actions/io": "^1.0.1",
|
"@actions/io": "^1.0.2",
|
||||||
"fs": "0.0.1-security"
|
"fs": "0.0.1-security"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/jest": "^24.0.21",
|
"@types/jest": "^25.1.3",
|
||||||
"@types/node": "^12.12.16",
|
"@types/node": "^13.7.7",
|
||||||
"@typescript-eslint/eslint-plugin": "^2.11.0",
|
"@typescript-eslint/eslint-plugin": "^2.21.0",
|
||||||
"@typescript-eslint/parser": "^2.11.0",
|
"@typescript-eslint/parser": "^2.21.0",
|
||||||
"@zeit/ncc": "^0.21.0",
|
"@zeit/ncc": "^0.21.1",
|
||||||
"eslint": "^6.6.0",
|
"eslint": "^6.8.0",
|
||||||
"eslint-config-prettier": "^6.5.0",
|
"eslint-config-prettier": "^6.10.0",
|
||||||
"eslint-plugin-import": "^2.19.1",
|
"eslint-plugin-import": "^2.20.1",
|
||||||
"eslint-plugin-jest": "^23.0.3",
|
"eslint-plugin-jest": "^23.8.1",
|
||||||
"eslint-plugin-prettier": "^3.1.1",
|
"eslint-plugin-prettier": "^3.1.2",
|
||||||
"husky": "^3.0.9",
|
"husky": "^4.2.3",
|
||||||
"jest": "^24.9.0",
|
"jest": "^25.1.0",
|
||||||
"jest-circus": "^24.9.0",
|
"jest-circus": "^25.1.0",
|
||||||
"prettier": "^1.17.1",
|
"prettier": "^1.19.1",
|
||||||
"ts-jest": "^24.1.0",
|
"ts-jest": "^25.2.1",
|
||||||
"typescript": "^3.7.3"
|
"typescript": "^3.8.3"
|
||||||
},
|
},
|
||||||
"husky": {
|
"husky": {
|
||||||
"skipCI": true,
|
"skipCI": true,
|
||||||
|
@ -18,12 +18,20 @@ export async function addExtensionDarwin(
|
|||||||
await utils.asyncForEach(extensions, async function(extension: string) {
|
await utils.asyncForEach(extensions, async function(extension: string) {
|
||||||
extension = extension.toLowerCase();
|
extension = extension.toLowerCase();
|
||||||
const version_extension: string = version + extension;
|
const version_extension: string = version + extension;
|
||||||
|
const [extension_name, stability]: string[] = extension.split('-');
|
||||||
|
const prefix = await utils.getExtensionPrefix(extension_name);
|
||||||
let install_command = '';
|
let install_command = '';
|
||||||
switch (true) {
|
switch (true) {
|
||||||
// match pre-release versions
|
// match pre-release versions
|
||||||
case /.*-(beta|alpha|devel|snapshot)/.test(version_extension):
|
case /.*-(beta|alpha|devel|snapshot)/.test(version_extension):
|
||||||
install_command = 'install_extension ' + extension + pipe;
|
script +=
|
||||||
break;
|
'\nadd_unstable_extension ' +
|
||||||
|
extension_name +
|
||||||
|
' ' +
|
||||||
|
stability +
|
||||||
|
' ' +
|
||||||
|
prefix;
|
||||||
|
return;
|
||||||
case /5\.6xdebug/.test(version_extension):
|
case /5\.6xdebug/.test(version_extension):
|
||||||
install_command = 'sudo pecl install -f xdebug-2.5.5' + pipe;
|
install_command = 'sudo pecl install -f xdebug-2.5.5' + pipe;
|
||||||
break;
|
break;
|
||||||
@ -41,15 +49,14 @@ export async function addExtensionDarwin(
|
|||||||
pipe;
|
pipe;
|
||||||
break;
|
break;
|
||||||
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
|
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
|
||||||
install_command =
|
script +=
|
||||||
'sh ' +
|
'sh ' +
|
||||||
path.join(__dirname, '../src/scripts/ext/phalcon_darwin.sh') +
|
path.join(__dirname, '../src/scripts/ext/phalcon_darwin.sh') +
|
||||||
' ' +
|
' ' +
|
||||||
extension +
|
extension +
|
||||||
' ' +
|
' ' +
|
||||||
version +
|
version;
|
||||||
pipe;
|
return;
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
install_command = 'sudo pecl install -f ' + extension + pipe;
|
install_command = 'sudo pecl install -f ' + extension + pipe;
|
||||||
break;
|
break;
|
||||||
@ -124,12 +131,20 @@ export async function addExtensionLinux(
|
|||||||
await utils.asyncForEach(extensions, async function(extension: string) {
|
await utils.asyncForEach(extensions, async function(extension: string) {
|
||||||
extension = extension.toLowerCase();
|
extension = extension.toLowerCase();
|
||||||
const version_extension: string = version + extension;
|
const version_extension: string = version + extension;
|
||||||
|
const [extension_name, stability]: string[] = extension.split('-');
|
||||||
|
const prefix = await utils.getExtensionPrefix(extension_name);
|
||||||
let install_command = '';
|
let install_command = '';
|
||||||
switch (true) {
|
switch (true) {
|
||||||
// match pre-release versions
|
// match pre-release versions
|
||||||
case /.*-(beta|alpha|devel|snapshot)/.test(version_extension):
|
case /.*-(beta|alpha|devel|snapshot)/.test(version_extension):
|
||||||
install_command = 'install_extension ' + extension + pipe;
|
script +=
|
||||||
break;
|
'\nadd_unstable_extension ' +
|
||||||
|
extension_name +
|
||||||
|
' ' +
|
||||||
|
stability +
|
||||||
|
' ' +
|
||||||
|
prefix;
|
||||||
|
return;
|
||||||
// match 5.6gearman..7.4gearman
|
// match 5.6gearman..7.4gearman
|
||||||
case /^((5\.6)|(7\.[0-4]))gearman$/.test(version_extension):
|
case /^((5\.6)|(7\.[0-4]))gearman$/.test(version_extension):
|
||||||
install_command =
|
install_command =
|
||||||
@ -163,19 +178,11 @@ export async function addExtensionLinux(
|
|||||||
version +
|
version +
|
||||||
'-' +
|
'-' +
|
||||||
extension.replace('pdo_', '').replace('pdo-', '') +
|
extension.replace('pdo_', '').replace('pdo-', '') +
|
||||||
pipe +
|
|
||||||
' || sudo pecl install -f ' +
|
|
||||||
extension +
|
|
||||||
pipe;
|
pipe;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
script +=
|
script +=
|
||||||
'\nadd_extension ' +
|
'\nadd_extension ' + extension + ' "' + install_command + '" ' + prefix;
|
||||||
extension +
|
|
||||||
' "' +
|
|
||||||
install_command +
|
|
||||||
'" ' +
|
|
||||||
(await utils.getExtensionPrefix(extension));
|
|
||||||
});
|
});
|
||||||
return script;
|
return script;
|
||||||
}
|
}
|
||||||
|
@ -16,81 +16,131 @@ add_log() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Function to remove extensions
|
||||||
|
remove_extension() {
|
||||||
|
extension=$1
|
||||||
|
sudo sed -i '' "/$extension/d" "$ini_file"
|
||||||
|
sudo rm -rf "$scan_dir"/*"$extension"* >/dev/null 2>&1
|
||||||
|
sudo rm -rf "$ext_dir"/"$extension".so >/dev/null 2>&1
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to test if extension is loaded
|
||||||
|
check_extension() {
|
||||||
|
extension=$1
|
||||||
|
php -m | grep -i -q -w "$extension"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Fuction to get the PECL version
|
||||||
|
get_pecl_version() {
|
||||||
|
extension=$1
|
||||||
|
stability=$2
|
||||||
|
pecl_rest='https://pecl.php.net/rest/r/'
|
||||||
|
response=$(curl -q -sSL "$pecl_rest$extension"/allreleases.xml)
|
||||||
|
pecl_version=$(echo "$response" | grep -m 1 -Eo "(\d*\.\d*\.\d*$stability\d*)")
|
||||||
|
if [ ! "$pecl_version" ]; then
|
||||||
|
pecl_version=$(echo "$response" | grep -m 1 -Eo "(\d*\.\d*\.\d*)")
|
||||||
|
fi
|
||||||
|
echo "$pecl_version"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to install a PECL version
|
||||||
|
add_pecl_extension() {
|
||||||
|
extension=$1
|
||||||
|
pecl_version=$2
|
||||||
|
prefix=$3
|
||||||
|
if ! check_extension "$extension" && [ -e "$ext_dir/$extension.so" ]; then
|
||||||
|
echo "$prefix=$ext_dir/$extension.so" >>"$ini_file"
|
||||||
|
fi
|
||||||
|
ext_version=$(php -r "echo phpversion('$extension');")
|
||||||
|
if [ "$ext_version" = "$pecl_version" ]; then
|
||||||
|
add_log "$tick" "$extension" "Enabled"
|
||||||
|
else
|
||||||
|
remove_extension "$extension"
|
||||||
|
(
|
||||||
|
sudo pecl install -f "$extension-$pecl_version" >/dev/null 2>&1 &&
|
||||||
|
check_extension "$extension" &&
|
||||||
|
add_log "$tick" "$extension" "Installed and enabled"
|
||||||
|
) || add_log "$cross" "$extension" "Could not install $extension-$pecl_version on PHP $semver"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# Function to setup extensions
|
# Function to setup extensions
|
||||||
add_extension() {
|
add_extension() {
|
||||||
extension=$1
|
extension=$1
|
||||||
install_command=$2
|
install_command=$2
|
||||||
prefix=$3
|
prefix=$3
|
||||||
if ! php -m | grep -i -q -w "$extension" && [ -e "$ext_dir/$extension.so" ]; then
|
if ! check_extension "$extension" && [ -e "$ext_dir/$extension.so" ]; then
|
||||||
echo "$prefix=$extension" >>"$ini_file" && add_log "$tick" "$extension" "Enabled"
|
echo "$prefix=$ext_dir/$extension.so" >>"$ini_file" && add_log "$tick" "$extension" "Enabled"
|
||||||
elif php -m | grep -i -q -w "$extension"; then
|
elif check_extension "$extension"; then
|
||||||
add_log "$tick" "$extension" "Enabled"
|
add_log "$tick" "$extension" "Enabled"
|
||||||
elif ! php -m | grep -i -q -w "$extension"; then
|
elif ! check_extension "$extension"; then
|
||||||
(eval "$install_command" && add_log "$tick" "$extension" "Installed and enabled") ||
|
(
|
||||||
add_log "$cross" "$extension" "Could not install $extension on PHP $semver"
|
eval "$install_command" >/dev/null 2>&1 &&
|
||||||
|
check_extension "$extension" &&
|
||||||
|
add_log "$tick" "$extension" "Installed and enabled"
|
||||||
|
) || add_log "$cross" "$extension" "Could not install $extension on PHP $semver"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to force install extensions using PECL
|
# Function to pre-release extensions using PECL
|
||||||
install_extension() {
|
add_unstable_extension() {
|
||||||
extension=$1
|
extension=$1
|
||||||
extension_name="$(echo "$extension" | cut -d'-' -f 1)"
|
stability=$2
|
||||||
sudo sed -i "/$extension_name/d" "$ini_file"
|
prefix=$3
|
||||||
sudo rm -rf /etc/php/"$version"/cli/conf.d/*"$extension_name"* >/dev/null 2>&1
|
pecl_version=$(get_pecl_version "$extension" "$stability")
|
||||||
sudo rm -rf "$ext_dir"/"$extension_name".so >/dev/null 2>&1
|
add_pecl_extension "$extension" "$pecl_version" "$prefix"
|
||||||
sudo pecl install -f "$extension" >/dev/null 2>&1
|
|
||||||
}
|
|
||||||
|
|
||||||
# Function to remove extensions
|
|
||||||
remove_extension() {
|
|
||||||
extension=$1
|
|
||||||
sudo sed -i '' "/$1/d" "$ini_file"
|
|
||||||
sudo rm -rf "$ext_dir"/"$1".so >/dev/null 2>&1
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to setup a remote tool
|
# Function to setup a remote tool
|
||||||
add_tool() {
|
add_tool() {
|
||||||
url=$1
|
url=$1
|
||||||
tool=$2
|
tool=$2
|
||||||
if [ "$tool" = "composer" ]; then
|
tool_path="$tool_path_dir/$tool"
|
||||||
brew install composer >/dev/null 2>&1
|
if [ ! -e "$tool_path" ]; then
|
||||||
composer -q global config process-timeout 0
|
rm -rf "$tool_path"
|
||||||
|
fi
|
||||||
|
|
||||||
|
status_code=$(sudo curl -s -w "%{http_code}" -o "$tool_path" -L "$url")
|
||||||
|
if [ "$status_code" = "200" ]; then
|
||||||
|
sudo chmod a+x "$tool_path"
|
||||||
|
if [ "$tool" = "phive" ]; then
|
||||||
|
add_extension curl "sudo pecl install -f curl" extension >/dev/null 2>&1
|
||||||
|
add_extension mbstring "sudo pecl install -f mbstring" extension >/dev/null 2>&1
|
||||||
|
add_extension xml "sudo pecl install -f xml" extension >/dev/null 2>&1
|
||||||
|
elif [ "$tool" = "cs2pr" ]; then
|
||||||
|
sudo sed -i '' 's/exit(9)/exit(0)/' "$tool_path"
|
||||||
|
tr -d '\r' < "$tool_path" | sudo tee "$tool_path.tmp" >/dev/null 2>&1 && sudo mv "$tool_path.tmp" "$tool_path"
|
||||||
|
sudo chmod a+x "$tool_path"
|
||||||
|
fi
|
||||||
add_log "$tick" "$tool" "Added"
|
add_log "$tick" "$tool" "Added"
|
||||||
else
|
else
|
||||||
if [ ! -e /usr/local/bin/"$tool" ]; then
|
add_log "$cross" "$tool" "Could not setup $tool"
|
||||||
rm -rf /usr/local/bin/"${tool:?}"
|
|
||||||
fi
|
|
||||||
status_code=$(sudo curl -s -w "%{http_code}" -o /usr/local/bin/"$tool" -L "$url")
|
|
||||||
if [ "$status_code" = "200" ]; then
|
|
||||||
sudo chmod a+x /usr/local/bin/"$tool"
|
|
||||||
add_log "$tick" "$tool" "Added"
|
|
||||||
else
|
|
||||||
add_log "$cross" "$tool" "Could not setup $tool"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
if [ "$tool" = "phive" ]; then
|
|
||||||
add_extension curl >/dev/null 2>&1
|
|
||||||
add_extension mbstring >/dev/null 2>&1
|
|
||||||
add_extension xml >/dev/null 2>&1
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
add_composer_tool() {
|
# Function to add a tool using composer
|
||||||
|
add_composertool() {
|
||||||
tool=$1
|
tool=$1
|
||||||
release=$2
|
release=$2
|
||||||
prefix=$3
|
prefix=$3
|
||||||
(
|
(
|
||||||
composer global require "$prefix$release" >/dev/null 2>&1 && \
|
composer global require "$prefix$release" >/dev/null 2>&1 &&
|
||||||
sudo ln -sf "$(composer -q global config home)"/vendor/bin/"$tool" /usr/local/bin/"$tool" && \
|
sudo ln -sf "$(composer -q global config home)"/vendor/bin/"$tool" /usr/local/bin/"$tool" &&
|
||||||
add_log "$tick" "$tool" "Added"
|
add_log "$tick" "$tool" "Added"
|
||||||
) || add_log "$cross" "$tool" "Could not setup $tool"
|
) || add_log "$cross" "$tool" "Could not setup $tool"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Function to configure PECL
|
||||||
|
configure_pecl() {
|
||||||
|
for tool in pear pecl; do
|
||||||
|
sudo "$tool" config-set php_ini "$ini_file" >/dev/null 2>&1
|
||||||
|
sudo "$tool" config-set auto_discover 1 >/dev/null 2>&1
|
||||||
|
sudo "$tool" channel-update "$tool".php.net >/dev/null 2>&1
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to log PECL, it is installed along with PHP
|
||||||
add_pecl() {
|
add_pecl() {
|
||||||
sudo pear config-set php_ini "$ini_file" >/dev/null 2>&1
|
|
||||||
sudo pear config-set auto_discover 1 >/dev/null 2>&1
|
|
||||||
sudo pear channel-update pear.php.net >/dev/null 2>&1
|
|
||||||
sudo pecl channel-update pecl.php.net >/dev/null 2>&1
|
|
||||||
add_log "$tick" "PECL" "Added"
|
add_log "$tick" "PECL" "Added"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,14 +156,26 @@ setup_php_and_composer() {
|
|||||||
tick="✓"
|
tick="✓"
|
||||||
cross="✗"
|
cross="✗"
|
||||||
version=$1
|
version=$1
|
||||||
|
tool_path_dir="/usr/local/bin"
|
||||||
|
existing_version=$(php-config --version | cut -c 1-3)
|
||||||
|
|
||||||
# Setup PHP and composer
|
# Setup PHP
|
||||||
step_log "Setup PHP"
|
step_log "Setup PHP"
|
||||||
setup_php_and_composer
|
if [ "$existing_version" != "$version" ]; then
|
||||||
|
export HOMEBREW_NO_INSTALL_CLEANUP=TRUE >/dev/null 2>&1
|
||||||
|
brew tap shivammathur/homebrew-php >/dev/null 2>&1
|
||||||
|
brew install shivammathur/php/php@"$version" >/dev/null 2>&1
|
||||||
|
brew link --force --overwrite php@"$version" >/dev/null 2>&1
|
||||||
|
status="Installed"
|
||||||
|
else
|
||||||
|
status="Found"
|
||||||
|
fi
|
||||||
ini_file=$(php -d "date.timezone=UTC" --ini | grep "Loaded Configuration" | sed -e "s|.*:s*||" | sed "s/ //g")
|
ini_file=$(php -d "date.timezone=UTC" --ini | grep "Loaded Configuration" | sed -e "s|.*:s*||" | sed "s/ //g")
|
||||||
|
sudo chmod 777 "$ini_file" "$tool_path_dir"
|
||||||
echo "date.timezone=UTC" >>"$ini_file"
|
echo "date.timezone=UTC" >>"$ini_file"
|
||||||
ext_dir=$(php -i | grep "extension_dir => /usr" | sed -e "s|.*=> s*||")
|
ext_dir=$(php -i | grep -Ei "extension_dir => /(usr|opt)" | sed -e "s|.*=> s*||")
|
||||||
sudo chmod 777 "$ini_file"
|
scan_dir=$(php --ini | grep additional | sed -e "s|.*: s*||")
|
||||||
mkdir -p "$(pecl config-get ext_dir)"
|
sudo mkdir -p "$ext_dir"
|
||||||
semver=$(php -v | head -n 1 | cut -f 2 -d ' ')
|
semver=$(php -v | head -n 1 | cut -f 2 -d ' ')
|
||||||
add_log "$tick" "PHP" "Installed PHP $semver"
|
configure_pecl
|
||||||
|
add_log "$tick" "PHP" "$status PHP $semver"
|
||||||
|
@ -22,7 +22,7 @@ Function Install-Phalcon() {
|
|||||||
$zip_file = $match.Matches[0].Groups[1].Value
|
$zip_file = $match.Matches[0].Groups[1].Value
|
||||||
Invoke-WebRequest -UseBasicParsing -Uri $domain/$zip_file -OutFile $ENV:RUNNER_TOOL_CACHE\phalcon.zip > $null 2>&1
|
Invoke-WebRequest -UseBasicParsing -Uri $domain/$zip_file -OutFile $ENV:RUNNER_TOOL_CACHE\phalcon.zip > $null 2>&1
|
||||||
Expand-Archive -Path $ENV:RUNNER_TOOL_CACHE\phalcon.zip -DestinationPath $ENV:RUNNER_TOOL_CACHE\phalcon -Force > $null 2>&1
|
Expand-Archive -Path $ENV:RUNNER_TOOL_CACHE\phalcon.zip -DestinationPath $ENV:RUNNER_TOOL_CACHE\phalcon -Force > $null 2>&1
|
||||||
New-Item -ItemType SymbolicLink -Path $ext_dir\php_phalcon.dll -Target $ENV:RUNNER_TOOL_CACHE\phalcon\php_phalcon.dll > $null 2>&1
|
Copy-Item -Path "$ENV:RUNNER_TOOL_CACHE\phalcon\php_phalcon.dll" -Destination "$ext_dir\php_phalcon.dll"
|
||||||
Enable-PhpExtension -Extension phalcon -Path $php_dir
|
Enable-PhpExtension -Extension phalcon -Path $php_dir
|
||||||
}
|
}
|
||||||
printf "\033[%s;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" "32" $tick $extension "Installed and enabled"
|
printf "\033[%s;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" "32" $tick $extension "Installed and enabled"
|
||||||
|
@ -27,14 +27,7 @@ install_phalcon() {
|
|||||||
add_log "$cross" "$extension" "Could not install $extension on PHP $semver"
|
add_log "$cross" "$extension" "Could not install $extension on PHP $semver"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to remove an extensions
|
ini_file="/etc/php/$2/cli/conf.d/50-phalcon.ini"
|
||||||
remove_extension() {
|
|
||||||
extension=$1
|
|
||||||
sudo sed -i "/$extension/d" "$ini_file"
|
|
||||||
rm -rf "$ext_dir/$extension.so"
|
|
||||||
}
|
|
||||||
|
|
||||||
ini_file=$(php --ini | grep "Loaded Configuration" | sed -e "s|.*:s*||" | sed "s/ //g")
|
|
||||||
ext_dir=$(php -i | grep "extension_dir => /usr" | sed -e "s|.*=> s*||")
|
ext_dir=$(php -i | grep "extension_dir => /usr" | sed -e "s|.*=> s*||")
|
||||||
semver=$(php -v | head -n 1 | cut -f 2 -d ' ' | cut -f 1 -d '-')
|
semver=$(php -v | head -n 1 | cut -f 2 -d ' ' | cut -f 1 -d '-')
|
||||||
extension_major_version=$(echo "$1" | grep -i -Po '\d')
|
extension_major_version=$(echo "$1" | grep -i -Po '\d')
|
||||||
@ -44,18 +37,16 @@ cross="✗"
|
|||||||
|
|
||||||
if [ "$extension_major_version" = "4" ]; then
|
if [ "$extension_major_version" = "4" ]; then
|
||||||
if [ -e "$ext_dir/psr.so" ]; then
|
if [ -e "$ext_dir/psr.so" ]; then
|
||||||
echo "extension=psr" >>"$ini_file"
|
echo "extension=psr.so" | sudo tee -a "$ini_file" >/dev/null 2>&1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -e "$ext_dir/phalcon.so" ]; then
|
if [ -e "$ext_dir/phalcon.so" ]; then
|
||||||
if php -m | grep -i -q -w psr; then
|
if php -m | grep -i -q -w psr; then
|
||||||
echo "extension=phalcon" >>"$ini_file"
|
phalcon_version=$(php -d="extension=phalcon" -r "echo phpversion('phalcon');" | cut -d'.' -f 1)
|
||||||
phalcon_version=$(php -r "echo phpversion('phalcon');" | cut -d'.' -f 1)
|
|
||||||
if [ "$phalcon_version" != "$extension_major_version" ]; then
|
if [ "$phalcon_version" != "$extension_major_version" ]; then
|
||||||
remove_extension "psr" >/dev/null 2>&1
|
|
||||||
remove_extension "phalcon" >/dev/null 2>&1
|
|
||||||
install_phalcon "$1" "$2"
|
install_phalcon "$1" "$2"
|
||||||
else
|
else
|
||||||
|
echo "extension=phalcon.so" | sudo tee -a "$ini_file" >/dev/null 2>&1
|
||||||
add_log "$tick" "$1" "Enabled"
|
add_log "$tick" "$1" "Enabled"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
@ -68,12 +59,11 @@ fi
|
|||||||
|
|
||||||
if [ "$extension_major_version" = "3" ]; then
|
if [ "$extension_major_version" = "3" ]; then
|
||||||
if [ -e "$ext_dir/phalcon.so" ]; then
|
if [ -e "$ext_dir/phalcon.so" ]; then
|
||||||
echo "extension=phalcon" >>"$ini_file"
|
phalcon_version=$(php -d="extension=phalcon.so" -r "echo phpversion('phalcon');" | cut -d'.' -f 1)
|
||||||
phalcon_version=$(php -r "echo phpversion('phalcon');" | cut -d'.' -f 1)
|
|
||||||
if [ "$phalcon_version" != "$extension_major_version" ]; then
|
if [ "$phalcon_version" != "$extension_major_version" ]; then
|
||||||
remove_extension "phalcon" >/dev/null 2>&1
|
|
||||||
install_phalcon "$1" "$2"
|
install_phalcon "$1" "$2"
|
||||||
else
|
else
|
||||||
|
echo "extension=phalcon.so" | sudo tee -a "$ini_file" >/dev/null 2>&1
|
||||||
add_log "$tick" "$1" "Enabled"
|
add_log "$tick" "$1" "Enabled"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
|
@ -1,22 +1,43 @@
|
|||||||
|
# Function to log result of a operation
|
||||||
|
add_log() {
|
||||||
|
mark=$1
|
||||||
|
subject=$2
|
||||||
|
message=$3
|
||||||
|
if [ "$mark" = "$tick" ]; then
|
||||||
|
printf "\033[32;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s\033[0m\n" "$mark" "$subject" "$message"
|
||||||
|
else
|
||||||
|
printf "\033[31;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s\033[0m\n" "$mark" "$subject" "$message"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to install phalcon
|
||||||
|
install_phalcon() {
|
||||||
|
(
|
||||||
|
brew tap shivammathur/homebrew-phalcon >/dev/null 2>&1
|
||||||
|
brew install phalcon@"$php_version"_"$extension_major" >/dev/null 2>&1
|
||||||
|
sudo cp /usr/local/opt/psr@"$php_version"/psr.so "$ext_dir" >/dev/null 2>&1
|
||||||
|
sudo cp /usr/local/opt/phalcon@"$php_version"_"$extension_major"/phalcon.so "$ext_dir" >/dev/null 2>&1
|
||||||
|
add_log "$tick" "$extension" "Installed and enabled"
|
||||||
|
) || add_log "$cross" "$extension" "Could not install $extension on PHP $semver"
|
||||||
|
}
|
||||||
|
|
||||||
|
tick="✓"
|
||||||
|
cross="✗"
|
||||||
extension=$1
|
extension=$1
|
||||||
extension_major=${extension: -1}
|
extension_major=${extension: -1}
|
||||||
php_version=$2
|
php_version=$2
|
||||||
|
semver=$(php -v | head -n 1 | cut -f 2 -d ' ')
|
||||||
ini_file=$(php -d "date.timezone=UTC" --ini | grep "Loaded Configuration" | sed -e "s|.*:s*||" | sed "s/ //g")
|
ini_file=$(php -d "date.timezone=UTC" --ini | grep "Loaded Configuration" | sed -e "s|.*:s*||" | sed "s/ //g")
|
||||||
ext_dir=$(php -i | grep "extension_dir => /usr" | sed -e "s|.*=> s*||")
|
ext_dir=$(php -i | grep "extension_dir => /usr" | sed -e "s|.*=> s*||")
|
||||||
if [ -e "$ext_dir/psr.so" ] && [ -e "$ext_dir/phalcon.so" ]; then
|
if [ -e "$ext_dir/psr.so" ] && [ -e "$ext_dir/phalcon.so" ]; then
|
||||||
echo "extension=psr" >>"$ini_file"
|
phalcon_version=$(php -d="extension=psr.so" -d="extension=phalcon.so" -r "echo phpversion('phalcon');" | cut -d'.' -f 1)
|
||||||
echo "extension=phalcon" >>"$ini_file"
|
|
||||||
phalcon_semver=$(php -r "echo phpversion('phalcon');")
|
|
||||||
phalcon_version=$(echo "$phalcon_semver" | cut -d'.' -f 1)
|
|
||||||
if [ "$phalcon_version" != "$extension_major" ]; then
|
if [ "$phalcon_version" != "$extension_major" ]; then
|
||||||
sudo sed -i '' "/psr/d" "$ini_file"
|
install_phalcon
|
||||||
sudo sed -i '' "/phalcon/d" "$ini_file"
|
else
|
||||||
rm -rf "$ext_dir"/psr.so
|
echo "extension=psr.so" >>"$ini_file"
|
||||||
rm -rf "$ext_dir"/phalcon.so
|
echo "extension=phalcon.so" >>"$ini_file"
|
||||||
brew tap shivammathur/homebrew-phalcon
|
add_log "$tick" "$extension" "Enabled"
|
||||||
brew install phalcon@"$php_version"_"$extension_major"
|
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
brew tap shivammathur/homebrew-phalcon
|
install_phalcon
|
||||||
brew install phalcon@"$php_version"_"$extension_major"
|
|
||||||
fi
|
fi
|
@ -24,42 +24,100 @@ update_ppa() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to setup extensions
|
configure_pecl() {
|
||||||
add_extension() {
|
if [ "$pecl_config" = "false" ] && [ -e /usr/bin/pecl ]; then
|
||||||
extension=$1
|
for tool in pear pecl; do
|
||||||
install_command=$2
|
sudo "$tool" config-set php_ini "$ini_file" >/dev/null 2>&1
|
||||||
prefix=$3
|
sudo "$tool" config-set auto_discover 1 >/dev/null 2>&1
|
||||||
if ! php -m | grep -i -q -w "$extension" && [ -e "$ext_dir/$extension.so" ]; then
|
sudo "$tool" channel-update "$tool".php.net >/dev/null 2>&1
|
||||||
echo "$prefix=$extension" >>"$ini_file" && add_log "$tick" "$extension" "Enabled"
|
done
|
||||||
elif php -m | grep -i -q -w "$extension"; then
|
pecl_config="true"
|
||||||
add_log "$tick" "$extension" "Enabled"
|
|
||||||
elif ! php -m | grep -i -q -w "$extension"; then
|
|
||||||
(eval "$install_command" && add_log "$tick" "$extension" "Installed and enabled") ||
|
|
||||||
(update_ppa && eval "$install_command" && add_log "$tick" "$extension" "Installed and enabled") ||
|
|
||||||
add_log "$cross" "$extension" "Could not install $extension on PHP $semver"
|
|
||||||
fi
|
fi
|
||||||
sudo chmod 777 "$ini_file"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to force install extensions using PECL
|
# Fuction to get the PECL version
|
||||||
install_extension() {
|
get_pecl_version() {
|
||||||
extension=$1
|
extension=$1
|
||||||
extension_name="$(echo "$extension" | cut -d'-' -f 1)"
|
stability=$2
|
||||||
sudo sed -i "/$extension_name/d" "$ini_file"
|
pecl_rest='https://pecl.php.net/rest/r/'
|
||||||
sudo rm -rf /etc/php/"$version"/cli/conf.d/*"$extension_name"* >/dev/null 2>&1
|
response=$(curl -q -sSL "$pecl_rest$extension"/allreleases.xml)
|
||||||
sudo rm -rf "$ext_dir"/"$extension_name".so >/dev/null 2>&1
|
pecl_version=$(echo "$response" | grep -m 1 -Po "(\d*\.\d*\.\d*$stability\d*)")
|
||||||
sudo pecl install -f "$extension" >/dev/null 2>&1
|
if [ ! "$pecl_version" ]; then
|
||||||
|
pecl_version=$(echo "$response" | grep -m 1 -Po "(\d*\.\d*\.\d*)")
|
||||||
|
fi
|
||||||
|
echo "$pecl_version"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to remove extensions
|
# Function to test if extension is loaded
|
||||||
|
check_extension() {
|
||||||
|
extension=$1
|
||||||
|
php -m | grep -i -q -w "$extension"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to delete extensions
|
||||||
|
delete_extension() {
|
||||||
|
extension=$1
|
||||||
|
sudo sed -i "/$extension/d" "$ini_file"
|
||||||
|
sudo rm -rf "$scan_dir"/*"$extension"* >/dev/null 2>&1
|
||||||
|
sudo rm -rf "$ext_dir"/"$extension".so >/dev/null 2>&1
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to disable and delete extensions
|
||||||
remove_extension() {
|
remove_extension() {
|
||||||
extension=$1
|
extension=$1
|
||||||
if [ -e /etc/php/"$version"/mods-available/"$extension".ini ]; then
|
if [ -e /etc/php/"$version"/mods-available/"$extension".ini ]; then
|
||||||
sudo phpdismod -v "$version" "$extension"
|
sudo phpdismod -v "$version" "$extension"
|
||||||
fi
|
fi
|
||||||
sudo sed -i "/$extension/d" "$ini_file"
|
delete_extension "$extension"
|
||||||
sudo rm -rf /etc/php/"$version"/cli/conf.d/*"$extension"* >/dev/null 2>&1
|
}
|
||||||
sudo rm -rf "$ext_dir"/"$extension".so >/dev/null 2>&1
|
|
||||||
|
# Function to setup extensions
|
||||||
|
add_extension() {
|
||||||
|
extension=$1
|
||||||
|
install_command=$2
|
||||||
|
prefix=$3
|
||||||
|
if ! check_extension "$extension" && [ -e "$ext_dir/$extension.so" ]; then
|
||||||
|
echo "$prefix=$extension.so" >>"$ini_file" && add_log "$tick" "$extension" "Enabled"
|
||||||
|
elif check_extension "$extension"; then
|
||||||
|
add_log "$tick" "$extension" "Enabled"
|
||||||
|
elif ! check_extension "$extension"; then
|
||||||
|
eval "$install_command" >/dev/null 2>&1 ||
|
||||||
|
(update_ppa && eval "$install_command" >/dev/null 2>&1) ||
|
||||||
|
sudo pecl install -f "$extension" >/dev/null 2>&1
|
||||||
|
(check_extension "$extension" && add_log "$tick" "$extension" "Installed and enabled") ||
|
||||||
|
add_log "$cross" "$extension" "Could not install $extension on PHP $semver"
|
||||||
|
fi
|
||||||
|
sudo chmod 777 "$ini_file"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to install a PECL version
|
||||||
|
add_pecl_extension() {
|
||||||
|
extension=$1
|
||||||
|
pecl_version=$2
|
||||||
|
prefix=$3
|
||||||
|
if ! check_extension "$extension" && [ -e "$ext_dir/$extension.so" ]; then
|
||||||
|
echo "$prefix=$ext_dir/$extension.so" >>"$ini_file"
|
||||||
|
fi
|
||||||
|
ext_version=$(php -r "echo phpversion('$extension');")
|
||||||
|
if [ "$ext_version" = "$pecl_version" ]; then
|
||||||
|
add_log "$tick" "$extension" "Enabled"
|
||||||
|
else
|
||||||
|
delete_extension "$extension"
|
||||||
|
(
|
||||||
|
sudo pecl install -f "$extension-$pecl_version" >/dev/null 2>&1 &&
|
||||||
|
check_extension "$extension" &&
|
||||||
|
add_log "$tick" "$extension" "Installed and enabled"
|
||||||
|
) || add_log "$cross" "$extension" "Could not install $extension-$pecl_version on PHP $semver"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to pre-release extensions using PECL
|
||||||
|
add_unstable_extension() {
|
||||||
|
extension=$1
|
||||||
|
stability=$2
|
||||||
|
prefix=$3
|
||||||
|
pecl_version=$(get_pecl_version "$extension" "$stability")
|
||||||
|
add_pecl_extension "$extension" "$pecl_version" "$prefix"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to update extension
|
# Function to update extension
|
||||||
@ -81,34 +139,37 @@ update_extension() {
|
|||||||
add_tool() {
|
add_tool() {
|
||||||
url=$1
|
url=$1
|
||||||
tool=$2
|
tool=$2
|
||||||
if [ ! -e /usr/local/bin/"$tool" ]; then
|
tool_path="$tool_path_dir/$tool"
|
||||||
rm -rf /usr/local/bin/"${tool:?}"
|
if [ ! -e "$tool_path" ]; then
|
||||||
|
rm -rf "$tool_path"
|
||||||
fi
|
fi
|
||||||
status_code=$(sudo curl -s -w "%{http_code}" -o /usr/local/bin/"$tool" -L "$url")
|
status_code=$(sudo curl -s -w "%{http_code}" -o "$tool_path" -L "$url")
|
||||||
if [ "$status_code" = "200" ]; then
|
if [ "$status_code" = "200" ]; then
|
||||||
sudo chmod a+x /usr/local/bin/"$tool"
|
sudo chmod a+x "$tool_path"
|
||||||
|
if [ "$tool" = "composer" ]; then
|
||||||
|
composer -q global config process-timeout 0
|
||||||
|
elif [ "$tool" = "cs2pr" ]; then
|
||||||
|
sudo sed -i 's/\r$//; s/exit(9)/exit(0)/' "$tool_path"
|
||||||
|
elif [ "$tool" = "phive" ]; then
|
||||||
|
add_extension curl "$apt_install php$version-curl" extension >/dev/null 2>&1
|
||||||
|
add_extension mbstring "$apt_install php$version-mbstring" extension >/dev/null 2>&1
|
||||||
|
add_extension xml "$apt_install php$version-xml" extension >/dev/null 2>&1
|
||||||
|
fi
|
||||||
add_log "$tick" "$tool" "Added"
|
add_log "$tick" "$tool" "Added"
|
||||||
else
|
else
|
||||||
add_log "$cross" "$tool" "Could not setup $tool"
|
add_log "$cross" "$tool" "Could not setup $tool"
|
||||||
fi
|
fi
|
||||||
if [ "$tool" = "composer" ]; then
|
|
||||||
composer -q global config process-timeout 0
|
|
||||||
fi
|
|
||||||
if [ "$tool" = "phive" ]; then
|
|
||||||
add_extension curl >/dev/null 2>&1
|
|
||||||
add_extension mbstring >/dev/null 2>&1
|
|
||||||
add_extension xml >/dev/null 2>&1
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
add_composer_tool() {
|
# Function to setup a tool using composer
|
||||||
|
add_composertool() {
|
||||||
tool=$1
|
tool=$1
|
||||||
release=$2
|
release=$2
|
||||||
prefix=$3
|
prefix=$3
|
||||||
(
|
(
|
||||||
composer global require "$prefix$release" >/dev/null 2>&1 && \
|
composer global require "$prefix$release" >/dev/null 2>&1 &&
|
||||||
sudo ln -sf "$(composer -q global config home)"/vendor/bin/"$tool" /usr/local/bin/"$tool" && \
|
sudo ln -sf "$(composer -q global config home)"/vendor/bin/"$tool" /usr/local/bin/"$tool" &&
|
||||||
add_log "$tick" "$tool" "Added"
|
add_log "$tick" "$tool" "Added"
|
||||||
) || add_log "$cross" "$tool" "Could not setup $tool"
|
) || add_log "$cross" "$tool" "Could not setup $tool"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,6 +180,7 @@ add_devtools() {
|
|||||||
fi
|
fi
|
||||||
sudo update-alternatives --set php-config /usr/bin/php-config"$version" >/dev/null 2>&1
|
sudo update-alternatives --set php-config /usr/bin/php-config"$version" >/dev/null 2>&1
|
||||||
sudo update-alternatives --set phpize /usr/bin/phpize"$version" >/dev/null 2>&1
|
sudo update-alternatives --set phpize /usr/bin/phpize"$version" >/dev/null 2>&1
|
||||||
|
configure_pecl
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to setup the nightly build from master branch
|
# Function to setup the nightly build from master branch
|
||||||
@ -126,8 +188,8 @@ setup_master() {
|
|||||||
tar_file=php_"$version"%2Bubuntu"$(lsb_release -r -s)".tar.xz
|
tar_file=php_"$version"%2Bubuntu"$(lsb_release -r -s)".tar.xz
|
||||||
install_dir=~/php/"$version"
|
install_dir=~/php/"$version"
|
||||||
sudo mkdir -m 777 -p ~/php
|
sudo mkdir -m 777 -p ~/php
|
||||||
$apt_install libicu-dev >/dev/null 2>&1
|
update_ppa && $apt_install libicu64 libicu-dev >/dev/null 2>&1
|
||||||
curl -o "$tar_file" -L https://bintray.com/shivammathur/php/download_file?file_path="$tar_file" >/dev/null 2>&1
|
curl -SLO https://dl.bintray.com/shivammathur/php/"$tar_file" >/dev/null 2>&1
|
||||||
sudo tar xf "$tar_file" -C ~/php >/dev/null 2>&1
|
sudo tar xf "$tar_file" -C ~/php >/dev/null 2>&1
|
||||||
rm -rf "$tar_file"
|
rm -rf "$tar_file"
|
||||||
sudo ln -sf -S "$version" "$install_dir"/bin/* /usr/bin/
|
sudo ln -sf -S "$version" "$install_dir"/bin/* /usr/bin/
|
||||||
@ -137,11 +199,10 @@ setup_master() {
|
|||||||
# Function to setup PECL
|
# Function to setup PECL
|
||||||
add_pecl() {
|
add_pecl() {
|
||||||
add_devtools
|
add_devtools
|
||||||
$apt_install php-pear >/dev/null 2>&1
|
if [ ! -e /usr/bin/pecl ]; then
|
||||||
sudo pear config-set php_ini "$ini_file" >/dev/null 2>&1
|
$apt_install php-pear >/dev/null 2>&1
|
||||||
sudo pear config-set auto_discover 1 >/dev/null 2>&1
|
fi
|
||||||
sudo pear channel-update pear.php.net >/dev/null 2>&1
|
configure_pecl
|
||||||
sudo pecl channel-update pecl.php.net >/dev/null 2>&1
|
|
||||||
add_log "$tick" "PECL" "Added"
|
add_log "$tick" "PECL" "Added"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -154,14 +215,25 @@ switch_version() {
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Function to get PHP version in semver format
|
||||||
|
php_semver() {
|
||||||
|
if [ ! "$version" = "8.0" ]; then
|
||||||
|
php"$version" -v | head -n 1 | cut -f 2 -d ' ' | cut -f 1 -d '-'
|
||||||
|
else
|
||||||
|
php -v | head -n 1 | cut -f 2 -d ' '
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# Variables
|
# Variables
|
||||||
tick="✓"
|
tick="✓"
|
||||||
cross="✗"
|
cross="✗"
|
||||||
ppa_updated="false"
|
ppa_updated="false"
|
||||||
|
pecl_config="false"
|
||||||
version=$1
|
version=$1
|
||||||
apt_install="sudo DEBIAN_FRONTEND=noninteractive apt-fast install -y"
|
debconf_fix="DEBIAN_FRONTEND=noninteractive"
|
||||||
|
apt_install="sudo $debconf_fix apt-fast install -y"
|
||||||
|
tool_path_dir="/usr/local/bin"
|
||||||
existing_version=$(php-config --version | cut -c 1-3)
|
existing_version=$(php-config --version | cut -c 1-3)
|
||||||
semver=$(php -v | head -n 1 | cut -f 2 -d ' ' | cut -f 1 -d '-')
|
|
||||||
|
|
||||||
# Setup PHP
|
# Setup PHP
|
||||||
step_log "Setup PHP"
|
step_log "Setup PHP"
|
||||||
@ -170,37 +242,25 @@ sudo mkdir -p /run/php
|
|||||||
|
|
||||||
if [ "$existing_version" != "$version" ]; then
|
if [ "$existing_version" != "$version" ]; then
|
||||||
if [ ! -e "/usr/bin/php$version" ]; then
|
if [ ! -e "/usr/bin/php$version" ]; then
|
||||||
update_ppa
|
if [ "$version" = "8.0" ]; then
|
||||||
ppa_updated=1
|
|
||||||
if [ "$version" = "7.4" ]; then
|
|
||||||
$apt_install php"$version" php"$version"-curl php"$version"-mbstring php"$version"-xml php"$version"-phpdbg >/dev/null 2>&1
|
|
||||||
elif [ "$version" = "8.0" ]; then
|
|
||||||
setup_master
|
setup_master
|
||||||
else
|
else
|
||||||
|
update_ppa
|
||||||
$apt_install php"$version" php"$version"-curl php"$version"-mbstring php"$version"-xml >/dev/null 2>&1
|
$apt_install php"$version" php"$version"-curl php"$version"-mbstring php"$version"-xml >/dev/null 2>&1
|
||||||
fi
|
fi
|
||||||
status="installed"
|
status="Installed"
|
||||||
else
|
else
|
||||||
status="switched"
|
status="Switched to"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
switch_version
|
switch_version
|
||||||
|
|
||||||
semver=$(php -v | head -n 1 | cut -f 2 -d ' ' | cut -f 1 -d '-')
|
|
||||||
if [ "$version" = "8.0" ]; then
|
|
||||||
semver=$(php -v | head -n 1 | cut -f 2 -d ' ')
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$status" != "switched" ]; then
|
|
||||||
status="Installed PHP $semver"
|
|
||||||
else
|
|
||||||
status="Switched to PHP $semver"
|
|
||||||
fi
|
|
||||||
else
|
else
|
||||||
status="PHP $semver Found"
|
status="Found"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
semver=$(php_semver)
|
||||||
ini_file=$(php --ini | grep "Loaded Configuration" | sed -e "s|.*:s*||" | sed "s/ //g")
|
ini_file=$(php --ini | grep "Loaded Configuration" | sed -e "s|.*:s*||" | sed "s/ //g")
|
||||||
ext_dir=$(php -i | grep "extension_dir => /usr" | sed -e "s|.*=> s*||")
|
ext_dir=$(php -i | grep "extension_dir => /" | sed -e "s|.*=> s*||")
|
||||||
sudo chmod 777 "$ini_file"
|
scan_dir=$(php --ini | grep additional | sed -e "s|.*: s*||")
|
||||||
add_log "$tick" "PHP" "$status"
|
sudo chmod 777 "$ini_file" "$tool_path_dir"
|
||||||
|
add_log "$tick" "PHP" "$status PHP $semver"
|
||||||
|
@ -35,7 +35,7 @@ Function Add-Extension {
|
|||||||
)
|
)
|
||||||
try {
|
try {
|
||||||
$extension_info = Get-PhpExtension -Path $php_dir | Where-Object { $_.Name -eq $extension -or $_.Handle -eq $extension }
|
$extension_info = Get-PhpExtension -Path $php_dir | Where-Object { $_.Name -eq $extension -or $_.Handle -eq $extension }
|
||||||
if ($null -ne $extension_info -and $mininum_stability -eq 'stable') {
|
if ($null -ne $extension_info) {
|
||||||
switch ($extension_info.State) {
|
switch ($extension_info.State) {
|
||||||
'Builtin' {
|
'Builtin' {
|
||||||
Add-Log $tick $extension "Enabled"
|
Add-Log $tick $extension "Enabled"
|
||||||
@ -51,11 +51,7 @@ Function Add-Extension {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Install-PhpExtension -Extension $extension -MinimumStability $mininum_stability -Path $php_dir
|
Install-PhpExtension -Extension $extension -MinimumStability $mininum_stability -Path $php_dir
|
||||||
if($mininum_stability -ne 'stable') {
|
Add-Log $tick $extension "Installed and enabled"
|
||||||
Add-Log $tick "$extension-$mininum_stability" "Installed and enabled"
|
|
||||||
} else {
|
|
||||||
Add-Log $tick $extension "Installed and enabled"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch {
|
catch {
|
||||||
@ -118,6 +114,9 @@ Function Add-Tool() {
|
|||||||
Add-Extension mbstring >$null 2>&1
|
Add-Extension mbstring >$null 2>&1
|
||||||
Add-Extension xml >$null 2>&1
|
Add-Extension xml >$null 2>&1
|
||||||
}
|
}
|
||||||
|
if($tool -eq "cs2pr") {
|
||||||
|
(Get-Content $php_dir/cs2pr).replace('exit(9)', 'exit(0)') | Set-Content $php_dir/cs2pr
|
||||||
|
}
|
||||||
if (((Get-ChildItem -Path $php_dir/* | Where-Object Name -Match "^$tool(.exe|.phar)*$").Count -gt 0)) {
|
if (((Get-ChildItem -Path $php_dir/* | Where-Object Name -Match "^$tool(.exe|.phar)*$").Count -gt 0)) {
|
||||||
Add-Log $tick $tool "Added"
|
Add-Log $tick $tool "Added"
|
||||||
} else {
|
} else {
|
||||||
@ -125,7 +124,7 @@ Function Add-Tool() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Function Add-Composer-Tool() {
|
Function Add-Composertool() {
|
||||||
Param (
|
Param (
|
||||||
[Parameter(Position = 0, Mandatory = $true)]
|
[Parameter(Position = 0, Mandatory = $true)]
|
||||||
[ValidateNotNull()]
|
[ValidateNotNull()]
|
||||||
@ -153,7 +152,7 @@ Function Add-Composer-Tool() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Function Add-PECL() {
|
Function Add-Pecl() {
|
||||||
Add-Log $tick "PECL" "Use extensions input to setup PECL extensions on windows"
|
Add-Log $tick "PECL" "Use extensions input to setup PECL extensions on windows"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -195,10 +194,7 @@ if ($null -eq $installed -or -not("$($installed.Version).".StartsWith(($version
|
|||||||
|
|
||||||
Install-Php -Version $version -Architecture $arch -ThreadSafe $ts -InstallVC -Path $php_dir -TimeZone UTC -InitialPhpIni Production -Force >$null 2>&1
|
Install-Php -Version $version -Architecture $arch -ThreadSafe $ts -InstallVC -Path $php_dir -TimeZone UTC -InitialPhpIni Production -Force >$null 2>&1
|
||||||
} else {
|
} else {
|
||||||
$updated = Update-Php $php_dir >$null 2>&1
|
$status = "Found"
|
||||||
if($updated -eq $False) {
|
|
||||||
$status = "Found"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$installed = Get-Php -Path $php_dir
|
$installed = Get-Php -Path $php_dir
|
||||||
|
166
src/tools.ts
166
src/tools.ts
@ -1,60 +1,20 @@
|
|||||||
import * as utils from './utils';
|
import * as utils from './utils';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function to get command to setup tool
|
* Function to get command to setup tools
|
||||||
*
|
*
|
||||||
* @param os_version
|
* @param os_version
|
||||||
*/
|
*/
|
||||||
export async function getArchiveCommand(os_version: string): Promise<string> {
|
export async function getCommand(
|
||||||
|
os_version: string,
|
||||||
|
suffix: string
|
||||||
|
): Promise<string> {
|
||||||
switch (os_version) {
|
switch (os_version) {
|
||||||
case 'linux':
|
case 'linux':
|
||||||
case 'darwin':
|
case 'darwin':
|
||||||
return 'add_tool ';
|
return 'add_' + suffix + ' ';
|
||||||
case 'win32':
|
case 'win32':
|
||||||
return 'Add-Tool ';
|
return 'Add-' + suffix.charAt(0).toUpperCase() + suffix.slice(1) + ' ';
|
||||||
default:
|
|
||||||
return await utils.log(
|
|
||||||
'Platform ' + os_version + ' is not supported',
|
|
||||||
os_version,
|
|
||||||
'error'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Function to get command to setup tools using composer
|
|
||||||
*
|
|
||||||
* @param os_version
|
|
||||||
*/
|
|
||||||
export async function getPackageCommand(os_version: string): Promise<string> {
|
|
||||||
switch (os_version) {
|
|
||||||
case 'linux':
|
|
||||||
case 'darwin':
|
|
||||||
return 'add_composer_tool ';
|
|
||||||
case 'win32':
|
|
||||||
return 'Add-Composer-Tool ';
|
|
||||||
default:
|
|
||||||
return await utils.log(
|
|
||||||
'Platform ' + os_version + ' is not supported',
|
|
||||||
os_version,
|
|
||||||
'error'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* Function to get command to setup PECL
|
|
||||||
*
|
|
||||||
* @param os_version
|
|
||||||
*/
|
|
||||||
export async function getPECLCommand(os_version: string): Promise<string> {
|
|
||||||
switch (os_version) {
|
|
||||||
case 'linux':
|
|
||||||
case 'darwin':
|
|
||||||
return 'add_pecl ';
|
|
||||||
case 'win32':
|
|
||||||
return 'Add-PECL ';
|
|
||||||
default:
|
default:
|
||||||
return await utils.log(
|
return await utils.log(
|
||||||
'Platform ' + os_version + ' is not supported',
|
'Platform ' + os_version + ' is not supported',
|
||||||
@ -116,6 +76,7 @@ export async function parseTool(
|
|||||||
*/
|
*/
|
||||||
export async function getUri(
|
export async function getUri(
|
||||||
tool: string,
|
tool: string,
|
||||||
|
extension: string,
|
||||||
version: string,
|
version: string,
|
||||||
prefix: string,
|
prefix: string,
|
||||||
version_prefix: string,
|
version_prefix: string,
|
||||||
@ -123,9 +84,11 @@ export async function getUri(
|
|||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
switch (version) {
|
switch (version) {
|
||||||
case 'latest':
|
case 'latest':
|
||||||
return [prefix, version, verb, tool + '.phar'].filter(Boolean).join('/');
|
return [prefix, version, verb, tool + extension]
|
||||||
|
.filter(Boolean)
|
||||||
|
.join('/');
|
||||||
default:
|
default:
|
||||||
return [prefix, verb, version_prefix + version, tool + '.phar']
|
return [prefix, verb, version_prefix + version, tool + extension]
|
||||||
.filter(Boolean)
|
.filter(Boolean)
|
||||||
.join('/');
|
.join('/');
|
||||||
}
|
}
|
||||||
@ -135,23 +98,15 @@ export async function getUri(
|
|||||||
* Helper function to get the codeception url
|
* Helper function to get the codeception url
|
||||||
*
|
*
|
||||||
* @param version
|
* @param version
|
||||||
* @param php_version
|
|
||||||
* @param suffix
|
* @param suffix
|
||||||
*/
|
*/
|
||||||
export async function getCodeceptionUriBuilder(
|
export async function getCodeceptionUriBuilder(
|
||||||
version: string,
|
version: string,
|
||||||
php_version: string,
|
|
||||||
suffix: string
|
suffix: string
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
switch (true) {
|
return ['releases', version, suffix, 'codecept.phar']
|
||||||
case /^5\.6$|^7\.[0|1]$/.test(php_version):
|
.filter(Boolean)
|
||||||
return ['releases', version, suffix, 'codecept.phar']
|
.join('/');
|
||||||
.filter(Boolean)
|
|
||||||
.join('/');
|
|
||||||
case /^7\.[2-4]$/.test(php_version):
|
|
||||||
default:
|
|
||||||
return ['releases', version, 'codecept.phar'].filter(Boolean).join('/');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -164,19 +119,55 @@ export async function getCodeceptionUri(
|
|||||||
version: string,
|
version: string,
|
||||||
php_version: string
|
php_version: string
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
|
const codecept: string = await getCodeceptionUriBuilder(version, '');
|
||||||
|
const codecept54: string = await getCodeceptionUriBuilder(version, 'php54');
|
||||||
|
const codecept56: string = await getCodeceptionUriBuilder(version, 'php56');
|
||||||
|
// Refer to https://codeception.com/builds
|
||||||
switch (true) {
|
switch (true) {
|
||||||
case /latest/.test(version):
|
case /latest/.test(version):
|
||||||
switch (true) {
|
switch (true) {
|
||||||
case /^5\.6$|^7\.[0|1]$/.test(php_version):
|
case /5\.6|7\.[0|1]/.test(php_version):
|
||||||
return 'php56/codecept.phar';
|
return 'php56/codecept.phar';
|
||||||
case /^7\.[2-4]$/.test(php_version):
|
case /7\.[2-4]/.test(php_version):
|
||||||
default:
|
default:
|
||||||
return 'codecept.phar';
|
return 'codecept.phar';
|
||||||
}
|
}
|
||||||
case /([4-9]|\d{2,})\..*/.test(version):
|
case /(^[4-9]|\d{2,})\..*/.test(version):
|
||||||
return await getCodeceptionUriBuilder(version, php_version, 'php56');
|
switch (true) {
|
||||||
|
case /5\.6|7\.[0|1]/.test(php_version):
|
||||||
|
return codecept56;
|
||||||
|
case /7\.[2-4]/.test(php_version):
|
||||||
|
default:
|
||||||
|
return codecept;
|
||||||
|
}
|
||||||
|
case /(^2\.[4-5]\.\d+|^3\.[0-1]\.\d+).*/.test(version):
|
||||||
|
switch (true) {
|
||||||
|
case /5\.6/.test(php_version):
|
||||||
|
return codecept54;
|
||||||
|
case /7\.[0-4]/.test(php_version):
|
||||||
|
default:
|
||||||
|
return codecept;
|
||||||
|
}
|
||||||
|
case /^2\.3\.\d+.*/.test(version):
|
||||||
|
switch (true) {
|
||||||
|
case /5\.[4-6]/.test(php_version):
|
||||||
|
return codecept54;
|
||||||
|
case /^7\.[0-4]$/.test(php_version):
|
||||||
|
default:
|
||||||
|
return codecept;
|
||||||
|
}
|
||||||
|
case /(^2\.(1\.([6-9]|\d{2,}))|^2\.2\.\d+).*/.test(version):
|
||||||
|
switch (true) {
|
||||||
|
case /5\.[4-5]/.test(php_version):
|
||||||
|
return codecept54;
|
||||||
|
case /5.6|7\.[0-4]/.test(php_version):
|
||||||
|
default:
|
||||||
|
return codecept;
|
||||||
|
}
|
||||||
|
case /(^2\.(1\.[0-5]|0\.\d+)|^1\.[6-8]\.\d+).*/.test(version):
|
||||||
|
return codecept;
|
||||||
default:
|
default:
|
||||||
return await getCodeceptionUriBuilder(version, php_version, 'php54');
|
return await codecept;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -195,12 +186,12 @@ export async function addPhive(
|
|||||||
switch (version) {
|
switch (version) {
|
||||||
case 'latest':
|
case 'latest':
|
||||||
return (
|
return (
|
||||||
(await getArchiveCommand(os_version)) +
|
(await getCommand(os_version, 'tool')) +
|
||||||
'https://phar.io/releases/phive.phar phive'
|
'https://phar.io/releases/phive.phar phive'
|
||||||
);
|
);
|
||||||
default:
|
default:
|
||||||
return (
|
return (
|
||||||
(await getArchiveCommand(os_version)) +
|
(await getCommand(os_version, 'tool')) +
|
||||||
'https://github.com/phar-io/phive/releases/download/' +
|
'https://github.com/phar-io/phive/releases/download/' +
|
||||||
version +
|
version +
|
||||||
'/phive-' +
|
'/phive-' +
|
||||||
@ -211,20 +202,21 @@ export async function addPhive(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function to get the PHPUnit url
|
* Function to get the phar url in domain/tool-version.phar format
|
||||||
*
|
*
|
||||||
* @param version
|
* @param version
|
||||||
*/
|
*/
|
||||||
export async function getPhpunitUrl(
|
export async function getPharUrl(
|
||||||
|
domain: string,
|
||||||
tool: string,
|
tool: string,
|
||||||
|
prefix: string,
|
||||||
version: string
|
version: string
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
const phpunit = 'https://phar.phpunit.de';
|
|
||||||
switch (version) {
|
switch (version) {
|
||||||
case 'latest':
|
case 'latest':
|
||||||
return phpunit + '/' + tool + '.phar';
|
return domain + '/' + tool + '.phar';
|
||||||
default:
|
default:
|
||||||
return phpunit + '/' + tool + '-' + version + '.phar';
|
return domain + '/' + tool + '-' + prefix + version + '.phar';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -330,7 +322,7 @@ export async function addArchive(
|
|||||||
url: string,
|
url: string,
|
||||||
os_version: string
|
os_version: string
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
return (await getArchiveCommand(os_version)) + url + ' ' + tool;
|
return (await getCommand(os_version, 'tool')) + url + ' ' + tool;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -382,7 +374,7 @@ export async function addPackage(
|
|||||||
prefix: string,
|
prefix: string,
|
||||||
os_version: string
|
os_version: string
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
const tool_command = await getPackageCommand(os_version);
|
const tool_command = await getCommand(os_version, 'composertool');
|
||||||
return tool_command + tool + ' ' + release + ' ' + prefix;
|
return tool_command + tool + ' ' + release + ' ' + prefix;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -404,12 +396,24 @@ export async function addTools(
|
|||||||
const tool: string = tool_data.name;
|
const tool: string = tool_data.name;
|
||||||
const version: string = tool_data.version;
|
const version: string = tool_data.version;
|
||||||
const github = 'https://github.com/';
|
const github = 'https://github.com/';
|
||||||
let uri: string = await getUri(tool, version, 'releases', '', 'download');
|
let uri: string = await getUri(
|
||||||
|
tool,
|
||||||
|
'.phar',
|
||||||
|
version,
|
||||||
|
'releases',
|
||||||
|
'',
|
||||||
|
'download'
|
||||||
|
);
|
||||||
script += '\n';
|
script += '\n';
|
||||||
let url = '';
|
let url = '';
|
||||||
switch (tool) {
|
switch (tool) {
|
||||||
|
case 'cs2pr':
|
||||||
|
uri = await getUri(tool, '', version, 'releases', '', 'download');
|
||||||
|
url = github + 'staabm/annotate-pull-request-from-checkstyle/' + uri;
|
||||||
|
script += await addArchive(tool, version, url, os_version);
|
||||||
|
break;
|
||||||
case 'php-cs-fixer':
|
case 'php-cs-fixer':
|
||||||
uri = await getUri(tool, version, 'releases', 'v', 'download');
|
uri = await getUri(tool, '.phar', version, 'releases', 'v', 'download');
|
||||||
url = github + 'FriendsOfPHP/PHP-CS-Fixer/' + uri;
|
url = github + 'FriendsOfPHP/PHP-CS-Fixer/' + uri;
|
||||||
script += await addArchive(tool, version, url, os_version);
|
script += await addArchive(tool, version, url, os_version);
|
||||||
break;
|
break;
|
||||||
@ -434,8 +438,10 @@ export async function addTools(
|
|||||||
script += await addArchive(tool, version, url, os_version);
|
script += await addArchive(tool, version, url, os_version);
|
||||||
break;
|
break;
|
||||||
case 'composer':
|
case 'composer':
|
||||||
url =
|
// If RC is released as latest release, switch to getcomposer.
|
||||||
github + 'composer/composer/releases/latest/download/composer.phar';
|
// Prefered source is GitHub as it is faster.
|
||||||
|
// url = github + 'composer/composer/releases/latest/download/composer.phar';
|
||||||
|
url = 'https://getcomposer.org/composer-stable.phar';
|
||||||
script += await addArchive(tool, version, url, os_version);
|
script += await addArchive(tool, version, url, os_version);
|
||||||
break;
|
break;
|
||||||
case 'codeception':
|
case 'codeception':
|
||||||
@ -446,7 +452,7 @@ export async function addTools(
|
|||||||
break;
|
break;
|
||||||
case 'phpcpd':
|
case 'phpcpd':
|
||||||
case 'phpunit':
|
case 'phpunit':
|
||||||
url = await getPhpunitUrl(tool, version);
|
url = await getPharUrl('https://phar.phpunit.de', tool, '', version);
|
||||||
script += await addArchive(tool, version, url, os_version);
|
script += await addArchive(tool, version, url, os_version);
|
||||||
break;
|
break;
|
||||||
case 'deployer':
|
case 'deployer':
|
||||||
@ -468,7 +474,7 @@ export async function addTools(
|
|||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case 'pecl':
|
case 'pecl':
|
||||||
script += await getPECLCommand(os_version);
|
script += await getCommand(os_version, 'pecl');
|
||||||
break;
|
break;
|
||||||
case 'php-config':
|
case 'php-config':
|
||||||
case 'phpize':
|
case 'phpize':
|
||||||
|
Reference in New Issue
Block a user