mirror of
https://github.com/shivammathur/setup-php.git
synced 2025-07-02 13:13:15 +07:00
Compare commits
11 Commits
Author | SHA1 | Date | |
---|---|---|---|
efbde18f4f | |||
a571b83a9a | |||
93544179be | |||
b33e1bd5fb | |||
9b259cca75 | |||
7734ee36e7 | |||
077d3caefc | |||
446bccb14d | |||
29d99c6866 | |||
1444e002ab | |||
03b97e24e9 |
5
.github/FUNDING.yml
vendored
5
.github/FUNDING.yml
vendored
@ -1,6 +1,7 @@
|
|||||||
# These are supported funding model platforms
|
# These are supported funding model platforms
|
||||||
|
|
||||||
github: shivammathur
|
open_collective: setup-php
|
||||||
|
tidelift: "npm/setup-php"
|
||||||
community_bridge: setup-php
|
community_bridge: setup-php
|
||||||
patreon: shivammathur
|
patreon: shivammathur
|
||||||
custom: https://www.paypal.me/shivammathur
|
custom: https://www.paypal.me/shivammathur
|
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.4.x | :white_check_mark: |
|
| 2.6.x | :white_check_mark: |
|
||||||
|
|
||||||
## Supported PHP Versions
|
## Supported PHP Versions
|
||||||
|
|
||||||
|
67
README.md
67
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"></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"></a>
|
||||||
<a href="#tada-php-support" title="PHP Versions Supported"><img alt="PHP Versions Supported" src="https://img.shields.io/badge/php-%3E%3D%205.6-8892BF.svg"></a>
|
<a href="#tada-php-support" title="PHP Versions Supported"><img alt="PHP Versions Supported" src="https://img.shields.io/badge/php-%3E%3D%205.6-8892BF.svg"></a>
|
||||||
</p>
|
</p>
|
||||||
@ -300,31 +300,72 @@ If you have a number of workflows which setup multiple tools or have many compos
|
|||||||
|
|
||||||
### Problem Matchers
|
### Problem Matchers
|
||||||
|
|
||||||
#### PHPUnit
|
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.
|
||||||
|
|
||||||
You can setup problem matchers for your `PHPUnit` output by adding this step after the `setup-php` step. This will scan the logs for failing tests and surface that information prominently in the GitHub Actions UI by creating annotations and log file decorations.
|
#### PHP
|
||||||
|
|
||||||
|
Setup problem matchers for your `PHP` output by adding this step after the `setup-php` step.
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- name: Setup Problem Matchers for PHPUnit
|
- name: Setup problem matchers for PHP
|
||||||
|
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
|
||||||
|
```
|
||||||
|
|
||||||
|
#### PHPUnit
|
||||||
|
|
||||||
|
Setup problem matchers for your `PHPUnit` output by adding this step after the `setup-php` step.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
- 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@v1
|
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
|
||||||
|
@ -12,9 +12,9 @@ describe('Config tests', () => {
|
|||||||
|
|
||||||
win32 = await config.addINIValues(
|
win32 = await config.addINIValues(
|
||||||
'post_max_size=256M, short_open_tag=On, date.timezone=Asia/Kolkata',
|
'post_max_size=256M, short_open_tag=On, date.timezone=Asia/Kolkata',
|
||||||
'fedora'
|
'openbsd'
|
||||||
);
|
);
|
||||||
expect(win32).toContain('Platform fedora is not supported');
|
expect(win32).toContain('Platform openbsd is not supported');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('checking addINIValuesOnLinux', async () => {
|
it('checking addINIValuesOnLinux', async () => {
|
||||||
@ -29,9 +29,9 @@ describe('Config tests', () => {
|
|||||||
|
|
||||||
linux = await config.addINIValues(
|
linux = await config.addINIValues(
|
||||||
'post_max_size=256M, short_open_tag=On, date.timezone=Asia/Kolkata',
|
'post_max_size=256M, short_open_tag=On, date.timezone=Asia/Kolkata',
|
||||||
'fedora'
|
'openbsd'
|
||||||
);
|
);
|
||||||
expect(linux).toContain('Platform fedora is not supported');
|
expect(linux).toContain('Platform openbsd is not supported');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('checking addINIValuesOnDarwin', async () => {
|
it('checking addINIValuesOnDarwin', async () => {
|
||||||
@ -45,8 +45,8 @@ describe('Config tests', () => {
|
|||||||
|
|
||||||
darwin = await config.addINIValues(
|
darwin = await config.addINIValues(
|
||||||
'post_max_size=256M, short_open_tag=On, date.timezone=Asia/Kolkata',
|
'post_max_size=256M, short_open_tag=On, date.timezone=Asia/Kolkata',
|
||||||
'fedora'
|
'openbsd'
|
||||||
);
|
);
|
||||||
expect(darwin).toContain('Platform fedora is not supported');
|
expect(darwin).toContain('Platform openbsd is not supported');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -35,8 +35,8 @@ describe('Extension tests', () => {
|
|||||||
expect(win32).toContain('phalcon.ps1 phalcon3');
|
expect(win32).toContain('phalcon.ps1 phalcon3');
|
||||||
expect(win32).toContain('Add-Extension does_not_exist');
|
expect(win32).toContain('Add-Extension does_not_exist');
|
||||||
|
|
||||||
win32 = await extensions.addExtension('xdebug', '7.2', 'fedora');
|
win32 = await extensions.addExtension('xdebug', '7.2', 'openbsd');
|
||||||
expect(win32).toContain('Platform fedora is not supported');
|
expect(win32).toContain('Platform openbsd is not supported');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('checking addExtensionOnLinux', async () => {
|
it('checking addExtensionOnLinux', async () => {
|
||||||
@ -68,8 +68,8 @@ describe('Extension tests', () => {
|
|||||||
linux = await extensions.addExtension('gearman', '7.4', 'linux');
|
linux = await extensions.addExtension('gearman', '7.4', 'linux');
|
||||||
expect(linux).toContain('gearman.sh 7.4');
|
expect(linux).toContain('gearman.sh 7.4');
|
||||||
|
|
||||||
linux = await extensions.addExtension('xdebug', '7.2', 'fedora');
|
linux = await extensions.addExtension('xdebug', '7.2', 'openbsd');
|
||||||
expect(linux).toContain('Platform fedora is not supported');
|
expect(linux).toContain('Platform openbsd is not supported');
|
||||||
|
|
||||||
linux = await extensions.addExtension('phalcon3, phalcon4', '7.3', 'linux');
|
linux = await extensions.addExtension('phalcon3, phalcon4', '7.3', 'linux');
|
||||||
expect(linux).toContain('phalcon.sh phalcon3 7.3');
|
expect(linux).toContain('phalcon.sh phalcon3 7.3');
|
||||||
@ -133,7 +133,7 @@ describe('Extension tests', () => {
|
|||||||
);
|
);
|
||||||
expect(darwin).toContain('add_extension does_not_exist');
|
expect(darwin).toContain('add_extension does_not_exist');
|
||||||
|
|
||||||
darwin = await extensions.addExtension('xdebug', '7.2', 'fedora');
|
darwin = await extensions.addExtension('xdebug', '7.2', 'openbsd');
|
||||||
expect(darwin).toContain('Platform fedora is not supported');
|
expect(darwin).toContain('Platform openbsd is not supported');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -1,24 +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(1);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('Test 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);
|
|
||||||
});
|
|
||||||
});
|
|
@ -5,8 +5,8 @@ describe('Tools tests', () => {
|
|||||||
expect(await tools.getCommand('linux', 'tool')).toBe('add_tool ');
|
expect(await tools.getCommand('linux', 'tool')).toBe('add_tool ');
|
||||||
expect(await tools.getCommand('darwin', 'tool')).toBe('add_tool ');
|
expect(await tools.getCommand('darwin', 'tool')).toBe('add_tool ');
|
||||||
expect(await tools.getCommand('win32', 'tool')).toBe('Add-Tool ');
|
expect(await tools.getCommand('win32', 'tool')).toBe('Add-Tool ');
|
||||||
expect(await tools.getCommand('fedora', 'tool')).toContain(
|
expect(await tools.getCommand('openbsd', 'tool')).toContain(
|
||||||
'Platform fedora is not supported'
|
'Platform openbsd is not supported'
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -20,8 +20,8 @@ describe('Tools tests', () => {
|
|||||||
expect(await tools.getCommand('win32', 'composertool')).toBe(
|
expect(await tools.getCommand('win32', 'composertool')).toBe(
|
||||||
'Add-Composertool '
|
'Add-Composertool '
|
||||||
);
|
);
|
||||||
expect(await tools.getCommand('fedora', 'composertool')).toContain(
|
expect(await tools.getCommand('openbsd', 'composertool')).toContain(
|
||||||
'Platform fedora is not supported'
|
'Platform openbsd is not supported'
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -29,8 +29,8 @@ describe('Tools tests', () => {
|
|||||||
expect(await tools.getCommand('linux', 'pecl')).toBe('add_pecl ');
|
expect(await tools.getCommand('linux', 'pecl')).toBe('add_pecl ');
|
||||||
expect(await tools.getCommand('darwin', 'pecl')).toBe('add_pecl ');
|
expect(await tools.getCommand('darwin', 'pecl')).toBe('add_pecl ');
|
||||||
expect(await tools.getCommand('win32', 'pecl')).toBe('Add-Pecl ');
|
expect(await tools.getCommand('win32', 'pecl')).toBe('Add-Pecl ');
|
||||||
expect(await tools.getCommand('fedora', 'pecl')).toContain(
|
expect(await tools.getCommand('openbsd', 'pecl')).toContain(
|
||||||
'Platform fedora is not supported'
|
'Platform openbsd is not supported'
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -303,8 +303,8 @@ describe('Tools tests', () => {
|
|||||||
expect(await tools.getSymfonyUri('1.2.3', 'win32')).toContain(
|
expect(await tools.getSymfonyUri('1.2.3', 'win32')).toContain(
|
||||||
'releases/download/v1.2.3/symfony_windows_amd64'
|
'releases/download/v1.2.3/symfony_windows_amd64'
|
||||||
);
|
);
|
||||||
expect(await tools.getSymfonyUri('1.2.3', 'fedora')).toContain(
|
expect(await tools.getSymfonyUri('1.2.3', 'openbsd')).toContain(
|
||||||
'Platform fedora is not supported'
|
'Platform openbsd is not supported'
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -324,21 +324,18 @@ describe('Tools tests', () => {
|
|||||||
it('checking addArchive', async () => {
|
it('checking addArchive', async () => {
|
||||||
let script: string = await tools.addArchive(
|
let script: string = await tools.addArchive(
|
||||||
'tool',
|
'tool',
|
||||||
'1.2.3',
|
|
||||||
'https://tool.com/tool.phar',
|
'https://tool.com/tool.phar',
|
||||||
'linux'
|
'linux'
|
||||||
);
|
);
|
||||||
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',
|
||||||
'1.2.3',
|
|
||||||
'https://tool.com/tool.phar',
|
'https://tool.com/tool.phar',
|
||||||
'darwin'
|
'darwin'
|
||||||
);
|
);
|
||||||
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',
|
||||||
'1.2.3',
|
|
||||||
'https://tool.com/tool.phar',
|
'https://tool.com/tool.phar',
|
||||||
'win32'
|
'win32'
|
||||||
);
|
);
|
||||||
@ -346,11 +343,10 @@ describe('Tools tests', () => {
|
|||||||
|
|
||||||
script = await tools.addArchive(
|
script = await tools.addArchive(
|
||||||
'tool',
|
'tool',
|
||||||
'1.2.3',
|
|
||||||
'https://tool.com/tool.phar',
|
'https://tool.com/tool.phar',
|
||||||
'fedora'
|
'openbsd'
|
||||||
);
|
);
|
||||||
expect(script).toContain('Platform fedora is not supported');
|
expect(script).toContain('Platform openbsd is not supported');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('checking addDevTools', async () => {
|
it('checking addDevTools', async () => {
|
||||||
@ -378,8 +374,8 @@ describe('Tools tests', () => {
|
|||||||
'Add-Log "$cross" "php-config" "php-config is not a windows tool"'
|
'Add-Log "$cross" "php-config" "php-config is not a windows tool"'
|
||||||
);
|
);
|
||||||
|
|
||||||
script = await tools.addDevTools('tool', 'fedora');
|
script = await tools.addDevTools('tool', 'openbsd');
|
||||||
expect(script).toContain('Platform fedora is not supported');
|
expect(script).toContain('Platform openbsd is not supported');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('checking addPackage', async () => {
|
it('checking addPackage', async () => {
|
||||||
@ -397,8 +393,8 @@ describe('Tools tests', () => {
|
|||||||
script = await tools.addPackage('tool', 'tool:1.2.3', 'user/', 'win32');
|
script = await tools.addPackage('tool', 'tool:1.2.3', 'user/', 'win32');
|
||||||
expect(script).toContain('Add-Composertool tool tool:1.2.3 user/');
|
expect(script).toContain('Add-Composertool tool tool:1.2.3 user/');
|
||||||
|
|
||||||
script = await tools.addPackage('tool', 'tool:1.2.3', 'user/', 'fedora');
|
script = await tools.addPackage('tool', 'tool:1.2.3', 'user/', 'openbsd');
|
||||||
expect(script).toContain('Platform fedora is not supported');
|
expect(script).toContain('Platform openbsd is not supported');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('checking addTools on linux', async () => {
|
it('checking addTools on linux', async () => {
|
||||||
|
@ -17,13 +17,19 @@ async function cleanup(path: string): Promise<void> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
describe('Utils tests', () => {
|
describe('Utils tests', () => {
|
||||||
it('checking getInput', async () => {
|
it('checking readEnv', async () => {
|
||||||
process.env['test'] = 'setup-php';
|
process.env['test'] = 'setup-php';
|
||||||
process.env['undefined'] = '';
|
expect(await utils.readEnv('test')).toBe('setup-php');
|
||||||
|
expect(await utils.readEnv('undefined')).toBe('');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('checking getInput', async () => {
|
||||||
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 asyncForEach', async () => {
|
it('checking asyncForEach', async () => {
|
||||||
@ -131,8 +137,8 @@ describe('Utils tests', () => {
|
|||||||
expect(step_log).toEqual('step_log "Test message"');
|
expect(step_log).toEqual('step_log "Test message"');
|
||||||
step_log = await utils.stepLog(message, 'darwin');
|
step_log = await utils.stepLog(message, 'darwin');
|
||||||
expect(step_log).toEqual('step_log "Test message"');
|
expect(step_log).toEqual('step_log "Test message"');
|
||||||
step_log = await utils.stepLog(message, 'fedora');
|
step_log = await utils.stepLog(message, 'openbsd');
|
||||||
expect(step_log).toContain('Platform fedora is not supported');
|
expect(step_log).toContain('Platform openbsd is not supported');
|
||||||
|
|
||||||
let add_log: string = await utils.addLog(
|
let add_log: string = await utils.addLog(
|
||||||
'tick',
|
'tick',
|
||||||
@ -145,8 +151,8 @@ describe('Utils tests', () => {
|
|||||||
expect(add_log).toEqual('add_log "tick" "xdebug" "enabled"');
|
expect(add_log).toEqual('add_log "tick" "xdebug" "enabled"');
|
||||||
add_log = await utils.addLog('tick', 'xdebug', 'enabled', 'darwin');
|
add_log = await utils.addLog('tick', 'xdebug', 'enabled', 'darwin');
|
||||||
expect(add_log).toEqual('add_log "tick" "xdebug" "enabled"');
|
expect(add_log).toEqual('add_log "tick" "xdebug" "enabled"');
|
||||||
add_log = await utils.addLog('tick', 'xdebug', 'enabled', 'fedora');
|
add_log = await utils.addLog('tick', 'xdebug', 'enabled', 'openbsd');
|
||||||
expect(add_log).toContain('Platform fedora is not supported');
|
expect(add_log).toContain('Platform openbsd is not supported');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('checking getExtensionPrefix', async () => {
|
it('checking getExtensionPrefix', async () => {
|
||||||
@ -162,8 +168,8 @@ describe('Utils tests', () => {
|
|||||||
expect(await utils.suppressOutput('win32')).toEqual(' >$null 2>&1');
|
expect(await utils.suppressOutput('win32')).toEqual(' >$null 2>&1');
|
||||||
expect(await utils.suppressOutput('linux')).toEqual(' >/dev/null 2>&1');
|
expect(await utils.suppressOutput('linux')).toEqual(' >/dev/null 2>&1');
|
||||||
expect(await utils.suppressOutput('darwin')).toEqual(' >/dev/null 2>&1');
|
expect(await utils.suppressOutput('darwin')).toEqual(' >/dev/null 2>&1');
|
||||||
expect(await utils.suppressOutput('fedora')).toContain(
|
expect(await utils.suppressOutput('openbsd')).toContain(
|
||||||
'Platform fedora is not supported'
|
'Platform openbsd is not supported'
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
199
dist/index.js
vendored
199
dist/index.js
vendored
@ -953,45 +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.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', 'phpunit.json');
|
if (input === null || input === undefined) {
|
||||||
const runner_dir = await utils.getInput('RUNNER_TOOL_CACHE', false);
|
return '';
|
||||||
await io.cp(config_path, runner_dir);
|
}
|
||||||
|
else if (typeof input === 'string' || input instanceof String) {
|
||||||
|
return input;
|
||||||
|
}
|
||||||
|
return JSON.stringify(input);
|
||||||
}
|
}
|
||||||
exports.addMatchers = addMatchers;
|
exports.toCommandValue = toCommandValue;
|
||||||
|
//# sourceMappingURL=utils.js.map
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
||||||
@ -1002,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) {
|
||||||
|
|
||||||
@ -1029,15 +1049,30 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||||
__setModuleDefault(result, mod);
|
__setModuleDefault(result, mod);
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
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.suppressOutput = exports.getExtensionPrefix = exports.CSVArray = exports.extensionArray = exports.writeScript = exports.readScript = exports.addLog = exports.stepLog = exports.log = exports.color = exports.asyncForEach = 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.
|
||||||
*
|
*
|
||||||
@ -1045,13 +1080,17 @@ 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;
|
||||||
@ -1270,6 +1309,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
|
||||||
*
|
*
|
||||||
@ -1323,28 +1363,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')
|
||||||
@ -1378,6 +1404,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));
|
||||||
/**
|
/**
|
||||||
@ -1404,9 +1432,17 @@ 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;
|
||||||
command_1.issueCommand('set-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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
exports.exportVariable = exportVariable;
|
exports.exportVariable = exportVariable;
|
||||||
/**
|
/**
|
||||||
@ -1422,7 +1458,13 @@ exports.setSecret = setSecret;
|
|||||||
* @param inputPath
|
* @param inputPath
|
||||||
*/
|
*/
|
||||||
function addPath(inputPath) {
|
function addPath(inputPath) {
|
||||||
command_1.issueCommand('add-path', {}, inputPath);
|
const filePath = process.env['GITHUB_PATH'] || '';
|
||||||
|
if (filePath) {
|
||||||
|
file_command_1.issueCommand('PATH', inputPath);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
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;
|
||||||
@ -1604,7 +1646,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||||
__setModuleDefault(result, mod);
|
__setModuleDefault(result, mod);
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
@ -1910,11 +1952,10 @@ exports.getCleanedToolsList = getCleanedToolsList;
|
|||||||
* Helper function to get script to setup a tool using a phar url
|
* Helper function to get script to setup a tool using a phar url
|
||||||
*
|
*
|
||||||
* @param tool
|
* @param tool
|
||||||
* @param version
|
|
||||||
* @param url
|
* @param url
|
||||||
* @param os_version
|
* @param os_version
|
||||||
*/
|
*/
|
||||||
async function addArchive(tool, version, url, os_version) {
|
async function addArchive(tool, url, os_version) {
|
||||||
return (await getCommand(os_version, 'tool')) + url + ' ' + tool;
|
return (await getCommand(os_version, 'tool')) + url + ' ' + tool;
|
||||||
}
|
}
|
||||||
exports.addArchive = addArchive;
|
exports.addArchive = addArchive;
|
||||||
@ -1974,51 +2015,51 @@ async function addTools(tools_csv, php_version, os_version) {
|
|||||||
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, version, url, os_version);
|
script += await addArchive(tool, url, os_version);
|
||||||
break;
|
break;
|
||||||
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, version, url, os_version);
|
script += await addArchive(tool, url, os_version);
|
||||||
break;
|
break;
|
||||||
case 'phpcs':
|
case 'phpcs':
|
||||||
case 'phpcbf':
|
case 'phpcbf':
|
||||||
url = github + 'squizlabs/PHP_CodeSniffer/' + uri;
|
url = github + 'squizlabs/PHP_CodeSniffer/' + uri;
|
||||||
script += await addArchive(tool, version, url, os_version);
|
script += await addArchive(tool, url, os_version);
|
||||||
break;
|
break;
|
||||||
case 'phive':
|
case 'phive':
|
||||||
script += await addPhive(version, os_version);
|
script += await addPhive(version, os_version);
|
||||||
break;
|
break;
|
||||||
case 'phpstan':
|
case 'phpstan':
|
||||||
url = github + 'phpstan/phpstan/' + uri;
|
url = github + 'phpstan/phpstan/' + uri;
|
||||||
script += await addArchive(tool, version, url, os_version);
|
script += await addArchive(tool, url, os_version);
|
||||||
break;
|
break;
|
||||||
case 'phpmd':
|
case 'phpmd':
|
||||||
url = github + 'phpmd/phpmd/' + uri;
|
url = github + 'phpmd/phpmd/' + uri;
|
||||||
script += await addArchive(tool, version, url, os_version);
|
script += await addArchive(tool, url, os_version);
|
||||||
break;
|
break;
|
||||||
case 'psalm':
|
case 'psalm':
|
||||||
url = github + 'vimeo/psalm/' + uri;
|
url = github + 'vimeo/psalm/' + uri;
|
||||||
script += await addArchive(tool, version, url, os_version);
|
script += await addArchive(tool, url, os_version);
|
||||||
break;
|
break;
|
||||||
case 'composer':
|
case 'composer':
|
||||||
url = await getComposerUrl(version);
|
url = await getComposerUrl(version);
|
||||||
script += await addArchive('composer', version, url, os_version);
|
script += await addArchive('composer', url, os_version);
|
||||||
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, version, url, os_version);
|
script += await addArchive(tool, url, os_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, version, url, os_version);
|
script += await addArchive(tool, url, os_version);
|
||||||
break;
|
break;
|
||||||
case 'deployer':
|
case 'deployer':
|
||||||
url = await getDeployerUrl(version);
|
url = await getDeployerUrl(version);
|
||||||
script += await addArchive(tool, version, url, os_version);
|
script += await addArchive(tool, url, os_version);
|
||||||
break;
|
break;
|
||||||
case 'phinx':
|
case 'phinx':
|
||||||
script += await addPackage(tool, release, 'robmorgan/', os_version);
|
script += await addPackage(tool, release, 'robmorgan/', os_version);
|
||||||
@ -2040,7 +2081,7 @@ async function addTools(tools_csv, php_version, os_version) {
|
|||||||
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', version, url, os_version);
|
script += await addArchive('symfony', url, os_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);
|
||||||
@ -2088,7 +2129,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||||
__setModuleDefault(result, mod);
|
__setModuleDefault(result, mod);
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
@ -2227,7 +2268,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||||
__setModuleDefault(result, mod);
|
__setModuleDefault(result, mod);
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
@ -2323,7 +2364,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||||
__setModuleDefault(result, mod);
|
__setModuleDefault(result, mod);
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
@ -2336,7 +2377,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
|
||||||
*
|
*
|
||||||
@ -2347,7 +2387,7 @@ const matchers = __importStar(__webpack_require__(86));
|
|||||||
async function build(filename, version, os_version) {
|
async function build(filename, version, os_version) {
|
||||||
// taking inputs
|
// taking inputs
|
||||||
const name = 'setup-php';
|
const name = 'setup-php';
|
||||||
const url = 'setup-php.com/support';
|
const url = 'https://setup-php.com/support';
|
||||||
const extension_csv = (await utils.getInput('extensions', false)) ||
|
const extension_csv = (await utils.getInput('extensions', false)) ||
|
||||||
(await utils.getInput('extension', false)) ||
|
(await utils.getInput('extension', false)) ||
|
||||||
(await utils.getInput('extension-csv', false));
|
(await utils.getInput('extension-csv', false));
|
||||||
@ -2397,7 +2437,6 @@ async function run() {
|
|||||||
await exec_1.exec('pwsh ' + script_path + ' ' + version + ' ' + __dirname);
|
await exec_1.exec('pwsh ' + script_path + ' ' + version + ' ' + __dirname);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
await matchers.addMatchers();
|
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
core.setFailed(error.message);
|
core.setFailed(error.message);
|
||||||
@ -2646,7 +2685,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||||
__setModuleDefault(result, mod);
|
__setModuleDefault(result, mod);
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
981
package-lock.json
generated
981
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
32
package.json
32
package.json
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "setup-php",
|
"name": "setup-php",
|
||||||
"version": "1.9.5",
|
"version": "1.9.7",
|
||||||
"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.4",
|
"@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.10",
|
"@types/jest": "^26.0.14",
|
||||||
"@types/node": "^14.0.27",
|
"@types/node": "^14.11.2",
|
||||||
"@typescript-eslint/eslint-plugin": "^3.9.0",
|
"@typescript-eslint/eslint-plugin": "^4.3.0",
|
||||||
"@typescript-eslint/parser": "^3.9.0",
|
"@typescript-eslint/parser": "^4.3.0",
|
||||||
"@zeit/ncc": "^0.22.3",
|
"@zeit/ncc": "^0.22.3",
|
||||||
"eslint": "^7.7.0",
|
"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": "^23.20.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.0",
|
"jest": "^26.4.2",
|
||||||
"jest-circus": "^26.4.0",
|
"jest-circus": "^26.4.2",
|
||||||
"prettier": "^2.0.5",
|
"prettier": "^2.1.2",
|
||||||
"ts-jest": "^26.2.0",
|
"ts-jest": "^26.4.1",
|
||||||
"typescript": "^3.9.7"
|
"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
|
||||||
@ -21,7 +20,7 @@ export async function build(
|
|||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
// taking inputs
|
// taking inputs
|
||||||
const name = 'setup-php';
|
const name = 'setup-php';
|
||||||
const url = 'setup-php.com/support';
|
const url = 'https://setup-php.com/support';
|
||||||
const extension_csv: string =
|
const extension_csv: string =
|
||||||
(await utils.getInput('extensions', false)) ||
|
(await utils.getInput('extensions', false)) ||
|
||||||
(await utils.getInput('extension', false)) ||
|
(await utils.getInput('extension', false)) ||
|
||||||
@ -79,7 +78,6 @@ export async function run(): Promise<void> {
|
|||||||
await exec('pwsh ' + script_path + ' ' + version + ' ' + __dirname);
|
await exec('pwsh ' + script_path + ' ' + version + ' ' + __dirname);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
await matchers.addMatchers();
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
core.setFailed(error.message);
|
core.setFailed(error.message);
|
||||||
}
|
}
|
||||||
|
@ -1,18 +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',
|
|
||||||
'phpunit.json'
|
|
||||||
);
|
|
||||||
const runner_dir: string = await utils.getInput('RUNNER_TOOL_CACHE', false);
|
|
||||||
await io.cp(config_path, runner_dir);
|
|
||||||
}
|
|
@ -124,7 +124,7 @@ 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
|
||||||
@ -204,6 +204,7 @@ setup_php() {
|
|||||||
tick="✓"
|
tick="✓"
|
||||||
cross="✗"
|
cross="✗"
|
||||||
version=$1
|
version=$1
|
||||||
|
dist=$2
|
||||||
tool_path_dir="/usr/local/bin"
|
tool_path_dir="/usr/local/bin"
|
||||||
curl_opts=(-sL)
|
curl_opts=(-sL)
|
||||||
existing_version=$(php-config --version 2>/dev/null | cut -c 1-3)
|
existing_version=$(php-config --version 2>/dev/null | cut -c 1-3)
|
||||||
@ -224,4 +225,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 ' ')
|
||||||
configure_pecl
|
configure_pecl
|
||||||
|
sudo mv "$dist"/../src/configs/*.json "$RUNNER_TOOL_CACHE/"
|
||||||
add_log "$tick" "PHP" "$status PHP $semver"
|
add_log "$tick" "PHP" "$status PHP $semver"
|
||||||
|
@ -155,7 +155,7 @@ 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
|
||||||
@ -254,6 +254,7 @@ cross="✗"
|
|||||||
lists_updated="false"
|
lists_updated="false"
|
||||||
pecl_config="false"
|
pecl_config="false"
|
||||||
version=$1
|
version=$1
|
||||||
|
dist=$2
|
||||||
debconf_fix="DEBIAN_FRONTEND=noninteractive"
|
debconf_fix="DEBIAN_FRONTEND=noninteractive"
|
||||||
apt_install="sudo $debconf_fix apt-fast install -y"
|
apt_install="sudo $debconf_fix apt-fast install -y"
|
||||||
tool_path_dir="/usr/local/bin"
|
tool_path_dir="/usr/local/bin"
|
||||||
@ -298,4 +299,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"
|
||||||
|
@ -8,7 +8,7 @@ param (
|
|||||||
[ValidateNotNull()]
|
[ValidateNotNull()]
|
||||||
[ValidateLength(1, [int]::MaxValue)]
|
[ValidateLength(1, [int]::MaxValue)]
|
||||||
[string]
|
[string]
|
||||||
$dir
|
$dist
|
||||||
)
|
)
|
||||||
|
|
||||||
Function Step-Log($message) {
|
Function Step-Log($message) {
|
||||||
@ -43,15 +43,29 @@ Function Add-ToProfile {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Function Add-Printf {
|
||||||
|
if (-not(Test-Path "C:\Program Files\Git\usr\bin\printf.exe")) {
|
||||||
|
if(Test-Path "C:\msys64\usr\bin\printf.exe") {
|
||||||
|
New-Item -Path $php_dir\printf.exe -ItemType SymbolicLink -Value C:\msys64\usr\bin\printf.exe
|
||||||
|
} else {
|
||||||
|
Invoke-WebRequest -UseBasicParsing -Uri "https://github.com/shivammathur/printf/releases/latest/download/printf-x64.zip" -OutFile "$php_dir\printf.zip"
|
||||||
|
Expand-Archive -Path $php_dir\printf.zip -DestinationPath $php_dir -Force
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
New-Item -Path $php_dir\printf.exe -ItemType SymbolicLink -Value "C:\Program Files\Git\usr\bin\printf.exe"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Function Install-PhpManager() {
|
Function Install-PhpManager() {
|
||||||
$repo = "mlocati/powershell-phpmanager"
|
$module_path = "$php_dir\PhpManager\PhpManager.psm1"
|
||||||
$zip_file = "$php_dir\PhpManager.zip"
|
if(-not (Test-Path $module_path -PathType Leaf)) {
|
||||||
$tag = (Invoke-RestMethod https://api.github.com/repos/$repo/tags)[0].Name
|
$release = Invoke-RestMethod https://api.github.com/repos/mlocati/powershell-phpmanager/releases/latest
|
||||||
$module_path = "$php_dir\PhpManager\powershell-phpmanager-$tag\PhpManager"
|
$zip_file = "$php_dir\PhpManager.zip"
|
||||||
Invoke-WebRequest -UseBasicParsing -Uri https://github.com/$repo/archive/$tag.zip -OutFile $zip_file
|
Invoke-WebRequest -UseBasicParsing -Uri $release.assets[0].browser_download_url -OutFile $zip_file
|
||||||
Expand-Archive -Path $zip_file -DestinationPath $php_dir\PhpManager -Force
|
Expand-Archive -Path $zip_file -DestinationPath $php_dir -Force
|
||||||
|
}
|
||||||
Import-Module $module_path
|
Import-Module $module_path
|
||||||
Add-ToProfile $current_profile "PhpManager" "Import-Module $module_path"
|
Add-ToProfile $current_profile 'powershell-phpmanager' "Import-Module $module_path"
|
||||||
}
|
}
|
||||||
|
|
||||||
Function Add-Extension {
|
Function Add-Extension {
|
||||||
@ -135,7 +149,7 @@ 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
|
||||||
}
|
}
|
||||||
@ -237,6 +251,7 @@ if(-not(Test-Path -LiteralPath $current_profile)) {
|
|||||||
New-Item -Path $current_profile -ItemType "file" -Force >$null 2>&1
|
New-Item -Path $current_profile -ItemType "file" -Force >$null 2>&1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Add-Printf >$null 2>&1
|
||||||
Step-Log "Setup PhpManager"
|
Step-Log "Setup PhpManager"
|
||||||
Install-PhpManager >$null 2>&1
|
Install-PhpManager >$null 2>&1
|
||||||
Add-Log $tick "PhpManager" "Installed"
|
Add-Log $tick "PhpManager" "Installed"
|
||||||
@ -270,4 +285,5 @@ Set-PhpIniKey -Key 'date.timezone' -Value 'UTC' -Path $php_dir
|
|||||||
Set-PhpIniKey -Key 'memory_limit' -Value '-1' -Path $php_dir
|
Set-PhpIniKey -Key 'memory_limit' -Value '-1' -Path $php_dir
|
||||||
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 CurrentUser
|
Update-PhpCAInfo -Path $php_dir -Source CurrentUser
|
||||||
|
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)"
|
||||||
|
24
src/tools.ts
24
src/tools.ts
@ -345,13 +345,11 @@ export async function getCleanedToolsList(
|
|||||||
* Helper function to get script to setup a tool using a phar url
|
* Helper function to get script to setup a tool using a phar url
|
||||||
*
|
*
|
||||||
* @param tool
|
* @param tool
|
||||||
* @param version
|
|
||||||
* @param url
|
* @param url
|
||||||
* @param os_version
|
* @param os_version
|
||||||
*/
|
*/
|
||||||
export async function addArchive(
|
export async function addArchive(
|
||||||
tool: string,
|
tool: string,
|
||||||
version: string,
|
|
||||||
url: string,
|
url: string,
|
||||||
os_version: string
|
os_version: string
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
@ -444,51 +442,51 @@ export async function addTools(
|
|||||||
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, version, url, os_version);
|
script += await addArchive(tool, url, os_version);
|
||||||
break;
|
break;
|
||||||
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, version, url, os_version);
|
script += await addArchive(tool, url, os_version);
|
||||||
break;
|
break;
|
||||||
case 'phpcs':
|
case 'phpcs':
|
||||||
case 'phpcbf':
|
case 'phpcbf':
|
||||||
url = github + 'squizlabs/PHP_CodeSniffer/' + uri;
|
url = github + 'squizlabs/PHP_CodeSniffer/' + uri;
|
||||||
script += await addArchive(tool, version, url, os_version);
|
script += await addArchive(tool, url, os_version);
|
||||||
break;
|
break;
|
||||||
case 'phive':
|
case 'phive':
|
||||||
script += await addPhive(version, os_version);
|
script += await addPhive(version, os_version);
|
||||||
break;
|
break;
|
||||||
case 'phpstan':
|
case 'phpstan':
|
||||||
url = github + 'phpstan/phpstan/' + uri;
|
url = github + 'phpstan/phpstan/' + uri;
|
||||||
script += await addArchive(tool, version, url, os_version);
|
script += await addArchive(tool, url, os_version);
|
||||||
break;
|
break;
|
||||||
case 'phpmd':
|
case 'phpmd':
|
||||||
url = github + 'phpmd/phpmd/' + uri;
|
url = github + 'phpmd/phpmd/' + uri;
|
||||||
script += await addArchive(tool, version, url, os_version);
|
script += await addArchive(tool, url, os_version);
|
||||||
break;
|
break;
|
||||||
case 'psalm':
|
case 'psalm':
|
||||||
url = github + 'vimeo/psalm/' + uri;
|
url = github + 'vimeo/psalm/' + uri;
|
||||||
script += await addArchive(tool, version, url, os_version);
|
script += await addArchive(tool, url, os_version);
|
||||||
break;
|
break;
|
||||||
case 'composer':
|
case 'composer':
|
||||||
url = await getComposerUrl(version);
|
url = await getComposerUrl(version);
|
||||||
script += await addArchive('composer', version, url, os_version);
|
script += await addArchive('composer', url, os_version);
|
||||||
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, version, url, os_version);
|
script += await addArchive(tool, url, os_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, version, url, os_version);
|
script += await addArchive(tool, url, os_version);
|
||||||
break;
|
break;
|
||||||
case 'deployer':
|
case 'deployer':
|
||||||
url = await getDeployerUrl(version);
|
url = await getDeployerUrl(version);
|
||||||
script += await addArchive(tool, version, url, os_version);
|
script += await addArchive(tool, url, os_version);
|
||||||
break;
|
break;
|
||||||
case 'phinx':
|
case 'phinx':
|
||||||
script += await addPackage(tool, release, 'robmorgan/', os_version);
|
script += await addPackage(tool, release, 'robmorgan/', os_version);
|
||||||
@ -515,7 +513,7 @@ export async function addTools(
|
|||||||
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', version, url, os_version);
|
script += await addArchive('symfony', url, os_version);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
script += await utils.addLog(
|
script += await utils.addLog(
|
||||||
|
31
src/utils.ts
31
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,17 @@ 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 '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user