mirror of
https://github.com/shivammathur/setup-php.git
synced 2025-07-04 06:03:17 +07:00
Compare commits
106 Commits
Author | SHA1 | Date | |
---|---|---|---|
fdfa901941 | |||
527cd148c8 | |||
59b6e2b54a | |||
5ad0888329 | |||
3cfc409e14 | |||
ebc671081f | |||
efae663c0f | |||
fa8a671e6f | |||
6a4159ba98 | |||
0da52b1327 | |||
3579c7ef28 | |||
d9cf6f5ad6 | |||
ea50c7c0a2 | |||
6ca549dcaa | |||
d3760be2cc | |||
3454287b87 | |||
88c7757dc8 | |||
48cfea3f3e | |||
43cfa2b1a8 | |||
76cecacc5e | |||
d6e173ffc6 | |||
26701f2ec8 | |||
e934fe28b8 | |||
d384d9fe7e | |||
4eeaf5f99e | |||
fd2392db56 | |||
494dde7189 | |||
706dfca1e6 | |||
d613c975f6 | |||
fbe1419ce4 | |||
c844c7b6e4 | |||
8e5cc09df9 | |||
f4f8aec1f2 | |||
b44b7344e0 | |||
e01b2f0bf7 | |||
f7f8ecb931 | |||
4f0d810cbc | |||
47335179aa | |||
63c4aea452 | |||
898b6fa1f9 | |||
747c8838bc | |||
9d6b61c5af | |||
5108c81610 | |||
e58c704985 | |||
e9c783eef0 | |||
b44e5e009f | |||
8489dbf4de | |||
f23ae2e6f7 | |||
d2b233e45f | |||
320474a245 | |||
65ccfb36dc | |||
88fb99b592 | |||
9e7bc5c91f | |||
ca2f547a35 | |||
9f21c80d24 | |||
c4317135df | |||
a2dd688679 | |||
bd214a2dca | |||
2ee4653d1c | |||
0b3e0f451d | |||
0bfa897634 | |||
71db1e2cf1 | |||
16d1cd4766 | |||
1193cd100b | |||
e839a77d8c | |||
552df3f2b0 | |||
3109c941eb | |||
aa8706a5bf | |||
9afdee42e8 | |||
aa0e9403d8 | |||
5b00f068f3 | |||
8f39d3eddd | |||
9d87d1fd14 | |||
07ae2343d0 | |||
7b8bf7af6a | |||
0ac6f76d36 | |||
6c6203b683 | |||
0c9f8a8e7e | |||
1705daea72 | |||
58fbc33c3a | |||
3f42b7d5fb | |||
dd4f0db7bf | |||
7d026bfa6b | |||
6a70f864ec | |||
8e1cde2d0a | |||
de32d8b95f | |||
273096b82f | |||
4c045616f4 | |||
935e74fb40 | |||
a507be73b5 | |||
673dcaff6d | |||
2cbfd4fb41 | |||
0969980399 | |||
1fa2905bc6 | |||
790a48c30d | |||
4b69160eff | |||
7f805f22af | |||
f2972dcf18 | |||
2d488f53fd | |||
421187c870 | |||
1798f4d615 | |||
8039546df3 | |||
c6ad3d1a70 | |||
922f1e27b8 | |||
2d3750b36e | |||
03f36220f4 |
@ -17,7 +17,6 @@
|
|||||||
"camelcase": "off",
|
"camelcase": "off",
|
||||||
"require-atomic-updates": "off",
|
"require-atomic-updates": "off",
|
||||||
"@typescript-eslint/ban-ts-ignore": "off",
|
"@typescript-eslint/ban-ts-ignore": "off",
|
||||||
"@typescript-eslint/camelcase": "off",
|
"@typescript-eslint/camelcase": "off"
|
||||||
"@typescript-eslint/no-unused-vars": "off"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
28
.github/workflows/experimental-workflow.yml
vendored
28
.github/workflows/experimental-workflow.yml
vendored
@ -2,19 +2,13 @@ name: Experimental workflow
|
|||||||
on:
|
on:
|
||||||
pull_request:
|
pull_request:
|
||||||
branches:
|
branches:
|
||||||
- nightly
|
- releases/v1
|
||||||
- master
|
|
||||||
- develop
|
|
||||||
- verbose
|
|
||||||
paths-ignore:
|
paths-ignore:
|
||||||
- '**.md'
|
- '**.md'
|
||||||
- 'examples/**'
|
- 'examples/**'
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- nightly
|
- releases/v1
|
||||||
- master
|
|
||||||
- develop
|
|
||||||
- verbose
|
|
||||||
paths-ignore:
|
paths-ignore:
|
||||||
- '**.md'
|
- '**.md'
|
||||||
- 'examples/**'
|
- 'examples/**'
|
||||||
@ -25,13 +19,11 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
operating-system: [ubuntu-latest, ubuntu-16.04, macOS-latest]
|
operating-system: [ubuntu-latest, windows-latest, macos-latest]
|
||||||
php-versions: ['8.0']
|
php-versions: ['8.0']
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v1
|
uses: actions/checkout@v2
|
||||||
with:
|
|
||||||
fetch-depth: 1
|
|
||||||
|
|
||||||
- name: Setup Node.js 12.x
|
- name: Setup Node.js 12.x
|
||||||
uses: actions/setup-node@v1
|
uses: actions/setup-node@v1
|
||||||
@ -59,9 +51,9 @@ jobs:
|
|||||||
run: node dist/index.js
|
run: node dist/index.js
|
||||||
env:
|
env:
|
||||||
php-version: ${{ matrix.php-versions }}
|
php-version: ${{ matrix.php-versions }}
|
||||||
extensions: mbstring, xdebug, pcov #optional
|
extensions: xml, opcache, xdebug, pcov #optional
|
||||||
ini-values: post_max_size=256M, short_open_tag=On, date.timezone=Asia/Kolkata #optional
|
ini-values: post_max_size=256M, short_open_tag=On, date.timezone=Asia/Kolkata #optional
|
||||||
coverage: xdebug
|
coverage: pcov
|
||||||
|
|
||||||
- name: Testing PHP version
|
- name: Testing PHP version
|
||||||
run: |
|
run: |
|
||||||
@ -76,17 +68,19 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
php -m
|
php -m
|
||||||
php -r "if(! extension_loaded('mbstring')) {throw new Exception('mbstring not found');}"
|
php -r "if(! extension_loaded('mbstring')) {throw new Exception('mbstring not found');}"
|
||||||
# php -r "if(! extension_loaded('Xdebug')) {throw new Exception('Xdebug not found');}"
|
|
||||||
php -r "if(! extension_loaded('pcov')) {throw new Exception('PCOV not found');}"
|
php -r "if(! extension_loaded('pcov')) {throw new Exception('PCOV not found');}"
|
||||||
- name: Testing ini values
|
- name: Testing ini values
|
||||||
run: |
|
run: |
|
||||||
php -r "if(ini_get('post_max_size')!='256M') {throw new Exception('post_max_size not added');}"
|
php -r "if(ini_get('post_max_size')!='256M') {throw new Exception('post_max_size not added');}"
|
||||||
php -r "if(ini_get('short_open_tag')!=1) {throw new Exception('short_open_tag not added');}"
|
php -r "if(ini_get('short_open_tag')!=1) {throw new Exception('short_open_tag not added');}"
|
||||||
php -r "if(ini_get('date.timezone')!='Asia/Kolkata') {throw new Exception('date.timezone not added');}"
|
php -r "if(ini_get('date.timezone')!='Asia/Kolkata') {throw new Exception('date.timezone not added');}"
|
||||||
- name: Test and Benchmark JIT
|
- name: Test JIT
|
||||||
run: |
|
run: |
|
||||||
php -r "if(! extension_loaded('Zend OPcache')) {throw new Exception('Zend OPcache not found');}"
|
php -r "if(! extension_loaded('Zend OPcache')) {throw new Exception('Zend OPcache not found');}"
|
||||||
php -r "if(ini_get('opcache.jit_buffer_size')!='256M') {throw new Exception('opcache.jit_buffer_size not set');}"
|
php -r "if(ini_get('opcache.jit_buffer_size')!='256M') {throw new Exception('opcache.jit_buffer_size not set');}"
|
||||||
php -r "if(ini_get('opcache.jit')!=1235) {throw new Exception('opcache.jit not set');}"
|
php -r "if(ini_get('opcache.jit')!=1235) {throw new Exception('opcache.jit not set');}"
|
||||||
php -r "if(ini_get('pcre.jit')!=1) {throw new Exception('pcre.jit not set');}"
|
php -r "if(ini_get('pcre.jit')!=1) {throw new Exception('pcre.jit not set');}"
|
||||||
curl https://raw.githubusercontent.com/php/php-src/master/Zend/bench.php | php
|
- name: Benchmark JIT
|
||||||
|
run: |
|
||||||
|
curl -o bench.php https://raw.githubusercontent.com/php/php-src/master/Zend/bench.php
|
||||||
|
php bench.php
|
18
.github/workflows/workflow.yml
vendored
18
.github/workflows/workflow.yml
vendored
@ -2,17 +2,13 @@ name: Main workflow
|
|||||||
on:
|
on:
|
||||||
pull_request:
|
pull_request:
|
||||||
branches:
|
branches:
|
||||||
- master
|
- releases/v1
|
||||||
- develop
|
|
||||||
- verbose
|
|
||||||
paths-ignore:
|
paths-ignore:
|
||||||
- '**.md'
|
- '**.md'
|
||||||
- 'examples/**'
|
- 'examples/**'
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- master
|
- releases/v1
|
||||||
- develop
|
|
||||||
- verbose
|
|
||||||
paths-ignore:
|
paths-ignore:
|
||||||
- '**.md'
|
- '**.md'
|
||||||
- 'examples/**'
|
- 'examples/**'
|
||||||
@ -23,13 +19,11 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
operating-system: [ubuntu-latest, windows-latest, macOS-latest]
|
operating-system: [ubuntu-latest, windows-latest, macos-latest]
|
||||||
php-versions: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4']
|
php-versions: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4']
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v1
|
uses: actions/checkout@v2
|
||||||
with:
|
|
||||||
fetch-depth: 1
|
|
||||||
|
|
||||||
- name: Setup Node.js 12.x
|
- name: Setup Node.js 12.x
|
||||||
uses: actions/setup-node@v1
|
uses: actions/setup-node@v1
|
||||||
@ -57,7 +51,7 @@ jobs:
|
|||||||
run: node dist/index.js
|
run: node dist/index.js
|
||||||
env:
|
env:
|
||||||
php-version: ${{ matrix.php-versions }}
|
php-version: ${{ matrix.php-versions }}
|
||||||
extensions: mbstring, xdebug, pcov #optional
|
extensions: xml, opcache, xdebug, pcov #optional
|
||||||
ini-values: post_max_size=256M, short_open_tag=On, date.timezone=Asia/Kolkata #optional
|
ini-values: post_max_size=256M, short_open_tag=On, date.timezone=Asia/Kolkata #optional
|
||||||
|
|
||||||
- name: Testing PHP version
|
- name: Testing PHP version
|
||||||
@ -72,7 +66,7 @@ jobs:
|
|||||||
- name: Testing Extensions
|
- name: Testing Extensions
|
||||||
run: |
|
run: |
|
||||||
php -m
|
php -m
|
||||||
php -r "if(! extension_loaded('mbstring')) {throw new Exception('mbstring not found');}"
|
php -r "if(! extension_loaded('xml')) {throw new Exception('xml not found');}"
|
||||||
php -r "if(! extension_loaded('Xdebug')) {throw new Exception('Xdebug not found');}"
|
php -r "if(! extension_loaded('Xdebug')) {throw new Exception('Xdebug not found');}"
|
||||||
php -r "if(phpversion()>=7.1 && ! extension_loaded('pcov')) {throw new Exception('PCOV not found');}"
|
php -r "if(phpversion()>=7.1 && ! extension_loaded('pcov')) {throw new Exception('PCOV not found');}"
|
||||||
- name: Testing ini values
|
- name: Testing ini values
|
||||||
|
2
LICENSE
2
LICENSE
@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
The MIT License (MIT)
|
The MIT License (MIT)
|
||||||
|
|
||||||
Copyright (c) 2019 shivammathur and contributors
|
Copyright (c) 2019-2020 shivammathur and contributors
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
170
README.md
170
README.md
@ -13,21 +13,25 @@
|
|||||||
<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>
|
||||||
|
|
||||||
Setup PHP with required extensions, php.ini configuration, code-coverage support and composer in [GitHub Actions](https://github.com/features/actions "GitHub Actions"). This action gives you a cross platform interface to setup the PHP environment you need to test your application. Refer to [Usage](#memo-usage "How to use this") section and [examples](#examples "Examples of use") to see how to use this.
|
Setup PHP with required extensions, php.ini configuration, code-coverage support and various tools like composer in [GitHub Actions](https://github.com/features/actions "GitHub Actions"). This action gives you a cross platform interface to setup the PHP environment you need to test your application. Refer to [Usage](#memo-usage "How to use this") section and [examples](#examples "Examples of use") to see how to use this.
|
||||||
|
|
||||||
## Contents
|
## Contents
|
||||||
|
|
||||||
- [PHP Support](#tada-php-support)
|
- [PHP Support](#tada-php-support)
|
||||||
- [OS/Platform Support](#cloud-osplatform-support)
|
- [OS/Platform Support](#cloud-osplatform-support)
|
||||||
- [PHP Extension Support](#wrench-php-extension-support)
|
- [PHP Extension Support](#heavy_plus_sign-php-extension-support)
|
||||||
|
- [Tools Support](#wrench-tools-support)
|
||||||
- [Coverage support](#signal_strength-coverage-support)
|
- [Coverage support](#signal_strength-coverage-support)
|
||||||
- [Xdebug](#xdebug)
|
- [Xdebug](#xdebug)
|
||||||
- [PCOV](#pcov)
|
- [PCOV](#pcov)
|
||||||
- [Disable coverage](#disable-coverage)
|
- [Disable coverage](#disable-coverage)
|
||||||
- [Usage](#memo-usage)
|
- [Usage](#memo-usage)
|
||||||
- [Basic Usage](#basic-usage)
|
- [Basic Setup](#basic-setup)
|
||||||
- [Matrix Testing](#matrix-testing)
|
- [Matrix Setup](#matrix-setup)
|
||||||
|
- [Experimental Setup](#experimental-setup)
|
||||||
|
- [Thread Safe Setup](#thread-safe-setup)
|
||||||
- [Cache dependencies](#cache-dependencies)
|
- [Cache dependencies](#cache-dependencies)
|
||||||
|
- [Problem Matchers](#problem-matchers)
|
||||||
- [Examples](#examples)
|
- [Examples](#examples)
|
||||||
- [License](#scroll-license)
|
- [License](#scroll-license)
|
||||||
- [Contributions](#1-contributions)
|
- [Contributions](#1-contributions)
|
||||||
@ -47,7 +51,7 @@ Setup PHP with required extensions, php.ini configuration, code-coverage support
|
|||||||
|7.4|`Stable`|`Active`|
|
|7.4|`Stable`|`Active`|
|
||||||
|8.0|`Experimental`|`In development`|
|
|8.0|`Experimental`|`In development`|
|
||||||
|
|
||||||
**Note:** Specifying `8.0` in `php-version` input installs `PHP 8.0.0-dev`. This is an experimental feature on this action available on `ubuntu` and `macOS`. Currently some extensions might not be available for this version.
|
**Note:** Specifying `8.0` in `php-version` input installs a nightly build of `PHP 8.0.0-dev` with `PHP JIT`, `Union Types v2` and other [new features](https://wiki.php.net/rfc#php_80 "New features implemented in PHP 8"). See [experimental setup](#experimental-setup) for more information.
|
||||||
|
|
||||||
## :cloud: OS/Platform Support
|
## :cloud: OS/Platform Support
|
||||||
|
|
||||||
@ -56,21 +60,51 @@ Setup PHP with required extensions, php.ini configuration, code-coverage support
|
|||||||
|Windows Server 2019|`windows-latest` or `windows-2019`|
|
|Windows Server 2019|`windows-latest` or `windows-2019`|
|
||||||
|Ubuntu 18.04|`ubuntu-latest` or `ubuntu-18.04`|
|
|Ubuntu 18.04|`ubuntu-latest` or `ubuntu-18.04`|
|
||||||
|Ubuntu 16.04|`ubuntu-16.04`|
|
|Ubuntu 16.04|`ubuntu-16.04`|
|
||||||
|macOS X Catalina 10.15|`macOS-latest` or `macOS-10.15`|
|
|macOS X Catalina 10.15|`macos-latest` or `macos-10.15`|
|
||||||
|
|
||||||
## :wrench: PHP Extension Support
|
## :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: true`.
|
- 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.
|
||||||
- On `windows` extensions which have `windows` binary on `PECL` can be installed.
|
- On `windows` extensions which have `windows` binary on `PECL` can be installed.
|
||||||
- On `macOS` extensions which are on `PECL` can be installed.
|
- On `macOS` extensions which are on `PECL` can be installed.
|
||||||
- Extensions which are installed along with PHP if specified are enabled.
|
- Extensions which are installed along with PHP if specified are enabled.
|
||||||
|
- Extensions on `PECL` which do not have a latest stable version, their pre-release versions can be installed by suffixing the extension with its state i.e `alpha`, `beta`, `devel` or `snapshot` separated by a `-` like `msgpack-beta`.
|
||||||
- Extensions which cannot be installed gracefully leave an error message in the logs, the action is not interrupted.
|
- Extensions which cannot be installed gracefully leave an error message in the logs, the action is not interrupted.
|
||||||
|
|
||||||
|
## :wrench: Tools Support
|
||||||
|
|
||||||
|
These tools can be setup globally using the `tools` input.
|
||||||
|
|
||||||
|
`codeception`, `composer`, `composer-prefetcher`, `cs2pr`, `deployer`, `pecl`, `phinx`, `phive`, `phpcbf`, `phpcpd`, `php-config`, `php-cs-fixer`, `phpcs`, `phpize`, `phpmd`, `phpstan`, `phpunit`, `prestissimo`, `psalm`, `symfony`
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
uses: shivammathur/setup-php@v1
|
||||||
|
with:
|
||||||
|
php-version: '7.4'
|
||||||
|
tools: php-cs-fixer, phpunit
|
||||||
|
```
|
||||||
|
|
||||||
|
To setup a particular version of a tool, specify it in the form `tool:version`.
|
||||||
|
Version should be in semver format and a valid release of the tool.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
uses: shivammathur/setup-php@v1
|
||||||
|
with:
|
||||||
|
php-version: '7.4'
|
||||||
|
tools: php-cs-fixer:2.15.5, phpunit:8.5.1
|
||||||
|
```
|
||||||
|
|
||||||
|
**Note**
|
||||||
|
- `composer` is setup by default.
|
||||||
|
- Specifying version for `composer` and `pecl` has no effect, latest version of both tools will be setup.
|
||||||
|
- If the version specified for the tool is not in semver format, latest version of the tool will be setup.
|
||||||
|
- Tools which cannot be installed gracefully leave an error message in the logs, the action is not interrupted.
|
||||||
|
|
||||||
## :signal_strength: Coverage support
|
## :signal_strength: Coverage support
|
||||||
|
|
||||||
### Xdebug
|
### Xdebug
|
||||||
|
|
||||||
Specify `coverage: xdebug` to use `Xdebug`.
|
Specify `coverage: xdebug` to use `Xdebug`.
|
||||||
Runs on all [PHP versions supported](#tada-php-support "List of PHP versions supported on this GitHub Action")
|
Runs on all [PHP versions supported](#tada-php-support "List of PHP versions supported on this GitHub Action") except `8.0`.
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
uses: shivammathur/setup-php@v1
|
uses: shivammathur/setup-php@v1
|
||||||
@ -81,7 +115,7 @@ with:
|
|||||||
|
|
||||||
### PCOV
|
### PCOV
|
||||||
|
|
||||||
Specify `coverage: pcov` to use `PCOV`.
|
Specify `coverage: pcov` to use `PCOV` and disable `Xdebug`.
|
||||||
It is much faster than `Xdebug`.
|
It is much faster than `Xdebug`.
|
||||||
`PCOV` needs `PHP >= 7.1`.
|
`PCOV` needs `PHP >= 7.1`.
|
||||||
If your source code directory is other than `src`, `lib` or, `app`, specify `pcov.directory` using the `ini-values` input.
|
If your source code directory is other than `src`, `lib` or, `app`, specify `pcov.directory` using the `ini-values` input.
|
||||||
@ -101,7 +135,7 @@ Specify `coverage: none` to disable both `Xdebug` and `PCOV`.
|
|||||||
Consider disabling the coverage using this PHP action for these reasons.
|
Consider disabling the coverage using this PHP action for these reasons.
|
||||||
|
|
||||||
- You are not generating coverage reports while testing.
|
- You are not generating coverage reports while testing.
|
||||||
- It will disable `Xdebug`, which will have a positive impact on PHP performance.
|
- It will remove `Xdebug`, which will have a positive impact on PHP performance.
|
||||||
- You are using `phpdbg` for running your tests.
|
- You are using `phpdbg` for running your tests.
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
@ -119,18 +153,18 @@ Inputs supported by this GitHub Action.
|
|||||||
- extensions `optional`
|
- extensions `optional`
|
||||||
- ini-values `optional`
|
- ini-values `optional`
|
||||||
- coverage `optional`
|
- coverage `optional`
|
||||||
- pecl `optional`
|
- tools `optional`
|
||||||
|
|
||||||
See [action.yml](action.yml "Metadata for this GitHub Action") and usage below for more info.
|
See [action.yml](action.yml "Metadata for this GitHub Action") and usage below for more info.
|
||||||
|
|
||||||
### Basic Usage
|
### Basic Setup
|
||||||
|
|
||||||
> Setup a particular PHP version
|
> Setup a particular PHP version.
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v1
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
- name: Setup PHP
|
- name: Setup PHP
|
||||||
uses: shivammathur/setup-php@v1
|
uses: shivammathur/setup-php@v1
|
||||||
@ -139,12 +173,12 @@ steps:
|
|||||||
extensions: mbstring, intl #optional, setup extensions
|
extensions: mbstring, intl #optional, setup extensions
|
||||||
ini-values: post_max_size=256M, short_open_tag=On #optional, setup php.ini configuration
|
ini-values: post_max_size=256M, short_open_tag=On #optional, setup php.ini configuration
|
||||||
coverage: xdebug #optional, setup coverage driver
|
coverage: xdebug #optional, setup coverage driver
|
||||||
pecl: false #optional, setup PECL
|
tools: php-cs-fixer, phpunit #optional, setup tools globally
|
||||||
```
|
```
|
||||||
|
|
||||||
### Matrix Testing
|
### Matrix Setup
|
||||||
|
|
||||||
> Setup multiple PHP versions
|
> Setup multiple PHP versions on multiple operating systems.
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
jobs:
|
jobs:
|
||||||
@ -152,12 +186,12 @@ jobs:
|
|||||||
runs-on: ${{ matrix.operating-system }}
|
runs-on: ${{ matrix.operating-system }}
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
operating-system: [ubuntu-latest, windows-latest, macOS-latest]
|
operating-system: [ubuntu-latest, windows-latest, macos-latest]
|
||||||
php-versions: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4']
|
php-versions: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4']
|
||||||
name: PHP ${{ matrix.php-versions }} Test on ${{ matrix.operating-system }}
|
name: PHP ${{ matrix.php-versions }} Test on ${{ matrix.operating-system }}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v1
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
- name: Setup PHP
|
- name: Setup PHP
|
||||||
uses: shivammathur/setup-php@v1
|
uses: shivammathur/setup-php@v1
|
||||||
@ -166,7 +200,55 @@ jobs:
|
|||||||
extensions: mbstring, intl #optional, setup extensions
|
extensions: mbstring, intl #optional, setup extensions
|
||||||
ini-values: post_max_size=256M, short_open_tag=On #optional, setup php.ini configuration
|
ini-values: post_max_size=256M, short_open_tag=On #optional, setup php.ini configuration
|
||||||
coverage: xdebug #optional, setup coverage driver
|
coverage: xdebug #optional, setup coverage driver
|
||||||
pecl: false #optional, setup PECL
|
tools: php-cs-fixer, phpunit #optional, setup tools globally
|
||||||
|
```
|
||||||
|
|
||||||
|
### Experimental Setup
|
||||||
|
|
||||||
|
> Setup a nightly build of `PHP 8.0.0-dev` from the [master branch](https://github.com/php/php-src/tree/master "Master branch on PHP source repository") of PHP.
|
||||||
|
|
||||||
|
- This version is currently in development and is an experimental feature on this action.
|
||||||
|
- `PECL` is installed by default with this version on `ubuntu`.
|
||||||
|
- Some extensions might not support this version currently.
|
||||||
|
- Refer to this [RFC](https://wiki.php.net/rfc/jit "PHP JIT RFC configuration") for configuring `PHP JIT` on this version.
|
||||||
|
- Refer to this [list of RFCs](https://wiki.php.net/rfc#php_80 "List of RFCs implemented in PHP8") implemented in this version.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Setup PHP
|
||||||
|
uses: shivammathur/setup-php@v1
|
||||||
|
with:
|
||||||
|
php-version: '8.0'
|
||||||
|
extensions: mbstring #optional, setup extensions
|
||||||
|
ini-values: opcache.jit_buffer_size=256M, opcache.jit=1235, pcre.jit=1 #optional, setup php.ini configuration
|
||||||
|
coverage: pcov #optional, setup PCOV, Xdebug does not support this version yet.
|
||||||
|
tools: php-cs-fixer, phpunit #optional, setup tools globally
|
||||||
|
```
|
||||||
|
|
||||||
|
### Thread Safe Setup
|
||||||
|
|
||||||
|
- `NTS` versions are setup by default.
|
||||||
|
- On `ubuntu` and `macOS` only NTS versions are supported.
|
||||||
|
- On `windows` both `TS` and `NTS` versions are supported.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
jobs:
|
||||||
|
run:
|
||||||
|
runs-on: windows-latest
|
||||||
|
name: Setup PHP TS on Windows
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Setup PHP
|
||||||
|
uses: shivammathur/setup-php@v1
|
||||||
|
with:
|
||||||
|
php-version: '7.4'
|
||||||
|
env:
|
||||||
|
PHPTS: ts # specify ts or nts
|
||||||
```
|
```
|
||||||
|
|
||||||
### Cache dependencies
|
### Cache dependencies
|
||||||
@ -191,12 +273,50 @@ You can persist composer's internal cache directory using the [`action/cache`](h
|
|||||||
run: composer install --prefer-dist
|
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.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Problem Matchers
|
||||||
|
|
||||||
|
#### PHPUnit
|
||||||
|
|
||||||
|
You can setup problem matchers for your `PHPUnit` output by adding this step after the `setup-php` step. This will scan the logs for failing tests and surface that information prominently in the GitHub Actions UI by creating annotations and log file decorations.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
- name: Setup Problem Matchers for PHPUnit
|
||||||
|
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Other tools
|
||||||
|
|
||||||
|
For tools that support `checkstyle` reporting like `phpstan`, `psalm`, `php-cs-fixer` and `phpcs` you can use `cs2pr` to annotate your code.
|
||||||
|
For examples refer to [cs2pr documentation](https://github.com/staabm/annotate-pull-request-from-checkstyle).
|
||||||
|
|
||||||
|
> Here is an example with `phpstan`.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
- name: Setup PHP
|
||||||
|
uses: shivammathur/setup-php@v1
|
||||||
|
with:
|
||||||
|
php-version: '7.4'
|
||||||
|
tools: cs2pr, phpstan
|
||||||
|
|
||||||
|
- name: PHPStan
|
||||||
|
run: phpstan analyse src --error-format=checkstyle | cs2pr
|
||||||
|
```
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
|
||||||
Examples for setting up this GitHub Action with different PHP Frameworks/Packages.
|
Examples for setting up this GitHub Action with different PHP Frameworks/Packages.
|
||||||
|
|
||||||
|Framework/Package|Runs on|Workflow|
|
|Framework/Package|Runs on|Workflow|
|
||||||
|--- |--- |--- |
|
|--- |--- |--- |
|
||||||
|
|CakePHP with `MySQL` and `Redis`|`ubuntu`|[cakephp-mysql.yml](./examples/cakephp-mysql.yml "GitHub Action for CakePHP with MySQL and Redis")|
|
||||||
|
|CakePHP with `PostgreSQL` and `Redis`|`ubuntu`|[cakephp-postgres.yml](./examples/cakephp-postgres.yml "GitHub Action for CakePHP with Postgres and Redis")|
|
||||||
|
|CakePHP without services|`macOS`, `ubuntu` and `windows`|[cakephp.yml](./examples/cakephp.yml "GitHub Action for CakePHP without services")|
|
||||||
|CodeIgniter|`macOS`, `ubuntu` and `windows`|[codeigniter.yml](./examples/codeigniter.yml "GitHub Action for CodeIgniter")|
|
|CodeIgniter|`macOS`, `ubuntu` and `windows`|[codeigniter.yml](./examples/codeigniter.yml "GitHub Action for CodeIgniter")|
|
||||||
|Laravel with `MySQL` and `Redis`|`ubuntu`|[laravel-mysql.yml](./examples/laravel-mysql.yml "GitHub Action for Laravel with MySQL and Redis")|
|
|Laravel with `MySQL` and `Redis`|`ubuntu`|[laravel-mysql.yml](./examples/laravel-mysql.yml "GitHub Action for Laravel with MySQL and Redis")|
|
||||||
|Laravel with `PostgreSQL` and `Redis`|`ubuntu`|[laravel-postgres.yml](./examples/laravel-postgres.yml "GitHub Action for Laravel with PostgreSQL and Redis")|
|
|Laravel with `PostgreSQL` and `Redis`|`ubuntu`|[laravel-postgres.yml](./examples/laravel-postgres.yml "GitHub Action for Laravel with PostgreSQL and Redis")|
|
||||||
@ -228,10 +348,10 @@ Contributions are welcome! See [Contributor's Guide](.github/CONTRIBUTING.md "sh
|
|||||||
|
|
||||||
If this action helped you.
|
If this action helped you.
|
||||||
|
|
||||||
- Please star the project and share it, this helps reach more people.
|
- Please star the project and share it with the community.
|
||||||
- If you blog, write about your experience using this.
|
- If you blog, write about your experience while using this action.
|
||||||
- Support this project on <a href="https://www.patreon.com/shivammathur"><img alt="Patreon" src="https://shivammathur.com/badges/patreon.svg"></a> or using <a href="https://www.paypal.me/shivammathur"><img alt="Paypal" src="https://shivammathur.com/badges/paypal.svg"></a>.
|
- I maintain this in my free time, please support me with a [Patreon](https://www.patreon.com/shivammathur "Shivam Mathur Patreon") subscription or a one time contribution using [Paypal](https://www.paypal.me/shivammathur "Shivam Mathur PayPal").
|
||||||
- If you need any help using this, reach out here <a href="https://www.codementor.io/shivammathur?utm_source=github&utm_medium=button&utm_term=shivammathur&utm_campaign=github" title="Contact Shivam Mathur on Codementor"><img alt="Contact me on Codementor" src="https://cdn.codementor.io/badges/contact_me_github.svg"></a>
|
- If you need any help using this, please contact me using [Codementor](https://www.codementor.io/shivammathur "Shivam Mathur Codementor")
|
||||||
|
|
||||||
## :bookmark: This action uses the following works
|
## :bookmark: This action uses the following works
|
||||||
|
|
||||||
|
@ -2,17 +2,15 @@ import * as coverage from '../src/coverage';
|
|||||||
|
|
||||||
jest.mock('../src/extensions', () => ({
|
jest.mock('../src/extensions', () => ({
|
||||||
addExtension: jest.fn().mockImplementation(extension => {
|
addExtension: jest.fn().mockImplementation(extension => {
|
||||||
return 'addExtension ' + extension + '\n';
|
return 'add_extension ' + extension + '\n';
|
||||||
})
|
})
|
||||||
}));
|
}));
|
||||||
|
|
||||||
describe('Config tests', () => {
|
describe('Config tests', () => {
|
||||||
it('checking addCoverage with PCOV on windows', async () => {
|
it('checking addCoverage with PCOV on windows', async () => {
|
||||||
let win32: string = await coverage.addCoverage('pcov', '7.4', 'win32');
|
let win32: string = await coverage.addCoverage('PCOV', '7.4', 'win32');
|
||||||
expect(win32).toContain('addExtension pcov');
|
expect(win32).toContain('add_extension pcov');
|
||||||
expect(win32).toContain(
|
expect(win32).toContain('Remove-Extension xdebug');
|
||||||
'if(php -m | findstr -i xdebug) { Disable-PhpExtension xdebug C:\\tools\\php'
|
|
||||||
);
|
|
||||||
|
|
||||||
win32 = await coverage.addCoverage('pcov', '7.0', 'win32');
|
win32 = await coverage.addCoverage('pcov', '7.0', 'win32');
|
||||||
expect(win32).toContain('PHP 7.1 or newer is required');
|
expect(win32).toContain('PHP 7.1 or newer is required');
|
||||||
@ -23,19 +21,19 @@ describe('Config tests', () => {
|
|||||||
|
|
||||||
it('checking addCoverage with PCOV on linux', async () => {
|
it('checking addCoverage with PCOV on linux', async () => {
|
||||||
const linux: string = await coverage.addCoverage('pcov', '7.4', 'linux');
|
const linux: string = await coverage.addCoverage('pcov', '7.4', 'linux');
|
||||||
expect(linux).toContain('addExtension pcov');
|
expect(linux).toContain('add_extension pcov');
|
||||||
expect(linux).toContain('sudo sed -i "/xdebug/d" $ini_file');
|
expect(linux).toContain('remove_extension xdebug');
|
||||||
expect(linux).toContain('sudo phpdismod -v 7.4 xdebug');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('checking addCoverage with PCOV on darwin', async () => {
|
it('checking addCoverage with PCOV on darwin', async () => {
|
||||||
const darwin: string = await coverage.addCoverage('pcov', '7.4', 'darwin');
|
const darwin: string = await coverage.addCoverage('pcov', '7.4', 'darwin');
|
||||||
expect(darwin).toContain('addExtension pcov');
|
expect(darwin).toContain('add_extension pcov');
|
||||||
|
expect(darwin).toContain('remove_extension xdebug');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('checking addCoverage with Xdebug on windows', async () => {
|
it('checking addCoverage with Xdebug on windows', async () => {
|
||||||
const win32: string = await coverage.addCoverage('xdebug', '7.4', 'win32');
|
const win32: string = await coverage.addCoverage('xdebug', '7.4', 'win32');
|
||||||
expect(win32).toContain('addExtension xdebug');
|
expect(win32).toContain('add_extension xdebug');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('checking addCoverage with Xdebug on windows', async () => {
|
it('checking addCoverage with Xdebug on windows', async () => {
|
||||||
@ -45,7 +43,7 @@ describe('Config tests', () => {
|
|||||||
|
|
||||||
it('checking addCoverage with Xdebug on linux', async () => {
|
it('checking addCoverage with Xdebug on linux', async () => {
|
||||||
const linux: string = await coverage.addCoverage('xdebug', '7.4', 'linux');
|
const linux: string = await coverage.addCoverage('xdebug', '7.4', 'linux');
|
||||||
expect(linux).toContain('addExtension xdebug');
|
expect(linux).toContain('add_extension xdebug');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('checking addCoverage with Xdebug on linux', async () => {
|
it('checking addCoverage with Xdebug on linux', async () => {
|
||||||
@ -59,7 +57,7 @@ describe('Config tests', () => {
|
|||||||
'7.4',
|
'7.4',
|
||||||
'darwin'
|
'darwin'
|
||||||
);
|
);
|
||||||
expect(darwin).toContain('addExtension xdebug');
|
expect(darwin).toContain('add_extension xdebug');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('checking addCoverage with Xdebug on darwin', async () => {
|
it('checking addCoverage with Xdebug on darwin', async () => {
|
||||||
@ -73,22 +71,20 @@ describe('Config tests', () => {
|
|||||||
|
|
||||||
it('checking disableCoverage windows', async () => {
|
it('checking disableCoverage windows', async () => {
|
||||||
const win32 = await coverage.addCoverage('none', '7.4', 'win32');
|
const win32 = await coverage.addCoverage('none', '7.4', 'win32');
|
||||||
expect(win32).toContain('Disable-PhpExtension xdebug');
|
expect(win32).toContain('Remove-Extension xdebug');
|
||||||
expect(win32).toContain('Disable-PhpExtension pcov');
|
expect(win32).toContain('Remove-Extension pcov');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('checking disableCoverage on linux', async () => {
|
it('checking disableCoverage on linux', async () => {
|
||||||
const linux: string = await coverage.addCoverage('none', '7.4', 'linux');
|
const linux: string = await coverage.addCoverage('none', '7.4', 'linux');
|
||||||
expect(linux).toContain('sudo phpdismod -v 7.4 xdebug');
|
expect(linux).toContain('remove_extension xdebug');
|
||||||
expect(linux).toContain('sudo phpdismod -v 7.4 pcov');
|
expect(linux).toContain('remove_extension pcov');
|
||||||
expect(linux).toContain('sudo sed -i "/xdebug/d" $ini_file');
|
|
||||||
expect(linux).toContain('sudo sed -i "/pcov/d" $ini_file');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('checking disableCoverage on darwin', async () => {
|
it('checking disableCoverage on darwin', async () => {
|
||||||
const darwin: string = await coverage.addCoverage('none', '7.4', 'darwin');
|
const darwin: string = await coverage.addCoverage('none', '7.4', 'darwin');
|
||||||
expect(darwin).toContain('sudo sed -i \'\' "/xdebug/d" $ini_file');
|
expect(darwin).toContain('remove_extension xdebug');
|
||||||
expect(darwin).toContain('sudo sed -i \'\' "/pcov/d" $ini_file');
|
expect(darwin).toContain('remove_extension pcov');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('checking no or invalid coverage driver', async () => {
|
it('checking no or invalid coverage driver', async () => {
|
||||||
|
@ -3,20 +3,36 @@ import * as extensions from '../src/extensions';
|
|||||||
describe('Extension tests', () => {
|
describe('Extension tests', () => {
|
||||||
it('checking addExtensionOnWindows', async () => {
|
it('checking addExtensionOnWindows', async () => {
|
||||||
let win32: string = await extensions.addExtension(
|
let win32: string = await extensions.addExtension(
|
||||||
'xdebug, pcov, redis',
|
'Xdebug, pcov, sqlite, phalcon4, ast-beta',
|
||||||
'7.4',
|
'7.4',
|
||||||
'win32'
|
'win32'
|
||||||
);
|
);
|
||||||
expect(win32).toContain('Add-Extension xdebug');
|
expect(win32).toContain('Add-Extension xdebug');
|
||||||
expect(win32).toContain('Add-Extension pcov');
|
expect(win32).toContain('Add-Extension pcov');
|
||||||
expect(win32).toContain('Add-Extension redis beta');
|
expect(win32).toContain('Add-Extension sqlite3');
|
||||||
|
expect(win32).toContain('phalcon.ps1 phalcon4');
|
||||||
|
expect(win32).toContain('Add-Extension ast beta');
|
||||||
|
|
||||||
|
win32 = await extensions.addExtension('mysql', '7.4', 'win32');
|
||||||
|
expect(win32).toContain('Add-Extension mysqli');
|
||||||
|
expect(win32).toContain('Add-Extension mysqlnd');
|
||||||
|
|
||||||
|
win32 = await extensions.addExtension('mysql', '8.0', 'win32');
|
||||||
|
expect(win32).toContain('Add-Extension mysqli');
|
||||||
|
expect(win32).toContain('Add-Extension mysqlnd');
|
||||||
|
|
||||||
|
win32 = await extensions.addExtension('mysql', '5.6', 'win32');
|
||||||
|
expect(win32).toContain('Add-Extension mysql');
|
||||||
|
expect(win32).toContain('Add-Extension mysqli');
|
||||||
|
expect(win32).toContain('Add-Extension mysqlnd');
|
||||||
|
|
||||||
win32 = await extensions.addExtension(
|
win32 = await extensions.addExtension(
|
||||||
'does_not_exist',
|
'phalcon3, does_not_exist',
|
||||||
'7.2',
|
'7.2',
|
||||||
'win32',
|
'win32',
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
|
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', 'fedora');
|
||||||
@ -25,20 +41,18 @@ describe('Extension tests', () => {
|
|||||||
|
|
||||||
it('checking addExtensionOnLinux', async () => {
|
it('checking addExtensionOnLinux', async () => {
|
||||||
let linux: string = await extensions.addExtension(
|
let linux: string = await extensions.addExtension(
|
||||||
'xdebug, pcov, redis',
|
'Xdebug, pcov, sqlite, ast-beta, xdebug-alpha',
|
||||||
'7.4',
|
'7.4',
|
||||||
'linux'
|
'linux'
|
||||||
);
|
);
|
||||||
|
expect(linux).toContain('update_extension xdebug 2.9.2');
|
||||||
|
expect(linux).toContain('sudo $debconf_fix apt-get install -y php7.4-pcov');
|
||||||
expect(linux).toContain(
|
expect(linux).toContain(
|
||||||
'sudo DEBIAN_FRONTEND=noninteractive apt-get install -y php7.4-xdebug'
|
'sudo $debconf_fix apt-get install -y php7.4-sqlite3'
|
||||||
);
|
);
|
||||||
expect(linux).toContain('pecl install xdebug');
|
expect(linux).toContain('add_unstable_extension ast beta extension');
|
||||||
expect(linux).toContain(
|
expect(linux).toContain(
|
||||||
'sudo DEBIAN_FRONTEND=noninteractive apt-get install -y php7.4-pcov'
|
'add_unstable_extension xdebug alpha zend_extension'
|
||||||
);
|
|
||||||
expect(linux).toContain('pecl install pcov');
|
|
||||||
expect(linux).toContain(
|
|
||||||
'sudo DEBIAN_FRONTEND=noninteractive apt-get install -y php7.4-igbinary php7.4-redis'
|
|
||||||
);
|
);
|
||||||
|
|
||||||
linux = await extensions.addExtension('gearman', '7.0', 'linux');
|
linux = await extensions.addExtension('gearman', '7.0', 'linux');
|
||||||
@ -46,58 +60,68 @@ describe('Extension tests', () => {
|
|||||||
linux = await extensions.addExtension('gearman', '7.1', 'linux');
|
linux = await extensions.addExtension('gearman', '7.1', 'linux');
|
||||||
expect(linux).toContain('gearman.sh 7.1');
|
expect(linux).toContain('gearman.sh 7.1');
|
||||||
|
|
||||||
linux = await extensions.addExtension(
|
linux = await extensions.addExtension('gearman', '7.2', 'linux');
|
||||||
'phalcon3, phalcon4, gearman',
|
|
||||||
'7.2',
|
|
||||||
'linux'
|
|
||||||
);
|
|
||||||
expect(linux).toContain('phalcon.sh master 7.2');
|
|
||||||
expect(linux).toContain('phalcon.sh 4.0.x 7.2');
|
|
||||||
expect(linux).toContain('gearman.sh 7.2');
|
expect(linux).toContain('gearman.sh 7.2');
|
||||||
|
|
||||||
linux = await extensions.addExtension(
|
linux = await extensions.addExtension('gearman', '7.3', 'linux');
|
||||||
'phalcon3, phalcon4, gearman',
|
|
||||||
'7.3',
|
|
||||||
'linux'
|
|
||||||
);
|
|
||||||
expect(linux).toContain('phalcon.sh master 7.3');
|
|
||||||
expect(linux).toContain('phalcon.sh 4.0.x 7.3');
|
|
||||||
expect(linux).toContain('gearman.sh 7.3');
|
expect(linux).toContain('gearman.sh 7.3');
|
||||||
|
|
||||||
linux = await extensions.addExtension('phalcon4, gearman', '7.4', 'linux');
|
linux = await extensions.addExtension('gearman', '7.4', 'linux');
|
||||||
expect(linux).toContain('phalcon.sh 4.0.x 7.4');
|
|
||||||
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', 'fedora');
|
||||||
expect(linux).toContain('Platform fedora is not supported');
|
expect(linux).toContain('Platform fedora is not supported');
|
||||||
|
|
||||||
|
linux = await extensions.addExtension('phalcon3, phalcon4', '7.3', 'linux');
|
||||||
|
expect(linux).toContain('phalcon.sh phalcon3 7.3');
|
||||||
|
expect(linux).toContain('phalcon.sh phalcon4 7.3');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('checking addExtensionOnDarwin', async () => {
|
it('checking addExtensionOnDarwin', async () => {
|
||||||
let darwin: string = await extensions.addExtension(
|
let darwin: string = await extensions.addExtension(
|
||||||
'xdebug, pcov',
|
'Xdebug, pcov, sqlite, ast-beta',
|
||||||
'7.2',
|
'7.2',
|
||||||
'darwin'
|
'darwin'
|
||||||
);
|
);
|
||||||
expect(darwin).toContain('sudo pecl install xdebug');
|
expect(darwin).toContain('sudo pecl install -f xdebug');
|
||||||
expect(darwin).toContain('sudo pecl install pcov');
|
expect(darwin).toContain('sudo pecl install -f pcov');
|
||||||
|
expect(darwin).toContain('sudo pecl install -f sqlite3');
|
||||||
|
expect(darwin).toContain('add_unstable_extension ast beta extension');
|
||||||
|
|
||||||
|
darwin = await extensions.addExtension('phalcon3', '7.0', 'darwin');
|
||||||
|
expect(darwin).toContain('phalcon_darwin.sh phalcon3 7.0');
|
||||||
|
|
||||||
|
darwin = await extensions.addExtension('phalcon4', '7.3', 'darwin');
|
||||||
|
expect(darwin).toContain('phalcon_darwin.sh phalcon4 7.3');
|
||||||
|
|
||||||
darwin = await extensions.addExtension('pcov', '5.6', 'darwin');
|
darwin = await extensions.addExtension('pcov', '5.6', 'darwin');
|
||||||
expect(darwin).toContain('sudo pecl install pcov');
|
expect(darwin).toContain('sudo pecl install -f pcov');
|
||||||
|
|
||||||
darwin = await extensions.addExtension('pcov', '7.2', 'darwin');
|
darwin = await extensions.addExtension('pcov', '7.2', 'darwin');
|
||||||
expect(darwin).toContain('sudo pecl install pcov');
|
expect(darwin).toContain('sudo pecl install -f pcov');
|
||||||
|
|
||||||
darwin = await extensions.addExtension('xdebug', '5.6', 'darwin');
|
darwin = await extensions.addExtension('xdebug', '5.6', 'darwin');
|
||||||
expect(darwin).toContain('sudo pecl install xdebug-2.5.5');
|
expect(darwin).toContain('sudo pecl install -f xdebug-2.5.5');
|
||||||
|
|
||||||
|
darwin = await extensions.addExtension('xdebug', '7.0', 'darwin');
|
||||||
|
expect(darwin).toContain('sudo pecl install -f xdebug-2.9.0');
|
||||||
|
|
||||||
darwin = await extensions.addExtension('xdebug', '7.2', 'darwin');
|
darwin = await extensions.addExtension('xdebug', '7.2', 'darwin');
|
||||||
expect(darwin).toContain('sudo pecl install xdebug');
|
expect(darwin).toContain('sudo pecl install -f xdebug');
|
||||||
|
|
||||||
darwin = await extensions.addExtension('redis', '5.6', 'darwin');
|
darwin = await extensions.addExtension('redis', '5.6', 'darwin');
|
||||||
expect(darwin).toContain('sudo pecl install redis-2.2.8');
|
expect(darwin).toContain('sudo pecl install -f redis-2.2.8');
|
||||||
|
|
||||||
darwin = await extensions.addExtension('redis', '7.2', 'darwin');
|
darwin = await extensions.addExtension('redis', '7.2', 'darwin');
|
||||||
expect(darwin).toContain('sudo pecl install redis');
|
expect(darwin).toContain('sudo pecl install -f redis');
|
||||||
|
|
||||||
|
darwin = await extensions.addExtension('imagick', '5.6', 'darwin');
|
||||||
|
expect(darwin).toContain('brew install pkg-config imagemagick');
|
||||||
|
expect(darwin).toContain('sudo pecl install -f imagick');
|
||||||
|
|
||||||
|
darwin = await extensions.addExtension('imagick', '7.4', 'darwin');
|
||||||
|
expect(darwin).toContain('brew install pkg-config imagemagick');
|
||||||
|
expect(darwin).toContain('sudo pecl install -f imagick');
|
||||||
|
|
||||||
darwin = await extensions.addExtension(
|
darwin = await extensions.addExtension(
|
||||||
'does_not_exist',
|
'does_not_exist',
|
||||||
|
@ -13,8 +13,16 @@ jest.mock('../src/install', () => ({
|
|||||||
const extension_csv: string = process.env['extensions'] || '';
|
const extension_csv: string = process.env['extensions'] || '';
|
||||||
const ini_values_csv: string = process.env['ini-values'] || '';
|
const ini_values_csv: string = process.env['ini-values'] || '';
|
||||||
const coverage_driver: string = process.env['coverage'] || '';
|
const coverage_driver: string = process.env['coverage'] || '';
|
||||||
|
let tools_csv: string = process.env['tools'] || '';
|
||||||
|
const pecl: string = process.env['pecl'] || '';
|
||||||
|
if (pecl == 'true') {
|
||||||
|
tools_csv = 'pecl, ' + tools_csv;
|
||||||
|
}
|
||||||
|
|
||||||
let script = 'initial script ' + filename + version + os_version;
|
let script = 'initial script ' + filename + version + os_version;
|
||||||
|
if (tools_csv) {
|
||||||
|
script += 'add_tool';
|
||||||
|
}
|
||||||
if (extension_csv) {
|
if (extension_csv) {
|
||||||
script += 'install extensions';
|
script += 'install extensions';
|
||||||
}
|
}
|
||||||
@ -32,23 +40,17 @@ jest.mock('../src/install', () => ({
|
|||||||
async (): Promise<string> => {
|
async (): Promise<string> => {
|
||||||
const os_version: string = process.env['RUNNER_OS'] || '';
|
const os_version: string = process.env['RUNNER_OS'] || '';
|
||||||
let version: string = process.env['php-version'] || '';
|
let version: string = process.env['php-version'] || '';
|
||||||
version = version.length > 1 ? version : version + '.0';
|
version = version.length > 1 ? version.slice(0, 3) : version + '.0';
|
||||||
let script = '';
|
let script = '';
|
||||||
switch (os_version) {
|
switch (os_version) {
|
||||||
case 'darwin':
|
case 'darwin':
|
||||||
|
case 'linux':
|
||||||
script = await install.build(os_version + '.sh', version, os_version);
|
script = await install.build(os_version + '.sh', version, os_version);
|
||||||
script += 'sh script.sh ' + version + ' ' + __dirname;
|
script += 'sh script.sh ' + version + ' ' + __dirname;
|
||||||
break;
|
break;
|
||||||
case 'linux': {
|
|
||||||
const pecl: string = process.env['pecl'] || '';
|
|
||||||
script = await install.build(os_version + '.sh', version, os_version);
|
|
||||||
script += 'sh script.sh ' + version + ' ' + pecl + ' ' + __dirname;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 'win32':
|
case 'win32':
|
||||||
script = await install.build(os_version + '.sh', version, os_version);
|
script = await install.build(os_version + '.sh', version, os_version);
|
||||||
script +=
|
script += 'pwsh script.ps1 ' + version + ' ' + __dirname;
|
||||||
'pwsh script.ps1 -version ' + version + ' -dir ' + __dirname;
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
script += os_version + ' is not supported';
|
script += os_version + ' is not supported';
|
||||||
@ -67,81 +69,87 @@ jest.mock('../src/install', () => ({
|
|||||||
* @param extension_csv
|
* @param extension_csv
|
||||||
* @param ini_values_csv
|
* @param ini_values_csv
|
||||||
* @param coverage_driver
|
* @param coverage_driver
|
||||||
|
* @param tools
|
||||||
|
* @param pecl
|
||||||
*/
|
*/
|
||||||
function setEnv(
|
function setEnv(
|
||||||
version: string,
|
version: string | number,
|
||||||
os: string,
|
os: string,
|
||||||
extension_csv: string,
|
extension_csv: string,
|
||||||
ini_values_csv: string,
|
ini_values_csv: string,
|
||||||
coverage_driver: string,
|
coverage_driver: string,
|
||||||
|
tools: string,
|
||||||
pecl: string
|
pecl: string
|
||||||
): void {
|
): void {
|
||||||
process.env['php-version'] = version;
|
process.env['php-version'] = version.toString();
|
||||||
process.env['RUNNER_OS'] = os;
|
process.env['RUNNER_OS'] = os;
|
||||||
process.env['extensions'] = extension_csv;
|
process.env['extensions'] = extension_csv;
|
||||||
process.env['ini-values'] = ini_values_csv;
|
process.env['ini-values'] = ini_values_csv;
|
||||||
process.env['coverage'] = coverage_driver;
|
process.env['coverage'] = coverage_driver;
|
||||||
|
process.env['tools'] = tools;
|
||||||
process.env['pecl'] = pecl;
|
process.env['pecl'] = pecl;
|
||||||
}
|
}
|
||||||
|
|
||||||
describe('Install', () => {
|
describe('Install', () => {
|
||||||
it('Test install on windows', async () => {
|
it('Test install on windows', async () => {
|
||||||
setEnv('7.0', 'win32', '', '', '', '');
|
setEnv('7.0', 'win32', '', '', '', '', '');
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
let script: string = await install.run();
|
let script: string = await install.run();
|
||||||
expect(script).toContain('initial script');
|
expect(script).toContain('initial script');
|
||||||
expect(script).toContain('pwsh script.ps1 -version 7.0 -dir ' + __dirname);
|
expect(script).toContain('pwsh script.ps1 7.0 ' + __dirname);
|
||||||
|
|
||||||
setEnv('7.3', 'win32', '', '', '', '');
|
setEnv('7.3', 'win32', '', '', '', '', '');
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
script = await install.run();
|
script = await install.run();
|
||||||
expect(script).toContain('initial script');
|
expect(script).toContain('initial script');
|
||||||
expect(script).toContain('pwsh script.ps1 -version 7.3 -dir ' + __dirname);
|
expect(script).toContain('pwsh script.ps1 7.3 ' + __dirname);
|
||||||
|
|
||||||
setEnv('7.3', 'win32', 'a, b', 'a=b', 'x', '');
|
setEnv('7.3', 'win32', 'a, b', 'a=b', 'x', '', '');
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
script = await install.run();
|
script = await install.run();
|
||||||
expect(script).toContain('initial script');
|
expect(script).toContain('initial script');
|
||||||
expect(script).toContain('install extensions');
|
expect(script).toContain('install extensions');
|
||||||
expect(script).toContain('edit php.ini');
|
expect(script).toContain('edit php.ini');
|
||||||
expect(script).toContain('set coverage driver');
|
expect(script).toContain('set coverage driver');
|
||||||
expect(script).toContain('pwsh script.ps1 -version 7.3 -dir ' + __dirname);
|
expect(script).toContain('pwsh script.ps1 7.3 ' + __dirname);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Test install on linux', async () => {
|
it('Test install on linux', async () => {
|
||||||
setEnv('7.3', 'linux', '', '', '', '');
|
setEnv('7.3', 'linux', '', '', '', '', '');
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
let script: string = await install.run();
|
let script: string = await install.run();
|
||||||
expect(script).toContain('initial script');
|
expect(script).toContain('initial script');
|
||||||
expect(script).toContain('sh script.sh 7.3 ');
|
expect(script).toContain('sh script.sh 7.3 ');
|
||||||
|
|
||||||
setEnv('7.3', 'linux', 'a, b', 'a=b', 'x', 'true');
|
setEnv('7.3', 'linux', 'a, b', 'a=b', 'x', 'phpunit', 'true');
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
script = await install.run();
|
script = await install.run();
|
||||||
expect(script).toContain('initial script');
|
expect(script).toContain('initial script');
|
||||||
expect(script).toContain('install extensions');
|
expect(script).toContain('install extensions');
|
||||||
expect(script).toContain('edit php.ini');
|
expect(script).toContain('edit php.ini');
|
||||||
expect(script).toContain('set coverage driver');
|
expect(script).toContain('set coverage driver');
|
||||||
expect(script).toContain('sh script.sh 7.3 true');
|
expect(script).toContain('sh script.sh 7.3');
|
||||||
|
expect(script).toContain('add_tool');
|
||||||
|
|
||||||
setEnv('7.3', 'linux', 'a, b', 'a=b', 'x', 'true');
|
setEnv('7.3', 'linux', 'a, b', 'a=b', 'x', 'phpunit', '');
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
script = await install.run();
|
script = await install.run();
|
||||||
expect(script).toContain('initial script');
|
expect(script).toContain('initial script');
|
||||||
expect(script).toContain('install extensions');
|
expect(script).toContain('install extensions');
|
||||||
expect(script).toContain('edit php.ini');
|
expect(script).toContain('edit php.ini');
|
||||||
expect(script).toContain('set coverage driver');
|
expect(script).toContain('set coverage driver');
|
||||||
expect(script).toContain('sh script.sh 7.3 true');
|
expect(script).toContain('sh script.sh 7.3');
|
||||||
|
expect(script).toContain('add_tool');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Test install on darwin', async () => {
|
it('Test install on darwin', async () => {
|
||||||
setEnv('7.3', 'darwin', '', '', '', '');
|
setEnv('7.3', 'darwin', '', '', '', '', '');
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
let script: string = await install.run();
|
let script: string = await install.run();
|
||||||
expect(script).toContain('initial script');
|
expect(script).toContain('initial script');
|
||||||
expect(script).toContain('sh script.sh 7.3 ' + __dirname);
|
expect(script).toContain('sh script.sh 7.3 ' + __dirname);
|
||||||
|
|
||||||
setEnv('7.3', 'darwin', 'a, b', 'a=b', 'x', '');
|
setEnv('7.3', 'darwin', 'a, b', 'a=b', 'x', '', '');
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
script = await install.run();
|
script = await install.run();
|
||||||
expect(script).toContain('initial script');
|
expect(script).toContain('initial script');
|
||||||
@ -150,4 +158,24 @@ describe('Install', () => {
|
|||||||
expect(script).toContain('set coverage driver');
|
expect(script).toContain('set coverage driver');
|
||||||
expect(script).toContain('sh script.sh 7.3 ' + __dirname);
|
expect(script).toContain('sh script.sh 7.3 ' + __dirname);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('Test malformed version inputs', async () => {
|
||||||
|
setEnv('7.4.1', 'darwin', '', '', '', '', '');
|
||||||
|
// @ts-ignore
|
||||||
|
let script: string = await install.run();
|
||||||
|
expect(script).toContain('initial script');
|
||||||
|
expect(script).toContain('sh script.sh 7.4 ' + __dirname);
|
||||||
|
|
||||||
|
setEnv(8.0, 'darwin', '', '', '', '', '');
|
||||||
|
// @ts-ignore
|
||||||
|
script = await install.run();
|
||||||
|
expect(script).toContain('initial script');
|
||||||
|
expect(script).toContain('sh script.sh 8.0 ' + __dirname);
|
||||||
|
|
||||||
|
setEnv(8, 'darwin', '', '', '', '', '');
|
||||||
|
// @ts-ignore
|
||||||
|
script = await install.run();
|
||||||
|
expect(script).toContain('initial script');
|
||||||
|
expect(script).toContain('sh script.sh 8.0 ' + __dirname);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
24
__tests__/matchers.test.ts
Normal file
24
__tests__/matchers.test.ts
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
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);
|
||||||
|
});
|
||||||
|
});
|
488
__tests__/tools.test.ts
Normal file
488
__tests__/tools.test.ts
Normal file
@ -0,0 +1,488 @@
|
|||||||
|
import * as tools from '../src/tools';
|
||||||
|
|
||||||
|
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'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('checking getCommand', async () => {
|
||||||
|
expect(await tools.getCommand('linux', 'composertool')).toBe(
|
||||||
|
'add_composertool '
|
||||||
|
);
|
||||||
|
expect(await tools.getCommand('darwin', 'composertool')).toBe(
|
||||||
|
'add_composertool '
|
||||||
|
);
|
||||||
|
expect(await tools.getCommand('win32', 'composertool')).toBe(
|
||||||
|
'Add-Composertool '
|
||||||
|
);
|
||||||
|
expect(await tools.getCommand('fedora', 'composertool')).toContain(
|
||||||
|
'Platform fedora is not supported'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('checking getCommand', async () => {
|
||||||
|
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'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('checking parseToolVersion', async () => {
|
||||||
|
expect(await tools.getToolVersion('latest')).toBe('latest');
|
||||||
|
expect(await tools.getToolVersion('1.2.3')).toBe('1.2.3');
|
||||||
|
expect(await tools.getToolVersion('^1.2.3')).toBe('1.2.3');
|
||||||
|
expect(await tools.getToolVersion('>=1.2.3')).toBe('1.2.3');
|
||||||
|
expect(await tools.getToolVersion('>1.2.3')).toBe('1.2.3');
|
||||||
|
expect(await tools.getToolVersion('1.2.3-ALPHA')).toBe('1.2.3-ALPHA');
|
||||||
|
expect(await tools.getToolVersion('1.2.3-alpha')).toBe('1.2.3-alpha');
|
||||||
|
expect(await tools.getToolVersion('1.2.3-beta')).toBe('1.2.3-beta');
|
||||||
|
expect(await tools.getToolVersion('1.2.3-rc')).toBe('1.2.3-rc');
|
||||||
|
expect(await tools.getToolVersion('1.2.3-dev')).toBe('1.2.3-dev');
|
||||||
|
expect(await tools.getToolVersion('1.2.3-alpha1')).toBe('1.2.3-alpha1');
|
||||||
|
expect(await tools.getToolVersion('1.2.3-alpha.1')).toBe('1.2.3-alpha.1');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('checking parseToolVersion', async () => {
|
||||||
|
expect(await tools.parseTool('phpunit')).toStrictEqual({
|
||||||
|
name: 'phpunit',
|
||||||
|
version: 'latest'
|
||||||
|
});
|
||||||
|
expect(await tools.parseTool('phpunit:1.2.3')).toStrictEqual({
|
||||||
|
name: 'phpunit',
|
||||||
|
version: '1.2.3'
|
||||||
|
});
|
||||||
|
expect(await tools.parseTool('phpunit:^1.2.3')).toStrictEqual({
|
||||||
|
name: 'phpunit',
|
||||||
|
version: '1.2.3'
|
||||||
|
});
|
||||||
|
expect(await tools.parseTool('phpunit:>=1.2.3')).toStrictEqual({
|
||||||
|
name: 'phpunit',
|
||||||
|
version: '1.2.3'
|
||||||
|
});
|
||||||
|
expect(await tools.parseTool('phpunit:>1.2.3')).toStrictEqual({
|
||||||
|
name: 'phpunit',
|
||||||
|
version: '1.2.3'
|
||||||
|
});
|
||||||
|
expect(await tools.parseTool('phpunit:1.2.3-ALPHA')).toStrictEqual({
|
||||||
|
name: 'phpunit',
|
||||||
|
version: '1.2.3-ALPHA'
|
||||||
|
});
|
||||||
|
expect(await tools.parseTool('phpunit:1.2.3-alpha')).toStrictEqual({
|
||||||
|
name: 'phpunit',
|
||||||
|
version: '1.2.3-alpha'
|
||||||
|
});
|
||||||
|
expect(await tools.parseTool('phpunit:1.2.3-beta')).toStrictEqual({
|
||||||
|
name: 'phpunit',
|
||||||
|
version: '1.2.3-beta'
|
||||||
|
});
|
||||||
|
expect(await tools.parseTool('phpunit:1.2.3-rc')).toStrictEqual({
|
||||||
|
name: 'phpunit',
|
||||||
|
version: '1.2.3-rc'
|
||||||
|
});
|
||||||
|
expect(await tools.parseTool('phpunit:1.2.3-dev')).toStrictEqual({
|
||||||
|
name: 'phpunit',
|
||||||
|
version: '1.2.3-dev'
|
||||||
|
});
|
||||||
|
expect(await tools.parseTool('phpunit:1.2.3-alpha1')).toStrictEqual({
|
||||||
|
name: 'phpunit',
|
||||||
|
version: '1.2.3-alpha1'
|
||||||
|
});
|
||||||
|
expect(await tools.parseTool('phpunit:1.2.3-alpha.1')).toStrictEqual({
|
||||||
|
name: 'phpunit',
|
||||||
|
version: '1.2.3-alpha.1'
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('checking getUri', async () => {
|
||||||
|
expect(
|
||||||
|
await tools.getUri('tool', '.phar', 'latest', 'releases', '', 'download')
|
||||||
|
).toBe('releases/latest/download/tool.phar');
|
||||||
|
expect(
|
||||||
|
await tools.getUri('tool', '.phar', '1.2.3', 'releases', '', 'download')
|
||||||
|
).toBe('releases/download/1.2.3/tool.phar');
|
||||||
|
expect(
|
||||||
|
await tools.getUri('tool', '.phar', '1.2.3', 'releases', 'v', 'download')
|
||||||
|
).toBe('releases/download/v1.2.3/tool.phar');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('checking getCodeceptionUriBuilder', async () => {
|
||||||
|
expect(await tools.getCodeceptionUriBuilder('3.2.1', 'php56')).toBe(
|
||||||
|
'releases/3.2.1/php56/codecept.phar'
|
||||||
|
);
|
||||||
|
expect(await tools.getCodeceptionUriBuilder('3.2.1', 'php54')).toBe(
|
||||||
|
'releases/3.2.1/php54/codecept.phar'
|
||||||
|
);
|
||||||
|
expect(await tools.getCodeceptionUriBuilder('3.2.1', '')).toBe(
|
||||||
|
'releases/3.2.1/codecept.phar'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('checking getCodeceptionUri', async () => {
|
||||||
|
expect(await tools.getCodeceptionUri('latest', '5.6')).toBe(
|
||||||
|
'php56/codecept.phar'
|
||||||
|
);
|
||||||
|
expect(await tools.getCodeceptionUri('latest', '7.0')).toBe(
|
||||||
|
'php56/codecept.phar'
|
||||||
|
);
|
||||||
|
expect(await tools.getCodeceptionUri('latest', '7.1')).toBe(
|
||||||
|
'php56/codecept.phar'
|
||||||
|
);
|
||||||
|
expect(await tools.getCodeceptionUri('latest', '7.2')).toBe(
|
||||||
|
'codecept.phar'
|
||||||
|
);
|
||||||
|
expect(await tools.getCodeceptionUri('latest', '7.3')).toBe(
|
||||||
|
'codecept.phar'
|
||||||
|
);
|
||||||
|
expect(await tools.getCodeceptionUri('latest', '7.4')).toBe(
|
||||||
|
'codecept.phar'
|
||||||
|
);
|
||||||
|
expect(await tools.getCodeceptionUri('4.0.0', '7.4')).toBe(
|
||||||
|
'releases/4.0.0/codecept.phar'
|
||||||
|
);
|
||||||
|
expect(await tools.getCodeceptionUri('4.0.0', '5.6')).toBe(
|
||||||
|
'releases/4.0.0/php56/codecept.phar'
|
||||||
|
);
|
||||||
|
expect(await tools.getCodeceptionUri('4.0.0', '7.1')).toBe(
|
||||||
|
'releases/4.0.0/php56/codecept.phar'
|
||||||
|
);
|
||||||
|
expect(await tools.getCodeceptionUri('3.1.0', '7.4')).toBe(
|
||||||
|
'releases/3.1.0/codecept.phar'
|
||||||
|
);
|
||||||
|
expect(await tools.getCodeceptionUri('3.1.0', '5.6')).toBe(
|
||||||
|
'releases/3.1.0/php54/codecept.phar'
|
||||||
|
);
|
||||||
|
expect(await tools.getCodeceptionUri('2.5.4', '7.4')).toBe(
|
||||||
|
'releases/2.5.4/codecept.phar'
|
||||||
|
);
|
||||||
|
expect(await tools.getCodeceptionUri('2.5.4', '5.6')).toBe(
|
||||||
|
'releases/2.5.4/php54/codecept.phar'
|
||||||
|
);
|
||||||
|
expect(await tools.getCodeceptionUri('2.3.4', '7.4')).toBe(
|
||||||
|
'releases/2.3.4/codecept.phar'
|
||||||
|
);
|
||||||
|
expect(await tools.getCodeceptionUri('2.3.4', '5.4')).toBe(
|
||||||
|
'releases/2.3.4/php54/codecept.phar'
|
||||||
|
);
|
||||||
|
expect(await tools.getCodeceptionUri('2.2.4', '5.6')).toBe(
|
||||||
|
'releases/2.2.4/codecept.phar'
|
||||||
|
);
|
||||||
|
expect(await tools.getCodeceptionUri('2.2.4', '7.4')).toBe(
|
||||||
|
'releases/2.2.4/codecept.phar'
|
||||||
|
);
|
||||||
|
expect(await tools.getCodeceptionUri('2.2.4', '5.4')).toBe(
|
||||||
|
'releases/2.2.4/php54/codecept.phar'
|
||||||
|
);
|
||||||
|
expect(await tools.getCodeceptionUri('2.1.7', '5.6')).toBe(
|
||||||
|
'releases/2.1.7/codecept.phar'
|
||||||
|
);
|
||||||
|
expect(await tools.getCodeceptionUri('2.1.7', '5.4')).toBe(
|
||||||
|
'releases/2.1.7/php54/codecept.phar'
|
||||||
|
);
|
||||||
|
expect(await tools.getCodeceptionUri('2.1.5', '5.4')).toBe(
|
||||||
|
'releases/2.1.5/codecept.phar'
|
||||||
|
);
|
||||||
|
expect(await tools.getCodeceptionUri('2.1.5', '7.4')).toBe(
|
||||||
|
'releases/2.1.5/codecept.phar'
|
||||||
|
);
|
||||||
|
expect(await tools.getCodeceptionUri('1.6.9', '7.4')).toBe(
|
||||||
|
'releases/1.6.9/codecept.phar'
|
||||||
|
);
|
||||||
|
expect(await tools.getCodeceptionUri('1.5.0', '7.4')).toBe(
|
||||||
|
'releases/1.5.0/codecept.phar'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('checking addPhive', async () => {
|
||||||
|
let script: string = await tools.addPhive('1.2.3', 'linux');
|
||||||
|
expect(script).toContain(
|
||||||
|
'add_tool https://github.com/phar-io/phive/releases/download/1.2.3/phive-1.2.3.phar phive'
|
||||||
|
);
|
||||||
|
|
||||||
|
script = await tools.addPhive('latest', 'win32');
|
||||||
|
expect(script).toContain(
|
||||||
|
'Add-Tool https://phar.io/releases/phive.phar phive'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('checking getPhpunitUri', async () => {
|
||||||
|
expect(await tools.getPharUrl('domain', 'tool', '', 'latest')).toBe(
|
||||||
|
'domain/tool.phar'
|
||||||
|
);
|
||||||
|
expect(await tools.getPharUrl('domain', 'tool', 'v', '1.2.3')).toBe(
|
||||||
|
'domain/tool-v1.2.3.phar'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('checking getDeployerUri', async () => {
|
||||||
|
expect(await tools.getDeployerUrl('latest')).toBe(
|
||||||
|
'https://deployer.org/deployer.phar'
|
||||||
|
);
|
||||||
|
expect(await tools.getDeployerUrl('1.2.3')).toBe(
|
||||||
|
'https://deployer.org/releases/v1.2.3/deployer.phar'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('checking addComposer', async () => {
|
||||||
|
expect(await tools.addComposer(['a', 'b'])).toStrictEqual([
|
||||||
|
'composer',
|
||||||
|
'a',
|
||||||
|
'b'
|
||||||
|
]);
|
||||||
|
expect(await tools.addComposer(['a', 'b', 'composer'])).toStrictEqual([
|
||||||
|
'composer',
|
||||||
|
'a',
|
||||||
|
'b'
|
||||||
|
]);
|
||||||
|
expect(
|
||||||
|
await tools.addComposer(['a', 'b', 'composer:1.2.3'])
|
||||||
|
).toStrictEqual(['composer', 'a', 'b']);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('checking getSymfonyUri', async () => {
|
||||||
|
expect(await tools.getSymfonyUri('latest', 'linux')).toContain(
|
||||||
|
'releases/latest/download/symfony_linux_amd64'
|
||||||
|
);
|
||||||
|
expect(await tools.getSymfonyUri('1.2.3', 'linux')).toContain(
|
||||||
|
'releases/download/v1.2.3/symfony_linux_amd64'
|
||||||
|
);
|
||||||
|
expect(await tools.getSymfonyUri('latest', 'darwin')).toContain(
|
||||||
|
'releases/latest/download/symfony_darwin_amd64'
|
||||||
|
);
|
||||||
|
expect(await tools.getSymfonyUri('1.2.3', 'darwin')).toContain(
|
||||||
|
'releases/download/v1.2.3/symfony_darwin_amd64'
|
||||||
|
);
|
||||||
|
expect(await tools.getSymfonyUri('latest', 'win32')).toContain(
|
||||||
|
'releases/latest/download/symfony_windows_amd64'
|
||||||
|
);
|
||||||
|
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'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('checking getCleanedToolsList', async () => {
|
||||||
|
const tools_list: string[] = await tools.getCleanedToolsList(
|
||||||
|
'tool, composer:1.2.3, robmorgan/phinx, hirak/prestissimo, narrowspark/automatic-composer-prefetcher'
|
||||||
|
);
|
||||||
|
expect(tools_list).toStrictEqual([
|
||||||
|
'composer',
|
||||||
|
'tool',
|
||||||
|
'phinx',
|
||||||
|
'prestissimo',
|
||||||
|
'composer-prefetcher'
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
|
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'
|
||||||
|
);
|
||||||
|
expect(script).toContain('Add-Tool https://tool.com/tool.phar tool');
|
||||||
|
|
||||||
|
script = await tools.addArchive(
|
||||||
|
'tool',
|
||||||
|
'1.2.3',
|
||||||
|
'https://tool.com/tool.phar',
|
||||||
|
'fedora'
|
||||||
|
);
|
||||||
|
expect(script).toContain('Platform fedora is not supported');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('checking addDevTools', async () => {
|
||||||
|
let script: string = await tools.addDevTools('phpize', 'linux');
|
||||||
|
expect(script).toContain('add_devtools');
|
||||||
|
expect(script).toContain('add_log "$tick" "phpize" "Added"');
|
||||||
|
|
||||||
|
script = await tools.addDevTools('php-config', 'linux');
|
||||||
|
expect(script).toContain('add_devtools');
|
||||||
|
expect(script).toContain('add_log "$tick" "php-config" "Added"');
|
||||||
|
|
||||||
|
script = await tools.addDevTools('phpize', 'darwin');
|
||||||
|
expect(script).toContain('add_log "$tick" "phpize" "Added"');
|
||||||
|
|
||||||
|
script = await tools.addDevTools('php-config', 'darwin');
|
||||||
|
expect(script).toContain('add_log "$tick" "php-config" "Added"');
|
||||||
|
|
||||||
|
script = await tools.addDevTools('phpize', 'win32');
|
||||||
|
expect(script).toContain(
|
||||||
|
'Add-Log "$cross" "phpize" "phpize is not a windows tool"'
|
||||||
|
);
|
||||||
|
|
||||||
|
script = await tools.addDevTools('php-config', 'win32');
|
||||||
|
expect(script).toContain(
|
||||||
|
'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');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('checking addPackage', async () => {
|
||||||
|
let script: string = await tools.addPackage(
|
||||||
|
'tool',
|
||||||
|
'tool:1.2.3',
|
||||||
|
'user/',
|
||||||
|
'linux'
|
||||||
|
);
|
||||||
|
expect(script).toContain('add_composertool tool tool:1.2.3 user/');
|
||||||
|
|
||||||
|
script = await tools.addPackage('tool', 'tool:1.2.3', 'user/', 'darwin');
|
||||||
|
expect(script).toContain('add_composertool tool tool:1.2.3 user/');
|
||||||
|
|
||||||
|
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');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('checking addTools on linux', async () => {
|
||||||
|
const script: string = await tools.addTools(
|
||||||
|
'cs2pr, php-cs-fixer, phpstan, phpunit, pecl, phinx, phinx:1.2.3, phive, php-config, phpize, symfony',
|
||||||
|
'7.4',
|
||||||
|
'linux'
|
||||||
|
);
|
||||||
|
expect(script).toContain(
|
||||||
|
'add_tool https://getcomposer.org/composer-stable.phar composer'
|
||||||
|
);
|
||||||
|
expect(script).toContain(
|
||||||
|
'add_tool https://github.com/staabm/annotate-pull-request-from-checkstyle/releases/latest/download/cs2pr cs2pr'
|
||||||
|
);
|
||||||
|
expect(script).toContain(
|
||||||
|
'add_tool https://github.com/FriendsOfPHP/PHP-CS-Fixer/releases/latest/download/php-cs-fixer.phar php-cs-fixer'
|
||||||
|
);
|
||||||
|
expect(script).toContain(
|
||||||
|
'add_tool https://github.com/phpstan/phpstan/releases/latest/download/phpstan.phar phpstan'
|
||||||
|
);
|
||||||
|
expect(script).toContain(
|
||||||
|
'add_tool https://phar.io/releases/phive.phar phive'
|
||||||
|
);
|
||||||
|
expect(script).toContain(
|
||||||
|
'add_tool https://phar.phpunit.de/phpunit.phar phpunit'
|
||||||
|
);
|
||||||
|
expect(script).toContain(
|
||||||
|
'add_tool https://github.com/symfony/cli/releases/latest/download/symfony_linux_amd64 symfony'
|
||||||
|
);
|
||||||
|
expect(script).toContain('add_pecl');
|
||||||
|
expect(script).toContain('add_composertool phinx phinx robmorgan/');
|
||||||
|
expect(script).toContain('add_composertool phinx phinx:1.2.3 robmorgan/');
|
||||||
|
expect(script).toContain('add_devtools');
|
||||||
|
expect(script).toContain('add_log "$tick" "php-config" "Added"');
|
||||||
|
expect(script).toContain('add_log "$tick" "phpize" "Added"');
|
||||||
|
});
|
||||||
|
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',
|
||||||
|
'7.4',
|
||||||
|
'darwin'
|
||||||
|
);
|
||||||
|
expect(script).toContain(
|
||||||
|
'add_tool https://getcomposer.org/composer-stable.phar composer'
|
||||||
|
);
|
||||||
|
expect(script).toContain(
|
||||||
|
'add_tool https://github.com/staabm/annotate-pull-request-from-checkstyle/releases/download/1.2.3/cs2pr cs2pr'
|
||||||
|
);
|
||||||
|
expect(script).toContain(
|
||||||
|
'add_tool https://github.com/squizlabs/PHP_CodeSniffer/releases/latest/download/phpcs.phar phpcs'
|
||||||
|
);
|
||||||
|
expect(script).toContain(
|
||||||
|
'add_tool https://github.com/squizlabs/PHP_CodeSniffer/releases/latest/download/phpcbf.phar phpcbf'
|
||||||
|
);
|
||||||
|
expect(script).toContain(
|
||||||
|
'add_tool https://phar.phpunit.de/phpcpd.phar phpcpd'
|
||||||
|
);
|
||||||
|
expect(script).toContain(
|
||||||
|
'add_tool https://github.com/phpmd/phpmd/releases/latest/download/phpmd.phar phpmd'
|
||||||
|
);
|
||||||
|
expect(script).toContain(
|
||||||
|
'https://github.com/vimeo/psalm/releases/latest/download/psalm.phar psalm'
|
||||||
|
);
|
||||||
|
expect(script).toContain('add_composertool phinx phinx robmorgan/');
|
||||||
|
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'
|
||||||
|
);
|
||||||
|
expect(script).toContain('add_log "$tick" "phpize" "Added"');
|
||||||
|
expect(script).toContain('add_log "$tick" "php-config" "Added"');
|
||||||
|
});
|
||||||
|
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_exit',
|
||||||
|
'7.4',
|
||||||
|
'win32'
|
||||||
|
);
|
||||||
|
expect(script).toContain(
|
||||||
|
'Add-Tool https://getcomposer.org/composer-stable.phar composer'
|
||||||
|
);
|
||||||
|
expect(script).toContain(
|
||||||
|
'Add-Tool https://github.com/staabm/annotate-pull-request-from-checkstyle/releases/latest/download/cs2pr cs2pr'
|
||||||
|
);
|
||||||
|
expect(script).toContain(
|
||||||
|
'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'
|
||||||
|
);
|
||||||
|
expect(script).toContain('Add-Composertool phinx phinx robmorgan/');
|
||||||
|
expect(script).toContain(
|
||||||
|
'Add-Tool https://github.com/phar-io/phive/releases/download/0.13.2/phive-0.13.2.phar phive'
|
||||||
|
);
|
||||||
|
expect(script).toContain(
|
||||||
|
'Add-Tool https://github.com/symfony/cli/releases/latest/download/symfony_windows_amd64.exe symfony'
|
||||||
|
);
|
||||||
|
expect(script).toContain('phpize is not a windows tool');
|
||||||
|
expect(script).toContain('php-config is not a windows tool');
|
||||||
|
expect(script).toContain('Tool does_not_exit is not supported');
|
||||||
|
expect(script).toContain('Tool does_not_exit is not supported');
|
||||||
|
});
|
||||||
|
it('checking addTools with composer tool using user/tool as input', async () => {
|
||||||
|
const script: string = await tools.addTools(
|
||||||
|
'hirak/prestissimo, narrowspark/automatic-composer-prefetcher, robmorgan/phinx',
|
||||||
|
'7.4',
|
||||||
|
'win32'
|
||||||
|
);
|
||||||
|
expect(script).toContain(
|
||||||
|
'Add-Tool https://getcomposer.org/composer-stable.phar composer'
|
||||||
|
);
|
||||||
|
expect(script).toContain('Add-Composertool prestissimo prestissimo hirak/');
|
||||||
|
expect(script).toContain('Add-Composertool phinx phinx robmorgan/');
|
||||||
|
expect(script).toContain(
|
||||||
|
'Add-Composertool composer-prefetcher composer-prefetcher narrowspark/automatic-'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
@ -55,12 +55,12 @@ describe('Utils tests', () => {
|
|||||||
path.join(__dirname, '../src/scripts/win32.ps1'),
|
path.join(__dirname, '../src/scripts/win32.ps1'),
|
||||||
'utf8'
|
'utf8'
|
||||||
);
|
);
|
||||||
expect(await utils.readScript('darwin.sh', '7.4', 'darwin')).toBe(darwin);
|
expect(await utils.readScript('darwin.sh')).toBe(darwin);
|
||||||
expect(await utils.readScript('darwin.sh', '7.3', 'darwin')).toBe(darwin);
|
expect(await utils.readScript('darwin.sh')).toBe(darwin);
|
||||||
expect(await utils.readScript('linux.sh', '7.4', 'linux')).toBe(linux);
|
expect(await utils.readScript('linux.sh')).toBe(linux);
|
||||||
expect(await utils.readScript('linux.sh', '7.3', 'linux')).toBe(linux);
|
expect(await utils.readScript('linux.sh')).toBe(linux);
|
||||||
expect(await utils.readScript('win32.ps1', '7.4', 'win32')).toBe(win32);
|
expect(await utils.readScript('win32.ps1')).toBe(win32);
|
||||||
expect(await utils.readScript('win32.ps1', '7.3', 'win32')).toBe(win32);
|
expect(await utils.readScript('win32.ps1')).toBe(win32);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('checking writeScripts', async () => {
|
it('checking writeScripts', async () => {
|
||||||
@ -87,13 +87,13 @@ describe('Utils tests', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('checking INIArray', async () => {
|
it('checking INIArray', async () => {
|
||||||
expect(await utils.INIArray('a=1, b=2, c=3')).toEqual([
|
expect(await utils.CSVArray('a=1, b=2, c=3')).toEqual([
|
||||||
'a=1',
|
'a=1',
|
||||||
'b=2',
|
'b=2',
|
||||||
'c=3'
|
'c=3'
|
||||||
]);
|
]);
|
||||||
expect(await utils.INIArray('')).toEqual([]);
|
expect(await utils.CSVArray('')).toEqual([]);
|
||||||
expect(await utils.INIArray(' ')).toEqual([]);
|
expect(await utils.CSVArray(' ')).toEqual([]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('checking log', async () => {
|
it('checking log', async () => {
|
||||||
|
16
action.yml
16
action.yml
@ -1,8 +1,9 @@
|
|||||||
name: 'Setup PHP Action'
|
name: 'Setup PHP Action'
|
||||||
author: shivammathur
|
author: shivammathur
|
||||||
description: 'GitHub action to setup PHP with required extensions, php.ini configuration, code-coverage support and composer'
|
description: 'Setup PHP with required extensions, php.ini configuration, code-coverage support and various tools like composer'
|
||||||
branding:
|
branding:
|
||||||
color: 'purple'
|
color: 'purple'
|
||||||
|
icon: 'play-circle'
|
||||||
inputs:
|
inputs:
|
||||||
php-version:
|
php-version:
|
||||||
description: 'Setup PHP version.'
|
description: 'Setup PHP version.'
|
||||||
@ -17,17 +18,20 @@ inputs:
|
|||||||
coverage:
|
coverage:
|
||||||
description: 'Setup code coverage driver.'
|
description: 'Setup code coverage driver.'
|
||||||
required: false
|
required: false
|
||||||
pecl:
|
tools:
|
||||||
description: 'Setup PECL on ubuntu'
|
description: 'Setup popular tools globally.'
|
||||||
required: false
|
required: false
|
||||||
# Deprecated options, do not use. Will not be supported after February 1, 2019.
|
|
||||||
extension-csv:
|
extension-csv:
|
||||||
description: 'Deprecated! Use extensions instead.'
|
description: 'Deprecated! Use extensions instead.'
|
||||||
deprecationMessage: 'The extension-csv property will not be supported after February 1, 2020. Use extensions instead.'
|
deprecationMessage: 'The extension-csv property is deprecated. Use extensions instead.'
|
||||||
required: false
|
required: false
|
||||||
ini-values-csv:
|
ini-values-csv:
|
||||||
description: 'Deprecated! Use ini-values instead.'
|
description: 'Deprecated! Use ini-values instead.'
|
||||||
deprecationMessage: 'The ini-values-csv property will not be supported after February 1, 2020. Use ini-values instead.'
|
deprecationMessage: 'The ini-values-csv property is deprecated. Use ini-values instead.'
|
||||||
|
required: false
|
||||||
|
pecl:
|
||||||
|
description: 'Deprecated! Use tools instead to setup PECL.'
|
||||||
|
deprecationMessage: 'The pecl property is deprecated. Specify pecl in tools instead.'
|
||||||
required: false
|
required: false
|
||||||
runs:
|
runs:
|
||||||
using: 'node12'
|
using: 'node12'
|
||||||
|
1100
dist/index.js
vendored
1100
dist/index.js
vendored
File diff suppressed because it is too large
Load Diff
@ -11,7 +11,7 @@ jobs:
|
|||||||
php-versions: ['7.1', '7.2', '7.3', '7.4']
|
php-versions: ['7.1', '7.2', '7.3', '7.4']
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v1
|
uses: actions/checkout@v2
|
||||||
- name: Setup PHP, with composer and extensions
|
- name: Setup PHP, with composer and extensions
|
||||||
uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php
|
uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php
|
||||||
with:
|
with:
|
||||||
@ -22,6 +22,8 @@ jobs:
|
|||||||
- uses: actions/cache@v1
|
- uses: actions/cache@v1
|
||||||
with:
|
with:
|
||||||
path: ${{ steps.composer-cache.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') }}
|
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
|
||||||
restore-keys: ${{ runner.os }}-composer-
|
restore-keys: ${{ runner.os }}-composer-
|
||||||
- name: Install Composer dependencies
|
- name: Install Composer dependencies
|
||||||
|
114
examples/cakephp-mysql.yml
Normal file
114
examples/cakephp-mysql.yml
Normal file
@ -0,0 +1,114 @@
|
|||||||
|
# GitHub Action for CakePHP with MySQL and Redis
|
||||||
|
# Tested with https://github.com/cakephp/app
|
||||||
|
name: Testing CakePHP with MySQL
|
||||||
|
on: [push, pull_request]
|
||||||
|
jobs:
|
||||||
|
tests:
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
php-versions: ['7.2', '7.3', '7.4']
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
services:
|
||||||
|
mysql:
|
||||||
|
image: mysql:5.7
|
||||||
|
env:
|
||||||
|
MYSQL_ALLOW_EMPTY_PASSWORD: false
|
||||||
|
MYSQL_ROOT_PASSWORD: password
|
||||||
|
MYSQL_DATABASE: cakephp
|
||||||
|
ports:
|
||||||
|
- 3306/tcp
|
||||||
|
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
|
||||||
|
redis:
|
||||||
|
image: redis
|
||||||
|
ports:
|
||||||
|
- 6379/tcp
|
||||||
|
options: --health-cmd="redis-cli ping" --health-interval=10s --health-timeout=5s --health-retries=3
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
- name: Setup PHP
|
||||||
|
uses: shivammathur/setup-php@v1
|
||||||
|
with:
|
||||||
|
php-version: ${{ matrix.php-versions }}
|
||||||
|
# You can also use ext-apcu or ext-memcached instead of ext-redis
|
||||||
|
# Install memcached if using ext-memcached
|
||||||
|
extensions: mbstring, intl, redis, pdo_mysql
|
||||||
|
coverage: pcov
|
||||||
|
- name: Start mysql service
|
||||||
|
run: sudo /etc/init.d/mysql start
|
||||||
|
- name: Get composer cache directory
|
||||||
|
id: composer-cache
|
||||||
|
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
||||||
|
- name: Cache composer dependencies
|
||||||
|
uses: actions/cache@v1
|
||||||
|
with:
|
||||||
|
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') }}
|
||||||
|
restore-keys: ${{ runner.os }}-composer-
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
composer install --no-progress --no-suggest --prefer-dist --optimize-autoloader
|
||||||
|
composer run-script post-install-cmd --no-interaction
|
||||||
|
# Add a step to run migrations if required
|
||||||
|
- name: Test with phpunit
|
||||||
|
run: vendor/bin/phpunit --coverage-text
|
||||||
|
env:
|
||||||
|
REDIS_PORT: ${{ job.services.redis.ports['6379'] }}
|
||||||
|
DB_DSN: "mysql://root:password@127.0.0.1:${{ job.services.mysql.ports['3306'] }}/cakephp?init[]=SET sql_mode = \"STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION\""
|
||||||
|
|
||||||
|
coding-standard:
|
||||||
|
name: Coding Standard
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
- name: Setup PHP
|
||||||
|
uses: shivammathur/setup-php@v1
|
||||||
|
with:
|
||||||
|
php-version: '7.3'
|
||||||
|
extensions: mbstring, intl
|
||||||
|
- name: Get composer cache directory
|
||||||
|
id: composer-cache
|
||||||
|
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
||||||
|
- name: Cache composer dependencies
|
||||||
|
uses: actions/cache@v1
|
||||||
|
with:
|
||||||
|
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') }}
|
||||||
|
restore-keys: ${{ runner.os }}-composer-
|
||||||
|
- name: Install dependencies
|
||||||
|
run: composer install --no-progress --no-suggest --prefer-dist --optimize-autoloader
|
||||||
|
- name: PHP CodeSniffer
|
||||||
|
run: composer cs-check
|
||||||
|
|
||||||
|
static-analysis:
|
||||||
|
name: Static Analysis
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
- name: Setup PHP
|
||||||
|
uses: shivammathur/setup-php@v1
|
||||||
|
with:
|
||||||
|
php-version: '7.3'
|
||||||
|
extensions: mbstring, intl
|
||||||
|
tools: phpstan
|
||||||
|
- name: Get composer cache directory
|
||||||
|
id: composer-cache
|
||||||
|
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
||||||
|
- name: Cache composer dependencies
|
||||||
|
uses: actions/cache@v1
|
||||||
|
with:
|
||||||
|
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') }}
|
||||||
|
restore-keys: ${{ runner.os }}-composer-
|
||||||
|
- name: Install dependencies
|
||||||
|
run: composer install --no-progress --no-suggest --prefer-dist --optimize-autoloader
|
||||||
|
- name: Static Analysis using PHPStan
|
||||||
|
run: phpstan analyse --no-progress src/
|
112
examples/cakephp-postgres.yml
Normal file
112
examples/cakephp-postgres.yml
Normal file
@ -0,0 +1,112 @@
|
|||||||
|
# GitHub Action for CakePHP with PostgreSQL and Redis
|
||||||
|
# Tested with https://github.com/cakephp/app
|
||||||
|
name: Testing CakePHP with PostgreSQL
|
||||||
|
on: [push, pull_request]
|
||||||
|
jobs:
|
||||||
|
tests:
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
php-versions: ['7.2', '7.3', '7.4']
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
services:
|
||||||
|
postgres:
|
||||||
|
image: postgres:10.8
|
||||||
|
env:
|
||||||
|
POSTGRES_USER: postgres
|
||||||
|
POSTGRES_PASSWORD: postgres
|
||||||
|
POSTGRES_DB: postgres
|
||||||
|
ports:
|
||||||
|
- 5432/tcp
|
||||||
|
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 3
|
||||||
|
redis:
|
||||||
|
image: redis
|
||||||
|
ports:
|
||||||
|
- 6379/tcp
|
||||||
|
options: --health-cmd="redis-cli ping" --health-interval=10s --health-timeout=5s --health-retries=3
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
- name: Setup PHP
|
||||||
|
uses: shivammathur/setup-php@v1
|
||||||
|
with:
|
||||||
|
php-version: ${{ matrix.php-versions }}
|
||||||
|
# You can also use ext-apcu or ext-memcached instead of ext-redis
|
||||||
|
# Install memcached if using ext-memcached
|
||||||
|
extensions: mbstring, intl, redis, pdo_pgsql
|
||||||
|
coverage: pcov
|
||||||
|
- name: Get composer cache directory
|
||||||
|
id: composer-cache
|
||||||
|
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
||||||
|
- name: Cache composer dependencies
|
||||||
|
uses: actions/cache@v1
|
||||||
|
with:
|
||||||
|
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') }}
|
||||||
|
restore-keys: ${{ runner.os }}-composer-
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
composer install --no-progress --no-suggest --prefer-dist --optimize-autoloader
|
||||||
|
composer run-script post-install-cmd --no-interaction
|
||||||
|
# Add a step to run migrations if required
|
||||||
|
- name: Test with phpunit
|
||||||
|
run: vendor/bin/phpunit --coverage-text
|
||||||
|
env:
|
||||||
|
REDIS_PORT: ${{ job.services.redis.ports['6379'] }}
|
||||||
|
DB_DSN: postgres://postgres@127.0.0.1:${{ job.services.postgres.ports['5432'] }}/postgres
|
||||||
|
|
||||||
|
coding-standard:
|
||||||
|
name: Coding Standard
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
- name: Setup PHP
|
||||||
|
uses: shivammathur/setup-php@v1
|
||||||
|
with:
|
||||||
|
php-version: '7.3'
|
||||||
|
extensions: mbstring, intl
|
||||||
|
- name: Get composer cache directory
|
||||||
|
id: composer-cache
|
||||||
|
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
||||||
|
- name: Cache composer dependencies
|
||||||
|
uses: actions/cache@v1
|
||||||
|
with:
|
||||||
|
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') }}
|
||||||
|
restore-keys: ${{ runner.os }}-composer-
|
||||||
|
- name: Install dependencies
|
||||||
|
run: composer install --no-progress --no-suggest --prefer-dist --optimize-autoloader
|
||||||
|
- name: PHP CodeSniffer
|
||||||
|
run: composer cs-check
|
||||||
|
|
||||||
|
static-analysis:
|
||||||
|
name: Static Analysis
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
- name: Setup PHP
|
||||||
|
uses: shivammathur/setup-php@v1
|
||||||
|
with:
|
||||||
|
php-version: '7.3'
|
||||||
|
extensions: mbstring, intl
|
||||||
|
tools: phpstan
|
||||||
|
- name: Get composer cache directory
|
||||||
|
id: composer-cache
|
||||||
|
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
||||||
|
- name: Cache composer dependencies
|
||||||
|
uses: actions/cache@v1
|
||||||
|
with:
|
||||||
|
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') }}
|
||||||
|
restore-keys: ${{ runner.os }}-composer-
|
||||||
|
- name: Install dependencies
|
||||||
|
run: composer install --no-progress --no-suggest --prefer-dist --optimize-autoloader
|
||||||
|
- name: Static Analysis using PHPStan
|
||||||
|
run: phpstan analyse --no-progress src/
|
92
examples/cakephp.yml
Normal file
92
examples/cakephp.yml
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
# GitHub Action for CakePHP
|
||||||
|
# Tested with https://github.com/cakephp/app
|
||||||
|
name: Testing CakePHP
|
||||||
|
on: [push, pull_request]
|
||||||
|
jobs:
|
||||||
|
tests:
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
operating-system: [ubuntu-latest, windows-latest, macos-latest]
|
||||||
|
php-versions: ['7.2', '7.3', '7.4']
|
||||||
|
runs-on: ${{ matrix.operating-system }}
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
- name: Setup PHP
|
||||||
|
uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php
|
||||||
|
with:
|
||||||
|
php-version: ${{ matrix.php-versions }}
|
||||||
|
extensions: mbstring, intl, pdo_sqlite, pdo_mysql
|
||||||
|
coverage: pcov #optional
|
||||||
|
- name: Get composer cache directory
|
||||||
|
id: composer-cache
|
||||||
|
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
||||||
|
- name: Cache composer dependencies
|
||||||
|
uses: actions/cache@v1
|
||||||
|
with:
|
||||||
|
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') }}
|
||||||
|
restore-keys: ${{ runner.os }}-composer-
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
composer install --no-progress --no-suggest --prefer-dist --optimize-autoloader
|
||||||
|
composer run-script post-install-cmd --no-interaction
|
||||||
|
- name: Test with phpunit
|
||||||
|
run: vendor/bin/phpunit --coverage-text
|
||||||
|
|
||||||
|
coding-standard:
|
||||||
|
name: Coding Standard
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
- name: Setup PHP
|
||||||
|
uses: shivammathur/setup-php@v1
|
||||||
|
with:
|
||||||
|
php-version: '7.3'
|
||||||
|
extensions: mbstring, intl
|
||||||
|
- name: Get composer cache directory
|
||||||
|
id: composer-cache
|
||||||
|
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
||||||
|
- name: Cache composer dependencies
|
||||||
|
uses: actions/cache@v1
|
||||||
|
with:
|
||||||
|
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') }}
|
||||||
|
restore-keys: ${{ runner.os }}-composer-
|
||||||
|
- name: Install dependencies
|
||||||
|
run: composer install --no-progress --no-suggest --prefer-dist --optimize-autoloader
|
||||||
|
- name: PHP CodeSniffer
|
||||||
|
run: composer cs-check
|
||||||
|
|
||||||
|
static-analysis:
|
||||||
|
name: Static Analysis
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
- name: Setup PHP
|
||||||
|
uses: shivammathur/setup-php@v1
|
||||||
|
with:
|
||||||
|
php-version: '7.3'
|
||||||
|
extensions: mbstring, intl
|
||||||
|
tools: phpstan
|
||||||
|
- name: Get composer cache directory
|
||||||
|
id: composer-cache
|
||||||
|
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
||||||
|
- name: Cache composer dependencies
|
||||||
|
uses: actions/cache@v1
|
||||||
|
with:
|
||||||
|
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') }}
|
||||||
|
restore-keys: ${{ runner.os }}-composer-
|
||||||
|
- name: Install dependencies
|
||||||
|
run: composer install --no-progress --no-suggest --prefer-dist --optimize-autoloader
|
||||||
|
- name: Static Analysis using PHPStan
|
||||||
|
run: phpstan analyse --no-progress src/
|
@ -5,12 +5,12 @@ jobs:
|
|||||||
build:
|
build:
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
operating-system: [ubuntu-latest, windows-latest, macOS-latest]
|
operating-system: [ubuntu-latest, windows-latest, macos-latest]
|
||||||
php-versions: ['7.2', '7.3', '7.4']
|
php-versions: ['7.2', '7.3', '7.4']
|
||||||
runs-on: ${{ matrix.operating-system }}
|
runs-on: ${{ matrix.operating-system }}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v1
|
uses: actions/checkout@v2
|
||||||
- name: Setup PHP, with composer and extensions
|
- name: Setup PHP, with composer and extensions
|
||||||
uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php
|
uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php
|
||||||
with:
|
with:
|
||||||
@ -24,6 +24,8 @@ jobs:
|
|||||||
uses: actions/cache@v1
|
uses: actions/cache@v1
|
||||||
with:
|
with:
|
||||||
path: ${{ steps.composer-cache.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') }}
|
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
|
||||||
restore-keys: ${{ runner.os }}-composer-
|
restore-keys: ${{ runner.os }}-composer-
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
|
@ -21,7 +21,7 @@ jobs:
|
|||||||
MYSQL_ROOT_PASSWORD: password
|
MYSQL_ROOT_PASSWORD: password
|
||||||
MYSQL_DATABASE: laravel
|
MYSQL_DATABASE: laravel
|
||||||
ports:
|
ports:
|
||||||
- 3306
|
- 3306/tcp
|
||||||
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
|
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
|
||||||
redis:
|
redis:
|
||||||
image: redis
|
image: redis
|
||||||
@ -34,13 +34,15 @@ jobs:
|
|||||||
php-versions: ['7.2', '7.3', '7.4']
|
php-versions: ['7.2', '7.3', '7.4']
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v1
|
uses: actions/checkout@v2
|
||||||
- name: Setup PHP, with composer and extensions
|
- name: Setup PHP, with composer and extensions
|
||||||
uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php
|
uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php
|
||||||
with:
|
with:
|
||||||
php-version: ${{ matrix.php-versions }}
|
php-version: ${{ matrix.php-versions }}
|
||||||
extensions: mbstring, dom, fileinfo, mysql
|
extensions: mbstring, dom, fileinfo, mysql
|
||||||
coverage: xdebug #optional
|
coverage: xdebug #optional
|
||||||
|
- name: Start mysql service
|
||||||
|
run: sudo /etc/init.d/mysql start
|
||||||
- name: Get composer cache directory
|
- name: Get composer cache directory
|
||||||
id: composer-cache
|
id: composer-cache
|
||||||
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
||||||
@ -48,6 +50,8 @@ jobs:
|
|||||||
uses: actions/cache@v1
|
uses: actions/cache@v1
|
||||||
with:
|
with:
|
||||||
path: ${{ steps.composer-cache.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') }}
|
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
|
||||||
restore-keys: ${{ runner.os }}-composer-
|
restore-keys: ${{ runner.os }}-composer-
|
||||||
- name: Install Composer dependencies
|
- name: Install Composer dependencies
|
||||||
@ -62,7 +66,9 @@ jobs:
|
|||||||
run: php artisan migrate -v
|
run: php artisan migrate -v
|
||||||
env:
|
env:
|
||||||
DB_PORT: ${{ job.services.mysql.ports['3306'] }}
|
DB_PORT: ${{ job.services.mysql.ports['3306'] }}
|
||||||
|
REDIS_PORT: ${{ job.services.redis.ports['6379'] }}
|
||||||
- name: Test with phpunit
|
- name: Test with phpunit
|
||||||
run: vendor/bin/phpunit --coverage-text
|
run: vendor/bin/phpunit --coverage-text
|
||||||
env:
|
env:
|
||||||
DB_PORT: ${{ job.services.mysql.ports['3306'] }}
|
DB_PORT: ${{ job.services.mysql.ports['3306'] }}
|
||||||
|
REDIS_PORT: ${{ job.services.redis.ports['6379'] }}
|
@ -36,7 +36,7 @@ jobs:
|
|||||||
php-versions: ['7.2', '7.3', '7.4']
|
php-versions: ['7.2', '7.3', '7.4']
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v1
|
uses: actions/checkout@v2
|
||||||
- name: Setup PHP, with composer and extensions
|
- name: Setup PHP, with composer and extensions
|
||||||
uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php
|
uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php
|
||||||
with:
|
with:
|
||||||
@ -50,6 +50,8 @@ jobs:
|
|||||||
uses: actions/cache@v1
|
uses: actions/cache@v1
|
||||||
with:
|
with:
|
||||||
path: ${{ steps.composer-cache.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') }}
|
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
|
||||||
restore-keys: ${{ runner.os }}-composer-
|
restore-keys: ${{ runner.os }}-composer-
|
||||||
- name: Install Composer dependencies
|
- name: Install Composer dependencies
|
||||||
@ -64,7 +66,9 @@ jobs:
|
|||||||
run: php artisan migrate -v
|
run: php artisan migrate -v
|
||||||
env:
|
env:
|
||||||
DB_PORT: ${{ job.services.postgres.ports[5432] }}
|
DB_PORT: ${{ job.services.postgres.ports[5432] }}
|
||||||
|
REDIS_PORT: ${{ job.services.redis.ports['6379'] }}
|
||||||
- name: Test with phpunit
|
- name: Test with phpunit
|
||||||
run: vendor/bin/phpunit --coverage-text
|
run: vendor/bin/phpunit --coverage-text
|
||||||
env:
|
env:
|
||||||
DB_PORT: ${{ job.services.postgres.ports[5432] }}
|
DB_PORT: ${{ job.services.postgres.ports[5432] }}
|
||||||
|
REDIS_PORT: ${{ job.services.redis.ports['6379'] }}
|
@ -8,11 +8,11 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
operating-system: [ubuntu-latest, windows-latest, macOS-latest]
|
operating-system: [ubuntu-latest, windows-latest, macos-latest]
|
||||||
php-versions: ['7.2', '7.3', '7.4']
|
php-versions: ['7.2', '7.3', '7.4']
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v1
|
uses: actions/checkout@v2
|
||||||
- name: Setup PHP, with composer and extensions
|
- name: Setup PHP, with composer and extensions
|
||||||
uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php
|
uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php
|
||||||
with:
|
with:
|
||||||
@ -26,6 +26,8 @@ jobs:
|
|||||||
uses: actions/cache@v1
|
uses: actions/cache@v1
|
||||||
with:
|
with:
|
||||||
path: ${{ steps.composer-cache.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') }}
|
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
|
||||||
restore-keys: ${{ runner.os }}-composer-
|
restore-keys: ${{ runner.os }}-composer-
|
||||||
- name: Install Composer dependencies
|
- name: Install Composer dependencies
|
||||||
|
@ -21,7 +21,7 @@ jobs:
|
|||||||
MYSQL_ROOT_PASSWORD: password
|
MYSQL_ROOT_PASSWORD: password
|
||||||
MYSQL_DATABASE: lumen
|
MYSQL_DATABASE: lumen
|
||||||
ports:
|
ports:
|
||||||
- 3306
|
- 3306/tcp
|
||||||
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
|
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
|
||||||
redis:
|
redis:
|
||||||
image: redis
|
image: redis
|
||||||
@ -34,13 +34,15 @@ jobs:
|
|||||||
php-versions: ['7.2', '7.3', '7.4']
|
php-versions: ['7.2', '7.3', '7.4']
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v1
|
uses: actions/checkout@v2
|
||||||
- name: Setup PHP, with composer and extensions
|
- name: Setup PHP, with composer and extensions
|
||||||
uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php
|
uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php
|
||||||
with:
|
with:
|
||||||
php-version: ${{ matrix.php-versions }}
|
php-version: ${{ matrix.php-versions }}
|
||||||
extensions: mbstring, dom, fileinfo, mysql
|
extensions: mbstring, dom, fileinfo, mysql
|
||||||
coverage: xdebug #optional
|
coverage: xdebug #optional
|
||||||
|
- name: Start mysql service
|
||||||
|
run: sudo /etc/init.d/mysql start
|
||||||
- name: Get composer cache directory
|
- name: Get composer cache directory
|
||||||
id: composer-cache
|
id: composer-cache
|
||||||
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
||||||
@ -48,6 +50,8 @@ jobs:
|
|||||||
uses: actions/cache@v1
|
uses: actions/cache@v1
|
||||||
with:
|
with:
|
||||||
path: ${{ steps.composer-cache.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') }}
|
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
|
||||||
restore-keys: ${{ runner.os }}-composer-
|
restore-keys: ${{ runner.os }}-composer-
|
||||||
- name: Install Composer dependencies
|
- name: Install Composer dependencies
|
||||||
@ -62,7 +66,9 @@ jobs:
|
|||||||
run: php artisan migrate -v
|
run: php artisan migrate -v
|
||||||
env:
|
env:
|
||||||
DB_PORT: ${{ job.services.mysql.ports['3306'] }}
|
DB_PORT: ${{ job.services.mysql.ports['3306'] }}
|
||||||
|
REDIS_PORT: ${{ job.services.redis.ports['6379'] }}
|
||||||
- name: Test with phpunit
|
- name: Test with phpunit
|
||||||
run: vendor/bin/phpunit --coverage-text
|
run: vendor/bin/phpunit --coverage-text
|
||||||
env:
|
env:
|
||||||
DB_PORT: ${{ job.services.mysql.ports['3306'] }}
|
DB_PORT: ${{ job.services.mysql.ports['3306'] }}
|
||||||
|
REDIS_PORT: ${{ job.services.redis.ports['6379'] }}
|
@ -36,7 +36,7 @@ jobs:
|
|||||||
php-versions: ['7.2', '7.3', '7.4']
|
php-versions: ['7.2', '7.3', '7.4']
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v1
|
uses: actions/checkout@v2
|
||||||
- name: Setup PHP, with composer and extensions
|
- name: Setup PHP, with composer and extensions
|
||||||
uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php
|
uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php
|
||||||
with:
|
with:
|
||||||
@ -50,6 +50,8 @@ jobs:
|
|||||||
uses: actions/cache@v1
|
uses: actions/cache@v1
|
||||||
with:
|
with:
|
||||||
path: ${{ steps.composer-cache.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') }}
|
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
|
||||||
restore-keys: ${{ runner.os }}-composer-
|
restore-keys: ${{ runner.os }}-composer-
|
||||||
- name: Install Composer dependencies
|
- name: Install Composer dependencies
|
||||||
@ -64,7 +66,9 @@ jobs:
|
|||||||
run: php artisan migrate -v
|
run: php artisan migrate -v
|
||||||
env:
|
env:
|
||||||
DB_PORT: ${{ job.services.postgres.ports[5432] }}
|
DB_PORT: ${{ job.services.postgres.ports[5432] }}
|
||||||
|
REDIS_PORT: ${{ job.services.redis.ports['6379'] }}
|
||||||
- name: Test with phpunit
|
- name: Test with phpunit
|
||||||
run: vendor/bin/phpunit --coverage-text
|
run: vendor/bin/phpunit --coverage-text
|
||||||
env:
|
env:
|
||||||
DB_PORT: ${{ job.services.postgres.ports[5432] }}
|
DB_PORT: ${{ job.services.postgres.ports[5432] }}
|
||||||
|
REDIS_PORT: ${{ job.services.redis.ports['6379'] }}
|
||||||
|
@ -8,11 +8,11 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
operating-system: [ubuntu-latest, windows-latest, macOS-latest]
|
operating-system: [ubuntu-latest, windows-latest, macos-latest]
|
||||||
php-versions: ['7.2', '7.3', '7.4']
|
php-versions: ['7.2', '7.3', '7.4']
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v1
|
uses: actions/checkout@v2
|
||||||
- name: Setup PHP, with composer and extensions
|
- name: Setup PHP, with composer and extensions
|
||||||
uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php
|
uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php
|
||||||
with:
|
with:
|
||||||
@ -26,6 +26,8 @@ jobs:
|
|||||||
uses: actions/cache@v1
|
uses: actions/cache@v1
|
||||||
with:
|
with:
|
||||||
path: ${{ steps.composer-cache.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') }}
|
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
|
||||||
restore-keys: ${{ runner.os }}-composer-
|
restore-keys: ${{ runner.os }}-composer-
|
||||||
- name: Install Composer dependencies
|
- name: Install Composer dependencies
|
||||||
|
@ -24,21 +24,25 @@ jobs:
|
|||||||
MYSQL_ROOT_PASSWORD: password
|
MYSQL_ROOT_PASSWORD: password
|
||||||
MYSQL_DATABASE: phalcon
|
MYSQL_DATABASE: phalcon
|
||||||
ports:
|
ports:
|
||||||
- 3306
|
- 3306/tcp
|
||||||
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
|
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
php-versions: ['7.2', '7.3', '7.4']
|
php-versions: ['7.2', '7.3', '7.4']
|
||||||
|
# For phalcon 3.x, use
|
||||||
|
# php-versions: ['7.0', '7.1', '7.2', '7.3']
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v1
|
uses: actions/checkout@v2
|
||||||
- name: Setup PHP, with composer and extensions
|
- name: Setup PHP, with composer and extensions
|
||||||
uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php
|
uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php
|
||||||
with:
|
with:
|
||||||
php-version: ${{ matrix.php-versions }}
|
php-version: ${{ matrix.php-versions }}
|
||||||
extensions: mbstring, dom, zip, phalcon4, mysql #use phalcon3 for the phalcon 3.x.
|
extensions: mbstring, dom, zip, phalcon4, mysql #use phalcon3 for the phalcon 3.x.
|
||||||
coverage: xdebug #optional
|
coverage: xdebug #optional
|
||||||
|
- name: Start mysql service
|
||||||
|
run: sudo /etc/init.d/mysql start
|
||||||
- name: Get composer cache directory
|
- name: Get composer cache directory
|
||||||
id: composer-cache
|
id: composer-cache
|
||||||
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
||||||
@ -46,6 +50,8 @@ jobs:
|
|||||||
uses: actions/cache@v1
|
uses: actions/cache@v1
|
||||||
with:
|
with:
|
||||||
path: ${{ steps.composer-cache.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') }}
|
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
|
||||||
restore-keys: ${{ runner.os }}-composer-
|
restore-keys: ${{ runner.os }}-composer-
|
||||||
- name: Install Composer dependencies
|
- name: Install Composer dependencies
|
||||||
|
@ -31,9 +31,11 @@ jobs:
|
|||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
php-versions: ['7.2', '7.3', '7.4']
|
php-versions: ['7.2', '7.3', '7.4']
|
||||||
|
# For phalcon 3.x, use
|
||||||
|
# php-versions: ['7.0', '7.1', '7.2', '7.3']
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v1
|
uses: actions/checkout@v2
|
||||||
- name: Setup PHP, with composer and extensions
|
- name: Setup PHP, with composer and extensions
|
||||||
uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php
|
uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php
|
||||||
with:
|
with:
|
||||||
@ -47,6 +49,8 @@ jobs:
|
|||||||
uses: actions/cache@v1
|
uses: actions/cache@v1
|
||||||
with:
|
with:
|
||||||
path: ${{ steps.composer-cache.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') }}
|
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
|
||||||
restore-keys: ${{ runner.os }}-composer-
|
restore-keys: ${{ runner.os }}-composer-
|
||||||
- name: Install Composer dependencies
|
- name: Install Composer dependencies
|
||||||
|
@ -12,7 +12,7 @@ jobs:
|
|||||||
node-versions: ['8', '10']
|
node-versions: ['8', '10']
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v1
|
uses: actions/checkout@v2
|
||||||
- name: Setup Node.js
|
- name: Setup Node.js
|
||||||
uses: actions/setup-node@v1
|
uses: actions/setup-node@v1
|
||||||
with:
|
with:
|
||||||
@ -39,6 +39,8 @@ jobs:
|
|||||||
uses: actions/cache@v1
|
uses: actions/cache@v1
|
||||||
with:
|
with:
|
||||||
path: ${{ steps.composer-cache.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') }}
|
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
|
||||||
restore-keys: ${{ runner.os }}-composer-
|
restore-keys: ${{ runner.os }}-composer-
|
||||||
- name: Install yarn dependencies
|
- name: Install yarn dependencies
|
||||||
|
@ -5,12 +5,12 @@ jobs:
|
|||||||
build:
|
build:
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
operating-system: [ubuntu-latest, windows-latest, macOS-latest]
|
operating-system: [ubuntu-latest, windows-latest, macos-latest]
|
||||||
php-versions: ['7.2', '7.3', '7.4']
|
php-versions: ['7.2', '7.3', '7.4']
|
||||||
runs-on: ${{ matrix.operating-system }}
|
runs-on: ${{ matrix.operating-system }}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v1
|
uses: actions/checkout@v2
|
||||||
- name: Setup PHP, with composer and extensions
|
- name: Setup PHP, with composer and extensions
|
||||||
uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php
|
uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php
|
||||||
with:
|
with:
|
||||||
@ -24,6 +24,8 @@ jobs:
|
|||||||
uses: actions/cache@v1
|
uses: actions/cache@v1
|
||||||
with:
|
with:
|
||||||
path: ${{ steps.composer-cache.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') }}
|
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
|
||||||
restore-keys: ${{ runner.os }}-composer-
|
restore-keys: ${{ runner.os }}-composer-
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
|
@ -13,7 +13,7 @@ jobs:
|
|||||||
MYSQL_ROOT_PASSWORD: symfony
|
MYSQL_ROOT_PASSWORD: symfony
|
||||||
MYSQL_DATABASE: symfony
|
MYSQL_DATABASE: symfony
|
||||||
ports:
|
ports:
|
||||||
- 3306
|
- 3306/tcp
|
||||||
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
|
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
@ -21,13 +21,15 @@ jobs:
|
|||||||
php-versions: ['7.3', '7.4']
|
php-versions: ['7.3', '7.4']
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v1
|
uses: actions/checkout@v2
|
||||||
- name: Setup PHP, with composer and extensions
|
- name: Setup PHP, with composer and extensions
|
||||||
uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php
|
uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php
|
||||||
with:
|
with:
|
||||||
php-version: ${{ matrix.php-versions }}
|
php-version: ${{ matrix.php-versions }}
|
||||||
extensions: mbstring, xml, ctype, iconv, mysql
|
extensions: mbstring, xml, ctype, iconv, intl, pdo_sqlite, mysql
|
||||||
coverage: xdebug #optional
|
coverage: xdebug #optional
|
||||||
|
- name: Start mysql service
|
||||||
|
run: sudo /etc/init.d/mysql start
|
||||||
- name: Get composer cache directory
|
- name: Get composer cache directory
|
||||||
id: composer-cache
|
id: composer-cache
|
||||||
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
||||||
@ -35,6 +37,8 @@ jobs:
|
|||||||
uses: actions/cache@v1
|
uses: actions/cache@v1
|
||||||
with:
|
with:
|
||||||
path: ${{ steps.composer-cache.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') }}
|
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
|
||||||
restore-keys: ${{ runner.os }}-composer-
|
restore-keys: ${{ runner.os }}-composer-
|
||||||
- name: Install Composer dependencies
|
- name: Install Composer dependencies
|
||||||
@ -48,6 +52,4 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
DATABASE_URL: mysql://root:symfony@127.0.0.1:${{ job.services.mysql.ports['3306'] }}/symfony
|
DATABASE_URL: mysql://root:symfony@127.0.0.1:${{ job.services.mysql.ports['3306'] }}/symfony
|
||||||
- name: Run Tests
|
- name: Run Tests
|
||||||
run: |
|
run: php bin/phpunit --coverage-text
|
||||||
composer require phpunit
|
|
||||||
php bin/phpunit --coverage-text
|
|
@ -21,12 +21,12 @@ jobs:
|
|||||||
php-versions: ['7.3', '7.4']
|
php-versions: ['7.3', '7.4']
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v1
|
uses: actions/checkout@v2
|
||||||
- name: Setup PHP, with composer and extensions
|
- name: Setup PHP, with composer and extensions
|
||||||
uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php
|
uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php
|
||||||
with:
|
with:
|
||||||
php-version: ${{ matrix.php-versions }}
|
php-version: ${{ matrix.php-versions }}
|
||||||
extensions: mbstring, xml, ctype, iconv, pgsql
|
extensions: mbstring, xml, ctype, iconv, intl, pdo_sqlite, pgsql
|
||||||
coverage: xdebug #optional
|
coverage: xdebug #optional
|
||||||
- name: Get composer cache directory
|
- name: Get composer cache directory
|
||||||
id: composer-cache
|
id: composer-cache
|
||||||
@ -35,6 +35,8 @@ jobs:
|
|||||||
uses: actions/cache@v1
|
uses: actions/cache@v1
|
||||||
with:
|
with:
|
||||||
path: ${{ steps.composer-cache.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') }}
|
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
|
||||||
restore-keys: ${{ runner.os }}-composer-
|
restore-keys: ${{ runner.os }}-composer-
|
||||||
- name: Install Composer dependencies
|
- name: Install Composer dependencies
|
||||||
@ -48,6 +50,4 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
DATABASE_URL: postgres://postgres:postgres@127.0.0.1:${{ job.services.postgres.ports[5432] }}/postgres?charset=UTF-8
|
DATABASE_URL: postgres://postgres:postgres@127.0.0.1:${{ job.services.postgres.ports[5432] }}/postgres?charset=UTF-8
|
||||||
- name: Run Tests
|
- name: Run Tests
|
||||||
run: |
|
run: php bin/phpunit --coverage-text
|
||||||
composer require phpunit
|
|
||||||
php bin/phpunit --coverage-text
|
|
@ -8,16 +8,16 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
operating-system: [ubuntu-latest, windows-latest, macOS-latest]
|
operating-system: [ubuntu-latest, windows-latest, macos-latest]
|
||||||
php-versions: ['7.3', '7.4']
|
php-versions: ['7.3', '7.4']
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v1
|
uses: actions/checkout@v2
|
||||||
- name: Setup PHP, with composer and extensions
|
- name: Setup PHP, with composer and extensions
|
||||||
uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php
|
uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php
|
||||||
with:
|
with:
|
||||||
php-version: ${{ matrix.php-versions }}
|
php-version: ${{ matrix.php-versions }}
|
||||||
extensions: mbstring, xml, ctype, iconv
|
extensions: mbstring, xml, ctype, iconv, intl, pdo_sqlite
|
||||||
coverage: xdebug #optional
|
coverage: xdebug #optional
|
||||||
- name: Get composer cache directory
|
- name: Get composer cache directory
|
||||||
id: composer-cache
|
id: composer-cache
|
||||||
@ -26,6 +26,8 @@ jobs:
|
|||||||
uses: actions/cache@v1
|
uses: actions/cache@v1
|
||||||
with:
|
with:
|
||||||
path: ${{ steps.composer-cache.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') }}
|
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
|
||||||
restore-keys: ${{ runner.os }}-composer-
|
restore-keys: ${{ runner.os }}-composer-
|
||||||
- name: Install Composer dependencies
|
- name: Install Composer dependencies
|
||||||
@ -33,6 +35,4 @@ jobs:
|
|||||||
composer require symfony/orm-pack
|
composer require symfony/orm-pack
|
||||||
composer install --no-progress --no-suggest --prefer-dist --optimize-autoloader
|
composer install --no-progress --no-suggest --prefer-dist --optimize-autoloader
|
||||||
- name: Run Tests
|
- name: Run Tests
|
||||||
run: |
|
run: php bin/phpunit --coverage-text
|
||||||
composer require phpunit
|
|
||||||
php bin/phpunit --coverage-text
|
|
@ -19,7 +19,7 @@ jobs:
|
|||||||
MYSQL_ROOT_PASSWORD: yii
|
MYSQL_ROOT_PASSWORD: yii
|
||||||
MYSQL_DATABASE: yii
|
MYSQL_DATABASE: yii
|
||||||
ports:
|
ports:
|
||||||
- 3306
|
- 3306/tcp
|
||||||
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
|
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
@ -27,7 +27,7 @@ jobs:
|
|||||||
php-versions: ['7.2', '7.3', '7.4']
|
php-versions: ['7.2', '7.3', '7.4']
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v1
|
uses: actions/checkout@v2
|
||||||
- name: Set Node.js 10.x
|
- name: Set Node.js 10.x
|
||||||
uses: actions/setup-node@v1
|
uses: actions/setup-node@v1
|
||||||
with:
|
with:
|
||||||
@ -38,6 +38,8 @@ jobs:
|
|||||||
php-version: ${{ matrix.php-versions }}
|
php-version: ${{ matrix.php-versions }}
|
||||||
extensions: mbstring, intl, gd, imagick, zip, dom, mysql
|
extensions: mbstring, intl, gd, imagick, zip, dom, mysql
|
||||||
coverage: xdebug #optional
|
coverage: xdebug #optional
|
||||||
|
- name: Start mysql service
|
||||||
|
run: sudo /etc/init.d/mysql start
|
||||||
- name: Get composer cache directory
|
- name: Get composer cache directory
|
||||||
id: composer-cache
|
id: composer-cache
|
||||||
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
||||||
@ -45,6 +47,8 @@ jobs:
|
|||||||
uses: actions/cache@v1
|
uses: actions/cache@v1
|
||||||
with:
|
with:
|
||||||
path: ${{ steps.composer-cache.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') }}
|
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
|
||||||
restore-keys: ${{ runner.os }}-composer-
|
restore-keys: ${{ runner.os }}-composer-
|
||||||
- name: Install Composer dependencies
|
- name: Install Composer dependencies
|
||||||
|
@ -27,7 +27,7 @@ jobs:
|
|||||||
php-versions: ['7.2', '7.3', '7.4']
|
php-versions: ['7.2', '7.3', '7.4']
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v1
|
uses: actions/checkout@v2
|
||||||
- name: Set Node.js 10.x
|
- name: Set Node.js 10.x
|
||||||
uses: actions/setup-node@v1
|
uses: actions/setup-node@v1
|
||||||
with:
|
with:
|
||||||
@ -45,6 +45,8 @@ jobs:
|
|||||||
uses: actions/cache@v1
|
uses: actions/cache@v1
|
||||||
with:
|
with:
|
||||||
path: ${{ steps.composer-cache.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') }}
|
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
|
||||||
restore-keys: ${{ runner.os }}-composer-
|
restore-keys: ${{ runner.os }}-composer-
|
||||||
- name: Install Composer dependencies
|
- name: Install Composer dependencies
|
||||||
|
@ -5,12 +5,12 @@ jobs:
|
|||||||
build:
|
build:
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
operating-system: [ubuntu-latest, windows-latest, macOS-latest]
|
operating-system: [ubuntu-latest, windows-latest, macos-latest]
|
||||||
php-versions: ['7.2', '7.3', '7.4']
|
php-versions: ['7.2', '7.3', '7.4']
|
||||||
runs-on: ${{ matrix.operating-system }}
|
runs-on: ${{ matrix.operating-system }}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v1
|
uses: actions/checkout@v2
|
||||||
- name: Setup PHP, with composer and extensions
|
- name: Setup PHP, with composer and extensions
|
||||||
uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php
|
uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php
|
||||||
with:
|
with:
|
||||||
@ -24,6 +24,8 @@ jobs:
|
|||||||
uses: actions/cache@v1
|
uses: actions/cache@v1
|
||||||
with:
|
with:
|
||||||
path: ${{ steps.composer-cache.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') }}
|
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
|
||||||
restore-keys: ${{ runner.os }}-composer-
|
restore-keys: ${{ runner.os }}-composer-
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
|
3927
package-lock.json
generated
3927
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
41
package.json
41
package.json
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "setup-php",
|
"name": "setup-php",
|
||||||
"version": "1.6.1",
|
"version": "1.8.6",
|
||||||
"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,32 +24,33 @@
|
|||||||
"author": "shivammathur",
|
"author": "shivammathur",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^1.2.0",
|
"@actions/core": "^1.2.3",
|
||||||
"@actions/exec": "^1.0.2",
|
"@actions/exec": "^1.0.3",
|
||||||
|
"@actions/io": "^1.0.2",
|
||||||
"fs": "0.0.1-security"
|
"fs": "0.0.1-security"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/jest": "^24.0.21",
|
"@types/jest": "^25.1.4",
|
||||||
"@types/node": "^12.12.16",
|
"@types/node": "^13.9.1",
|
||||||
"@typescript-eslint/eslint-plugin": "^2.11.0",
|
"@typescript-eslint/eslint-plugin": "^2.24.0",
|
||||||
"@typescript-eslint/parser": "^2.11.0",
|
"@typescript-eslint/parser": "^2.24.0",
|
||||||
"@zeit/ncc": "^0.20.5",
|
"@zeit/ncc": "^0.21.1",
|
||||||
"eslint": "^6.6.0",
|
"eslint": "^6.8.0",
|
||||||
"eslint-config-prettier": "^6.5.0",
|
"eslint-config-prettier": "^6.10.0",
|
||||||
"eslint-plugin-import": "^2.19.1",
|
"eslint-plugin-import": "^2.20.1",
|
||||||
"eslint-plugin-jest": "^23.0.3",
|
"eslint-plugin-jest": "^23.8.2",
|
||||||
"eslint-plugin-prettier": "^3.1.1",
|
"eslint-plugin-prettier": "^3.1.2",
|
||||||
"husky": "^3.0.9",
|
"husky": "^4.2.3",
|
||||||
"jest": "^24.9.0",
|
"jest": "^25.1.0",
|
||||||
"jest-circus": "^24.9.0",
|
"jest-circus": "^25.1.0",
|
||||||
"prettier": "^1.17.1",
|
"prettier": "^1.19.1",
|
||||||
"ts-jest": "^24.1.0",
|
"ts-jest": "^25.2.1",
|
||||||
"typescript": "^3.7.3"
|
"typescript": "^3.8.3"
|
||||||
},
|
},
|
||||||
"husky": {
|
"husky": {
|
||||||
"skipCI": true,
|
"skipCI": true,
|
||||||
"hooks": {
|
"hooks": {
|
||||||
"pre-commit": "npm run build && npm run format && npm run release"
|
"pre-commit": "npm run format && npm run lint && npm run build && npm run release"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
BIN
src/bin/php_pcov.dll
Normal file
BIN
src/bin/php_pcov.dll
Normal file
Binary file not shown.
BIN
src/bin/php_ts_pcov.dll
Normal file
BIN
src/bin/php_ts_pcov.dll
Normal file
Binary file not shown.
@ -8,7 +8,7 @@ import * as utils from './utils';
|
|||||||
export async function addINIValuesUnix(
|
export async function addINIValuesUnix(
|
||||||
ini_values_csv: string
|
ini_values_csv: string
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
const ini_values: Array<string> = await utils.INIArray(ini_values_csv);
|
const ini_values: Array<string> = await utils.CSVArray(ini_values_csv);
|
||||||
let script = '\n';
|
let script = '\n';
|
||||||
await utils.asyncForEach(ini_values, async function(line: string) {
|
await utils.asyncForEach(ini_values, async function(line: string) {
|
||||||
script +=
|
script +=
|
||||||
@ -25,7 +25,7 @@ export async function addINIValuesUnix(
|
|||||||
export async function addINIValuesWindows(
|
export async function addINIValuesWindows(
|
||||||
ini_values_csv: string
|
ini_values_csv: string
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
const ini_values: Array<string> = await utils.INIArray(ini_values_csv);
|
const ini_values: Array<string> = await utils.CSVArray(ini_values_csv);
|
||||||
let script = '\n';
|
let script = '\n';
|
||||||
await utils.asyncForEach(ini_values, async function(line: string) {
|
await utils.asyncForEach(ini_values, async function(line: string) {
|
||||||
script +=
|
script +=
|
||||||
@ -44,6 +44,7 @@ export async function addINIValuesWindows(
|
|||||||
*
|
*
|
||||||
* @param ini_values_csv
|
* @param ini_values_csv
|
||||||
* @param os_version
|
* @param os_version
|
||||||
|
* @param no_step
|
||||||
*/
|
*/
|
||||||
export async function addINIValues(
|
export async function addINIValues(
|
||||||
ini_values_csv: string,
|
ini_values_csv: string,
|
||||||
|
24
src/configs/phpunit.json
Normal file
24
src/configs/phpunit.json
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
{
|
||||||
|
"problemMatcher": [
|
||||||
|
{
|
||||||
|
"owner": "phpunit",
|
||||||
|
"pattern": [
|
||||||
|
{
|
||||||
|
"regexp": "^\\d+\\)\\s.*$"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"regexp": "^(.*Failed\\sasserting\\sthat.*)$",
|
||||||
|
"message": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"regexp": "^\\s*$"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"regexp": "^(.*):(\\d+)$",
|
||||||
|
"file": 1,
|
||||||
|
"line": 2
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
@ -7,10 +7,12 @@ import * as config from './config';
|
|||||||
*
|
*
|
||||||
* @param version
|
* @param version
|
||||||
* @param os_version
|
* @param os_version
|
||||||
|
* @param pipe
|
||||||
*/
|
*/
|
||||||
export async function addCoverageXdebug(
|
export async function addCoverageXdebug(
|
||||||
version: string,
|
version: string,
|
||||||
os_version: string
|
os_version: string,
|
||||||
|
pipe: string
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
switch (version) {
|
switch (version) {
|
||||||
case '8.0':
|
case '8.0':
|
||||||
@ -27,7 +29,7 @@ export async function addCoverageXdebug(
|
|||||||
default:
|
default:
|
||||||
return (
|
return (
|
||||||
(await extensions.addExtension('xdebug', version, os_version, true)) +
|
(await extensions.addExtension('xdebug', version, os_version, true)) +
|
||||||
(await utils.suppressOutput(os_version)) +
|
pipe +
|
||||||
'\n' +
|
'\n' +
|
||||||
(await utils.addLog(
|
(await utils.addLog(
|
||||||
'$tick',
|
'$tick',
|
||||||
@ -44,17 +46,19 @@ export async function addCoverageXdebug(
|
|||||||
*
|
*
|
||||||
* @param version
|
* @param version
|
||||||
* @param os_version
|
* @param os_version
|
||||||
|
* @param pipe
|
||||||
*/
|
*/
|
||||||
export async function addCoveragePCOV(
|
export async function addCoveragePCOV(
|
||||||
version: string,
|
version: string,
|
||||||
os_version: string
|
os_version: string,
|
||||||
|
pipe: string
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
let script = '\n';
|
let script = '\n';
|
||||||
switch (version) {
|
switch (version) {
|
||||||
default:
|
default:
|
||||||
script +=
|
script +=
|
||||||
(await extensions.addExtension('pcov', version, os_version, true)) +
|
(await extensions.addExtension('pcov', version, os_version, true)) +
|
||||||
(await utils.suppressOutput(os_version)) +
|
pipe +
|
||||||
'\n';
|
'\n';
|
||||||
script +=
|
script +=
|
||||||
(await config.addINIValues('pcov.enabled=1', os_version, true)) + '\n';
|
(await config.addINIValues('pcov.enabled=1', os_version, true)) + '\n';
|
||||||
@ -62,20 +66,11 @@ export async function addCoveragePCOV(
|
|||||||
// add command to disable xdebug and enable pcov
|
// add command to disable xdebug and enable pcov
|
||||||
switch (os_version) {
|
switch (os_version) {
|
||||||
case 'linux':
|
case 'linux':
|
||||||
script +=
|
|
||||||
'if [ -e /etc/php/' +
|
|
||||||
version +
|
|
||||||
'/mods-available/xdebug.ini ]; then sudo phpdismod -v ' +
|
|
||||||
version +
|
|
||||||
' xdebug; fi\n';
|
|
||||||
script += 'sudo sed -i "/xdebug/d" $ini_file\n';
|
|
||||||
break;
|
|
||||||
case 'darwin':
|
case 'darwin':
|
||||||
script += 'sudo sed -i \'\' "/xdebug/d" $ini_file\n';
|
script += 'remove_extension xdebug' + pipe + '\n';
|
||||||
break;
|
break;
|
||||||
case 'win32':
|
case 'win32':
|
||||||
script +=
|
script += 'Remove-Extension xdebug' + pipe + '\n';
|
||||||
'if(php -m | findstr -i xdebug) { Disable-PhpExtension xdebug C:\\tools\\php }\n';
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -107,38 +102,23 @@ export async function addCoveragePCOV(
|
|||||||
*
|
*
|
||||||
* @param version
|
* @param version
|
||||||
* @param os_version
|
* @param os_version
|
||||||
|
* @param pipe
|
||||||
*/
|
*/
|
||||||
export async function disableCoverage(
|
export async function disableCoverage(
|
||||||
version: string,
|
version: string,
|
||||||
os_version: string
|
os_version: string,
|
||||||
|
pipe: string
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
let script = '\n';
|
let script = '\n';
|
||||||
switch (os_version) {
|
switch (os_version) {
|
||||||
case 'linux':
|
case 'linux':
|
||||||
script +=
|
|
||||||
'if [ -e /etc/php/' +
|
|
||||||
version +
|
|
||||||
'/mods-available/xdebug.ini ]; then sudo phpdismod -v ' +
|
|
||||||
version +
|
|
||||||
' xdebug; fi\n';
|
|
||||||
script +=
|
|
||||||
'if [ -e /etc/php/' +
|
|
||||||
version +
|
|
||||||
'/mods-available/pcov.ini ]; then sudo phpdismod -v ' +
|
|
||||||
version +
|
|
||||||
' pcov; fi\n';
|
|
||||||
script += 'sudo sed -i "/xdebug/d" $ini_file\n';
|
|
||||||
script += 'sudo sed -i "/pcov/d" $ini_file\n';
|
|
||||||
break;
|
|
||||||
case 'darwin':
|
case 'darwin':
|
||||||
script += 'sudo sed -i \'\' "/xdebug/d" $ini_file\n';
|
script += 'remove_extension xdebug' + pipe + '\n';
|
||||||
script += 'sudo sed -i \'\' "/pcov/d" $ini_file\n';
|
script += 'remove_extension pcov' + pipe + '\n';
|
||||||
break;
|
break;
|
||||||
case 'win32':
|
case 'win32':
|
||||||
script +=
|
script += 'Remove-Extension xdebug' + pipe + '\n';
|
||||||
'if(php -m | findstr -i xdebug) { Disable-PhpExtension xdebug C:\\tools\\php }\n';
|
script += 'Remove-Extension pcov' + pipe + '\n';
|
||||||
script +=
|
|
||||||
'if(php -m | findstr -i pcov) { Disable-PhpExtension pcov C:\\tools\\php }\n';
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
script += await utils.addLog(
|
script += await utils.addLog(
|
||||||
@ -163,16 +143,17 @@ export async function addCoverage(
|
|||||||
version: string,
|
version: string,
|
||||||
os_version: string
|
os_version: string
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
coverage_driver.toLowerCase();
|
coverage_driver = coverage_driver.toLowerCase();
|
||||||
const script: string =
|
const script: string =
|
||||||
'\n' + (await utils.stepLog('Setup Coverage', os_version));
|
'\n' + (await utils.stepLog('Setup Coverage', os_version));
|
||||||
|
const pipe: string = await utils.suppressOutput(os_version);
|
||||||
switch (coverage_driver) {
|
switch (coverage_driver) {
|
||||||
case 'pcov':
|
case 'pcov':
|
||||||
return script + (await addCoveragePCOV(version, os_version));
|
return script + (await addCoveragePCOV(version, os_version, pipe));
|
||||||
case 'xdebug':
|
case 'xdebug':
|
||||||
return script + (await addCoverageXdebug(version, os_version));
|
return script + (await addCoverageXdebug(version, os_version, pipe));
|
||||||
case 'none':
|
case 'none':
|
||||||
return script + (await disableCoverage(version, os_version));
|
return script + (await disableCoverage(version, os_version, pipe));
|
||||||
default:
|
default:
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
Binary file not shown.
@ -6,33 +6,78 @@ import * as utils from './utils';
|
|||||||
*
|
*
|
||||||
* @param extension_csv
|
* @param extension_csv
|
||||||
* @param version
|
* @param version
|
||||||
|
* @param pipe
|
||||||
*/
|
*/
|
||||||
export async function addExtensionDarwin(
|
export async function addExtensionDarwin(
|
||||||
extension_csv: string,
|
extension_csv: string,
|
||||||
version: string
|
version: string,
|
||||||
|
pipe: string
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
const extensions: Array<string> = await utils.extensionArray(extension_csv);
|
const extensions: Array<string> = await utils.extensionArray(extension_csv);
|
||||||
let script = '\n';
|
let script = '\n';
|
||||||
await utils.asyncForEach(extensions, async function(extension: string) {
|
await utils.asyncForEach(extensions, async function(extension: string) {
|
||||||
extension = extension.toLowerCase();
|
const version_extension: string = version + extension;
|
||||||
// add script to enable extension is already installed along with php
|
const [extension_name, stability]: string[] = extension.split('-');
|
||||||
let install_command = '';
|
const ext_prefix = await utils.getExtensionPrefix(extension_name);
|
||||||
switch (version + extension) {
|
const command_prefix = 'sudo pecl install -f ';
|
||||||
case '5.6xdebug':
|
let command = '';
|
||||||
install_command = 'sudo pecl install xdebug-2.5.5 >/dev/null 2>&1';
|
switch (true) {
|
||||||
|
// match pre-release versions
|
||||||
|
case /.*-(beta|alpha|devel|snapshot)/.test(version_extension):
|
||||||
|
script +=
|
||||||
|
'\nadd_unstable_extension ' +
|
||||||
|
extension_name +
|
||||||
|
' ' +
|
||||||
|
stability +
|
||||||
|
' ' +
|
||||||
|
ext_prefix;
|
||||||
|
return;
|
||||||
|
// match 5.6xdebug
|
||||||
|
case /5\.6xdebug/.test(version_extension):
|
||||||
|
command = command_prefix + 'xdebug-2.5.5' + pipe;
|
||||||
break;
|
break;
|
||||||
case '5.6redis':
|
// match 7.0xdebug
|
||||||
install_command = 'sudo pecl install redis-2.2.8 >/dev/null 2>&1';
|
case /7\.0xdebug/.test(version_extension):
|
||||||
|
command = command_prefix + 'xdebug-2.9.0' + pipe;
|
||||||
break;
|
break;
|
||||||
|
// match 5.6redis
|
||||||
|
case /5\.6redis/.test(version_extension):
|
||||||
|
command = command_prefix + 'redis-2.2.8' + pipe;
|
||||||
|
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';
|
||||||
|
command = command_prefix + extension + pipe;
|
||||||
|
break;
|
||||||
|
// match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4
|
||||||
|
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
|
||||||
|
script +=
|
||||||
|
'sh ' +
|
||||||
|
path.join(__dirname, '../src/scripts/ext/phalcon_darwin.sh') +
|
||||||
|
' ' +
|
||||||
|
extension +
|
||||||
|
' ' +
|
||||||
|
version;
|
||||||
|
return;
|
||||||
default:
|
default:
|
||||||
install_command = 'sudo pecl install ' + extension + ' >/dev/null 2>&1';
|
command = command_prefix + extension + pipe;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
script +=
|
script +=
|
||||||
'\nadd_extension ' +
|
'\nadd_extension ' +
|
||||||
extension +
|
extension +
|
||||||
' "' +
|
' "' +
|
||||||
install_command +
|
command +
|
||||||
'" ' +
|
'" ' +
|
||||||
(await utils.getExtensionPrefix(extension));
|
(await utils.getExtensionPrefix(extension));
|
||||||
});
|
});
|
||||||
@ -52,10 +97,39 @@ export async function addExtensionWindows(
|
|||||||
const extensions: Array<string> = await utils.extensionArray(extension_csv);
|
const extensions: Array<string> = await utils.extensionArray(extension_csv);
|
||||||
let script = '\n';
|
let script = '\n';
|
||||||
await utils.asyncForEach(extensions, async function(extension: string) {
|
await utils.asyncForEach(extensions, async function(extension: string) {
|
||||||
// add script to enable extension is already installed along with php
|
const [extension_name, stability]: string[] = extension.split('-');
|
||||||
switch (version + extension) {
|
const version_extension: string = version + extension;
|
||||||
case '7.4redis':
|
switch (true) {
|
||||||
script += '\nAdd-Extension ' + extension + ' beta';
|
// match pre-release versions
|
||||||
|
case /.*-(beta|alpha|devel|snapshot)/.test(version_extension):
|
||||||
|
script += '\nAdd-Extension ' + extension_name + ' ' + stability;
|
||||||
|
break;
|
||||||
|
// match 5.6mysql, 5.6mysqli, 5.6mysqlnd
|
||||||
|
case /^5\.6(mysql|mysqli|mysqlnd)$/.test(version_extension):
|
||||||
|
script +=
|
||||||
|
'\nAdd-Extension mysql\nAdd-Extension mysqli\nAdd-Extension mysqlnd';
|
||||||
|
break;
|
||||||
|
// match 7.0mysql..8.0mysql
|
||||||
|
// match 7.0mysqli..8.0mysqli
|
||||||
|
// match 7.0mysqlnd..8.0mysqlnd
|
||||||
|
case /[7-8]\.\d(mysql|mysqli|mysqlnd)$/.test(version_extension):
|
||||||
|
script += '\nAdd-Extension mysqli\nAdd-Extension mysqlnd';
|
||||||
|
break;
|
||||||
|
// match sqlite
|
||||||
|
case /^sqlite$/.test(extension):
|
||||||
|
extension = 'sqlite3';
|
||||||
|
script += '\nAdd-Extension ' + extension;
|
||||||
|
break;
|
||||||
|
// match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4
|
||||||
|
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
|
||||||
|
script +=
|
||||||
|
'\n& ' +
|
||||||
|
path.join(__dirname, '../src/scripts/ext/phalcon.ps1') +
|
||||||
|
' ' +
|
||||||
|
extension +
|
||||||
|
' ' +
|
||||||
|
version +
|
||||||
|
'\n';
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
script += '\nAdd-Extension ' + extension;
|
script += '\nAdd-Extension ' + extension;
|
||||||
@ -70,72 +144,75 @@ export async function addExtensionWindows(
|
|||||||
*
|
*
|
||||||
* @param extension_csv
|
* @param extension_csv
|
||||||
* @param version
|
* @param version
|
||||||
|
* @param pipe
|
||||||
*/
|
*/
|
||||||
export async function addExtensionLinux(
|
export async function addExtensionLinux(
|
||||||
extension_csv: string,
|
extension_csv: string,
|
||||||
version: string
|
version: string,
|
||||||
|
pipe: string
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
const extensions: Array<string> = await utils.extensionArray(extension_csv);
|
const extensions: Array<string> = await utils.extensionArray(extension_csv);
|
||||||
let script = '\n';
|
let script = '\n';
|
||||||
await utils.asyncForEach(extensions, async function(extension: string) {
|
await utils.asyncForEach(extensions, async function(extension: string) {
|
||||||
extension = extension.toLowerCase();
|
const version_extension: string = version + extension;
|
||||||
// add script to enable extension is already installed along with php
|
const [extension_name, stability]: string[] = extension.split('-');
|
||||||
|
const ext_prefix = await utils.getExtensionPrefix(extension_name);
|
||||||
let install_command = '';
|
const command_prefix = 'sudo $debconf_fix apt-get install -y php';
|
||||||
switch (version + extension) {
|
let command = '';
|
||||||
case '7.4redis':
|
switch (true) {
|
||||||
install_command =
|
// match pre-release versions
|
||||||
'sudo DEBIAN_FRONTEND=noninteractive apt-get install -y php7.4-igbinary php7.4-redis >/dev/null 2>&1';
|
case /.*-(beta|alpha|devel|snapshot)/.test(version_extension):
|
||||||
break;
|
script +=
|
||||||
case '7.2phalcon3':
|
'\nadd_unstable_extension ' +
|
||||||
case '7.3phalcon3':
|
extension_name +
|
||||||
install_command =
|
' ' +
|
||||||
|
stability +
|
||||||
|
' ' +
|
||||||
|
ext_prefix;
|
||||||
|
return;
|
||||||
|
// match 5.6gearman..7.4gearman
|
||||||
|
case /^((5\.6)|(7\.[0-4]))gearman$/.test(version_extension):
|
||||||
|
command =
|
||||||
'sh ' +
|
'sh ' +
|
||||||
path.join(__dirname, '../src/scripts/phalcon.sh') +
|
path.join(__dirname, '../src/scripts/ext/gearman.sh') +
|
||||||
' master ' +
|
|
||||||
version +
|
|
||||||
' >/dev/null 2>&1';
|
|
||||||
break;
|
|
||||||
case '7.2phalcon4':
|
|
||||||
case '7.3phalcon4':
|
|
||||||
case '7.4phalcon4':
|
|
||||||
install_command =
|
|
||||||
'sh ' +
|
|
||||||
path.join(__dirname, '../src/scripts/phalcon.sh') +
|
|
||||||
' 4.0.x ' +
|
|
||||||
version +
|
|
||||||
' >/dev/null 2>&1';
|
|
||||||
break;
|
|
||||||
case '7.0gearman':
|
|
||||||
case '7.1gearman':
|
|
||||||
case '7.2gearman':
|
|
||||||
case '7.3gearman':
|
|
||||||
case '7.4gearman':
|
|
||||||
install_command =
|
|
||||||
'sh ' +
|
|
||||||
path.join(__dirname, '../src/scripts/gearman.sh') +
|
|
||||||
' ' +
|
' ' +
|
||||||
version +
|
version +
|
||||||
' >/dev/null 2>&1';
|
pipe;
|
||||||
|
break;
|
||||||
|
// match 7.0phalcon3...7.3phalcon3 or 7.2phalcon4...7.4phalcon4
|
||||||
|
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
|
||||||
|
script +=
|
||||||
|
'\nsh ' +
|
||||||
|
path.join(__dirname, '../src/scripts/ext/phalcon.sh') +
|
||||||
|
' ' +
|
||||||
|
extension +
|
||||||
|
' ' +
|
||||||
|
version;
|
||||||
|
return;
|
||||||
|
// match 7.0xdebug..7.4xdebug
|
||||||
|
case /^7\.[0-4]xdebug$/.test(version_extension):
|
||||||
|
script +=
|
||||||
|
'\nupdate_extension xdebug 2.9.2' +
|
||||||
|
pipe +
|
||||||
|
'\n' +
|
||||||
|
(await utils.addLog('$tick', 'xdebug', 'Enabled', 'linux'));
|
||||||
|
return;
|
||||||
|
// match sqlite
|
||||||
|
case /^sqlite$/.test(extension):
|
||||||
|
extension = 'sqlite3';
|
||||||
|
command = command_prefix + version + '-' + extension + pipe;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
install_command =
|
command =
|
||||||
'sudo DEBIAN_FRONTEND=noninteractive apt-get install -y php' +
|
command_prefix +
|
||||||
version +
|
version +
|
||||||
'-' +
|
'-' +
|
||||||
extension.replace('pdo_', '').replace('pdo-', '') +
|
extension.replace('pdo_', '').replace('pdo-', '') +
|
||||||
' >/dev/null 2>&1 || sudo pecl install ' +
|
pipe;
|
||||||
extension +
|
|
||||||
' >/dev/null 2>&1';
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
script +=
|
script +=
|
||||||
'\nadd_extension ' +
|
'\nadd_extension ' + extension + ' "' + command + '" ' + ext_prefix;
|
||||||
extension +
|
|
||||||
' "' +
|
|
||||||
install_command +
|
|
||||||
'" ' +
|
|
||||||
(await utils.getExtensionPrefix(extension));
|
|
||||||
});
|
});
|
||||||
return script;
|
return script;
|
||||||
}
|
}
|
||||||
@ -146,7 +223,7 @@ export async function addExtensionLinux(
|
|||||||
* @param extension_csv
|
* @param extension_csv
|
||||||
* @param version
|
* @param version
|
||||||
* @param os_version
|
* @param os_version
|
||||||
* @param log_prefix
|
* @param no_step
|
||||||
*/
|
*/
|
||||||
export async function addExtension(
|
export async function addExtension(
|
||||||
extension_csv: string,
|
extension_csv: string,
|
||||||
@ -154,12 +231,11 @@ export async function addExtension(
|
|||||||
os_version: string,
|
os_version: string,
|
||||||
no_step = false
|
no_step = false
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
|
const pipe: string = await utils.suppressOutput(os_version);
|
||||||
let script = '\n';
|
let script = '\n';
|
||||||
switch (no_step) {
|
switch (no_step) {
|
||||||
case true:
|
case true:
|
||||||
script +=
|
script += (await utils.stepLog('Setup Extensions', os_version)) + pipe;
|
||||||
(await utils.stepLog('Setup Extensions', os_version)) +
|
|
||||||
(await utils.suppressOutput(os_version));
|
|
||||||
break;
|
break;
|
||||||
case false:
|
case false:
|
||||||
default:
|
default:
|
||||||
@ -171,9 +247,9 @@ export async function addExtension(
|
|||||||
case 'win32':
|
case 'win32':
|
||||||
return script + (await addExtensionWindows(extension_csv, version));
|
return script + (await addExtensionWindows(extension_csv, version));
|
||||||
case 'darwin':
|
case 'darwin':
|
||||||
return script + (await addExtensionDarwin(extension_csv, version));
|
return script + (await addExtensionDarwin(extension_csv, version, pipe));
|
||||||
case 'linux':
|
case 'linux':
|
||||||
return script + (await addExtensionLinux(extension_csv, version));
|
return script + (await addExtensionLinux(extension_csv, version, pipe));
|
||||||
default:
|
default:
|
||||||
return await utils.log(
|
return await utils.log(
|
||||||
'Platform ' + os_version + ' is not supported',
|
'Platform ' + os_version + ' is not supported',
|
||||||
|
@ -3,7 +3,9 @@ import * as core from '@actions/core';
|
|||||||
import * as config from './config';
|
import * as config from './config';
|
||||||
import * as coverage from './coverage';
|
import * as coverage from './coverage';
|
||||||
import * as extensions from './extensions';
|
import * as extensions from './extensions';
|
||||||
|
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
|
||||||
@ -20,13 +22,24 @@ export async function build(
|
|||||||
// taking inputs
|
// taking inputs
|
||||||
const extension_csv: string =
|
const extension_csv: string =
|
||||||
(await utils.getInput('extensions', false)) ||
|
(await utils.getInput('extensions', false)) ||
|
||||||
|
(await utils.getInput('extension', false)) ||
|
||||||
(await utils.getInput('extension-csv', false));
|
(await utils.getInput('extension-csv', false));
|
||||||
const ini_values_csv: string =
|
const ini_values_csv: string =
|
||||||
(await utils.getInput('ini-values', false)) ||
|
(await utils.getInput('ini-values', false)) ||
|
||||||
(await utils.getInput('ini-values-csv', false));
|
(await utils.getInput('ini-values-csv', false));
|
||||||
const coverage_driver: string = await utils.getInput('coverage', false);
|
const coverage_driver: string = await utils.getInput('coverage', false);
|
||||||
|
const pecl: string = await utils.getInput('pecl', false);
|
||||||
|
let tools_csv: string = await utils.getInput('tools', false);
|
||||||
|
if (
|
||||||
|
pecl == 'true' ||
|
||||||
|
/.*-(beta|alpha|devel|snapshot).*/.test(extension_csv)
|
||||||
|
) {
|
||||||
|
tools_csv = 'pecl, ' + tools_csv;
|
||||||
|
}
|
||||||
|
|
||||||
|
let script: string = await utils.readScript(filename);
|
||||||
|
script += await tools.addTools(tools_csv, version, os_version);
|
||||||
|
|
||||||
let script: string = await utils.readScript(filename, version, os_version);
|
|
||||||
if (extension_csv) {
|
if (extension_csv) {
|
||||||
script += await extensions.addExtension(extension_csv, version, os_version);
|
script += await extensions.addExtension(extension_csv, version, os_version);
|
||||||
}
|
}
|
||||||
@ -47,25 +60,21 @@ export async function run(): Promise<void> {
|
|||||||
try {
|
try {
|
||||||
const os_version: string = process.platform;
|
const os_version: string = process.platform;
|
||||||
let version: string = await utils.getInput('php-version', true);
|
let version: string = await utils.getInput('php-version', true);
|
||||||
version = version.length > 1 ? version : version + '.0';
|
version = version.length > 1 ? version.slice(0, 3) : version + '.0';
|
||||||
// check the os version and run the respective script
|
// check the os version and run the respective script
|
||||||
let script_path = '';
|
let script_path = '';
|
||||||
switch (os_version) {
|
switch (os_version) {
|
||||||
case 'darwin':
|
case 'darwin':
|
||||||
|
case 'linux':
|
||||||
script_path = await build(os_version + '.sh', version, os_version);
|
script_path = await build(os_version + '.sh', version, os_version);
|
||||||
await exec('sh ' + script_path + ' ' + version + ' ' + __dirname);
|
await exec('sh ' + script_path + ' ' + version + ' ' + __dirname);
|
||||||
break;
|
break;
|
||||||
case 'linux': {
|
|
||||||
const pecl: string = await utils.getInput('pecl', false);
|
|
||||||
script_path = await build(os_version + '.sh', version, os_version);
|
|
||||||
await exec('sh ' + script_path + ' ' + version + ' ' + pecl);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 'win32':
|
case 'win32':
|
||||||
script_path = await build('win32.ps1', version, os_version);
|
script_path = await build('win32.ps1', version, os_version);
|
||||||
await exec('pwsh ' + script_path + ' -version ' + version);
|
await exec('pwsh ' + script_path + ' ' + version + ' ' + __dirname);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
await matchers.addMatchers();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
core.setFailed(error.message);
|
core.setFailed(error.message);
|
||||||
}
|
}
|
||||||
|
18
src/matchers.ts
Normal file
18
src/matchers.ts
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
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);
|
||||||
|
}
|
@ -1,116 +0,0 @@
|
|||||||
tick="✓"
|
|
||||||
cross="✗"
|
|
||||||
|
|
||||||
step_log() {
|
|
||||||
message=$1
|
|
||||||
printf "\n\033[90;1m==> \033[0m\033[37;1m%s\033[0m\n" "$message"
|
|
||||||
}
|
|
||||||
|
|
||||||
add_log() {
|
|
||||||
mark=$1
|
|
||||||
subject=$2
|
|
||||||
message=$3
|
|
||||||
if [ "$mark" = "$tick" ]; then
|
|
||||||
printf "\033[32;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s\033[0m\n" "$mark" "$subject" "$message"
|
|
||||||
else
|
|
||||||
printf "\033[31;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s\033[0m\n" "$mark" "$subject" "$message"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
version='7.4.0'
|
|
||||||
step_log "Setup dependencies"
|
|
||||||
for package in pkg-config autoconf bison re2c openssl@1.1 krb5 enchant libffi freetype intltool icu4c libiconv t1lib gd libzip gmp tidyp libxml2 libxslt postgresql curl;
|
|
||||||
do
|
|
||||||
brew install "$package" >/dev/null 2>&1
|
|
||||||
add_log "$tick" "$package" "Installed"
|
|
||||||
done
|
|
||||||
brew link icu4c gettext --force >/dev/null 2>&1
|
|
||||||
|
|
||||||
for package in gettext gmp krb5 icu4c bison openssl@1.1 libxml2 libffi libxslt libiconv pkgconfig enchant krb5 readline libedit freetype;
|
|
||||||
do
|
|
||||||
caps_package=$(echo "$package" | tr '[:lower:]' '[:upper:]')
|
|
||||||
{
|
|
||||||
echo 'export PATH="/usr/local/opt/'"$package"'/bin:$PATH"'
|
|
||||||
echo 'export PKG_CONFIG_PATH="/usr/local/opt/'$package'/lib/pkgconfig:$PKG_CONFIG_PATH"'
|
|
||||||
echo 'export '"$caps_package"'_LIBS="-L/usr/local/opt/'$package'/lib"'
|
|
||||||
echo 'export '"$caps_package"'_CFLAGS="-I/usr/local/opt/'$package'/include"'
|
|
||||||
} >> ~/.bash_profile;
|
|
||||||
done
|
|
||||||
{
|
|
||||||
echo 'export ICONV_LIBS="-L/usr/local/opt/libiconv/lib"'
|
|
||||||
echo 'export ICONV_CFLAGS="-I/usr/local/opt/libiconv/include"'
|
|
||||||
echo 'export LIBXML_LIBS="-L/usr/local/opt/libxml2/lib"'
|
|
||||||
echo 'export LIBXML_CFLAGS="-I/usr/local/opt/libxml2/include"'
|
|
||||||
echo 'export ICU_LIBS="-L/usr/local/opt/icu4c/lib"'
|
|
||||||
echo 'export ICU_CFLAGS="-I/usr/local/opt/icu4c/include"'
|
|
||||||
echo 'export OPENSSL_LIBS="-L/usr/local/opt/openssl@1.1/lib -lcrypto"'
|
|
||||||
echo 'export OPENSSL_CFLAGS="-I/usr/local/opt/openssl@1.1/include"'
|
|
||||||
echo 'export OPENSSL_ROOT_DIR="/usr/local/opt/openssl@1.1/"'
|
|
||||||
echo 'export OPENSSL_LIB_DIR="/usr/local/opt/openssl@1.1/lib"'
|
|
||||||
echo 'export OPENSSL_INCLUDE_DIR="/usr/local/opt/openssl@1.1/include"'
|
|
||||||
echo 'export PKG_CONFIG="/usr/local/opt/pkgconfig/bin/pkg-config"'
|
|
||||||
echo 'export EXTRA_LIBS="/usr/local/opt/readline/lib/libhistory.dylib
|
|
||||||
/usr/local/opt/readline/lib/libreadline.dylib
|
|
||||||
/usr/local/opt/openssl@1.1/lib/libssl.dylib
|
|
||||||
/usr/local/opt/openssl@1.1/lib/libcrypto.dylib
|
|
||||||
/usr/local/opt/icu4c/lib/libicudata.dylib
|
|
||||||
/usr/local/opt/icu4c/lib/libicui18n.dylib
|
|
||||||
/usr/local/opt/icu4c/lib/libicuio.dylib
|
|
||||||
/usr/local/opt/icu4c/lib/libicutu.dylib
|
|
||||||
/usr/local/opt/icu4c/lib/libicuuc.dylib"'
|
|
||||||
} >> ~/.bash_profile
|
|
||||||
config_file=$2/../src/configs/config.yaml
|
|
||||||
|
|
||||||
step_log "Setup PHPBrew"
|
|
||||||
curl -L -O https://github.com/phpbrew/phpbrew/raw/master/phpbrew >/dev/null 2>&1
|
|
||||||
chmod +x ./phpbrew
|
|
||||||
sudo mv phpbrew /usr/local/bin/phpbrew
|
|
||||||
sudo mkdir -p /opt/phpbrew
|
|
||||||
sudo mkdir -p /usr/local/lib
|
|
||||||
sudo mkdir -p /usr/local/bin
|
|
||||||
sudo phpbrew init --root=/opt/phpbrew --config="$config_file" >/dev/null 2>&1
|
|
||||||
sudo chmod -R 777 /opt/phpbrew
|
|
||||||
export PHPBREW_ROOT=/opt/phpbrew
|
|
||||||
export PHPBREW_HOME=/opt/phpbrew
|
|
||||||
echo "[[ -e ~/.phpbrew/bashrc ]] && source ~/.phpbrew/bashrc" >> ~/.bashrc
|
|
||||||
add_log "$tick" "PHPBrew" "Installed"
|
|
||||||
|
|
||||||
source ~/.bash_profile >/dev/null 2>&1
|
|
||||||
source ~/.bashrc >/dev/null 2>&1
|
|
||||||
|
|
||||||
step_log "Setup PHP and Composer"
|
|
||||||
phpbrew install -j 6 github:php/php-src@PHP-$version as php-$version +dev >/dev/null 2>&1
|
|
||||||
phpbrew switch $version
|
|
||||||
sudo ln -sf /opt/phpbrew/php/php-$version/bin/* /usr/local/bin/
|
|
||||||
sudo ln -sf /opt/phpbrew/php/php-$version/etc/php.ini /etc/php.ini
|
|
||||||
ini_file=$(php --ini | grep "Loaded Configuration" | sed -e "s|.*:s*||" | sed "s/ //g")
|
|
||||||
ext_dir=$(php -i | grep "extension_dir => /opt" | sed -e "s|.*=> s*||")
|
|
||||||
pecl config-set php_ini "$ini_file" >/dev/null 2>&1
|
|
||||||
pear config-set php_ini "$ini_file" >/dev/null 2>&1
|
|
||||||
sudo chmod 777 "$ini_file"
|
|
||||||
brew install composer >/dev/null 2>&1
|
|
||||||
|
|
||||||
add_log "$tick" "PHP" "Installed PHP$version"
|
|
||||||
add_log "$tick" "Composer" "Installed"
|
|
||||||
|
|
||||||
add_extension() {
|
|
||||||
extension=$1
|
|
||||||
install_command=$2
|
|
||||||
prefix=$3
|
|
||||||
if ! php -m | grep -i -q "$extension" && [ -e "$ext_dir/$extension.so" ]; then
|
|
||||||
echo "$prefix=$extension" >>"$ini_file" && add_log "$tick" "$extension" "Enabled"
|
|
||||||
elif php -m | grep -i -q "$extension"; then
|
|
||||||
add_log "$tick" "$extension" "Enabled"
|
|
||||||
elif ! php -m | grep -i -q "$extension"; then
|
|
||||||
exists=$(curl -sL https://pecl.php.net/json.php?package="$extension" -w "%{http_code}" -o /dev/null)
|
|
||||||
if [ "$exists" = "200" ]; then
|
|
||||||
(
|
|
||||||
eval "$install_command" && \
|
|
||||||
add_log "$tick" "$extension" "Installed and enabled"
|
|
||||||
) || add_log "$cross" "$extension" "Could not install $extension on PHP$version"
|
|
||||||
else
|
|
||||||
if ! php -m | grep -i -q "$extension"; then
|
|
||||||
add_log "$cross" "$extension" "Could not find $extension for PHP$version on PECL"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
}
|
|
@ -1,11 +1,10 @@
|
|||||||
tick="✓"
|
# Function to log start of a operation
|
||||||
cross="✗"
|
|
||||||
|
|
||||||
step_log() {
|
step_log() {
|
||||||
message=$1
|
message=$1
|
||||||
printf "\n\033[90;1m==> \033[0m\033[37;1m%s\033[0m\n" "$message"
|
printf "\n\033[90;1m==> \033[0m\033[37;1m%s\033[0m\n" "$message"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Function to log result of a operation
|
||||||
add_log() {
|
add_log() {
|
||||||
mark=$1
|
mark=$1
|
||||||
subject=$2
|
subject=$2
|
||||||
@ -17,41 +16,170 @@ add_log() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
step_log "Setup PHP and Composer"
|
# Function to remove extensions
|
||||||
version=$1
|
remove_extension() {
|
||||||
export HOMEBREW_NO_INSTALL_CLEANUP=TRUE
|
extension=$1
|
||||||
brew tap shivammathur/homebrew-php >/dev/null 2>&1
|
sudo sed -i '' "/$extension/d" "$ini_file"
|
||||||
brew install shivammathur/php/php@"$1" composer >/dev/null 2>&1
|
sudo rm -rf "$scan_dir"/*"$extension"* >/dev/null 2>&1
|
||||||
brew link --force --overwrite php@"$1" >/dev/null 2>&1
|
sudo rm -rf "$ext_dir"/"$extension".so >/dev/null 2>&1
|
||||||
ini_file=$(php -d "date.timezone=UTC" --ini | grep "Loaded Configuration" | sed -e "s|.*:s*||" | sed "s/ //g")
|
}
|
||||||
echo "date.timezone=UTC" >> "$ini_file"
|
|
||||||
ext_dir=$(php -i | grep "extension_dir => /usr" | sed -e "s|.*=> s*||")
|
|
||||||
sudo chmod 777 "$ini_file"
|
|
||||||
mkdir -p "$(pecl config-get ext_dir)"
|
|
||||||
composer global require hirak/prestissimo >/dev/null 2>&1
|
|
||||||
semver=$(php -v | head -n 1 | cut -f 2 -d ' ')
|
|
||||||
add_log "$tick" "PHP" "Installed PHP $semver"
|
|
||||||
add_log "$tick" "Composer" "Installed"
|
|
||||||
|
|
||||||
|
# Function to test if extension is loaded
|
||||||
|
check_extension() {
|
||||||
|
extension=$1
|
||||||
|
if [ "$extension" != "mysql" ]; then
|
||||||
|
php -m | grep -i -q -w "$extension"
|
||||||
|
else
|
||||||
|
php -m | grep -i -q "$extension"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Fuction to get the PECL version
|
||||||
|
get_pecl_version() {
|
||||||
|
extension=$1
|
||||||
|
stability=$2
|
||||||
|
pecl_rest='https://pecl.php.net/rest/r/'
|
||||||
|
response=$(curl -q -sSL "$pecl_rest$extension"/allreleases.xml)
|
||||||
|
pecl_version=$(echo "$response" | grep -m 1 -Eo "(\d*\.\d*\.\d*$stability\d*)")
|
||||||
|
if [ ! "$pecl_version" ]; then
|
||||||
|
pecl_version=$(echo "$response" | grep -m 1 -Eo "(\d*\.\d*\.\d*)")
|
||||||
|
fi
|
||||||
|
echo "$pecl_version"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to install a PECL version
|
||||||
|
add_pecl_extension() {
|
||||||
|
extension=$1
|
||||||
|
pecl_version=$2
|
||||||
|
prefix=$3
|
||||||
|
if ! check_extension "$extension" && [ -e "$ext_dir/$extension.so" ]; then
|
||||||
|
echo "$prefix=$ext_dir/$extension.so" >>"$ini_file"
|
||||||
|
fi
|
||||||
|
ext_version=$(php -r "echo phpversion('$extension');")
|
||||||
|
if [ "$ext_version" = "$pecl_version" ]; then
|
||||||
|
add_log "$tick" "$extension" "Enabled"
|
||||||
|
else
|
||||||
|
remove_extension "$extension"
|
||||||
|
(
|
||||||
|
sudo pecl install -f "$extension-$pecl_version" >/dev/null 2>&1 &&
|
||||||
|
check_extension "$extension" &&
|
||||||
|
add_log "$tick" "$extension" "Installed and enabled"
|
||||||
|
) || add_log "$cross" "$extension" "Could not install $extension-$pecl_version on PHP $semver"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to setup extensions
|
||||||
add_extension() {
|
add_extension() {
|
||||||
extension=$1
|
extension=$1
|
||||||
install_command=$2
|
install_command=$2
|
||||||
prefix=$3
|
prefix=$3
|
||||||
if ! php -m | grep -i -q ^"$extension"$ && [ -e "$ext_dir/$extension.so" ]; then
|
if ! check_extension "$extension" && [ -e "$ext_dir/$extension.so" ]; then
|
||||||
echo "$prefix=$extension" >>"$ini_file" && add_log $tick "$extension" "Enabled"
|
echo "$prefix=$ext_dir/$extension.so" >>"$ini_file" && add_log "$tick" "$extension" "Enabled"
|
||||||
elif php -m | grep -i -q ^"$extension"$; then
|
elif check_extension "$extension"; then
|
||||||
add_log "$tick" "$extension" "Enabled"
|
add_log "$tick" "$extension" "Enabled"
|
||||||
elif ! php -m | grep -i -q ^"$extension"$; then
|
elif ! check_extension "$extension"; then
|
||||||
exists=$(curl -sL https://pecl.php.net/json.php?package="$extension" -w "%{http_code}" -o /dev/null)
|
|
||||||
if [ "$exists" = "200" ]; then
|
|
||||||
(
|
(
|
||||||
eval "$install_command" && \
|
eval "$install_command" >/dev/null 2>&1 &&
|
||||||
|
check_extension "$extension" &&
|
||||||
add_log "$tick" "$extension" "Installed and enabled"
|
add_log "$tick" "$extension" "Installed and enabled"
|
||||||
) || add_log "$cross" "$extension" "Could not install $extension on PHP $semver"
|
) || add_log "$cross" "$extension" "Could not install $extension on PHP $semver"
|
||||||
else
|
|
||||||
if ! php -m | grep -i -q ^"$extension"$; then
|
|
||||||
add_log "$cross" "$extension" "Could not find $extension for PHP $semver on PECL"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Function to pre-release extensions using PECL
|
||||||
|
add_unstable_extension() {
|
||||||
|
extension=$1
|
||||||
|
stability=$2
|
||||||
|
prefix=$3
|
||||||
|
pecl_version=$(get_pecl_version "$extension" "$stability")
|
||||||
|
add_pecl_extension "$extension" "$pecl_version" "$prefix"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to setup a remote tool
|
||||||
|
add_tool() {
|
||||||
|
url=$1
|
||||||
|
tool=$2
|
||||||
|
tool_path="$tool_path_dir/$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 [ "$status_code" = "200" ]; then
|
||||||
|
sudo chmod a+x "$tool_path"
|
||||||
|
if [ "$tool" = "phive" ]; then
|
||||||
|
add_extension curl "sudo pecl install -f curl" extension >/dev/null 2>&1
|
||||||
|
add_extension mbstring "sudo pecl install -f mbstring" extension >/dev/null 2>&1
|
||||||
|
add_extension xml "sudo pecl install -f xml" extension >/dev/null 2>&1
|
||||||
|
elif [ "$tool" = "cs2pr" ]; then
|
||||||
|
sudo sed -i '' 's/exit(9)/exit(0)/' "$tool_path"
|
||||||
|
tr -d '\r' < "$tool_path" | sudo tee "$tool_path.tmp" >/dev/null 2>&1 && sudo mv "$tool_path.tmp" "$tool_path"
|
||||||
|
sudo chmod a+x "$tool_path"
|
||||||
|
fi
|
||||||
|
add_log "$tick" "$tool" "Added"
|
||||||
|
else
|
||||||
|
add_log "$cross" "$tool" "Could not setup $tool"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to add a tool using composer
|
||||||
|
add_composertool() {
|
||||||
|
tool=$1
|
||||||
|
release=$2
|
||||||
|
prefix=$3
|
||||||
|
(
|
||||||
|
composer global require "$prefix$release" >/dev/null 2>&1 &&
|
||||||
|
sudo ln -sf "$(composer -q global config home)"/vendor/bin/"$tool" /usr/local/bin/"$tool" &&
|
||||||
|
add_log "$tick" "$tool" "Added"
|
||||||
|
) || add_log "$cross" "$tool" "Could not setup $tool"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to configure PECL
|
||||||
|
configure_pecl() {
|
||||||
|
for tool in pear pecl; do
|
||||||
|
sudo "$tool" config-set php_ini "$ini_file" >/dev/null 2>&1
|
||||||
|
sudo "$tool" config-set auto_discover 1 >/dev/null 2>&1
|
||||||
|
sudo "$tool" channel-update "$tool".php.net >/dev/null 2>&1
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to log PECL, it is installed along with PHP
|
||||||
|
add_pecl() {
|
||||||
|
add_log "$tick" "PECL" "Added"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to setup PHP and composer
|
||||||
|
setup_php_and_composer() {
|
||||||
|
export HOMEBREW_NO_INSTALL_CLEANUP=TRUE
|
||||||
|
brew tap shivammathur/homebrew-php >/dev/null 2>&1
|
||||||
|
brew install shivammathur/php/php@"$version" >/dev/null 2>&1
|
||||||
|
brew link --force --overwrite php@"$version" >/dev/null 2>&1
|
||||||
|
}
|
||||||
|
|
||||||
|
# Variables
|
||||||
|
tick="✓"
|
||||||
|
cross="✗"
|
||||||
|
version=$1
|
||||||
|
tool_path_dir="/usr/local/bin"
|
||||||
|
existing_version=$(php-config --version | cut -c 1-3)
|
||||||
|
|
||||||
|
# Setup PHP
|
||||||
|
step_log "Setup PHP"
|
||||||
|
if [ "$existing_version" != "$version" ]; then
|
||||||
|
export HOMEBREW_NO_INSTALL_CLEANUP=TRUE >/dev/null 2>&1
|
||||||
|
brew tap shivammathur/homebrew-php >/dev/null 2>&1
|
||||||
|
brew install shivammathur/php/php@"$version" >/dev/null 2>&1
|
||||||
|
brew link --force --overwrite php@"$version" >/dev/null 2>&1
|
||||||
|
status="Installed"
|
||||||
|
else
|
||||||
|
status="Found"
|
||||||
|
fi
|
||||||
|
ini_file=$(php -d "date.timezone=UTC" --ini | grep "Loaded Configuration" | sed -e "s|.*:s*||" | sed "s/ //g")
|
||||||
|
sudo chmod 777 "$ini_file" "$tool_path_dir"
|
||||||
|
echo "date.timezone=UTC" >>"$ini_file"
|
||||||
|
ext_dir=$(php -i | grep -Ei "extension_dir => /(usr|opt)" | sed -e "s|.*=> s*||")
|
||||||
|
scan_dir=$(php --ini | grep additional | sed -e "s|.*: s*||")
|
||||||
|
sudo mkdir -p "$ext_dir"
|
||||||
|
semver=$(php -v | head -n 1 | cut -f 2 -d ' ')
|
||||||
|
configure_pecl
|
||||||
|
add_log "$tick" "PHP" "$status PHP $semver"
|
||||||
|
56
src/scripts/ext/phalcon.ps1
Normal file
56
src/scripts/ext/phalcon.ps1
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
Param (
|
||||||
|
[Parameter(Position = 0, Mandatory = $true)]
|
||||||
|
[ValidateNotNull()]
|
||||||
|
[ValidateSet('phalcon3', 'phalcon4')]
|
||||||
|
[string]
|
||||||
|
$extension,
|
||||||
|
[Parameter(Position = 1, Mandatory = $true)]
|
||||||
|
[ValidateNotNull()]
|
||||||
|
[ValidateLength(1, [int]::MaxValue)]
|
||||||
|
[string]
|
||||||
|
$version
|
||||||
|
)
|
||||||
|
|
||||||
|
# Function to install phalcon
|
||||||
|
Function Install-Phalcon() {
|
||||||
|
if ($extension_version -eq '4') {
|
||||||
|
Install-Phpextension phalcon -MinimumStability stable -Path $php_dir
|
||||||
|
} else {
|
||||||
|
$installed = Get-Php -Path $php_dir
|
||||||
|
$nts = if (!$installed.ThreadSafe) { "_nts" } else { "" }
|
||||||
|
$match = Invoke-WebRequest -UseBasicParsing -Uri $domain/phalcon/cphalcon/releases | Select-String -Pattern "href=`"(.*phalcon_x64_.*_php${version}_${extension_version}.*[0-9]${nts}.zip)`""
|
||||||
|
$zip_file = $match.Matches[0].Groups[1].Value
|
||||||
|
Invoke-WebRequest -UseBasicParsing -Uri $domain/$zip_file -OutFile $ENV:RUNNER_TOOL_CACHE\phalcon.zip > $null 2>&1
|
||||||
|
Expand-Archive -Path $ENV:RUNNER_TOOL_CACHE\phalcon.zip -DestinationPath $ENV:RUNNER_TOOL_CACHE\phalcon -Force > $null 2>&1
|
||||||
|
Copy-Item -Path "$ENV:RUNNER_TOOL_CACHE\phalcon\php_phalcon.dll" -Destination "$ext_dir\php_phalcon.dll"
|
||||||
|
Enable-PhpExtension -Extension phalcon -Path $php_dir
|
||||||
|
}
|
||||||
|
printf "\033[%s;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" "32" $tick $extension "Installed and enabled"
|
||||||
|
}
|
||||||
|
|
||||||
|
$tick = ([char]8730)
|
||||||
|
$domain = 'https://github.com'
|
||||||
|
$php_dir = 'C:\tools\php'
|
||||||
|
$ext_dir = $php_dir + '\ext'
|
||||||
|
$extension_version = $extension.substring($extension.Length - 1)
|
||||||
|
|
||||||
|
if($extension_version -eq '4') {
|
||||||
|
if (Test-Path $ext_dir\php_psr.dll) {
|
||||||
|
Enable-PhpExtension -Extension psr -Path $php_dir
|
||||||
|
} else {
|
||||||
|
Install-Phpextension psr -MinimumStability stable -Path $php_dir
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(Test-Path $ext_dir\php_phalcon.dll) {
|
||||||
|
$phalcon = Get-PhpExtension $ext_dir\php_phalcon.dll
|
||||||
|
if($phalcon.Version[0] -eq $extension_version) {
|
||||||
|
Enable-PhpExtension -Extension phalcon -Path $php_dir
|
||||||
|
printf "\033[%s;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" "32" $tick $extension "Enabled"
|
||||||
|
} else {
|
||||||
|
Remove-Item $ext_dir\php_phalcon.dll
|
||||||
|
Install-Phalcon
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Install-Phalcon
|
||||||
|
}
|
72
src/scripts/ext/phalcon.sh
Normal file
72
src/scripts/ext/phalcon.sh
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
# Function to log result of a operation
|
||||||
|
add_log() {
|
||||||
|
mark=$1
|
||||||
|
subject=$2
|
||||||
|
message=$3
|
||||||
|
if [ "$mark" = "$tick" ]; then
|
||||||
|
printf "\033[32;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s\033[0m\n" "$mark" "$subject" "$message"
|
||||||
|
else
|
||||||
|
printf "\033[31;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s\033[0m\n" "$mark" "$subject" "$message"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to update php ppa
|
||||||
|
update_ppa() {
|
||||||
|
if [ "$ppa_updated" = "false" ]; then
|
||||||
|
find /etc/apt/sources.list.d -type f -name 'ondrej-ubuntu-php*.list' -exec sudo DEBIAN_FRONTEND=noninteractive apt-get update -o Dir::Etc::sourcelist="{}" ';' >/dev/null 2>&1
|
||||||
|
ppa_updated="true"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to install phalcon
|
||||||
|
install_phalcon() {
|
||||||
|
extension=$1
|
||||||
|
version=$2
|
||||||
|
(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-$extension" >/dev/null 2>&1 && add_log "$tick" "$extension" "Installed and enabled") ||
|
||||||
|
add_log "$cross" "$extension" "Could not install $extension on PHP $semver"
|
||||||
|
}
|
||||||
|
|
||||||
|
ini_file="/etc/php/$2/cli/conf.d/50-phalcon.ini"
|
||||||
|
ext_dir=$(php -i | grep "extension_dir => /usr" | sed -e "s|.*=> s*||")
|
||||||
|
semver=$(php -v | head -n 1 | cut -f 2 -d ' ' | cut -f 1 -d '-')
|
||||||
|
extension_major_version=$(echo "$1" | grep -i -Po '\d')
|
||||||
|
ppa_updated="false"
|
||||||
|
tick="✓"
|
||||||
|
cross="✗"
|
||||||
|
|
||||||
|
if [ "$extension_major_version" = "4" ]; then
|
||||||
|
if [ -e "$ext_dir/psr.so" ]; then
|
||||||
|
echo "extension=psr.so" | sudo tee -a "$ini_file" >/dev/null 2>&1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -e "$ext_dir/phalcon.so" ]; then
|
||||||
|
if php -m | grep -i -q -w psr; then
|
||||||
|
phalcon_version=$(php -d="extension=phalcon" -r "echo phpversion('phalcon');" | cut -d'.' -f 1)
|
||||||
|
if [ "$phalcon_version" != "$extension_major_version" ]; then
|
||||||
|
install_phalcon "$1" "$2"
|
||||||
|
else
|
||||||
|
echo "extension=phalcon.so" | sudo tee -a "$ini_file" >/dev/null 2>&1
|
||||||
|
add_log "$tick" "$1" "Enabled"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
install_phalcon "$1" "$2"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
install_phalcon "$1" "$2"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$extension_major_version" = "3" ]; then
|
||||||
|
if [ -e "$ext_dir/phalcon.so" ]; then
|
||||||
|
phalcon_version=$(php -d="extension=phalcon.so" -r "echo phpversion('phalcon');" | cut -d'.' -f 1)
|
||||||
|
if [ "$phalcon_version" != "$extension_major_version" ]; then
|
||||||
|
install_phalcon "$1" "$2"
|
||||||
|
else
|
||||||
|
echo "extension=phalcon.so" | sudo tee -a "$ini_file" >/dev/null 2>&1
|
||||||
|
add_log "$tick" "$1" "Enabled"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
install_phalcon "$1" "$2"
|
||||||
|
fi
|
||||||
|
fi
|
43
src/scripts/ext/phalcon_darwin.sh
Normal file
43
src/scripts/ext/phalcon_darwin.sh
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
# Function to log result of a operation
|
||||||
|
add_log() {
|
||||||
|
mark=$1
|
||||||
|
subject=$2
|
||||||
|
message=$3
|
||||||
|
if [ "$mark" = "$tick" ]; then
|
||||||
|
printf "\033[32;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s\033[0m\n" "$mark" "$subject" "$message"
|
||||||
|
else
|
||||||
|
printf "\033[31;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s\033[0m\n" "$mark" "$subject" "$message"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to install phalcon
|
||||||
|
install_phalcon() {
|
||||||
|
(
|
||||||
|
brew tap shivammathur/homebrew-phalcon >/dev/null 2>&1
|
||||||
|
brew install phalcon@"$php_version"_"$extension_major" >/dev/null 2>&1
|
||||||
|
sudo cp /usr/local/opt/psr@"$php_version"/psr.so "$ext_dir" >/dev/null 2>&1
|
||||||
|
sudo cp /usr/local/opt/phalcon@"$php_version"_"$extension_major"/phalcon.so "$ext_dir" >/dev/null 2>&1
|
||||||
|
add_log "$tick" "$extension" "Installed and enabled"
|
||||||
|
) || add_log "$cross" "$extension" "Could not install $extension on PHP $semver"
|
||||||
|
}
|
||||||
|
|
||||||
|
tick="✓"
|
||||||
|
cross="✗"
|
||||||
|
extension=$1
|
||||||
|
extension_major=${extension: -1}
|
||||||
|
php_version=$2
|
||||||
|
semver=$(php -v | head -n 1 | cut -f 2 -d ' ')
|
||||||
|
ini_file=$(php -d "date.timezone=UTC" --ini | grep "Loaded Configuration" | sed -e "s|.*:s*||" | sed "s/ //g")
|
||||||
|
ext_dir=$(php -i | grep "extension_dir => /usr" | sed -e "s|.*=> s*||")
|
||||||
|
if [ -e "$ext_dir/psr.so" ] && [ -e "$ext_dir/phalcon.so" ]; then
|
||||||
|
phalcon_version=$(php -d="extension=psr.so" -d="extension=phalcon.so" -r "echo phpversion('phalcon');" | cut -d'.' -f 1)
|
||||||
|
if [ "$phalcon_version" != "$extension_major" ]; then
|
||||||
|
install_phalcon
|
||||||
|
else
|
||||||
|
echo "extension=psr.so" >>"$ini_file"
|
||||||
|
echo "extension=phalcon.so" >>"$ini_file"
|
||||||
|
add_log "$tick" "$extension" "Enabled"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
install_phalcon
|
||||||
|
fi
|
@ -1,11 +1,10 @@
|
|||||||
tick="✓"
|
# Function to log start of a operation
|
||||||
cross="✗"
|
|
||||||
|
|
||||||
step_log() {
|
step_log() {
|
||||||
message=$1
|
message=$1
|
||||||
printf "\n\033[90;1m==> \033[0m\033[37;1m%s\033[0m\n" "$message"
|
printf "\n\033[90;1m==> \033[0m\033[37;1m%s\033[0m\n" "$message"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Function to log result of a operation
|
||||||
add_log() {
|
add_log() {
|
||||||
mark=$1
|
mark=$1
|
||||||
subject=$2
|
subject=$2
|
||||||
@ -16,94 +15,257 @@ add_log() {
|
|||||||
printf "\033[31;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s\033[0m\n" "$mark" "$subject" "$message"
|
printf "\033[31;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s\033[0m\n" "$mark" "$subject" "$message"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
existing_version=$(php-config --version | cut -c 1-3)
|
|
||||||
semver=$(php -v | head -n 1 | cut -f 2 -d ' ' | cut -f 1 -d '-')
|
|
||||||
step_log "Setup PHP and Composer"
|
|
||||||
sudo mkdir -p /var/run
|
|
||||||
sudo mkdir -p /run/php
|
|
||||||
find /etc/apt/sources.list.d -type f -name 'ondrej-ubuntu-php*.list' -exec sudo DEBIAN_FRONTEND=noninteractive apt-fast update -o Dir::Etc::sourcelist="{}" ';' >/dev/null 2>&1
|
|
||||||
if [ "$existing_version" != "$1" ]; then
|
|
||||||
if [ ! -e "/usr/bin/php$1" ]; then
|
|
||||||
if [ "$1" = "7.4" ]; then
|
|
||||||
sudo DEBIAN_FRONTEND=noninteractive apt-fast install -y php"$1" php"$1"-phpdbg php"$1"-xml curl php"$1"-curl >/dev/null 2>&1
|
|
||||||
elif [ "$1" = "8.0" ]; then
|
|
||||||
tar_file=php_"$1"%2Bubuntu"$(lsb_release -r -s)".tar.xz
|
|
||||||
install_dir=~/php/"$1"
|
|
||||||
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install libicu-dev >/dev/null 2>&1
|
|
||||||
curl -o "$tar_file" -L https://bintray.com/shivammathur/php/download_file?file_path="$tar_file" >/dev/null 2>&1
|
|
||||||
sudo mkdir -m 777 -p ~/php
|
|
||||||
sudo tar xf "$tar_file" -C ~/php >/dev/null 2>&1 && rm -rf "$tar_file"
|
|
||||||
sudo ln -sf -S "$1" "$install_dir"/bin/* /usr/bin/ && sudo ln -sf "$install_dir"/etc/php.ini /etc/php.ini
|
|
||||||
else
|
|
||||||
sudo DEBIAN_FRONTEND=noninteractive apt-fast install -y php"$1" curl php"$1"-curl >/dev/null 2>&1
|
|
||||||
fi
|
|
||||||
status="installed"
|
|
||||||
else
|
|
||||||
status="switched"
|
|
||||||
fi
|
|
||||||
|
|
||||||
for tool in pear pecl php phar phar.phar php-cgi php-config phpize phpdbg; do
|
# Function to update php ppa
|
||||||
if [ -e "/usr/bin/$tool$1" ]; then
|
update_ppa() {
|
||||||
sudo update-alternatives --set $tool /usr/bin/"$tool$1" >/dev/null 2>&1
|
if [ "$ppa_updated" = "false" ]; then
|
||||||
|
sudo "$debconf_fix" apt-get update >/dev/null 2>&1
|
||||||
|
#find /etc/apt/sources.list.d -type f -name 'ondrej-ubuntu-php*.list' -exec sudo DEBIAN_FRONTEND=noninteractive apt-fast update -o Dir::Etc::sourcelist="{}" ';' >/dev/null 2>&1
|
||||||
|
#ppa_updated="true"
|
||||||
fi
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
configure_pecl() {
|
||||||
|
if [ "$pecl_config" = "false" ] && [ -e /usr/bin/pecl ]; then
|
||||||
|
for tool in pear pecl; do
|
||||||
|
sudo "$tool" config-set php_ini "$ini_file" >/dev/null 2>&1
|
||||||
|
sudo "$tool" config-set auto_discover 1 >/dev/null 2>&1
|
||||||
|
sudo "$tool" channel-update "$tool".php.net >/dev/null 2>&1
|
||||||
done
|
done
|
||||||
|
pecl_config="true"
|
||||||
semver=$(php -v | head -n 1 | cut -f 2 -d ' ' | cut -f 1 -d '-')
|
|
||||||
if [ "$1" = "8.0" ]; then
|
|
||||||
semver=$(php -v | head -n 1 | cut -f 2 -d ' ')
|
|
||||||
fi
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
if [ "$status" != "switched" ]; then
|
# Fuction to get the PECL version
|
||||||
status="Installed PHP $semver"
|
get_pecl_version() {
|
||||||
|
extension=$1
|
||||||
|
stability=$2
|
||||||
|
pecl_rest='https://pecl.php.net/rest/r/'
|
||||||
|
response=$(curl -q -sSL "$pecl_rest$extension"/allreleases.xml)
|
||||||
|
pecl_version=$(echo "$response" | grep -m 1 -Po "(\d*\.\d*\.\d*$stability\d*)")
|
||||||
|
if [ ! "$pecl_version" ]; then
|
||||||
|
pecl_version=$(echo "$response" | grep -m 1 -Po "(\d*\.\d*\.\d*)")
|
||||||
|
fi
|
||||||
|
echo "$pecl_version"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to test if extension is loaded
|
||||||
|
check_extension() {
|
||||||
|
extension=$1
|
||||||
|
if [ "$extension" != "mysql" ]; then
|
||||||
|
php -m | grep -i -q -w "$extension"
|
||||||
else
|
else
|
||||||
status="Switched to PHP $semver"
|
php -m | grep -i -q "$extension"
|
||||||
fi
|
fi
|
||||||
else
|
}
|
||||||
status="PHP $semver Found"
|
|
||||||
fi
|
|
||||||
|
|
||||||
ini_file=$(php --ini | grep "Loaded Configuration" | sed -e "s|.*:s*||" | sed "s/ //g")
|
# Function to delete extensions
|
||||||
ext_dir=$(php -i | grep "extension_dir => /usr" | sed -e "s|.*=> s*||")
|
delete_extension() {
|
||||||
sudo chmod 777 "$ini_file"
|
extension=$1
|
||||||
add_log "$tick" "PHP" "$status"
|
sudo sed -i "/$extension/d" "$ini_file"
|
||||||
if [ "$2" = "true" ]; then
|
sudo rm -rf "$scan_dir"/*"$extension"* >/dev/null 2>&1
|
||||||
sudo DEBIAN_FRONTEND=noninteractive apt-fast install -y php"$1"-dev php"$1"-xml >/dev/null 2>&1
|
sudo rm -rf "$ext_dir"/"$extension".so >/dev/null 2>&1
|
||||||
sudo update-alternatives --set php-config /usr/bin/php-config"$1" >/dev/null 2>&1
|
}
|
||||||
sudo update-alternatives --set phpize /usr/bin/phpize"$1" >/dev/null 2>&1
|
|
||||||
wget https://github.com/pear/pearweb_phars/raw/master/install-pear-nozlib.phar >/dev/null 2>&1
|
|
||||||
sudo php install-pear-nozlib.phar >/dev/null 2>&1
|
|
||||||
sudo pear config-set php_ini "$ini_file" >/dev/null 2>&1
|
|
||||||
sudo pear config-set auto_discover 1
|
|
||||||
sudo pear channel-update pear.php.net
|
|
||||||
add_log "$tick" "PECL" "Installed"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ ! -e "/usr/bin/composer" ]; then
|
# Function to disable and delete extensions
|
||||||
curl -s -L https://getcomposer.org/installer > composer-setup.php
|
remove_extension() {
|
||||||
if [ "$(curl -s https://composer.github.io/installer.sig)" != "$(php -r "echo hash_file('sha384', 'composer-setup.php');")" ]; then
|
extension=$1
|
||||||
>&2 echo 'ERROR: Invalid installer signature'
|
if [ -e /etc/php/"$version"/mods-available/"$extension".ini ]; then
|
||||||
else
|
sudo phpdismod -v "$version" "$extension"
|
||||||
export COMPOSER_ALLOW_SUPERUSER=1
|
|
||||||
sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer
|
|
||||||
fi
|
fi
|
||||||
rm composer-setup.php
|
delete_extension "$extension"
|
||||||
fi
|
}
|
||||||
composer global require hirak/prestissimo >/dev/null 2>&1
|
|
||||||
add_log "$tick" "Composer" "Installed"
|
|
||||||
|
|
||||||
add_extension()
|
# Function to setup extensions
|
||||||
{
|
add_extension() {
|
||||||
extension=$1
|
extension=$1
|
||||||
install_command=$2
|
install_command=$2
|
||||||
prefix=$3
|
prefix=$3
|
||||||
if ! php -m | grep -i -q ^"$extension"$ && [ -e "$ext_dir/$extension.so" ]; then
|
if ! check_extension "$extension" && [ -e "$ext_dir/$extension.so" ]; then
|
||||||
echo "$prefix=$extension" >> "$ini_file" && add_log "$tick" "$extension" "Enabled"
|
echo "$prefix=$extension.so" >>"$ini_file" && add_log "$tick" "$extension" "Enabled"
|
||||||
elif php -m | grep -i -q ^"$extension"$; then
|
elif check_extension "$extension"; then
|
||||||
add_log "$tick" "$extension" "Enabled"
|
add_log "$tick" "$extension" "Enabled"
|
||||||
elif ! php -m | grep -i -q ^"$extension"$; then
|
elif ! check_extension "$extension"; then
|
||||||
|
eval "$install_command" >/dev/null 2>&1 ||
|
||||||
|
(update_ppa && eval "$install_command" >/dev/null 2>&1) ||
|
||||||
|
sudo pecl install -f "$extension" >/dev/null 2>&1
|
||||||
|
(check_extension "$extension" && add_log "$tick" "$extension" "Installed and enabled") ||
|
||||||
|
add_log "$cross" "$extension" "Could not install $extension on PHP $semver"
|
||||||
|
fi
|
||||||
|
sudo chmod 777 "$ini_file"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to install a PECL version
|
||||||
|
add_pecl_extension() {
|
||||||
|
extension=$1
|
||||||
|
pecl_version=$2
|
||||||
|
prefix=$3
|
||||||
|
if ! check_extension "$extension" && [ -e "$ext_dir/$extension.so" ]; then
|
||||||
|
echo "$prefix=$ext_dir/$extension.so" >>"$ini_file"
|
||||||
|
fi
|
||||||
|
ext_version=$(php -r "echo phpversion('$extension');")
|
||||||
|
if [ "$ext_version" = "$pecl_version" ]; then
|
||||||
|
add_log "$tick" "$extension" "Enabled"
|
||||||
|
else
|
||||||
|
delete_extension "$extension"
|
||||||
(
|
(
|
||||||
eval "$install_command" && \
|
sudo pecl install -f "$extension-$pecl_version" >/dev/null 2>&1 &&
|
||||||
|
check_extension "$extension" &&
|
||||||
add_log "$tick" "$extension" "Installed and enabled"
|
add_log "$tick" "$extension" "Installed and enabled"
|
||||||
) || add_log "$cross" "$extension" "Could not install $extension on PHP $semver"
|
) || add_log "$cross" "$extension" "Could not install $extension-$pecl_version on PHP $semver"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Function to pre-release extensions using PECL
|
||||||
|
add_unstable_extension() {
|
||||||
|
extension=$1
|
||||||
|
stability=$2
|
||||||
|
prefix=$3
|
||||||
|
pecl_version=$(get_pecl_version "$extension" "$stability")
|
||||||
|
add_pecl_extension "$extension" "$pecl_version" "$prefix"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to update extension
|
||||||
|
update_extension() {
|
||||||
|
extension=$1
|
||||||
|
latest_version=$2
|
||||||
|
current_version=$(php -r "echo phpversion('$extension');")
|
||||||
|
final_version=$(printf "%s\n%s" "$current_version" "$latest_version" | sort | tail -n 1)
|
||||||
|
if [ "$final_version" != "$current_version" ]; then
|
||||||
|
version_exists=$(apt-cache policy -- *"$extension" | grep "$final_version")
|
||||||
|
if [ -z "$version_exists" ]; then
|
||||||
|
update_ppa
|
||||||
|
fi
|
||||||
|
$apt_install php"$version"-"$extension"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to setup a remote tool
|
||||||
|
add_tool() {
|
||||||
|
url=$1
|
||||||
|
tool=$2
|
||||||
|
tool_path="$tool_path_dir/$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 [ "$status_code" = "200" ]; then
|
||||||
|
sudo chmod a+x "$tool_path"
|
||||||
|
if [ "$tool" = "composer" ]; then
|
||||||
|
composer -q global config process-timeout 0
|
||||||
|
elif [ "$tool" = "cs2pr" ]; then
|
||||||
|
sudo sed -i 's/\r$//; s/exit(9)/exit(0)/' "$tool_path"
|
||||||
|
elif [ "$tool" = "phive" ]; then
|
||||||
|
add_extension curl "$apt_install php$version-curl" extension >/dev/null 2>&1
|
||||||
|
add_extension mbstring "$apt_install php$version-mbstring" extension >/dev/null 2>&1
|
||||||
|
add_extension xml "$apt_install php$version-xml" extension >/dev/null 2>&1
|
||||||
|
fi
|
||||||
|
add_log "$tick" "$tool" "Added"
|
||||||
|
else
|
||||||
|
add_log "$cross" "$tool" "Could not setup $tool"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to setup a tool using composer
|
||||||
|
add_composertool() {
|
||||||
|
tool=$1
|
||||||
|
release=$2
|
||||||
|
prefix=$3
|
||||||
|
(
|
||||||
|
composer global require "$prefix$release" >/dev/null 2>&1 &&
|
||||||
|
sudo ln -sf "$(composer -q global config home)"/vendor/bin/"$tool" /usr/local/bin/"$tool" &&
|
||||||
|
add_log "$tick" "$tool" "Added"
|
||||||
|
) || add_log "$cross" "$tool" "Could not setup $tool"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to setup phpize and php-config
|
||||||
|
add_devtools() {
|
||||||
|
if ! [ -e "/usr/bin/phpize$version" ] || ! [ -e "/usr/bin/php-config$version" ]; then
|
||||||
|
$apt_install php"$version"-dev php"$version"-xml >/dev/null 2>&1
|
||||||
|
fi
|
||||||
|
sudo update-alternatives --set php-config /usr/bin/php-config"$version" >/dev/null 2>&1
|
||||||
|
sudo update-alternatives --set phpize /usr/bin/phpize"$version" >/dev/null 2>&1
|
||||||
|
configure_pecl
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to setup the nightly build from master branch
|
||||||
|
setup_master() {
|
||||||
|
tar_file=php_"$version"%2Bubuntu"$(lsb_release -r -s)".tar.xz
|
||||||
|
install_dir=~/php/"$version"
|
||||||
|
sudo mkdir -m 777 -p ~/php
|
||||||
|
update_ppa && $apt_install libicu64 libicu-dev >/dev/null 2>&1
|
||||||
|
curl -SLO https://dl.bintray.com/shivammathur/php/"$tar_file" >/dev/null 2>&1
|
||||||
|
sudo tar xf "$tar_file" -C ~/php >/dev/null 2>&1
|
||||||
|
rm -rf "$tar_file"
|
||||||
|
sudo ln -sf -S "$version" "$install_dir"/bin/* /usr/bin/
|
||||||
|
sudo ln -sf "$install_dir"/etc/php.ini /etc/php.ini
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to setup PECL
|
||||||
|
add_pecl() {
|
||||||
|
add_devtools
|
||||||
|
if [ ! -e /usr/bin/pecl ]; then
|
||||||
|
$apt_install php-pear >/dev/null 2>&1
|
||||||
|
fi
|
||||||
|
configure_pecl
|
||||||
|
add_log "$tick" "PECL" "Added"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to switch versions of PHP binaries
|
||||||
|
switch_version() {
|
||||||
|
for tool in pear pecl php phar phar.phar php-cgi php-config phpize phpdbg; do
|
||||||
|
if [ -e "/usr/bin/$tool$version" ]; then
|
||||||
|
sudo update-alternatives --set $tool /usr/bin/"$tool$version" >/dev/null 2>&1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to get PHP version in semver format
|
||||||
|
php_semver() {
|
||||||
|
if [ ! "$version" = "8.0" ]; then
|
||||||
|
php"$version" -v | head -n 1 | cut -f 2 -d ' ' | cut -f 1 -d '-'
|
||||||
|
else
|
||||||
|
php -v | head -n 1 | cut -f 2 -d ' '
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Variables
|
||||||
|
tick="✓"
|
||||||
|
cross="✗"
|
||||||
|
ppa_updated="false"
|
||||||
|
pecl_config="false"
|
||||||
|
version=$1
|
||||||
|
debconf_fix="DEBIAN_FRONTEND=noninteractive"
|
||||||
|
apt_install="sudo $debconf_fix apt-fast install -y"
|
||||||
|
tool_path_dir="/usr/local/bin"
|
||||||
|
existing_version=$(php-config --version | cut -c 1-3)
|
||||||
|
|
||||||
|
# Setup PHP
|
||||||
|
step_log "Setup PHP"
|
||||||
|
sudo mkdir -p /var/run
|
||||||
|
sudo mkdir -p /run/php
|
||||||
|
|
||||||
|
if [ "$existing_version" != "$version" ]; then
|
||||||
|
if [ ! -e "/usr/bin/php$version" ]; then
|
||||||
|
if [ "$version" = "8.0" ]; then
|
||||||
|
setup_master
|
||||||
|
else
|
||||||
|
update_ppa
|
||||||
|
$apt_install php"$version" php"$version"-curl php"$version"-mbstring php"$version"-xml >/dev/null 2>&1
|
||||||
|
fi
|
||||||
|
status="Installed"
|
||||||
|
else
|
||||||
|
status="Switched to"
|
||||||
|
fi
|
||||||
|
|
||||||
|
switch_version
|
||||||
|
else
|
||||||
|
status="Found"
|
||||||
|
fi
|
||||||
|
|
||||||
|
semver=$(php_semver)
|
||||||
|
ini_file=$(php --ini | grep "Loaded Configuration" | sed -e "s|.*:s*||" | sed "s/ //g")
|
||||||
|
ext_dir=$(php -i | grep "extension_dir => /" | sed -e "s|.*=> s*||")
|
||||||
|
scan_dir=$(php --ini | grep additional | sed -e "s|.*: s*||")
|
||||||
|
sudo chmod 777 "$ini_file" "$tool_path_dir"
|
||||||
|
add_log "$tick" "PHP" "$status PHP $semver"
|
||||||
|
@ -1,26 +0,0 @@
|
|||||||
ini_file=$(php --ini | grep "Loaded Configuration" | sed -e "s|.*:s*||" | sed "s/ //g")
|
|
||||||
if [ ! "$(apt-cache search php"$2"-psr)" ]; then
|
|
||||||
sudo DEBIAN_FRONTEND=noninteractive add-apt-repository ppa:ondrej/php -y >/dev/null 2>&1
|
|
||||||
fi
|
|
||||||
sudo DEBIAN_FRONTEND=noninteractive apt-fast install -y php"$2"-dev php"$2"-psr
|
|
||||||
for tool in php-config phpize; do
|
|
||||||
if [ -e "/usr/bin/$tool$2" ]; then
|
|
||||||
sudo update-alternatives --set $tool /usr/bin/"$tool$2"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
if [ ! "$(apt-cache search php"$2"-psr)" ]; then
|
|
||||||
cd ~ && git clone --depth=1 https://github.com/jbboehr/php-psr.git
|
|
||||||
cd php-psr && sudo /usr/bin/phpize"$2"
|
|
||||||
./configure --with-php-config=/usr/bin/php-config"$2"
|
|
||||||
make -j2 && sudo make -j2 install
|
|
||||||
echo "extension=psr.so" >> "$ini_file"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$1" = "master" ]; then
|
|
||||||
sudo DEBIAN_FRONTEND=noninteractive apt-fast install -y php"$2"-phalcon
|
|
||||||
else
|
|
||||||
cd ~ && git clone --depth=1 -v https://github.com/phalcon/cphalcon.git -b "$1"
|
|
||||||
cd cphalcon/build && sudo ./install --phpize /usr/bin/phpize"$2" --php-config /usr/bin/php-config"$2"
|
|
||||||
echo "extension=phalcon.so" >> "$ini_file"
|
|
||||||
fi
|
|
@ -1,11 +1,16 @@
|
|||||||
param (
|
param (
|
||||||
[Parameter(Mandatory = $true)][string]$version = "7.3"
|
[Parameter(Position = 0, Mandatory = $true)]
|
||||||
|
[ValidateNotNull()]
|
||||||
|
[ValidateLength(1, [int]::MaxValue)]
|
||||||
|
[string]
|
||||||
|
$version = '7.4',
|
||||||
|
[Parameter(Position = 1, Mandatory = $true)]
|
||||||
|
[ValidateNotNull()]
|
||||||
|
[ValidateLength(1, [int]::MaxValue)]
|
||||||
|
[string]
|
||||||
|
$dir
|
||||||
)
|
)
|
||||||
|
|
||||||
$tick = ([char]8730)
|
|
||||||
$cross = ([char]10007)
|
|
||||||
$php_dir = 'C:\tools\php'
|
|
||||||
|
|
||||||
Function Step-Log($message) {
|
Function Step-Log($message) {
|
||||||
printf "\n\033[90;1m==> \033[0m\033[37;1m%s \033[0m\n" $message
|
printf "\n\033[90;1m==> \033[0m\033[37;1m%s \033[0m\n" $message
|
||||||
}
|
}
|
||||||
@ -15,44 +20,18 @@ Function Add-Log($mark, $subject, $message) {
|
|||||||
printf "\033[%s;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" $code $mark $subject $message
|
printf "\033[%s;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" $code $mark $subject $message
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($version -eq '8.0') {
|
Function Install-PhpManager() {
|
||||||
$version = '7.4'
|
$repo = "mlocati/powershell-phpmanager"
|
||||||
|
$zip_file = "$php_dir\PhpManager.zip"
|
||||||
|
$tags = Invoke-WebRequest https://api.github.com/repos/$repo/tags | ConvertFrom-Json
|
||||||
|
$tag = $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
|
||||||
|
Import-Module $module_path
|
||||||
|
Add-Content -Path $PsHome\profile.ps1 -Value "Import-Module $module_path"
|
||||||
}
|
}
|
||||||
|
|
||||||
Step-Log "Setup PhpManager"
|
|
||||||
Install-Module -Name PhpManager -Force -Scope CurrentUser
|
|
||||||
Add-Log $tick "PhpManager" "Installed"
|
|
||||||
|
|
||||||
$installed = $null
|
|
||||||
if (Test-Path -LiteralPath $php_dir -PathType Container) {
|
|
||||||
try {
|
|
||||||
$installed = Get-Php -Path $php_dir
|
|
||||||
}
|
|
||||||
catch {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Step-Log "Setup PHP and Composer"
|
|
||||||
if ($null -eq $installed -or -not("$($installed.Version).".StartsWith(($version -replace '^(\d+(\.\d+)*).*', '$1.')))) {
|
|
||||||
if ($version -lt '7.0') {
|
|
||||||
Install-Module -Name VcRedist -Force
|
|
||||||
}
|
|
||||||
|
|
||||||
Install-Php -Version $version -Architecture x86 -ThreadSafe $true -InstallVC -Path $php_dir -TimeZone UTC -InitialPhpIni Production -Force >$null 2>&1
|
|
||||||
$installed = Get-Php -Path $php_dir
|
|
||||||
$status = "Installed PHP $($installed.FullVersion)"
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$status = "PHP $($installed.FullVersion) Found"
|
|
||||||
}
|
|
||||||
|
|
||||||
Set-PhpIniKey -Key 'date.timezone' -Value 'UTC' -Path $php_dir
|
|
||||||
Enable-PhpExtension -Extension openssl, curl -Path $php_dir
|
|
||||||
Update-PhpCAInfo -Path $php_dir -Source CurrentUser
|
|
||||||
Add-Log $tick "PHP" $status
|
|
||||||
|
|
||||||
Install-Composer -Scope System -Path $php_dir -PhpPath $php_dir
|
|
||||||
Add-Log $tick "Composer" "Installed"
|
|
||||||
|
|
||||||
Function Add-Extension {
|
Function Add-Extension {
|
||||||
Param (
|
Param (
|
||||||
[Parameter(Position = 0, Mandatory = $true)]
|
[Parameter(Position = 0, Mandatory = $true)]
|
||||||
@ -91,3 +70,156 @@ Function Add-Extension {
|
|||||||
Add-Log $cross $extension "Could not install $extension on PHP $($installed.FullVersion)"
|
Add-Log $cross $extension "Could not install $extension on PHP $($installed.FullVersion)"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Function Remove-Extension() {
|
||||||
|
Param (
|
||||||
|
[Parameter(Position = 0, Mandatory = $true)]
|
||||||
|
[ValidateNotNull()]
|
||||||
|
[ValidateLength(1, [int]::MaxValue)]
|
||||||
|
[string]
|
||||||
|
$extension
|
||||||
|
)
|
||||||
|
if(php -m | findstr -i $extension) {
|
||||||
|
Disable-PhpExtension $extension $php_dir
|
||||||
|
}
|
||||||
|
if (Test-Path $ext_dir\php_$extension.dll) {
|
||||||
|
Remove-Item $ext_dir\php_$extension.dll
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Function Add-Tool() {
|
||||||
|
Param (
|
||||||
|
[Parameter(Position = 0, Mandatory = $true)]
|
||||||
|
[ValidateNotNull()]
|
||||||
|
[ValidateLength(1, [int]::MaxValue)]
|
||||||
|
[string]
|
||||||
|
$url,
|
||||||
|
[Parameter(Position = 1, Mandatory = $true)]
|
||||||
|
[ValidateNotNull()]
|
||||||
|
[ValidateLength(1, [int]::MaxValue)]
|
||||||
|
[string]
|
||||||
|
$tool
|
||||||
|
)
|
||||||
|
if (Test-Path $php_dir\$tool) {
|
||||||
|
Remove-Item $php_dir\$tool
|
||||||
|
}
|
||||||
|
if ($tool -eq "composer") {
|
||||||
|
Install-Composer -Scope System -Path $php_dir -PhpPath $php_dir
|
||||||
|
composer -q global config process-timeout 0
|
||||||
|
} elseif ($tool -eq "symfony") {
|
||||||
|
Invoke-WebRequest -UseBasicParsing -Uri $url -OutFile $php_dir\$tool.exe
|
||||||
|
Add-Content -Path $PsHome\profile.ps1 -Value "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-Content -Path $PsHome\profile.ps1 -Value "New-Alias $tool $php_dir\$tool.bat" > $null 2>&1
|
||||||
|
} catch { }
|
||||||
|
}
|
||||||
|
if($tool -eq "phive") {
|
||||||
|
Add-Extension curl >$null 2>&1
|
||||||
|
Add-Extension mbstring >$null 2>&1
|
||||||
|
Add-Extension xml >$null 2>&1
|
||||||
|
}
|
||||||
|
if($tool -eq "cs2pr") {
|
||||||
|
(Get-Content $php_dir/cs2pr).replace('exit(9)', 'exit(0)') | Set-Content $php_dir/cs2pr
|
||||||
|
}
|
||||||
|
if (((Get-ChildItem -Path $php_dir/* | Where-Object Name -Match "^$tool(.exe|.phar)*$").Count -gt 0)) {
|
||||||
|
Add-Log $tick $tool "Added"
|
||||||
|
} else {
|
||||||
|
Add-Log $cross $tool "Could not add $tool"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Function Add-Composertool() {
|
||||||
|
Param (
|
||||||
|
[Parameter(Position = 0, Mandatory = $true)]
|
||||||
|
[ValidateNotNull()]
|
||||||
|
[ValidateLength(1, [int]::MaxValue)]
|
||||||
|
[string]
|
||||||
|
$tool,
|
||||||
|
[Parameter(Position = 1, Mandatory = $true)]
|
||||||
|
[ValidateNotNull()]
|
||||||
|
[ValidateLength(1, [int]::MaxValue)]
|
||||||
|
[string]
|
||||||
|
$release,
|
||||||
|
[Parameter(Position = 2, Mandatory = $true)]
|
||||||
|
[ValidateNotNull()]
|
||||||
|
[ValidateLength(1, [int]::MaxValue)]
|
||||||
|
[string]
|
||||||
|
$prefix
|
||||||
|
)
|
||||||
|
composer -q global require $prefix$release 2>&1 | out-null
|
||||||
|
if($?) {
|
||||||
|
$composer_dir = composer -q global config home | ForEach-Object { $_ -replace "/", "\" }
|
||||||
|
Add-Content -Path $PsHome\profile.ps1 -Value "New-Alias $tool $composer_dir\vendor\bin\$tool.bat"
|
||||||
|
Add-Log $tick $tool "Added"
|
||||||
|
} else {
|
||||||
|
Add-Log $cross $tool "Could not setup $tool"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Function Add-Pecl() {
|
||||||
|
Add-Log $tick "PECL" "Use extensions input to setup PECL extensions on windows"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Variables
|
||||||
|
$tick = ([char]8730)
|
||||||
|
$cross = ([char]10007)
|
||||||
|
$php_dir = 'C:\tools\php'
|
||||||
|
$ext_dir = $php_dir + '\ext'
|
||||||
|
$ProgressPreference = 'SilentlyContinue'
|
||||||
|
$master_version = '8.0'
|
||||||
|
$arch = 'x64'
|
||||||
|
$ts = $false
|
||||||
|
if((Test-Path env:PHPTS) -and $env:PHPTS -eq 'ts') {
|
||||||
|
$ts = $true
|
||||||
|
}
|
||||||
|
|
||||||
|
Step-Log "Setup PhpManager"
|
||||||
|
Install-PhpManager >$null 2>&1
|
||||||
|
Add-Log $tick "PhpManager" "Installed"
|
||||||
|
|
||||||
|
$installed = $null
|
||||||
|
if (Test-Path -LiteralPath $php_dir -PathType Container) {
|
||||||
|
try {
|
||||||
|
$installed = Get-Php -Path $php_dir
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Step-Log "Setup PHP"
|
||||||
|
$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
|
||||||
|
$arch='x86'
|
||||||
|
}
|
||||||
|
if ($version -eq $master_version) {
|
||||||
|
$version = 'master'
|
||||||
|
}
|
||||||
|
|
||||||
|
Install-Php -Version $version -Architecture $arch -ThreadSafe $ts -InstallVC -Path $php_dir -TimeZone UTC -InitialPhpIni Production -Force >$null 2>&1
|
||||||
|
} else {
|
||||||
|
$status = "Found"
|
||||||
|
}
|
||||||
|
|
||||||
|
$installed = Get-Php -Path $php_dir
|
||||||
|
Set-PhpIniKey -Key 'date.timezone' -Value 'UTC' -Path $php_dir
|
||||||
|
Enable-PhpExtension -Extension openssl, curl, opcache -Path $php_dir
|
||||||
|
Update-PhpCAInfo -Path $php_dir -Source CurrentUser
|
||||||
|
if ($version -eq 'master') {
|
||||||
|
if($installed.ThreadSafe) {
|
||||||
|
Copy-Item $dir"\..\src\bin\php_ts_pcov.dll" -Destination $ext_dir"\php_pcov.dll"
|
||||||
|
} else {
|
||||||
|
Copy-Item $dir"\..\src\bin\php_pcov.dll" -Destination $ext_dir"\php_pcov.dll"
|
||||||
|
}
|
||||||
|
Set-PhpIniKey -Key 'opcache.jit_buffer_size' -Value '256M' -Path $php_dir
|
||||||
|
Set-PhpIniKey -Key 'opcache.jit' -Value '1235' -Path $php_dir
|
||||||
|
}
|
||||||
|
Add-Log $tick "PHP" "$status PHP $($installed.FullVersion)"
|
||||||
|
506
src/tools.ts
Normal file
506
src/tools.ts
Normal file
@ -0,0 +1,506 @@
|
|||||||
|
import * as utils from './utils';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function to get command to setup tools
|
||||||
|
*
|
||||||
|
* @param os_version
|
||||||
|
* @param suffix
|
||||||
|
*/
|
||||||
|
export async function getCommand(
|
||||||
|
os_version: string,
|
||||||
|
suffix: string
|
||||||
|
): Promise<string> {
|
||||||
|
switch (os_version) {
|
||||||
|
case 'linux':
|
||||||
|
case 'darwin':
|
||||||
|
return 'add_' + suffix + ' ';
|
||||||
|
case 'win32':
|
||||||
|
return 'Add-' + suffix.charAt(0).toUpperCase() + suffix.slice(1) + ' ';
|
||||||
|
default:
|
||||||
|
return await utils.log(
|
||||||
|
'Platform ' + os_version + ' is not supported',
|
||||||
|
os_version,
|
||||||
|
'error'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function to get tool version
|
||||||
|
*
|
||||||
|
* @param version
|
||||||
|
*/
|
||||||
|
export async function getToolVersion(version: string): Promise<string> {
|
||||||
|
// semver_regex - https://semver.org/
|
||||||
|
const semver_regex = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/;
|
||||||
|
version = version.replace(/[><=^]*/, '');
|
||||||
|
switch (true) {
|
||||||
|
case semver_regex.test(version):
|
||||||
|
return version;
|
||||||
|
default:
|
||||||
|
return 'latest';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function to parse tool:version
|
||||||
|
*
|
||||||
|
* @param release
|
||||||
|
*/
|
||||||
|
export async function parseTool(
|
||||||
|
release: string
|
||||||
|
): Promise<{name: string; version: string}> {
|
||||||
|
const parts: string[] = release.split(':');
|
||||||
|
const tool: string = parts[0];
|
||||||
|
const version: string | undefined = parts[1];
|
||||||
|
switch (version) {
|
||||||
|
case undefined:
|
||||||
|
return {
|
||||||
|
name: tool,
|
||||||
|
version: 'latest'
|
||||||
|
};
|
||||||
|
default:
|
||||||
|
return {
|
||||||
|
name: tool,
|
||||||
|
version: await getToolVersion(parts[1])
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function to get the url of tool with the given version
|
||||||
|
*
|
||||||
|
* @param tool
|
||||||
|
* @param extension
|
||||||
|
* @param version
|
||||||
|
* @param prefix
|
||||||
|
* @param version_prefix
|
||||||
|
* @param verb
|
||||||
|
*/
|
||||||
|
export async function getUri(
|
||||||
|
tool: string,
|
||||||
|
extension: string,
|
||||||
|
version: string,
|
||||||
|
prefix: string,
|
||||||
|
version_prefix: string,
|
||||||
|
verb: string
|
||||||
|
): Promise<string> {
|
||||||
|
switch (version) {
|
||||||
|
case 'latest':
|
||||||
|
return [prefix, version, verb, tool + extension]
|
||||||
|
.filter(Boolean)
|
||||||
|
.join('/');
|
||||||
|
default:
|
||||||
|
return [prefix, verb, version_prefix + version, tool + extension]
|
||||||
|
.filter(Boolean)
|
||||||
|
.join('/');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper function to get the codeception url
|
||||||
|
*
|
||||||
|
* @param version
|
||||||
|
* @param suffix
|
||||||
|
*/
|
||||||
|
export async function getCodeceptionUriBuilder(
|
||||||
|
version: string,
|
||||||
|
suffix: string
|
||||||
|
): Promise<string> {
|
||||||
|
return ['releases', version, suffix, 'codecept.phar']
|
||||||
|
.filter(Boolean)
|
||||||
|
.join('/');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function to get the codeception url
|
||||||
|
*
|
||||||
|
* @param version
|
||||||
|
* @param php_version
|
||||||
|
*/
|
||||||
|
export async function getCodeceptionUri(
|
||||||
|
version: string,
|
||||||
|
php_version: string
|
||||||
|
): Promise<string> {
|
||||||
|
const codecept: string = await getCodeceptionUriBuilder(version, '');
|
||||||
|
const codecept54: string = await getCodeceptionUriBuilder(version, 'php54');
|
||||||
|
const codecept56: string = await getCodeceptionUriBuilder(version, 'php56');
|
||||||
|
// Refer to https://codeception.com/builds
|
||||||
|
switch (true) {
|
||||||
|
case /latest/.test(version):
|
||||||
|
switch (true) {
|
||||||
|
case /5\.6|7\.[0|1]/.test(php_version):
|
||||||
|
return 'php56/codecept.phar';
|
||||||
|
case /7\.[2-4]/.test(php_version):
|
||||||
|
default:
|
||||||
|
return 'codecept.phar';
|
||||||
|
}
|
||||||
|
case /(^[4-9]|\d{2,})\..*/.test(version):
|
||||||
|
switch (true) {
|
||||||
|
case /5\.6|7\.[0|1]/.test(php_version):
|
||||||
|
return codecept56;
|
||||||
|
case /7\.[2-4]/.test(php_version):
|
||||||
|
default:
|
||||||
|
return codecept;
|
||||||
|
}
|
||||||
|
case /(^2\.[4-5]\.\d+|^3\.[0-1]\.\d+).*/.test(version):
|
||||||
|
switch (true) {
|
||||||
|
case /5\.6/.test(php_version):
|
||||||
|
return codecept54;
|
||||||
|
case /7\.[0-4]/.test(php_version):
|
||||||
|
default:
|
||||||
|
return codecept;
|
||||||
|
}
|
||||||
|
case /^2\.3\.\d+.*/.test(version):
|
||||||
|
switch (true) {
|
||||||
|
case /5\.[4-6]/.test(php_version):
|
||||||
|
return codecept54;
|
||||||
|
case /^7\.[0-4]$/.test(php_version):
|
||||||
|
default:
|
||||||
|
return codecept;
|
||||||
|
}
|
||||||
|
case /(^2\.(1\.([6-9]|\d{2,}))|^2\.2\.\d+).*/.test(version):
|
||||||
|
switch (true) {
|
||||||
|
case /5\.[4-5]/.test(php_version):
|
||||||
|
return codecept54;
|
||||||
|
case /5.6|7\.[0-4]/.test(php_version):
|
||||||
|
default:
|
||||||
|
return codecept;
|
||||||
|
}
|
||||||
|
case /(^2\.(1\.[0-5]|0\.\d+)|^1\.[6-8]\.\d+).*/.test(version):
|
||||||
|
return codecept;
|
||||||
|
default:
|
||||||
|
return codecept;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper function to get script to setup phive
|
||||||
|
*
|
||||||
|
* @param version
|
||||||
|
* @param os_version
|
||||||
|
*/
|
||||||
|
export async function addPhive(
|
||||||
|
version: string,
|
||||||
|
os_version: string
|
||||||
|
): Promise<string> {
|
||||||
|
switch (version) {
|
||||||
|
case 'latest':
|
||||||
|
return (
|
||||||
|
(await getCommand(os_version, 'tool')) +
|
||||||
|
'https://phar.io/releases/phive.phar phive'
|
||||||
|
);
|
||||||
|
default:
|
||||||
|
return (
|
||||||
|
(await getCommand(os_version, 'tool')) +
|
||||||
|
'https://github.com/phar-io/phive/releases/download/' +
|
||||||
|
version +
|
||||||
|
'/phive-' +
|
||||||
|
version +
|
||||||
|
'.phar phive'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function to get the phar url in domain/tool-version.phar format
|
||||||
|
*
|
||||||
|
* @param domain
|
||||||
|
* @param tool
|
||||||
|
* @param prefix
|
||||||
|
* @param version
|
||||||
|
*/
|
||||||
|
export async function getPharUrl(
|
||||||
|
domain: string,
|
||||||
|
tool: string,
|
||||||
|
prefix: string,
|
||||||
|
version: string
|
||||||
|
): Promise<string> {
|
||||||
|
switch (version) {
|
||||||
|
case 'latest':
|
||||||
|
return domain + '/' + tool + '.phar';
|
||||||
|
default:
|
||||||
|
return domain + '/' + tool + '-' + prefix + version + '.phar';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function to get the Deployer url
|
||||||
|
*
|
||||||
|
* @param version
|
||||||
|
*/
|
||||||
|
export async function getDeployerUrl(version: string): Promise<string> {
|
||||||
|
const deployer = 'https://deployer.org';
|
||||||
|
switch (version) {
|
||||||
|
case 'latest':
|
||||||
|
return deployer + '/deployer.phar';
|
||||||
|
default:
|
||||||
|
return deployer + '/releases/v' + version + '/deployer.phar';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function to get the Deployer url
|
||||||
|
*
|
||||||
|
* @param version
|
||||||
|
* @param os_version
|
||||||
|
*/
|
||||||
|
export async function getSymfonyUri(
|
||||||
|
version: string,
|
||||||
|
os_version: string
|
||||||
|
): Promise<string> {
|
||||||
|
let filename = '';
|
||||||
|
switch (os_version) {
|
||||||
|
case 'linux':
|
||||||
|
case 'darwin':
|
||||||
|
filename = 'symfony_' + os_version + '_amd64';
|
||||||
|
break;
|
||||||
|
case 'win32':
|
||||||
|
filename = 'symfony_windows_amd64.exe';
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return await utils.log(
|
||||||
|
'Platform ' + os_version + ' is not supported',
|
||||||
|
os_version,
|
||||||
|
'error'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
switch (version) {
|
||||||
|
case 'latest':
|
||||||
|
return 'releases/latest/download/' + filename;
|
||||||
|
default:
|
||||||
|
return 'releases/download/v' + version + '/' + filename;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function to add/move composer in the tools list
|
||||||
|
*
|
||||||
|
* @param tools_list
|
||||||
|
*/
|
||||||
|
export async function addComposer(tools_list: string[]): Promise<string[]> {
|
||||||
|
const regex = /^composer($|:.*)/;
|
||||||
|
const composer: string = tools_list.filter(tool => regex.test(tool))[0];
|
||||||
|
switch (composer) {
|
||||||
|
case undefined:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
tools_list = tools_list.filter(tool => !regex.test(tool));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
tools_list.unshift('composer');
|
||||||
|
return tools_list;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function to get Tools list after cleanup
|
||||||
|
*
|
||||||
|
* @param tools_csv
|
||||||
|
*/
|
||||||
|
export async function getCleanedToolsList(
|
||||||
|
tools_csv: string
|
||||||
|
): Promise<string[]> {
|
||||||
|
let tools_list: string[] = await utils.CSVArray(tools_csv);
|
||||||
|
tools_list = await addComposer(tools_list);
|
||||||
|
tools_list = tools_list
|
||||||
|
.map(function(extension: string) {
|
||||||
|
return extension
|
||||||
|
.trim()
|
||||||
|
.replace(/robmorgan\/|hirak\/|narrowspark\/automatic-/, '');
|
||||||
|
})
|
||||||
|
.filter(Boolean);
|
||||||
|
return [...new Set(tools_list)];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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> {
|
||||||
|
return (await getCommand(os_version, 'tool')) + url + ' ' + tool;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function to get the script to setup php-config and phpize
|
||||||
|
*
|
||||||
|
* @param tool
|
||||||
|
* @param os_version
|
||||||
|
*/
|
||||||
|
export async function addDevTools(
|
||||||
|
tool: string,
|
||||||
|
os_version: string
|
||||||
|
): Promise<string> {
|
||||||
|
switch (os_version) {
|
||||||
|
case 'linux':
|
||||||
|
return (
|
||||||
|
'add_devtools' +
|
||||||
|
'\n' +
|
||||||
|
(await utils.addLog('$tick', tool, 'Added', 'linux'))
|
||||||
|
);
|
||||||
|
case 'darwin':
|
||||||
|
return await utils.addLog('$tick', tool, 'Added', 'darwin');
|
||||||
|
case 'win32':
|
||||||
|
return await utils.addLog(
|
||||||
|
'$cross',
|
||||||
|
tool,
|
||||||
|
tool + ' is not a windows tool',
|
||||||
|
'win32'
|
||||||
|
);
|
||||||
|
default:
|
||||||
|
return await utils.log(
|
||||||
|
'Platform ' + os_version + ' is not supported',
|
||||||
|
os_version,
|
||||||
|
'error'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper function to get script to setup a tool using composer
|
||||||
|
*
|
||||||
|
* @param tool
|
||||||
|
* @param release
|
||||||
|
* @param prefix
|
||||||
|
* @param os_version
|
||||||
|
*/
|
||||||
|
export async function addPackage(
|
||||||
|
tool: string,
|
||||||
|
release: string,
|
||||||
|
prefix: string,
|
||||||
|
os_version: string
|
||||||
|
): Promise<string> {
|
||||||
|
const tool_command = await getCommand(os_version, 'composertool');
|
||||||
|
return tool_command + tool + ' ' + release + ' ' + prefix;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Setup tools
|
||||||
|
*
|
||||||
|
* @param tools_csv
|
||||||
|
* @param php_version
|
||||||
|
* @param os_version
|
||||||
|
*/
|
||||||
|
export async function addTools(
|
||||||
|
tools_csv: string,
|
||||||
|
php_version: string,
|
||||||
|
os_version: string
|
||||||
|
): Promise<string> {
|
||||||
|
let script = '\n' + (await utils.stepLog('Setup Tools', os_version));
|
||||||
|
const tools_list: Array<string> = await getCleanedToolsList(tools_csv);
|
||||||
|
await utils.asyncForEach(tools_list, async function(release: string) {
|
||||||
|
const tool_data: {name: string; version: string} = await parseTool(release);
|
||||||
|
const tool: string = tool_data.name;
|
||||||
|
const version: string = tool_data.version;
|
||||||
|
const github = 'https://github.com/';
|
||||||
|
let uri: string = await getUri(
|
||||||
|
tool,
|
||||||
|
'.phar',
|
||||||
|
version,
|
||||||
|
'releases',
|
||||||
|
'',
|
||||||
|
'download'
|
||||||
|
);
|
||||||
|
script += '\n';
|
||||||
|
let url = '';
|
||||||
|
switch (tool) {
|
||||||
|
case 'cs2pr':
|
||||||
|
uri = await getUri(tool, '', version, 'releases', '', 'download');
|
||||||
|
url = github + 'staabm/annotate-pull-request-from-checkstyle/' + uri;
|
||||||
|
script += await addArchive(tool, version, url, os_version);
|
||||||
|
break;
|
||||||
|
case 'php-cs-fixer':
|
||||||
|
uri = await getUri(tool, '.phar', version, 'releases', 'v', 'download');
|
||||||
|
url = github + 'FriendsOfPHP/PHP-CS-Fixer/' + uri;
|
||||||
|
script += await addArchive(tool, version, url, os_version);
|
||||||
|
break;
|
||||||
|
case 'phpcs':
|
||||||
|
case 'phpcbf':
|
||||||
|
url = github + 'squizlabs/PHP_CodeSniffer/' + uri;
|
||||||
|
script += await addArchive(tool, version, 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);
|
||||||
|
break;
|
||||||
|
case 'phpmd':
|
||||||
|
url = github + 'phpmd/phpmd/' + uri;
|
||||||
|
script += await addArchive(tool, version, url, os_version);
|
||||||
|
break;
|
||||||
|
case 'psalm':
|
||||||
|
url = github + 'vimeo/psalm/' + uri;
|
||||||
|
script += await addArchive(tool, version, url, os_version);
|
||||||
|
break;
|
||||||
|
case 'composer':
|
||||||
|
// If RC is released as latest release, switch to getcomposer.
|
||||||
|
// Preferred source is GitHub as it is faster.
|
||||||
|
// url = github + 'composer/composer/releases/latest/download/composer.phar';
|
||||||
|
url = 'https://getcomposer.org/composer-stable.phar';
|
||||||
|
script += await addArchive(tool, version, url, os_version);
|
||||||
|
break;
|
||||||
|
case 'codeception':
|
||||||
|
url =
|
||||||
|
'https://codeception.com/' +
|
||||||
|
(await getCodeceptionUri(version, php_version));
|
||||||
|
script += await addArchive(tool, version, 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);
|
||||||
|
break;
|
||||||
|
case 'deployer':
|
||||||
|
url = await getDeployerUrl(version);
|
||||||
|
script += await addArchive(tool, version, url, os_version);
|
||||||
|
break;
|
||||||
|
case 'phinx':
|
||||||
|
script += await addPackage(tool, release, 'robmorgan/', os_version);
|
||||||
|
break;
|
||||||
|
case 'prestissimo':
|
||||||
|
script += await addPackage(tool, release, 'hirak/', os_version);
|
||||||
|
break;
|
||||||
|
case 'composer-prefetcher':
|
||||||
|
script += await addPackage(
|
||||||
|
tool,
|
||||||
|
release,
|
||||||
|
'narrowspark/automatic-',
|
||||||
|
os_version
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
case 'pecl':
|
||||||
|
script += await getCommand(os_version, 'pecl');
|
||||||
|
break;
|
||||||
|
case 'php-config':
|
||||||
|
case 'phpize':
|
||||||
|
script += await addDevTools(tool, os_version);
|
||||||
|
break;
|
||||||
|
case 'symfony':
|
||||||
|
case 'symfony-cli':
|
||||||
|
uri = await getSymfonyUri(version, os_version);
|
||||||
|
url = github + 'symfony/cli/' + uri;
|
||||||
|
script += await addArchive('symfony', version, url, os_version);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
script += await utils.addLog(
|
||||||
|
'$cross',
|
||||||
|
tool,
|
||||||
|
'Tool ' + tool + ' is not supported',
|
||||||
|
os_version
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return script;
|
||||||
|
}
|
36
src/utils.ts
36
src/utils.ts
@ -65,7 +65,6 @@ export async function color(type: string): Promise<string> {
|
|||||||
* @param message
|
* @param message
|
||||||
* @param os_version
|
* @param os_version
|
||||||
* @param log_type
|
* @param log_type
|
||||||
* @param prefix
|
|
||||||
*/
|
*/
|
||||||
export async function log(
|
export async function log(
|
||||||
message: string,
|
message: string,
|
||||||
@ -121,6 +120,7 @@ export async function stepLog(
|
|||||||
* @param mark
|
* @param mark
|
||||||
* @param subject
|
* @param subject
|
||||||
* @param message
|
* @param message
|
||||||
|
* @param os_version
|
||||||
*/
|
*/
|
||||||
export async function addLog(
|
export async function addLog(
|
||||||
mark: string,
|
mark: string,
|
||||||
@ -147,14 +147,8 @@ export async function addLog(
|
|||||||
* Read the scripts
|
* Read the scripts
|
||||||
*
|
*
|
||||||
* @param filename
|
* @param filename
|
||||||
* @param version
|
|
||||||
* @param os_version
|
|
||||||
*/
|
*/
|
||||||
export async function readScript(
|
export async function readScript(filename: string): Promise<string> {
|
||||||
filename: string,
|
|
||||||
version: string,
|
|
||||||
os_version: string
|
|
||||||
): Promise<string> {
|
|
||||||
return fs.readFileSync(
|
return fs.readFileSync(
|
||||||
path.join(__dirname, '../src/scripts/' + filename),
|
path.join(__dirname, '../src/scripts/' + filename),
|
||||||
'utf8'
|
'utf8'
|
||||||
@ -165,7 +159,6 @@ export async function readScript(
|
|||||||
* Write final script which runs
|
* Write final script which runs
|
||||||
*
|
*
|
||||||
* @param filename
|
* @param filename
|
||||||
* @param version
|
|
||||||
* @param script
|
* @param script
|
||||||
*/
|
*/
|
||||||
export async function writeScript(
|
export async function writeScript(
|
||||||
@ -191,30 +184,37 @@ export async function extensionArray(
|
|||||||
case ' ':
|
case ' ':
|
||||||
return [];
|
return [];
|
||||||
default:
|
default:
|
||||||
return extension_csv.split(',').map(function(extension: string) {
|
return extension_csv
|
||||||
|
.split(',')
|
||||||
|
.map(function(extension: string) {
|
||||||
return extension
|
return extension
|
||||||
.trim()
|
.trim()
|
||||||
|
.toLowerCase()
|
||||||
.replace('php-', '')
|
.replace('php-', '')
|
||||||
.replace('php_', '');
|
.replace('php_', '');
|
||||||
});
|
})
|
||||||
|
.filter(Boolean);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function to break ini values csv into an array
|
* Function to break csv into an array
|
||||||
*
|
*
|
||||||
* @param ini_values_csv
|
* @param values_csv
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
export async function INIArray(ini_values_csv: string): Promise<Array<string>> {
|
export async function CSVArray(values_csv: string): Promise<Array<string>> {
|
||||||
switch (ini_values_csv) {
|
switch (values_csv) {
|
||||||
case '':
|
case '':
|
||||||
case ' ':
|
case ' ':
|
||||||
return [];
|
return [];
|
||||||
default:
|
default:
|
||||||
return ini_values_csv.split(',').map(function(ini_value: string) {
|
return values_csv
|
||||||
return ini_value.trim();
|
.split(',')
|
||||||
});
|
.map(function(value: string) {
|
||||||
|
return value.trim();
|
||||||
|
})
|
||||||
|
.filter(Boolean);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
/* Basic Options */
|
/* Basic Options */
|
||||||
// "incremental": true, /* Enable incremental compilation */
|
// "incremental": true, /* Enable incremental compilation */
|
||||||
"target": "es6", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */
|
"target": "ES2020", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */
|
||||||
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
|
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
|
||||||
// "allowJs": true, /* Allow javascript files to be compiled. */
|
// "allowJs": true, /* Allow javascript files to be compiled. */
|
||||||
// "checkJs": true, /* Report errors in .js files. */
|
// "checkJs": true, /* Report errors in .js files. */
|
||||||
|
Reference in New Issue
Block a user