Merge pull request #337 from shivammathur/develop

2.8.0
This commit is contained in:
Shivam Mathur 2020-11-17 15:43:47 +05:30
commit 02cba443ad
No known key found for this signature in database
GPG Key ID: 3E13E4C8591ACC2A
54 changed files with 1558 additions and 2624 deletions

View File

@ -18,13 +18,6 @@ Due to time constraints, you may not always get a quick response. Please do not
## Coding Guidelines ## Coding Guidelines
This project comes with `.prettierrc.json` and `eslintrc.json` configuration files. Please run the following commands to format the code before committing it.
```bash
$ npm run format
$ npm run lint
```
## Using setup-php from a Git checkout ## Using setup-php from a Git checkout
The following commands can be used to perform the initial checkout of setup-php: The following commands can be used to perform the initial checkout of setup-php:
@ -41,6 +34,19 @@ Install setup-php dependencies using [npm](https://www.npmjs.com/):
$ npm install $ npm install
``` ```
If you are using `Windows` configure `git` to handle line endings.
```cmd
git config --local core.autocrlf true
```
This project comes with `.prettierrc.json` and `eslintrc.json` configuration files. Please run the following commands to fix and verify the code quality.
```bash
$ npm run format
$ npm run lint
```
## Running the test suite ## Running the test suite
After following the steps shown above, The `setup-php` tests in the `__tests__` directory can be run using this command: After following the steps shown above, The `setup-php` tests in the `__tests__` directory can be run using this command:

View File

@ -30,7 +30,7 @@ This PR [briefly explain what it does]
> In case this PR edits any scripts: > In case this PR edits any scripts:
- [ ] I have checked the edited scripts for syntax. - [ ] I have checked the edited scripts for syntax.
- [ ] I have tested the changes in an integration test (If yes, provide workflow link). - [ ] I have tested the changes in an integration test (If yes, provide workflow YAML and link).
<!-- <!--
- Please target the develop branch when submitting the pull request. - Please target the develop branch when submitting the pull request.

4
.github/SECURITY.md vendored
View File

@ -6,8 +6,8 @@ The following versions of this project are supported for security updates.
| Version | Supported | | Version | Supported |
| ------- | ------------------ | | ------- | ------------------ |
| 1.9.x | :white_check_mark: | | 1.10.x | :white_check_mark: |
| 2.6.x | :white_check_mark: | | 2.8.x | :white_check_mark: |
## Supported PHP Versions ## Supported PHP Versions

73
.github/workflows/docs.yml vendored Normal file
View File

@ -0,0 +1,73 @@
name: Docs workflow
on:
repository_dispatch:
schedule:
- cron: '0 0 * * 2'
jobs:
create:
name: Create
runs-on: ${{ matrix.operating-system }}
strategy:
fail-fast: false
matrix:
operating-system: [ubuntu-20.04, ubuntu-18.04, ubuntu-16.04, windows-2019, macos-10.15, macos-11.0]
php-versions: ['5.3', '5.4', '5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1']
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
- name: Save unix
env:
file: php${{ matrix.php-versions }}-${{ matrix.operating-system }}.md
version: ${{ matrix.php-versions }}
if: matrix.operating-system != 'windows-2019'
run: |
echo "## PHP $version" >> "$file"
printf "\n" >> "$file"
echo "\`\`\`" >> "$file"
php -m >> "$file"
echo "\`\`\`" >> "$file"
printf "\n" >> "$file"
- name: Save Windows
env:
file: php${{ matrix.php-versions }}-${{ matrix.operating-system }}.md
version: ${{ matrix.php-versions }}
if: matrix.operating-system == 'windows-2019'
run: |
Write-Output "## PHP $version`n" | Out-File -FilePath "$env:file"
Write-Output "``````" | Out-File -FilePath "$env:file" -Append
php -m | Out-File -FilePath "$env:file" -Append
Write-Output "```````n" | Out-File -FilePath "$env:file" -Append
- uses: actions/upload-artifact@v2
with:
name: lists
path: php${{ matrix.php-versions }}-${{ matrix.operating-system }}.md
update:
name: Update
needs: create
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
repository: ${{ github.repository }}.wiki
- uses: actions/download-artifact@v2
with:
path: ${{ github.workspace }}
- name: Combine
run: |
git config --local user.email "${{ secrets.email }}"
git config --local user.name "${{ github.repository_owner }}"
for os in ubuntu-20.04 ubuntu-18.04 ubuntu-16.04 windows-2019 macos-10.15 macos-11.0; do
echo "# PHP Extensions on $os" > Php-extensions-on-"$os".md
for version in 5.3 5.4 5.5 5.6 7.0 7.1 7.2 7.3 7.4 8.0 8.1; do
cat lists/php"$version"-"$os".md >> Php-extensions-on-"$os".md
done
done
rm -rf ./lists
if [ "$(git status --porcelain=v1 2>/dev/null | wc -l)" != "0" ]; then
git add .
git commit -m "Update PHP extensions on wiki - $(date +'%d-%m-%y')"
git push -f https://${{ github.repository_owner }}:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.wiki.git master || true
fi

View File

@ -34,7 +34,7 @@ jobs:
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Setup cache environment - name: Setup cache environment
id: extcache id: cache-env
uses: shivammathur/cache-extensions@develop uses: shivammathur/cache-extensions@develop
with: with:
php-version: ${{ matrix.php-versions }} php-version: ${{ matrix.php-versions }}
@ -44,9 +44,9 @@ jobs:
- name: Cache extensions - name: Cache extensions
uses: actions/cache@v2 uses: actions/cache@v2
with: with:
path: ${{ steps.extcache.outputs.dir }} path: ${{ steps.cache-env.outputs.dir }}
key: ${{ steps.extcache.outputs.key }} key: ${{ steps.cache-env.outputs.key }}
restore-keys: ${{ steps.extcache.outputs.key }} restore-keys: ${{ steps.cache-env.outputs.key }}
- name: Setup PHP with extensions and custom config - name: Setup PHP with extensions and custom config
run: node dist/index.js run: node dist/index.js

View File

@ -10,7 +10,7 @@
<a href="https://github.com/shivammathur/setup-php" title="GitHub action to setup PHP"><img alt="GitHub Actions status" src="https://github.com/shivammathur/setup-php/workflows/Main%20workflow/badge.svg"></a> <a href="https://github.com/shivammathur/setup-php" title="GitHub action to setup PHP"><img alt="GitHub Actions status" src="https://github.com/shivammathur/setup-php/workflows/Main%20workflow/badge.svg"></a>
<a href="https://codecov.io/gh/shivammathur/setup-php" title="Code coverage"><img alt="Codecov Code Coverage" src="https://img.shields.io/codecov/c/github/shivammathur/setup-php?logo=codecov"></a> <a href="https://codecov.io/gh/shivammathur/setup-php" title="Code coverage"><img alt="Codecov Code Coverage" src="https://img.shields.io/codecov/c/github/shivammathur/setup-php?logo=codecov"></a>
<a href="https://github.com/shivammathur/setup-php/blob/master/LICENSE" title="license"><img alt="LICENSE" src="https://img.shields.io/badge/license-MIT-428f7e.svg?logo=open%20source%20initiative&logoColor=white&labelColor=555555"></a> <a href="https://github.com/shivammathur/setup-php/blob/master/LICENSE" title="license"><img alt="LICENSE" src="https://img.shields.io/badge/license-MIT-428f7e.svg?logo=open%20source%20initiative&logoColor=white&labelColor=555555"></a>
<a href="#tada-php-support" title="PHP Versions Supported"><img alt="PHP Versions Supported" src="https://img.shields.io/badge/php-5.3%20to%208.0-777bb3.svg?logo=php&logoColor=white&labelColor=555555"></a> <a href="#tada-php-support" title="PHP Versions Supported"><img alt="PHP Versions Supported" src="https://img.shields.io/badge/php-5.3%20to%208.1-777bb3.svg?logo=php&logoColor=white&labelColor=555555"></a>
</p> </p>
<p align="center"> <p align="center">
<a href="https://reddit.com/r/setup_php" title="setup-php reddit"><img alt="setup-php reddit" src="https://img.shields.io/badge/reddit-join-FF5700?logo=reddit&logoColor=FF5700&labelColor=555555"></a> <a href="https://reddit.com/r/setup_php" title="setup-php reddit"><img alt="setup-php reddit" src="https://img.shields.io/badge/reddit-join-FF5700?logo=reddit&logoColor=FF5700&labelColor=555555"></a>
@ -37,6 +37,7 @@ Setup PHP with required extensions, php.ini configuration, code-coverage support
- [Flags](#flags) - [Flags](#flags)
- [Basic Setup](#basic-setup) - [Basic Setup](#basic-setup)
- [Matrix Setup](#matrix-setup) - [Matrix Setup](#matrix-setup)
- [Multi-Arch Setup](#multi-arch-setup)
- [Nightly Build Setup](#nightly-build-setup) - [Nightly Build Setup](#nightly-build-setup)
- [Self Hosted Setup](#self-hosted-setup) - [Self Hosted Setup](#self-hosted-setup)
- [Local Testing Setup](#local-testing-setup) - [Local Testing Setup](#local-testing-setup)
@ -106,6 +107,8 @@ The action supports both `GitHub-hosted` runners and `self-hosted` runners on th
## :heavy_plus_sign: PHP Extension Support ## :heavy_plus_sign: PHP Extension Support
- Extensions enabled by default after `setup-php` runs can be found on the [wiki](https://github.com/shivammathur/setup-php/wiki).
- On `ubuntu` by default extensions which are available as a package can be installed. PECL extensions if not available as a package can be installed by specifying `pecl` in the tools input. - On `ubuntu` by default extensions which are available as a package can be installed. PECL extensions if not available as a package can be installed by specifying `pecl` in the tools input.
```yaml ```yaml
@ -165,7 +168,7 @@ The action supports both `GitHub-hosted` runners and `self-hosted` runners on th
extensions: intl-67.1 extensions: intl-67.1
``` ```
- These extensions have custom support - `cubrid`, `pdo_cubrid` and `gearman` on `Ubuntu`, and `blackfire`, `ioncube`, `oci8`, `pdo_oci`, `phalcon3` and `phalcon4` on all supported OS. - These extensions have custom support - `cubrid`, `pdo_cubrid` and `gearman` on `Ubuntu`, and `blackfire`, `couchbase`, `ioncube`, `oci8`, `pdo_oci`, `phalcon3` and `phalcon4` on all supported OS.
- By default, extensions which cannot be added or removed gracefully leave an error message in the logs, the action is not interrupted. To change this behaviour you can set `fail-fast` flag to `true`. - By default, extensions which cannot be added or removed gracefully leave an error message in the logs, the action is not interrupted. To change this behaviour you can set `fail-fast` flag to `true`.
@ -193,7 +196,7 @@ These tools can be setup globally using the `tools` input.
tools: php-cs-fixer, phpunit tools: php-cs-fixer, phpunit
``` ```
- To set up a particular version of a tool, specify it in the form `tool:version`. The latest stable version of `composer` is set up by default. You can set up the required version by specifying `v1`, `v2`, `snapshot` or `preview` as version. - To set up a particular version of a tool, specify it in the form `tool:version`. The latest stable version of `composer` is set up by default. You can set up the required `composer` version by specifying `v1`, `v2`, `snapshot` or `preview` as versions or the exact version in semver format.
```yaml ```yaml
- name: Setup PHP with composer v2 - name: Setup PHP with composer v2
@ -203,6 +206,8 @@ These tools can be setup globally using the `tools` input.
tools: composer:v2 tools: composer:v2
``` ```
- If you have specified composer plugins `prestissimo` or `composer-prefetcher` in tools, the latest stable version of `composer v1` will be setup. Unless some of your packages require `composer v1`, it is recommended to drop `prestissimo` and use `composer v2`.
- The latest versions of both agent `blackfire-agent` and client `blackfire` are setup when `blackfire` is specified in tools input. Please refer to the [official documentation](https://blackfire.io/docs/integrations/ci/github-actions "Blackfire.io documentation for GitHub Actions") for using `blackfire` with GitHub Actions. - The latest versions of both agent `blackfire-agent` and client `blackfire` are setup when `blackfire` is specified in tools input. Please refer to the [official documentation](https://blackfire.io/docs/integrations/ci/github-actions "Blackfire.io documentation for GitHub Actions") for using `blackfire` with GitHub Actions.
- Version for other tools should be in `semver` format and a valid release of the tool. This is useful for installing tools for older versions of PHP. For example to set up `PHPUnit` on `PHP 7.2`. - Version for other tools should be in `semver` format and a valid release of the tool. This is useful for installing tools for older versions of PHP. For example to set up `PHPUnit` on `PHP 7.2`.
@ -402,6 +407,37 @@ jobs:
tools: php-cs-fixer, phpunit tools: php-cs-fixer, phpunit
``` ```
### Multi-Arch Setup
> Setup PHP on multiple architecture on Ubuntu GitHub Runners.
- `PHP 5.6` to `PHP 7.4` are supported by `setup-php` on multiple architecture on `Ubuntu`.
- For this, you can use `shivammathur/node` images as containers. These have compatible `Nodejs` and `spc` utility.
- Using `spc` you can run `setup-php` on both `i386` and `amd64` containers as opposed to [default syntax](#basic-setup), which only supports `amd64`.
- Currently, for `Arm` based setup, you will need [self-hosted runners](#self-hosted-setup).
```yaml
jobs:
run:
runs-on: ubuntu-latest
container: shivammathur/node:latest-${{ matrix.arch }}
strategy:
matrix:
arch: ["amd64", "i386"]
steps:
- name: Install PHP
run: |
# Update spc (See https://github.com/shivammathur/spc for options)
spc -U
# Install PHP
spc --php-version "7.4" \
--extensions "mbstring, intl" \
--ini-values "post_max_size=256M, short_open_tag=On" \
--coverage "xdebug" \
--tools "php-cs-fixer, phpunit"
```
### Nightly Build Setup ### Nightly Build Setup
> Setup a nightly build of `PHP 8.0` or `PHP 8.1`. > Setup a nightly build of `PHP 8.0` or `PHP 8.1`.
@ -460,6 +496,7 @@ jobs:
**Notes** **Notes**
- Do not setup multiple self-hosted runners on a single server instance as parallel workflow will conflict with each other. - Do not setup multiple self-hosted runners on a single server instance as parallel workflow will conflict with each other.
- Do not setup self-hosted runners on the side on your development environment or your production server. - Do not setup self-hosted runners on the side on your development environment or your production server.
- Avoid using the same labels for your `self-hosted` runners which are used by `GitHub-hosted` runners.
### Local Testing Setup ### Local Testing Setup
@ -561,13 +598,13 @@ If your project uses composer, you can persist the composer's internal cache dir
```yaml ```yaml
- name: Get composer cache directory - name: Get composer cache directory
id: composercache 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)"
- name: Cache dependencies - name: Cache dependencies
uses: actions/cache@v2 uses: actions/cache@v2
with: with:
path: ${{ steps.composercache.outputs.dir }} path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer- restore-keys: ${{ runner.os }}-composer-
@ -577,25 +614,30 @@ If your project uses composer, you can persist the composer's internal cache dir
**Notes** **Notes**
- Please do not cache `vendor` directory using `action/cache` as that will have side effects. - Please do not cache `vendor` directory using `action/cache` as that will have side effects.
- In the above example, if you support a range of `composer` dependencies and do not commit `composer.lock`, you can use the hash of `composer.json` as the key for your cache. - If you do not commit `composer.lock`, you can use the hash of `composer.json` as the key for your cache.
```yaml ```yaml
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
``` ```
- If you support a range of `composer` dependencies and use `prefer-lowest` and `prefer-stable` options, you can store them in your matrix and add them to the keys.
```yaml
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}-${{ matrix.prefer }}-
restore-keys: ${{ runner.os }}-composer-${{ matrix.prefer }}-
```
### Cache Node.js Dependencies ### Cache Node.js Dependencies
If your project has node.js dependencies, you can persist NPM or yarn cache directory. The cached files are available across check-runs and will reduce the workflow execution time. If your project has node.js dependencies, you can persist NPM or yarn cache directory. The cached files are available across check-runs and will reduce the workflow execution time.
```yaml ```yaml
- name: Get node.js cache directory - name: Get node.js cache directory
id: nodecache id: node-cache-dir
run: echo "::set-output name=dir::$(npm config get cache)" # Use $(yarn cache dir) for yarn run: echo "::set-output name=dir::$(npm config get cache)" # Use $(yarn cache dir) for yarn
- name: Cache dependencies - name: Cache dependencies
uses: actions/cache@v2 uses: actions/cache@v2
with: with:
path: ${{ steps.nodecache.outputs.dir }} path: ${{ steps.node-cache-dir.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} # Use '**/yarn.lock' for yarn key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} # Use '**/yarn.lock' for yarn
restore-keys: ${{ runner.os }}-node- restore-keys: ${{ runner.os }}-node-
``` ```
@ -769,6 +811,7 @@ Examples of using `setup-php` with various PHP Frameworks and Packages.
## :package: Dependencies ## :package: Dependencies
- [Node.js dependencies](https://github.com/shivammathur/setup-php/network/dependencies "Node.js dependencies") - [Node.js dependencies](https://github.com/shivammathur/setup-php/network/dependencies "Node.js dependencies")
- [aaronparker/VcRedist](https://github.com/aaronparker/VcRedist "VcRedist PowerShell package")
- [gplessis/dotdeb-php](https://github.com/gplessis/dotdeb-php "Packaging for end of life PHP versions") - [gplessis/dotdeb-php](https://github.com/gplessis/dotdeb-php "Packaging for end of life PHP versions")
- [mlocati/powershell-phpmanager](https://github.com/mlocati/powershell-phpmanager "Package to handle PHP on windows") - [mlocati/powershell-phpmanager](https://github.com/mlocati/powershell-phpmanager "Package to handle PHP on windows")
- [ppa:ondrej/php](https://launchpad.net/~ondrej/+archive/ubuntu/php "Packaging active PHP packages") - [ppa:ondrej/php](https://launchpad.net/~ondrej/+archive/ubuntu/php "Packaging active PHP packages")

View File

@ -21,7 +21,7 @@ describe('Config tests', () => {
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('add_extension pcov'); expect(darwin).toContain('add_brew_extension pcov');
expect(darwin).toContain('remove_extension xdebug'); expect(darwin).toContain('remove_extension xdebug');
}); });
@ -71,7 +71,7 @@ describe('Config tests', () => {
'7.4', '7.4',
'darwin' 'darwin'
); );
expect(darwin).toContain('add_extension xdebug'); expect(darwin).toContain('add_brew_extension xdebug');
}); });
it('checking disableCoverage windows', async () => { it('checking disableCoverage windows', async () => {

View File

@ -3,7 +3,7 @@ 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, sqlite, :intl, phalcon4, ioncube, oci8, pdo_oci, ast-beta, grpc-1.2.3, inotify-1.2.3alpha2', 'Xdebug, pcov, sqlite, :intl, phalcon4, ioncube, oci8, pdo_oci, ast-beta, grpc-1.2.3, inotify-1.2.3alpha2, sqlsrv-1.2.3preview1',
'7.4', '7.4',
'win32' 'win32'
); );
@ -18,6 +18,7 @@ describe('Extension tests', () => {
expect(win32).toContain('Add-Extension ast beta'); expect(win32).toContain('Add-Extension ast beta');
expect(win32).toContain('Add-Extension grpc stable 1.2.3'); expect(win32).toContain('Add-Extension grpc stable 1.2.3');
expect(win32).toContain('Add-Extension inotify alpha 1.2.3'); expect(win32).toContain('Add-Extension inotify alpha 1.2.3');
expect(win32).toContain('Add-Extension sqlsrv devel 1.2.3');
win32 = await extensions.addExtension('pcov', '5.6', 'win32'); win32 = await extensions.addExtension('pcov', '5.6', 'win32');
expect(win32).toContain( expect(win32).toContain(
@ -58,20 +59,15 @@ describe('Extension tests', () => {
it('checking addExtensionOnLinux', async () => { it('checking addExtensionOnLinux', async () => {
let linux: string = await extensions.addExtension( let linux: string = await extensions.addExtension(
'Xdebug, xdebug3, pcov, sqlite, :intl, ast, uopz, ast-beta, pdo_mysql, pdo-odbc, xdebug-alpha, grpc-1.2.3', 'Xdebug, xdebug3, pcov, sqlite, :intl, ast, ast-beta, pdo_mysql, pdo-odbc, xdebug-alpha, grpc-1.2.3',
'7.4', '7.4',
'linux' 'linux'
); );
expect(linux).toContain( expect(linux).toContain(
'add_extension_from_source xdebug xdebug/xdebug master --enable-xdebug zend_extension' 'add_extension_from_source xdebug xdebug/xdebug master --enable-xdebug zend_extension'
); );
expect(linux).toContain('sudo $debconf_fix apt-get install -y php7.4-pcov'); expect(linux).toContain('add_extension sqlite3');
expect(linux).toContain(
'sudo $debconf_fix apt-get install -y php7.4-sqlite3'
);
expect(linux).toContain('remove_extension intl'); expect(linux).toContain('remove_extension intl');
expect(linux).toContain('sudo $debconf_fix apt-get install -y php7.4-ast');
expect(linux).toContain('sudo $debconf_fix apt-get install -y php-uopz');
expect(linux).toContain('add_unstable_extension ast beta extension'); expect(linux).toContain('add_unstable_extension ast beta extension');
expect(linux).toContain('add_pdo_extension mysql'); expect(linux).toContain('add_pdo_extension mysql');
expect(linux).toContain('add_pdo_extension odbc'); expect(linux).toContain('add_pdo_extension odbc');
@ -80,21 +76,21 @@ describe('Extension tests', () => {
'add_unstable_extension xdebug alpha zend_extension' 'add_unstable_extension xdebug alpha zend_extension'
); );
linux = await extensions.addExtension('xdebug3', '8.0', 'linux');
expect(linux).toContain(
'sudo $debconf_fix apt-get install -y php8.0-xdebug'
);
linux = await extensions.addExtension('pcov', '5.6', 'linux'); linux = await extensions.addExtension('pcov', '5.6', 'linux');
expect(linux).toContain( expect(linux).toContain(
'add_log "$cross" "pcov" "pcov is not supported on PHP 5.6"' 'add_log "$cross" "pcov" "pcov is not supported on PHP 5.6"'
); );
linux = await extensions.addExtension('gearman', '7.0', 'linux'); linux = await extensions.addExtension('gearman', '5.6', 'linux');
expect(linux).toContain('add_gearman'); expect(linux).toContain('add_gearman');
linux = await extensions.addExtension('gearman', '7.4', 'linux'); linux = await extensions.addExtension('gearman', '7.4', 'linux');
expect(linux).toContain('add_gearman'); expect(linux).toContain('add_gearman');
linux = await extensions.addExtension('couchbase', '5.6', 'linux');
expect(linux).toContain('add_couchbase');
linux = await extensions.addExtension('couchbase', '7.4', 'linux');
expect(linux).toContain('add_couchbase');
linux = await extensions.addExtension('pdo_cubrid', '7.0', 'linux'); linux = await extensions.addExtension('pdo_cubrid', '7.0', 'linux');
expect(linux).toContain('add_cubrid pdo_cubrid'); expect(linux).toContain('add_cubrid pdo_cubrid');
linux = await extensions.addExtension('cubrid', '7.4', 'linux'); linux = await extensions.addExtension('cubrid', '7.4', 'linux');
@ -133,14 +129,14 @@ describe('Extension tests', () => {
'7.2', '7.2',
'darwin' 'darwin'
); );
expect(darwin).toContain('add_brew_extension xdebug'); expect(darwin).toContain('add_brew_extension xdebug zend_extension');
expect(darwin).toContain('add_brew_extension pcov'); expect(darwin).toContain('add_brew_extension pcov extension');
expect(darwin).toContain('add_brew_extension grpc'); expect(darwin).toContain('add_brew_extension grpc extension');
expect(darwin).toContain('add_brew_extension igbinary'); expect(darwin).toContain('add_brew_extension igbinary extension');
expect(darwin).toContain('add_brew_extension imagick'); expect(darwin).toContain('add_brew_extension imagick extension');
expect(darwin).toContain('add_brew_extension protobuf'); expect(darwin).toContain('add_brew_extension protobuf extension');
expect(darwin).toContain('add_brew_extension swoole'); expect(darwin).toContain('add_brew_extension swoole extension');
expect(darwin).toContain('pecl_install sqlite3'); expect(darwin).toContain('add_extension sqlite3');
expect(darwin).toContain('remove_extension intl'); expect(darwin).toContain('remove_extension intl');
expect(darwin).toContain('add_unstable_extension ast beta extension'); expect(darwin).toContain('add_unstable_extension ast beta extension');
expect(darwin).toContain('add_pecl_extension grpc 1.2.3 extension'); expect(darwin).toContain('add_pecl_extension grpc 1.2.3 extension');
@ -151,6 +147,12 @@ describe('Extension tests', () => {
darwin = await extensions.addExtension('phalcon4', '7.3', 'darwin'); darwin = await extensions.addExtension('phalcon4', '7.3', 'darwin');
expect(darwin).toContain('add_phalcon phalcon4'); expect(darwin).toContain('add_phalcon phalcon4');
darwin = await extensions.addExtension('couchbase', '5.6', 'darwin');
expect(darwin).toContain('add_couchbase');
darwin = await extensions.addExtension('couchbase', '7.3', 'darwin');
expect(darwin).toContain('add_couchbase');
darwin = await extensions.addExtension('ioncube', '7.3', 'darwin'); darwin = await extensions.addExtension('ioncube', '7.3', 'darwin');
expect(darwin).toContain('add_ioncube'); expect(darwin).toContain('add_ioncube');
@ -176,14 +178,13 @@ describe('Extension tests', () => {
expect(darwin).toContain('add_brew_extension xdebug'); expect(darwin).toContain('add_brew_extension xdebug');
darwin = await extensions.addExtension('redis', '5.6', 'darwin'); darwin = await extensions.addExtension('redis', '5.6', 'darwin');
expect(darwin).toContain('pecl_install redis-2.2.8'); expect(darwin).toContain('add_extension redis-2.2.8');
darwin = await extensions.addExtension('redis', '7.2', 'darwin'); darwin = await extensions.addExtension('redis', '7.2', 'darwin');
expect(darwin).toContain('pecl_install redis'); expect(darwin).toContain('add_extension redis');
darwin = await extensions.addExtension('imagick', '5.5', 'darwin'); darwin = await extensions.addExtension('imagick', '5.5', 'darwin');
expect(darwin).toContain('brew install pkg-config imagemagick'); expect(darwin).toContain('add_extension imagick');
expect(darwin).toContain('pecl_install imagick');
darwin = await extensions.addExtension('blackfire', '7.3', 'darwin'); darwin = await extensions.addExtension('blackfire', '7.3', 'darwin');
expect(darwin).toContain('add_blackfire blackfire'); expect(darwin).toContain('add_blackfire blackfire');

View File

@ -187,6 +187,21 @@ describe('Tools tests', () => {
); );
}); });
it('checking getBlackfirePlayerUrl', async () => {
expect(await tools.getBlackfirePlayerUrl('latest', '7.4')).toBe(
'https://get.blackfire.io/blackfire-player.phar'
);
expect(await tools.getBlackfirePlayerUrl('latest', '5.5')).toBe(
'https://get.blackfire.io/blackfire-player-v1.9.3.phar'
);
expect(await tools.getBlackfirePlayerUrl('latest', '7.0')).toBe(
'https://get.blackfire.io/blackfire-player-v1.9.3.phar'
);
expect(await tools.getBlackfirePlayerUrl('1.2.3', '7.0')).toBe(
'https://get.blackfire.io/blackfire-player-v1.2.3.phar'
);
});
it('checking getDeployerUri', async () => { it('checking getDeployerUri', async () => {
expect(await tools.getDeployerUrl('latest')).toBe( expect(await tools.getDeployerUrl('latest')).toBe(
'https://deployer.org/deployer.phar' 'https://deployer.org/deployer.phar'
@ -207,9 +222,17 @@ describe('Tools tests', () => {
'a', 'a',
'b' 'b'
]); ]);
expect(await tools.addComposer(['a', 'b', 'composer:1.2'])).toStrictEqual([
'composer',
'a',
'b'
]);
expect( expect(
await tools.addComposer(['a', 'b', 'composer:1.2.3']) await tools.addComposer(['a', 'b', 'composer:1.2.3'])
).toStrictEqual(['composer', 'a', 'b']); ).toStrictEqual(['composer:1.2.3', 'a', 'b']);
expect(
await tools.addComposer(['a', 'b', 'composer:v1.2.3'])
).toStrictEqual(['composer:1.2.3', 'a', 'b']);
expect( expect(
await tools.addComposer(['a', 'b', 'composer:snapshot']) await tools.addComposer(['a', 'b', 'composer:snapshot'])
).toStrictEqual(['composer:snapshot', 'a', 'b']); ).toStrictEqual(['composer:snapshot', 'a', 'b']);
@ -228,6 +251,9 @@ describe('Tools tests', () => {
expect( expect(
await tools.addComposer(['a', 'b', 'c', 'composer:v2']) await tools.addComposer(['a', 'b', 'c', 'composer:v2'])
).toStrictEqual(['composer:2', 'a', 'b', 'c']); ).toStrictEqual(['composer:2', 'a', 'b', 'c']);
expect(
await tools.addComposer(['hirak', 'b', 'c', 'composer:v2'])
).toStrictEqual(['composer:1', 'hirak', 'b', 'c']);
}); });
it('checking getComposerUrl', async () => { it('checking getComposerUrl', async () => {
@ -249,6 +275,21 @@ describe('Tools tests', () => {
expect(await tools.getComposerUrl('2')).toContain( expect(await tools.getComposerUrl('2')).toContain(
'https://getcomposer.org/composer-2.phar' 'https://getcomposer.org/composer-2.phar'
); );
expect(await tools.getComposerUrl('1.7.2')).toContain(
'https://github.com/composer/composer/releases/download/1.7.2/composer.phar'
);
expect(await tools.getComposerUrl('1.7.2')).toContain(
'https://getcomposer.org/composer-1.7.2.phar'
);
expect(await tools.getComposerUrl('2.0.0-RC2')).toContain(
'https://github.com/composer/composer/releases/download/2.0.0-RC2/composer.phar'
);
expect(await tools.getComposerUrl('2.0.0-RC2')).toContain(
'https://getcomposer.org/composer-2.0.0-RC2.phar'
);
expect(await tools.getComposerUrl('wrong')).toContain(
'https://getcomposer.org/composer-stable.phar'
);
}); });
it('checking getSymfonyUri', async () => { it('checking getSymfonyUri', async () => {
@ -277,7 +318,7 @@ describe('Tools tests', () => {
it('checking getCleanedToolsList', async () => { it('checking getCleanedToolsList', async () => {
const tools_list: string[] = await tools.getCleanedToolsList( const tools_list: string[] = await tools.getCleanedToolsList(
'tool, composer:1.2.3, behat/behat, icanhazstring/composer-unused, laravel/vapor-cli, robmorgan/phinx, hirak/prestissimo, narrowspark/automatic-composer-prefetcher, phpspec/phpspec, symfony/flex' 'tool, composer:1.2, behat/behat, icanhazstring/composer-unused, laravel/vapor-cli, robmorgan/phinx, phpspec/phpspec, symfony/flex'
); );
expect(tools_list).toStrictEqual([ expect(tools_list).toStrictEqual([
'composer', 'composer',
@ -286,8 +327,6 @@ describe('Tools tests', () => {
'composer-unused', 'composer-unused',
'vapor-cli', 'vapor-cli',
'phinx', 'phinx',
'prestissimo',
'composer-prefetcher',
'phpspec', 'phpspec',
'flex' 'flex'
]); ]);
@ -433,7 +472,6 @@ describe('Tools tests', () => {
'blackfire', 'blackfire',
'blackfire-player', 'blackfire-player',
'composer-normalize', 'composer-normalize',
'composer-prefetcher:1.2.3',
'composer-require-checker', 'composer-require-checker',
'composer-unused', 'composer-unused',
'cs2pr:1.2.3', 'cs2pr:1.2.3',
@ -522,9 +560,6 @@ describe('Tools tests', () => {
expect(script).toContain( expect(script).toContain(
'add_composertool composer-unused composer-unused icanhazstring/' 'add_composertool composer-unused composer-unused icanhazstring/'
); );
expect(script).toContain(
'add_composertool composer-prefetcher composer-prefetcher:1.2.3 narrowspark/automatic-'
);
expect(script).toContain( expect(script).toContain(
'add_tool https://github.com/symfony/cli/releases/latest/download/symfony_darwin_amd64 symfony version' 'add_tool https://github.com/symfony/cli/releases/latest/download/symfony_darwin_amd64 symfony version'
); );
@ -551,7 +586,6 @@ describe('Tools tests', () => {
'php-config', 'php-config',
'phpize', 'phpize',
'phpmd', 'phpmd',
'prestissimo',
'symfony', 'symfony',
'wp-cli' 'wp-cli'
]; ];
@ -576,7 +610,6 @@ describe('Tools tests', () => {
expect(script).toContain( expect(script).toContain(
'Add-Tool https://deployer.org/deployer.phar deployer "-V"' 'Add-Tool https://deployer.org/deployer.phar deployer "-V"'
); );
expect(script).toContain('Add-Composertool prestissimo prestissimo hirak/');
expect(script).toContain( expect(script).toContain(
'Add-Tool https://github.com/phpmd/phpmd/releases/latest/download/phpmd.phar phpmd "--version"' 'Add-Tool https://github.com/phpmd/phpmd/releases/latest/download/phpmd.phar phpmd "--version"'
); );
@ -608,7 +641,7 @@ describe('Tools tests', () => {
); );
expect(script).toContain( expect(script).toContain(
'Add-Tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-stable.phar,https://getcomposer.org/composer-stable.phar composer' 'Add-Tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-1.phar,https://getcomposer.org/composer-1.phar composer'
); );
expect(script).toContain('Add-Composertool prestissimo prestissimo hirak/'); expect(script).toContain('Add-Composertool prestissimo prestissimo hirak/');
expect(script).toContain('Add-Composertool phinx phinx robmorgan/'); expect(script).toContain('Add-Composertool phinx phinx robmorgan/');

113
dist/index.js vendored
View File

@ -1764,7 +1764,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
return result; return result;
}; };
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
exports.addTools = exports.addPackage = exports.addDevTools = exports.addArchive = exports.getCleanedToolsList = exports.getComposerUrl = exports.addComposer = exports.getWpCliUrl = exports.getSymfonyUri = exports.getDeployerUrl = exports.getPharUrl = exports.addPhive = exports.getCodeceptionUri = exports.getCodeceptionUriBuilder = exports.getUri = exports.parseTool = exports.getToolVersion = void 0; exports.addTools = exports.addPackage = exports.addDevTools = exports.addArchive = exports.getCleanedToolsList = exports.getComposerUrl = exports.addComposer = exports.getWpCliUrl = exports.getSymfonyUri = exports.getDeployerUrl = exports.getBlackfirePlayerUrl = exports.getPharUrl = exports.addPhive = exports.getCodeceptionUri = exports.getCodeceptionUriBuilder = exports.getUri = exports.parseTool = exports.getToolVersion = void 0;
const utils = __importStar(__webpack_require__(163)); const utils = __importStar(__webpack_require__(163));
/** /**
* Function to get tool version * Function to get tool version
@ -1942,6 +1942,23 @@ async function getPharUrl(domain, tool, prefix, version) {
} }
} }
exports.getPharUrl = getPharUrl; exports.getPharUrl = getPharUrl;
/**
* Function to get blackfire player url for a PHP version.
*
* @param version
* @param php_version
*/
async function getBlackfirePlayerUrl(version, php_version) {
switch (true) {
case /5\.[5-6]|7\.0/.test(php_version) && version == 'latest':
version = '1.9.3';
break;
default:
break;
}
return await getPharUrl('https://get.blackfire.io', 'blackfire-player', 'v', version);
}
exports.getBlackfirePlayerUrl = getBlackfirePlayerUrl;
/** /**
* Function to get the Deployer url * Function to get the Deployer url
* *
@ -2005,15 +2022,19 @@ exports.getWpCliUrl = getWpCliUrl;
*/ */
async function addComposer(tools_list) { async function addComposer(tools_list) {
const regex_any = /^composer($|:.*)/; const regex_any = /^composer($|:.*)/;
const regex_valid = /^composer:?($|preview$|snapshot$|v?[1-2]$)/; const regex_valid = /^composer:?($|preview$|snapshot$|v?[1-2]$|v?\d+\.\d+\.\d+[\w-]*$)/;
const regex_composer1_tools = /hirak|prestissimo|narrowspark|composer-prefetcher/;
const matches = tools_list.filter(tool => regex_valid.test(tool)); const matches = tools_list.filter(tool => regex_valid.test(tool));
let composer = 'composer'; let composer = 'composer';
tools_list = tools_list.filter(tool => !regex_any.test(tool)); tools_list = tools_list.filter(tool => !regex_any.test(tool));
switch (matches[0]) { switch (true) {
case undefined: case regex_composer1_tools.test(tools_list.join(' ')):
composer = 'composer:1';
break;
case matches[0] == undefined:
break; break;
default: default:
composer = matches[matches.length - 1].replace(/v([1-2])/, '$1'); composer = matches[matches.length - 1].replace(/v(\d\S*)/, '$1');
break; break;
} }
tools_list.unshift(composer); tools_list.unshift(composer);
@ -2026,18 +2047,17 @@ exports.addComposer = addComposer;
* @param version * @param version
*/ */
async function getComposerUrl(version) { async function getComposerUrl(version) {
const cache_url = 'https://github.com/shivammathur/composer-cache/releases/latest/download/composer-' + let cache_url = `https://github.com/shivammathur/composer-cache/releases/latest/download/composer-${version.replace('latest', 'stable')}.phar`;
version.replace('latest', 'stable') + switch (true) {
'.phar,'; case /^snapshot$/.test(version):
switch (version) { return `${cache_url},https://getcomposer.org/composer.phar`;
case 'snapshot': case /^preview$|^[1-2]$/.test(version):
return cache_url + 'https://getcomposer.org/composer.phar'; return `${cache_url},https://getcomposer.org/composer-${version}.phar`;
case 'preview': case /^\d+\.\d+\.\d+[\w-]*$/.test(version):
case '1': cache_url = `https://github.com/composer/composer/releases/download/${version}/composer.phar`;
case '2': return `${cache_url},https://getcomposer.org/composer-${version}.phar`;
return (cache_url + 'https://getcomposer.org/composer-' + version + '.phar');
default: default:
return cache_url + 'https://getcomposer.org/composer-stable.phar'; return `${cache_url},https://getcomposer.org/composer-stable.phar`;
} }
} }
exports.getComposerUrl = getComposerUrl; exports.getComposerUrl = getComposerUrl;
@ -2132,7 +2152,7 @@ async function addTools(tools_csv, php_version, os_version) {
script += await addPackage(tool, release, tool + '/', os_version); script += await addPackage(tool, release, tool + '/', os_version);
break; break;
case 'blackfire-player': case 'blackfire-player':
url = await getPharUrl('https://get.blackfire.io', tool, 'v', version); url = await getBlackfirePlayerUrl(version, php_version);
script += await addArchive(tool, url, os_version, '"-V"'); script += await addArchive(tool, url, os_version, '"-V"');
break; break;
case 'codeception': case 'codeception':
@ -2550,6 +2570,7 @@ async function getScript(filename, version, os_version) {
const name = 'setup-php'; const name = 'setup-php';
const url = 'https://setup-php.com/support'; const url = 'https://setup-php.com/support';
// taking inputs // taking inputs
process.env['fail_fast'] = await utils.getInput('fail-fast', false);
const extension_csv = await utils.getInput('extensions', false); const extension_csv = await utils.getInput('extensions', false);
const ini_values_csv = await utils.getInput('ini-values', false); const ini_values_csv = await utils.getInput('ini-values', false);
const coverage_driver = await utils.getInput('coverage', false); const coverage_driver = await utils.getInput('coverage', false);
@ -2583,8 +2604,7 @@ async function run() {
const tool = await utils.scriptTool(os_version); const tool = await utils.scriptTool(os_version);
const script = os_version + (await utils.scriptExtension(os_version)); const script = os_version + (await utils.scriptExtension(os_version));
const location = await getScript(script, version, os_version); const location = await getScript(script, version, os_version);
const fail_fast = await utils.readEnv('fail-fast'); await exec_1.exec(await utils.joins(tool, location, version, __dirname));
await exec_1.exec(await utils.joins(tool, location, version, __dirname, fail_fast));
} }
catch (error) { catch (error) {
core.setFailed(error.message); core.setFailed(error.message);
@ -2845,9 +2865,8 @@ const utils = __importStar(__webpack_require__(163));
* *
* @param extension_csv * @param extension_csv
* @param version * @param version
* @param pipe
*/ */
async function addExtensionDarwin(extension_csv, version, pipe) { async function addExtensionDarwin(extension_csv, version) {
const extensions = await utils.extensionArray(extension_csv); const extensions = await utils.extensionArray(extension_csv);
let add_script = '\n'; let add_script = '\n';
let remove_script = ''; let remove_script = '';
@ -2855,8 +2874,6 @@ async function addExtensionDarwin(extension_csv, version, pipe) {
const version_extension = version + extension; const version_extension = version + extension;
const [ext_name, ext_version] = extension.split('-'); const [ext_name, ext_version] = extension.split('-');
const ext_prefix = await utils.getExtensionPrefix(ext_name); const ext_prefix = await utils.getExtensionPrefix(ext_name);
const command_prefix = 'pecl_install ';
let command = '';
switch (true) { switch (true) {
// match :extension // match :extension
case /^:/.test(ext_name): case /^:/.test(ext_name):
@ -2867,10 +2884,12 @@ async function addExtensionDarwin(extension_csv, version, pipe) {
// match pdo_oci and oci8 // match pdo_oci and oci8
// match 5.3ioncube...7.4ioncube, 7.0ioncube...7.4ioncube // match 5.3ioncube...7.4ioncube, 7.0ioncube...7.4ioncube
// match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4 // match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4
// match 5.6couchbase...7.4couchbase
case /^(5\.[3-6]|7\.[0-4])blackfire(-\d+\.\d+\.\d+)?$/.test(version_extension): case /^(5\.[3-6]|7\.[0-4])blackfire(-\d+\.\d+\.\d+)?$/.test(version_extension):
case /^pdo_oci$|^oci8$/.test(extension): case /^pdo_oci$|^oci8$/.test(extension):
case /^5\.[3-6]ioncube$|^7\.[0-4]ioncube$/.test(version_extension): case /^5\.[3-6]ioncube$|^7\.[0-4]ioncube$/.test(version_extension):
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension): case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
case /^5\.6couchbase$|^7\.[0-4]couchbase$/.test(version_extension):
add_script += await utils.customPackage(ext_name, 'ext', extension, 'darwin'); add_script += await utils.customPackage(ext_name, 'ext', extension, 'darwin');
return; return;
// match pre-release versions. For example - xdebug-beta // match pre-release versions. For example - xdebug-beta
@ -2891,26 +2910,20 @@ async function addExtensionDarwin(extension_csv, version, pipe) {
case /(5\.6|7\.[0-4]|8\.[0-9])(xdebug|igbinary)/.test(version_extension): case /(5\.6|7\.[0-4]|8\.[0-9])(xdebug|igbinary)/.test(version_extension):
case /(5\.6|7\.[0-4])(grpc|imagick|protobuf|swoole)/.test(version_extension): case /(5\.6|7\.[0-4])(grpc|imagick|protobuf|swoole)/.test(version_extension):
case /(7\.[1-4]|8\.[0-9])pcov/.test(version_extension): case /(7\.[1-4]|8\.[0-9])pcov/.test(version_extension):
command = 'add_brew_extension ' + ext_name; add_script += await utils.joins('\nadd_brew_extension', ext_name, ext_prefix);
break; return;
// match 5.6redis // match 5.6redis
case /5\.6redis/.test(version_extension): case /5\.6redis/.test(version_extension):
command = command_prefix + 'redis-2.2.8'; extension = 'redis-2.2.8';
break;
// match 5.4imagick and 5.5imagick
case /^5\.[4-5]imagick$/.test(version_extension):
command = await utils.joins('brew install pkg-config imagemagick' + pipe, '&& ' + command_prefix + 'imagick' + pipe);
break; break;
// match sqlite // match sqlite
case /^sqlite$/.test(extension): case /^sqlite$/.test(extension):
extension = 'sqlite3'; extension = 'sqlite3';
command = command_prefix + extension;
break; break;
default: default:
command = command_prefix + extension;
break; break;
} }
add_script += await utils.joins('\nadd_extension', extension, '"' + command + '"', ext_prefix); add_script += await utils.joins('\nadd_extension', extension, ext_prefix);
}); });
return add_script + remove_script; return add_script + remove_script;
} }
@ -2954,9 +2967,9 @@ async function addExtensionWindows(extension_csv, version) {
add_script += await utils.joins('\nAdd-Extension', ext_name, 'stable', ext_version); add_script += await utils.joins('\nAdd-Extension', ext_name, 'stable', ext_version);
break; break;
// match semver with state // match semver with state
case /.*-(\d+\.\d+\.\d)(beta|alpha|devel|snapshot)\d*/.test(version_extension): case /.*-(\d+\.\d+\.\d)([a-zA-Z+]+)\d*/.test(version_extension):
matches = /.*-(\d+\.\d+\.\d)(beta|alpha|devel|snapshot)\d*/.exec(version_extension); matches = /.*-(\d+\.\d+\.\d)([a-zA-Z+]+)\d*/.exec(version_extension);
add_script += await utils.joins('\nAdd-Extension', ext_name, matches[2], matches[1]); add_script += await utils.joins('\nAdd-Extension', ext_name, matches[2].replace('preview', 'devel'), matches[1]);
break; break;
// match 5.3pcov to 7.0pcov // match 5.3pcov to 7.0pcov
case /(5\.[3-6]|7\.0)pcov/.test(version_extension): case /(5\.[3-6]|7\.0)pcov/.test(version_extension):
@ -2993,9 +3006,8 @@ exports.addExtensionWindows = addExtensionWindows;
* *
* @param extension_csv * @param extension_csv
* @param version * @param version
* @param pipe
*/ */
async function addExtensionLinux(extension_csv, version, pipe) { async function addExtensionLinux(extension_csv, version) {
const extensions = await utils.extensionArray(extension_csv); const extensions = await utils.extensionArray(extension_csv);
let add_script = '\n'; let add_script = '\n';
let remove_script = ''; let remove_script = '';
@ -3003,8 +3015,6 @@ async function addExtensionLinux(extension_csv, version, pipe) {
const version_extension = version + extension; const version_extension = version + extension;
const [ext_name, ext_version] = extension.split('-'); const [ext_name, ext_version] = extension.split('-');
const ext_prefix = await utils.getExtensionPrefix(ext_name); const ext_prefix = await utils.getExtensionPrefix(ext_name);
const command_prefix = 'sudo $debconf_fix apt-get install -y php';
let command = '';
switch (true) { switch (true) {
// Match :extension // Match :extension
case /^:/.test(ext_name): case /^:/.test(ext_name):
@ -3016,14 +3026,14 @@ async function addExtensionLinux(extension_csv, version, pipe) {
// match pdo_oci and oci8 // match pdo_oci and oci8
// match 5.3ioncube...7.4ioncube, 7.0ioncube...7.4ioncube // match 5.3ioncube...7.4ioncube, 7.0ioncube...7.4ioncube
// match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4 // match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4
// match 5.6gearman..7.4gearman // match 5.6gearman...7.4gearman, 5.6couchbase...7.4couchbase
case /^(5\.[3-6]|7\.[0-4])blackfire(-\d+\.\d+\.\d+)?$/.test(version_extension): case /^(5\.[3-6]|7\.[0-4])blackfire(-\d+\.\d+\.\d+)?$/.test(version_extension):
case /^((5\.[3-6])|(7\.[0-2]))pdo_cubrid$|^((5\.[3-6])|(7\.[0-4]))cubrid$/.test(version_extension): case /^((5\.[3-6])|(7\.[0-2]))pdo_cubrid$|^((5\.[3-6])|(7\.[0-4]))cubrid$/.test(version_extension):
case /^pdo_oci$|^oci8$/.test(extension): case /^pdo_oci$|^oci8$/.test(extension):
case /^5\.6intl-[\d]+\.[\d]+$|^7\.[0-4]intl-[\d]+\.[\d]+$/.test(version_extension): case /^5\.6intl-[\d]+\.[\d]+$|^7\.[0-4]intl-[\d]+\.[\d]+$/.test(version_extension):
case /^5\.[3-6]ioncube$|^7\.[0-4]ioncube$/.test(version_extension): case /^5\.[3-6]ioncube$|^7\.[0-4]ioncube$/.test(version_extension):
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension): case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
case /^((5\.6)|(7\.[0-4]))gearman$/.test(version_extension): case /^((5\.6)|(7\.[0-4]))(gearman|couchbase)$/.test(version_extension):
add_script += await utils.customPackage(ext_name, 'ext', extension, 'linux'); add_script += await utils.customPackage(ext_name, 'ext', extension, 'linux');
return; return;
// match pre-release versions. For example - xdebug-beta // match pre-release versions. For example - xdebug-beta
@ -3046,27 +3056,20 @@ async function addExtensionLinux(extension_csv, version, pipe) {
// match 8.0xdebug3...8.9xdebug3 // match 8.0xdebug3...8.9xdebug3
case /^8\.[0-9]xdebug3$/.test(version_extension): case /^8\.[0-9]xdebug3$/.test(version_extension):
extension = 'xdebug'; extension = 'xdebug';
command = command_prefix + version + '-' + extension + pipe;
break; break;
// match pdo extensions // match pdo extensions
case /.*pdo[_-].*/.test(version_extension): case /.*pdo[_-].*/.test(version_extension):
extension = extension.replace(/pdo[_-]|3/, ''); extension = extension.replace(/pdo[_-]|3/, '');
add_script += '\nadd_pdo_extension ' + extension; add_script += '\nadd_pdo_extension ' + extension;
return; return;
// match uopz
case /^(uopz)$/.test(extension):
command = command_prefix + '-' + extension + pipe;
break;
// match sqlite // match sqlite
case /^sqlite$/.test(extension): case /^sqlite$/.test(extension):
extension = 'sqlite3'; extension = 'sqlite3';
command = command_prefix + version + '-' + extension + pipe;
break; break;
default: default:
command = command_prefix + version + '-' + extension + pipe;
break; break;
} }
add_script += await utils.joins('\nadd_extension', extension, '"' + command + '"', ext_prefix); add_script += await utils.joins('\nadd_extension', extension, ext_prefix);
}); });
return add_script + remove_script; return add_script + remove_script;
} }
@ -3080,24 +3083,24 @@ exports.addExtensionLinux = addExtensionLinux;
* @param no_step * @param no_step
*/ */
async function addExtension(extension_csv, version, os_version, no_step = false) { async function addExtension(extension_csv, version, os_version, no_step = false) {
const pipe = await utils.suppressOutput(os_version); const log = await utils.stepLog('Setup Extensions', os_version);
let script = '\n'; let script = '\n';
switch (no_step) { switch (no_step) {
case true: case true:
script += (await utils.stepLog('Setup Extensions', os_version)) + pipe; script += log + (await utils.suppressOutput(os_version));
break; break;
case false: case false:
default: default:
script += await utils.stepLog('Setup Extensions', os_version); script += log;
break; break;
} }
switch (os_version) { switch (os_version) {
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, pipe)); return script + (await addExtensionDarwin(extension_csv, version));
case 'linux': case 'linux':
return script + (await addExtensionLinux(extension_csv, version, pipe)); return script + (await addExtensionLinux(extension_csv, version));
default: default:
return await utils.log('Platform ' + os_version + ' is not supported', os_version, 'error'); return await utils.log('Platform ' + os_version + ' is not supported', os_version, 'error');
} }

View File

@ -17,11 +17,11 @@ jobs:
with: with:
php-version: ${{ matrix.php-versions }} php-version: ${{ matrix.php-versions }}
- name: Get composer cache directory - name: Get composer cache directory
id: composercache 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)"
- uses: actions/cache@v2 - uses: actions/cache@v2
with: with:
path: ${{ steps.composercache.outputs.dir }} path: ${{ steps.composer-cache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed. # Use composer.json for key, if composer.lock is not committed.
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} # key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}

View File

@ -37,12 +37,12 @@ jobs:
- name: Start mysql service - name: Start mysql service
run: sudo /etc/init.d/mysql start run: sudo /etc/init.d/mysql start
- name: Get composer cache directory - name: Get composer cache directory
id: composercache 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)"
- name: Cache composer dependencies - name: Cache composer dependencies
uses: actions/cache@v2 uses: actions/cache@v2
with: with:
path: ${{ steps.composercache.outputs.dir }} path: ${{ steps.composer-cache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed. # Use composer.json for key, if composer.lock is not committed.
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} # key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
@ -70,12 +70,12 @@ jobs:
php-version: '7.3' php-version: '7.3'
extensions: mbstring, intl extensions: mbstring, intl
- name: Get composer cache directory - name: Get composer cache directory
id: composercache 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)"
- name: Cache composer dependencies - name: Cache composer dependencies
uses: actions/cache@v2 uses: actions/cache@v2
with: with:
path: ${{ steps.composercache.outputs.dir }} path: ${{ steps.composer-cache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed. # Use composer.json for key, if composer.lock is not committed.
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} # key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
@ -98,12 +98,12 @@ jobs:
extensions: mbstring, intl extensions: mbstring, intl
tools: phpstan tools: phpstan
- name: Get composer cache directory - name: Get composer cache directory
id: composercache 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)"
- name: Cache composer dependencies - name: Cache composer dependencies
uses: actions/cache@v2 uses: actions/cache@v2
with: with:
path: ${{ steps.composercache.outputs.dir }} path: ${{ steps.composer-cache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed. # Use composer.json for key, if composer.lock is not committed.
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} # key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}

View File

@ -35,12 +35,12 @@ jobs:
extensions: mbstring, intl, redis, pdo_pgsql extensions: mbstring, intl, redis, pdo_pgsql
coverage: pcov coverage: pcov
- name: Get composer cache directory - name: Get composer cache directory
id: composercache 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)"
- name: Cache composer dependencies - name: Cache composer dependencies
uses: actions/cache@v2 uses: actions/cache@v2
with: with:
path: ${{ steps.composercache.outputs.dir }} path: ${{ steps.composer-cache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed. # Use composer.json for key, if composer.lock is not committed.
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} # key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
@ -68,12 +68,12 @@ jobs:
php-version: '7.3' php-version: '7.3'
extensions: mbstring, intl extensions: mbstring, intl
- name: Get composer cache directory - name: Get composer cache directory
id: composercache 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)"
- name: Cache composer dependencies - name: Cache composer dependencies
uses: actions/cache@v2 uses: actions/cache@v2
with: with:
path: ${{ steps.composercache.outputs.dir }} path: ${{ steps.composer-cache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed. # Use composer.json for key, if composer.lock is not committed.
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} # key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
@ -96,12 +96,12 @@ jobs:
extensions: mbstring, intl extensions: mbstring, intl
tools: phpstan tools: phpstan
- name: Get composer cache directory - name: Get composer cache directory
id: composercache 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)"
- name: Cache composer dependencies - name: Cache composer dependencies
uses: actions/cache@v2 uses: actions/cache@v2
with: with:
path: ${{ steps.composercache.outputs.dir }} path: ${{ steps.composer-cache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed. # Use composer.json for key, if composer.lock is not committed.
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} # key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}

View File

@ -19,12 +19,12 @@ jobs:
extensions: mbstring, intl, pdo_sqlite, pdo_mysql extensions: mbstring, intl, pdo_sqlite, pdo_mysql
coverage: pcov #optional coverage: pcov #optional
- name: Get composer cache directory - name: Get composer cache directory
id: composercache 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)"
- name: Cache composer dependencies - name: Cache composer dependencies
uses: actions/cache@v2 uses: actions/cache@v2
with: with:
path: ${{ steps.composercache.outputs.dir }} path: ${{ steps.composer-cache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed. # Use composer.json for key, if composer.lock is not committed.
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} # key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
@ -48,12 +48,12 @@ jobs:
php-version: '7.3' php-version: '7.3'
extensions: mbstring, intl extensions: mbstring, intl
- name: Get composer cache directory - name: Get composer cache directory
id: composercache 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)"
- name: Cache composer dependencies - name: Cache composer dependencies
uses: actions/cache@v2 uses: actions/cache@v2
with: with:
path: ${{ steps.composercache.outputs.dir }} path: ${{ steps.composer-cache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed. # Use composer.json for key, if composer.lock is not committed.
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} # key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
@ -76,12 +76,12 @@ jobs:
extensions: mbstring, intl extensions: mbstring, intl
tools: phpstan tools: phpstan
- name: Get composer cache directory - name: Get composer cache directory
id: composercache 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)"
- name: Cache composer dependencies - name: Cache composer dependencies
uses: actions/cache@v2 uses: actions/cache@v2
with: with:
path: ${{ steps.composercache.outputs.dir }} path: ${{ steps.composer-cache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed. # Use composer.json for key, if composer.lock is not committed.
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} # key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}

View File

@ -18,12 +18,12 @@ jobs:
extensions: mbstring, intl, curl, dom extensions: mbstring, intl, curl, dom
coverage: xdebug #optional coverage: xdebug #optional
- name: Get composer cache directory - name: Get composer cache directory
id: composercache 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)"
- name: Cache composer dependencies - name: Cache composer dependencies
uses: actions/cache@v2 uses: actions/cache@v2
with: with:
path: ${{ steps.composercache.outputs.dir }} path: ${{ steps.composer-cache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed. # Use composer.json for key, if composer.lock is not committed.
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} # key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}

View File

@ -44,12 +44,12 @@ jobs:
- name: Start mysql service - name: Start mysql service
run: sudo /etc/init.d/mysql start run: sudo /etc/init.d/mysql start
- name: Get composer cache directory - name: Get composer cache directory
id: composercache 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)"
- name: Cache composer dependencies - name: Cache composer dependencies
uses: actions/cache@v2 uses: actions/cache@v2
with: with:
path: ${{ steps.composercache.outputs.dir }} path: ${{ steps.composer-cache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed. # Use composer.json for key, if composer.lock is not committed.
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} # key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}

View File

@ -44,12 +44,12 @@ jobs:
extensions: mbstring, dom, fileinfo, pgsql extensions: mbstring, dom, fileinfo, pgsql
coverage: xdebug #optional coverage: xdebug #optional
- name: Get composer cache directory - name: Get composer cache directory
id: composercache 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)"
- name: Cache composer dependencies - name: Cache composer dependencies
uses: actions/cache@v2 uses: actions/cache@v2
with: with:
path: ${{ steps.composercache.outputs.dir }} path: ${{ steps.composer-cache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed. # Use composer.json for key, if composer.lock is not committed.
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} # key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}

View File

@ -20,12 +20,12 @@ jobs:
extensions: mbstring, dom, fileinfo extensions: mbstring, dom, fileinfo
coverage: xdebug #optional coverage: xdebug #optional
- name: Get composer cache directory - name: Get composer cache directory
id: composercache 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)"
- name: Cache composer dependencies - name: Cache composer dependencies
uses: actions/cache@v2 uses: actions/cache@v2
with: with:
path: ${{ steps.composercache.outputs.dir }} path: ${{ steps.composer-cache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed. # Use composer.json for key, if composer.lock is not committed.
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} # key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}

View File

@ -44,12 +44,12 @@ jobs:
- name: Start mysql service - name: Start mysql service
run: sudo /etc/init.d/mysql start run: sudo /etc/init.d/mysql start
- name: Get composer cache directory - name: Get composer cache directory
id: composercache 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)"
- name: Cache composer dependencies - name: Cache composer dependencies
uses: actions/cache@v2 uses: actions/cache@v2
with: with:
path: ${{ steps.composercache.outputs.dir }} path: ${{ steps.composer-cache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed. # Use composer.json for key, if composer.lock is not committed.
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} # key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}

View File

@ -44,12 +44,12 @@ jobs:
extensions: mbstring, dom, fileinfo, pgsql extensions: mbstring, dom, fileinfo, pgsql
coverage: xdebug #optional coverage: xdebug #optional
- name: Get composer cache directory - name: Get composer cache directory
id: composercache 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)"
- name: Cache composer dependencies - name: Cache composer dependencies
uses: actions/cache@v2 uses: actions/cache@v2
with: with:
path: ${{ steps.composercache.outputs.dir }} path: ${{ steps.composer-cache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed. # Use composer.json for key, if composer.lock is not committed.
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} # key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}

View File

@ -20,12 +20,12 @@ jobs:
extensions: mbstring, dom, fileinfo, mysql extensions: mbstring, dom, fileinfo, mysql
coverage: xdebug #optional coverage: xdebug #optional
- name: Get composer cache directory - name: Get composer cache directory
id: composercache 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)"
- name: Cache composer dependencies - name: Cache composer dependencies
uses: actions/cache@v2 uses: actions/cache@v2
with: with:
path: ${{ steps.composercache.outputs.dir }} path: ${{ steps.composer-cache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed. # Use composer.json for key, if composer.lock is not committed.
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} # key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}

View File

@ -44,12 +44,12 @@ jobs:
- name: Start mysql service - name: Start mysql service
run: sudo /etc/init.d/mysql start run: sudo /etc/init.d/mysql start
- name: Get composer cache directory - name: Get composer cache directory
id: composercache 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)"
- name: Cache composer dependencies - name: Cache composer dependencies
uses: actions/cache@v2 uses: actions/cache@v2
with: with:
path: ${{ steps.composercache.outputs.dir }} path: ${{ steps.composer-cache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed. # Use composer.json for key, if composer.lock is not committed.
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} # key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}

View File

@ -43,12 +43,12 @@ jobs:
extensions: mbstring, dom, zip, phalcon4, pgsql #use phalcon3 for the phalcon 3.x extensions: mbstring, dom, zip, phalcon4, pgsql #use phalcon3 for the phalcon 3.x
coverage: xdebug #optional coverage: xdebug #optional
- name: Get composer cache directory - name: Get composer cache directory
id: composercache 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)"
- name: Cache composer dependencies - name: Cache composer dependencies
uses: actions/cache@v2 uses: actions/cache@v2
with: with:
path: ${{ steps.composercache.outputs.dir }} path: ${{ steps.composer-cache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed. # Use composer.json for key, if composer.lock is not committed.
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} # key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}

View File

@ -33,12 +33,12 @@ jobs:
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: ${{ runner.os }}-yarn- restore-keys: ${{ runner.os }}-yarn-
- name: Get composer cache directory - name: Get composer cache directory
id: composercache 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)"
- name: Cache composer dependencies - name: Cache composer dependencies
uses: actions/cache@v2 uses: actions/cache@v2
with: with:
path: ${{ steps.composercache.outputs.dir }} path: ${{ steps.composer-cache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed. # Use composer.json for key, if composer.lock is not committed.
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} # key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}

View File

@ -18,12 +18,12 @@ jobs:
extensions: mbstring, simplexml, dom extensions: mbstring, simplexml, dom
coverage: xdebug #optional coverage: xdebug #optional
- name: Get composer cache directory - name: Get composer cache directory
id: composercache 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)"
- name: Cache composer dependencies - name: Cache composer dependencies
uses: actions/cache@v2 uses: actions/cache@v2
with: with:
path: ${{ steps.composercache.outputs.dir }} path: ${{ steps.composer-cache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed. # Use composer.json for key, if composer.lock is not committed.
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} # key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}

View File

@ -31,12 +31,12 @@ jobs:
- name: Start mysql service - name: Start mysql service
run: sudo /etc/init.d/mysql start run: sudo /etc/init.d/mysql start
- name: Get composer cache directory - name: Get composer cache directory
id: composercache 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)"
- name: Cache composer dependencies - name: Cache composer dependencies
uses: actions/cache@v2 uses: actions/cache@v2
with: with:
path: ${{ steps.composercache.outputs.dir }} path: ${{ steps.composer-cache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed. # Use composer.json for key, if composer.lock is not committed.
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} # key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}

View File

@ -29,12 +29,12 @@ jobs:
extensions: mbstring, xml, ctype, iconv, intl, pdo_sqlite, 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: composercache 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)"
- name: Cache composer dependencies - name: Cache composer dependencies
uses: actions/cache@v2 uses: actions/cache@v2
with: with:
path: ${{ steps.composercache.outputs.dir }} path: ${{ steps.composer-cache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed. # Use composer.json for key, if composer.lock is not committed.
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} # key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}

View File

@ -20,12 +20,12 @@ jobs:
extensions: mbstring, xml, ctype, iconv, intl, pdo_sqlite 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: composercache 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)"
- name: Cache composer dependencies - name: Cache composer dependencies
uses: actions/cache@v2 uses: actions/cache@v2
with: with:
path: ${{ steps.composercache.outputs.dir }} path: ${{ steps.composer-cache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed. # Use composer.json for key, if composer.lock is not committed.
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} # key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}

View File

@ -41,12 +41,12 @@ jobs:
- name: Start mysql service - name: Start mysql service
run: sudo /etc/init.d/mysql start run: sudo /etc/init.d/mysql start
- name: Get composer cache directory - name: Get composer cache directory
id: composercache 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)"
- name: Cache composer dependencies - name: Cache composer dependencies
uses: actions/cache@v2 uses: actions/cache@v2
with: with:
path: ${{ steps.composercache.outputs.dir }} path: ${{ steps.composer-cache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed. # Use composer.json for key, if composer.lock is not committed.
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} # key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}

View File

@ -39,12 +39,12 @@ jobs:
extensions: mbstring, intl, gd, imagick, zip, dom, pgsql extensions: mbstring, intl, gd, imagick, zip, dom, pgsql
coverage: xdebug #optional coverage: xdebug #optional
- name: Get composer cache directory - name: Get composer cache directory
id: composercache 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)"
- name: Cache composer dependencies - name: Cache composer dependencies
uses: actions/cache@v2 uses: actions/cache@v2
with: with:
path: ${{ steps.composercache.outputs.dir }} path: ${{ steps.composer-cache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed. # Use composer.json for key, if composer.lock is not committed.
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} # key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}

View File

@ -18,12 +18,12 @@ jobs:
extensions: mbstring, bcmath, curl, intl extensions: mbstring, bcmath, curl, intl
coverage: xdebug #optional coverage: xdebug #optional
- name: Get composer cache directory - name: Get composer cache directory
id: composercache 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)"
- name: Cache composer dependencies - name: Cache composer dependencies
uses: actions/cache@v2 uses: actions/cache@v2
with: with:
path: ${{ steps.composercache.outputs.dir }} path: ${{ steps.composer-cache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed. # Use composer.json for key, if composer.lock is not committed.
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} # key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}

2307
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,12 +1,12 @@
{ {
"name": "setup-php", "name": "setup-php",
"version": "2.7.0", "version": "2.8.0",
"private": false, "private": false,
"description": "Setup PHP for use with GitHub Actions", "description": "Setup PHP for use with GitHub Actions",
"main": "dist/index.js", "main": "dist/index.js",
"scripts": { "scripts": {
"build": "tsc", "build": "tsc",
"lint": "eslint **/*.ts --cache", "lint": "eslint **/*.ts --cache --fix",
"format": "prettier --write **/*.ts && git add .", "format": "prettier --write **/*.ts && git add .",
"format-check": "prettier --check **/*.ts", "format-check": "prettier --check **/*.ts",
"release": "ncc build src/install.ts -o dist && git add -f dist/", "release": "ncc build src/install.ts -o dist && git add -f dist/",
@ -30,22 +30,22 @@
"fs": "0.0.1-security" "fs": "0.0.1-security"
}, },
"devDependencies": { "devDependencies": {
"@types/jest": "^26.0.14", "@types/jest": "^26.0.15",
"@types/node": "^14.11.10", "@types/node": "^14.14.7",
"@typescript-eslint/eslint-plugin": "^4.4.1", "@typescript-eslint/eslint-plugin": "^4.7.0",
"@typescript-eslint/parser": "^4.4.1", "@typescript-eslint/parser": "^4.7.0",
"@zeit/ncc": "^0.22.3", "@zeit/ncc": "^0.22.3",
"eslint": "^7.11.0", "eslint": "^7.13.0",
"eslint-config-prettier": "^6.13.0", "eslint-config-prettier": "^6.15.0",
"eslint-plugin-import": "^2.22.1", "eslint-plugin-import": "^2.22.1",
"eslint-plugin-jest": "^24.1.0", "eslint-plugin-jest": "^24.1.3",
"eslint-plugin-prettier": "^3.1.4", "eslint-plugin-prettier": "^3.1.4",
"husky": "^4.3.0", "husky": "^4.3.0",
"jest": "^26.6.0", "jest": "^26.6.3",
"jest-circus": "^26.6.0", "jest-circus": "^26.6.3",
"prettier": "^2.1.2", "prettier": "^2.1.2",
"ts-jest": "^26.4.1", "ts-jest": "^26.4.4",
"typescript": "^4.0.3" "typescript": "^4.0.5"
}, },
"husky": { "husky": {
"skipCI": true, "skipCI": true,

View File

@ -5,12 +5,10 @@ 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 add_script = '\n'; let add_script = '\n';
@ -19,8 +17,6 @@ export async function addExtensionDarwin(
const version_extension: string = version + extension; const version_extension: string = version + extension;
const [ext_name, ext_version]: string[] = extension.split('-'); const [ext_name, ext_version]: string[] = extension.split('-');
const ext_prefix = await utils.getExtensionPrefix(ext_name); const ext_prefix = await utils.getExtensionPrefix(ext_name);
const command_prefix = 'pecl_install ';
let command = '';
switch (true) { switch (true) {
// match :extension // match :extension
case /^:/.test(ext_name): case /^:/.test(ext_name):
@ -31,12 +27,14 @@ export async function addExtensionDarwin(
// match pdo_oci and oci8 // match pdo_oci and oci8
// match 5.3ioncube...7.4ioncube, 7.0ioncube...7.4ioncube // match 5.3ioncube...7.4ioncube, 7.0ioncube...7.4ioncube
// match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4 // match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4
// match 5.6couchbase...7.4couchbase
case /^(5\.[3-6]|7\.[0-4])blackfire(-\d+\.\d+\.\d+)?$/.test( case /^(5\.[3-6]|7\.[0-4])blackfire(-\d+\.\d+\.\d+)?$/.test(
version_extension version_extension
): ):
case /^pdo_oci$|^oci8$/.test(extension): case /^pdo_oci$|^oci8$/.test(extension):
case /^5\.[3-6]ioncube$|^7\.[0-4]ioncube$/.test(version_extension): case /^5\.[3-6]ioncube$|^7\.[0-4]ioncube$/.test(version_extension):
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension): case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
case /^5\.6couchbase$|^7\.[0-4]couchbase$/.test(version_extension):
add_script += await utils.customPackage( add_script += await utils.customPackage(
ext_name, ext_name,
'ext', 'ext',
@ -74,34 +72,24 @@ export async function addExtensionDarwin(
version_extension version_extension
): ):
case /(7\.[1-4]|8\.[0-9])pcov/.test(version_extension): case /(7\.[1-4]|8\.[0-9])pcov/.test(version_extension):
command = 'add_brew_extension ' + ext_name; add_script += await utils.joins(
break; '\nadd_brew_extension',
ext_name,
ext_prefix
);
return;
// match 5.6redis // match 5.6redis
case /5\.6redis/.test(version_extension): case /5\.6redis/.test(version_extension):
command = command_prefix + 'redis-2.2.8'; extension = 'redis-2.2.8';
break;
// match 5.4imagick and 5.5imagick
case /^5\.[4-5]imagick$/.test(version_extension):
command = await utils.joins(
'brew install pkg-config imagemagick' + pipe,
'&& ' + command_prefix + 'imagick' + pipe
);
break; break;
// match sqlite // match sqlite
case /^sqlite$/.test(extension): case /^sqlite$/.test(extension):
extension = 'sqlite3'; extension = 'sqlite3';
command = command_prefix + extension;
break; break;
default: default:
command = command_prefix + extension;
break; break;
} }
add_script += await utils.joins( add_script += await utils.joins('\nadd_extension', extension, ext_prefix);
'\nadd_extension',
extension,
'"' + command + '"',
ext_prefix
);
}); });
return add_script + remove_script; return add_script + remove_script;
} }
@ -164,16 +152,14 @@ export async function addExtensionWindows(
); );
break; break;
// match semver with state // match semver with state
case /.*-(\d+\.\d+\.\d)(beta|alpha|devel|snapshot)\d*/.test( case /.*-(\d+\.\d+\.\d)([a-zA-Z+]+)\d*/.test(version_extension):
version_extension matches = /.*-(\d+\.\d+\.\d)([a-zA-Z+]+)\d*/.exec(
):
matches = /.*-(\d+\.\d+\.\d)(beta|alpha|devel|snapshot)\d*/.exec(
version_extension version_extension
) as RegExpExecArray; ) as RegExpExecArray;
add_script += await utils.joins( add_script += await utils.joins(
'\nAdd-Extension', '\nAdd-Extension',
ext_name, ext_name,
matches[2], matches[2].replace('preview', 'devel'),
matches[1] matches[1]
); );
break; break;
@ -212,12 +198,10 @@ 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 add_script = '\n'; let add_script = '\n';
@ -226,8 +210,6 @@ export async function addExtensionLinux(
const version_extension: string = version + extension; const version_extension: string = version + extension;
const [ext_name, ext_version]: string[] = extension.split('-'); const [ext_name, ext_version]: string[] = extension.split('-');
const ext_prefix = await utils.getExtensionPrefix(ext_name); const ext_prefix = await utils.getExtensionPrefix(ext_name);
const command_prefix = 'sudo $debconf_fix apt-get install -y php';
let command = '';
switch (true) { switch (true) {
// Match :extension // Match :extension
case /^:/.test(ext_name): case /^:/.test(ext_name):
@ -239,7 +221,7 @@ export async function addExtensionLinux(
// match pdo_oci and oci8 // match pdo_oci and oci8
// match 5.3ioncube...7.4ioncube, 7.0ioncube...7.4ioncube // match 5.3ioncube...7.4ioncube, 7.0ioncube...7.4ioncube
// match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4 // match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4
// match 5.6gearman..7.4gearman // match 5.6gearman...7.4gearman, 5.6couchbase...7.4couchbase
case /^(5\.[3-6]|7\.[0-4])blackfire(-\d+\.\d+\.\d+)?$/.test( case /^(5\.[3-6]|7\.[0-4])blackfire(-\d+\.\d+\.\d+)?$/.test(
version_extension version_extension
): ):
@ -252,7 +234,7 @@ export async function addExtensionLinux(
): ):
case /^5\.[3-6]ioncube$|^7\.[0-4]ioncube$/.test(version_extension): case /^5\.[3-6]ioncube$|^7\.[0-4]ioncube$/.test(version_extension):
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension): case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
case /^((5\.6)|(7\.[0-4]))gearman$/.test(version_extension): case /^((5\.6)|(7\.[0-4]))(gearman|couchbase)$/.test(version_extension):
add_script += await utils.customPackage( add_script += await utils.customPackage(
ext_name, ext_name,
'ext', 'ext',
@ -290,32 +272,20 @@ export async function addExtensionLinux(
// match 8.0xdebug3...8.9xdebug3 // match 8.0xdebug3...8.9xdebug3
case /^8\.[0-9]xdebug3$/.test(version_extension): case /^8\.[0-9]xdebug3$/.test(version_extension):
extension = 'xdebug'; extension = 'xdebug';
command = command_prefix + version + '-' + extension + pipe;
break; break;
// match pdo extensions // match pdo extensions
case /.*pdo[_-].*/.test(version_extension): case /.*pdo[_-].*/.test(version_extension):
extension = extension.replace(/pdo[_-]|3/, ''); extension = extension.replace(/pdo[_-]|3/, '');
add_script += '\nadd_pdo_extension ' + extension; add_script += '\nadd_pdo_extension ' + extension;
return; return;
// match uopz
case /^(uopz)$/.test(extension):
command = command_prefix + '-' + extension + pipe;
break;
// match sqlite // match sqlite
case /^sqlite$/.test(extension): case /^sqlite$/.test(extension):
extension = 'sqlite3'; extension = 'sqlite3';
command = command_prefix + version + '-' + extension + pipe;
break; break;
default: default:
command = command_prefix + version + '-' + extension + pipe;
break; break;
} }
add_script += await utils.joins( add_script += await utils.joins('\nadd_extension', extension, ext_prefix);
'\nadd_extension',
extension,
'"' + command + '"',
ext_prefix
);
}); });
return add_script + remove_script; return add_script + remove_script;
} }
@ -334,15 +304,15 @@ 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); const log: string = await utils.stepLog('Setup Extensions', os_version);
let script = '\n'; let script = '\n';
switch (no_step) { switch (no_step) {
case true: case true:
script += (await utils.stepLog('Setup Extensions', os_version)) + pipe; script += log + (await utils.suppressOutput(os_version));
break; break;
case false: case false:
default: default:
script += await utils.stepLog('Setup Extensions', os_version); script += log;
break; break;
} }
@ -350,9 +320,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, pipe)); return script + (await addExtensionDarwin(extension_csv, version));
case 'linux': case 'linux':
return script + (await addExtensionLinux(extension_csv, version, pipe)); return script + (await addExtensionLinux(extension_csv, version));
default: default:
return await utils.log( return await utils.log(
'Platform ' + os_version + ' is not supported', 'Platform ' + os_version + ' is not supported',

View File

@ -21,6 +21,7 @@ export async function getScript(
const name = 'setup-php'; const name = 'setup-php';
const url = 'https://setup-php.com/support'; const url = 'https://setup-php.com/support';
// taking inputs // taking inputs
process.env['fail_fast'] = await utils.getInput('fail-fast', false);
const extension_csv: string = await utils.getInput('extensions', false); const extension_csv: string = await utils.getInput('extensions', false);
const ini_values_csv: string = await utils.getInput('ini-values', false); const ini_values_csv: string = await utils.getInput('ini-values', false);
const coverage_driver: string = await utils.getInput('coverage', false); const coverage_driver: string = await utils.getInput('coverage', false);
@ -60,10 +61,7 @@ export async function run(): Promise<void> {
const tool = await utils.scriptTool(os_version); const tool = await utils.scriptTool(os_version);
const script = os_version + (await utils.scriptExtension(os_version)); const script = os_version + (await utils.scriptExtension(os_version));
const location = await getScript(script, version, os_version); const location = await getScript(script, version, os_version);
const fail_fast = await utils.readEnv('fail-fast'); await exec(await utils.joins(tool, location, version, __dirname));
await exec(
await utils.joins(tool, location, version, __dirname, fail_fast)
);
} catch (error) { } catch (error) {
core.setFailed(error.message); core.setFailed(error.message);
} }

251
src/scripts/common.sh Normal file
View File

@ -0,0 +1,251 @@
# Variables
export tick="✓"
export cross="✗"
export curl_opts=(-sL)
export nightly_versions="8.[0-1]"
export old_versions="5.[3-5]"
export tool_path_dir="/usr/local/bin"
export composer_bin="$HOME/.composer/vendor/bin"
export composer_json="$HOME/.composer/composer.json"
export latest="releases/latest/download"
export github="https://github.com/shivammathur"
export bintray="https://dl.bintray/shivammathur"
# Function to log start of a operation.
step_log() {
message=$1
printf "\n\033[90;1m==> \033[0m\033[37;1m%s\033[0m\n" "$message"
}
# 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"
[ "$fail_fast" = "true" ] && exit 1;
fi
}
# Function to log result of installing extension.
add_extension_log() {
extension=$1
status=$2
extension_name=$(echo "$extension" | cut -d '-' -f 1)
(
check_extension "$extension_name" && add_log "$tick" "$extension_name" "$status"
) || add_log "$cross" "$extension_name" "Could not install $extension on PHP ${semver:?}"
}
# Function to read env inputs.
read_env() {
[[ -z "${update}" ]] && update='false' && UPDATE='false' || update="${update}"
[ "$update" = false ] && [[ -n ${UPDATE} ]] && update="${UPDATE}"
[[ -z "${runner}" ]] && runner='github' && RUNNER='github' || runner="${runner}"
[ "$runner" = false ] && [[ -n ${RUNNER} ]] && runner="${RUNNER}"
[[ -z "${fail_fast}" ]] && fail_fast='false' || fail_fast="${fail_fast}"
}
# Function to download a file using cURL.
# mode: -s pipe to stdout, -v save file and return status code
# execute: -e save file as executable
get() {
mode=$1
execute=$2
file_path=$3
shift 3
links=("$@")
if [ "$mode" = "-s" ]; then
sudo curl "${curl_opts[@]}" "${links[0]}"
else
for link in "${links[@]}"; do
status_code=$(sudo curl -w "%{http_code}" -o "$file_path" "${curl_opts[@]}" "$link")
[ "$status_code" = "200" ] && break
done
[ "$execute" = "-e" ] && sudo chmod a+x "$file_path"
[ "$mode" = "-v" ] && echo "$status_code"
fi
}
# Function to download and run scripts from GitHub releases with bintray fallback.
run_script() {
repo=$1
shift
args=("$@")
get -q -e /tmp/install.sh "$github/$repo/$latest/install.sh" "$bintray/php/$repo.sh"
bash /tmp/install.sh "${args[@]}"
}
# Function to install required packages on self-hosted runners.
self_hosted_setup() {
if [ "$runner" = "self-hosted" ]; then
if [[ "${version:?}" =~ $old_versions ]]; then
add_log "$cross" "PHP" "PHP $version is not supported on self-hosted runner"
exit 1
else
self_hosted_helper >/dev/null 2>&1
fi
fi
}
# 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
}
# Function to enable existing extensions.
enable_extension() {
if [ -e /tmp/setup_php_dismod ] && grep -q "$1" /tmp/setup_php_dismod; then
sudo phpenmod -v "$version" "$1" >/dev/null 2>&1
fi
if ! check_extension "$1" && [ -e "${ext_dir:?}/$1.so" ]; then
echo "$2=${ext_dir:?}/$1.so" >>"${pecl_file:-$ini_file}"
fi
}
# Function to configure PECL.
configure_pecl() {
if ! [ -e /tmp/pecl_config ] && command -v pecl >/dev/null; then
for script in pear pecl; do
sudo "$script" config-set php_ini "${pecl_file:-$ini_file}"
sudo "$script" channel-update "$script".php.net
done
echo '' | sudo tee /tmp/pecl_config >/dev/null 2>&1
fi
}
# Function to get the PECL version of an extension.
get_pecl_version() {
extension=$1
stability="$(echo "$2" | grep -m 1 -Eio "(alpha|beta|rc|snapshot|preview)")"
pecl_rest='https://pecl.php.net/rest/r/'
response=$(get -s -n "" "$pecl_rest$extension"/allreleases.xml)
pecl_version=$(echo "$response" | grep -m 1 -Pio "(\d*\.\d*\.\d*$stability\d*)")
if [ ! "$pecl_version" ]; then
pecl_version=$(echo "$response" | grep -m 1 -Po "(\d*\.\d*\.\d*)")
fi
echo "$pecl_version"
}
# Function to install PECL extensions and accept default options
pecl_install() {
local extension=$1
yes '' 2>/dev/null | sudo pecl install -f "$extension" >/dev/null 2>&1
}
# Function to setup 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 extract tool version.
get_tool_version() {
tool=$1
param=$2
version_regex="[0-9]+((\.{1}[0-9]+)+)(\.{0})(-[a-zA-Z0-9]+){0,1}"
if [ "$tool" = "composer" ]; then
if [ "$param" != "snapshot" ]; then
composer_version="$(grep -Ea "const\sVERSION" "$tool_path_dir/composer" | grep -Eo "$version_regex")"
else
composer_version="$(grep -Ea "const\sBRANCH_ALIAS_VERSION" "$tool_path_dir/composer" | grep -Eo "$version_regex")+$(grep -Ea "const\sVERSION" "$tool_path_dir/composer" | grep -Eo "[a-zA-z0-9]+" | tail -n 1)"
fi
echo "$composer_version" | sudo tee /tmp/composer_version
else
$tool "$param" 2>/dev/null | sed -Ee "s/[Cc]omposer(.)?$version_regex//g" | grep -Eo "$version_regex" | head -n 1
fi
}
# Function to configure composer
configure_composer() {
tool_path=$1
sudo ln -sf "$tool_path" "$tool_path.phar"
php -r "try {\$p=new Phar('$tool_path.phar', 0);exit(0);} catch(Exception \$e) {exit(1);}"
if [ $? -eq 1 ]; then
add_log "$cross" "composer" "Could not download composer"
exit 1
fi
composer -q global config process-timeout 0
echo "$composer_bin" >> "$GITHUB_PATH"
if [ -n "$COMPOSER_TOKEN" ]; then
composer -q global config github-oauth.github.com "$COMPOSER_TOKEN"
fi
}
# Function to setup a remote tool.
add_tool() {
url=$1
tool=$2
ver_param=$3
tool_path="$tool_path_dir/$tool"
if [ ! -e "$tool_path" ]; then
rm -rf "$tool_path"
fi
IFS="," read -r -a url <<< "$url"
status_code=$(get -v -e "$tool_path" "${url[@]}")
if [ "$status_code" != "200" ] && [[ "${url[0]}" =~ .*github.com.*releases.*latest.* ]]; then
url[0]="${url[0]//releases\/latest\/download/releases/download/$(get -s -n "" "$(echo "${url[0]}" | cut -d '/' -f '1-5')/releases" | grep -Eo -m 1 "([0-9]+\.[0-9]+\.[0-9]+)/$(echo "${url[0]}" | sed -e "s/.*\///")" | cut -d '/' -f 1)}"
status_code=$(get -v -e "$tool_path" "${url[0]}")
fi
if [ "$status_code" = "200" ]; then
if [ "$tool" = "composer" ]; then
configure_composer "$tool_path"
elif [ "$tool" = "cs2pr" ]; then
sudo sed -i 's/\r$//; s/exit(9)/exit(0)/' "$tool_path" 2>/dev/null ||
sudo sed -i '' 's/\r$//; s/exit(9)/exit(0)/' "$tool_path"
elif [ "$tool" = "phan" ]; then
add_extension fileinfo extension >/dev/null 2>&1
add_extension ast extension >/dev/null 2>&1
elif [ "$tool" = "phive" ]; then
add_extension curl extension >/dev/null 2>&1
add_extension mbstring extension >/dev/null 2>&1
add_extension xml extension >/dev/null 2>&1
elif [ "$tool" = "wp-cli" ]; then
sudo cp -p "$tool_path" "$tool_path_dir"/wp
fi
tool_version=$(get_tool_version "$tool" "$ver_param")
add_log "$tick" "$tool" "Added $tool $tool_version"
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
if [[ "$tool" =~ prestissimo|composer-prefetcher ]]; then
composer_version=$(cat /tmp/composer_version)
if [ "$(echo "$composer_version" | cut -d'.' -f 1)" != "1" ]; then
echo "::warning:: Skipping $tool, as it does not support Composer $composer_version. Specify composer:v1 in tools to use $tool"
add_log "$cross" "$tool" "Skipped"
return
fi
fi
(
composer global require "$prefix$release" >/dev/null 2>&1 &&
json=$(grep "$prefix$tool" "$composer_json") &&
tool_version=$(get_tool_version 'echo' "$json") &&
add_log "$tick" "$tool" "Added $tool $tool_version"
) || add_log "$cross" "$tool" "Could not setup $tool"
if [ -e "$composer_bin/composer" ]; then
sudo cp -p "$tool_path_dir/composer" "$composer_bin"
fi
}
# Function to get PHP version in semver format.
php_semver() {
php"$version" -v | grep -Eo -m 1 "[0-9]+\.[0-9]+\.[0-9]+" | head -n 1
}

View File

@ -1,46 +1,9 @@
# Function to log start of a operation.
step_log() {
message=$1
printf "\n\033[90;1m==> \033[0m\033[37;1m%s\033[0m\n" "$message"
}
# 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"
[ "$fail_fast" = "true" ] && exit 1;
fi
}
# Function to log result of installing extension.
add_extension_log() {
extension=$1
status=$2
extension_name=$(echo "$extension" | cut -d '-' -f 1)
(
check_extension "$extension_name" && add_log "$tick" "$extension_name" "$status"
) || add_log "$cross" "$extension_name" "Could not install $extension on PHP $semver"
}
# Function to read env inputs.
read_env() {
[[ -z "${update}" ]] && update='false' && UPDATE='false' || update="${update}"
[ "$update" = false ] && [[ -n ${UPDATE} ]] && update="${UPDATE}"
[[ -z "${runner}" ]] && runner='github' && RUNNER='github' || runner="${runner}"
[ "$runner" = false ] && [[ -n ${RUNNER} ]] && runner="${RUNNER}"
}
# Function to setup environment for self-hosted runners. # Function to setup environment for self-hosted runners.
self_hosted_setup() { self_hosted_helper() {
if [[ $(command -v brew) == "" ]]; then if ! command -v brew >/dev/null; then
step_log "Setup Brew" step_log "Setup Brew"
curl "${curl_opts[@]}" https://raw.githubusercontent.com/Homebrew/install/master/install.sh | bash -s >/dev/null 2>&1 get -q -e "/tmp/install.sh" "https://raw.githubusercontent.com/Homebrew/install/master/install.sh" && /tmp/install.sh >/dev/null 2>&1
add_log "$tick" "Brew" "Installed Homebrew" add_log "${tick:?}" "Brew" "Installed Homebrew"
fi fi
} }
@ -48,59 +11,27 @@ self_hosted_setup() {
remove_extension() { remove_extension() {
extension=$1 extension=$1
if check_extension "$extension"; then if check_extension "$extension"; then
sudo sed -i '' "/$extension/d" "$ini_file" sudo sed -i '' "/$extension/d" "${ini_file:?}"
sudo rm -rf "$scan_dir"/*"$extension"* >/dev/null 2>&1 sudo rm -rf "${scan_dir:?}"/*"$extension"* "${ext_dir:?}"/"$extension".so >/dev/null 2>&1
sudo rm -rf "$ext_dir"/"$extension".so >/dev/null 2>&1 (! check_extension "$extension" && add_log "${tick:?}" ":$extension" "Removed") ||
(! check_extension "$extension" && add_log "$tick" ":$extension" "Removed") || add_log "${cross:?}" ":$extension" "Could not remove $extension on PHP ${semver:?}"
add_log "$cross" ":$extension" "Could not remove $extension on PHP $semver"
else else
add_log "$tick" ":$extension" "Could not find $extension on PHP $semver" add_log "${tick:?}" ":$extension" "Could not find $extension on PHP $semver"
fi fi
} }
# 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
}
# Function to get the PECL version.
get_pecl_version() {
extension=$1
stability="$(echo "$2" | grep -m 1 -Eio "(alpha|beta|rc|snapshot)")"
pecl_rest='https://pecl.php.net/rest/r/'
response=$(curl "${curl_opts[@]}" "$pecl_rest$extension"/allreleases.xml)
pecl_version=$(echo "$response" | grep -m 1 -Eio "(\d*\.\d*\.\d*$stability\d*)")
if [ ! "$pecl_version" ]; then
pecl_version=$(echo "$response" | grep -m 1 -Eo "(\d*\.\d*\.\d*)")
fi
echo "$pecl_version"
}
# Function to install PECL extensions and accept default options
pecl_install() {
local extension=$1
yes '' | sudo pecl install -f "$extension" >/dev/null 2>&1
}
# Function to install a specific version of PECL extension. # Function to install a specific version of PECL extension.
add_pecl_extension() { add_pecl_extension() {
extension=$1 extension=$1
pecl_version=$2 pecl_version=$2
prefix=$3 prefix=$3
if [[ $pecl_version =~ .*(alpha|beta|rc|snapshot).* ]]; then enable_extension "$extension" "$prefix"
if [[ $pecl_version =~ .*(alpha|beta|rc|snapshot|preview).* ]]; then
pecl_version=$(get_pecl_version "$extension" "$pecl_version") pecl_version=$(get_pecl_version "$extension" "$pecl_version")
fi fi
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');") ext_version=$(php -r "echo phpversion('$extension');")
if [ "$ext_version" = "$pecl_version" ]; then if [ "$ext_version" = "$pecl_version" ]; then
add_log "$tick" "$extension" "Enabled" add_log "${tick:?}" "$extension" "Enabled"
else else
remove_extension "$extension" >/dev/null 2>&1 remove_extension "$extension" >/dev/null 2>&1
pecl_install "$extension-$pecl_version" pecl_install "$extension-$pecl_version"
@ -111,151 +42,66 @@ add_pecl_extension() {
# Function to install a php extension from shivammathur/extensions tap. # Function to install a php extension from shivammathur/extensions tap.
add_brew_extension() { add_brew_extension() {
extension=$1 extension=$1
if ! brew tap | grep shivammathur/extensions; then prefix=$2
brew tap --shallow shivammathur/extensions enable_extension "$extension" "$prefix"
if check_extension "$extension"; then
add_log "${tick:?}" "$extension" "Enabled"
else
if ! brew tap | grep -q shivammathur/extensions; then
brew tap --shallow shivammathur/extensions >/dev/null 2>&1
fi fi
brew install "$extension@$version" brew install "$extension@$version" >/dev/null 2>&1
sudo cp "$(brew --prefix)/opt/$extension@$version/$extension.so" "$ext_dir" sudo cp "$(brew --prefix)/opt/$extension@$version/$extension.so" "$ext_dir"
add_extension_log "$extension" "Installed and enabled"
fi
} }
# Function to setup extensions # Function to setup extensions
add_extension() { add_extension() {
extension=$1 extension=$1
install_command=$2 prefix=$2
prefix=$3 enable_extension "$extension" "$prefix"
if ! check_extension "$extension" && [ -e "$ext_dir/$extension.so" ]; then if check_extension "$extension"; then
echo "$prefix=$ext_dir/$extension.so" >>"$ini_file" && add_log "$tick" "$extension" "Enabled" add_log "${tick:?}" "$extension" "Enabled"
elif check_extension "$extension"; then else
add_log "$tick" "$extension" "Enabled" [[ "$version" =~ 5.[4-5] ]] && [ "$extension" = "imagick" ] && brew install pkg-config imagemagick >/dev/null 2>&1
elif ! check_extension "$extension"; then pecl_install "$extension" >/dev/null 2>&1 &&
eval "$install_command" >/dev/null 2>&1 && if [[ "$version" =~ ${old_versions:?} ]]; then echo "$prefix=$ext_dir/$extension.so" >>"$ini_file"; fi
if [[ "$version" =~ $old_versions ]]; then echo "$prefix=$ext_dir/$extension.so" >>"$ini_file"; fi
add_extension_log "$extension" "Installed and enabled" add_extension_log "$extension" "Installed and enabled"
fi fi
} }
# Function to setup 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 configure composer
configure_composer() {
tool_path=$1
sudo ln -sf "$tool_path" "$tool_path.phar"
php -r "try {\$p=new Phar('$tool_path.phar', 0);exit(0);} catch(Exception \$e) {exit(1);}"
if [ $? -eq 1 ]; then
add_log "$cross" "composer" "Could not download composer"
exit 1
fi
composer -q global config process-timeout 0
echo "/Users/$USER/.composer/vendor/bin" >> "$GITHUB_PATH"
if [ -n "$COMPOSER_TOKEN" ]; then
composer -q global config github-oauth.github.com "$COMPOSER_TOKEN"
fi
}
# Function to extract tool version.
get_tool_version() {
tool=$1
param=$2
version_regex="[0-9]+((\.{1}[0-9]+)+)(\.{0})(-[a-zA-Z0-9]+){0,1}"
if [ "$tool" = "composer" ]; then
if [ "$param" != "snapshot" ]; then
grep -Ea "const\sVERSION" "$tool_path_dir/composer" | grep -Eo "$version_regex"
else
trunk=$(grep -Ea "const\sBRANCH_ALIAS_VERSION" "$tool_path_dir/composer" | grep -Eo "$version_regex")
commit=$(grep -Ea "const\sVERSION" "$tool_path_dir/composer" | grep -Eo "[a-zA-z0-9]+" | tail -n 1)
echo "$trunk+$commit"
fi
else
$tool "$param" 2>/dev/null | sed -Ee "s/[Cc]omposer(.)?$version_regex//g" | grep -Eo "$version_regex" | head -n 1
fi
}
# Function to setup a remote tool.
add_tool() {
url=$1
tool=$2
ver_param=$3
tool_path="$tool_path_dir/$tool"
if [ ! -e "$tool_path" ]; then
rm -rf "$tool_path"
fi
if [ "$tool" = "composer" ]; then
IFS="," read -r -a urls <<< "$url"
status_code=$(sudo curl -f -w "%{http_code}" -o "$tool_path" "${curl_opts[@]}" "${urls[0]}") ||
status_code=$(sudo curl -w "%{http_code}" -o "$tool_path" "${curl_opts[@]}" "${urls[1]}")
else
status_code=$(sudo curl -w "%{http_code}" -o "$tool_path" "${curl_opts[@]}" "$url")
fi
if [ "$status_code" = "200" ]; then
sudo chmod a+x "$tool_path"
if [ "$tool" = "composer" ]; then
configure_composer "$tool_path"
elif [ "$tool" = "phan" ]; then
add_extension fileinfo "pecl_install fileinfo" extension >/dev/null 2>&1
add_extension ast "pecl_install ast" extension >/dev/null 2>&1
elif [ "$tool" = "phive" ]; then
add_extension curl "pecl_install curl" extension >/dev/null 2>&1
add_extension mbstring "pecl_install mbstring" extension >/dev/null 2>&1
add_extension xml "pecl_install 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"
elif [ "$tool" = "wp-cli" ]; then
sudo cp -p "$tool_path" "$tool_path_dir"/wp
fi
tool_version=$(get_tool_version "$tool" "$ver_param")
add_log "$tick" "$tool" "Added $tool $tool_version"
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 &&
json=$(grep "$prefix$tool" /Users/"$USER"/.composer/composer.json) &&
tool_version=$(get_tool_version 'echo' "$json") &&
add_log "$tick" "$tool" "Added $tool $tool_version"
) || add_log "$cross" "$tool" "Could not setup $tool"
}
# Function to handle request to add phpize and php-config. # Function to handle request to add phpize and php-config.
add_devtools() { add_devtools() {
tool=$1 tool=$1
add_log "$tick" "$tool" "Added $tool $semver" add_log "${tick:?}" "$tool" "Added $tool $semver"
}
# Function to configure PECL
configure_pecl() {
for tool in pear pecl; do
sudo "$tool" config-set php_ini "$ini_file"
sudo "$tool" channel-update "$tool".php.net
done
} }
# Function to handle request to add PECL. # Function to handle request to add PECL.
add_pecl() { add_pecl() {
pecl_version=$(get_tool_version "pecl" "version") pecl_version=$(get_tool_version "pecl" "version")
add_log "$tick" "PECL" "Found PECL $pecl_version" add_log "${tick:?}" "PECL" "Found PECL $pecl_version"
} }
# Function to setup PHP 5.6 and newer. # Function to update dependencies.
setup_php() { update_dependencies() {
if [[ "$version" =~ ${nightly_versions:?} ]] && [ "${runner:?}" != "self-hosted" ]; then
tap_dir="$(brew --prefix)/Homebrew/Library/Taps"
while read -r formula; do
get -q -n "$tap_dir/homebrew/homebrew-core/Formula/$formula.rb" "https://raw.githubusercontent.com/Homebrew/homebrew-core/master/Formula/$formula.rb" &
to_wait+=($!)
done <"$tap_dir/shivammathur/homebrew-php/.github/deps/${ImageOS:?}_${ImageVersion:?}"
wait "${to_wait[@]}"
fi
}
# Function to setup PHP 5.6 and newer using Homebrew.
add_php() {
action=$1 action=$1
export HOMEBREW_NO_INSTALL_CLEANUP=TRUE if ! brew tap | grep -q shivammathur/php; then
brew tap --shallow shivammathur/homebrew-php brew tap --shallow shivammathur/php
fi
update_dependencies
if brew list php@"$version" 2>/dev/null | grep -q "Error" && [ "$action" != "upgrade" ]; then if brew list php@"$version" 2>/dev/null | grep -q "Error" && [ "$action" != "upgrade" ]; then
brew unlink php@"$version" brew unlink php@"$version"
else else
@ -264,49 +110,42 @@ setup_php() {
brew link --force --overwrite php@"$version" brew link --force --overwrite php@"$version"
} }
# Variables # Function to Setup PHP
tick="✓" setup_php() {
cross="✗"
version=$1
dist=$2
fail_fast=$3
nodot_version=${1/./}
old_versions="5.[3-5]"
tool_path_dir="/usr/local/bin"
curl_opts=(-sL)
existing_version=$(php-config --version 2>/dev/null | cut -c 1-3)
read_env
if [ "$runner" = "self-hosted" ]; then
if [[ "$version" =~ $old_versions ]]; then
add_log "$cross" "PHP" "PHP $version is not supported on self-hosted runner"
exit 1
else
self_hosted_setup >/dev/null 2>&1
fi
fi
# Setup PHP
step_log "Setup PHP" step_log "Setup PHP"
if [[ "$version" =~ $old_versions ]]; then existing_version=$(php-config --version 2>/dev/null | cut -c 1-3)
curl "${curl_opts[@]}" https://github.com/shivammathur/php5-darwin/releases/latest/download/install.sh | bash -s "$nodot_version" >/dev/null 2>&1 if [[ "$version" =~ ${old_versions:?} ]]; then
run_script "php5-darwin" "${version/./}" >/dev/null 2>&1
status="Installed" status="Installed"
elif [ "$existing_version" != "$version" ]; then elif [ "$existing_version" != "$version" ]; then
setup_php "install" >/dev/null 2>&1 add_php "install" >/dev/null 2>&1
status="Installed" status="Installed"
elif [ "$existing_version" = "$version" ] && [ "$update" = "true" ]; then elif [ "$existing_version" = "$version" ] && [ "${update:?}" = "true" ]; then
setup_php "upgrade" >/dev/null 2>&1 add_php "upgrade" >/dev/null 2>&1
status="Updated to" status="Updated to"
else else
status="Found" status="Found"
fi fi
ini_file=$(php -d "date.timezone=UTC" --ini | grep "Loaded Configuration" | sed -e "s|.*:s*||" | sed "s/ //g") ini_file=$(php -d "date.timezone=UTC" --ini | grep "Loaded Configuration" | sed -e "s|.*:s*||" | sed "s/ //g")
sudo chmod 777 "$ini_file" "$tool_path_dir" sudo chmod 777 "$ini_file" "${tool_path_dir:?}"
echo -e "date.timezone=UTC\nmemory_limit=-1" >>"$ini_file" echo -e "date.timezone=UTC\nmemory_limit=-1" >>"$ini_file"
ext_dir=$(php -i | grep -Ei "extension_dir => /" | sed -e "s|.*=> s*||") ext_dir=$(php -i | grep -Ei "extension_dir => /" | sed -e "s|.*=> s*||")
scan_dir=$(php --ini | grep additional | sed -e "s|.*: s*||") scan_dir=$(php --ini | grep additional | sed -e "s|.*: s*||")
sudo mkdir -p "$ext_dir" sudo mkdir -m 777 -p "$ext_dir" "$HOME/.composer"
semver=$(php -v | head -n 1 | cut -f 2 -d ' ') semver=$(php -v | head -n 1 | cut -f 2 -d ' ')
if [[ ! "$version" =~ $old_versions ]]; then configure_pecl >/dev/null 2>&1; fi if [[ ! "$version" =~ $old_versions ]]; then configure_pecl >/dev/null 2>&1; fi
sudo cp "$dist"/../src/configs/*.json "$RUNNER_TOOL_CACHE/" sudo cp "$dist"/../src/configs/*.json "$RUNNER_TOOL_CACHE/"
add_log "$tick" "PHP" "$status PHP $semver" add_log "$tick" "PHP" "$status PHP $semver"
}
# Variables
version=$1
dist=$2
export HOMEBREW_NO_INSTALL_CLEANUP=1
export HOMEBREW_NO_AUTO_UPDATE=1
# shellcheck source=.
. "${dist}"/../src/scripts/common.sh
read_env
self_hosted_setup
setup_php

View File

@ -17,7 +17,7 @@ Function Add-Blackfire() {
$status="Enabled" $status="Enabled"
} else { } else {
$nts = if (!$installed.ThreadSafe) { "_nts" } else { "" } $nts = if (!$installed.ThreadSafe) { "_nts" } else { "" }
Invoke-WebRequest -UseBasicParsing -Uri "https://packages.blackfire.io/binaries/blackfire-php/${extension_version}/blackfire-php-windows_${arch}-php-${no_dot_version}${nts}.dll" -OutFile $ext_dir\blackfire.dll > $null 2>&1 Invoke-WebRequest -Uri "https://packages.blackfire.io/binaries/blackfire-php/${extension_version}/blackfire-php-windows_${arch}-php-${no_dot_version}${nts}.dll" -OutFile $ext_dir\blackfire.dll > $null 2>&1
Enable-PhpExtension -Extension blackfire -Path $php_dir Enable-PhpExtension -Extension blackfire -Path $php_dir
$status="Installed and enabled" $status="Installed and enabled"
} }

View File

@ -8,9 +8,9 @@ add_blackfire() {
blackfire_ini_file="${scan_dir:?}/50-blackfire.ini" blackfire_ini_file="${scan_dir:?}/50-blackfire.ini"
if [ ! -e "${ext_dir:?}/blackfire.so" ]; then if [ ! -e "${ext_dir:?}/blackfire.so" ]; then
if [ "$extension_version" = "blackfire" ]; then if [ "$extension_version" = "blackfire" ]; then
extension_version=$(curl -sSL https://blackfire.io/api/v1/releases | grep -Eo 'php":"([0-9]+.[0-9]+.[0-9]+)' | cut -d '"' -f 3) extension_version=$(get -s -n "" https://blackfire.io/api/v1/releases | grep -Eo 'php":"([0-9]+.[0-9]+.[0-9]+)' | cut -d '"' -f 3)
fi fi
sudo curl -o "${ext_dir:?}/blackfire.so" "${curl_opts[@]:?}" https://packages.blackfire.io/binaries/blackfire-php/"$extension_version"/blackfire-php-"$platform"_amd64-php-"$no_dot_version".so >/dev/null 2>&1 get -q -n "${ext_dir:?}/blackfire.so" https://packages.blackfire.io/binaries/blackfire-php/"$extension_version"/blackfire-php-"$platform"_amd64-php-"$no_dot_version".so >/dev/null 2>&1
fi fi
echo "extension=blackfire.so" | sudo tee -a "$blackfire_ini_file" >/dev/null 2>&1 echo "extension=blackfire.so" | sudo tee -a "$blackfire_ini_file" >/dev/null 2>&1
add_extension_log "$extension-$extension_version" "Installed and enabled" add_extension_log "$extension-$extension_version" "Installed and enabled"

View File

@ -0,0 +1,40 @@
# Function to install libraries required by couchbase
add_couchbase_libs() {
if [ "$(uname -s)" = "Linux" ]; then
if [[ ${version:?} =~ 5.6|7.[0-1] ]]; then
trunk="http://packages.couchbase.com/ubuntu"
list="deb $trunk ${DISTRIB_CODENAME:?} ${DISTRIB_CODENAME:?}/main"
else
trunk="http://packages.couchbase.com/clients/c/repos/deb"
list="deb $trunk/ubuntu${DISTRIB_RELEASE/./} ${DISTRIB_CODENAME:?} ${DISTRIB_CODENAME:?}/main"
fi
add_pecl
get -s -n "" "$trunk/couchbase.key" | sudo apt-key add
echo "$list" | sudo tee /etc/apt/sources.list.d/couchbase.list
sudo apt-get update
${apt_install:?} libcouchbase-dev
else
if [[ ${version:?} =~ 5.6|7.[0-1] ]]; then
brew install libcouchbase@2
brew link --overwrite --force libcouchbase@2
else
brew install libcouchbase
fi
fi
}
# Function to add couchbase.
add_couchbase() {
add_couchbase_libs >/dev/null 2>&1
enable_extension "couchbase" "extension"
if check_extension "couchbase"; then
add_log "${tick:?}" "couchbase" "Enabled"
else
if [[ ${version:?} =~ 5.6|7.[0-1] ]]; then
pecl_install couchbase-2.6.2 >/dev/null 2>&1
else
pecl_install couchbase >/dev/null 2>&1
fi
add_extension_log "couchbase" "Installed and enabled"
fi
}

View File

@ -2,7 +2,7 @@
install_icu() { install_icu() {
icu=$1 icu=$1
if [ "$(php -i | grep "ICU version =>" | sed -e "s|.*=> s*||")" != "$icu" ]; then if [ "$(php -i | grep "ICU version =>" | sed -e "s|.*=> s*||")" != "$icu" ]; then
sudo curl -o /tmp/icu.tar.zst -sL "https://dl.bintray.com/shivammathur/icu4c/icu4c-$icu.tar.zst" get -q -n /tmp/icu.tar.zst "https://dl.bintray.com/shivammathur/icu4c/icu4c-$icu.tar.zst"
sudo tar -I zstd -xf /tmp/icu.tar.zst -C /usr/local sudo tar -I zstd -xf /tmp/icu.tar.zst -C /usr/local
sudo cp -r /usr/local/icu/lib/* /usr/lib/x86_64-linux-gnu/ sudo cp -r /usr/local/icu/lib/* /usr/lib/x86_64-linux-gnu/
fi fi
@ -11,12 +11,12 @@ install_icu() {
# Function to add ext-intl with the given version of ICU # Function to add ext-intl with the given version of ICU
add_intl() { add_intl() {
icu=$(echo "$1" | cut -d'-' -f 2) icu=$(echo "$1" | cut -d'-' -f 2)
supported_version=$(curl "${curl_opts[@]:?}" https://api.bintray.com/packages/shivammathur/icu4c/icu4c | grep -Po "$icu" | head -n 1) supported_version=$(get -s -n "" https://api.bintray.com/packages/shivammathur/icu4c/icu4c | grep -Po "$icu" | head -n 1)
if [ "$icu" != "$supported_version" ]; then if [ "$icu" != "$supported_version" ]; then
add_log "${cross:?}" "intl" "ICU $icu is not supported" add_log "${cross:?}" "intl" "ICU $icu is not supported"
else else
install_icu "$icu" >/dev/null 2>&1 install_icu "$icu" >/dev/null 2>&1
sudo curl "${curl_opts[@]:?}" -o "${ext_dir:?}/intl.so" "https://dl.bintray.com/shivammathur/icu4c/php${version:?}-intl-$icu.so" get -q -n "${ext_dir:?}/intl.so" "https://dl.bintray.com/shivammathur/icu4c/php${version:?}-intl-$icu.so"
enable_extension intl extension enable_extension intl extension
add_extension_log intl "Installed and enabled with ICU $icu" add_extension_log intl "Installed and enabled with ICU $icu"
fi fi

View File

@ -19,7 +19,7 @@ Function Add-Ioncube() {
if (-not($installed.ThreadSafe)) { if (-not($installed.ThreadSafe)) {
$ts_part = "_nonts" $ts_part = "_nonts"
} }
Invoke-WebRequest -UseBasicParsing -Uri "https://downloads.ioncube.com/loader_downloads/ioncube_loaders_win$ts_part`_vc$vc`_$arch_part.zip" -OutFile $ext_dir\ioncube.zip Invoke-WebRequest -Uri "https://downloads.ioncube.com/loader_downloads/ioncube_loaders_win$ts_part`_vc$vc`_$arch_part.zip" -OutFile $ext_dir\ioncube.zip
Expand-Archive -Path $ext_dir\ioncube.zip -DestinationPath $ext_dir -Force Expand-Archive -Path $ext_dir\ioncube.zip -DestinationPath $ext_dir -Force
Copy-Item $ext_dir\ioncube\ioncube_loader_win_$version.dll $ext_dir\php_ioncube.dll Copy-Item $ext_dir\ioncube\ioncube_loader_win_$version.dll $ext_dir\php_ioncube.dll
} }

View File

@ -10,7 +10,7 @@ add_ioncube() {
if [ ! -e "${ext_dir:?}/ioncube.so" ]; then if [ ! -e "${ext_dir:?}/ioncube.so" ]; then
status='Installed and enabled' status='Installed and enabled'
os_name='lin' && [ "$(uname -s)" = "Darwin" ] && os_name='mac' os_name='lin' && [ "$(uname -s)" = "Darwin" ] && os_name='mac'
curl "${curl_opts[@]:?}" https://downloads.ioncube.com/loader_downloads/ioncube_loaders_"$os_name"_x86-64.tar.gz | tar -xzf - -C /tmp get -s -n "" https://downloads.ioncube.com/loader_downloads/ioncube_loaders_"$os_name"_x86-64.tar.gz | tar -xzf - -C /tmp
sudo mv /tmp/ioncube/ioncube_loader_"$os_name"_"${version:?}".so "$ext_dir/ioncube.so" sudo mv /tmp/ioncube/ioncube_loader_"$os_name"_"${version:?}".so "$ext_dir/ioncube.so"
fi fi
echo "zend_extension=$ext_dir/ioncube.so" | sudo tee "${scan_dir:?}/00-ioncube.ini" >/dev/null 2>&1 echo "zend_extension=$ext_dir/ioncube.so" | sudo tee "${scan_dir:?}/00-ioncube.ini" >/dev/null 2>&1

View File

@ -14,7 +14,7 @@ Function Add-InstantClient() {
if ($arch -eq 'x86') { if ($arch -eq 'x86') {
$suffix = 'nt' $suffix = 'nt'
} }
Invoke-WebRequest -UseBasicParsing -Uri https://download.oracle.com/otn_software/nt/instantclient/instantclient-basiclite-$suffix.zip -OutFile $php_dir\instantclient.zip Invoke-WebRequest -Uri https://download.oracle.com/otn_software/nt/instantclient/instantclient-basiclite-$suffix.zip -OutFile $php_dir\instantclient.zip
Expand-Archive -Path $php_dir\instantclient.zip -DestinationPath $php_dir -Force Expand-Archive -Path $php_dir\instantclient.zip -DestinationPath $php_dir -Force
Copy-Item $php_dir\instantclient*\* $php_dir Copy-Item $php_dir\instantclient*\* $php_dir
} }
@ -44,7 +44,7 @@ Function Add-Oci() {
$ociVersion = '2.0.12' $ociVersion = '2.0.12'
} }
$ociUrl = Get-PeclArchiveUrl oci8 $ociVersion $installed $ociUrl = Get-PeclArchiveUrl oci8 $ociVersion $installed
Invoke-WebRequest -UseBasicParsing -Uri $ociUrl -OutFile $php_dir\oci8.zip Invoke-WebRequest -Uri $ociUrl -OutFile $php_dir\oci8.zip
Expand-Archive -Path $php_dir\oci8.zip -DestinationPath $ext_dir -Force Expand-Archive -Path $php_dir\oci8.zip -DestinationPath $ext_dir -Force
} }

View File

@ -34,7 +34,7 @@ add_client() {
arch='macos' arch='macos'
lib_ext='dylib' lib_ext='dylib'
fi fi
curl -o "/opt/oracle/$package.zip" "${curl_opts[@]:?}" "https://download.oracle.com/otn_software/$os_name/instantclient/instantclient-$package-$arch.zip" get -q -n "/opt/oracle/$package.zip" "https://download.oracle.com/otn_software/$os_name/instantclient/instantclient-$package-$arch.zip"
unzip "/opt/oracle/$package.zip" -d "$oracle_home" unzip "/opt/oracle/$package.zip" -d "$oracle_home"
done done
sudo ln -sf /opt/oracle/instantclient*/*.$lib_ext* $libs sudo ln -sf /opt/oracle/instantclient*/*.$lib_ext* $libs
@ -44,7 +44,7 @@ add_client() {
# Function to get PHP source. # Function to get PHP source.
get_php() { get_php() {
[ ! -d "/opt/oracle/php-src-$tag" ] && curl "${curl_opts[@]}" "https://github.com/php/php-src/archive/$tag.tar.gz" | tar xzf - -C "$oracle_home/" [ ! -d "/opt/oracle/php-src-$tag" ] && get -s -n "" "https://github.com/php/php-src/archive/$tag.tar.gz" | tar xzf - -C "$oracle_home/"
} }
# Function to get phpize location on darwin. # Function to get phpize location on darwin.
@ -73,7 +73,7 @@ restore_phpize() {
# Function to patch pdo_oci. # Function to patch pdo_oci.
patch_pdo_oci_config() { patch_pdo_oci_config() {
curl -O "${curl_opts[@]}" https://raw.githubusercontent.com/php/php-src/PHP-8.0/ext/pdo_oci/config.m4 get -q -n config.m4 https://raw.githubusercontent.com/php/php-src/PHP-8.0/ext/pdo_oci/config.m4
if [[ ${version:?} =~ 5.[3-6] ]]; then if [[ ${version:?} =~ 5.[3-6] ]]; then
sudo sed -i '' "/PHP_CHECK_PDO_INCLUDES/d" config.m4 2>/dev/null || sudo sed -i "/PHP_CHECK_PDO_INCLUDES/d" config.m4 sudo sed -i '' "/PHP_CHECK_PDO_INCLUDES/d" config.m4 2>/dev/null || sudo sed -i "/PHP_CHECK_PDO_INCLUDES/d" config.m4
fi fi
@ -83,16 +83,9 @@ patch_pdo_oci_config() {
add_dependencies() { add_dependencies() {
if [ "$os" = 'Linux' ]; then if [ "$os" = 'Linux' ]; then
if [ "${runner:?}" = "self-hosted" ]; then if [ "${runner:?}" = "self-hosted" ]; then
if ! [[ ${version:?} =~ $nightly_versions ]]; then
${apt_install:?} --no-upgrade --no-install-recommends autoconf automake libaio-dev gcc g++ php"$version"-dev
else
${apt_install:?} --no-upgrade --no-install-recommends autoconf automake libaio-dev gcc g++ ${apt_install:?} --no-upgrade --no-install-recommends autoconf automake libaio-dev gcc g++
fi fi
else ! [[ ${version:?} =~ $nightly_versions ]] && add_devtools phpize
! [[ ${version:?} =~ $nightly_versions ]] && update_lists && ${apt_install:?} --no-upgrade --no-install-recommends php"$version"-dev
fi
sudo update-alternatives --set php-config /usr/bin/php-config"$version"
sudo update-alternatives --set phpize /usr/bin/phpize"$version"
fi fi
} }

View File

@ -5,9 +5,9 @@ Function Add-PhalconHelper() {
} else { } else {
$domain = 'https://github.com' $domain = 'https://github.com'
$nts = if (!$installed.ThreadSafe) { "_nts" } else { "" } $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)`"" $match = Invoke-WebRequest -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 $zip_file = $match.Matches[0].Groups[1].Value
Invoke-WebRequest -UseBasicParsing -Uri $domain/$zip_file -OutFile $ENV:RUNNER_TOOL_CACHE\phalcon.zip > $null 2>&1 Invoke-WebRequest -Uri $domain/$zip_file -OutFile $ENV:RUNNER_TOOL_CACHE\phalcon.zip > $null 2>&1
Expand-Archive -Path $ENV:RUNNER_TOOL_CACHE\phalcon.zip -DestinationPath $ENV:RUNNER_TOOL_CACHE\phalcon -Force > $null 2>&1 Expand-Archive -Path $ENV:RUNNER_TOOL_CACHE\phalcon.zip -DestinationPath $ENV:RUNNER_TOOL_CACHE\phalcon -Force > $null 2>&1
Copy-Item -Path "$ENV:RUNNER_TOOL_CACHE\phalcon\php_phalcon.dll" -Destination "$ext_dir\php_phalcon.dll" Copy-Item -Path "$ENV:RUNNER_TOOL_CACHE\phalcon\php_phalcon.dll" -Destination "$ext_dir\php_phalcon.dll"
Enable-PhpExtension -Extension phalcon -Path $php_dir Enable-PhpExtension -Extension phalcon -Path $php_dir

View File

@ -1,39 +1,10 @@
# Function to log start of a operation. # Function to setup environment for self-hosted runners.
step_log() { self_hosted_helper() {
message=$1 if ! command -v apt-fast >/dev/null; then
printf "\n\033[90;1m==> \033[0m\033[37;1m%s\033[0m\n" "$message" sudo ln -sf /usr/bin/apt-get /usr/bin/apt-fast
}
# 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"
[ "$fail_fast" = "true" ] && exit 1;
fi fi
} install_packages curl make software-properties-common unzip
add_ppa
# Function to log result of installing extension.
add_extension_log() {
extension=$1
status=$2
extension_name=$(echo "$extension" | cut -d '-' -f 1)
(
check_extension "$extension_name" && add_log "$tick" "$extension_name" "$status"
) || add_log "$cross" "$extension_name" "Could not install $extension on PHP $semver"
}
# Function to read env inputs.
read_env() {
. /etc/lsb-release
[[ -z "${update}" ]] && update='false' && UPDATE='false' || update="${update}"
[ "$update" = false ] && [[ -n ${UPDATE} ]] && update="${UPDATE}"
[[ -z "${runner}" ]] && runner='github' && RUNNER='github' || runner="${runner}"
[ "$runner" = false ] && [[ -n ${RUNNER} ]] && runner="${RUNNER}"
} }
# Function to backup and cleanup package lists. # Function to backup and cleanup package lists.
@ -64,70 +35,24 @@ update_lists() {
[ "$DISTRIB_RELEASE" = "20.04" ] && add_ppa >/dev/null 2>&1 [ "$DISTRIB_RELEASE" = "20.04" ] && add_ppa >/dev/null 2>&1
cleanup_lists cleanup_lists
sudo "$debconf_fix" apt-get update >/dev/null 2>&1 sudo "$debconf_fix" apt-get update >/dev/null 2>&1
echo '' | sudo tee "/tmp/setup_php" >/dev/null 2>&1 echo '' | sudo tee /tmp/setup_php >/dev/null 2>&1
fi fi
} }
# Function to setup environment for self-hosted runners. # Function to install a package
self_hosted_setup() { install_packages() {
if ! command -v apt-fast >/dev/null; then packages=("$@")
sudo ln -sf /usr/bin/apt-get /usr/bin/apt-fast $apt_install "${packages[@]}" >/dev/null 2>&1 || update_lists && $apt_install "${packages[@]}" >/dev/null 2>&1
fi
update_lists && $apt_install curl make software-properties-common unzip
add_ppa
}
# Function to configure PECL.
configure_pecl() {
if [ "$pecl_config" = "false" ] && [ -e /usr/bin/pecl ]; then
for tool in pear pecl; do
sudo "$tool" config-set php_ini "$scan_dir"/99-pecl.ini
sudo "$tool" channel-update "$tool".php.net
done
pecl_config="true"
fi
}
# Function to get the PECL version of an extension.
get_pecl_version() {
extension=$1
stability="$(echo "$2" | grep -m 1 -Eio "(alpha|beta|rc|snapshot)")"
pecl_rest='https://pecl.php.net/rest/r/'
response=$(curl "${curl_opts[@]}" "$pecl_rest$extension"/allreleases.xml)
pecl_version=$(echo "$response" | grep -m 1 -Pio "(\d*\.\d*\.\d*$stability\d*)")
if [ ! "$pecl_version" ]; then
pecl_version=$(echo "$response" | grep -m 1 -Po "(\d*\.\d*\.\d*)")
fi
echo "$pecl_version"
}
# Function to install PECL extensions and accept default options
pecl_install() {
local extension=$1
yes '' | sudo pecl install -f "$extension" >/dev/null 2>&1
}
# Function to check if an 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
} }
# Function to delete extensions. # Function to delete extensions.
delete_extension() { delete_extension() {
extension=$1 extension=$1
sudo sed -i "/$extension/d" "$ini_file" sudo sed -i "/$extension/d" "${ini_file:?}"
sudo sed -i "/$extension/d" "$pecl_file" sudo sed -i "/$extension/d" "${pecl_file:?}"
sudo rm -rf "$scan_dir"/*"$extension"* >/dev/null 2>&1 sudo rm -rf "${scan_dir:?}"/*"$extension"* "${ext_dir:?}"/"$extension".so >/dev/null 2>&1
sudo rm -rf "$ext_dir"/"$extension".so >/dev/null 2>&1 if [ "${runner:?}" = "self-hosted" ]; then
if [ "$runner" = "self-hosted" ]; then $apt_remove "php-$extension" "php$version-$extension" >/dev/null 2>&1 || true
$apt_remove "php-$extension" >/dev/null 2>&1 || true
$apt_remove "php$version-$extension" >/dev/null 2>&1 || true
fi fi
} }
@ -135,21 +60,16 @@ delete_extension() {
remove_extension() { remove_extension() {
extension=$1 extension=$1
if check_extension "$extension"; then if check_extension "$extension"; then
if [[ ! "$version" =~ $old_versions ]] && [ -e /etc/php/"$version"/mods-available/"$extension".ini ]; then if [[ ! "$version" =~ ${old_versions:?} ]] && [ -e /etc/php/"$version"/mods-available/"$extension".ini ]; then
sudo phpdismod -v "$version" "$extension" >/dev/null 2>&1 sudo phpdismod -v "$version" "$extension" >/dev/null 2>&1
echo "$extension" | sudo tee -a /tmp/setup_php_dismod >/dev/null 2>&1
fi fi
delete_extension "$extension" delete_extension "$extension"
(! check_extension "$extension" && add_log "$tick" ":$extension" "Removed") || (! check_extension "$extension" && add_log "${tick:?}" ":$extension" "Removed") ||
add_log "$cross" ":$extension" "Could not remove $extension on PHP $semver" add_log "${cross:?}" ":$extension" "Could not remove $extension on PHP ${semver:?}"
else else
add_log "$tick" ":$extension" "Could not find $extension on PHP $semver" delete_extension "$extension"
fi add_log "${tick:?}" ":$extension" "Could not find $extension on PHP $semver"
}
# Function to enable existing extensions.
enable_extension() {
if ! check_extension "$1" && [ -e "$ext_dir/$1.so" ]; then
echo "$2=$1.so" >>"$pecl_file"
fi fi
} }
@ -157,19 +77,19 @@ enable_extension() {
add_pdo_extension() { add_pdo_extension() {
pdo_ext="pdo_$1" pdo_ext="pdo_$1"
if check_extension "$pdo_ext"; then if check_extension "$pdo_ext"; then
add_log "$tick" "$pdo_ext" "Enabled" add_log "${tick:?}" "$pdo_ext" "Enabled"
else else
read -r ext ext_name <<< "$1 $1" ext=$1; ext_name=$1;
sudo rm -rf "$scan_dir"/*pdo.ini >/dev/null 2>&1 sudo rm -rf "$scan_dir"/*pdo.ini >/dev/null 2>&1
if ! check_extension "pdo" 2>/dev/null; then echo "extension=pdo.so" >>"$ini_file"; fi if ! check_extension "pdo" 2>/dev/null; then echo "extension=pdo.so" >>"$ini_file"; fi
if [ "$ext" = "mysql" ]; then if [ "$ext" = "mysql" ]; then
enable_extension "mysqlnd" "extension" enable_extension "mysqlnd" "extension"
ext_name="mysqli" ext_name="mysqli"
elif [ "$ext" = "sqlite" ]; then elif [ "$ext" = "sqlite" ]; then
read -r ext ext_name <<< "sqlite3 sqlite3" ext="sqlite3"; ext_name="sqlite3";
fi fi
add_extension "$ext_name" "$apt_install php$version-$ext" "extension" >/dev/null 2>&1 add_extension "$ext_name" "extension" >/dev/null 2>&1
add_extension "$pdo_ext" "pecl_install $pdo_ext" "extension" >/dev/null 2>&1 add_extension "$pdo_ext" "extension" >/dev/null 2>&1
add_extension_log "$pdo_ext" "Enabled" add_extension_log "$pdo_ext" "Enabled"
fi fi
} }
@ -177,17 +97,18 @@ add_pdo_extension() {
# Function to add extensions. # Function to add extensions.
add_extension() { add_extension() {
extension=$1 extension=$1
install_command=$2 prefix=$2
prefix=$3
enable_extension "$extension" "$prefix" enable_extension "$extension" "$prefix"
if check_extension "$extension"; then if check_extension "$extension"; then
add_log "$tick" "$extension" "Enabled" add_log "${tick:?}" "$extension" "Enabled"
else else
if [[ "$version" =~ 5.[4-5] ]]; then if [[ "$version" =~ 5.[4-5] ]]; then
install_command="update_lists && ${install_command/5\.[4-5]-$extension/5-$extension=$release_version}" install_packages "php5-$extension=$release_version"
elif [[ "$version" =~ ${nightly_versions:?} ]]; then
pecl_install "$extension"
else
install_packages "php$version-$extension" || pecl_install "$extension"
fi fi
eval "$install_command" >/dev/null 2>&1 ||
(update_lists && eval "$install_command" >/dev/null 2>&1) || pecl_install "$extension"
add_extension_log "$extension" "Installed and enabled" add_extension_log "$extension" "Installed and enabled"
fi fi
sudo chmod 777 "$ini_file" sudo chmod 777 "$ini_file"
@ -198,15 +119,13 @@ add_pecl_extension() {
extension=$1 extension=$1
pecl_version=$2 pecl_version=$2
prefix=$3 prefix=$3
if [[ $pecl_version =~ .*(alpha|beta|rc|snapshot).* ]]; then if [[ $pecl_version =~ .*(alpha|beta|rc|snapshot|preview).* ]]; then
pecl_version=$(get_pecl_version "$extension" "$pecl_version") pecl_version=$(get_pecl_version "$extension" "$pecl_version")
fi fi
if ! check_extension "$extension" && [ -e "$ext_dir/$extension.so" ]; then enable_extension "$extension" "$prefix"
echo "$prefix=$ext_dir/$extension.so" >>"$pecl_file"
fi
ext_version=$(php -r "echo phpversion('$extension');") ext_version=$(php -r "echo phpversion('$extension');")
if [ "$ext_version" = "$pecl_version" ]; then if [ "$ext_version" = "$pecl_version" ]; then
add_log "$tick" "$extension" "Enabled" add_log "${tick:?}" "$extension" "Enabled"
else else
delete_extension "$extension" delete_extension "$extension"
pecl_install "$extension-$pecl_version" pecl_install "$extension-$pecl_version"
@ -214,15 +133,6 @@ add_pecl_extension() {
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 install extension from source # Function to install extension from source
add_extension_from_source() { add_extension_from_source() {
extension=$1 extension=$1
@ -233,121 +143,37 @@ add_extension_from_source() {
( (
add_devtools phpize add_devtools phpize
delete_extension "$extension" delete_extension "$extension"
curl -o /tmp/"$extension".tar.gz "${curl_opts[@]}" https://github.com/"$repo"/archive/"$release".tar.gz get -q -n "/tmp/$extension.tar.gz" "https://github.com/$repo/archive/$release.tar.gz"
tar xf /tmp/"$extension".tar.gz -C /tmp tar xf /tmp/"$extension".tar.gz -C /tmp
cd /tmp/"$extension-$release" || exit 1 cd /tmp/"$extension-$release" || exit 1
phpize && ./configure "$args" && make && sudo make install phpize && ./configure "$args" && make -j"$(nproc)" && sudo make install
enable_extension "$extension" "$prefix" enable_extension "$extension" "$prefix"
) >/dev/null 2>&1 ) >/dev/null 2>&1
add_extension_log "$extension-$release" "Installed and enabled" add_extension_log "$extension-$release" "Installed and enabled"
} }
# Function to configure composer
configure_composer() {
tool_path=$1
sudo ln -sf "$tool_path" "$tool_path.phar"
php -r "try {\$p=new Phar('$tool_path.phar', 0);exit(0);} catch(Exception \$e) {exit(1);}"
if [ $? -eq 1 ]; then
add_log "$cross" "composer" "Could not download composer"
exit 1;
fi
composer -q global config process-timeout 0
echo "/home/$USER/.composer/vendor/bin" >> "$GITHUB_PATH"
if [ -n "$COMPOSER_TOKEN" ]; then
composer -q global config github-oauth.github.com "$COMPOSER_TOKEN"
fi
}
# Function to extract tool version.
get_tool_version() {
tool=$1
param=$2
version_regex="[0-9]+((\.{1}[0-9]+)+)(\.{0})(-[a-zA-Z0-9]+){0,1}"
if [ "$tool" = "composer" ]; then
if [ "$param" != "snapshot" ]; then
grep -Ea "const\sVERSION" "$tool_path_dir/composer" | grep -Eo "$version_regex"
else
trunk=$(grep -Ea "const\sBRANCH_ALIAS_VERSION" "$tool_path_dir/composer" | grep -Eo "$version_regex")
commit=$(grep -Ea "const\sVERSION" "$tool_path_dir/composer" | grep -Eo "[a-zA-z0-9]+" | tail -n 1)
echo "$trunk+$commit"
fi
else
$tool "$param" 2>/dev/null | sed -Ee "s/[Cc]omposer(.)?$version_regex//g" | grep -Eo "$version_regex" | head -n 1
fi
}
# Function to setup a remote tool.
add_tool() {
url=$1
tool=$2
ver_param=$3
tool_path="$tool_path_dir/$tool"
if [ ! -e "$tool_path" ]; then
rm -rf "$tool_path"
fi
if [ "$tool" = "composer" ]; then
IFS="," read -r -a urls <<< "$url"
status_code=$(sudo curl -f -w "%{http_code}" -o "$tool_path" "${curl_opts[@]}" "${urls[0]}") ||
status_code=$(sudo curl -w "%{http_code}" -o "$tool_path" "${curl_opts[@]}" "${urls[1]}")
else
status_code=$(sudo curl -w "%{http_code}" -o "$tool_path" "${curl_opts[@]}" "$url")
fi
if [ "$status_code" = "200" ]; then
sudo chmod a+x "$tool_path"
if [ "$tool" = "composer" ]; then
configure_composer "$tool_path"
elif [ "$tool" = "cs2pr" ]; then
sudo sed -i 's/\r$//; s/exit(9)/exit(0)/' "$tool_path"
elif [ "$tool" = "phan" ]; then
add_extension fileinfo "$apt_install php$version-fileinfo" extension >/dev/null 2>&1
add_extension ast "$apt_install php-ast" extension >/dev/null 2>&1
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
elif [ "$tool" = "wp-cli" ]; then
sudo cp -p "$tool_path" "$tool_path_dir"/wp
fi
tool_version=$(get_tool_version "$tool" "$ver_param")
add_log "$tick" "$tool" "Added $tool $tool_version"
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 &&
json=$(grep "$prefix$tool" /home/"$USER"/.composer/composer.json) &&
tool_version=$(get_tool_version 'echo' "$json") &&
add_log "$tick" "$tool" "Added $tool $tool_version"
) || add_log "$cross" "$tool" "Could not setup $tool"
}
# Function to setup phpize and php-config. # Function to setup phpize and php-config.
add_devtools() { add_devtools() {
tool=$1 tool=$1
if ! [ -e "/usr/bin/phpize$version" ] || ! [ -e "/usr/bin/php-config$version" ]; then if ! command -v "$tool$version" >/dev/null; then
update_lists && $apt_install php"$version"-dev php"$version"-xml >/dev/null 2>&1 install_packages "php$version-dev" "php$version-xml"
fi fi
sudo update-alternatives --set php-config /usr/bin/php-config"$version" >/dev/null 2>&1 sudo update-alternatives --set php-config /usr/bin/php-config"$version" >/dev/null 2>&1
sudo update-alternatives --set phpize /usr/bin/phpize"$version" >/dev/null 2>&1 sudo update-alternatives --set phpize /usr/bin/phpize"$version" >/dev/null 2>&1
if command -v pecl >/dev/null; then
configure_pecl >/dev/null 2>&1 configure_pecl >/dev/null 2>&1
add_log "$tick" "$tool" "Added $tool $semver" fi
add_log "${tick:?}" "$tool" "Added $tool $semver"
} }
# Function to setup the nightly build from shivammathur/php-builder # Function to setup the nightly build from shivammathur/php-builder
setup_nightly() { setup_nightly() {
curl "${curl_opts[@]}" "$github"/php-builder/releases/latest/download/install.sh | bash -s "$runner" "$version" run_script "php-builder" "$runner" "$version"
} }
# Function to setup PHP 5.3, PHP 5.4 and PHP 5.5. # Function to setup PHP 5.3, PHP 5.4 and PHP 5.5.
setup_old_versions() { setup_old_versions() {
curl "${curl_opts[@]}" "$github"/php5-ubuntu/releases/latest/download/install.sh | bash -s "$version" run_script "php5-ubuntu" "$version"
configure_pecl configure_pecl
release_version=$(php -v | head -n 1 | cut -d' ' -f 2) release_version=$(php -v | head -n 1 | cut -d' ' -f 2)
} }
@ -355,30 +181,23 @@ setup_old_versions() {
# Function to add PECL. # Function to add PECL.
add_pecl() { add_pecl() {
add_devtools phpize >/dev/null 2>&1 add_devtools phpize >/dev/null 2>&1
if [ ! -e /usr/bin/pecl ]; then if ! command -v pecl >/dev/null; then
$apt_install php-pear >/dev/null 2>&1 || update_lists && $apt_install php-pear >/dev/null 2>&1 install_packages php-pear
fi fi
configure_pecl >/dev/null 2>&1 configure_pecl >/dev/null 2>&1
pecl_version=$(get_tool_version "pecl" "version") pecl_version=$(get_tool_version "pecl" "version")
add_log "$tick" "PECL" "Added PECL $pecl_version" add_log "${tick:?}" "PECL" "Added PECL $pecl_version"
} }
# Function to switch versions of PHP binaries. # Function to switch versions of PHP binaries.
switch_version() { switch_version() {
for tool in pear pecl php phar phar.phar php-cgi php-config phpize phpdbg; do for tool in pear pecl php phar phar.phar php-cgi php-config phpize phpdbg; do
if [ -e "/usr/bin/$tool$version" ]; then if [ -e "/usr/bin/$tool$version" ]; then
sudo update-alternatives --set $tool /usr/bin/"$tool$version" sudo update-alternatives --set $tool /usr/bin/"$tool$version" &
to_wait+=( $! )
fi fi
done done
} wait "${to_wait[@]}"
# Function to get PHP version in semver format.
php_semver() {
if ! [[ "$version" =~ $nightly_versions ]]; 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
} }
# Function to install packaged PHP # Function to install packaged PHP
@ -388,15 +207,14 @@ add_packaged_php() {
IFS=' ' read -r -a packages <<<"$(echo "cli curl mbstring xml intl" | sed "s/[^ ]*/php$version-&/g")" IFS=' ' read -r -a packages <<<"$(echo "cli curl mbstring xml intl" | sed "s/[^ ]*/php$version-&/g")"
$apt_install "${packages[@]}" $apt_install "${packages[@]}"
else else
curl "${curl_opts[@]}" "$github"/php-ubuntu/releases/latest/download/install.sh | bash -s "$version" run_script "php-ubuntu" "$version"
fi fi
} }
# Function to update PHP. # Function to update PHP.
update_php() { update_php() {
initial_version=$(php_semver) initial_version=$(php_semver)
use_package_cache="false" use_package_cache="false" add_packaged_php
add_packaged_php
updated_version=$(php_semver) updated_version=$(php_semver)
if [ "$updated_version" != "$initial_version" ]; then if [ "$updated_version" != "$initial_version" ]; then
status="Updated to" status="Updated to"
@ -407,9 +225,9 @@ update_php() {
# Function to install PHP. # Function to install PHP.
add_php() { add_php() {
if [[ "$version" =~ $nightly_versions ]]; then if [[ "$version" =~ ${nightly_versions:?} ]]; then
setup_nightly setup_nightly
elif [[ "$version" =~ $old_versions ]]; then elif [[ "$version" =~ ${old_versions:?} ]]; then
setup_old_versions setup_old_versions
else else
add_packaged_php add_packaged_php
@ -417,47 +235,21 @@ add_php() {
status="Installed" status="Installed"
} }
# Variables # Function to Setup PHP
tick="✓" setup_php() {
cross="✗"
pecl_config="false"
version=$1
dist=$2
fail_fast=$3
nightly_versions="8.[0-1]"
old_versions="5.[3-5]"
debconf_fix="DEBIAN_FRONTEND=noninteractive"
github="https://github.com/shivammathur"
apt_install="sudo $debconf_fix apt-get install -y"
apt_remove="sudo $debconf_fix apt-get remove -y"
tool_path_dir="/usr/local/bin"
curl_opts=(-sL)
existing_version=$(php-config --version 2>/dev/null | cut -c 1-3)
read_env
if [ "$runner" = "self-hosted" ]; then
if [[ "$version" =~ $old_versions ]]; then
add_log "$cross" "PHP" "PHP $version is not supported on self-hosted runner"
exit 1
else
self_hosted_setup >/dev/null 2>&1
fi
fi
# Setup PHP
step_log "Setup PHP" step_log "Setup PHP"
sudo mkdir -p /var/run /run/php sudo mkdir -m 777 -p /var/run /run/php
if [ "$existing_version" != "$version" ]; then if [ "$(php-config --version 2>/dev/null | cut -c 1-3)" != "$version" ]; then
if [ ! -e "/usr/bin/php$version" ]; then if [ ! -e "/usr/bin/php$version" ]; then
add_php >/dev/null 2>&1 add_php >/dev/null 2>&1
else else
if [ "$update" = "true" ]; then if [ "${update:?}" = "true" ]; then
update_php >/dev/null 2>&1 update_php >/dev/null 2>&1
else else
status="Switched to" status="Switched to"
fi fi
fi fi
if ! [[ "$version" =~ $old_versions ]]; then if ! [[ "$version" =~ ${old_versions:?}|${nightly_versions:?} ]]; then
switch_version >/dev/null 2>&1 switch_version >/dev/null 2>&1
fi fi
else else
@ -465,12 +257,8 @@ else
update_php >/dev/null 2>&1 update_php >/dev/null 2>&1
else else
status="Found" status="Found"
if [[ "$version" =~ $nightly_versions ]]; then
switch_version >/dev/null 2>&1
fi fi
fi fi
fi
semver=$(php_semver) semver=$(php_semver)
ext_dir=$(php -i | grep "extension_dir => /" | sed -e "s|.*=> s*||") ext_dir=$(php -i | grep "extension_dir => /" | sed -e "s|.*=> s*||")
scan_dir=$(php --ini | grep additional | sed -e "s|.*: s*||") scan_dir=$(php --ini | grep additional | sed -e "s|.*: s*||")
@ -478,6 +266,21 @@ ini_file=$(php --ini | grep "Loaded Configuration" | sed -e "s|.*:s*||" | sed "s
pecl_file="$scan_dir"/99-pecl.ini pecl_file="$scan_dir"/99-pecl.ini
echo '' | sudo tee "$pecl_file" >/dev/null 2>&1 echo '' | sudo tee "$pecl_file" >/dev/null 2>&1
sudo rm -rf /usr/local/bin/phpunit >/dev/null 2>&1 sudo rm -rf /usr/local/bin/phpunit >/dev/null 2>&1
sudo chmod 777 "$ini_file" "$pecl_file" "$tool_path_dir" sudo chmod 777 "$ini_file" "$pecl_file" "${tool_path_dir:?}"
sudo cp "$dist"/../src/configs/*.json "$RUNNER_TOOL_CACHE/" sudo cp "$dist"/../src/configs/*.json "$RUNNER_TOOL_CACHE/"
add_log "$tick" "PHP" "$status PHP $semver" add_log "${tick:?}" "PHP" "$status PHP $semver"
}
# Variables
version=$1
dist=$2
debconf_fix="DEBIAN_FRONTEND=noninteractive"
apt_install="sudo $debconf_fix apt-fast install -y"
apt_remove="sudo $debconf_fix apt-fast remove -y"
# shellcheck source=.
. "${dist}"/../src/scripts/common.sh
. /etc/lsb-release
read_env
self_hosted_setup
setup_php

View File

@ -6,7 +6,7 @@ Function Add-Blackfire() {
} }
$agent_version = (Invoke-RestMethod https://blackfire.io/api/v1/releases).agent $agent_version = (Invoke-RestMethod https://blackfire.io/api/v1/releases).agent
$url = "https://packages.blackfire.io/binaries/blackfire-agent/${agent_version}/blackfire-agent-windows_${arch_name}.zip" $url = "https://packages.blackfire.io/binaries/blackfire-agent/${agent_version}/blackfire-agent-windows_${arch_name}.zip"
Invoke-WebRequest -UseBasicParsing -Uri $url -OutFile $bin_dir\blackfire.zip >$null 2>&1 Invoke-WebRequest -Uri $url -OutFile $bin_dir\blackfire.zip >$null 2>&1
Expand-Archive -Path $bin_dir\blackfire.zip -DestinationPath $bin_dir -Force >$null 2>&1 Expand-Archive -Path $bin_dir\blackfire.zip -DestinationPath $bin_dir -Force >$null 2>&1
Add-ToProfile $current_profile 'blackfire' "New-Alias blackfire $bin_dir\blackfire.exe" Add-ToProfile $current_profile 'blackfire' "New-Alias blackfire $bin_dir\blackfire.exe"
Add-ToProfile $current_profile 'blackfire-agent' "New-Alias blackfire-agent $bin_dir\blackfire-agent.exe" Add-ToProfile $current_profile 'blackfire-agent' "New-Alias blackfire-agent $bin_dir\blackfire-agent.exe"

View File

@ -1,6 +1,6 @@
add_blackfire_linux() { add_blackfire_linux() {
sudo mkdir -p /var/run/blackfire sudo mkdir -p /var/run/blackfire
sudo curl "${curl_opts[@]:?}" https://packages.blackfire.io/gpg.key | sudo apt-key add - get -s -n "" https://packages.blackfire.io/gpg.key | sudo apt-key add -
echo "deb http://packages.blackfire.io/debian any main" | sudo tee /etc/apt/sources.list.d/blackfire.list echo "deb http://packages.blackfire.io/debian any main" | sudo tee /etc/apt/sources.list.d/blackfire.list
sudo "${debconf_fix:?}" apt-get update sudo "${debconf_fix:?}" apt-get update
${apt_install:?} blackfire-agent ${apt_install:?} blackfire-agent

View File

@ -1,13 +1,12 @@
add_bazel() { add_bazel() {
if [ ! "$(command -v bazel)" ]; then if ! command -v bazel; then
os=$(uname -s) if [ "$(uname -s)" = "Linux" ]; then
if [ "$os" = "Linux" ]; then
${apt_install:?} curl gnupg ${apt_install:?} curl gnupg
curl "${curl_opts[@]:?}" https://bazel.build/bazel-release.pub.gpg | sudo apt-key add - get -s -n "" https://bazel.build/bazel-release.pub.gpg | sudo apt-key add -
echo "deb [arch=amd64] https://storage.googleapis.com/bazel-apt stable jdk1.8" | sudo tee /etc/apt/sources.list.d/bazel.list echo "deb [arch=amd64] https://storage.googleapis.com/bazel-apt stable jdk1.8" | sudo tee /etc/apt/sources.list.d/bazel.list
sudo "${debconf_fix:?}" apt-get update -y sudo "${debconf_fix:?}" apt-get update -y
${apt_install:?} bazel ${apt_install:?} bazel
elif [ "$os" = "Darwin" ]; then else
brew install bazel brew install bazel
fi fi
fi fi
@ -15,13 +14,13 @@ add_bazel() {
get_grpc_tag() { get_grpc_tag() {
if [ "$grpc_tag" = "latest" ]; then if [ "$grpc_tag" = "latest" ]; then
grpc_tag=$(curl "${curl_opts[@]:?}" https://grpc.io/release) grpc_tag=$(get -s -n "" https://grpc.io/release)
else else
status_code=$(sudo curl -s -w "%{http_code}" -o /tmp/grpc.tmp "${curl_opts[@]:?}" "https://github.com/grpc/grpc/releases/tag/v$grpc_tag") status_code=$(get -v -n /tmp/grpc.tmp "https://github.com/grpc/grpc/releases/tag/v$grpc_tag")
if [ "$status_code" = "200" ]; then if [ "$status_code" = "200" ]; then
grpc_tag="v$grpc_tag" grpc_tag="v$grpc_tag"
else else
grpc_tag=$(curl "${curl_opts[@]:?}" https://grpc.io/release) grpc_tag=$(get -s -n "" https://grpc.io/release)
fi fi
fi fi
} }
@ -30,11 +29,10 @@ add_grpc_php_plugin() {
grpc_tag=$1 grpc_tag=$1
get_grpc_tag get_grpc_tag
( (
curl "${curl_opts[@]:?}" "https://github.com/grpc/grpc/archive/$grpc_tag.tar.gz" | tar -xz -C /tmp get -s -n "" "https://github.com/grpc/grpc/archive/$grpc_tag.tar.gz" | tar -xz -C /tmp
cd "/tmp/grpc-${grpc_tag:1}" || exit cd "/tmp/grpc-${grpc_tag:1}" || exit
add_bazel add_bazel
echo "os: $os" [ "$(uname -s)" = "Darwin" ] && sudo xcode-select -s /Applications/Xcode_11.7.app
echo "release: $DISTRIB_RELEASE"
if [ "$DISTRIB_RELEASE" = "16.04" ]; then if [ "$DISTRIB_RELEASE" = "16.04" ]; then
CC="$(command -v gcc)" CXX="$(command -v g++)" ./tools/bazel build src/compiler:grpc_php_plugin CC="$(command -v gcc)" CXX="$(command -v g++)" ./tools/bazel build src/compiler:grpc_php_plugin
else else

View File

@ -27,7 +27,7 @@ Function Add-Protoc() {
$arch_num = '32' $arch_num = '32'
} }
$url = "https://github.com/protocolbuffers/protobuf/releases/download/$protobuf_tag/protoc-$($protobuf_tag -replace 'v', '')-win$arch_num.zip" $url = "https://github.com/protocolbuffers/protobuf/releases/download/$protobuf_tag/protoc-$($protobuf_tag -replace 'v', '')-win$arch_num.zip"
Invoke-WebRequest -UseBasicParsing -Uri $url -OutFile $bin_dir\protoc.zip >$null 2>&1 Invoke-WebRequest -Uri $url -OutFile $bin_dir\protoc.zip >$null 2>&1
Expand-Archive -Path $bin_dir\protoc.zip -DestinationPath $bin_dir\protoc -Force >$null 2>&1 Expand-Archive -Path $bin_dir\protoc.zip -DestinationPath $bin_dir\protoc -Force >$null 2>&1
Move-Item -Path $bin_dir\protoc\bin\protoc.exe -Destination $bin_dir\protoc.exe Move-Item -Path $bin_dir\protoc\bin\protoc.exe -Destination $bin_dir\protoc.exe
Add-ToProfile $current_profile 'protoc' "New-Alias protoc $bin_dir\protoc.exe" Add-ToProfile $current_profile 'protoc' "New-Alias protoc $bin_dir\protoc.exe"

View File

@ -1,12 +1,12 @@
get_protobuf_tag() { get_protobuf_tag() {
if [ "$protobuf_tag" = "latest" ]; then if [ "$protobuf_tag" = "latest" ]; then
protobuf_tag=$(curl "${curl_opts[@]:?}" https://github.com/protocolbuffers/protobuf/releases/latest 2<&1 | grep -m 1 -Eo "(v[0-9]+\.[0-9]+\.[0-9]+)" | head -n 1) protobuf_tag=$(get -s -n "" https://github.com/protocolbuffers/protobuf/releases/latest 2<&1 | grep -m 1 -Eo "(v[0-9]+\.[0-9]+\.[0-9]+)" | head -n 1)
else else
status_code=$(sudo curl -s -w "%{http_code}" -o /tmp/protobuf.tmp "${curl_opts[@]:?}" "https://github.com/protocolbuffers/protobuf/releases/tag/v$protobuf_tag") status_code=$(get -v -n /tmp/protobuf.tmp "https://github.com/protocolbuffers/protobuf/releases/tag/v$protobuf_tag")
if [ "$status_code" = "200" ]; then if [ "$status_code" = "200" ]; then
protobuf_tag="v$protobuf_tag" protobuf_tag="v$protobuf_tag"
else else
protobuf_tag=$(curl "${curl_opts[@]:?}" https://github.com/protocolbuffers/protobuf/releases/latest 2<&1 | grep -m 1 -Eo "(v[0-9]+\.[0-9]+\.[0-9]+)" | head -n 1) protobuf_tag=$(get -s -n "" https://github.com/protocolbuffers/protobuf/releases/latest 2<&1 | grep -m 1 -Eo "(v[0-9]+\.[0-9]+\.[0-9]+)" | head -n 1)
fi fi
fi fi
} }
@ -17,7 +17,7 @@ add_protoc() {
( (
platform='linux' platform='linux'
[ "$(uname -s)" = "Darwin" ] && platform='osx' [ "$(uname -s)" = "Darwin" ] && platform='osx'
curl -o /tmp/protobuf.zip "${curl_opts[@]:?}" "https://github.com/protocolbuffers/protobuf/releases/download/$protobuf_tag/protoc-${protobuf_tag:1}-$platform-x86_64.zip" get -q -n /tmp/protobuf.zip "https://github.com/protocolbuffers/protobuf/releases/download/$protobuf_tag/protoc-${protobuf_tag:1}-$platform-x86_64.zip"
sudo unzip /tmp/protobuf.zip -d /usr/local/ sudo unzip /tmp/protobuf.zip -d /usr/local/
sudo chmod 777 /usr/local/bin/protoc -R /usr/local/include/google sudo chmod 777 /usr/local/bin/protoc -R /usr/local/include/google
) >/dev/null 2>&1 ) >/dev/null 2>&1

View File

@ -79,7 +79,7 @@ Function Add-Printf {
if(Test-Path "C:\msys64\usr\bin\printf.exe") { if(Test-Path "C:\msys64\usr\bin\printf.exe") {
New-Item -Path $bin_dir\printf.exe -ItemType SymbolicLink -Value C:\msys64\usr\bin\printf.exe New-Item -Path $bin_dir\printf.exe -ItemType SymbolicLink -Value C:\msys64\usr\bin\printf.exe
} else { } else {
Invoke-WebRequest -UseBasicParsing -Uri "https://github.com/shivammathur/printf/releases/latest/download/printf-x64.zip" -OutFile "$bin_dir\printf.zip" Invoke-WebRequest -Uri "$github/shivammathur/printf/releases/latest/download/printf-x64.zip" -OutFile "$bin_dir\printf.zip"
Expand-Archive -Path $bin_dir\printf.zip -DestinationPath $bin_dir -Force Expand-Archive -Path $bin_dir\printf.zip -DestinationPath $bin_dir -Force
} }
} else { } else {
@ -96,16 +96,24 @@ Function Get-CleanPSProfile {
Add-ToProfile $profile $current_profile.replace('\', '\\') ". $current_profile" Add-ToProfile $profile $current_profile.replace('\', '\\') ". $current_profile"
} }
# Function to install PhpManager. # Function to install a powershell package from GitHub.
Function Install-PhpManager() { Function Install-PSPackage() {
$module_path = "$bin_dir\PhpManager\PhpManager.psm1" param(
[Parameter(Position = 0, Mandatory = $true)]
$package,
[Parameter(Position = 1, Mandatory = $true)]
$psm1_path,
[Parameter(Position = 2, Mandatory = $true)]
$url
)
$module_path = "$bin_dir\$psm1_path.psm1"
if(-not (Test-Path $module_path -PathType Leaf)) { if(-not (Test-Path $module_path -PathType Leaf)) {
$zip_file = "$bin_dir\PhpManager.zip" $zip_file = "$bin_dir\$package.zip"
Invoke-WebRequest -UseBasicParsing -Uri 'https://github.com/mlocati/powershell-phpmanager/releases/latest/download/PhpManager.zip' -OutFile $zip_file Invoke-WebRequest -Uri $url -OutFile $zip_file
Expand-Archive -Path $zip_file -DestinationPath $bin_dir -Force Expand-Archive -Path $zip_file -DestinationPath $bin_dir -Force
} }
Import-Module $module_path Import-Module $module_path
Add-ToProfile $current_profile 'powershell-phpmanager' "Import-Module $module_path" Add-ToProfile $current_profile "$package-search" "Import-Module $module_path"
} }
# Function to add PHP extensions. # Function to add PHP extensions.
@ -197,7 +205,7 @@ Function Edit-ComposerConfig() {
exit 1; exit 1;
} }
composer -q global config process-timeout 0 composer -q global config process-timeout 0
Write-Output "$env:APPDATA\Composer\vendor\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 Write-Output $composer_bin | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8
if (Test-Path env:COMPOSER_TOKEN) { if (Test-Path env:COMPOSER_TOKEN) {
composer -q global config github-oauth.github.com $env:COMPOSER_TOKEN composer -q global config github-oauth.github.com $env:COMPOSER_TOKEN
} }
@ -242,11 +250,21 @@ Function Add-Tool() {
} }
if($url.Count -gt 1) { $url = $url[0] } if($url.Count -gt 1) { $url = $url[0] }
if ($tool -eq "symfony") { if ($tool -eq "symfony") {
Invoke-WebRequest -UseBasicParsing -Uri $url -OutFile $bin_dir\$tool.exe Invoke-WebRequest -Uri $url -OutFile $bin_dir\$tool.exe
Add-ToProfile $current_profile $tool "New-Alias $tool $bin_dir\$tool.exe" >$null 2>&1 Add-ToProfile $current_profile $tool "New-Alias $tool $bin_dir\$tool.exe" >$null 2>&1
} else { } else {
try { try {
Invoke-WebRequest -UseBasicParsing -Uri $url -OutFile $bin_dir\$tool Invoke-WebRequest -Uri $url -OutFile $bin_dir\$tool
} catch {
if($url -match '.*github.com.*releases.*latest.*') {
try {
$url = $url.replace("releases/latest/download", "releases/download/" + ([regex]::match((Invoke-WebRequest -Uri ($url.split('/release')[0] + "/releases")).Content, "([0-9]+\.[0-9]+\.[0-9]+)/" + ($url.Substring($url.LastIndexOf("/") + 1))).Groups[0].Value).split('/')[0])
Invoke-WebRequest -Uri $url -OutFile $bin_dir\$tool
} catch { }
}
}
}
if (((Get-ChildItem -Path $bin_dir/* | Where-Object Name -Match "^$tool(.exe|.phar)*$").Count -gt 0)) {
$bat_content = @() $bat_content = @()
$bat_content += "@ECHO off" $bat_content += "@ECHO off"
$bat_content += "setlocal DISABLEDELAYEDEXPANSION" $bat_content += "setlocal DISABLEDELAYEDEXPANSION"
@ -254,8 +272,6 @@ Function Add-Tool() {
$bat_content += "php %BIN_TARGET% %*" $bat_content += "php %BIN_TARGET% %*"
Set-Content -Path $bin_dir\$tool.bat -Value $bat_content Set-Content -Path $bin_dir\$tool.bat -Value $bat_content
Add-ToProfile $current_profile $tool "New-Alias $tool $bin_dir\$tool.bat" >$null 2>&1 Add-ToProfile $current_profile $tool "New-Alias $tool $bin_dir\$tool.bat" >$null 2>&1
} catch { }
}
if($tool -eq "phan") { if($tool -eq "phan") {
Add-Extension fileinfo >$null 2>&1 Add-Extension fileinfo >$null 2>&1
Add-Extension ast >$null 2>&1 Add-Extension ast >$null 2>&1
@ -268,7 +284,6 @@ Function Add-Tool() {
} elseif($tool -eq "wp-cli") { } elseif($tool -eq "wp-cli") {
Copy-Item $bin_dir\wp-cli.bat -Destination $bin_dir\wp.bat Copy-Item $bin_dir\wp-cli.bat -Destination $bin_dir\wp.bat
} }
if (((Get-ChildItem -Path $bin_dir/* | Where-Object Name -Match "^$tool(.exe|.phar)*$").Count -gt 0)) {
$tool_version = Get-ToolVersion $tool $ver_param $tool_version = Get-ToolVersion $tool $ver_param
Add-Log $tick $tool "Added $tool $tool_version" Add-Log $tick $tool "Added $tool $tool_version"
} else { } else {
@ -297,6 +312,9 @@ Function Add-Composertool() {
) )
composer global require $prefix$release 2>&1 | out-null composer global require $prefix$release 2>&1 | out-null
$json = findstr $prefix$tool $env:APPDATA\Composer\composer.json $json = findstr $prefix$tool $env:APPDATA\Composer\composer.json
if(Test-Path $composer_bin\composer) {
Copy-Item -Path "$bin_dir\composer" -Destination "$composer_bin\composer" -Force
}
if($json) { if($json) {
$tool_version = Get-ToolVersion "Write-Output" "$json" $tool_version = Get-ToolVersion "Write-Output" "$json"
Add-Log $tick $tool "Added $tool $tool_version" Add-Log $tick $tool "Added $tool $tool_version"
@ -316,10 +334,14 @@ $cross = ([char]10007)
$php_dir = 'C:\tools\php' $php_dir = 'C:\tools\php'
$ext_dir = "$php_dir\ext" $ext_dir = "$php_dir\ext"
$bin_dir = $php_dir $bin_dir = $php_dir
$bintray = 'https://dl.bintray.com/shivammathur/php'
$github = 'https://github.com'
$composer_bin = "$env:APPDATA\Composer\vendor\bin"
$current_profile = "$env:TEMP\setup-php.ps1" $current_profile = "$env:TEMP\setup-php.ps1"
$ProgressPreference = 'SilentlyContinue' $ProgressPreference = 'SilentlyContinue'
$nightly_version = '8.[0-9]' $nightly_version = '8.[0-9]'
$cert_source='CurrentUser' $cert_source='CurrentUser'
$enable_extensions = ('openssl', 'curl', 'mbstring')
$arch = 'x64' $arch = 'x64'
if(-not([Environment]::Is64BitOperatingSystem) -or $version -lt '7.0') { if(-not([Environment]::Is64BitOperatingSystem) -or $version -lt '7.0') {
@ -358,7 +380,7 @@ if($env:RUNNER -eq 'self-hosted') {
Add-Printf >$null 2>&1 Add-Printf >$null 2>&1
Step-Log "Setup PhpManager" Step-Log "Setup PhpManager"
Install-PhpManager >$null 2>&1 Install-PSPackage PhpManager PhpManager\PhpManager "$github/mlocati/powershell-phpmanager/releases/latest/download/PhpManager.zip" >$null 2>&1
Add-Log $tick "PhpManager" "Installed" Add-Log $tick "PhpManager" "Installed"
Step-Log "Setup PHP" Step-Log "Setup PHP"
@ -371,11 +393,11 @@ if (Test-Path -LiteralPath $php_dir -PathType Container) {
$status = "Installed" $status = "Installed"
if ($null -eq $installed -or -not("$($installed.Version).".StartsWith(($version -replace '^(\d+(\.\d+)*).*', '$1.'))) -or $ts -ne $installed.ThreadSafe) { if ($null -eq $installed -or -not("$($installed.Version).".StartsWith(($version -replace '^(\d+(\.\d+)*).*', '$1.'))) -or $ts -ne $installed.ThreadSafe) {
if ($version -lt '7.0' -and (Get-InstalledModule).Name -notcontains 'VcRedist') { if ($version -lt '7.0' -and (Get-InstalledModule).Name -notcontains 'VcRedist') {
Install-Module -Name VcRedist -Force Install-PSPackage VcRedist VcRedist-main\VcRedist\VcRedist "$github/aaronparker/VcRedist/archive/main.zip" >$null 2>&1
} }
if ($version -match $nightly_version) { if ($version -match $nightly_version) {
Invoke-WebRequest -UseBasicParsing -Uri https://dl.bintray.com/shivammathur/php/Install-PhpNightly.ps1 -OutFile $php_dir\Install-PhpNightly.ps1 > $null 2>&1 Invoke-WebRequest -Uri $bintray/Get-PhpNightly.ps1 -OutFile $php_dir\Get-PhpNightly.ps1 > $null 2>&1
& $php_dir\Install-PhpNightly.ps1 -Architecture $arch -ThreadSafe $ts -Path $php_dir -Version $version > $null 2>&1 & $php_dir\Get-PhpNightly.ps1 -Architecture $arch -ThreadSafe $ts -Path $php_dir -Version $version > $null 2>&1
} else { } else {
Install-Php -Version $version -Architecture $arch -ThreadSafe $ts -InstallVC -Path $php_dir -TimeZone UTC -InitialPhpIni Production -Force > $null 2>&1 Install-Php -Version $version -Architecture $arch -ThreadSafe $ts -InstallVC -Path $php_dir -TimeZone UTC -InitialPhpIni Production -Force > $null 2>&1
} }
@ -389,16 +411,14 @@ if ($null -eq $installed -or -not("$($installed.Version).".StartsWith(($version
} }
$installed = Get-Php -Path $php_dir $installed = Get-Php -Path $php_dir
Set-PhpIniKey -Key 'date.timezone' -Value 'UTC' -Path $php_dir ('date.timezone=UTC', 'memory_limit=-1') | foreach { $p=$_.split('='); Set-PhpIniKey -Key $p[0] -Value $p[1] -Path $php_dir }
Set-PhpIniKey -Key 'memory_limit' -Value '-1' -Path $php_dir
if($version -lt "5.5") { if($version -lt "5.5") {
ForEach($lib in "libeay32.dll", "ssleay32.dll") { ('libeay32.dll', 'ssleay32.dll') | ForEach { Invoke-WebRequest -Uri $bintray/$_ -OutFile $php_dir\$_ >$null 2>&1 }
Invoke-WebRequest -UseBasicParsing -Uri https://dl.bintray.com/shivammathur/php/$lib -OutFile $php_dir\$lib >$null 2>&1
}
Enable-PhpExtension -Extension openssl, curl, mbstring -Path $php_dir
} else { } else {
Enable-PhpExtension -Extension openssl, curl, opcache, mbstring -Path $php_dir $enable_extensions += ('opcache')
} }
Enable-PhpExtension -Extension $enable_extensions -Path $php_dir
Update-PhpCAInfo -Path $php_dir -Source $cert_source Update-PhpCAInfo -Path $php_dir -Source $cert_source
Copy-Item -Path $dist\..\src\configs\*.json -Destination $env:RUNNER_TOOL_CACHE Copy-Item -Path $dist\..\src\configs\*.json -Destination $env:RUNNER_TOOL_CACHE
New-Item -ItemType Directory -Path $composer_bin -Force 2>&1 | Out-Null
Add-Log $tick "PHP" "$status PHP $($installed.FullVersion)" Add-Log $tick "PHP" "$status PHP $($installed.FullVersion)"

View File

@ -203,6 +203,31 @@ export async function getPharUrl(
} }
} }
/**
* Function to get blackfire player url for a PHP version.
*
* @param version
* @param php_version
*/
export async function getBlackfirePlayerUrl(
version: string,
php_version: string
): Promise<string> {
switch (true) {
case /5\.[5-6]|7\.0/.test(php_version) && version == 'latest':
version = '1.9.3';
break;
default:
break;
}
return await getPharUrl(
'https://get.blackfire.io',
'blackfire-player',
'v',
version
);
}
/** /**
* Function to get the Deployer url * Function to get the Deployer url
* *
@ -280,15 +305,19 @@ export async function getWpCliUrl(version: string): Promise<string> {
*/ */
export async function addComposer(tools_list: string[]): Promise<string[]> { export async function addComposer(tools_list: string[]): Promise<string[]> {
const regex_any = /^composer($|:.*)/; const regex_any = /^composer($|:.*)/;
const regex_valid = /^composer:?($|preview$|snapshot$|v?[1-2]$)/; const regex_valid = /^composer:?($|preview$|snapshot$|v?[1-2]$|v?\d+\.\d+\.\d+[\w-]*$)/;
const regex_composer1_tools = /hirak|prestissimo|narrowspark|composer-prefetcher/;
const matches: string[] = tools_list.filter(tool => regex_valid.test(tool)); const matches: string[] = tools_list.filter(tool => regex_valid.test(tool));
let composer = 'composer'; let composer = 'composer';
tools_list = tools_list.filter(tool => !regex_any.test(tool)); tools_list = tools_list.filter(tool => !regex_any.test(tool));
switch (matches[0]) { switch (true) {
case undefined: case regex_composer1_tools.test(tools_list.join(' ')):
composer = 'composer:1';
break;
case matches[0] == undefined:
break; break;
default: default:
composer = matches[matches.length - 1].replace(/v([1-2])/, '$1'); composer = matches[matches.length - 1].replace(/v(\d\S*)/, '$1');
break; break;
} }
tools_list.unshift(composer); tools_list.unshift(composer);
@ -301,21 +330,20 @@ export async function addComposer(tools_list: string[]): Promise<string[]> {
* @param version * @param version
*/ */
export async function getComposerUrl(version: string): Promise<string> { export async function getComposerUrl(version: string): Promise<string> {
const cache_url = let cache_url = `https://github.com/shivammathur/composer-cache/releases/latest/download/composer-${version.replace(
'https://github.com/shivammathur/composer-cache/releases/latest/download/composer-' + 'latest',
version.replace('latest', 'stable') + 'stable'
'.phar,'; )}.phar`;
switch (version) { switch (true) {
case 'snapshot': case /^snapshot$/.test(version):
return cache_url + 'https://getcomposer.org/composer.phar'; return `${cache_url},https://getcomposer.org/composer.phar`;
case 'preview': case /^preview$|^[1-2]$/.test(version):
case '1': return `${cache_url},https://getcomposer.org/composer-${version}.phar`;
case '2': case /^\d+\.\d+\.\d+[\w-]*$/.test(version):
return ( cache_url = `https://github.com/composer/composer/releases/download/${version}/composer.phar`;
cache_url + 'https://getcomposer.org/composer-' + version + '.phar' return `${cache_url},https://getcomposer.org/composer-${version}.phar`;
);
default: default:
return cache_url + 'https://getcomposer.org/composer-stable.phar'; return `${cache_url},https://getcomposer.org/composer-stable.phar`;
} }
} }
@ -450,7 +478,7 @@ export async function addTools(
script += await addPackage(tool, release, tool + '/', os_version); script += await addPackage(tool, release, tool + '/', os_version);
break; break;
case 'blackfire-player': case 'blackfire-player':
url = await getPharUrl('https://get.blackfire.io', tool, 'v', version); url = await getBlackfirePlayerUrl(version, php_version);
script += await addArchive(tool, url, os_version, '"-V"'); script += await addArchive(tool, url, os_version, '"-V"');
break; break;
case 'codeception': case 'codeception':