mirror of
https://github.com/shivammathur/setup-php.git
synced 2024-11-23 04:11:06 +07:00
commit
073c2e666b
2
.github/CONTRIBUTING.md
vendored
2
.github/CONTRIBUTING.md
vendored
@ -8,7 +8,7 @@ Please note that this project is released with a [Contributor Code of Conduct](C
|
|||||||
|
|
||||||
* Fork the project.
|
* Fork the project.
|
||||||
* Make your bug fix or feature addition.
|
* Make your bug fix or feature addition.
|
||||||
* Add tests for it. This is important so we don't break it in a future version unintentionally.
|
* Add tests for it, so we don't break it in a future version unintentionally.
|
||||||
* If editing the scripts, create a demo integration test.
|
* If editing the scripts, create a demo integration test.
|
||||||
* Send a pull request to the develop branch with all the details.
|
* Send a pull request to the develop branch with all the details.
|
||||||
|
|
||||||
|
2
.github/ISSUE_TEMPLATE/bug_report.md
vendored
2
.github/ISSUE_TEMPLATE/bug_report.md
vendored
@ -11,7 +11,7 @@ assignees: 'shivammathur'
|
|||||||
<!-- Please describe the bug concisely. -->
|
<!-- Please describe the bug concisely. -->
|
||||||
|
|
||||||
**Version**
|
**Version**
|
||||||
- [ ] I have checked releases and the bug exists in the latest patch version of `v1` or `v2`.
|
- [ ] I have checked releases, and the bug exists in the latest patch version of `v1` or `v2`.
|
||||||
- [ ] `v2`
|
- [ ] `v2`
|
||||||
- [ ] `v1`
|
- [ ] `v1`
|
||||||
|
|
||||||
|
2
.github/ISSUE_TEMPLATE/feature_request.md
vendored
2
.github/ISSUE_TEMPLATE/feature_request.md
vendored
@ -11,7 +11,7 @@ assignees: 'shivammathur'
|
|||||||
<!-- Please describe concisely the feature you want to add. -->
|
<!-- Please describe concisely the feature you want to add. -->
|
||||||
|
|
||||||
**Version**
|
**Version**
|
||||||
- [ ] I have checked releases and the feature is missing in the latest patch version of `v2`.
|
- [ ] I have checked releases, and the feature is missing in the latest patch version of `v2`.
|
||||||
|
|
||||||
**Underlying issue**
|
**Underlying issue**
|
||||||
<!-- Please describe the issue this would solve. -->
|
<!-- Please describe the issue this would solve. -->
|
||||||
|
6
.github/PULL_REQUEST_TEMPLATE.md
vendored
6
.github/PULL_REQUEST_TEMPLATE.md
vendored
@ -5,12 +5,12 @@ labels: bug or enhancement
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## A Pull Request should be associated with an Issue.
|
## A Pull Request should be associated with a Discussion.
|
||||||
|
|
||||||
> If you're fixing a bug, adding a new feature or improving something please provide the details in Issues,
|
> If you're fixing a bug, adding a new feature or improving something please provide the details in discussions,
|
||||||
> so that the development can be pointed in the intended direction.
|
> so that the development can be pointed in the intended direction.
|
||||||
|
|
||||||
Related issue: <!-- Please link the related issue -->
|
Related discussion: <!-- Please link the related discussion -->
|
||||||
|
|
||||||
> Further notes in [Contribution Guidelines](.github/CONTRIBUTING.md)
|
> Further notes in [Contribution Guidelines](.github/CONTRIBUTING.md)
|
||||||
> Thank you for your contribution.
|
> Thank you for your contribution.
|
||||||
|
2
.github/SECURITY.md
vendored
2
.github/SECURITY.md
vendored
@ -7,7 +7,7 @@ The following versions of this project are supported for security updates.
|
|||||||
| Version | Supported |
|
| Version | Supported |
|
||||||
| ------- | ------------------ |
|
| ------- | ------------------ |
|
||||||
| 1.9.x | :white_check_mark: |
|
| 1.9.x | :white_check_mark: |
|
||||||
| 2.5.x | :white_check_mark: |
|
| 2.6.x | :white_check_mark: |
|
||||||
|
|
||||||
## Supported PHP Versions
|
## Supported PHP Versions
|
||||||
|
|
||||||
|
58
README.md
58
README.md
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<a href="https://github.com/shivammathur/setup-php" title="GitHub action to setup PHP"><img alt="GitHub Actions status" src="https://github.com/shivammathur/setup-php/workflows/Main%20workflow/badge.svg"></a>
|
<a href="https://github.com/shivammathur/setup-php" title="GitHub action to setup PHP"><img alt="GitHub Actions status" src="https://github.com/shivammathur/setup-php/workflows/Main%20workflow/badge.svg"></a>
|
||||||
<a href="https://codecov.io/gh/shivammathur/setup-php" title="Code coverage"><img alt="Codecov Code Coverage" src="https://codecov.io/gh/shivammathur/setup-php/branch/master/graph/badge.svg"></a>
|
<a href="https://codecov.io/gh/shivammathur/setup-php" title="Code coverage"><img alt="Codecov Code Coverage" src="https://img.shields.io/codecov/c/github/shivammathur/setup-php?logo=codecov"></a>
|
||||||
<a href="https://github.com/shivammathur/setup-php/blob/master/LICENSE" title="license"><img alt="LICENSE" src="https://img.shields.io/badge/license-MIT-428f7e.svg?logo=open%20source%20initiative&logoColor=white&labelColor=555555"></a>
|
<a href="https://github.com/shivammathur/setup-php/blob/master/LICENSE" title="license"><img alt="LICENSE" src="https://img.shields.io/badge/license-MIT-428f7e.svg?logo=open%20source%20initiative&logoColor=white&labelColor=555555"></a>
|
||||||
<a href="#tada-php-support" title="PHP Versions Supported"><img alt="PHP Versions Supported" src="https://img.shields.io/badge/php-5.3%20to%208.0-777bb3.svg?logo=php&logoColor=white&labelColor=555555"></a>
|
<a href="#tada-php-support" title="PHP Versions Supported"><img alt="PHP Versions Supported" src="https://img.shields.io/badge/php-5.3%20to%208.0-777bb3.svg?logo=php&logoColor=white&labelColor=555555"></a>
|
||||||
</p>
|
</p>
|
||||||
@ -168,7 +168,7 @@ Both `GitHub-hosted` runners and `self-hosted` runners are supported on the foll
|
|||||||
|
|
||||||
These tools can be setup globally using the `tools` input.
|
These tools can be setup globally using the `tools` input.
|
||||||
|
|
||||||
`blackfire`, `blackfire-player`, `codeception`, `composer`, `composer-normalize`, `composer-prefetcher`, `composer-require-checker`, `composer-unused`, `cs2pr`, `deployer`, `flex`, `grpc_php_plugin`, `infection`, `pecl`, `phan`, `phing`, `phinx`, `phive`, `phpcbf`, `phpcpd`, `php-config`, `php-cs-fixer`, `phpcs`, `phpize`, `phpmd`, `phpstan`, `phpunit`, `prestissimo`, `protoc`, `psalm`, `symfony`, `vapor-cli`
|
`behat`, `blackfire`, `blackfire-player`, `codeception`, `composer`, `composer-normalize`, `composer-prefetcher`, `composer-require-checker`, `composer-unused`, `cs2pr`, `deployer`, `flex`, `grpc_php_plugin`, `infection`, `pecl`, `phan`, `phing`, `phinx`, `phive`, `phpcbf`, `phpcpd`, `php-config`, `php-cs-fixer`, `phpcs`, `phpize`, `phpmd`, `phpspec`, `phpstan`, `phpunit`, `prestissimo`, `protoc`, `psalm`, `symfony`, `vapor-cli`
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- name: Setup PHP with tools
|
- name: Setup PHP with tools
|
||||||
@ -204,6 +204,7 @@ For example to setup `PHPUnit` on `PHP 7.2`.
|
|||||||
```
|
```
|
||||||
|
|
||||||
**Notes**
|
**Notes**
|
||||||
|
- This is useful to set up tools which you only use in GitHub Actions, thus keeping your `composer.json` tidy.
|
||||||
- If you have a tool in your `composer.json`, do not setup it globally using this action as the two instances of the tool might conflict.
|
- If you have a tool in your `composer.json`, do not setup it globally using this action as the two instances of the tool might conflict.
|
||||||
- Tools which cannot be setup gracefully leave an error message in the logs, the action is not interrupted.
|
- Tools which cannot be setup gracefully leave an error message in the logs, the action is not interrupted.
|
||||||
|
|
||||||
@ -275,6 +276,7 @@ Consider disabling the coverage using this PHP action for these reasons.
|
|||||||
|
|
||||||
- Specify the PHP version you want to setup.
|
- Specify the PHP version you want to setup.
|
||||||
- Accepts a `string`. For example `'7.4'`.
|
- Accepts a `string`. For example `'7.4'`.
|
||||||
|
- Accepts `latest` to set up the latest stable PHP version.
|
||||||
- See [PHP support](#tada-php-support) for supported PHP versions.
|
- See [PHP support](#tada-php-support) for supported PHP versions.
|
||||||
|
|
||||||
#### `extensions` (optional)
|
#### `extensions` (optional)
|
||||||
@ -564,9 +566,11 @@ If you have a number of workflows which setup multiple tools or have many compos
|
|||||||
|
|
||||||
### Problem Matchers
|
### Problem Matchers
|
||||||
|
|
||||||
|
Problem matchers are `json` configurations which identify errors and warnings in your logs and surface that information prominently in the GitHub Actions UI by highlighting them and creating code annotations.
|
||||||
|
|
||||||
#### PHP
|
#### PHP
|
||||||
|
|
||||||
Setup problem matchers for your `PHP` output by adding this step after the `setup-php` step. This will scan the logs for PHP errors and warnings, and surface them prominently in the GitHub Actions UI by creating annotations and log file decorations.
|
Setup problem matchers for your `PHP` output by adding this step after the `setup-php` step.
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- name: Setup problem matchers for PHP
|
- name: Setup problem matchers for PHP
|
||||||
@ -575,29 +579,59 @@ Setup problem matchers for your `PHP` output by adding this step after the `setu
|
|||||||
|
|
||||||
#### PHPUnit
|
#### PHPUnit
|
||||||
|
|
||||||
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.
|
Setup problem matchers for your `PHPUnit` output by adding this step after the `setup-php` step.
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- name: Setup problem matchers for PHPUnit
|
- name: Setup problem matchers for PHPUnit
|
||||||
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
|
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Other Tools
|
#### PHPStan
|
||||||
|
|
||||||
For tools that support `checkstyle` reporting like `phpstan`, `psalm`, `php-cs-fixer` and `phpcs` you can use `cs2pr` to annotate your code.
|
PHPStan supports error reporting in GitHub Actions, so no problem matchers are required.
|
||||||
For examples refer to [cs2pr documentation](https://github.com/staabm/annotate-pull-request-from-checkstyle).
|
|
||||||
|
|
||||||
> Here is an example with `phpstan`.
|
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- name: Setup PHP
|
- name: Setup PHP
|
||||||
uses: shivammathur/setup-php@v2
|
uses: shivammathur/setup-php@v2
|
||||||
with:
|
with:
|
||||||
php-version: '7.4'
|
php-version: '7.4'
|
||||||
tools: cs2pr, phpstan
|
tools: phpstan
|
||||||
|
|
||||||
- name: PHPStan
|
- name: Run PHPStan
|
||||||
run: phpstan analyse src --error-format=checkstyle | cs2pr
|
run: phpstan analyse src
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Psalm
|
||||||
|
|
||||||
|
Psalm supports error reporting in GitHub Actions with an output format `github`.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
- name: Setup PHP
|
||||||
|
uses: shivammathur/setup-php@v2
|
||||||
|
with:
|
||||||
|
php-version: '7.4'
|
||||||
|
tools: psalm
|
||||||
|
|
||||||
|
- name: Run Psalm
|
||||||
|
run: psalm --output-format=github
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Tools with checkstyle support
|
||||||
|
|
||||||
|
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 `phpcs`.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
- name: Setup PHP
|
||||||
|
uses: shivammathur/setup-php@v2
|
||||||
|
with:
|
||||||
|
php-version: '7.4'
|
||||||
|
tools: cs2pr, phpcs
|
||||||
|
|
||||||
|
- name: Run phpcs
|
||||||
|
run: phpcs -q --report=checkstyle src | cs2pr
|
||||||
```
|
```
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
import * as install from '../src/install';
|
import * as install from '../src/install';
|
||||||
|
import * as utils from '../src/utils';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mock install.ts
|
* Mock install.ts
|
||||||
*/
|
*/
|
||||||
jest.mock('../src/install', () => ({
|
jest.mock('../src/install', () => ({
|
||||||
build: jest.fn().mockImplementation(
|
getScript: jest.fn().mockImplementation(
|
||||||
async (
|
async (
|
||||||
filename: string,
|
filename: string,
|
||||||
version: string,
|
version: string,
|
||||||
@ -39,24 +40,18 @@ jest.mock('../src/install', () => ({
|
|||||||
run: jest.fn().mockImplementation(
|
run: jest.fn().mockImplementation(
|
||||||
async (): Promise<string> => {
|
async (): Promise<string> => {
|
||||||
const os_version: string = process.env['RUNNER_OS'] || '';
|
const os_version: string = process.env['RUNNER_OS'] || '';
|
||||||
let version: string = process.env['php-version'] || '';
|
const version: string = await utils.parseVersion(
|
||||||
version = version.length > 1 ? version.slice(0, 3) : version + '.0';
|
await utils.getInput('php-version', true)
|
||||||
let script = '';
|
);
|
||||||
switch (os_version) {
|
const tool = await utils.scriptTool(os_version);
|
||||||
case 'darwin':
|
const filename = os_version + (await utils.scriptExtension(os_version));
|
||||||
case 'linux':
|
return [
|
||||||
script = await install.build(os_version + '.sh', version, os_version);
|
await install.getScript(filename, version, os_version),
|
||||||
script += 'bash script.sh ' + version + ' ' + __dirname;
|
tool,
|
||||||
break;
|
filename,
|
||||||
case 'win32':
|
version,
|
||||||
script = await install.build(os_version + '.sh', version, os_version);
|
__dirname
|
||||||
script += 'pwsh script.ps1 ' + version + ' ' + __dirname;
|
].join(' ');
|
||||||
break;
|
|
||||||
default:
|
|
||||||
script += os_version + ' is not supported';
|
|
||||||
}
|
|
||||||
|
|
||||||
return script;
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}));
|
}));
|
||||||
@ -93,13 +88,13 @@ describe('Install', () => {
|
|||||||
|
|
||||||
let script: string = '' + (await install.run());
|
let script: string = '' + (await install.run());
|
||||||
expect(script).toContain('initial script');
|
expect(script).toContain('initial script');
|
||||||
expect(script).toContain('pwsh script.ps1 7.0 ' + __dirname);
|
expect(script).toContain('pwsh win32.ps1 7.0 ' + __dirname);
|
||||||
|
|
||||||
setEnv('7.3', 'win32', '', '', '', '');
|
setEnv('7.3', 'win32', '', '', '', '');
|
||||||
|
|
||||||
script = '' + (await install.run());
|
script = '' + (await install.run());
|
||||||
expect(script).toContain('initial script');
|
expect(script).toContain('initial script');
|
||||||
expect(script).toContain('pwsh script.ps1 7.3 ' + __dirname);
|
expect(script).toContain('pwsh win32.ps1 7.3 ' + __dirname);
|
||||||
|
|
||||||
setEnv('7.3', 'win32', 'a, b', 'a=b', 'x', '');
|
setEnv('7.3', 'win32', 'a, b', 'a=b', 'x', '');
|
||||||
|
|
||||||
@ -108,7 +103,7 @@ describe('Install', () => {
|
|||||||
expect(script).toContain('install extensions');
|
expect(script).toContain('install extensions');
|
||||||
expect(script).toContain('edit php.ini');
|
expect(script).toContain('edit php.ini');
|
||||||
expect(script).toContain('set coverage driver');
|
expect(script).toContain('set coverage driver');
|
||||||
expect(script).toContain('pwsh script.ps1 7.3 ' + __dirname);
|
expect(script).toContain('pwsh win32.ps1 7.3 ' + __dirname);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Test install on linux', async () => {
|
it('Test install on linux', async () => {
|
||||||
@ -116,7 +111,13 @@ describe('Install', () => {
|
|||||||
|
|
||||||
let script: string = '' + (await install.run());
|
let script: string = '' + (await install.run());
|
||||||
expect(script).toContain('initial script');
|
expect(script).toContain('initial script');
|
||||||
expect(script).toContain('bash script.sh 7.3 ');
|
expect(script).toContain('bash linux.sh 7.3 ');
|
||||||
|
|
||||||
|
setEnv('latest', 'linux', '', '', '', '');
|
||||||
|
|
||||||
|
script = '' + (await install.run());
|
||||||
|
expect(script).toContain('initial script');
|
||||||
|
expect(script).toContain('bash linux.sh 7.4 ');
|
||||||
|
|
||||||
setEnv('7.3', 'linux', 'a, b', 'a=b', 'x', 'phpunit');
|
setEnv('7.3', 'linux', 'a, b', 'a=b', 'x', 'phpunit');
|
||||||
|
|
||||||
@ -125,7 +126,7 @@ describe('Install', () => {
|
|||||||
expect(script).toContain('install extensions');
|
expect(script).toContain('install extensions');
|
||||||
expect(script).toContain('edit php.ini');
|
expect(script).toContain('edit php.ini');
|
||||||
expect(script).toContain('set coverage driver');
|
expect(script).toContain('set coverage driver');
|
||||||
expect(script).toContain('bash script.sh 7.3');
|
expect(script).toContain('bash linux.sh 7.3');
|
||||||
expect(script).toContain('add_tool');
|
expect(script).toContain('add_tool');
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -134,7 +135,7 @@ describe('Install', () => {
|
|||||||
|
|
||||||
let script: string = '' + (await install.run());
|
let script: string = '' + (await install.run());
|
||||||
expect(script).toContain('initial script');
|
expect(script).toContain('initial script');
|
||||||
expect(script).toContain('bash script.sh 7.3 ' + __dirname);
|
expect(script).toContain('bash darwin.sh 7.3 ' + __dirname);
|
||||||
|
|
||||||
setEnv('7.3', 'darwin', 'a, b', 'a=b', 'x', '');
|
setEnv('7.3', 'darwin', 'a, b', 'a=b', 'x', '');
|
||||||
|
|
||||||
@ -143,7 +144,7 @@ describe('Install', () => {
|
|||||||
expect(script).toContain('install extensions');
|
expect(script).toContain('install extensions');
|
||||||
expect(script).toContain('edit php.ini');
|
expect(script).toContain('edit php.ini');
|
||||||
expect(script).toContain('set coverage driver');
|
expect(script).toContain('set coverage driver');
|
||||||
expect(script).toContain('bash script.sh 7.3 ' + __dirname);
|
expect(script).toContain('bash darwin.sh 7.3 ' + __dirname);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Test malformed version inputs', async () => {
|
it('Test malformed version inputs', async () => {
|
||||||
@ -151,18 +152,18 @@ describe('Install', () => {
|
|||||||
|
|
||||||
let script: string = '' + '' + (await install.run());
|
let script: string = '' + '' + (await install.run());
|
||||||
expect(script).toContain('initial script');
|
expect(script).toContain('initial script');
|
||||||
expect(script).toContain('bash script.sh 7.4 ' + __dirname);
|
expect(script).toContain('bash darwin.sh 7.4 ' + __dirname);
|
||||||
|
|
||||||
setEnv(8.0, 'darwin', '', '', '', '');
|
setEnv(8.0, 'darwin', '', '', '', '');
|
||||||
|
|
||||||
script = '' + (await install.run());
|
script = '' + (await install.run());
|
||||||
expect(script).toContain('initial script');
|
expect(script).toContain('initial script');
|
||||||
expect(script).toContain('bash script.sh 8.0 ' + __dirname);
|
expect(script).toContain('bash darwin.sh 8.0 ' + __dirname);
|
||||||
|
|
||||||
setEnv(8, 'darwin', '', '', '', '');
|
setEnv(8, 'darwin', '', '', '', '');
|
||||||
|
|
||||||
script = '' + (await install.run());
|
script = '' + (await install.run());
|
||||||
expect(script).toContain('initial script');
|
expect(script).toContain('initial script');
|
||||||
expect(script).toContain('bash script.sh 8.0 ' + __dirname);
|
expect(script).toContain('bash darwin.sh 8.0 ' + __dirname);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -1,41 +0,0 @@
|
|||||||
import * as io from '@actions/io';
|
|
||||||
import * as matchers from '../src/matchers';
|
|
||||||
|
|
||||||
jest.mock('@actions/io');
|
|
||||||
|
|
||||||
describe('Matchers', () => {
|
|
||||||
it('Add matchers', async () => {
|
|
||||||
process.env['RUNNER_TOOL_CACHE'] = __dirname;
|
|
||||||
await matchers.addMatchers();
|
|
||||||
const spy = jest.spyOn(io, 'cp');
|
|
||||||
expect(spy).toHaveBeenCalledTimes(2);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('Test PHPUnit Regex', async () => {
|
|
||||||
const regex1 = /^\d+\)\s.*$/;
|
|
||||||
const regex2 = /^(.*Failed\sasserting\sthat.*)$/;
|
|
||||||
const regex3 = /^\s*$/;
|
|
||||||
const regex4 = /^(.*):(\d+)$/;
|
|
||||||
expect(regex1.test('1) Tests\\Test::it_tests')).toBe(true);
|
|
||||||
expect(regex2.test('Failed asserting that false is true')).toBe(true);
|
|
||||||
expect(regex3.test('\n')).toBe(true);
|
|
||||||
expect(regex4.test('/path/to/file.php:42')).toBe(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('Test PHP Regex', async () => {
|
|
||||||
const regex1 = /^(.*error):\s+\s+(.+) in (.+) on line (\d+)$/;
|
|
||||||
const regex2 = /^(.*Warning|.*Deprecated|.*Notice):\s+\s+(.+) in (.+) on line (\d+)$/;
|
|
||||||
expect(
|
|
||||||
regex1.test('PHP Parse error: error_message in file.php on line 10')
|
|
||||||
).toBe(true);
|
|
||||||
expect(
|
|
||||||
regex2.test('PHP Notice: info_message in file.php on line 10')
|
|
||||||
).toBe(true);
|
|
||||||
expect(
|
|
||||||
regex2.test('PHP Warning: warning_message in file.php on line 10')
|
|
||||||
).toBe(true);
|
|
||||||
expect(
|
|
||||||
regex2.test('PHP Deprecated: deprecated_message in file.php on line 10')
|
|
||||||
).toBe(true);
|
|
||||||
});
|
|
||||||
});
|
|
@ -277,14 +277,19 @@ describe('Tools tests', () => {
|
|||||||
|
|
||||||
it('checking getCleanedToolsList', async () => {
|
it('checking getCleanedToolsList', async () => {
|
||||||
const tools_list: string[] = await tools.getCleanedToolsList(
|
const tools_list: string[] = await tools.getCleanedToolsList(
|
||||||
'tool, composer:1.2.3, robmorgan/phinx, hirak/prestissimo, narrowspark/automatic-composer-prefetcher'
|
'tool, composer:1.2.3, behat/behat, icanhazstring/composer-unused, laravel/vapor-cli, robmorgan/phinx, hirak/prestissimo, narrowspark/automatic-composer-prefetcher, phpspec/phpspec, symfony/flex'
|
||||||
);
|
);
|
||||||
expect(tools_list).toStrictEqual([
|
expect(tools_list).toStrictEqual([
|
||||||
'composer',
|
'composer',
|
||||||
'tool',
|
'tool',
|
||||||
|
'behat',
|
||||||
|
'composer-unused',
|
||||||
|
'vapor-cli',
|
||||||
'phinx',
|
'phinx',
|
||||||
'prestissimo',
|
'prestissimo',
|
||||||
'composer-prefetcher'
|
'composer-prefetcher',
|
||||||
|
'phpspec',
|
||||||
|
'flex'
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -301,44 +306,46 @@ describe('Tools tests', () => {
|
|||||||
let script: string = await tools.addArchive(
|
let script: string = await tools.addArchive(
|
||||||
'tool',
|
'tool',
|
||||||
'https://tool.com/tool.phar',
|
'https://tool.com/tool.phar',
|
||||||
'linux'
|
'linux',
|
||||||
|
'-v'
|
||||||
);
|
);
|
||||||
expect(script).toContain('add_tool https://tool.com/tool.phar tool');
|
expect(script).toContain('add_tool https://tool.com/tool.phar tool');
|
||||||
script = await tools.addArchive(
|
script = await tools.addArchive(
|
||||||
'tool',
|
'tool',
|
||||||
'https://tool.com/tool.phar',
|
'https://tool.com/tool.phar',
|
||||||
'darwin'
|
'darwin',
|
||||||
|
'-v'
|
||||||
);
|
);
|
||||||
expect(script).toContain('add_tool https://tool.com/tool.phar tool');
|
expect(script).toContain('add_tool https://tool.com/tool.phar tool');
|
||||||
script = await tools.addArchive(
|
script = await tools.addArchive(
|
||||||
'tool',
|
'tool',
|
||||||
'https://tool.com/tool.phar',
|
'https://tool.com/tool.phar',
|
||||||
'win32'
|
'win32',
|
||||||
|
'-v'
|
||||||
);
|
);
|
||||||
expect(script).toContain('Add-Tool https://tool.com/tool.phar tool');
|
expect(script).toContain('Add-Tool https://tool.com/tool.phar tool');
|
||||||
|
|
||||||
script = await tools.addArchive(
|
script = await tools.addArchive(
|
||||||
'tool',
|
'tool',
|
||||||
'https://tool.com/tool.phar',
|
'https://tool.com/tool.phar',
|
||||||
'openbsd'
|
'openbsd',
|
||||||
|
'-v'
|
||||||
);
|
);
|
||||||
expect(script).toContain('Platform openbsd is not supported');
|
expect(script).toContain('Platform openbsd is not supported');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('checking addDevTools', async () => {
|
it('checking addDevTools', async () => {
|
||||||
let script: string = await tools.addDevTools('phpize', 'linux');
|
let script: string = await tools.addDevTools('phpize', 'linux');
|
||||||
expect(script).toContain('add_devtools');
|
expect(script).toContain('add_devtools phpize');
|
||||||
expect(script).toContain('add_log "$tick" "phpize" "Added"');
|
|
||||||
|
|
||||||
script = await tools.addDevTools('php-config', 'linux');
|
script = await tools.addDevTools('php-config', 'linux');
|
||||||
expect(script).toContain('add_devtools');
|
expect(script).toContain('add_devtools php-config');
|
||||||
expect(script).toContain('add_log "$tick" "php-config" "Added"');
|
|
||||||
|
|
||||||
script = await tools.addDevTools('phpize', 'darwin');
|
script = await tools.addDevTools('phpize', 'darwin');
|
||||||
expect(script).toContain('add_log "$tick" "phpize" "Added"');
|
expect(script).toContain('add_devtools phpize');
|
||||||
|
|
||||||
script = await tools.addDevTools('php-config', 'darwin');
|
script = await tools.addDevTools('php-config', 'darwin');
|
||||||
expect(script).toContain('add_log "$tick" "php-config" "Added"');
|
expect(script).toContain('add_devtools php-config');
|
||||||
|
|
||||||
script = await tools.addDevTools('phpize', 'win32');
|
script = await tools.addDevTools('phpize', 'win32');
|
||||||
expect(script).toContain(
|
expect(script).toContain(
|
||||||
@ -381,34 +388,34 @@ describe('Tools tests', () => {
|
|||||||
);
|
);
|
||||||
expect(script).toContain('add_blackfire');
|
expect(script).toContain('add_blackfire');
|
||||||
expect(script).toContain(
|
expect(script).toContain(
|
||||||
'add_tool https://get.blackfire.io/blackfire-player.phar blackfire-player'
|
'add_tool https://get.blackfire.io/blackfire-player.phar blackfire-player "-V"'
|
||||||
);
|
);
|
||||||
expect(script).toContain(
|
expect(script).toContain(
|
||||||
'add_tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-stable.phar,https://getcomposer.org/composer-stable.phar composer'
|
'add_tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-stable.phar,https://getcomposer.org/composer-stable.phar composer'
|
||||||
);
|
);
|
||||||
expect(script).toContain(
|
expect(script).toContain(
|
||||||
'add_tool https://github.com/staabm/annotate-pull-request-from-checkstyle/releases/latest/download/cs2pr cs2pr'
|
'add_tool https://github.com/staabm/annotate-pull-request-from-checkstyle/releases/latest/download/cs2pr cs2pr "-V"'
|
||||||
);
|
);
|
||||||
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 "-V"'
|
||||||
);
|
);
|
||||||
expect(script).toContain(
|
expect(script).toContain(
|
||||||
'add_tool https://github.com/phpstan/phpstan/releases/latest/download/phpstan.phar phpstan'
|
'add_tool https://github.com/phpstan/phpstan/releases/latest/download/phpstan.phar phpstan "-V"'
|
||||||
);
|
);
|
||||||
expect(script).toContain(
|
expect(script).toContain(
|
||||||
'add_tool https://www.phing.info/get/phing-latest.phar phing'
|
'add_tool https://www.phing.info/get/phing-latest.phar phing "-v"'
|
||||||
);
|
);
|
||||||
expect(script).toContain(
|
expect(script).toContain(
|
||||||
'add_tool https://phar.io/releases/phive.phar phive'
|
'add_tool https://phar.io/releases/phive.phar phive status'
|
||||||
);
|
);
|
||||||
expect(script).toContain(
|
expect(script).toContain(
|
||||||
'add_tool https://phar.phpunit.de/phpunit.phar phpunit'
|
'add_tool https://phar.phpunit.de/phpunit.phar phpunit "--version"'
|
||||||
);
|
);
|
||||||
expect(script).toContain(
|
expect(script).toContain(
|
||||||
'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 version'
|
||||||
);
|
);
|
||||||
expect(script).toContain(
|
expect(script).toContain(
|
||||||
'add_tool https://github.com/wp-cli/builds/blob/gh-pages/phar/wp-cli.phar?raw=true wp-cli'
|
'add_tool https://github.com/wp-cli/builds/blob/gh-pages/phar/wp-cli.phar?raw=true wp-cli "--version"'
|
||||||
);
|
);
|
||||||
expect(script).toContain('add_protoc latest');
|
expect(script).toContain('add_protoc latest');
|
||||||
expect(script).toContain('add_grpc_php_plugin latest');
|
expect(script).toContain('add_grpc_php_plugin latest');
|
||||||
@ -417,12 +424,12 @@ describe('Tools tests', () => {
|
|||||||
expect(script).toContain('add_composertool phinx phinx robmorgan/');
|
expect(script).toContain('add_composertool phinx phinx robmorgan/');
|
||||||
expect(script).toContain('add_composertool phplint phplint overtrue/');
|
expect(script).toContain('add_composertool phplint phplint overtrue/');
|
||||||
expect(script).toContain('add_composertool 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 php-config');
|
||||||
expect(script).toContain('add_log "$tick" "php-config" "Added"');
|
expect(script).toContain('add_devtools phpize');
|
||||||
expect(script).toContain('add_log "$tick" "phpize" "Added"');
|
|
||||||
});
|
});
|
||||||
it('checking addTools on darwin', async () => {
|
it('checking addTools on darwin', async () => {
|
||||||
const listOfTools = [
|
const listOfTools = [
|
||||||
|
'behat',
|
||||||
'blackfire',
|
'blackfire',
|
||||||
'blackfire-player',
|
'blackfire-player',
|
||||||
'composer-normalize',
|
'composer-normalize',
|
||||||
@ -444,6 +451,7 @@ describe('Tools tests', () => {
|
|||||||
'phpcs',
|
'phpcs',
|
||||||
'phpize',
|
'phpize',
|
||||||
'phpmd',
|
'phpmd',
|
||||||
|
'phpspec',
|
||||||
'protoc:v1.2.3',
|
'protoc:v1.2.3',
|
||||||
'psalm',
|
'psalm',
|
||||||
'symfony',
|
'symfony',
|
||||||
@ -460,72 +468,74 @@ describe('Tools tests', () => {
|
|||||||
|
|
||||||
expect(script).toContain('add_blackfire');
|
expect(script).toContain('add_blackfire');
|
||||||
expect(script).toContain(
|
expect(script).toContain(
|
||||||
'add_tool https://get.blackfire.io/blackfire-player.phar blackfire-player'
|
'add_tool https://get.blackfire.io/blackfire-player.phar blackfire-player "-V"'
|
||||||
);
|
);
|
||||||
expect(script).toContain(
|
expect(script).toContain(
|
||||||
'add_tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-stable.phar,https://getcomposer.org/composer-stable.phar composer'
|
'add_tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-stable.phar,https://getcomposer.org/composer-stable.phar composer'
|
||||||
);
|
);
|
||||||
expect(script).toContain(
|
expect(script).toContain(
|
||||||
'add_tool https://github.com/ergebnis/composer-normalize/releases/latest/download/composer-normalize.phar composer-normalize'
|
'add_tool https://github.com/ergebnis/composer-normalize/releases/latest/download/composer-normalize.phar composer-normalize "-V"'
|
||||||
);
|
);
|
||||||
expect(script).toContain(
|
expect(script).toContain(
|
||||||
'add_tool https://github.com/maglnet/ComposerRequireChecker/releases/latest/download/composer-require-checker.phar composer-require-checker'
|
'add_tool https://github.com/maglnet/ComposerRequireChecker/releases/latest/download/composer-require-checker.phar composer-require-checker "-V"'
|
||||||
);
|
);
|
||||||
expect(script).toContain(
|
expect(script).toContain(
|
||||||
'add_tool https://github.com/composer-unused/composer-unused/releases/latest/download/composer-unused.phar composer-unused'
|
'add_tool https://github.com/staabm/annotate-pull-request-from-checkstyle/releases/download/1.2.3/cs2pr cs2pr "-V"'
|
||||||
);
|
);
|
||||||
expect(script).toContain(
|
expect(script).toContain(
|
||||||
'add_tool https://github.com/staabm/annotate-pull-request-from-checkstyle/releases/download/1.2.3/cs2pr cs2pr'
|
'add_tool https://github.com/infection/infection/releases/latest/download/infection.phar infection "-V"'
|
||||||
);
|
);
|
||||||
expect(script).toContain(
|
expect(script).toContain(
|
||||||
'add_tool https://github.com/infection/infection/releases/latest/download/infection.phar infection'
|
'add_tool https://github.com/phan/phan/releases/latest/download/phan.phar phan "-v"'
|
||||||
);
|
);
|
||||||
expect(script).toContain(
|
expect(script).toContain(
|
||||||
'add_tool https://github.com/phan/phan/releases/latest/download/phan.phar phan'
|
'add_tool https://www.phing.info/get/phing-1.2.3.phar phing "-v"'
|
||||||
);
|
);
|
||||||
expect(script).toContain(
|
expect(script).toContain(
|
||||||
'add_tool https://www.phing.info/get/phing-1.2.3.phar phing'
|
'add_tool https://github.com/squizlabs/PHP_CodeSniffer/releases/latest/download/phpcs.phar phpcs "--version"'
|
||||||
);
|
);
|
||||||
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/phpcbf.phar phpcbf "--version"'
|
||||||
);
|
);
|
||||||
expect(script).toContain(
|
expect(script).toContain(
|
||||||
'add_tool https://github.com/squizlabs/PHP_CodeSniffer/releases/latest/download/phpcbf.phar phpcbf'
|
'add_tool https://phar.phpunit.de/phpcpd.phar phpcpd "--version"'
|
||||||
);
|
);
|
||||||
expect(script).toContain(
|
expect(script).toContain(
|
||||||
'add_tool https://phar.phpunit.de/phpcpd.phar phpcpd'
|
'add_tool https://github.com/phpmd/phpmd/releases/latest/download/phpmd.phar phpmd "--version"'
|
||||||
);
|
);
|
||||||
expect(script).toContain(
|
expect(script).toContain(
|
||||||
'add_tool https://github.com/phpmd/phpmd/releases/latest/download/phpmd.phar phpmd'
|
'https://github.com/vimeo/psalm/releases/latest/download/psalm.phar psalm "-v"'
|
||||||
);
|
|
||||||
expect(script).toContain(
|
|
||||||
'https://github.com/vimeo/psalm/releases/latest/download/psalm.phar psalm'
|
|
||||||
);
|
);
|
||||||
expect(script).toContain('add_grpc_php_plugin 1.2.3');
|
expect(script).toContain('add_grpc_php_plugin 1.2.3');
|
||||||
expect(script).toContain('add_protoc 1.2.3');
|
expect(script).toContain('add_protoc 1.2.3');
|
||||||
|
expect(script).toContain('add_composertool behat behat behat/');
|
||||||
|
expect(script).toContain('add_composertool phpspec phpspec phpspec/');
|
||||||
expect(script).toContain('add_composertool vapor-cli vapor-cli laravel/');
|
expect(script).toContain('add_composertool vapor-cli vapor-cli laravel/');
|
||||||
expect(script).toContain('add_composertool flex flex symfony/');
|
expect(script).toContain('add_composertool flex flex symfony/');
|
||||||
expect(script).toContain('add_composertool phinx phinx robmorgan/');
|
expect(script).toContain('add_composertool phinx phinx robmorgan/');
|
||||||
expect(script).toContain(
|
expect(script).toContain(
|
||||||
'add_tool https://github.com/phan/phan/releases/download/2.7.2/phan.phar phan'
|
'add_tool https://github.com/phan/phan/releases/download/2.7.2/phan.phar phan "-v"'
|
||||||
);
|
);
|
||||||
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(
|
||||||
|
'add_composertool composer-unused composer-unused icanhazstring/'
|
||||||
|
);
|
||||||
expect(script).toContain(
|
expect(script).toContain(
|
||||||
'add_composertool 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 version'
|
||||||
);
|
);
|
||||||
expect(script).toContain(
|
expect(script).toContain(
|
||||||
'add_tool https://github.com/symfony/cli/releases/download/v1.2.3/symfony_darwin_amd64 symfony'
|
'add_tool https://github.com/symfony/cli/releases/download/v1.2.3/symfony_darwin_amd64 symfony version'
|
||||||
);
|
);
|
||||||
expect(script).toContain(
|
expect(script).toContain(
|
||||||
'add_tool https://github.com/wp-cli/builds/blob/gh-pages/phar/wp-cli.phar?raw=true wp-cli'
|
'add_tool https://github.com/wp-cli/builds/blob/gh-pages/phar/wp-cli.phar?raw=true wp-cli "--version"'
|
||||||
);
|
);
|
||||||
expect(script).toContain('add_log "$tick" "phpize" "Added"');
|
expect(script).toContain('add_devtools phpize');
|
||||||
expect(script).toContain('add_log "$tick" "php-config" "Added"');
|
expect(script).toContain('add_devtools php-config');
|
||||||
});
|
});
|
||||||
it('checking addTools on windows', async () => {
|
it('checking addTools on windows', async () => {
|
||||||
const listOfTools = [
|
const listOfTools = [
|
||||||
@ -554,31 +564,31 @@ describe('Tools tests', () => {
|
|||||||
|
|
||||||
expect(script).toContain('Add-Blackfire');
|
expect(script).toContain('Add-Blackfire');
|
||||||
expect(script).toContain(
|
expect(script).toContain(
|
||||||
'Add-Tool https://get.blackfire.io/blackfire-player-v1.8.1.phar blackfire-player'
|
'Add-Tool https://get.blackfire.io/blackfire-player-v1.8.1.phar blackfire-player "-V"'
|
||||||
);
|
);
|
||||||
expect(script).toContain(
|
expect(script).toContain(
|
||||||
'Add-Tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-stable.phar,https://getcomposer.org/composer-stable.phar composer'
|
'Add-Tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-stable.phar,https://getcomposer.org/composer-stable.phar composer'
|
||||||
);
|
);
|
||||||
expect(script).toContain(
|
expect(script).toContain(
|
||||||
'Add-Tool https://github.com/staabm/annotate-pull-request-from-checkstyle/releases/latest/download/cs2pr cs2pr'
|
'Add-Tool https://github.com/staabm/annotate-pull-request-from-checkstyle/releases/latest/download/cs2pr cs2pr "-V"'
|
||||||
);
|
);
|
||||||
expect(script).toContain('Add-Composertool flex flex symfony/');
|
expect(script).toContain('Add-Composertool flex flex symfony/');
|
||||||
expect(script).toContain(
|
expect(script).toContain(
|
||||||
'Add-Tool https://deployer.org/deployer.phar deployer'
|
'Add-Tool https://deployer.org/deployer.phar deployer "-V"'
|
||||||
);
|
);
|
||||||
expect(script).toContain('Add-Composertool prestissimo prestissimo hirak/');
|
expect(script).toContain('Add-Composertool 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 "--version"'
|
||||||
);
|
);
|
||||||
expect(script).toContain('Add-Composertool 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 status'
|
||||||
);
|
);
|
||||||
expect(script).toContain(
|
expect(script).toContain(
|
||||||
'Add-Tool https://github.com/symfony/cli/releases/latest/download/symfony_windows_amd64.exe symfony'
|
'Add-Tool https://github.com/symfony/cli/releases/latest/download/symfony_windows_amd64.exe symfony version'
|
||||||
);
|
);
|
||||||
expect(script).toContain(
|
expect(script).toContain(
|
||||||
'Add-Tool https://github.com/wp-cli/builds/blob/gh-pages/phar/wp-cli.phar?raw=true wp-cli'
|
'Add-Tool https://github.com/wp-cli/builds/blob/gh-pages/phar/wp-cli.phar?raw=true wp-cli "--version"'
|
||||||
);
|
);
|
||||||
expect(script).toContain('phpize is not a windows tool');
|
expect(script).toContain('phpize is not a windows tool');
|
||||||
expect(script).toContain('php-config is not a windows tool');
|
expect(script).toContain('php-config is not a windows tool');
|
||||||
@ -621,7 +631,7 @@ describe('Tools tests', () => {
|
|||||||
|
|
||||||
script = await tools.addTools('composer:preview', '7.4', 'linux');
|
script = await tools.addTools('composer:preview', '7.4', 'linux');
|
||||||
expect(script).toContain(
|
expect(script).toContain(
|
||||||
'add_tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-preview.phar,https://getcomposer.org/composer-preview.phar composer'
|
'add_tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-preview.phar,https://getcomposer.org/composer-preview.phar composer preview'
|
||||||
);
|
);
|
||||||
script = await tools.addTools(
|
script = await tools.addTools(
|
||||||
'composer:v1, composer:preview, composer:snapshot',
|
'composer:v1, composer:preview, composer:snapshot',
|
||||||
@ -629,7 +639,7 @@ describe('Tools tests', () => {
|
|||||||
'linux'
|
'linux'
|
||||||
);
|
);
|
||||||
expect(script).toContain(
|
expect(script).toContain(
|
||||||
'add_tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-snapshot.phar,https://getcomposer.org/composer.phar composer'
|
'add_tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-snapshot.phar,https://getcomposer.org/composer.phar composer snapshot'
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -17,13 +17,26 @@ async function cleanup(path: string): Promise<void> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
describe('Utils tests', () => {
|
describe('Utils tests', () => {
|
||||||
|
it('checking readEnv', async () => {
|
||||||
|
process.env['test'] = 'setup-php';
|
||||||
|
expect(await utils.readEnv('test')).toBe('setup-php');
|
||||||
|
expect(await utils.readEnv('undefined')).toBe('');
|
||||||
|
});
|
||||||
|
|
||||||
it('checking getInput', async () => {
|
it('checking getInput', async () => {
|
||||||
process.env['test'] = 'setup-php';
|
process.env['test'] = 'setup-php';
|
||||||
process.env['undefined'] = '';
|
|
||||||
expect(await utils.getInput('test', false)).toBe('setup-php');
|
expect(await utils.getInput('test', false)).toBe('setup-php');
|
||||||
expect(await utils.getInput('undefined', false)).toBe('');
|
|
||||||
expect(await utils.getInput('setup-php', false)).toBe('setup-php');
|
expect(await utils.getInput('setup-php', false)).toBe('setup-php');
|
||||||
expect(await utils.getInput('DoesNotExist', false)).toBe('');
|
expect(await utils.getInput('DoesNotExist', false)).toBe('');
|
||||||
|
expect(async () => {
|
||||||
|
await utils.getInput('DoesNotExist', true);
|
||||||
|
}).rejects.toThrow('Input required and not supplied: DoesNotExist');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('checking parseVersion', async () => {
|
||||||
|
expect(await utils.parseVersion('7')).toBe('7.0');
|
||||||
|
expect(await utils.parseVersion('7.4')).toBe('7.4');
|
||||||
|
expect(await utils.parseVersion('latest')).toBe('7.4');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('checking asyncForEach', async () => {
|
it('checking asyncForEach', async () => {
|
||||||
@ -196,6 +209,15 @@ describe('Utils tests', () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('checking scriptTool', async () => {
|
||||||
|
expect(await utils.scriptTool('linux')).toBe('bash');
|
||||||
|
expect(await utils.scriptTool('darwin')).toBe('bash');
|
||||||
|
expect(await utils.scriptTool('win32')).toBe('pwsh');
|
||||||
|
expect(await utils.scriptTool('openbsd')).toContain(
|
||||||
|
'Platform openbsd is not supported'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
it('checking customPackage', async () => {
|
it('checking customPackage', async () => {
|
||||||
const script_path: string = path.join('ext', 'pkg.sh');
|
const script_path: string = path.join('ext', 'pkg.sh');
|
||||||
expect(await utils.customPackage('pkg', 'ext', '1.2.3', 'linux')).toContain(
|
expect(await utils.customPackage('pkg', 'ext', '1.2.3', 'linux')).toContain(
|
||||||
|
290
dist/index.js
vendored
290
dist/index.js
vendored
@ -953,46 +953,29 @@ class ExecState extends events.EventEmitter {
|
|||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
||||||
/***/ 86:
|
/***/ 82:
|
||||||
/***/ (function(__unusedmodule, exports, __webpack_require__) {
|
/***/ (function(__unusedmodule, exports) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
// We use any as a valid input type
|
||||||
if (k2 === undefined) k2 = k;
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
||||||
}) : (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
o[k2] = m[k];
|
|
||||||
}));
|
|
||||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
||||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
||||||
}) : function(o, v) {
|
|
||||||
o["default"] = v;
|
|
||||||
});
|
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
|
||||||
if (mod && mod.__esModule) return mod;
|
|
||||||
var result = {};
|
|
||||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
||||||
__setModuleDefault(result, mod);
|
|
||||||
return result;
|
|
||||||
};
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.addMatchers = void 0;
|
|
||||||
const path = __importStar(__webpack_require__(622));
|
|
||||||
const utils = __importStar(__webpack_require__(163));
|
|
||||||
const io = __importStar(__webpack_require__(1));
|
|
||||||
/**
|
/**
|
||||||
* Cache json files for problem matchers
|
* Sanitizes an input into a string so it can be passed into issueCommand safely
|
||||||
|
* @param input input to sanitize into a string
|
||||||
*/
|
*/
|
||||||
async function addMatchers() {
|
function toCommandValue(input) {
|
||||||
const config_path = path.join(__dirname, '..', 'src', 'configs');
|
if (input === null || input === undefined) {
|
||||||
const runner_dir = await utils.getInput('RUNNER_TOOL_CACHE', false);
|
return '';
|
||||||
await io.cp(path.join(config_path, 'phpunit.json'), runner_dir);
|
|
||||||
await io.cp(path.join(config_path, 'php.json'), runner_dir);
|
|
||||||
}
|
}
|
||||||
exports.addMatchers = addMatchers;
|
else if (typeof input === 'string' || input instanceof String) {
|
||||||
|
return input;
|
||||||
|
}
|
||||||
|
return JSON.stringify(input);
|
||||||
|
}
|
||||||
|
exports.toCommandValue = toCommandValue;
|
||||||
|
//# sourceMappingURL=utils.js.map
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
||||||
@ -1003,6 +986,42 @@ module.exports = require("os");
|
|||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
||||||
|
/***/ 102:
|
||||||
|
/***/ (function(__unusedmodule, exports, __webpack_require__) {
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
// For internal use, subject to change.
|
||||||
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
|
if (mod && mod.__esModule) return mod;
|
||||||
|
var result = {};
|
||||||
|
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
||||||
|
result["default"] = mod;
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
// We use any as a valid input type
|
||||||
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||||
|
const fs = __importStar(__webpack_require__(747));
|
||||||
|
const os = __importStar(__webpack_require__(87));
|
||||||
|
const utils_1 = __webpack_require__(82);
|
||||||
|
function issueCommand(command, message) {
|
||||||
|
const filePath = process.env[`GITHUB_${command}`];
|
||||||
|
if (!filePath) {
|
||||||
|
throw new Error(`Unable to find environment variable for file command ${command}`);
|
||||||
|
}
|
||||||
|
if (!fs.existsSync(filePath)) {
|
||||||
|
throw new Error(`Missing file at path: ${filePath}`);
|
||||||
|
}
|
||||||
|
fs.appendFileSync(filePath, `${utils_1.toCommandValue(message)}${os.EOL}`, {
|
||||||
|
encoding: 'utf8'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
exports.issueCommand = issueCommand;
|
||||||
|
//# sourceMappingURL=file-command.js.map
|
||||||
|
|
||||||
|
/***/ }),
|
||||||
|
|
||||||
/***/ 129:
|
/***/ 129:
|
||||||
/***/ (function(module) {
|
/***/ (function(module) {
|
||||||
|
|
||||||
@ -1035,10 +1054,25 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.customPackage = exports.scriptExtension = exports.joins = exports.getCommand = exports.getUnsupportedLog = exports.suppressOutput = exports.getExtensionPrefix = exports.CSVArray = exports.extensionArray = exports.writeScript = exports.readScript = exports.addLog = exports.stepLog = exports.log = exports.color = exports.asyncForEach = exports.getInput = void 0;
|
exports.customPackage = exports.scriptTool = exports.scriptExtension = exports.joins = exports.getCommand = exports.getUnsupportedLog = exports.suppressOutput = exports.getExtensionPrefix = exports.CSVArray = exports.extensionArray = exports.writeScript = exports.readScript = exports.addLog = exports.stepLog = exports.log = exports.color = exports.asyncForEach = exports.parseVersion = exports.getInput = exports.readEnv = void 0;
|
||||||
const fs = __importStar(__webpack_require__(747));
|
const fs = __importStar(__webpack_require__(747));
|
||||||
const path = __importStar(__webpack_require__(622));
|
const path = __importStar(__webpack_require__(622));
|
||||||
const core = __importStar(__webpack_require__(470));
|
const core = __importStar(__webpack_require__(470));
|
||||||
|
/**
|
||||||
|
* Function to read environment variable and return a string value.
|
||||||
|
*
|
||||||
|
* @param property
|
||||||
|
*/
|
||||||
|
async function readEnv(property) {
|
||||||
|
const value = process.env[property];
|
||||||
|
switch (value) {
|
||||||
|
case undefined:
|
||||||
|
return '';
|
||||||
|
default:
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exports.readEnv = readEnv;
|
||||||
/**
|
/**
|
||||||
* Function to get inputs from both with and env annotations.
|
* Function to get inputs from both with and env annotations.
|
||||||
*
|
*
|
||||||
@ -1046,16 +1080,39 @@ const core = __importStar(__webpack_require__(470));
|
|||||||
* @param mandatory
|
* @param mandatory
|
||||||
*/
|
*/
|
||||||
async function getInput(name, mandatory) {
|
async function getInput(name, mandatory) {
|
||||||
const input = process.env[name];
|
const input = core.getInput(name);
|
||||||
switch (input) {
|
const env_input = await readEnv(name);
|
||||||
case '':
|
switch (true) {
|
||||||
case undefined:
|
case input != '':
|
||||||
return core.getInput(name, { required: mandatory });
|
|
||||||
default:
|
|
||||||
return input;
|
return input;
|
||||||
|
case input == '' && env_input != '':
|
||||||
|
return env_input;
|
||||||
|
case input == '' && env_input == '' && mandatory:
|
||||||
|
throw new Error(`Input required and not supplied: ${name}`);
|
||||||
|
default:
|
||||||
|
return '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.getInput = getInput;
|
exports.getInput = getInput;
|
||||||
|
/**
|
||||||
|
* Function to parse PHP version.
|
||||||
|
*
|
||||||
|
* @param version
|
||||||
|
*/
|
||||||
|
async function parseVersion(version) {
|
||||||
|
switch (version) {
|
||||||
|
case 'latest':
|
||||||
|
return '7.4';
|
||||||
|
default:
|
||||||
|
switch (true) {
|
||||||
|
case version.length > 1:
|
||||||
|
return version.slice(0, 3);
|
||||||
|
default:
|
||||||
|
return version + '.0';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exports.parseVersion = parseVersion;
|
||||||
/**
|
/**
|
||||||
* Async foreach loop
|
* Async foreach loop
|
||||||
*
|
*
|
||||||
@ -1307,6 +1364,23 @@ async function scriptExtension(os_version) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.scriptExtension = scriptExtension;
|
exports.scriptExtension = scriptExtension;
|
||||||
|
/**
|
||||||
|
* Function to get script tool
|
||||||
|
*
|
||||||
|
* @param os_version
|
||||||
|
*/
|
||||||
|
async function scriptTool(os_version) {
|
||||||
|
switch (os_version) {
|
||||||
|
case 'win32':
|
||||||
|
return 'pwsh';
|
||||||
|
case 'linux':
|
||||||
|
case 'darwin':
|
||||||
|
return 'bash';
|
||||||
|
default:
|
||||||
|
return await log('Platform ' + os_version + ' is not supported', os_version, 'error');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exports.scriptTool = scriptTool;
|
||||||
/**
|
/**
|
||||||
* Function to get script to add tools with custom support.
|
* Function to get script to add tools with custom support.
|
||||||
*
|
*
|
||||||
@ -1348,6 +1422,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
const os = __importStar(__webpack_require__(87));
|
const os = __importStar(__webpack_require__(87));
|
||||||
|
const utils_1 = __webpack_require__(82);
|
||||||
/**
|
/**
|
||||||
* Commands
|
* Commands
|
||||||
*
|
*
|
||||||
@ -1401,28 +1476,14 @@ class Command {
|
|||||||
return cmdStr;
|
return cmdStr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* Sanitizes an input into a string so it can be passed into issueCommand safely
|
|
||||||
* @param input input to sanitize into a string
|
|
||||||
*/
|
|
||||||
function toCommandValue(input) {
|
|
||||||
if (input === null || input === undefined) {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
else if (typeof input === 'string' || input instanceof String) {
|
|
||||||
return input;
|
|
||||||
}
|
|
||||||
return JSON.stringify(input);
|
|
||||||
}
|
|
||||||
exports.toCommandValue = toCommandValue;
|
|
||||||
function escapeData(s) {
|
function escapeData(s) {
|
||||||
return toCommandValue(s)
|
return utils_1.toCommandValue(s)
|
||||||
.replace(/%/g, '%25')
|
.replace(/%/g, '%25')
|
||||||
.replace(/\r/g, '%0D')
|
.replace(/\r/g, '%0D')
|
||||||
.replace(/\n/g, '%0A');
|
.replace(/\n/g, '%0A');
|
||||||
}
|
}
|
||||||
function escapeProperty(s) {
|
function escapeProperty(s) {
|
||||||
return toCommandValue(s)
|
return utils_1.toCommandValue(s)
|
||||||
.replace(/%/g, '%25')
|
.replace(/%/g, '%25')
|
||||||
.replace(/\r/g, '%0D')
|
.replace(/\r/g, '%0D')
|
||||||
.replace(/\n/g, '%0A')
|
.replace(/\n/g, '%0A')
|
||||||
@ -1456,6 +1517,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
const command_1 = __webpack_require__(431);
|
const command_1 = __webpack_require__(431);
|
||||||
|
const file_command_1 = __webpack_require__(102);
|
||||||
|
const utils_1 = __webpack_require__(82);
|
||||||
const os = __importStar(__webpack_require__(87));
|
const os = __importStar(__webpack_require__(87));
|
||||||
const path = __importStar(__webpack_require__(622));
|
const path = __importStar(__webpack_require__(622));
|
||||||
/**
|
/**
|
||||||
@ -1482,10 +1545,18 @@ var ExitCode;
|
|||||||
*/
|
*/
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
function exportVariable(name, val) {
|
function exportVariable(name, val) {
|
||||||
const convertedVal = command_1.toCommandValue(val);
|
const convertedVal = utils_1.toCommandValue(val);
|
||||||
process.env[name] = convertedVal;
|
process.env[name] = convertedVal;
|
||||||
|
const filePath = process.env['GITHUB_ENV'] || '';
|
||||||
|
if (filePath) {
|
||||||
|
const delimiter = '_GitHubActionsFileCommandDelimeter_';
|
||||||
|
const commandValue = `${name}<<${delimiter}${os.EOL}${convertedVal}${os.EOL}${delimiter}`;
|
||||||
|
file_command_1.issueCommand('ENV', commandValue);
|
||||||
|
}
|
||||||
|
else {
|
||||||
command_1.issueCommand('set-env', { name }, convertedVal);
|
command_1.issueCommand('set-env', { name }, convertedVal);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
exports.exportVariable = exportVariable;
|
exports.exportVariable = exportVariable;
|
||||||
/**
|
/**
|
||||||
* Registers a secret which will get masked from logs
|
* Registers a secret which will get masked from logs
|
||||||
@ -1500,7 +1571,13 @@ exports.setSecret = setSecret;
|
|||||||
* @param inputPath
|
* @param inputPath
|
||||||
*/
|
*/
|
||||||
function addPath(inputPath) {
|
function addPath(inputPath) {
|
||||||
|
const filePath = process.env['GITHUB_PATH'] || '';
|
||||||
|
if (filePath) {
|
||||||
|
file_command_1.issueCommand('PATH', inputPath);
|
||||||
|
}
|
||||||
|
else {
|
||||||
command_1.issueCommand('add-path', {}, inputPath);
|
command_1.issueCommand('add-path', {}, inputPath);
|
||||||
|
}
|
||||||
process.env['PATH'] = `${inputPath}${path.delimiter}${process.env['PATH']}`;
|
process.env['PATH'] = `${inputPath}${path.delimiter}${process.env['PATH']}`;
|
||||||
}
|
}
|
||||||
exports.addPath = addPath;
|
exports.addPath = addPath;
|
||||||
@ -1837,14 +1914,14 @@ async function addPhive(version, os_version) {
|
|||||||
switch (version) {
|
switch (version) {
|
||||||
case 'latest':
|
case 'latest':
|
||||||
return ((await utils.getCommand(os_version, 'tool')) +
|
return ((await utils.getCommand(os_version, 'tool')) +
|
||||||
'https://phar.io/releases/phive.phar phive');
|
'https://phar.io/releases/phive.phar phive status');
|
||||||
default:
|
default:
|
||||||
return ((await utils.getCommand(os_version, 'tool')) +
|
return ((await utils.getCommand(os_version, 'tool')) +
|
||||||
'https://github.com/phar-io/phive/releases/download/' +
|
'https://github.com/phar-io/phive/releases/download/' +
|
||||||
version +
|
version +
|
||||||
'/phive-' +
|
'/phive-' +
|
||||||
version +
|
version +
|
||||||
'.phar phive');
|
'.phar phive status');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.addPhive = addPhive;
|
exports.addPhive = addPhive;
|
||||||
@ -1976,7 +2053,7 @@ async function getCleanedToolsList(tools_csv) {
|
|||||||
.map(function (extension) {
|
.map(function (extension) {
|
||||||
return extension
|
return extension
|
||||||
.trim()
|
.trim()
|
||||||
.replace(/-agent|hirak\/|laravel\/|narrowspark\/automatic-|overtrue\/|robmorgan\/|symfony\//, '');
|
.replace(/-agent|behat\/|hirak\/|icanhazstring\/|laravel\/|narrowspark\/automatic-|overtrue\/|phpspec\/|robmorgan\/|symfony\//, '');
|
||||||
})
|
})
|
||||||
.filter(Boolean);
|
.filter(Boolean);
|
||||||
return [...new Set(tools_list)];
|
return [...new Set(tools_list)];
|
||||||
@ -1988,9 +2065,11 @@ exports.getCleanedToolsList = getCleanedToolsList;
|
|||||||
* @param tool
|
* @param tool
|
||||||
* @param url
|
* @param url
|
||||||
* @param os_version
|
* @param os_version
|
||||||
|
* @param ver_param
|
||||||
*/
|
*/
|
||||||
async function addArchive(tool, url, os_version) {
|
async function addArchive(tool, url, os_version, ver_param) {
|
||||||
return (await utils.getCommand(os_version, 'tool')) + url + ' ' + tool;
|
return ((await utils.getCommand(os_version, 'tool')) +
|
||||||
|
(await utils.joins(url, tool, ver_param)));
|
||||||
}
|
}
|
||||||
exports.addArchive = addArchive;
|
exports.addArchive = addArchive;
|
||||||
/**
|
/**
|
||||||
@ -2002,11 +2081,8 @@ exports.addArchive = addArchive;
|
|||||||
async function addDevTools(tool, os_version) {
|
async function addDevTools(tool, os_version) {
|
||||||
switch (os_version) {
|
switch (os_version) {
|
||||||
case 'linux':
|
case 'linux':
|
||||||
return ('add_devtools' +
|
|
||||||
'\n' +
|
|
||||||
(await utils.addLog('$tick', tool, 'Added', 'linux')));
|
|
||||||
case 'darwin':
|
case 'darwin':
|
||||||
return await utils.addLog('$tick', tool, 'Added', 'darwin');
|
return 'add_devtools ' + tool;
|
||||||
case 'win32':
|
case 'win32':
|
||||||
return await utils.addLog('$cross', tool, tool + ' is not a windows tool', 'win32');
|
return await utils.addLog('$cross', tool, tool + ' is not a windows tool', 'win32');
|
||||||
default:
|
default:
|
||||||
@ -2051,24 +2127,28 @@ async function addTools(tools_csv, php_version, os_version) {
|
|||||||
case 'protoc':
|
case 'protoc':
|
||||||
script += await utils.customPackage(tool, 'tools', version, os_version);
|
script += await utils.customPackage(tool, 'tools', version, os_version);
|
||||||
break;
|
break;
|
||||||
|
case 'behat':
|
||||||
|
case 'phpspec':
|
||||||
|
script += await addPackage(tool, release, tool + '/', os_version);
|
||||||
|
break;
|
||||||
case 'blackfire-player':
|
case 'blackfire-player':
|
||||||
url = await getPharUrl('https://get.blackfire.io', tool, 'v', version);
|
url = await getPharUrl('https://get.blackfire.io', tool, 'v', version);
|
||||||
script += await addArchive(tool, url, os_version);
|
script += await addArchive(tool, url, os_version, '"-V"');
|
||||||
break;
|
break;
|
||||||
case 'codeception':
|
case 'codeception':
|
||||||
url =
|
url =
|
||||||
'https://codeception.com/' +
|
'https://codeception.com/' +
|
||||||
(await getCodeceptionUri(version, php_version));
|
(await getCodeceptionUri(version, php_version));
|
||||||
script += await addArchive(tool, url, os_version);
|
script += await addArchive(tool, url, os_version, '"-V"');
|
||||||
break;
|
break;
|
||||||
case 'composer':
|
case 'composer':
|
||||||
url = await getComposerUrl(version);
|
url = await getComposerUrl(version);
|
||||||
script += await addArchive('composer', url, os_version);
|
script += await addArchive('composer', url, os_version, version);
|
||||||
break;
|
break;
|
||||||
case 'composer-normalize':
|
case 'composer-normalize':
|
||||||
uri = await getUri(tool, '.phar', version, 'releases', '', 'download');
|
uri = await getUri(tool, '.phar', version, 'releases', '', 'download');
|
||||||
url = github + 'ergebnis/composer-normalize/' + uri;
|
url = github + 'ergebnis/composer-normalize/' + uri;
|
||||||
script += await addArchive(tool, url, os_version);
|
script += await addArchive(tool, url, os_version, '"-V"');
|
||||||
break;
|
break;
|
||||||
case 'composer-prefetcher':
|
case 'composer-prefetcher':
|
||||||
script += await addPackage(tool, release, 'narrowspark/automatic-', os_version);
|
script += await addPackage(tool, release, 'narrowspark/automatic-', os_version);
|
||||||
@ -2076,39 +2156,37 @@ async function addTools(tools_csv, php_version, os_version) {
|
|||||||
case 'composer-require-checker':
|
case 'composer-require-checker':
|
||||||
uri = await getUri(tool, '.phar', version, 'releases', '', 'download');
|
uri = await getUri(tool, '.phar', version, 'releases', '', 'download');
|
||||||
url = github + 'maglnet/ComposerRequireChecker/' + uri;
|
url = github + 'maglnet/ComposerRequireChecker/' + uri;
|
||||||
script += await addArchive(tool, url, os_version);
|
script += await addArchive(tool, url, os_version, '"-V"');
|
||||||
break;
|
break;
|
||||||
case 'composer-unused':
|
case 'composer-unused':
|
||||||
uri = await getUri(tool, '.phar', version, 'releases', '', 'download');
|
script += await addPackage(tool, release, 'icanhazstring/', os_version);
|
||||||
url = github + 'composer-unused/composer-unused/' + uri;
|
|
||||||
script += await addArchive(tool, url, os_version);
|
|
||||||
break;
|
break;
|
||||||
case 'cs2pr':
|
case 'cs2pr':
|
||||||
uri = await getUri(tool, '', version, 'releases', '', 'download');
|
uri = await getUri(tool, '', version, 'releases', '', 'download');
|
||||||
url = github + 'staabm/annotate-pull-request-from-checkstyle/' + uri;
|
url = github + 'staabm/annotate-pull-request-from-checkstyle/' + uri;
|
||||||
script += await addArchive(tool, url, os_version);
|
script += await addArchive(tool, url, os_version, '"-V"');
|
||||||
break;
|
break;
|
||||||
case 'deployer':
|
case 'deployer':
|
||||||
url = await getDeployerUrl(version);
|
url = await getDeployerUrl(version);
|
||||||
script += await addArchive(tool, url, os_version);
|
script += await addArchive(tool, url, os_version, '"-V"');
|
||||||
break;
|
break;
|
||||||
case 'flex':
|
case 'flex':
|
||||||
script += await addPackage(tool, release, 'symfony/', os_version);
|
script += await addPackage(tool, release, 'symfony/', os_version);
|
||||||
break;
|
break;
|
||||||
case 'infection':
|
case 'infection':
|
||||||
url = github + 'infection/infection/' + uri;
|
url = github + 'infection/infection/' + uri;
|
||||||
script += await addArchive(tool, url, os_version);
|
script += await addArchive(tool, url, os_version, '"-V"');
|
||||||
break;
|
break;
|
||||||
case 'pecl':
|
case 'pecl':
|
||||||
script += await utils.getCommand(os_version, 'pecl');
|
script += await utils.getCommand(os_version, 'pecl');
|
||||||
break;
|
break;
|
||||||
case 'phan':
|
case 'phan':
|
||||||
url = github + 'phan/phan/' + uri;
|
url = github + 'phan/phan/' + uri;
|
||||||
script += await addArchive(tool, url, os_version);
|
script += await addArchive(tool, url, os_version, '"-v"');
|
||||||
break;
|
break;
|
||||||
case 'phing':
|
case 'phing':
|
||||||
url = 'https://www.phing.info/get/phing-' + version + '.phar';
|
url = 'https://www.phing.info/get/phing-' + version + '.phar';
|
||||||
script += await addArchive(tool, url, os_version);
|
script += await addArchive(tool, url, os_version, '"-v"');
|
||||||
break;
|
break;
|
||||||
case 'phinx':
|
case 'phinx':
|
||||||
script += await addPackage(tool, release, 'robmorgan/', os_version);
|
script += await addPackage(tool, release, 'robmorgan/', os_version);
|
||||||
@ -2123,48 +2201,48 @@ async function addTools(tools_csv, php_version, os_version) {
|
|||||||
case 'php-cs-fixer':
|
case 'php-cs-fixer':
|
||||||
uri = await getUri(tool, '.phar', 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, url, os_version);
|
script += await addArchive(tool, url, os_version, '"-V"');
|
||||||
break;
|
break;
|
||||||
case 'phpcbf':
|
case 'phpcbf':
|
||||||
case 'phpcs':
|
case 'phpcs':
|
||||||
url = github + 'squizlabs/PHP_CodeSniffer/' + uri;
|
url = github + 'squizlabs/PHP_CodeSniffer/' + uri;
|
||||||
script += await addArchive(tool, url, os_version);
|
script += await addArchive(tool, url, os_version, '"--version"');
|
||||||
break;
|
break;
|
||||||
case 'phpcpd':
|
case 'phpcpd':
|
||||||
case 'phpunit':
|
case 'phpunit':
|
||||||
url = await getPharUrl('https://phar.phpunit.de', tool, '', version);
|
url = await getPharUrl('https://phar.phpunit.de', tool, '', version);
|
||||||
script += await addArchive(tool, url, os_version);
|
script += await addArchive(tool, url, os_version, '"--version"');
|
||||||
break;
|
break;
|
||||||
case 'phplint':
|
case 'phplint':
|
||||||
script += await addPackage(tool, release, 'overtrue/', os_version);
|
script += await addPackage(tool, release, 'overtrue/', os_version);
|
||||||
break;
|
break;
|
||||||
case 'phpmd':
|
case 'phpmd':
|
||||||
url = github + 'phpmd/phpmd/' + uri;
|
url = github + 'phpmd/phpmd/' + uri;
|
||||||
script += await addArchive(tool, url, os_version);
|
script += await addArchive(tool, url, os_version, '"--version"');
|
||||||
break;
|
break;
|
||||||
case 'phpstan':
|
case 'phpstan':
|
||||||
url = github + 'phpstan/phpstan/' + uri;
|
url = github + 'phpstan/phpstan/' + uri;
|
||||||
script += await addArchive(tool, url, os_version);
|
script += await addArchive(tool, url, os_version, '"-V"');
|
||||||
break;
|
break;
|
||||||
case 'prestissimo':
|
case 'prestissimo':
|
||||||
script += await addPackage(tool, release, 'hirak/', os_version);
|
script += await addPackage(tool, release, 'hirak/', os_version);
|
||||||
break;
|
break;
|
||||||
case 'psalm':
|
case 'psalm':
|
||||||
url = github + 'vimeo/psalm/' + uri;
|
url = github + 'vimeo/psalm/' + uri;
|
||||||
script += await addArchive(tool, url, os_version);
|
script += await addArchive(tool, url, os_version, '"-v"');
|
||||||
break;
|
break;
|
||||||
case 'symfony':
|
case 'symfony':
|
||||||
case 'symfony-cli':
|
case 'symfony-cli':
|
||||||
uri = await getSymfonyUri(version, os_version);
|
uri = await getSymfonyUri(version, os_version);
|
||||||
url = github + 'symfony/cli/' + uri;
|
url = github + 'symfony/cli/' + uri;
|
||||||
script += await addArchive('symfony', url, os_version);
|
script += await addArchive('symfony', url, os_version, 'version');
|
||||||
break;
|
break;
|
||||||
case 'vapor-cli':
|
case 'vapor-cli':
|
||||||
script += await addPackage(tool, release, 'laravel/', os_version);
|
script += await addPackage(tool, release, 'laravel/', os_version);
|
||||||
break;
|
break;
|
||||||
case 'wp-cli':
|
case 'wp-cli':
|
||||||
url = github + (await getWpCliUrl(version));
|
url = github + (await getWpCliUrl(version));
|
||||||
script += await addArchive(tool, url, os_version);
|
script += await addArchive(tool, url, os_version, '"--version"');
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
script += await utils.addLog('$cross', tool, 'Tool ' + tool + ' is not supported', os_version);
|
script += await utils.addLog('$cross', tool, 'Tool ' + tool + ' is not supported', os_version);
|
||||||
@ -2453,7 +2531,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.run = exports.build = void 0;
|
exports.run = exports.getScript = void 0;
|
||||||
const exec_1 = __webpack_require__(986);
|
const exec_1 = __webpack_require__(986);
|
||||||
const core = __importStar(__webpack_require__(470));
|
const core = __importStar(__webpack_require__(470));
|
||||||
const config = __importStar(__webpack_require__(641));
|
const config = __importStar(__webpack_require__(641));
|
||||||
@ -2461,7 +2539,6 @@ const coverage = __importStar(__webpack_require__(635));
|
|||||||
const extensions = __importStar(__webpack_require__(911));
|
const extensions = __importStar(__webpack_require__(911));
|
||||||
const tools = __importStar(__webpack_require__(534));
|
const tools = __importStar(__webpack_require__(534));
|
||||||
const utils = __importStar(__webpack_require__(163));
|
const utils = __importStar(__webpack_require__(163));
|
||||||
const matchers = __importStar(__webpack_require__(86));
|
|
||||||
/**
|
/**
|
||||||
* Build the script
|
* Build the script
|
||||||
*
|
*
|
||||||
@ -2469,19 +2546,15 @@ const matchers = __importStar(__webpack_require__(86));
|
|||||||
* @param version
|
* @param version
|
||||||
* @param os_version
|
* @param os_version
|
||||||
*/
|
*/
|
||||||
async function build(filename, version, os_version) {
|
async function getScript(filename, version, os_version) {
|
||||||
const name = 'setup-php';
|
const name = 'setup-php';
|
||||||
const url = 'setup-php.com/support';
|
const url = 'https://setup-php.com/support';
|
||||||
// taking inputs
|
// taking inputs
|
||||||
const extension_csv = (await utils.getInput('extensions', false)) ||
|
const extension_csv = await utils.getInput('extensions', false);
|
||||||
(await utils.getInput('extension', false));
|
|
||||||
const ini_values_csv = await utils.getInput('ini-values', false);
|
const ini_values_csv = await utils.getInput('ini-values', false);
|
||||||
const coverage_driver = await utils.getInput('coverage', false);
|
const coverage_driver = await utils.getInput('coverage', false);
|
||||||
const pecl = await utils.getInput('pecl', false);
|
|
||||||
let tools_csv = await utils.getInput('tools', false);
|
let tools_csv = await utils.getInput('tools', false);
|
||||||
if (pecl == 'true' ||
|
if (/.*-(beta|alpha|devel|snapshot|\d+\.\d+\.\d+).*/.test(extension_csv)) {
|
||||||
/.*-(beta|alpha|devel|snapshot).*/.test(extension_csv) ||
|
|
||||||
/.*-(\d+\.\d+\.\d+).*/.test(extension_csv)) {
|
|
||||||
tools_csv = 'pecl, ' + tools_csv;
|
tools_csv = 'pecl, ' + tools_csv;
|
||||||
}
|
}
|
||||||
let script = await utils.readScript(filename);
|
let script = await utils.readScript(filename);
|
||||||
@ -2499,29 +2572,18 @@ async function build(filename, version, os_version) {
|
|||||||
script += '\n' + (await utils.addLog('$tick', name, url, os_version));
|
script += '\n' + (await utils.addLog('$tick', name, url, os_version));
|
||||||
return await utils.writeScript(filename, script);
|
return await utils.writeScript(filename, script);
|
||||||
}
|
}
|
||||||
exports.build = build;
|
exports.getScript = getScript;
|
||||||
/**
|
/**
|
||||||
* Run the script
|
* Run the script
|
||||||
*/
|
*/
|
||||||
async function run() {
|
async function run() {
|
||||||
try {
|
try {
|
||||||
let version = await utils.getInput('php-version', true);
|
const version = await utils.parseVersion(await utils.getInput('php-version', true));
|
||||||
version = version.length > 1 ? version.slice(0, 3) : version + '.0';
|
|
||||||
const os_version = process.platform;
|
const os_version = process.platform;
|
||||||
// check the os version and run the respective script
|
const tool = await utils.scriptTool(os_version);
|
||||||
let script_path = '';
|
const script = os_version + (await utils.scriptExtension(os_version));
|
||||||
switch (os_version) {
|
const location = await getScript(script, version, os_version);
|
||||||
case 'darwin':
|
await exec_1.exec(await utils.joins(tool, location, version, __dirname));
|
||||||
case 'linux':
|
|
||||||
script_path = await build(os_version + '.sh', version, os_version);
|
|
||||||
await exec_1.exec('bash ' + script_path + ' ' + version + ' ' + __dirname);
|
|
||||||
break;
|
|
||||||
case 'win32':
|
|
||||||
script_path = await build('win32.ps1', version, os_version);
|
|
||||||
await exec_1.exec('pwsh ' + script_path + ' ' + version + ' ' + __dirname);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
await matchers.addMatchers();
|
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
core.setFailed(error.message);
|
core.setFailed(error.message);
|
||||||
|
1422
package-lock.json
generated
1422
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
28
package.json
28
package.json
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "setup-php",
|
"name": "setup-php",
|
||||||
"version": "2.5.0",
|
"version": "2.6.0",
|
||||||
"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.5",
|
"@actions/core": "^1.2.6",
|
||||||
"@actions/exec": "^1.0.4",
|
"@actions/exec": "^1.0.4",
|
||||||
"@actions/io": "^1.0.2",
|
"@actions/io": "^1.0.2",
|
||||||
"fs": "0.0.1-security"
|
"fs": "0.0.1-security"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/jest": "^26.0.13",
|
"@types/jest": "^26.0.14",
|
||||||
"@types/node": "^14.6.4",
|
"@types/node": "^14.11.2",
|
||||||
"@typescript-eslint/eslint-plugin": "^4.0.1",
|
"@typescript-eslint/eslint-plugin": "^4.3.0",
|
||||||
"@typescript-eslint/parser": "^4.0.1",
|
"@typescript-eslint/parser": "^4.3.0",
|
||||||
"@zeit/ncc": "^0.22.3",
|
"@zeit/ncc": "^0.22.3",
|
||||||
"eslint": "^7.8.1",
|
"eslint": "^7.10.0",
|
||||||
"eslint-config-prettier": "^6.11.0",
|
"eslint-config-prettier": "^6.12.0",
|
||||||
"eslint-plugin-import": "^2.22.0",
|
"eslint-plugin-import": "^2.22.1",
|
||||||
"eslint-plugin-jest": "^24.0.0",
|
"eslint-plugin-jest": "^24.0.2",
|
||||||
"eslint-plugin-prettier": "^3.1.4",
|
"eslint-plugin-prettier": "^3.1.4",
|
||||||
"husky": "^4.2.5",
|
"husky": "^4.3.0",
|
||||||
"jest": "^26.4.2",
|
"jest": "^26.4.2",
|
||||||
"jest-circus": "^26.4.2",
|
"jest-circus": "^26.4.2",
|
||||||
"prettier": "^2.1.1",
|
"prettier": "^2.1.2",
|
||||||
"ts-jest": "^26.3.0",
|
"ts-jest": "^26.4.1",
|
||||||
"typescript": "^4.0.2"
|
"typescript": "^4.0.3"
|
||||||
},
|
},
|
||||||
"husky": {
|
"husky": {
|
||||||
"skipCI": true,
|
"skipCI": true,
|
||||||
|
@ -5,7 +5,6 @@ import * as coverage from './coverage';
|
|||||||
import * as extensions from './extensions';
|
import * as extensions from './extensions';
|
||||||
import * as tools from './tools';
|
import * as tools from './tools';
|
||||||
import * as utils from './utils';
|
import * as utils from './utils';
|
||||||
import * as matchers from './matchers';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Build the script
|
* Build the script
|
||||||
@ -14,26 +13,19 @@ import * as matchers from './matchers';
|
|||||||
* @param version
|
* @param version
|
||||||
* @param os_version
|
* @param os_version
|
||||||
*/
|
*/
|
||||||
export async function build(
|
export async function getScript(
|
||||||
filename: string,
|
filename: string,
|
||||||
version: string,
|
version: string,
|
||||||
os_version: string
|
os_version: string
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
const name = 'setup-php';
|
const name = 'setup-php';
|
||||||
const url = 'setup-php.com/support';
|
const url = 'https://setup-php.com/support';
|
||||||
// taking inputs
|
// taking inputs
|
||||||
const extension_csv: string =
|
const extension_csv: string = await utils.getInput('extensions', false);
|
||||||
(await utils.getInput('extensions', false)) ||
|
|
||||||
(await utils.getInput('extension', false));
|
|
||||||
const ini_values_csv: string = await utils.getInput('ini-values', false);
|
const ini_values_csv: string = await utils.getInput('ini-values', false);
|
||||||
const coverage_driver: string = await utils.getInput('coverage', false);
|
const coverage_driver: string = await utils.getInput('coverage', false);
|
||||||
const pecl: string = await utils.getInput('pecl', false);
|
|
||||||
let tools_csv: string = await utils.getInput('tools', false);
|
let tools_csv: string = await utils.getInput('tools', false);
|
||||||
if (
|
if (/.*-(beta|alpha|devel|snapshot|\d+\.\d+\.\d+).*/.test(extension_csv)) {
|
||||||
pecl == 'true' ||
|
|
||||||
/.*-(beta|alpha|devel|snapshot).*/.test(extension_csv) ||
|
|
||||||
/.*-(\d+\.\d+\.\d+).*/.test(extension_csv)
|
|
||||||
) {
|
|
||||||
tools_csv = 'pecl, ' + tools_csv;
|
tools_csv = 'pecl, ' + tools_csv;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,24 +53,14 @@ export async function build(
|
|||||||
*/
|
*/
|
||||||
export async function run(): Promise<void> {
|
export async function run(): Promise<void> {
|
||||||
try {
|
try {
|
||||||
let version: string = await utils.getInput('php-version', true);
|
const version: string = await utils.parseVersion(
|
||||||
version = version.length > 1 ? version.slice(0, 3) : version + '.0';
|
await utils.getInput('php-version', true)
|
||||||
|
);
|
||||||
const os_version: string = process.platform;
|
const os_version: string = process.platform;
|
||||||
|
const tool = await utils.scriptTool(os_version);
|
||||||
// check the os version and run the respective script
|
const script = os_version + (await utils.scriptExtension(os_version));
|
||||||
let script_path = '';
|
const location = await getScript(script, version, os_version);
|
||||||
switch (os_version) {
|
await exec(await utils.joins(tool, location, version, __dirname));
|
||||||
case 'darwin':
|
|
||||||
case 'linux':
|
|
||||||
script_path = await build(os_version + '.sh', version, os_version);
|
|
||||||
await exec('bash ' + script_path + ' ' + version + ' ' + __dirname);
|
|
||||||
break;
|
|
||||||
case 'win32':
|
|
||||||
script_path = await build('win32.ps1', version, os_version);
|
|
||||||
await exec('pwsh ' + script_path + ' ' + version + ' ' + __dirname);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
await matchers.addMatchers();
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
core.setFailed(error.message);
|
core.setFailed(error.message);
|
||||||
}
|
}
|
||||||
|
@ -1,13 +0,0 @@
|
|||||||
import * as path from 'path';
|
|
||||||
import * as utils from './utils';
|
|
||||||
import * as io from '@actions/io';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Cache json files for problem matchers
|
|
||||||
*/
|
|
||||||
export async function addMatchers(): Promise<void> {
|
|
||||||
const config_path = path.join(__dirname, '..', 'src', 'configs');
|
|
||||||
const runner_dir: string = await utils.getInput('RUNNER_TOOL_CACHE', false);
|
|
||||||
await io.cp(path.join(config_path, 'phpunit.json'), runner_dir);
|
|
||||||
await io.cp(path.join(config_path, 'php.json'), runner_dir);
|
|
||||||
}
|
|
@ -152,16 +152,35 @@ configure_composer() {
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
composer -q global config process-timeout 0
|
composer -q global config process-timeout 0
|
||||||
echo "::add-path::/Users/$USER/.composer/vendor/bin"
|
echo "/Users/$USER/.composer/vendor/bin" >> "$GITHUB_PATH"
|
||||||
if [ -n "$COMPOSER_TOKEN" ]; then
|
if [ -n "$COMPOSER_TOKEN" ]; then
|
||||||
composer -q global config github-oauth.github.com "$COMPOSER_TOKEN"
|
composer -q global config github-oauth.github.com "$COMPOSER_TOKEN"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Function to extract tool version.
|
||||||
|
get_tool_version() {
|
||||||
|
tool=$1
|
||||||
|
param=$2
|
||||||
|
version_regex="[0-9]+((\.{1}[0-9]+)+)(\.{0})(-[a-zA-Z0-9]+){0,1}"
|
||||||
|
if [ "$tool" = "composer" ]; then
|
||||||
|
if [ "$param" != "snapshot" ]; then
|
||||||
|
grep -Ea "const\sVERSION" "$tool_path_dir/composer" | grep -Eo "$version_regex"
|
||||||
|
else
|
||||||
|
trunk=$(grep -Ea "const\sBRANCH_ALIAS_VERSION" "$tool_path_dir/composer" | grep -Eo "$version_regex")
|
||||||
|
commit=$(grep -Ea "const\sVERSION" "$tool_path_dir/composer" | grep -Eo "[a-zA-z0-9]+" | tail -n 1)
|
||||||
|
echo "$trunk+$commit"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
$tool "$param" 2>/dev/null | sed -Ee "s/[Cc]omposer(.)?$version_regex//g" | grep -Eo "$version_regex" | head -n 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# Function to setup a remote tool.
|
# Function to setup a remote tool.
|
||||||
add_tool() {
|
add_tool() {
|
||||||
url=$1
|
url=$1
|
||||||
tool=$2
|
tool=$2
|
||||||
|
ver_param=$3
|
||||||
tool_path="$tool_path_dir/$tool"
|
tool_path="$tool_path_dir/$tool"
|
||||||
if [ ! -e "$tool_path" ]; then
|
if [ ! -e "$tool_path" ]; then
|
||||||
rm -rf "$tool_path"
|
rm -rf "$tool_path"
|
||||||
@ -191,7 +210,8 @@ add_tool() {
|
|||||||
elif [ "$tool" = "wp-cli" ]; then
|
elif [ "$tool" = "wp-cli" ]; then
|
||||||
sudo cp -p "$tool_path" "$tool_path_dir"/wp
|
sudo cp -p "$tool_path" "$tool_path_dir"/wp
|
||||||
fi
|
fi
|
||||||
add_log "$tick" "$tool" "Added"
|
tool_version=$(get_tool_version "$tool" "$ver_param")
|
||||||
|
add_log "$tick" "$tool" "Added $tool $tool_version"
|
||||||
else
|
else
|
||||||
add_log "$cross" "$tool" "Could not setup $tool"
|
add_log "$cross" "$tool" "Could not setup $tool"
|
||||||
fi
|
fi
|
||||||
@ -203,10 +223,19 @@ add_composertool() {
|
|||||||
release=$2
|
release=$2
|
||||||
prefix=$3
|
prefix=$3
|
||||||
(
|
(
|
||||||
composer global require "$prefix$release" >/dev/null 2>&1 && add_log "$tick" "$tool" "Added"
|
composer global require "$prefix$release" >/dev/null 2>&1 &&
|
||||||
|
json=$(grep "$prefix$tool" /Users/$USER/.composer/composer.json) &&
|
||||||
|
tool_version=$(get_tool_version 'echo' "$json") &&
|
||||||
|
add_log "$tick" "$tool" "Added $tool $tool_version"
|
||||||
) || add_log "$cross" "$tool" "Could not setup $tool"
|
) || add_log "$cross" "$tool" "Could not setup $tool"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Function to handle request to add phpize and php-config.
|
||||||
|
add_devtools() {
|
||||||
|
tool=$1
|
||||||
|
add_log "$tick" "$tool" "Added $tool $semver"
|
||||||
|
}
|
||||||
|
|
||||||
# Function to configure PECL
|
# Function to configure PECL
|
||||||
configure_pecl() {
|
configure_pecl() {
|
||||||
for tool in pear pecl; do
|
for tool in pear pecl; do
|
||||||
@ -217,7 +246,8 @@ configure_pecl() {
|
|||||||
|
|
||||||
# Function to handle request to add PECL.
|
# Function to handle request to add PECL.
|
||||||
add_pecl() {
|
add_pecl() {
|
||||||
add_log "$tick" "PECL" "Added"
|
pecl_version=$(get_tool_version "pecl" "version")
|
||||||
|
add_log "$tick" "PECL" "Found PECL $pecl_version"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to setup PHP 5.6 and newer.
|
# Function to setup PHP 5.6 and newer.
|
||||||
@ -237,6 +267,7 @@ setup_php() {
|
|||||||
tick="✓"
|
tick="✓"
|
||||||
cross="✗"
|
cross="✗"
|
||||||
version=$1
|
version=$1
|
||||||
|
dist=$2
|
||||||
nodot_version=${1/./}
|
nodot_version=${1/./}
|
||||||
old_versions="5.[3-5]"
|
old_versions="5.[3-5]"
|
||||||
tool_path_dir="/usr/local/bin"
|
tool_path_dir="/usr/local/bin"
|
||||||
@ -275,4 +306,5 @@ scan_dir=$(php --ini | grep additional | sed -e "s|.*: s*||")
|
|||||||
sudo mkdir -p "$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 ' ')
|
||||||
if [[ ! "$version" =~ $old_versions ]]; then configure_pecl >/dev/null 2>&1; fi
|
if [[ ! "$version" =~ $old_versions ]]; then configure_pecl >/dev/null 2>&1; fi
|
||||||
|
sudo mv "$dist"/../src/configs/*.json "$RUNNER_TOOL_CACHE/"
|
||||||
add_log "$tick" "PHP" "$status PHP $semver"
|
add_log "$tick" "PHP" "$status PHP $semver"
|
||||||
|
@ -231,7 +231,7 @@ add_extension_from_source() {
|
|||||||
args=$4
|
args=$4
|
||||||
prefix=$5
|
prefix=$5
|
||||||
(
|
(
|
||||||
add_devtools
|
add_devtools phpize
|
||||||
delete_extension "$extension"
|
delete_extension "$extension"
|
||||||
curl -o /tmp/"$extension".tar.gz "${curl_opts[@]}" https://github.com/"$repo"/archive/"$release".tar.gz
|
curl -o /tmp/"$extension".tar.gz "${curl_opts[@]}" https://github.com/"$repo"/archive/"$release".tar.gz
|
||||||
tar xf /tmp/"$extension".tar.gz -C /tmp
|
tar xf /tmp/"$extension".tar.gz -C /tmp
|
||||||
@ -252,16 +252,35 @@ configure_composer() {
|
|||||||
exit 1;
|
exit 1;
|
||||||
fi
|
fi
|
||||||
composer -q global config process-timeout 0
|
composer -q global config process-timeout 0
|
||||||
echo "::add-path::/home/$USER/.composer/vendor/bin"
|
echo "/home/$USER/.composer/vendor/bin" >> "$GITHUB_PATH"
|
||||||
if [ -n "$COMPOSER_TOKEN" ]; then
|
if [ -n "$COMPOSER_TOKEN" ]; then
|
||||||
composer -q global config github-oauth.github.com "$COMPOSER_TOKEN"
|
composer -q global config github-oauth.github.com "$COMPOSER_TOKEN"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Function to extract tool version.
|
||||||
|
get_tool_version() {
|
||||||
|
tool=$1
|
||||||
|
param=$2
|
||||||
|
version_regex="[0-9]+((\.{1}[0-9]+)+)(\.{0})(-[a-zA-Z0-9]+){0,1}"
|
||||||
|
if [ "$tool" = "composer" ]; then
|
||||||
|
if [ "$param" != "snapshot" ]; then
|
||||||
|
grep -Ea "const\sVERSION" "$tool_path_dir/composer" | grep -Eo "$version_regex"
|
||||||
|
else
|
||||||
|
trunk=$(grep -Ea "const\sBRANCH_ALIAS_VERSION" "$tool_path_dir/composer" | grep -Eo "$version_regex")
|
||||||
|
commit=$(grep -Ea "const\sVERSION" "$tool_path_dir/composer" | grep -Eo "[a-zA-z0-9]+" | tail -n 1)
|
||||||
|
echo "$trunk+$commit"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
$tool "$param" 2>/dev/null | sed -Ee "s/[Cc]omposer(.)?$version_regex//g" | grep -Eo "$version_regex" | head -n 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# Function to setup a remote tool.
|
# Function to setup a remote tool.
|
||||||
add_tool() {
|
add_tool() {
|
||||||
url=$1
|
url=$1
|
||||||
tool=$2
|
tool=$2
|
||||||
|
ver_param=$3
|
||||||
tool_path="$tool_path_dir/$tool"
|
tool_path="$tool_path_dir/$tool"
|
||||||
if [ ! -e "$tool_path" ]; then
|
if [ ! -e "$tool_path" ]; then
|
||||||
rm -rf "$tool_path"
|
rm -rf "$tool_path"
|
||||||
@ -289,7 +308,8 @@ add_tool() {
|
|||||||
elif [ "$tool" = "wp-cli" ]; then
|
elif [ "$tool" = "wp-cli" ]; then
|
||||||
sudo cp -p "$tool_path" "$tool_path_dir"/wp
|
sudo cp -p "$tool_path" "$tool_path_dir"/wp
|
||||||
fi
|
fi
|
||||||
add_log "$tick" "$tool" "Added"
|
tool_version=$(get_tool_version "$tool" "$ver_param")
|
||||||
|
add_log "$tick" "$tool" "Added $tool $tool_version"
|
||||||
else
|
else
|
||||||
add_log "$cross" "$tool" "Could not setup $tool"
|
add_log "$cross" "$tool" "Could not setup $tool"
|
||||||
fi
|
fi
|
||||||
@ -302,18 +322,22 @@ add_composertool() {
|
|||||||
prefix=$3
|
prefix=$3
|
||||||
(
|
(
|
||||||
composer global require "$prefix$release" >/dev/null 2>&1 &&
|
composer global require "$prefix$release" >/dev/null 2>&1 &&
|
||||||
add_log "$tick" "$tool" "Added"
|
json=$(grep "$prefix$tool" /home/$USER/.composer/composer.json) &&
|
||||||
|
tool_version=$(get_tool_version 'echo' "$json") &&
|
||||||
|
add_log "$tick" "$tool" "Added $tool $tool_version"
|
||||||
) || add_log "$cross" "$tool" "Could not setup $tool"
|
) || add_log "$cross" "$tool" "Could not setup $tool"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to setup phpize and php-config.
|
# Function to setup phpize and php-config.
|
||||||
add_devtools() {
|
add_devtools() {
|
||||||
|
tool=$1
|
||||||
if ! [ -e "/usr/bin/phpize$version" ] || ! [ -e "/usr/bin/php-config$version" ]; then
|
if ! [ -e "/usr/bin/phpize$version" ] || ! [ -e "/usr/bin/php-config$version" ]; then
|
||||||
update_lists && $apt_install php"$version"-dev php"$version"-xml >/dev/null 2>&1
|
update_lists && $apt_install php"$version"-dev php"$version"-xml >/dev/null 2>&1
|
||||||
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 >/dev/null 2>&1
|
configure_pecl >/dev/null 2>&1
|
||||||
|
add_log "$tick" "$tool" "Added $tool $semver"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to setup the nightly build from master branch.
|
# Function to setup the nightly build from master branch.
|
||||||
@ -330,12 +354,13 @@ setup_old_versions() {
|
|||||||
|
|
||||||
# Function to add PECL.
|
# Function to add PECL.
|
||||||
add_pecl() {
|
add_pecl() {
|
||||||
add_devtools >/dev/null 2>&1
|
add_devtools phpize >/dev/null 2>&1
|
||||||
if [ ! -e /usr/bin/pecl ]; then
|
if [ ! -e /usr/bin/pecl ]; then
|
||||||
$apt_install php-pear >/dev/null 2>&1 || update_lists && $apt_install php-pear >/dev/null 2>&1
|
$apt_install php-pear >/dev/null 2>&1 || update_lists && $apt_install php-pear >/dev/null 2>&1
|
||||||
fi
|
fi
|
||||||
configure_pecl >/dev/null 2>&1
|
configure_pecl >/dev/null 2>&1
|
||||||
add_log "$tick" "PECL" "Added"
|
pecl_version=$(get_tool_version "pecl" "version")
|
||||||
|
add_log "$tick" "PECL" "Added PECL $pecl_version"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to switch versions of PHP binaries.
|
# Function to switch versions of PHP binaries.
|
||||||
@ -397,6 +422,7 @@ tick="✓"
|
|||||||
cross="✗"
|
cross="✗"
|
||||||
pecl_config="false"
|
pecl_config="false"
|
||||||
version=$1
|
version=$1
|
||||||
|
dist=$2
|
||||||
master_version="8.0"
|
master_version="8.0"
|
||||||
old_versions="5.[3-5]"
|
old_versions="5.[3-5]"
|
||||||
debconf_fix="DEBIAN_FRONTEND=noninteractive"
|
debconf_fix="DEBIAN_FRONTEND=noninteractive"
|
||||||
@ -452,4 +478,5 @@ pecl_file="$scan_dir"/99-pecl.ini
|
|||||||
echo '' | sudo tee "$pecl_file" >/dev/null 2>&1
|
echo '' | sudo tee "$pecl_file" >/dev/null 2>&1
|
||||||
sudo rm -rf /usr/local/bin/phpunit >/dev/null 2>&1
|
sudo rm -rf /usr/local/bin/phpunit >/dev/null 2>&1
|
||||||
sudo chmod 777 "$ini_file" "$pecl_file" "$tool_path_dir"
|
sudo chmod 777 "$ini_file" "$pecl_file" "$tool_path_dir"
|
||||||
|
sudo mv "$dist"/../src/configs/*.json "$RUNNER_TOOL_CACHE/"
|
||||||
add_log "$tick" "PHP" "$status PHP $semver"
|
add_log "$tick" "PHP" "$status PHP $semver"
|
||||||
|
@ -16,6 +16,6 @@ Function Add-Blackfire() {
|
|||||||
if ((Test-Path env:BLACKFIRE_CLIENT_ID) -and (Test-Path env:BLACKFIRE_CLIENT_TOKEN)) {
|
if ((Test-Path env:BLACKFIRE_CLIENT_ID) -and (Test-Path env:BLACKFIRE_CLIENT_TOKEN)) {
|
||||||
blackfire config --client-id=$env:BLACKFIRE_CLIENT_ID --client-token=$env:BLACKFIRE_CLIENT_TOKEN --ca-cert=$php_dir\ssl\cacert.pem >$null 2>&1
|
blackfire config --client-id=$env:BLACKFIRE_CLIENT_ID --client-token=$env:BLACKFIRE_CLIENT_TOKEN --ca-cert=$php_dir\ssl\cacert.pem >$null 2>&1
|
||||||
}
|
}
|
||||||
Add-Log $tick "blackfire" "Added"
|
Add-Log $tick "blackfire" "Added blackfire $agent_version"
|
||||||
Add-Log $tick "blackfire-agent" "Added"
|
Add-Log $tick "blackfire-agent" "Added blackfire-agent $agent_version"
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,7 @@ add_blackfire() {
|
|||||||
[ "$os" = "Linux" ] && add_blackfire_linux >/dev/null 2>&1
|
[ "$os" = "Linux" ] && add_blackfire_linux >/dev/null 2>&1
|
||||||
[ "$os" = "Darwin" ] && add_blackfire_darwin >/dev/null 2>&1
|
[ "$os" = "Darwin" ] && add_blackfire_darwin >/dev/null 2>&1
|
||||||
blackfire_config >/dev/null 2>&1
|
blackfire_config >/dev/null 2>&1
|
||||||
add_log "${tick:?}" "blackfire" "Added"
|
tool_version=$(get_tool_version "blackfire" "version")
|
||||||
add_log "${tick:?}" "blackfire-agent" "Added"
|
add_log "${tick:?}" "blackfire" "Added blackfire $tool_version"
|
||||||
|
add_log "${tick:?}" "blackfire-agent" "Added blackfire-agent $tool_version"
|
||||||
}
|
}
|
||||||
|
@ -9,11 +9,12 @@ Function Add-Msys2() {
|
|||||||
|
|
||||||
Function Add-Grpc_php_plugin() {
|
Function Add-Grpc_php_plugin() {
|
||||||
$msys_location = Add-Msys2
|
$msys_location = Add-Msys2
|
||||||
. $msys_location\usr\bin\bash -l -c "pacman -S --noconfirm mingw-w64-x86_64-grpc" >$null 2>&1
|
$logs = . $msys_location\usr\bin\bash -l -c "pacman -S --noconfirm mingw-w64-x86_64-grpc" >$null 2>&1
|
||||||
Write-Output "::add-path::$msys_location\mingw64\bin"
|
$grpc_version = Get-ToolVersion 'Write-Output' "$logs"
|
||||||
|
Write-Output "$msys_location\mingw64\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8
|
||||||
Write-Output "::set-output name=grpc_php_plugin_path::$msys_location\mingw64\bin\grpc_php_plugin.exe"
|
Write-Output "::set-output name=grpc_php_plugin_path::$msys_location\mingw64\bin\grpc_php_plugin.exe"
|
||||||
Add-ToProfile $current_profile 'grpc_php_plugin' "New-Alias grpc_php_plugin $msys_location\mingw64\bin\grpc_php_plugin.exe"
|
Add-ToProfile $current_profile 'grpc_php_plugin' "New-Alias grpc_php_plugin $msys_location\mingw64\bin\grpc_php_plugin.exe"
|
||||||
Add-Log $tick "grpc_php_plugin" "Added"
|
Add-Log $tick "grpc_php_plugin" "Added grpc_php_plugin $grpc_version"
|
||||||
printf "::group::\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" "grpc_php_plugin" "Click to read the grpc_php_plugin related license information"
|
printf "::group::\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" "grpc_php_plugin" "Click to read the grpc_php_plugin related license information"
|
||||||
Write-Output (Invoke-WebRequest https://raw.githubusercontent.com/grpc/grpc/master/LICENSE).Content
|
Write-Output (Invoke-WebRequest https://raw.githubusercontent.com/grpc/grpc/master/LICENSE).Content
|
||||||
Write-Output "::endgroup::"
|
Write-Output "::endgroup::"
|
||||||
|
@ -44,7 +44,7 @@ add_grpc_php_plugin() {
|
|||||||
sudo chmod a+x /usr/local/bin/grpc_php_plugin
|
sudo chmod a+x /usr/local/bin/grpc_php_plugin
|
||||||
) >/dev/null 2>&1
|
) >/dev/null 2>&1
|
||||||
echo "::set-output name=grpc_php_plugin_path::/usr/local/bin/grpc_php_plugin"
|
echo "::set-output name=grpc_php_plugin_path::/usr/local/bin/grpc_php_plugin"
|
||||||
add_log "${tick:?}" "grpc_php_plugin" "Added"
|
add_log "${tick:?}" "grpc_php_plugin" "Added grpc_php_plugin ${grpc_tag:1}"
|
||||||
printf "::group::\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" "grpc_php_plugin" "Click to read the grpc_php_plugin related license information"
|
printf "::group::\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" "grpc_php_plugin" "Click to read the grpc_php_plugin related license information"
|
||||||
cat "/tmp/grpc-${grpc_tag:1}/LICENSE"
|
cat "/tmp/grpc-${grpc_tag:1}/LICENSE"
|
||||||
echo "::endgroup::"
|
echo "::endgroup::"
|
||||||
|
@ -31,7 +31,7 @@ Function Add-Protoc() {
|
|||||||
Expand-Archive -Path $bin_dir\protoc.zip -DestinationPath $bin_dir\protoc -Force >$null 2>&1
|
Expand-Archive -Path $bin_dir\protoc.zip -DestinationPath $bin_dir\protoc -Force >$null 2>&1
|
||||||
Move-Item -Path $bin_dir\protoc\bin\protoc.exe -Destination $bin_dir\protoc.exe
|
Move-Item -Path $bin_dir\protoc\bin\protoc.exe -Destination $bin_dir\protoc.exe
|
||||||
Add-ToProfile $current_profile 'protoc' "New-Alias protoc $bin_dir\protoc.exe"
|
Add-ToProfile $current_profile 'protoc' "New-Alias protoc $bin_dir\protoc.exe"
|
||||||
Add-Log $tick "protoc" "Added"
|
Add-Log $tick "protoc" "Added protoc $($protobuf_tag -replace 'v', '')"
|
||||||
printf "::group::\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" "protoc" "Click to read the protoc related license information"
|
printf "::group::\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" "protoc" "Click to read the protoc related license information"
|
||||||
Write-Output (Invoke-WebRequest https://raw.githubusercontent.com/protocolbuffers/protobuf/master/LICENSE).Content
|
Write-Output (Invoke-WebRequest https://raw.githubusercontent.com/protocolbuffers/protobuf/master/LICENSE).Content
|
||||||
Write-Output "::endgroup::"
|
Write-Output "::endgroup::"
|
||||||
|
@ -21,7 +21,7 @@ add_protoc() {
|
|||||||
sudo unzip /tmp/protobuf.zip -d /usr/local/
|
sudo unzip /tmp/protobuf.zip -d /usr/local/
|
||||||
sudo chmod 777 /usr/local/bin/protoc -R /usr/local/include/google
|
sudo chmod 777 /usr/local/bin/protoc -R /usr/local/include/google
|
||||||
) >/dev/null 2>&1
|
) >/dev/null 2>&1
|
||||||
add_log "${tick:?}" "protoc" "Added"
|
add_log "${tick:?}" "protoc" "Added protoc ${protobuf_tag:1}"
|
||||||
printf "::group::\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" "protoc" "Click to read the protoc related license information"
|
printf "::group::\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" "protoc" "Click to read the protoc related license information"
|
||||||
curl "${curl_opts[@]:?}" https://raw.githubusercontent.com/protocolbuffers/protobuf/master/LICENSE
|
curl "${curl_opts[@]:?}" https://raw.githubusercontent.com/protocolbuffers/protobuf/master/LICENSE
|
||||||
echo "::endgroup::"
|
echo "::endgroup::"
|
||||||
|
@ -8,7 +8,7 @@ param (
|
|||||||
[ValidateNotNull()]
|
[ValidateNotNull()]
|
||||||
[ValidateLength(1, [int]::MaxValue)]
|
[ValidateLength(1, [int]::MaxValue)]
|
||||||
[string]
|
[string]
|
||||||
$dir
|
$dist
|
||||||
)
|
)
|
||||||
|
|
||||||
# Function to log start of a operation.
|
# Function to log start of a operation.
|
||||||
@ -189,12 +189,33 @@ Function Edit-ComposerConfig() {
|
|||||||
exit 1;
|
exit 1;
|
||||||
}
|
}
|
||||||
composer -q global config process-timeout 0
|
composer -q global config process-timeout 0
|
||||||
Write-Output "::add-path::$env:APPDATA\Composer\vendor\bin"
|
Write-Output "$env:APPDATA\Composer\vendor\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8
|
||||||
if (Test-Path env:COMPOSER_TOKEN) {
|
if (Test-Path env:COMPOSER_TOKEN) {
|
||||||
composer -q global config github-oauth.github.com $env:COMPOSER_TOKEN
|
composer -q global config github-oauth.github.com $env:COMPOSER_TOKEN
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Function to extract tool version.
|
||||||
|
Function Get-ToolVersion() {
|
||||||
|
Param (
|
||||||
|
[Parameter(Position = 0, Mandatory = $true)]
|
||||||
|
$tool,
|
||||||
|
[Parameter(Position = 1, Mandatory = $true)]
|
||||||
|
$param
|
||||||
|
)
|
||||||
|
$version_regex = "[0-9]+((\.{1}[0-9]+)+)(\.{0})(-[a-z0-9]+){0,1}"
|
||||||
|
if($tool -eq 'composer') {
|
||||||
|
if ($param -eq 'snapshot') {
|
||||||
|
$trunk = Select-String -Pattern "const\sBRANCH_ALIAS_VERSION" -Path $bin_dir\composer -Raw | Select-String -Pattern $version_regex | ForEach-Object { $_.matches.Value }
|
||||||
|
$commit = Select-String -Pattern "const\sVERSION" -Path $bin_dir\composer -Raw | Select-String -Pattern "[a-zA-Z0-9]+" -AllMatches | ForEach-Object { $_.matches[2].Value }
|
||||||
|
return "$trunk+$commit"
|
||||||
|
} else {
|
||||||
|
return Select-String -Pattern "const\sVERSION" -Path $bin_dir\composer -Raw | Select-String -Pattern $version_regex | ForEach-Object { $_.matches.Value }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return . $tool $param 2> $null | ForEach-Object { $_ -replace "composer $version_regex", '' } | Select-String -Pattern $version_regex | Select-Object -First 1 | ForEach-Object { $_.matches.Value }
|
||||||
|
}
|
||||||
|
|
||||||
# Function to add tools.
|
# Function to add tools.
|
||||||
Function Add-Tool() {
|
Function Add-Tool() {
|
||||||
Param (
|
Param (
|
||||||
@ -203,9 +224,10 @@ Function Add-Tool() {
|
|||||||
$url,
|
$url,
|
||||||
[Parameter(Position = 1, Mandatory = $true)]
|
[Parameter(Position = 1, Mandatory = $true)]
|
||||||
[ValidateNotNull()]
|
[ValidateNotNull()]
|
||||||
[ValidateLength(1, [int]::MaxValue)]
|
$tool,
|
||||||
[string]
|
[Parameter(Position = 2, Mandatory = $true)]
|
||||||
$tool
|
[ValidateNotNull()]
|
||||||
|
$ver_param
|
||||||
)
|
)
|
||||||
if (Test-Path $bin_dir\$tool) {
|
if (Test-Path $bin_dir\$tool) {
|
||||||
Remove-Item $bin_dir\$tool
|
Remove-Item $bin_dir\$tool
|
||||||
@ -239,7 +261,8 @@ Function Add-Tool() {
|
|||||||
Copy-Item $bin_dir\wp-cli.bat -Destination $bin_dir\wp.bat
|
Copy-Item $bin_dir\wp-cli.bat -Destination $bin_dir\wp.bat
|
||||||
}
|
}
|
||||||
if (((Get-ChildItem -Path $bin_dir/* | Where-Object Name -Match "^$tool(.exe|.phar)*$").Count -gt 0)) {
|
if (((Get-ChildItem -Path $bin_dir/* | Where-Object Name -Match "^$tool(.exe|.phar)*$").Count -gt 0)) {
|
||||||
Add-Log $tick $tool "Added"
|
$tool_version = Get-ToolVersion $tool $ver_param
|
||||||
|
Add-Log $tick $tool "Added $tool $tool_version"
|
||||||
} else {
|
} else {
|
||||||
Add-Log $cross $tool "Could not add $tool"
|
Add-Log $cross $tool "Could not add $tool"
|
||||||
}
|
}
|
||||||
@ -264,9 +287,11 @@ Function Add-Composertool() {
|
|||||||
[string]
|
[string]
|
||||||
$prefix
|
$prefix
|
||||||
)
|
)
|
||||||
composer -q global require $prefix$release 2>&1 | out-null
|
composer global require $prefix$release 2>&1 | out-null
|
||||||
if($?) {
|
$json = findstr $prefix$tool $env:APPDATA\Composer\composer.json
|
||||||
Add-Log $tick $tool "Added"
|
if($json) {
|
||||||
|
$tool_version = Get-ToolVersion "Write-Output" "$json"
|
||||||
|
Add-Log $tick $tool "Added $tool $tool_version"
|
||||||
} else {
|
} else {
|
||||||
Add-Log $cross $tool "Could not setup $tool"
|
Add-Log $cross $tool "Could not setup $tool"
|
||||||
}
|
}
|
||||||
@ -368,4 +393,5 @@ if($version -lt "5.5") {
|
|||||||
Enable-PhpExtension -Extension openssl, curl, opcache, mbstring -Path $php_dir
|
Enable-PhpExtension -Extension openssl, curl, opcache, mbstring -Path $php_dir
|
||||||
}
|
}
|
||||||
Update-PhpCAInfo -Path $php_dir -Source $cert_source
|
Update-PhpCAInfo -Path $php_dir -Source $cert_source
|
||||||
|
Move-Item -path $dist\..\src\configs\*.json -Destination $env:RUNNER_TOOL_CACHE
|
||||||
Add-Log $tick "PHP" "$status PHP $($installed.FullVersion)"
|
Add-Log $tick "PHP" "$status PHP $($installed.FullVersion)"
|
||||||
|
66
src/tools.ts
66
src/tools.ts
@ -167,7 +167,7 @@ export async function addPhive(
|
|||||||
case 'latest':
|
case 'latest':
|
||||||
return (
|
return (
|
||||||
(await utils.getCommand(os_version, 'tool')) +
|
(await utils.getCommand(os_version, 'tool')) +
|
||||||
'https://phar.io/releases/phive.phar phive'
|
'https://phar.io/releases/phive.phar phive status'
|
||||||
);
|
);
|
||||||
default:
|
default:
|
||||||
return (
|
return (
|
||||||
@ -176,7 +176,7 @@ export async function addPhive(
|
|||||||
version +
|
version +
|
||||||
'/phive-' +
|
'/phive-' +
|
||||||
version +
|
version +
|
||||||
'.phar phive'
|
'.phar phive status'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -334,7 +334,7 @@ export async function getCleanedToolsList(
|
|||||||
return extension
|
return extension
|
||||||
.trim()
|
.trim()
|
||||||
.replace(
|
.replace(
|
||||||
/-agent|hirak\/|laravel\/|narrowspark\/automatic-|overtrue\/|robmorgan\/|symfony\//,
|
/-agent|behat\/|hirak\/|icanhazstring\/|laravel\/|narrowspark\/automatic-|overtrue\/|phpspec\/|robmorgan\/|symfony\//,
|
||||||
''
|
''
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
@ -348,13 +348,18 @@ export async function getCleanedToolsList(
|
|||||||
* @param tool
|
* @param tool
|
||||||
* @param url
|
* @param url
|
||||||
* @param os_version
|
* @param os_version
|
||||||
|
* @param ver_param
|
||||||
*/
|
*/
|
||||||
export async function addArchive(
|
export async function addArchive(
|
||||||
tool: string,
|
tool: string,
|
||||||
url: string,
|
url: string,
|
||||||
os_version: string
|
os_version: string,
|
||||||
|
ver_param: string
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
return (await utils.getCommand(os_version, 'tool')) + url + ' ' + tool;
|
return (
|
||||||
|
(await utils.getCommand(os_version, 'tool')) +
|
||||||
|
(await utils.joins(url, tool, ver_param))
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -369,13 +374,8 @@ export async function addDevTools(
|
|||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
switch (os_version) {
|
switch (os_version) {
|
||||||
case 'linux':
|
case 'linux':
|
||||||
return (
|
|
||||||
'add_devtools' +
|
|
||||||
'\n' +
|
|
||||||
(await utils.addLog('$tick', tool, 'Added', 'linux'))
|
|
||||||
);
|
|
||||||
case 'darwin':
|
case 'darwin':
|
||||||
return await utils.addLog('$tick', tool, 'Added', 'darwin');
|
return 'add_devtools ' + tool;
|
||||||
case 'win32':
|
case 'win32':
|
||||||
return await utils.addLog(
|
return await utils.addLog(
|
||||||
'$cross',
|
'$cross',
|
||||||
@ -445,24 +445,28 @@ export async function addTools(
|
|||||||
case 'protoc':
|
case 'protoc':
|
||||||
script += await utils.customPackage(tool, 'tools', version, os_version);
|
script += await utils.customPackage(tool, 'tools', version, os_version);
|
||||||
break;
|
break;
|
||||||
|
case 'behat':
|
||||||
|
case 'phpspec':
|
||||||
|
script += await addPackage(tool, release, tool + '/', os_version);
|
||||||
|
break;
|
||||||
case 'blackfire-player':
|
case 'blackfire-player':
|
||||||
url = await getPharUrl('https://get.blackfire.io', tool, 'v', version);
|
url = await getPharUrl('https://get.blackfire.io', tool, 'v', version);
|
||||||
script += await addArchive(tool, url, os_version);
|
script += await addArchive(tool, url, os_version, '"-V"');
|
||||||
break;
|
break;
|
||||||
case 'codeception':
|
case 'codeception':
|
||||||
url =
|
url =
|
||||||
'https://codeception.com/' +
|
'https://codeception.com/' +
|
||||||
(await getCodeceptionUri(version, php_version));
|
(await getCodeceptionUri(version, php_version));
|
||||||
script += await addArchive(tool, url, os_version);
|
script += await addArchive(tool, url, os_version, '"-V"');
|
||||||
break;
|
break;
|
||||||
case 'composer':
|
case 'composer':
|
||||||
url = await getComposerUrl(version);
|
url = await getComposerUrl(version);
|
||||||
script += await addArchive('composer', url, os_version);
|
script += await addArchive('composer', url, os_version, version);
|
||||||
break;
|
break;
|
||||||
case 'composer-normalize':
|
case 'composer-normalize':
|
||||||
uri = await getUri(tool, '.phar', version, 'releases', '', 'download');
|
uri = await getUri(tool, '.phar', version, 'releases', '', 'download');
|
||||||
url = github + 'ergebnis/composer-normalize/' + uri;
|
url = github + 'ergebnis/composer-normalize/' + uri;
|
||||||
script += await addArchive(tool, url, os_version);
|
script += await addArchive(tool, url, os_version, '"-V"');
|
||||||
break;
|
break;
|
||||||
case 'composer-prefetcher':
|
case 'composer-prefetcher':
|
||||||
script += await addPackage(
|
script += await addPackage(
|
||||||
@ -475,39 +479,37 @@ export async function addTools(
|
|||||||
case 'composer-require-checker':
|
case 'composer-require-checker':
|
||||||
uri = await getUri(tool, '.phar', version, 'releases', '', 'download');
|
uri = await getUri(tool, '.phar', version, 'releases', '', 'download');
|
||||||
url = github + 'maglnet/ComposerRequireChecker/' + uri;
|
url = github + 'maglnet/ComposerRequireChecker/' + uri;
|
||||||
script += await addArchive(tool, url, os_version);
|
script += await addArchive(tool, url, os_version, '"-V"');
|
||||||
break;
|
break;
|
||||||
case 'composer-unused':
|
case 'composer-unused':
|
||||||
uri = await getUri(tool, '.phar', version, 'releases', '', 'download');
|
script += await addPackage(tool, release, 'icanhazstring/', os_version);
|
||||||
url = github + 'composer-unused/composer-unused/' + uri;
|
|
||||||
script += await addArchive(tool, url, os_version);
|
|
||||||
break;
|
break;
|
||||||
case 'cs2pr':
|
case 'cs2pr':
|
||||||
uri = await getUri(tool, '', version, 'releases', '', 'download');
|
uri = await getUri(tool, '', version, 'releases', '', 'download');
|
||||||
url = github + 'staabm/annotate-pull-request-from-checkstyle/' + uri;
|
url = github + 'staabm/annotate-pull-request-from-checkstyle/' + uri;
|
||||||
script += await addArchive(tool, url, os_version);
|
script += await addArchive(tool, url, os_version, '"-V"');
|
||||||
break;
|
break;
|
||||||
case 'deployer':
|
case 'deployer':
|
||||||
url = await getDeployerUrl(version);
|
url = await getDeployerUrl(version);
|
||||||
script += await addArchive(tool, url, os_version);
|
script += await addArchive(tool, url, os_version, '"-V"');
|
||||||
break;
|
break;
|
||||||
case 'flex':
|
case 'flex':
|
||||||
script += await addPackage(tool, release, 'symfony/', os_version);
|
script += await addPackage(tool, release, 'symfony/', os_version);
|
||||||
break;
|
break;
|
||||||
case 'infection':
|
case 'infection':
|
||||||
url = github + 'infection/infection/' + uri;
|
url = github + 'infection/infection/' + uri;
|
||||||
script += await addArchive(tool, url, os_version);
|
script += await addArchive(tool, url, os_version, '"-V"');
|
||||||
break;
|
break;
|
||||||
case 'pecl':
|
case 'pecl':
|
||||||
script += await utils.getCommand(os_version, 'pecl');
|
script += await utils.getCommand(os_version, 'pecl');
|
||||||
break;
|
break;
|
||||||
case 'phan':
|
case 'phan':
|
||||||
url = github + 'phan/phan/' + uri;
|
url = github + 'phan/phan/' + uri;
|
||||||
script += await addArchive(tool, url, os_version);
|
script += await addArchive(tool, url, os_version, '"-v"');
|
||||||
break;
|
break;
|
||||||
case 'phing':
|
case 'phing':
|
||||||
url = 'https://www.phing.info/get/phing-' + version + '.phar';
|
url = 'https://www.phing.info/get/phing-' + version + '.phar';
|
||||||
script += await addArchive(tool, url, os_version);
|
script += await addArchive(tool, url, os_version, '"-v"');
|
||||||
break;
|
break;
|
||||||
case 'phinx':
|
case 'phinx':
|
||||||
script += await addPackage(tool, release, 'robmorgan/', os_version);
|
script += await addPackage(tool, release, 'robmorgan/', os_version);
|
||||||
@ -522,48 +524,48 @@ export async function addTools(
|
|||||||
case 'php-cs-fixer':
|
case 'php-cs-fixer':
|
||||||
uri = await getUri(tool, '.phar', 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, url, os_version);
|
script += await addArchive(tool, url, os_version, '"-V"');
|
||||||
break;
|
break;
|
||||||
case 'phpcbf':
|
case 'phpcbf':
|
||||||
case 'phpcs':
|
case 'phpcs':
|
||||||
url = github + 'squizlabs/PHP_CodeSniffer/' + uri;
|
url = github + 'squizlabs/PHP_CodeSniffer/' + uri;
|
||||||
script += await addArchive(tool, url, os_version);
|
script += await addArchive(tool, url, os_version, '"--version"');
|
||||||
break;
|
break;
|
||||||
case 'phpcpd':
|
case 'phpcpd':
|
||||||
case 'phpunit':
|
case 'phpunit':
|
||||||
url = await getPharUrl('https://phar.phpunit.de', tool, '', version);
|
url = await getPharUrl('https://phar.phpunit.de', tool, '', version);
|
||||||
script += await addArchive(tool, url, os_version);
|
script += await addArchive(tool, url, os_version, '"--version"');
|
||||||
break;
|
break;
|
||||||
case 'phplint':
|
case 'phplint':
|
||||||
script += await addPackage(tool, release, 'overtrue/', os_version);
|
script += await addPackage(tool, release, 'overtrue/', os_version);
|
||||||
break;
|
break;
|
||||||
case 'phpmd':
|
case 'phpmd':
|
||||||
url = github + 'phpmd/phpmd/' + uri;
|
url = github + 'phpmd/phpmd/' + uri;
|
||||||
script += await addArchive(tool, url, os_version);
|
script += await addArchive(tool, url, os_version, '"--version"');
|
||||||
break;
|
break;
|
||||||
case 'phpstan':
|
case 'phpstan':
|
||||||
url = github + 'phpstan/phpstan/' + uri;
|
url = github + 'phpstan/phpstan/' + uri;
|
||||||
script += await addArchive(tool, url, os_version);
|
script += await addArchive(tool, url, os_version, '"-V"');
|
||||||
break;
|
break;
|
||||||
case 'prestissimo':
|
case 'prestissimo':
|
||||||
script += await addPackage(tool, release, 'hirak/', os_version);
|
script += await addPackage(tool, release, 'hirak/', os_version);
|
||||||
break;
|
break;
|
||||||
case 'psalm':
|
case 'psalm':
|
||||||
url = github + 'vimeo/psalm/' + uri;
|
url = github + 'vimeo/psalm/' + uri;
|
||||||
script += await addArchive(tool, url, os_version);
|
script += await addArchive(tool, url, os_version, '"-v"');
|
||||||
break;
|
break;
|
||||||
case 'symfony':
|
case 'symfony':
|
||||||
case 'symfony-cli':
|
case 'symfony-cli':
|
||||||
uri = await getSymfonyUri(version, os_version);
|
uri = await getSymfonyUri(version, os_version);
|
||||||
url = github + 'symfony/cli/' + uri;
|
url = github + 'symfony/cli/' + uri;
|
||||||
script += await addArchive('symfony', url, os_version);
|
script += await addArchive('symfony', url, os_version, 'version');
|
||||||
break;
|
break;
|
||||||
case 'vapor-cli':
|
case 'vapor-cli':
|
||||||
script += await addPackage(tool, release, 'laravel/', os_version);
|
script += await addPackage(tool, release, 'laravel/', os_version);
|
||||||
break;
|
break;
|
||||||
case 'wp-cli':
|
case 'wp-cli':
|
||||||
url = github + (await getWpCliUrl(version));
|
url = github + (await getWpCliUrl(version));
|
||||||
script += await addArchive(tool, url, os_version);
|
script += await addArchive(tool, url, os_version, '"--version"');
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
script += await utils.addLog(
|
script += await utils.addLog(
|
||||||
|
71
src/utils.ts
71
src/utils.ts
@ -2,6 +2,21 @@ import * as fs from 'fs';
|
|||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function to read environment variable and return a string value.
|
||||||
|
*
|
||||||
|
* @param property
|
||||||
|
*/
|
||||||
|
export async function readEnv(property: string): Promise<string> {
|
||||||
|
const value = process.env[property];
|
||||||
|
switch (value) {
|
||||||
|
case undefined:
|
||||||
|
return '';
|
||||||
|
default:
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function to get inputs from both with and env annotations.
|
* Function to get inputs from both with and env annotations.
|
||||||
*
|
*
|
||||||
@ -12,13 +27,36 @@ export async function getInput(
|
|||||||
name: string,
|
name: string,
|
||||||
mandatory: boolean
|
mandatory: boolean
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
const input = process.env[name];
|
const input = core.getInput(name);
|
||||||
switch (input) {
|
const env_input = await readEnv(name);
|
||||||
case '':
|
switch (true) {
|
||||||
case undefined:
|
case input != '':
|
||||||
return core.getInput(name, {required: mandatory});
|
|
||||||
default:
|
|
||||||
return input;
|
return input;
|
||||||
|
case input == '' && env_input != '':
|
||||||
|
return env_input;
|
||||||
|
case input == '' && env_input == '' && mandatory:
|
||||||
|
throw new Error(`Input required and not supplied: ${name}`);
|
||||||
|
default:
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function to parse PHP version.
|
||||||
|
*
|
||||||
|
* @param version
|
||||||
|
*/
|
||||||
|
export async function parseVersion(version: string): Promise<string> {
|
||||||
|
switch (version) {
|
||||||
|
case 'latest':
|
||||||
|
return '7.4';
|
||||||
|
default:
|
||||||
|
switch (true) {
|
||||||
|
case version.length > 1:
|
||||||
|
return version.slice(0, 3);
|
||||||
|
default:
|
||||||
|
return version + '.0';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -339,6 +377,27 @@ export async function scriptExtension(os_version: string): Promise<string> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function to get script tool
|
||||||
|
*
|
||||||
|
* @param os_version
|
||||||
|
*/
|
||||||
|
export async function scriptTool(os_version: string): Promise<string> {
|
||||||
|
switch (os_version) {
|
||||||
|
case 'win32':
|
||||||
|
return 'pwsh';
|
||||||
|
case 'linux':
|
||||||
|
case 'darwin':
|
||||||
|
return 'bash';
|
||||||
|
default:
|
||||||
|
return await log(
|
||||||
|
'Platform ' + os_version + ' is not supported',
|
||||||
|
os_version,
|
||||||
|
'error'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function to get script to add tools with custom support.
|
* Function to get script to add tools with custom support.
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user