mirror of
https://github.com/shivammathur/setup-php.git
synced 2025-07-01 12:43:17 +07:00
Compare commits
37 Commits
Author | SHA1 | Date | |
---|---|---|---|
44cf056ba8 | |||
9bfde13f48 | |||
e38eccad04 | |||
fa211a9d07 | |||
5865982519 | |||
e201830bdd | |||
5c4074b01a | |||
48f537d6d0 | |||
bc40a61480 | |||
3d5fae7917 | |||
d0591e6d7c | |||
b108a66489 | |||
f0a05b4f6e | |||
5070ebd871 | |||
bea4065e11 | |||
c3875408ad | |||
1d1c0f2595 | |||
1ac189066e | |||
74cdfb97c1 | |||
ee05ca54f6 | |||
12b1061a6b | |||
1c6058bc18 | |||
2f8045c593 | |||
6597a6a15b | |||
1cc85eb670 | |||
6cba0a914f | |||
c43f842cf3 | |||
11e062bf23 | |||
dee3cfee50 | |||
26b0fcc6cd | |||
ab62fff526 | |||
446bccb14d | |||
29d99c6866 | |||
1444e002ab | |||
03b97e24e9 | |||
f7fb800623 | |||
5593bd4bd3 |
20
.github/CONTRIBUTING.md
vendored
20
.github/CONTRIBUTING.md
vendored
@ -17,13 +17,6 @@ Due to time constraints, you may not always get a quick response. Please do not
|
||||
|
||||
## Coding Guidelines
|
||||
|
||||
This project comes with `.prettierrc.json` and `eslintrc.json` configuration files. Please run the following commands to format the code before committing it.
|
||||
|
||||
```bash
|
||||
$ npm run format
|
||||
$ npm run lint
|
||||
```
|
||||
|
||||
## Using setup-php from a Git checkout
|
||||
|
||||
The following commands can be used to perform the initial checkout of setup-php:
|
||||
@ -40,6 +33,19 @@ Install setup-php dependencies using [npm](https://www.npmjs.com/):
|
||||
$ npm install
|
||||
```
|
||||
|
||||
If you are using `Windows` configure `git` to handle line endings.
|
||||
|
||||
```cmd
|
||||
git config --local core.autocrlf true
|
||||
```
|
||||
|
||||
This project comes with `.prettierrc.json` and `eslintrc.json` configuration files. Please run the following commands to fix and verify the code quality.
|
||||
|
||||
```bash
|
||||
$ npm run format
|
||||
$ npm run lint
|
||||
```
|
||||
|
||||
## Running the test suite
|
||||
|
||||
After following the steps shown above, The `setup-php` tests in the `__tests__` directory can be run using this command:
|
||||
|
5
.github/FUNDING.yml
vendored
5
.github/FUNDING.yml
vendored
@ -1,6 +1,7 @@
|
||||
# These are supported funding model platforms
|
||||
|
||||
github: shivammathur
|
||||
open_collective: setup-php
|
||||
tidelift: "npm/setup-php"
|
||||
community_bridge: setup-php
|
||||
patreon: shivammathur
|
||||
custom: https://www.paypal.me/shivammathur
|
||||
custom: https://www.paypal.me/shivammathur
|
7
.github/PULL_REQUEST_TEMPLATE.md
vendored
7
.github/PULL_REQUEST_TEMPLATE.md
vendored
@ -26,7 +26,12 @@ This PR [briefly explain what it does]
|
||||
- [ ] I have run `npm run format` before the commit.
|
||||
- [ ] I have run `npm run lint` before the commit.
|
||||
- [ ] I have run `npm run release` before the commit.
|
||||
- [ ] `npm test` returns with no unit test errors.
|
||||
- [ ] `npm test` returns with no unit test errors and all code covered.
|
||||
|
||||
> In case this PR edits any scripts:
|
||||
|
||||
- [ ] I have checked the edited scripts for syntax.
|
||||
- [ ] I have tested the changes in an integration test (If yes, provide workflow YAML and link).
|
||||
|
||||
<!--
|
||||
- Please target the develop branch when submitting the pull request.
|
||||
|
8
.github/SECURITY.md
vendored
8
.github/SECURITY.md
vendored
@ -4,10 +4,10 @@
|
||||
|
||||
The following versions of this project are supported for security updates.
|
||||
|
||||
| Version | Supported |
|
||||
| ------- | ------------------ |
|
||||
| 1.9.x | :white_check_mark: |
|
||||
| 2.4.x | :white_check_mark: |
|
||||
| Version | Supported |
|
||||
| -------- | ------------------ |
|
||||
| 1.10.x | :white_check_mark: |
|
||||
| 2.8.x | :white_check_mark: |
|
||||
|
||||
## Supported PHP Versions
|
||||
|
||||
|
94
README.md
94
README.md
@ -8,7 +8,7 @@
|
||||
|
||||
<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://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="#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>
|
||||
@ -63,6 +63,8 @@ Setup PHP with required extensions, php.ini configuration, code-coverage support
|
||||
|Ubuntu 20.04|`ubuntu-20.04`|`PHP 7.4`|
|
||||
|Windows Server 2019|`windows-latest` or `windows-2019`|`PHP 7.4`|
|
||||
|macOS 10.15 Catalina|`macos-latest` or `macos-10.15`|`PHP 7.4`|
|
||||
|macOS 11.0 Big Sur|`macos-11.0`|`PHP 7.4`|
|
||||
|
||||
|
||||
## :heavy_plus_sign: PHP Extension Support
|
||||
- On `ubuntu` by default extensions which are available as a package can be installed. If the extension is not available as a package but it is on `PECL`, it can be installed by specifying `pecl` in the tools input.
|
||||
@ -85,8 +87,9 @@ with:
|
||||
tools: php-cs-fixer, phpunit
|
||||
```
|
||||
|
||||
To setup a particular version of a tool, specify it in the form `tool:version`.
|
||||
Latest stable version of `composer` is setup by default and accepts `v1`, `v2`, `snapshot` and `preview` as versions.
|
||||
To set up a particular version of a tool, specify it in the form `tool:version`.
|
||||
|
||||
The latest stable version of `composer` is set up by default. You can set up the required `composer` version by specifying `v1`, `v2`, `snapshot` or `preview` as versions or the exact version in semver format.
|
||||
|
||||
```yaml
|
||||
uses: shivammathur/setup-php@v1
|
||||
@ -95,6 +98,8 @@ with:
|
||||
tools: composer:v2
|
||||
```
|
||||
|
||||
If you have specified composer plugins `prestissimo` or `composer-prefetcher` in tools, the latest stable version of `composer v1` will be setup. Unless some of your packages require `composer v1`, it is recommended to drop `prestissimo` and use `composer v2`.
|
||||
|
||||
Version for other tools should be in `semver` format and a valid release of the tool.
|
||||
|
||||
```yaml
|
||||
@ -264,14 +269,14 @@ You can persist composer's internal cache directory using the [`action/cache`](h
|
||||
**Note:** Please do not cache `vendor` directory using `action/cache` as that will have side-effects.
|
||||
|
||||
```yaml
|
||||
- name: Get composer cache directory
|
||||
id: composercache
|
||||
- name: Get Composer Cache Directory
|
||||
id: composer-cache
|
||||
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
||||
|
||||
- name: Cache dependencies
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ${{ steps.composercache.outputs.dir }}
|
||||
path: ${{ steps.composer-cache.outputs.dir }}
|
||||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
|
||||
restore-keys: ${{ runner.os }}-composer-
|
||||
|
||||
@ -279,10 +284,15 @@ You can persist composer's internal cache directory using the [`action/cache`](h
|
||||
run: composer install --prefer-dist
|
||||
```
|
||||
|
||||
In the above example, if you support a range of `composer` dependencies and do not commit `composer.lock`, you can use the hash of `composer.json` as the key for your cache.
|
||||
|
||||
- If you do not commit `composer.lock`, you can use the hash of `composer.json` as the key for your cache.
|
||||
```yaml
|
||||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
|
||||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
|
||||
```
|
||||
|
||||
- If you support a range of `composer` dependencies and use `prefer-lowest` and `prefer-stable` options, you can store them in your matrix add them to the keys.
|
||||
```yaml
|
||||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}-${{ matrix.prefer }}-
|
||||
restore-keys: ${{ runner.os }}-composer-${{ matrix.prefer }}-
|
||||
```
|
||||
|
||||
### Composer GitHub OAuth
|
||||
@ -300,31 +310,72 @@ If you have a number of workflows which setup multiple tools or have many compos
|
||||
|
||||
### 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
|
||||
- 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"
|
||||
```
|
||||
|
||||
#### 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.
|
||||
For examples refer to [cs2pr documentation](https://github.com/staabm/annotate-pull-request-from-checkstyle).
|
||||
|
||||
> Here is an example with `phpstan`.
|
||||
PHPStan supports error reporting in GitHub Actions, so no problem matchers are required.
|
||||
|
||||
```yaml
|
||||
- name: Setup PHP
|
||||
uses: shivammathur/setup-php@v1
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: '7.4'
|
||||
tools: cs2pr, phpstan
|
||||
tools: phpstan
|
||||
|
||||
- name: PHPStan
|
||||
run: phpstan analyse src --error-format=checkstyle | cs2pr
|
||||
- name: Run PHPStan
|
||||
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
|
||||
@ -375,6 +426,7 @@ If this action helped you.
|
||||
## :bookmark: Dependencies
|
||||
|
||||
- [Node.js dependencies](https://github.com/shivammathur/setup-php/network/dependencies "Node.js dependencies")
|
||||
- [aaronparker/VcRedist](https://github.com/aaronparker/VcRedist "VcRedist PowerShell package")
|
||||
- [mlocati/powershell-phpmanager](https://github.com/mlocati/powershell-phpmanager "Package to handle PHP on windows")
|
||||
- [ppa:ondrej/php](https://launchpad.net/~ondrej/+archive/ubuntu/php "Packaging active PHP packages")
|
||||
- [shivammathur/homebrew-php](https://github.com/shivammathur/homebrew-php "Tap for PHP builds for MacOS")
|
||||
|
@ -12,9 +12,9 @@ describe('Config tests', () => {
|
||||
|
||||
win32 = await config.addINIValues(
|
||||
'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 () => {
|
||||
@ -29,9 +29,9 @@ describe('Config tests', () => {
|
||||
|
||||
linux = await config.addINIValues(
|
||||
'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 () => {
|
||||
@ -45,8 +45,8 @@ describe('Config tests', () => {
|
||||
|
||||
darwin = await config.addINIValues(
|
||||
'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('Add-Extension does_not_exist');
|
||||
|
||||
win32 = await extensions.addExtension('xdebug', '7.2', 'fedora');
|
||||
expect(win32).toContain('Platform fedora is not supported');
|
||||
win32 = await extensions.addExtension('xdebug', '7.2', 'openbsd');
|
||||
expect(win32).toContain('Platform openbsd is not supported');
|
||||
});
|
||||
|
||||
it('checking addExtensionOnLinux', async () => {
|
||||
@ -68,8 +68,8 @@ describe('Extension tests', () => {
|
||||
linux = await extensions.addExtension('gearman', '7.4', 'linux');
|
||||
expect(linux).toContain('gearman.sh 7.4');
|
||||
|
||||
linux = await extensions.addExtension('xdebug', '7.2', 'fedora');
|
||||
expect(linux).toContain('Platform fedora is not supported');
|
||||
linux = await extensions.addExtension('xdebug', '7.2', 'openbsd');
|
||||
expect(linux).toContain('Platform openbsd is not supported');
|
||||
|
||||
linux = await extensions.addExtension('phalcon3, phalcon4', '7.3', 'linux');
|
||||
expect(linux).toContain('phalcon.sh phalcon3 7.3');
|
||||
@ -78,13 +78,15 @@ describe('Extension tests', () => {
|
||||
|
||||
it('checking addExtensionOnDarwin', async () => {
|
||||
let darwin: string = await extensions.addExtension(
|
||||
'Xdebug, pcov, grpc, protobuf, swoole, sqlite, ast-beta',
|
||||
'Xdebug, pcov, grpc, igbinary, imagick, protobuf, swoole, sqlite, ast-beta',
|
||||
'7.2',
|
||||
'darwin'
|
||||
);
|
||||
expect(darwin).toContain('add_brew_extension xdebug');
|
||||
expect(darwin).toContain('add_brew_extension pcov');
|
||||
expect(darwin).toContain('add_brew_extension grpc');
|
||||
expect(darwin).toContain('add_brew_extension igbinary');
|
||||
expect(darwin).toContain('add_brew_extension imagick');
|
||||
expect(darwin).toContain('add_brew_extension protobuf');
|
||||
expect(darwin).toContain('add_brew_extension swoole');
|
||||
expect(darwin).toContain('pecl_install sqlite3');
|
||||
@ -117,14 +119,6 @@ describe('Extension tests', () => {
|
||||
darwin = await extensions.addExtension('redis', '7.2', 'darwin');
|
||||
expect(darwin).toContain('pecl_install redis');
|
||||
|
||||
darwin = await extensions.addExtension('imagick', '5.6', 'darwin');
|
||||
expect(darwin).toContain('brew install pkg-config imagemagick');
|
||||
expect(darwin).toContain('pecl_install imagick');
|
||||
|
||||
darwin = await extensions.addExtension('imagick', '7.4', 'darwin');
|
||||
expect(darwin).toContain('brew install pkg-config imagemagick');
|
||||
expect(darwin).toContain('pecl_install imagick');
|
||||
|
||||
darwin = await extensions.addExtension(
|
||||
'does_not_exist',
|
||||
'7.2',
|
||||
@ -133,7 +127,7 @@ describe('Extension tests', () => {
|
||||
);
|
||||
expect(darwin).toContain('add_extension does_not_exist');
|
||||
|
||||
darwin = await extensions.addExtension('xdebug', '7.2', 'fedora');
|
||||
expect(darwin).toContain('Platform fedora is not supported');
|
||||
darwin = await extensions.addExtension('xdebug', '7.2', 'openbsd');
|
||||
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);
|
||||
});
|
||||
});
|
@ -1,28 +1,12 @@
|
||||
import * as httpm from '@actions/http-client';
|
||||
import * as tools from '../src/tools';
|
||||
|
||||
httpm.HttpClient.prototype.get = jest.fn().mockImplementation(() => {
|
||||
return {
|
||||
message: null,
|
||||
readBody: jest.fn().mockImplementation(() => {
|
||||
return JSON.stringify({
|
||||
stable: [{path: '/composer-stable.phar'}],
|
||||
preview: [{path: '/composer-preview.phar'}],
|
||||
snapshot: [{path: '/composer.phar'}],
|
||||
'1': [{path: '/composer-1.phar'}],
|
||||
'2': [{path: '/composer-2.phar'}]
|
||||
});
|
||||
})
|
||||
};
|
||||
});
|
||||
|
||||
describe('Tools tests', () => {
|
||||
it('checking getCommand', async () => {
|
||||
expect(await tools.getCommand('linux', 'tool')).toBe('add_tool ');
|
||||
expect(await tools.getCommand('darwin', 'tool')).toBe('add_tool ');
|
||||
expect(await tools.getCommand('win32', 'tool')).toBe('Add-Tool ');
|
||||
expect(await tools.getCommand('fedora', 'tool')).toContain(
|
||||
'Platform fedora is not supported'
|
||||
expect(await tools.getCommand('openbsd', 'tool')).toContain(
|
||||
'Platform openbsd is not supported'
|
||||
);
|
||||
});
|
||||
|
||||
@ -36,8 +20,8 @@ describe('Tools tests', () => {
|
||||
expect(await tools.getCommand('win32', 'composertool')).toBe(
|
||||
'Add-Composertool '
|
||||
);
|
||||
expect(await tools.getCommand('fedora', 'composertool')).toContain(
|
||||
'Platform fedora is not supported'
|
||||
expect(await tools.getCommand('openbsd', 'composertool')).toContain(
|
||||
'Platform openbsd is not supported'
|
||||
);
|
||||
});
|
||||
|
||||
@ -45,8 +29,8 @@ describe('Tools tests', () => {
|
||||
expect(await tools.getCommand('linux', '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('fedora', 'pecl')).toContain(
|
||||
'Platform fedora is not supported'
|
||||
expect(await tools.getCommand('openbsd', 'pecl')).toContain(
|
||||
'Platform openbsd is not supported'
|
||||
);
|
||||
});
|
||||
|
||||
@ -256,9 +240,17 @@ describe('Tools tests', () => {
|
||||
'a',
|
||||
'b'
|
||||
]);
|
||||
expect(await tools.addComposer(['a', 'b', 'composer:1.2'])).toStrictEqual([
|
||||
'composer',
|
||||
'a',
|
||||
'b'
|
||||
]);
|
||||
expect(
|
||||
await tools.addComposer(['a', 'b', 'composer:1.2.3'])
|
||||
).toStrictEqual(['composer', 'a', 'b']);
|
||||
).toStrictEqual(['composer:1.2.3', 'a', 'b']);
|
||||
expect(
|
||||
await tools.addComposer(['a', 'b', 'composer:v1.2.3'])
|
||||
).toStrictEqual(['composer:1.2.3', 'a', 'b']);
|
||||
expect(
|
||||
await tools.addComposer(['a', 'b', 'composer:snapshot'])
|
||||
).toStrictEqual(['composer:snapshot', 'a', 'b']);
|
||||
@ -277,6 +269,9 @@ describe('Tools tests', () => {
|
||||
expect(
|
||||
await tools.addComposer(['a', 'b', 'c', 'composer:v2'])
|
||||
).toStrictEqual(['composer:2', 'a', 'b', 'c']);
|
||||
expect(
|
||||
await tools.addComposer(['hirak', 'b', 'c', 'composer:v2'])
|
||||
).toStrictEqual(['composer:1', 'hirak', 'b', 'c']);
|
||||
});
|
||||
|
||||
it('checking getComposerUrl', async () => {
|
||||
@ -298,6 +293,21 @@ describe('Tools tests', () => {
|
||||
expect(await tools.getComposerUrl('2')).toContain(
|
||||
'https://getcomposer.org/composer-2.phar'
|
||||
);
|
||||
expect(await tools.getComposerUrl('1.7.2')).toContain(
|
||||
'https://github.com/composer/composer/releases/download/1.7.2/composer.phar'
|
||||
);
|
||||
expect(await tools.getComposerUrl('1.7.2')).toContain(
|
||||
'https://getcomposer.org/composer-1.7.2.phar'
|
||||
);
|
||||
expect(await tools.getComposerUrl('2.0.0-RC2')).toContain(
|
||||
'https://github.com/composer/composer/releases/download/2.0.0-RC2/composer.phar'
|
||||
);
|
||||
expect(await tools.getComposerUrl('2.0.0-RC2')).toContain(
|
||||
'https://getcomposer.org/composer-2.0.0-RC2.phar'
|
||||
);
|
||||
expect(await tools.getComposerUrl('wrong')).toContain(
|
||||
'https://getcomposer.org/composer-stable.phar'
|
||||
);
|
||||
});
|
||||
|
||||
it('checking getSymfonyUri', async () => {
|
||||
@ -319,42 +329,33 @@ describe('Tools tests', () => {
|
||||
expect(await tools.getSymfonyUri('1.2.3', 'win32')).toContain(
|
||||
'releases/download/v1.2.3/symfony_windows_amd64'
|
||||
);
|
||||
expect(await tools.getSymfonyUri('1.2.3', 'fedora')).toContain(
|
||||
'Platform fedora is not supported'
|
||||
expect(await tools.getSymfonyUri('1.2.3', 'openbsd')).toContain(
|
||||
'Platform openbsd is not supported'
|
||||
);
|
||||
});
|
||||
|
||||
it('checking getCleanedToolsList', async () => {
|
||||
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, robmorgan/phinx'
|
||||
);
|
||||
expect(tools_list).toStrictEqual([
|
||||
'composer',
|
||||
'tool',
|
||||
'phinx',
|
||||
'prestissimo',
|
||||
'composer-prefetcher'
|
||||
]);
|
||||
expect(tools_list).toStrictEqual(['composer:1.2.3', 'tool', 'phinx']);
|
||||
});
|
||||
|
||||
it('checking addArchive', async () => {
|
||||
let script: string = await tools.addArchive(
|
||||
'tool',
|
||||
'1.2.3',
|
||||
'https://tool.com/tool.phar',
|
||||
'linux'
|
||||
);
|
||||
expect(script).toContain('add_tool https://tool.com/tool.phar tool');
|
||||
script = await tools.addArchive(
|
||||
'tool',
|
||||
'1.2.3',
|
||||
'https://tool.com/tool.phar',
|
||||
'darwin'
|
||||
);
|
||||
expect(script).toContain('add_tool https://tool.com/tool.phar tool');
|
||||
script = await tools.addArchive(
|
||||
'tool',
|
||||
'1.2.3',
|
||||
'https://tool.com/tool.phar',
|
||||
'win32'
|
||||
);
|
||||
@ -362,11 +363,10 @@ describe('Tools tests', () => {
|
||||
|
||||
script = await tools.addArchive(
|
||||
'tool',
|
||||
'1.2.3',
|
||||
'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 () => {
|
||||
@ -394,8 +394,8 @@ describe('Tools tests', () => {
|
||||
'Add-Log "$cross" "php-config" "php-config is not a windows tool"'
|
||||
);
|
||||
|
||||
script = await tools.addDevTools('tool', 'fedora');
|
||||
expect(script).toContain('Platform fedora is not supported');
|
||||
script = await tools.addDevTools('tool', 'openbsd');
|
||||
expect(script).toContain('Platform openbsd is not supported');
|
||||
});
|
||||
|
||||
it('checking addPackage', async () => {
|
||||
@ -413,8 +413,8 @@ describe('Tools tests', () => {
|
||||
script = await tools.addPackage('tool', 'tool:1.2.3', 'user/', 'win32');
|
||||
expect(script).toContain('Add-Composertool tool tool:1.2.3 user/');
|
||||
|
||||
script = await tools.addPackage('tool', 'tool:1.2.3', 'user/', 'fedora');
|
||||
expect(script).toContain('Platform fedora is not supported');
|
||||
script = await tools.addPackage('tool', 'tool:1.2.3', 'user/', 'openbsd');
|
||||
expect(script).toContain('Platform openbsd is not supported');
|
||||
});
|
||||
|
||||
it('checking addTools on linux', async () => {
|
||||
@ -424,7 +424,7 @@ describe('Tools tests', () => {
|
||||
'linux'
|
||||
);
|
||||
expect(script).toContain(
|
||||
'add_tool https://getcomposer.org/composer-stable.phar composer'
|
||||
'add_tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-stable.phar,https://getcomposer.org/composer-stable.phar composer'
|
||||
);
|
||||
expect(script).toContain(
|
||||
'add_tool https://github.com/staabm/annotate-pull-request-from-checkstyle/releases/latest/download/cs2pr cs2pr'
|
||||
@ -453,12 +453,12 @@ describe('Tools tests', () => {
|
||||
});
|
||||
it('checking addTools on darwin', async () => {
|
||||
const script: string = await tools.addTools(
|
||||
'phpcs, phpcbf, phpcpd, phpmd, psalm, phinx, phive:1.2.3, cs2pr:1.2.3, composer-prefetcher:1.2.3, phpize, php-config, symfony, symfony:1.2.3',
|
||||
'phpcs, phpcbf, phpcpd, phpmd, psalm, phinx, phive:1.2.3, cs2pr:1.2.3, phpize, php-config, symfony:1.2.3',
|
||||
'7.4',
|
||||
'darwin'
|
||||
);
|
||||
expect(script).toContain(
|
||||
'add_tool https://getcomposer.org/composer-stable.phar composer'
|
||||
'add_tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-stable.phar,https://getcomposer.org/composer-stable.phar composer'
|
||||
);
|
||||
expect(script).toContain(
|
||||
'add_tool https://github.com/staabm/annotate-pull-request-from-checkstyle/releases/download/1.2.3/cs2pr cs2pr'
|
||||
@ -482,12 +482,6 @@ describe('Tools tests', () => {
|
||||
expect(script).toContain(
|
||||
'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-prefetcher composer-prefetcher:1.2.3 narrowspark/automatic-'
|
||||
);
|
||||
expect(script).toContain(
|
||||
'add_tool https://github.com/symfony/cli/releases/latest/download/symfony_darwin_amd64 symfony'
|
||||
);
|
||||
expect(script).toContain(
|
||||
'add_tool https://github.com/symfony/cli/releases/download/v1.2.3/symfony_darwin_amd64 symfony'
|
||||
);
|
||||
@ -496,12 +490,12 @@ describe('Tools tests', () => {
|
||||
});
|
||||
it('checking addTools on windows', async () => {
|
||||
const script: string = await tools.addTools(
|
||||
'codeception, cs2pr, deployer, prestissimo, phpmd, phinx, phive:0.13.2, php-config, phpize, symfony, does_not_exist',
|
||||
'codeception, cs2pr, deployer, phpmd, phinx, phive:0.13.2, php-config, phpize, symfony, does_not_exist, composer',
|
||||
'7.4',
|
||||
'win32'
|
||||
);
|
||||
expect(script).toContain(
|
||||
'Add-Tool https://getcomposer.org/composer-stable.phar composer'
|
||||
'Add-Tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-stable.phar,https://getcomposer.org/composer-stable.phar composer'
|
||||
);
|
||||
expect(script).toContain(
|
||||
'Add-Tool https://github.com/staabm/annotate-pull-request-from-checkstyle/releases/latest/download/cs2pr cs2pr'
|
||||
@ -509,7 +503,6 @@ describe('Tools tests', () => {
|
||||
expect(script).toContain(
|
||||
'Add-Tool https://deployer.org/deployer.phar deployer'
|
||||
);
|
||||
expect(script).toContain('Add-Composertool prestissimo prestissimo hirak/');
|
||||
expect(script).toContain(
|
||||
'Add-Tool https://github.com/phpmd/phpmd/releases/latest/download/phpmd.phar phpmd'
|
||||
);
|
||||
@ -531,7 +524,7 @@ describe('Tools tests', () => {
|
||||
'win32'
|
||||
);
|
||||
expect(script).toContain(
|
||||
'Add-Tool https://getcomposer.org/composer-stable.phar composer'
|
||||
'Add-Tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-1.phar,https://getcomposer.org/composer-1.phar composer'
|
||||
);
|
||||
expect(script).toContain('Add-Composertool prestissimo prestissimo hirak/');
|
||||
expect(script).toContain('Add-Composertool phinx phinx robmorgan/');
|
||||
@ -546,12 +539,12 @@ describe('Tools tests', () => {
|
||||
'linux'
|
||||
);
|
||||
expect(script).toContain(
|
||||
'add_tool https://getcomposer.org/composer-1.phar composer'
|
||||
'add_tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-1.phar,https://getcomposer.org/composer-1.phar composer'
|
||||
);
|
||||
|
||||
script = await tools.addTools('composer:preview', '7.4', 'linux');
|
||||
expect(script).toContain(
|
||||
'add_tool https://getcomposer.org/composer-preview.phar composer'
|
||||
'add_tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-preview.phar,https://getcomposer.org/composer-preview.phar composer'
|
||||
);
|
||||
script = await tools.addTools(
|
||||
'composer:v1, composer:preview, composer:snapshot',
|
||||
@ -559,7 +552,7 @@ describe('Tools tests', () => {
|
||||
'linux'
|
||||
);
|
||||
expect(script).toContain(
|
||||
'add_tool https://getcomposer.org/composer.phar composer'
|
||||
'add_tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-snapshot.phar,https://getcomposer.org/composer.phar composer'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
@ -17,13 +17,19 @@ async function cleanup(path: string): Promise<void> {
|
||||
}
|
||||
|
||||
describe('Utils tests', () => {
|
||||
it('checking getInput', async () => {
|
||||
it('checking readEnv', async () => {
|
||||
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('undefined', false)).toBe('');
|
||||
expect(await utils.getInput('setup-php', false)).toBe('setup-php');
|
||||
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 () => {
|
||||
@ -131,8 +137,8 @@ describe('Utils tests', () => {
|
||||
expect(step_log).toEqual('step_log "Test message"');
|
||||
step_log = await utils.stepLog(message, 'darwin');
|
||||
expect(step_log).toEqual('step_log "Test message"');
|
||||
step_log = await utils.stepLog(message, 'fedora');
|
||||
expect(step_log).toContain('Platform fedora is not supported');
|
||||
step_log = await utils.stepLog(message, 'openbsd');
|
||||
expect(step_log).toContain('Platform openbsd is not supported');
|
||||
|
||||
let add_log: string = await utils.addLog(
|
||||
'tick',
|
||||
@ -145,8 +151,8 @@ describe('Utils tests', () => {
|
||||
expect(add_log).toEqual('add_log "tick" "xdebug" "enabled"');
|
||||
add_log = await utils.addLog('tick', 'xdebug', 'enabled', 'darwin');
|
||||
expect(add_log).toEqual('add_log "tick" "xdebug" "enabled"');
|
||||
add_log = await utils.addLog('tick', 'xdebug', 'enabled', 'fedora');
|
||||
expect(add_log).toContain('Platform fedora is not supported');
|
||||
add_log = await utils.addLog('tick', 'xdebug', 'enabled', 'openbsd');
|
||||
expect(add_log).toContain('Platform openbsd is not supported');
|
||||
});
|
||||
|
||||
it('checking getExtensionPrefix', async () => {
|
||||
@ -162,8 +168,8 @@ describe('Utils tests', () => {
|
||||
expect(await utils.suppressOutput('win32')).toEqual(' >$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('fedora')).toContain(
|
||||
'Platform fedora is not supported'
|
||||
expect(await utils.suppressOutput('openbsd')).toContain(
|
||||
'Platform openbsd is not supported'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
1174
dist/index.js
vendored
1174
dist/index.js
vendored
File diff suppressed because it is too large
Load Diff
@ -17,11 +17,11 @@ jobs:
|
||||
with:
|
||||
php-version: ${{ matrix.php-versions }}
|
||||
- name: Get composer cache directory
|
||||
id: composercache
|
||||
id: composer-cache
|
||||
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
||||
- uses: actions/cache@v2
|
||||
with:
|
||||
path: ${{ steps.composercache.outputs.dir }}
|
||||
path: ${{ steps.composer-cache.outputs.dir }}
|
||||
# Use composer.json for key, if composer.lock is not committed.
|
||||
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
|
||||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
|
||||
|
@ -37,12 +37,12 @@ jobs:
|
||||
- name: Start mysql service
|
||||
run: sudo /etc/init.d/mysql start
|
||||
- name: Get composer cache directory
|
||||
id: composercache
|
||||
id: composer-cache
|
||||
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
||||
- name: Cache composer dependencies
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ${{ steps.composercache.outputs.dir }}
|
||||
path: ${{ steps.composer-cache.outputs.dir }}
|
||||
# Use composer.json for key, if composer.lock is not committed.
|
||||
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
|
||||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
|
||||
@ -70,12 +70,12 @@ jobs:
|
||||
php-version: '7.3'
|
||||
extensions: mbstring, intl
|
||||
- name: Get composer cache directory
|
||||
id: composercache
|
||||
id: composer-cache
|
||||
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
||||
- name: Cache composer dependencies
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ${{ steps.composercache.outputs.dir }}
|
||||
path: ${{ steps.composer-cache.outputs.dir }}
|
||||
# Use composer.json for key, if composer.lock is not committed.
|
||||
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
|
||||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
|
||||
@ -98,12 +98,12 @@ jobs:
|
||||
extensions: mbstring, intl
|
||||
tools: phpstan
|
||||
- name: Get composer cache directory
|
||||
id: composercache
|
||||
id: composer-cache
|
||||
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
||||
- name: Cache composer dependencies
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ${{ steps.composercache.outputs.dir }}
|
||||
path: ${{ steps.composer-cache.outputs.dir }}
|
||||
# Use composer.json for key, if composer.lock is not committed.
|
||||
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
|
||||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
|
||||
|
@ -35,12 +35,12 @@ jobs:
|
||||
extensions: mbstring, intl, redis, pdo_pgsql
|
||||
coverage: pcov
|
||||
- name: Get composer cache directory
|
||||
id: composercache
|
||||
id: composer-cache
|
||||
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
||||
- name: Cache composer dependencies
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ${{ steps.composercache.outputs.dir }}
|
||||
path: ${{ steps.composer-cache.outputs.dir }}
|
||||
# Use composer.json for key, if composer.lock is not committed.
|
||||
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
|
||||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
|
||||
@ -68,12 +68,12 @@ jobs:
|
||||
php-version: '7.3'
|
||||
extensions: mbstring, intl
|
||||
- name: Get composer cache directory
|
||||
id: composercache
|
||||
id: composer-cache
|
||||
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
||||
- name: Cache composer dependencies
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ${{ steps.composercache.outputs.dir }}
|
||||
path: ${{ steps.composer-cache.outputs.dir }}
|
||||
# Use composer.json for key, if composer.lock is not committed.
|
||||
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
|
||||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
|
||||
@ -96,12 +96,12 @@ jobs:
|
||||
extensions: mbstring, intl
|
||||
tools: phpstan
|
||||
- name: Get composer cache directory
|
||||
id: composercache
|
||||
id: composer-cache
|
||||
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
||||
- name: Cache composer dependencies
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ${{ steps.composercache.outputs.dir }}
|
||||
path: ${{ steps.composer-cache.outputs.dir }}
|
||||
# Use composer.json for key, if composer.lock is not committed.
|
||||
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
|
||||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
|
||||
|
@ -19,12 +19,12 @@ jobs:
|
||||
extensions: mbstring, intl, pdo_sqlite, pdo_mysql
|
||||
coverage: pcov #optional
|
||||
- name: Get composer cache directory
|
||||
id: composercache
|
||||
id: composer-cache
|
||||
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
||||
- name: Cache composer dependencies
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ${{ steps.composercache.outputs.dir }}
|
||||
path: ${{ steps.composer-cache.outputs.dir }}
|
||||
# Use composer.json for key, if composer.lock is not committed.
|
||||
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
|
||||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
|
||||
@ -48,12 +48,12 @@ jobs:
|
||||
php-version: '7.3'
|
||||
extensions: mbstring, intl
|
||||
- name: Get composer cache directory
|
||||
id: composercache
|
||||
id: composer-cache
|
||||
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
||||
- name: Cache composer dependencies
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ${{ steps.composercache.outputs.dir }}
|
||||
path: ${{ steps.composer-cache.outputs.dir }}
|
||||
# Use composer.json for key, if composer.lock is not committed.
|
||||
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
|
||||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
|
||||
@ -76,12 +76,12 @@ jobs:
|
||||
extensions: mbstring, intl
|
||||
tools: phpstan
|
||||
- name: Get composer cache directory
|
||||
id: composercache
|
||||
id: composer-cache
|
||||
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
||||
- name: Cache composer dependencies
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ${{ steps.composercache.outputs.dir }}
|
||||
path: ${{ steps.composer-cache.outputs.dir }}
|
||||
# Use composer.json for key, if composer.lock is not committed.
|
||||
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
|
||||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
|
||||
|
@ -18,12 +18,12 @@ jobs:
|
||||
extensions: mbstring, intl, curl, dom
|
||||
coverage: xdebug #optional
|
||||
- name: Get composer cache directory
|
||||
id: composercache
|
||||
id: composer-cache
|
||||
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
||||
- name: Cache composer dependencies
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ${{ steps.composercache.outputs.dir }}
|
||||
path: ${{ steps.composer-cache.outputs.dir }}
|
||||
# Use composer.json for key, if composer.lock is not committed.
|
||||
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
|
||||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
|
||||
|
@ -44,12 +44,12 @@ jobs:
|
||||
- name: Start mysql service
|
||||
run: sudo /etc/init.d/mysql start
|
||||
- name: Get composer cache directory
|
||||
id: composercache
|
||||
id: composer-cache
|
||||
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
||||
- name: Cache composer dependencies
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ${{ steps.composercache.outputs.dir }}
|
||||
path: ${{ steps.composer-cache.outputs.dir }}
|
||||
# Use composer.json for key, if composer.lock is not committed.
|
||||
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
|
||||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
|
||||
|
@ -44,12 +44,12 @@ jobs:
|
||||
extensions: mbstring, dom, fileinfo, pgsql
|
||||
coverage: xdebug #optional
|
||||
- name: Get composer cache directory
|
||||
id: composercache
|
||||
id: composer-cache
|
||||
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
||||
- name: Cache composer dependencies
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ${{ steps.composercache.outputs.dir }}
|
||||
path: ${{ steps.composer-cache.outputs.dir }}
|
||||
# Use composer.json for key, if composer.lock is not committed.
|
||||
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
|
||||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
|
||||
|
@ -20,12 +20,12 @@ jobs:
|
||||
extensions: mbstring, dom, fileinfo
|
||||
coverage: xdebug #optional
|
||||
- name: Get composer cache directory
|
||||
id: composercache
|
||||
id: composer-cache
|
||||
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
||||
- name: Cache composer dependencies
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ${{ steps.composercache.outputs.dir }}
|
||||
path: ${{ steps.composer-cache.outputs.dir }}
|
||||
# Use composer.json for key, if composer.lock is not committed.
|
||||
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
|
||||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
|
||||
|
@ -44,12 +44,12 @@ jobs:
|
||||
- name: Start mysql service
|
||||
run: sudo /etc/init.d/mysql start
|
||||
- name: Get composer cache directory
|
||||
id: composercache
|
||||
id: composer-cache
|
||||
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
||||
- name: Cache composer dependencies
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ${{ steps.composercache.outputs.dir }}
|
||||
path: ${{ steps.composer-cache.outputs.dir }}
|
||||
# Use composer.json for key, if composer.lock is not committed.
|
||||
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
|
||||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
|
||||
|
@ -44,12 +44,12 @@ jobs:
|
||||
extensions: mbstring, dom, fileinfo, pgsql
|
||||
coverage: xdebug #optional
|
||||
- name: Get composer cache directory
|
||||
id: composercache
|
||||
id: composer-cache
|
||||
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
||||
- name: Cache composer dependencies
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ${{ steps.composercache.outputs.dir }}
|
||||
path: ${{ steps.composer-cache.outputs.dir }}
|
||||
# Use composer.json for key, if composer.lock is not committed.
|
||||
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
|
||||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
|
||||
|
@ -20,12 +20,12 @@ jobs:
|
||||
extensions: mbstring, dom, fileinfo, mysql
|
||||
coverage: xdebug #optional
|
||||
- name: Get composer cache directory
|
||||
id: composercache
|
||||
id: composer-cache
|
||||
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
||||
- name: Cache composer dependencies
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ${{ steps.composercache.outputs.dir }}
|
||||
path: ${{ steps.composer-cache.outputs.dir }}
|
||||
# Use composer.json for key, if composer.lock is not committed.
|
||||
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
|
||||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
|
||||
|
@ -44,12 +44,12 @@ jobs:
|
||||
- name: Start mysql service
|
||||
run: sudo /etc/init.d/mysql start
|
||||
- name: Get composer cache directory
|
||||
id: composercache
|
||||
id: composer-cache
|
||||
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
||||
- name: Cache composer dependencies
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ${{ steps.composercache.outputs.dir }}
|
||||
path: ${{ steps.composer-cache.outputs.dir }}
|
||||
# Use composer.json for key, if composer.lock is not committed.
|
||||
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
|
||||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
|
||||
|
@ -43,12 +43,12 @@ jobs:
|
||||
extensions: mbstring, dom, zip, phalcon4, pgsql #use phalcon3 for the phalcon 3.x
|
||||
coverage: xdebug #optional
|
||||
- name: Get composer cache directory
|
||||
id: composercache
|
||||
id: composer-cache
|
||||
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
||||
- name: Cache composer dependencies
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ${{ steps.composercache.outputs.dir }}
|
||||
path: ${{ steps.composer-cache.outputs.dir }}
|
||||
# Use composer.json for key, if composer.lock is not committed.
|
||||
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
|
||||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
|
||||
|
@ -33,12 +33,12 @@ jobs:
|
||||
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
|
||||
restore-keys: ${{ runner.os }}-yarn-
|
||||
- name: Get composer cache directory
|
||||
id: composercache
|
||||
id: composer-cache
|
||||
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
||||
- name: Cache composer dependencies
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ${{ steps.composercache.outputs.dir }}
|
||||
path: ${{ steps.composer-cache.outputs.dir }}
|
||||
# Use composer.json for key, if composer.lock is not committed.
|
||||
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
|
||||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
|
||||
|
@ -18,12 +18,12 @@ jobs:
|
||||
extensions: mbstring, simplexml, dom
|
||||
coverage: xdebug #optional
|
||||
- name: Get composer cache directory
|
||||
id: composercache
|
||||
id: composer-cache
|
||||
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
||||
- name: Cache composer dependencies
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ${{ steps.composercache.outputs.dir }}
|
||||
path: ${{ steps.composer-cache.outputs.dir }}
|
||||
# Use composer.json for key, if composer.lock is not committed.
|
||||
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
|
||||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
|
||||
|
@ -31,12 +31,12 @@ jobs:
|
||||
- name: Start mysql service
|
||||
run: sudo /etc/init.d/mysql start
|
||||
- name: Get composer cache directory
|
||||
id: composercache
|
||||
id: composer-cache
|
||||
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
||||
- name: Cache composer dependencies
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ${{ steps.composercache.outputs.dir }}
|
||||
path: ${{ steps.composer-cache.outputs.dir }}
|
||||
# Use composer.json for key, if composer.lock is not committed.
|
||||
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
|
||||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
|
||||
|
@ -29,12 +29,12 @@ jobs:
|
||||
extensions: mbstring, xml, ctype, iconv, intl, pdo_sqlite, pgsql
|
||||
coverage: xdebug #optional
|
||||
- name: Get composer cache directory
|
||||
id: composercache
|
||||
id: composer-cache
|
||||
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
||||
- name: Cache composer dependencies
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ${{ steps.composercache.outputs.dir }}
|
||||
path: ${{ steps.composer-cache.outputs.dir }}
|
||||
# Use composer.json for key, if composer.lock is not committed.
|
||||
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
|
||||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
|
||||
|
@ -20,12 +20,12 @@ jobs:
|
||||
extensions: mbstring, xml, ctype, iconv, intl, pdo_sqlite
|
||||
coverage: xdebug #optional
|
||||
- name: Get composer cache directory
|
||||
id: composercache
|
||||
id: composer-cache
|
||||
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
||||
- name: Cache composer dependencies
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ${{ steps.composercache.outputs.dir }}
|
||||
path: ${{ steps.composer-cache.outputs.dir }}
|
||||
# Use composer.json for key, if composer.lock is not committed.
|
||||
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
|
||||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
|
||||
|
@ -41,12 +41,12 @@ jobs:
|
||||
- name: Start mysql service
|
||||
run: sudo /etc/init.d/mysql start
|
||||
- name: Get composer cache directory
|
||||
id: composercache
|
||||
id: composer-cache
|
||||
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
||||
- name: Cache composer dependencies
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ${{ steps.composercache.outputs.dir }}
|
||||
path: ${{ steps.composer-cache.outputs.dir }}
|
||||
# Use composer.json for key, if composer.lock is not committed.
|
||||
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
|
||||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
|
||||
|
@ -39,12 +39,12 @@ jobs:
|
||||
extensions: mbstring, intl, gd, imagick, zip, dom, pgsql
|
||||
coverage: xdebug #optional
|
||||
- name: Get composer cache directory
|
||||
id: composercache
|
||||
id: composer-cache
|
||||
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
||||
- name: Cache composer dependencies
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ${{ steps.composercache.outputs.dir }}
|
||||
path: ${{ steps.composer-cache.outputs.dir }}
|
||||
# Use composer.json for key, if composer.lock is not committed.
|
||||
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
|
||||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
|
||||
|
@ -18,12 +18,12 @@ jobs:
|
||||
extensions: mbstring, bcmath, curl, intl
|
||||
coverage: xdebug #optional
|
||||
- name: Get composer cache directory
|
||||
id: composercache
|
||||
id: composer-cache
|
||||
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
||||
- name: Cache composer dependencies
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ${{ steps.composercache.outputs.dir }}
|
||||
path: ${{ steps.composer-cache.outputs.dir }}
|
||||
# Use composer.json for key, if composer.lock is not committed.
|
||||
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
|
||||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
|
||||
|
2610
package-lock.json
generated
2610
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
35
package.json
35
package.json
@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "setup-php",
|
||||
"version": "1.9.4",
|
||||
"version": "1.10.0",
|
||||
"private": false,
|
||||
"description": "Setup PHP for use with GitHub Actions",
|
||||
"main": "dist/index.js",
|
||||
"scripts": {
|
||||
"build": "tsc",
|
||||
"lint": "eslint **/*.ts --cache",
|
||||
"lint": "eslint **/*.ts --cache --fix",
|
||||
"format": "prettier --write **/*.ts && git add .",
|
||||
"format-check": "prettier --check **/*.ts",
|
||||
"release": "ncc build src/install.ts -o dist && git add -f dist/",
|
||||
@ -24,29 +24,28 @@
|
||||
"author": "shivammathur",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@actions/core": "^1.2.4",
|
||||
"@actions/core": "^1.2.6",
|
||||
"@actions/exec": "^1.0.4",
|
||||
"@actions/http-client": "^1.0.8",
|
||||
"@actions/io": "^1.0.2",
|
||||
"fs": "0.0.1-security"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/jest": "^26.0.9",
|
||||
"@types/node": "^14.0.27",
|
||||
"@typescript-eslint/eslint-plugin": "^3.8.0",
|
||||
"@typescript-eslint/parser": "^3.8.0",
|
||||
"@types/jest": "^26.0.15",
|
||||
"@types/node": "^14.14.7",
|
||||
"@typescript-eslint/eslint-plugin": "^4.7.0",
|
||||
"@typescript-eslint/parser": "^4.7.0",
|
||||
"@zeit/ncc": "^0.22.3",
|
||||
"eslint": "^7.6.0",
|
||||
"eslint-config-prettier": "^6.11.0",
|
||||
"eslint-plugin-import": "^2.22.0",
|
||||
"eslint-plugin-jest": "^23.20.0",
|
||||
"eslint": "^7.13.0",
|
||||
"eslint-config-prettier": "^6.15.0",
|
||||
"eslint-plugin-import": "^2.22.1",
|
||||
"eslint-plugin-jest": "^24.1.3",
|
||||
"eslint-plugin-prettier": "^3.1.4",
|
||||
"husky": "^4.2.5",
|
||||
"jest": "^26.2.2",
|
||||
"jest-circus": "^26.2.2",
|
||||
"prettier": "^2.0.5",
|
||||
"ts-jest": "^26.1.4",
|
||||
"typescript": "^3.9.7"
|
||||
"husky": "^4.3.0",
|
||||
"jest": "^26.6.3",
|
||||
"jest-circus": "^26.6.3",
|
||||
"prettier": "^2.1.2",
|
||||
"ts-jest": "^26.4.4",
|
||||
"typescript": "^4.0.5"
|
||||
},
|
||||
"husky": {
|
||||
"skipCI": true,
|
||||
|
@ -6,12 +6,10 @@ import * as utils from './utils';
|
||||
*
|
||||
* @param extension_csv
|
||||
* @param version
|
||||
* @param pipe
|
||||
*/
|
||||
export async function addExtensionDarwin(
|
||||
extension_csv: string,
|
||||
version: string,
|
||||
pipe: string
|
||||
version: string
|
||||
): Promise<string> {
|
||||
const extensions: Array<string> = await utils.extensionArray(extension_csv);
|
||||
let script = '\n';
|
||||
@ -32,28 +30,20 @@ export async function addExtensionDarwin(
|
||||
' ' +
|
||||
ext_prefix;
|
||||
return;
|
||||
// match 5.6xdebug to 8.0xdebug, 5.6swoole to 8.0swoole
|
||||
// match 5.6grpc to 7.4grpc, 5.6protobuf to 7.4protobuf
|
||||
// match 5.6xdebug to 8.0xdebug, 5.6igbinary to 8.0igbinary
|
||||
// match 5.6grpc to 7.4grpc, 5.6imagick to 7.4imagick, 5.6protobuf to 7.4protobuf, 5.6swoole to 7.4swoole
|
||||
// match 7.1pcov to 8.0pcov
|
||||
case /(5\.6|7\.[0-4]|8\.[0-9])xdebug/.test(version_extension):
|
||||
case /(5\.6|7\.[0-4])(grpc|protobuf|swoole)/.test(version_extension):
|
||||
case /(7\.[1-4]|8\.[0-9])pcov/.test(version_extension):
|
||||
case /(5\.6|7\.[0-4]|8\.0)(xdebug|igbinary)/.test(version_extension):
|
||||
case /(5\.6|7\.[0-4])(grpc|imagick|protobuf|swoole)/.test(
|
||||
version_extension
|
||||
):
|
||||
case /(7\.[1-4]|8\.0])pcov/.test(version_extension):
|
||||
command = 'add_brew_extension ' + extension_name;
|
||||
break;
|
||||
// match 5.6redis
|
||||
case /5\.6redis/.test(version_extension):
|
||||
command = command_prefix + 'redis-2.2.8';
|
||||
break;
|
||||
// match imagick
|
||||
case /^imagick$/.test(extension):
|
||||
command =
|
||||
'brew install pkg-config imagemagick' +
|
||||
pipe +
|
||||
' && ' +
|
||||
command_prefix +
|
||||
'imagick' +
|
||||
pipe;
|
||||
break;
|
||||
// match sqlite
|
||||
case /^sqlite$/.test(extension):
|
||||
extension = 'sqlite3';
|
||||
@ -239,7 +229,7 @@ export async function addExtension(
|
||||
case 'win32':
|
||||
return script + (await addExtensionWindows(extension_csv, version));
|
||||
case 'darwin':
|
||||
return script + (await addExtensionDarwin(extension_csv, version, pipe));
|
||||
return script + (await addExtensionDarwin(extension_csv, version));
|
||||
case 'linux':
|
||||
return script + (await addExtensionLinux(extension_csv, version, pipe));
|
||||
default:
|
||||
|
@ -5,7 +5,6 @@ import * as coverage from './coverage';
|
||||
import * as extensions from './extensions';
|
||||
import * as tools from './tools';
|
||||
import * as utils from './utils';
|
||||
import * as matchers from './matchers';
|
||||
|
||||
/**
|
||||
* Build the script
|
||||
@ -20,6 +19,8 @@ export async function build(
|
||||
os_version: string
|
||||
): Promise<string> {
|
||||
// taking inputs
|
||||
const name = 'setup-php';
|
||||
const url = 'https://setup-php.com/support';
|
||||
const extension_csv: string =
|
||||
(await utils.getInput('extensions', false)) ||
|
||||
(await utils.getInput('extension', false)) ||
|
||||
@ -50,6 +51,9 @@ export async function build(
|
||||
script += await config.addINIValues(ini_values_csv, os_version);
|
||||
}
|
||||
|
||||
script += '\n' + (await utils.stepLog('Support this project', os_version));
|
||||
script += '\n' + (await utils.addLog('$tick', name, url, os_version));
|
||||
|
||||
return await utils.writeScript(filename, script);
|
||||
}
|
||||
|
||||
@ -58,9 +62,18 @@ export async function build(
|
||||
*/
|
||||
export async function run(): Promise<void> {
|
||||
try {
|
||||
core.warning(
|
||||
'setup-php v1 is deprecated.\nPlease upgrade to v2 - https://github.com/shivammathur/setup-php/wiki/Switch-to-v2'
|
||||
);
|
||||
const os_version: string = process.platform;
|
||||
let version: string = await utils.getInput('php-version', true);
|
||||
version = version.length > 1 ? version.slice(0, 3) : version + '.0';
|
||||
if (version == '8.1') {
|
||||
core.setFailed(
|
||||
'PHP 8.1 is not supported on setup-php v1.\nPlease upgrade to v2 - https://github.com/shivammathur/setup-php/wiki/Switch-to-v2'
|
||||
);
|
||||
return;
|
||||
}
|
||||
// check the os version and run the respective script
|
||||
let script_path = '';
|
||||
switch (os_version) {
|
||||
@ -74,7 +87,6 @@ export async function run(): Promise<void> {
|
||||
await exec('pwsh ' + script_path + ' ' + version + ' ' + __dirname);
|
||||
break;
|
||||
}
|
||||
await matchers.addMatchers();
|
||||
} catch (error) {
|
||||
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);
|
||||
}
|
@ -40,12 +40,12 @@ pecl_install() {
|
||||
yes '' | sudo pecl install -f "$extension" >/dev/null 2>&1
|
||||
}
|
||||
|
||||
# Fuction to get the PECL version
|
||||
# Function to get the PECL version
|
||||
get_pecl_version() {
|
||||
extension=$1
|
||||
stability="$(echo "$2" | grep -m 1 -Eio "(alpha|beta|rc|snapshot)")"
|
||||
stability="$(echo "$2" | grep -m 1 -Eio "(alpha|beta|rc|snapshot|preview)")"
|
||||
pecl_rest='https://pecl.php.net/rest/r/'
|
||||
response=$(curl -sL "$pecl_rest$extension"/allreleases.xml)
|
||||
response=$(curl "${curl_opts[@]}" "$pecl_rest$extension"/allreleases.xml)
|
||||
pecl_version=$(echo "$response" | grep -m 1 -Eio "(\d*\.\d*\.\d*$stability\d*)")
|
||||
if [ ! "$pecl_version" ]; then
|
||||
pecl_version=$(echo "$response" | grep -m 1 -Eo "(\d*\.\d*\.\d*)")
|
||||
@ -58,7 +58,7 @@ add_pecl_extension() {
|
||||
extension=$1
|
||||
pecl_version=$2
|
||||
prefix=$3
|
||||
if [[ $pecl_version =~ .*(alpha|beta|rc|snapshot).* ]]; then
|
||||
if [[ $pecl_version =~ .*(alpha|beta|rc|snapshot|preview).* ]]; then
|
||||
pecl_version=$(get_pecl_version "$extension" "$pecl_version")
|
||||
fi
|
||||
if ! check_extension "$extension" && [ -e "$ext_dir/$extension.so" ]; then
|
||||
@ -124,7 +124,7 @@ configure_composer() {
|
||||
exit 1;
|
||||
fi
|
||||
composer -q global config process-timeout 0
|
||||
echo "::add-path::/Users/$USER/.composer/vendor/bin"
|
||||
echo "$composer_bin" >> "$GITHUB_PATH"
|
||||
if [ -n "$COMPOSER_TOKEN" ]; then
|
||||
composer -q global config github-oauth.github.com "$COMPOSER_TOKEN"
|
||||
fi
|
||||
@ -138,8 +138,17 @@ add_tool() {
|
||||
if [ ! -e "$tool_path" ]; then
|
||||
rm -rf "$tool_path"
|
||||
fi
|
||||
|
||||
status_code=$(sudo curl -s -w "%{http_code}" -o "$tool_path" -L "$url")
|
||||
if [ "$tool" = "composer" ]; then
|
||||
IFS="," read -r -a urls <<< "$url"
|
||||
status_code=$(sudo curl -f -w "%{http_code}" -o "$tool_path" "${curl_opts[@]}" "${urls[0]}") ||
|
||||
status_code=$(sudo curl -w "%{http_code}" -o "$tool_path" "${curl_opts[@]}" "${urls[1]}")
|
||||
else
|
||||
status_code=$(sudo curl -w "%{http_code}" -o "$tool_path" "${curl_opts[@]}" "$url")
|
||||
fi
|
||||
if [ "$status_code" != "200" ] && [[ "$url" =~ .*github.com.*releases.*latest.* ]]; then
|
||||
url=$(echo $url | sed -e "s|releases/latest/download|releases/download/$(curl "${curl_opts[@]}" "$(echo "$url" | cut -d '/' -f '1-5')/releases" | grep -Eo -m 1 "([0-9]+\.[0-9]+\.[0-9]+)/$(echo "$url" | sed -e "s/.*\///")" | cut -d '/' -f 1)|")
|
||||
status_code=$(sudo curl -w "%{http_code}" -o "$tool_path" "${curl_opts[@]}" "$url")
|
||||
fi
|
||||
if [ "$status_code" = "200" ]; then
|
||||
sudo chmod a+x "$tool_path"
|
||||
if [ "$tool" = "composer" ]; then
|
||||
@ -171,6 +180,9 @@ add_composertool() {
|
||||
composer global require "$prefix$release" >/dev/null 2>&1 &&
|
||||
add_log "$tick" "$tool" "Added"
|
||||
) || add_log "$cross" "$tool" "Could not setup $tool"
|
||||
if [ -e "$composer_bin/composer" ]; then
|
||||
sudo cp -p "$tool_path_dir/composer" "$composer_bin"
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to configure PECL
|
||||
@ -187,8 +199,20 @@ add_pecl() {
|
||||
add_log "$tick" "PECL" "Added"
|
||||
}
|
||||
|
||||
# Function to update dependencies
|
||||
update_dependencies() {
|
||||
if [ "$version" = '8.0' ]; then
|
||||
while read -r formula; do
|
||||
curl -o "$(brew --prefix)/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/$formula.rb" "${curl_opts[@]}" "https://raw.githubusercontent.com/Homebrew/homebrew-core/master/Formula/$formula.rb" &
|
||||
to_wait+=( $! )
|
||||
done < "$(brew --prefix)/Homebrew/Library/Taps/shivammathur/homebrew-php/.github/deps/${ImageOS:?}_${ImageVersion:?}"
|
||||
wait "${to_wait[@]}"
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to setup PHP and composer
|
||||
setup_php() {
|
||||
update_dependencies
|
||||
export HOMEBREW_NO_INSTALL_CLEANUP=TRUE
|
||||
brew tap --shallow shivammathur/homebrew-php
|
||||
brew install shivammathur/php/php@"$version"
|
||||
@ -199,7 +223,10 @@ setup_php() {
|
||||
tick="✓"
|
||||
cross="✗"
|
||||
version=$1
|
||||
dist=$2
|
||||
tool_path_dir="/usr/local/bin"
|
||||
curl_opts=(-sL)
|
||||
composer_bin="$HOME/.composer/vendor/bin"
|
||||
existing_version=$(php-config --version 2>/dev/null | cut -c 1-3)
|
||||
|
||||
# Setup PHP
|
||||
@ -215,7 +242,8 @@ sudo chmod 777 "$ini_file" "$tool_path_dir"
|
||||
echo -e "date.timezone=UTC\nmemory_limit=-1" >>"$ini_file"
|
||||
ext_dir=$(php -i | grep -Ei "extension_dir => /" | sed -e "s|.*=> s*||")
|
||||
scan_dir=$(php --ini | grep additional | sed -e "s|.*: s*||")
|
||||
sudo mkdir -p "$ext_dir"
|
||||
sudo mkdir -m 777 -p "$ext_dir" "$HOME/.composer"
|
||||
semver=$(php -v | head -n 1 | cut -f 2 -d ' ')
|
||||
configure_pecl
|
||||
sudo cp "$dist"/../src/configs/*.json "$RUNNER_TOOL_CACHE/"
|
||||
add_log "$tick" "PHP" "$status PHP $semver"
|
||||
|
@ -22,7 +22,7 @@ update_ppa() {
|
||||
install_phalcon() {
|
||||
extension=$1
|
||||
version=$2
|
||||
(update_ppa && sudo DEBIAN_FRONTEND=noninteractive apt-get install -y "php$version-$extension" >/dev/null 2>&1 && add_log "$tick" "$extension" "Installed and enabled") ||
|
||||
(update_ppa && sudo DEBIAN_FRONTEND=noninteractive apt-get install -y "php$version-psr" "php$version-$extension" >/dev/null 2>&1 && add_log "$tick" "$extension" "Installed and enabled") ||
|
||||
add_log "$cross" "$extension" "Could not install $extension on PHP $semver"
|
||||
}
|
||||
|
||||
|
@ -1,3 +0,0 @@
|
||||
cd ~ && git clone --depth=1 https://github.com/xdebug/xdebug.git
|
||||
cd xdebug || echo "Failed to clone Xdebug"
|
||||
sudo ./rebuild.sh
|
@ -1,6 +0,0 @@
|
||||
cd ~ && git clone --depth=1 https://github.com/xdebug/xdebug.git
|
||||
cd xdebug || echo "Failed to clone Xdebug"
|
||||
sudo phpize
|
||||
sudo ./configure
|
||||
sudo make
|
||||
sudo cp modules/xdebug.so "$(php -i | grep "extension_dir => /opt" | sed -e "s|.*=> s*||")"
|
@ -16,13 +16,13 @@ add_log() {
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to backup and cleanup package lists.
|
||||
# Function to backup and cleanup package lists
|
||||
cleanup_lists() {
|
||||
if [ ! -e /etc/apt/sources.list.d.save ]; then
|
||||
sudo mv /etc/apt/sources.list.d /etc/apt/sources.list.d.save || true
|
||||
sudo mkdir /etc/apt/sources.list.d
|
||||
sudo mv /etc/apt/sources.list.d.save/*ondrej*.list /etc/apt/sources.list.d/ || true
|
||||
trap "sudo mv /etc/apt/sources.list.d.save/*.list /etc/apt/sources.list.d/" exit
|
||||
trap "sudo mv /etc/apt/sources.list.d.save/*.list /etc/apt/sources.list.d/ 2>/dev/null" exit
|
||||
fi
|
||||
}
|
||||
|
||||
@ -46,12 +46,12 @@ configure_pecl() {
|
||||
fi
|
||||
}
|
||||
|
||||
# Fuction to get the PECL version
|
||||
# Function to get the PECL version
|
||||
get_pecl_version() {
|
||||
extension=$1
|
||||
stability="$(echo "$2" | grep -m 1 -Eio "(alpha|beta|rc|snapshot)")"
|
||||
stability="$(echo "$2" | grep -m 1 -Eio "(alpha|beta|rc|snapshot|preview)")"
|
||||
pecl_rest='https://pecl.php.net/rest/r/'
|
||||
response=$(curl -sL "$pecl_rest$extension"/allreleases.xml)
|
||||
response=$(curl "${curl_opts[@]}" "$pecl_rest$extension"/allreleases.xml)
|
||||
pecl_version=$(echo "$response" | grep -m 1 -Pio "(\d*\.\d*\.\d*$stability\d*)")
|
||||
if [ ! "$pecl_version" ]; then
|
||||
pecl_version=$(echo "$response" | grep -m 1 -Po "(\d*\.\d*\.\d*)")
|
||||
@ -103,9 +103,12 @@ add_extension() {
|
||||
elif check_extension "$extension"; then
|
||||
add_log "$tick" "$extension" "Enabled"
|
||||
elif ! check_extension "$extension"; then
|
||||
eval "$install_command" >/dev/null 2>&1 ||
|
||||
(update_lists && eval "$install_command" >/dev/null 2>&1) ||
|
||||
sudo pecl install -f "$extension" >/dev/null 2>&1
|
||||
if [ "$version" = "8.0" ]; then
|
||||
pecl_install "$extension"
|
||||
else
|
||||
eval "$install_command" >/dev/null 2>&1 ||
|
||||
(update_lists && eval "$install_command" >/dev/null 2>&1) || pecl_install "$extension"
|
||||
fi
|
||||
(check_extension "$extension" && add_log "$tick" "$extension" "Installed and enabled") ||
|
||||
add_log "$cross" "$extension" "Could not install $extension on PHP $semver"
|
||||
fi
|
||||
@ -117,7 +120,7 @@ add_pecl_extension() {
|
||||
extension=$1
|
||||
pecl_version=$2
|
||||
prefix=$3
|
||||
if [[ $pecl_version =~ .*(alpha|beta|rc|snapshot).* ]]; then
|
||||
if [[ $pecl_version =~ .*(alpha|beta|rc|snapshot|preview).* ]]; then
|
||||
pecl_version=$(get_pecl_version "$extension" "$pecl_version")
|
||||
fi
|
||||
if ! check_extension "$extension" && [ -e "$ext_dir/$extension.so" ]; then
|
||||
@ -155,7 +158,7 @@ configure_composer() {
|
||||
exit 1;
|
||||
fi
|
||||
composer -q global config process-timeout 0
|
||||
echo "::add-path::/home/$USER/.composer/vendor/bin"
|
||||
echo "$composer_bin" >> "$GITHUB_PATH"
|
||||
if [ -n "$COMPOSER_TOKEN" ]; then
|
||||
composer -q global config github-oauth.github.com "$COMPOSER_TOKEN"
|
||||
fi
|
||||
@ -169,7 +172,17 @@ add_tool() {
|
||||
if [ ! -e "$tool_path" ]; then
|
||||
rm -rf "$tool_path"
|
||||
fi
|
||||
status_code=$(sudo curl -s -w "%{http_code}" -o "$tool_path" -L "$url")
|
||||
if [ "$tool" = "composer" ]; then
|
||||
IFS="," read -r -a urls <<< "$url"
|
||||
status_code=$(sudo curl -f -w "%{http_code}" -o "$tool_path" "${curl_opts[@]}" "${urls[0]}") ||
|
||||
status_code=$(sudo curl -w "%{http_code}" -o "$tool_path" "${curl_opts[@]}" "${urls[1]}")
|
||||
else
|
||||
status_code=$(sudo curl -w "%{http_code}" -o "$tool_path" "${curl_opts[@]}" "$url")
|
||||
fi
|
||||
if [ "$status_code" != "200" ] && [[ "$url" =~ .*github.com.*releases.*latest.* ]]; then
|
||||
url=$(echo $url | sed -e "s|releases/latest/download|releases/download/$(curl "${curl_opts[@]}" "$(echo "$url" | cut -d '/' -f '1-5')/releases" | grep -Eo -m 1 "([0-9]+\.[0-9]+\.[0-9]+)/$(echo "$url" | sed -e "s/.*\///")" | cut -d '/' -f 1)|")
|
||||
status_code=$(sudo curl -w "%{http_code}" -o "$tool_path" "${curl_opts[@]}" "$url")
|
||||
fi
|
||||
if [ "$status_code" = "200" ]; then
|
||||
sudo chmod a+x "$tool_path"
|
||||
if [ "$tool" = "composer" ]; then
|
||||
@ -184,6 +197,7 @@ add_tool() {
|
||||
add_log "$tick" "$tool" "Added"
|
||||
else
|
||||
add_log "$cross" "$tool" "Could not setup $tool"
|
||||
[ "$tool" = "composer" ] && exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
@ -196,6 +210,9 @@ add_composertool() {
|
||||
composer global require "$prefix$release" >/dev/null 2>&1 &&
|
||||
add_log "$tick" "$tool" "Added"
|
||||
) || add_log "$cross" "$tool" "Could not setup $tool"
|
||||
if [ -e "$composer_bin/composer" ]; then
|
||||
sudo cp -p "$tool_path_dir/composer" "$composer_bin"
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to setup phpize and php-config
|
||||
@ -210,7 +227,7 @@ add_devtools() {
|
||||
|
||||
# Function to setup the nightly build from master branch
|
||||
setup_master() {
|
||||
curl -sL https://github.com/shivammathur/php-builder/releases/latest/download/install.sh | bash -s "github"
|
||||
curl "${curl_opts[@]}" https://github.com/shivammathur/php-builder/releases/latest/download/install.sh | bash -s "github"
|
||||
}
|
||||
|
||||
# Function to setup PECL
|
||||
@ -247,14 +264,17 @@ cross="✗"
|
||||
lists_updated="false"
|
||||
pecl_config="false"
|
||||
version=$1
|
||||
dist=$2
|
||||
debconf_fix="DEBIAN_FRONTEND=noninteractive"
|
||||
apt_install="sudo $debconf_fix apt-fast install -y"
|
||||
tool_path_dir="/usr/local/bin"
|
||||
curl_opts=(-sL)
|
||||
composer_bin="$HOME/.composer/vendor/bin"
|
||||
existing_version=$(php-config --version 2>/dev/null | cut -c 1-3)
|
||||
|
||||
# Setup PHP
|
||||
step_log "Setup PHP"
|
||||
sudo mkdir -p /var/run /run/php
|
||||
sudo mkdir -m 777 -p "$HOME/.composer" /var/run /run/php
|
||||
. /etc/lsb-release
|
||||
if [ "$DISTRIB_RELEASE" = "20.04" ]; then
|
||||
if ! apt-cache policy | grep -q ondrej/php; then
|
||||
@ -288,5 +308,7 @@ ini_file=$(php --ini | grep "Loaded Configuration" | sed -e "s|.*:s*||" | sed "s
|
||||
ext_dir=$(php -i | grep "extension_dir => /" | sed -e "s|.*=> s*||")
|
||||
pecl_file="$scan_dir"/99-pecl.ini
|
||||
echo '' | sudo tee "$pecl_file" >/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 cp "$dist"/../src/configs/*.json "$RUNNER_TOOL_CACHE/"
|
||||
add_log "$tick" "PHP" "$status PHP $semver"
|
||||
|
@ -8,7 +8,7 @@ param (
|
||||
[ValidateNotNull()]
|
||||
[ValidateLength(1, [int]::MaxValue)]
|
||||
[string]
|
||||
$dir
|
||||
$dist
|
||||
)
|
||||
|
||||
Function Step-Log($message) {
|
||||
@ -43,15 +43,36 @@ Function Add-ToProfile {
|
||||
}
|
||||
}
|
||||
|
||||
Function Install-PhpManager() {
|
||||
$repo = "mlocati/powershell-phpmanager"
|
||||
$zip_file = "$php_dir\PhpManager.zip"
|
||||
$tag = (Invoke-RestMethod https://api.github.com/repos/$repo/tags)[0].Name
|
||||
$module_path = "$php_dir\PhpManager\powershell-phpmanager-$tag\PhpManager"
|
||||
Invoke-WebRequest -UseBasicParsing -Uri https://github.com/$repo/archive/$tag.zip -OutFile $zip_file
|
||||
Expand-Archive -Path $zip_file -DestinationPath $php_dir\PhpManager -Force
|
||||
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 "$github/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-PSPackage() {
|
||||
param(
|
||||
[Parameter(Position = 0, Mandatory = $true)]
|
||||
$package,
|
||||
[Parameter(Position = 1, Mandatory = $true)]
|
||||
$psm1_path,
|
||||
[Parameter(Position = 2, Mandatory = $true)]
|
||||
$url
|
||||
)
|
||||
$module_path = "$php_dir\$psm1_path.psm1"
|
||||
if(-not (Test-Path $module_path -PathType Leaf)) {
|
||||
$zip_file = "$php_dir\$package.zip"
|
||||
Invoke-WebRequest -UseBasicParsing -Uri $url -OutFile $zip_file
|
||||
Expand-Archive -Path $zip_file -DestinationPath $php_dir -Force
|
||||
}
|
||||
Import-Module $module_path
|
||||
Add-ToProfile $current_profile "PhpManager" "Import-Module $module_path"
|
||||
Add-ToProfile $current_profile "$package-search" "Import-Module $module_path"
|
||||
}
|
||||
|
||||
Function Add-Extension {
|
||||
@ -135,7 +156,7 @@ Function Edit-ComposerConfig() {
|
||||
exit 1;
|
||||
}
|
||||
composer -q global config process-timeout 0
|
||||
Write-Output "::add-path::$env:APPDATA\Composer\vendor\bin"
|
||||
Write-Output $composer_bin | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8
|
||||
if (Test-Path env:COMPOSER_TOKEN) {
|
||||
composer -q global config github-oauth.github.com $env:COMPOSER_TOKEN
|
||||
}
|
||||
@ -145,8 +166,6 @@ Function Add-Tool() {
|
||||
Param (
|
||||
[Parameter(Position = 0, Mandatory = $true)]
|
||||
[ValidateNotNull()]
|
||||
[ValidateLength(1, [int]::MaxValue)]
|
||||
[string]
|
||||
$url,
|
||||
[Parameter(Position = 1, Mandatory = $true)]
|
||||
[ValidateNotNull()]
|
||||
@ -157,35 +176,44 @@ Function Add-Tool() {
|
||||
if (Test-Path $php_dir\$tool) {
|
||||
Remove-Item $php_dir\$tool
|
||||
}
|
||||
if($url.Count -gt 1) { $url = $url[0] }
|
||||
if ($tool -eq "symfony") {
|
||||
Invoke-WebRequest -UseBasicParsing -Uri $url -OutFile $php_dir\$tool.exe
|
||||
Add-ToProfile $current_profile $tool "New-Alias $tool $php_dir\$tool.exe" > $null 2>&1
|
||||
Add-ToProfile $current_profile $tool "New-Alias $tool $php_dir\$tool.exe" >$null 2>&1
|
||||
} else {
|
||||
try {
|
||||
Invoke-WebRequest -UseBasicParsing -Uri $url -OutFile $php_dir\$tool
|
||||
$bat_content = @()
|
||||
$bat_content += "@ECHO off"
|
||||
$bat_content += "setlocal DISABLEDELAYEDEXPANSION"
|
||||
$bat_content += "SET BIN_TARGET=%~dp0/" + $tool
|
||||
$bat_content += "php %BIN_TARGET% %*"
|
||||
Set-Content -Path $php_dir\$tool.bat -Value $bat_content
|
||||
Add-ToProfile $current_profile $tool "New-Alias $tool $php_dir\$tool.bat" > $null 2>&1
|
||||
} catch { }
|
||||
} catch {
|
||||
if($url -match '.*github.com.*releases.*latest.*') {
|
||||
try {
|
||||
$url = $url.replace("releases/latest/download", "releases/download/" + ([regex]::match((Invoke-WebRequest -UseBasicParsing -Uri ($url.split('/release')[0] + "/releases")).Content, "([0-9]+\.[0-9]+\.[0-9]+)/" + ($url.Substring($url.LastIndexOf("/") + 1))).Groups[0].Value).split('/')[0])
|
||||
Invoke-WebRequest -UseBasicParsing -Uri $url -OutFile $php_dir\$tool
|
||||
} catch { }
|
||||
}
|
||||
}
|
||||
}
|
||||
if($tool -eq "phive") {
|
||||
Add-Extension curl >$null 2>&1
|
||||
Add-Extension mbstring >$null 2>&1
|
||||
Add-Extension xml >$null 2>&1
|
||||
} elseif($tool -eq "cs2pr") {
|
||||
(Get-Content $php_dir/cs2pr).replace('exit(9)', 'exit(0)') | Set-Content $php_dir/cs2pr
|
||||
} elseif($tool -eq "composer") {
|
||||
Edit-ComposerConfig $php_dir\$tool
|
||||
} elseif($tool -eq "wp-cli") {
|
||||
Copy-Item $php_dir\wp-cli.bat -Destination $php_dir\wp.bat
|
||||
}
|
||||
|
||||
if (((Get-ChildItem -Path $php_dir/* | Where-Object Name -Match "^$tool(.exe|.phar)*$").Count -gt 0)) {
|
||||
Add-Log $tick $tool "Added"
|
||||
$bat_content = @()
|
||||
$bat_content += "@ECHO off"
|
||||
$bat_content += "setlocal DISABLEDELAYEDEXPANSION"
|
||||
$bat_content += "SET BIN_TARGET=%~dp0/" + $tool
|
||||
$bat_content += "php %BIN_TARGET% %*"
|
||||
Set-Content -Path $php_dir\$tool.bat -Value $bat_content
|
||||
Add-ToProfile $current_profile $tool "New-Alias $tool $php_dir\$tool.bat" >$null 2>&1
|
||||
if($tool -eq "phan") {
|
||||
Add-Extension fileinfo >$null 2>&1
|
||||
Add-Extension ast >$null 2>&1
|
||||
} elseif($tool -eq "phive") {
|
||||
Add-Extension xml >$null 2>&1
|
||||
} elseif($tool -eq "cs2pr") {
|
||||
(Get-Content $php_dir/cs2pr).replace('exit(9)', 'exit(0)') | Set-Content $php_dir/cs2pr
|
||||
} elseif($tool -eq "composer") {
|
||||
Edit-ComposerConfig $php_dir\$tool
|
||||
} elseif($tool -eq "wp-cli") {
|
||||
Copy-Item $php_dir\wp-cli.bat -Destination $php_dir\wp.bat
|
||||
}
|
||||
$tool_version = Get-ToolVersion $tool $ver_param
|
||||
Add-Log $tick $tool "Added $tool $tool_version"
|
||||
} else {
|
||||
Add-Log $cross $tool "Could not add $tool"
|
||||
}
|
||||
@ -215,6 +243,9 @@ Function Add-Composertool() {
|
||||
} else {
|
||||
Add-Log $cross $tool "Could not setup $tool"
|
||||
}
|
||||
if(Test-Path $composer_bin\composer) {
|
||||
Copy-Item -Path "$php_dir\composer" -Destination "$composer_bin\composer" -Force
|
||||
}
|
||||
}
|
||||
|
||||
Function Add-Pecl() {
|
||||
@ -228,6 +259,8 @@ $php_dir = 'C:\tools\php'
|
||||
$ext_dir = "$php_dir\ext"
|
||||
$current_profile = "$PSHOME\Profile.ps1"
|
||||
$ProgressPreference = 'SilentlyContinue'
|
||||
$github = 'https://github.com'
|
||||
$composer_bin = "$env:APPDATA\Composer\vendor\bin"
|
||||
$master_version = '8.0'
|
||||
$arch = 'x64'
|
||||
$ts = $env:PHPTS -eq 'ts'
|
||||
@ -238,8 +271,9 @@ if(-not(Test-Path -LiteralPath $current_profile)) {
|
||||
New-Item -Path $current_profile -ItemType "file" -Force >$null 2>&1
|
||||
}
|
||||
|
||||
Add-Printf >$null 2>&1
|
||||
Step-Log "Setup PhpManager"
|
||||
Install-PhpManager >$null 2>&1
|
||||
Install-PSPackage PhpManager PhpManager\PhpManager "$github/mlocati/powershell-phpmanager/releases/latest/download/PhpManager.zip" >$null 2>&1
|
||||
Add-Log $tick "PhpManager" "Installed"
|
||||
|
||||
Step-Log "Setup PHP"
|
||||
@ -252,7 +286,7 @@ if (Test-Path -LiteralPath $php_dir -PathType Container) {
|
||||
$status = "Installed"
|
||||
if ($null -eq $installed -or -not("$($installed.Version).".StartsWith(($version -replace '^(\d+(\.\d+)*).*', '$1.'))) -or $ts -ne $installed.ThreadSafe) {
|
||||
if ($version -lt '7.0') {
|
||||
Install-Module -Name VcRedist -Force
|
||||
Install-PSPackage VcRedist VcRedist-main\VcRedist\VcRedist "$github/aaronparker/VcRedist/archive/main.zip" >$null 2>&1
|
||||
$arch='x86'
|
||||
}
|
||||
if ($version -eq $master_version) {
|
||||
@ -271,4 +305,6 @@ Set-PhpIniKey -Key 'date.timezone' -Value 'UTC' -Path $php_dir
|
||||
Set-PhpIniKey -Key 'memory_limit' -Value '-1' -Path $php_dir
|
||||
Enable-PhpExtension -Extension openssl, curl, opcache, mbstring -Path $php_dir
|
||||
Update-PhpCAInfo -Path $php_dir -Source CurrentUser
|
||||
Copy-Item -Path $dist\..\src\configs\*.json -Destination $env:RUNNER_TOOL_CACHE
|
||||
New-Item -ItemType Directory -Path $composer_bin -Force 2>&1 | Out-Null
|
||||
Add-Log $tick "PHP" "$status PHP $($installed.FullVersion)"
|
||||
|
67
src/tools.ts
67
src/tools.ts
@ -1,6 +1,4 @@
|
||||
import * as utils from './utils';
|
||||
import * as httpm from '@actions/http-client';
|
||||
import {IHttpClientResponse as hcr} from '@actions/http-client/interfaces';
|
||||
|
||||
/**
|
||||
* Function to get command to setup tools
|
||||
@ -284,15 +282,19 @@ export async function getSymfonyUri(
|
||||
*/
|
||||
export async function addComposer(tools_list: string[]): Promise<string[]> {
|
||||
const regex_any = /^composer($|:.*)/;
|
||||
const regex_valid = /^composer:?($|preview$|snapshot$|v?[1-2]$)/;
|
||||
const regex_valid = /^composer:?($|preview$|snapshot$|v?[1-2]$|v?\d+\.\d+\.\d+[\w-]*$)/;
|
||||
const regex_composer1_tools = /hirak|prestissimo|narrowspark|composer-prefetcher/;
|
||||
const matches: string[] = tools_list.filter(tool => regex_valid.test(tool));
|
||||
let composer = 'composer';
|
||||
tools_list = tools_list.filter(tool => !regex_any.test(tool));
|
||||
switch (matches[0]) {
|
||||
case undefined:
|
||||
switch (true) {
|
||||
case regex_composer1_tools.test(tools_list.join(' ')):
|
||||
composer = 'composer:1';
|
||||
break;
|
||||
case matches[0] == undefined:
|
||||
break;
|
||||
default:
|
||||
composer = matches[matches.length - 1].replace(/v([1-2])/, '$1');
|
||||
composer = matches[matches.length - 1].replace(/v(\d\S*)/, '$1');
|
||||
break;
|
||||
}
|
||||
tools_list.unshift(composer);
|
||||
@ -305,23 +307,20 @@ export async function addComposer(tools_list: string[]): Promise<string[]> {
|
||||
* @param version
|
||||
*/
|
||||
export async function getComposerUrl(version: string): Promise<string> {
|
||||
const getComposerUrlHelper = async function (
|
||||
version: string
|
||||
): Promise<string> {
|
||||
const client: httpm.HttpClient = new httpm.HttpClient('setup-php');
|
||||
const response: hcr = await client.get('https://getcomposer.org/versions');
|
||||
const data = JSON.parse(await response.readBody());
|
||||
return 'https://getcomposer.org' + data[version][0]['path'];
|
||||
};
|
||||
switch (version) {
|
||||
case 'snapshot':
|
||||
return 'https://getcomposer.org/composer.phar';
|
||||
case 'preview':
|
||||
case '1':
|
||||
case '2':
|
||||
return await getComposerUrlHelper(version);
|
||||
let cache_url = `https://github.com/shivammathur/composer-cache/releases/latest/download/composer-${version.replace(
|
||||
'latest',
|
||||
'stable'
|
||||
)}.phar`;
|
||||
switch (true) {
|
||||
case /^snapshot$/.test(version):
|
||||
return `${cache_url},https://getcomposer.org/composer.phar`;
|
||||
case /^preview$|^[1-2]$/.test(version):
|
||||
return `${cache_url},https://getcomposer.org/composer-${version}.phar`;
|
||||
case /^\d+\.\d+\.\d+[\w-]*$/.test(version):
|
||||
cache_url = `https://github.com/composer/composer/releases/download/${version}/composer.phar`;
|
||||
return `${cache_url},https://getcomposer.org/composer-${version}.phar`;
|
||||
default:
|
||||
return 'https://getcomposer.org/composer-stable.phar';
|
||||
return `${cache_url},https://getcomposer.org/composer-stable.phar`;
|
||||
}
|
||||
}
|
||||
|
||||
@ -349,13 +348,11 @@ export async function getCleanedToolsList(
|
||||
* Helper function to get script to setup a tool using a phar url
|
||||
*
|
||||
* @param tool
|
||||
* @param version
|
||||
* @param url
|
||||
* @param os_version
|
||||
*/
|
||||
export async function addArchive(
|
||||
tool: string,
|
||||
version: string,
|
||||
url: string,
|
||||
os_version: string
|
||||
): Promise<string> {
|
||||
@ -448,51 +445,51 @@ export async function addTools(
|
||||
case 'cs2pr':
|
||||
uri = await getUri(tool, '', version, 'releases', '', 'download');
|
||||
url = github + 'staabm/annotate-pull-request-from-checkstyle/' + uri;
|
||||
script += await addArchive(tool, version, url, os_version);
|
||||
script += await addArchive(tool, url, os_version);
|
||||
break;
|
||||
case 'php-cs-fixer':
|
||||
uri = await getUri(tool, '.phar', version, 'releases', 'v', 'download');
|
||||
url = github + 'FriendsOfPHP/PHP-CS-Fixer/' + uri;
|
||||
script += await addArchive(tool, version, url, os_version);
|
||||
script += await addArchive(tool, url, os_version);
|
||||
break;
|
||||
case 'phpcs':
|
||||
case 'phpcbf':
|
||||
url = github + 'squizlabs/PHP_CodeSniffer/' + uri;
|
||||
script += await addArchive(tool, version, url, os_version);
|
||||
script += await addArchive(tool, url, os_version);
|
||||
break;
|
||||
case 'phive':
|
||||
script += await addPhive(version, os_version);
|
||||
break;
|
||||
case 'phpstan':
|
||||
url = github + 'phpstan/phpstan/' + uri;
|
||||
script += await addArchive(tool, version, url, os_version);
|
||||
script += await addArchive(tool, url, os_version);
|
||||
break;
|
||||
case 'phpmd':
|
||||
url = github + 'phpmd/phpmd/' + uri;
|
||||
script += await addArchive(tool, version, url, os_version);
|
||||
script += await addArchive(tool, url, os_version);
|
||||
break;
|
||||
case 'psalm':
|
||||
url = github + 'vimeo/psalm/' + uri;
|
||||
script += await addArchive(tool, version, url, os_version);
|
||||
script += await addArchive(tool, url, os_version);
|
||||
break;
|
||||
case 'composer':
|
||||
url = await getComposerUrl(version);
|
||||
script += await addArchive('composer', version, url, os_version);
|
||||
script += await addArchive('composer', url, os_version);
|
||||
break;
|
||||
case 'codeception':
|
||||
url =
|
||||
'https://codeception.com/' +
|
||||
(await getCodeceptionUri(version, php_version));
|
||||
script += await addArchive(tool, version, url, os_version);
|
||||
script += await addArchive(tool, url, os_version);
|
||||
break;
|
||||
case 'phpcpd':
|
||||
case 'phpunit':
|
||||
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;
|
||||
case 'deployer':
|
||||
url = await getDeployerUrl(version);
|
||||
script += await addArchive(tool, version, url, os_version);
|
||||
script += await addArchive(tool, url, os_version);
|
||||
break;
|
||||
case 'phinx':
|
||||
script += await addPackage(tool, release, 'robmorgan/', os_version);
|
||||
@ -519,7 +516,7 @@ export async function addTools(
|
||||
case 'symfony-cli':
|
||||
uri = await getSymfonyUri(version, os_version);
|
||||
url = github + 'symfony/cli/' + uri;
|
||||
script += await addArchive('symfony', version, url, os_version);
|
||||
script += await addArchive('symfony', url, os_version);
|
||||
break;
|
||||
default:
|
||||
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 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.
|
||||
*
|
||||
@ -12,13 +27,17 @@ export async function getInput(
|
||||
name: string,
|
||||
mandatory: boolean
|
||||
): Promise<string> {
|
||||
const input = process.env[name];
|
||||
switch (input) {
|
||||
case '':
|
||||
case undefined:
|
||||
return core.getInput(name, {required: mandatory});
|
||||
default:
|
||||
const input = core.getInput(name);
|
||||
const env_input = await readEnv(name);
|
||||
switch (true) {
|
||||
case 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