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

View File

@ -30,7 +30,7 @@ This PR [briefly explain what it does]
> In case this PR edits any scripts:
- [ ] I have checked the edited scripts for syntax.
- [ ] I have tested the changes in an integration test (If yes, provide workflow 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.

4
.github/SECURITY.md vendored
View File

@ -6,8 +6,8 @@ The following versions of this project are supported for security updates.
| Version | Supported |
| ------- | ------------------ |
| 1.9.x | :white_check_mark: |
| 2.6.x | :white_check_mark: |
| 1.10.x | :white_check_mark: |
| 2.8.x | :white_check_mark: |
## 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
- name: Setup cache environment
id: extcache
id: cache-env
uses: shivammathur/cache-extensions@develop
with:
php-version: ${{ matrix.php-versions }}
@ -44,9 +44,9 @@ jobs:
- name: Cache extensions
uses: actions/cache@v2
with:
path: ${{ steps.extcache.outputs.dir }}
key: ${{ steps.extcache.outputs.key }}
restore-keys: ${{ steps.extcache.outputs.key }}
path: ${{ steps.cache-env.outputs.dir }}
key: ${{ steps.cache-env.outputs.key }}
restore-keys: ${{ steps.cache-env.outputs.key }}
- name: Setup PHP with extensions and custom config
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://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="#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 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>
@ -37,6 +37,7 @@ Setup PHP with required extensions, php.ini configuration, code-coverage support
- [Flags](#flags)
- [Basic Setup](#basic-setup)
- [Matrix Setup](#matrix-setup)
- [Multi-Arch Setup](#multi-arch-setup)
- [Nightly Build Setup](#nightly-build-setup)
- [Self Hosted Setup](#self-hosted-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
- 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.
```yaml
@ -165,7 +168,7 @@ The action supports both `GitHub-hosted` runners and `self-hosted` runners on th
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`.
@ -193,7 +196,7 @@ These tools can be setup globally using the `tools` input.
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
- name: Setup PHP with composer v2
@ -203,6 +206,8 @@ These tools can be setup globally using the `tools` input.
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.
- 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
```
### 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
> Setup a nightly build of `PHP 8.0` or `PHP 8.1`.
@ -460,6 +496,7 @@ jobs:
**Notes**
- 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.
- Avoid using the same labels for your `self-hosted` runners which are used by `GitHub-hosted` runners.
### Local Testing Setup
@ -561,13 +598,13 @@ If your project uses composer, you can persist the composer's internal cache dir
```yaml
- name: Get composer cache directory
id: composercache
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache dependencies
uses: actions/cache@v2
with:
path: ${{ steps.composercache.outputs.dir }}
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
@ -577,25 +614,30 @@ If your project uses composer, you can persist the composer's internal cache dir
**Notes**
- 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
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
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
- 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
- name: Cache dependencies
uses: actions/cache@v2
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
restore-keys: ${{ runner.os }}-node-
```
@ -769,6 +811,7 @@ Examples of using `setup-php` with various PHP Frameworks and Packages.
## :package: 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")
- [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")

View File

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

View File

@ -3,7 +3,7 @@ import * as extensions from '../src/extensions';
describe('Extension tests', () => {
it('checking addExtensionOnWindows', async () => {
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',
'win32'
);
@ -18,6 +18,7 @@ describe('Extension tests', () => {
expect(win32).toContain('Add-Extension ast beta');
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 sqlsrv devel 1.2.3');
win32 = await extensions.addExtension('pcov', '5.6', 'win32');
expect(win32).toContain(
@ -58,20 +59,15 @@ describe('Extension tests', () => {
it('checking addExtensionOnLinux', async () => {
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',
'linux'
);
expect(linux).toContain(
'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(
'sudo $debconf_fix apt-get install -y php7.4-sqlite3'
);
expect(linux).toContain('add_extension sqlite3');
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_pdo_extension mysql');
expect(linux).toContain('add_pdo_extension odbc');
@ -80,21 +76,21 @@ describe('Extension tests', () => {
'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');
expect(linux).toContain(
'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');
linux = await extensions.addExtension('gearman', '7.4', 'linux');
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');
expect(linux).toContain('add_cubrid pdo_cubrid');
linux = await extensions.addExtension('cubrid', '7.4', 'linux');
@ -133,14 +129,14 @@ describe('Extension tests', () => {
'7.2',
'darwin'
);
expect(darwin).toContain('add_brew_extension xdebug');
expect(darwin).toContain('add_brew_extension pcov');
expect(darwin).toContain('add_brew_extension grpc');
expect(darwin).toContain('add_brew_extension igbinary');
expect(darwin).toContain('add_brew_extension imagick');
expect(darwin).toContain('add_brew_extension protobuf');
expect(darwin).toContain('add_brew_extension swoole');
expect(darwin).toContain('pecl_install sqlite3');
expect(darwin).toContain('add_brew_extension xdebug zend_extension');
expect(darwin).toContain('add_brew_extension pcov extension');
expect(darwin).toContain('add_brew_extension grpc extension');
expect(darwin).toContain('add_brew_extension igbinary extension');
expect(darwin).toContain('add_brew_extension imagick extension');
expect(darwin).toContain('add_brew_extension protobuf extension');
expect(darwin).toContain('add_brew_extension swoole extension');
expect(darwin).toContain('add_extension sqlite3');
expect(darwin).toContain('remove_extension intl');
expect(darwin).toContain('add_unstable_extension ast beta 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');
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');
expect(darwin).toContain('add_ioncube');
@ -176,14 +178,13 @@ describe('Extension tests', () => {
expect(darwin).toContain('add_brew_extension xdebug');
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');
expect(darwin).toContain('pecl_install redis');
expect(darwin).toContain('add_extension redis');
darwin = await extensions.addExtension('imagick', '5.5', 'darwin');
expect(darwin).toContain('brew install pkg-config imagemagick');
expect(darwin).toContain('pecl_install imagick');
expect(darwin).toContain('add_extension imagick');
darwin = await extensions.addExtension('blackfire', '7.3', 'darwin');
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 () => {
expect(await tools.getDeployerUrl('latest')).toBe(
'https://deployer.org/deployer.phar'
@ -207,9 +222,17 @@ describe('Tools tests', () => {
'a',
'b'
]);
expect(await tools.addComposer(['a', 'b', 'composer:1.2'])).toStrictEqual([
'composer',
'a',
'b'
]);
expect(
await tools.addComposer(['a', 'b', 'composer:1.2.3'])
).toStrictEqual(['composer', 'a', 'b']);
).toStrictEqual(['composer:1.2.3', 'a', 'b']);
expect(
await tools.addComposer(['a', 'b', 'composer:v1.2.3'])
).toStrictEqual(['composer:1.2.3', 'a', 'b']);
expect(
await tools.addComposer(['a', 'b', 'composer:snapshot'])
).toStrictEqual(['composer:snapshot', 'a', 'b']);
@ -228,6 +251,9 @@ describe('Tools tests', () => {
expect(
await tools.addComposer(['a', 'b', 'c', 'composer:v2'])
).toStrictEqual(['composer:2', 'a', 'b', 'c']);
expect(
await tools.addComposer(['hirak', 'b', 'c', 'composer:v2'])
).toStrictEqual(['composer:1', 'hirak', 'b', 'c']);
});
it('checking getComposerUrl', async () => {
@ -249,6 +275,21 @@ describe('Tools tests', () => {
expect(await tools.getComposerUrl('2')).toContain(
'https://getcomposer.org/composer-2.phar'
);
expect(await tools.getComposerUrl('1.7.2')).toContain(
'https://github.com/composer/composer/releases/download/1.7.2/composer.phar'
);
expect(await tools.getComposerUrl('1.7.2')).toContain(
'https://getcomposer.org/composer-1.7.2.phar'
);
expect(await tools.getComposerUrl('2.0.0-RC2')).toContain(
'https://github.com/composer/composer/releases/download/2.0.0-RC2/composer.phar'
);
expect(await tools.getComposerUrl('2.0.0-RC2')).toContain(
'https://getcomposer.org/composer-2.0.0-RC2.phar'
);
expect(await tools.getComposerUrl('wrong')).toContain(
'https://getcomposer.org/composer-stable.phar'
);
});
it('checking getSymfonyUri', async () => {
@ -277,7 +318,7 @@ describe('Tools tests', () => {
it('checking getCleanedToolsList', async () => {
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([
'composer',
@ -286,8 +327,6 @@ describe('Tools tests', () => {
'composer-unused',
'vapor-cli',
'phinx',
'prestissimo',
'composer-prefetcher',
'phpspec',
'flex'
]);
@ -433,7 +472,6 @@ describe('Tools tests', () => {
'blackfire',
'blackfire-player',
'composer-normalize',
'composer-prefetcher:1.2.3',
'composer-require-checker',
'composer-unused',
'cs2pr:1.2.3',
@ -522,9 +560,6 @@ describe('Tools tests', () => {
expect(script).toContain(
'add_composertool composer-unused composer-unused icanhazstring/'
);
expect(script).toContain(
'add_composertool composer-prefetcher composer-prefetcher:1.2.3 narrowspark/automatic-'
);
expect(script).toContain(
'add_tool https://github.com/symfony/cli/releases/latest/download/symfony_darwin_amd64 symfony version'
);
@ -551,7 +586,6 @@ describe('Tools tests', () => {
'php-config',
'phpize',
'phpmd',
'prestissimo',
'symfony',
'wp-cli'
];
@ -576,7 +610,6 @@ describe('Tools tests', () => {
expect(script).toContain(
'Add-Tool https://deployer.org/deployer.phar deployer "-V"'
);
expect(script).toContain('Add-Composertool prestissimo prestissimo hirak/');
expect(script).toContain(
'Add-Tool https://github.com/phpmd/phpmd/releases/latest/download/phpmd.phar phpmd "--version"'
);
@ -608,7 +641,7 @@ describe('Tools tests', () => {
);
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 phinx phinx robmorgan/');

113
dist/index.js vendored
View File

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

View File

@ -17,11 +17,11 @@ jobs:
with:
php-version: ${{ matrix.php-versions }}
- name: Get composer cache directory
id: composercache
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- uses: actions/cache@v2
with:
path: ${{ steps.composercache.outputs.dir }}
path: ${{ steps.composer-cache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed.
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -20,12 +20,12 @@ jobs:
extensions: mbstring, dom, fileinfo
coverage: xdebug #optional
- name: Get composer cache directory
id: composercache
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache composer dependencies
uses: actions/cache@v2
with:
path: ${{ steps.composercache.outputs.dir }}
path: ${{ steps.composer-cache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed.
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -33,12 +33,12 @@ jobs:
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: ${{ runner.os }}-yarn-
- name: Get composer cache directory
id: composercache
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache composer dependencies
uses: actions/cache@v2
with:
path: ${{ steps.composercache.outputs.dir }}
path: ${{ steps.composer-cache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed.
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}

View File

@ -18,12 +18,12 @@ jobs:
extensions: mbstring, simplexml, dom
coverage: xdebug #optional
- name: Get composer cache directory
id: composercache
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache composer dependencies
uses: actions/cache@v2
with:
path: ${{ steps.composercache.outputs.dir }}
path: ${{ steps.composer-cache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed.
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}

View File

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

View File

@ -29,12 +29,12 @@ jobs:
extensions: mbstring, xml, ctype, iconv, intl, pdo_sqlite, pgsql
coverage: xdebug #optional
- name: Get composer cache directory
id: composercache
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache composer dependencies
uses: actions/cache@v2
with:
path: ${{ steps.composercache.outputs.dir }}
path: ${{ steps.composer-cache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed.
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}

View File

@ -20,12 +20,12 @@ jobs:
extensions: mbstring, xml, ctype, iconv, intl, pdo_sqlite
coverage: xdebug #optional
- name: Get composer cache directory
id: composercache
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache composer dependencies
uses: actions/cache@v2
with:
path: ${{ steps.composercache.outputs.dir }}
path: ${{ steps.composer-cache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed.
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}

View File

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

View File

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

View File

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

2307
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

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

View File

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

View File

@ -21,6 +21,7 @@ export async function getScript(
const name = 'setup-php';
const url = 'https://setup-php.com/support';
// taking inputs
process.env['fail_fast'] = await utils.getInput('fail-fast', false);
const extension_csv: string = await utils.getInput('extensions', false);
const ini_values_csv: string = await utils.getInput('ini-values', 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 script = os_version + (await utils.scriptExtension(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, fail_fast)
);
await exec(await utils.joins(tool, location, version, __dirname));
} catch (error) {
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.
self_hosted_setup() {
if [[ $(command -v brew) == "" ]]; then
self_hosted_helper() {
if ! command -v brew >/dev/null; then
step_log "Setup Brew"
curl "${curl_opts[@]}" https://raw.githubusercontent.com/Homebrew/install/master/install.sh | bash -s >/dev/null 2>&1
add_log "$tick" "Brew" "Installed Homebrew"
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"
fi
}
@ -48,59 +11,27 @@ self_hosted_setup() {
remove_extension() {
extension=$1
if check_extension "$extension"; then
sudo sed -i '' "/$extension/d" "$ini_file"
sudo rm -rf "$scan_dir"/*"$extension"* >/dev/null 2>&1
sudo rm -rf "$ext_dir"/"$extension".so >/dev/null 2>&1
(! check_extension "$extension" && add_log "$tick" ":$extension" "Removed") ||
add_log "$cross" ":$extension" "Could not remove $extension on PHP $semver"
sudo sed -i '' "/$extension/d" "${ini_file:?}"
sudo rm -rf "${scan_dir:?}"/*"$extension"* "${ext_dir:?}"/"$extension".so >/dev/null 2>&1
(! check_extension "$extension" && add_log "${tick:?}" ":$extension" "Removed") ||
add_log "${cross:?}" ":$extension" "Could not remove $extension on PHP ${semver:?}"
else
add_log "$tick" ":$extension" "Could not find $extension on PHP $semver"
add_log "${tick:?}" ":$extension" "Could not find $extension on PHP $semver"
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.
add_pecl_extension() {
extension=$1
pecl_version=$2
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")
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');")
if [ "$ext_version" = "$pecl_version" ]; then
add_log "$tick" "$extension" "Enabled"
add_log "${tick:?}" "$extension" "Enabled"
else
remove_extension "$extension" >/dev/null 2>&1
pecl_install "$extension-$pecl_version"
@ -111,151 +42,66 @@ add_pecl_extension() {
# Function to install a php extension from shivammathur/extensions tap.
add_brew_extension() {
extension=$1
if ! brew tap | grep shivammathur/extensions; then
brew tap --shallow shivammathur/extensions
prefix=$2
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
brew install "$extension@$version" >/dev/null 2>&1
sudo cp "$(brew --prefix)/opt/$extension@$version/$extension.so" "$ext_dir"
add_extension_log "$extension" "Installed and enabled"
fi
brew install "$extension@$version"
sudo cp "$(brew --prefix)/opt/$extension@$version/$extension.so" "$ext_dir"
}
# Function to setup extensions
add_extension() {
extension=$1
install_command=$2
prefix=$3
if ! check_extension "$extension" && [ -e "$ext_dir/$extension.so" ]; then
echo "$prefix=$ext_dir/$extension.so" >>"$ini_file" && add_log "$tick" "$extension" "Enabled"
elif check_extension "$extension"; then
add_log "$tick" "$extension" "Enabled"
elif ! check_extension "$extension"; then
eval "$install_command" >/dev/null 2>&1 &&
if [[ "$version" =~ $old_versions ]]; then echo "$prefix=$ext_dir/$extension.so" >>"$ini_file"; fi
prefix=$2
enable_extension "$extension" "$prefix"
if check_extension "$extension"; then
add_log "${tick:?}" "$extension" "Enabled"
else
[[ "$version" =~ 5.[4-5] ]] && [ "$extension" = "imagick" ] && brew install pkg-config imagemagick >/dev/null 2>&1
pecl_install "$extension" >/dev/null 2>&1 &&
if [[ "$version" =~ ${old_versions:?} ]]; then echo "$prefix=$ext_dir/$extension.so" >>"$ini_file"; fi
add_extension_log "$extension" "Installed and enabled"
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.
add_devtools() {
tool=$1
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
add_log "${tick:?}" "$tool" "Added $tool $semver"
}
# Function to handle request to add PECL.
add_pecl() {
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.
setup_php() {
# Function to update dependencies.
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
export HOMEBREW_NO_INSTALL_CLEANUP=TRUE
brew tap --shallow shivammathur/homebrew-php
if ! brew tap | grep -q shivammathur/php; then
brew tap --shallow shivammathur/php
fi
update_dependencies
if brew list php@"$version" 2>/dev/null | grep -q "Error" && [ "$action" != "upgrade" ]; then
brew unlink php@"$version"
else
@ -264,49 +110,42 @@ setup_php() {
brew link --force --overwrite php@"$version"
}
# Function to Setup PHP
setup_php() {
step_log "Setup PHP"
existing_version=$(php-config --version 2>/dev/null | cut -c 1-3)
if [[ "$version" =~ ${old_versions:?} ]]; then
run_script "php5-darwin" "${version/./}" >/dev/null 2>&1
status="Installed"
elif [ "$existing_version" != "$version" ]; then
add_php "install" >/dev/null 2>&1
status="Installed"
elif [ "$existing_version" = "$version" ] && [ "${update:?}" = "true" ]; then
add_php "upgrade" >/dev/null 2>&1
status="Updated to"
else
status="Found"
fi
ini_file=$(php -d "date.timezone=UTC" --ini | grep "Loaded Configuration" | sed -e "s|.*:s*||" | sed "s/ //g")
sudo chmod 777 "$ini_file" "${tool_path_dir:?}"
echo -e "date.timezone=UTC\nmemory_limit=-1" >>"$ini_file"
ext_dir=$(php -i | grep -Ei "extension_dir => /" | sed -e "s|.*=> s*||")
scan_dir=$(php --ini | grep additional | sed -e "s|.*: s*||")
sudo mkdir -m 777 -p "$ext_dir" "$HOME/.composer"
semver=$(php -v | head -n 1 | cut -f 2 -d ' ')
if [[ ! "$version" =~ $old_versions ]]; then configure_pecl >/dev/null 2>&1; fi
sudo cp "$dist"/../src/configs/*.json "$RUNNER_TOOL_CACHE/"
add_log "$tick" "PHP" "$status PHP $semver"
}
# Variables
tick="✓"
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)
export HOMEBREW_NO_INSTALL_CLEANUP=1
export HOMEBREW_NO_AUTO_UPDATE=1
# shellcheck source=.
. "${dist}"/../src/scripts/common.sh
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"
if [[ "$version" =~ $old_versions ]]; then
curl "${curl_opts[@]}" https://github.com/shivammathur/php5-darwin/releases/latest/download/install.sh | bash -s "$nodot_version" >/dev/null 2>&1
status="Installed"
elif [ "$existing_version" != "$version" ]; then
setup_php "install" >/dev/null 2>&1
status="Installed"
elif [ "$existing_version" = "$version" ] && [ "$update" = "true" ]; then
setup_php "upgrade" >/dev/null 2>&1
status="Updated to"
else
status="Found"
fi
ini_file=$(php -d "date.timezone=UTC" --ini | grep "Loaded Configuration" | sed -e "s|.*:s*||" | sed "s/ //g")
sudo chmod 777 "$ini_file" "$tool_path_dir"
echo -e "date.timezone=UTC\nmemory_limit=-1" >>"$ini_file"
ext_dir=$(php -i | grep -Ei "extension_dir => /" | sed -e "s|.*=> s*||")
scan_dir=$(php --ini | grep additional | sed -e "s|.*: s*||")
sudo mkdir -p "$ext_dir"
semver=$(php -v | head -n 1 | cut -f 2 -d ' ')
if [[ ! "$version" =~ $old_versions ]]; then configure_pecl >/dev/null 2>&1; fi
sudo cp "$dist"/../src/configs/*.json "$RUNNER_TOOL_CACHE/"
add_log "$tick" "PHP" "$status PHP $semver"
self_hosted_setup
setup_php

View File

@ -17,7 +17,7 @@ Function Add-Blackfire() {
$status="Enabled"
} 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
$status="Installed and enabled"
}

View File

@ -8,9 +8,9 @@ add_blackfire() {
blackfire_ini_file="${scan_dir:?}/50-blackfire.ini"
if [ ! -e "${ext_dir:?}/blackfire.so" ]; 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
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
echo "extension=blackfire.so" | sudo tee -a "$blackfire_ini_file" >/dev/null 2>&1
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() {
icu=$1
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 cp -r /usr/local/icu/lib/* /usr/lib/x86_64-linux-gnu/
fi
@ -11,12 +11,12 @@ install_icu() {
# Function to add ext-intl with the given version of ICU
add_intl() {
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
add_log "${cross:?}" "intl" "ICU $icu is not supported"
else
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
add_extension_log intl "Installed and enabled with ICU $icu"
fi

View File

@ -19,7 +19,7 @@ Function Add-Ioncube() {
if (-not($installed.ThreadSafe)) {
$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
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
status='Installed and enabled'
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"
fi
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') {
$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
Copy-Item $php_dir\instantclient*\* $php_dir
}
@ -44,7 +44,7 @@ Function Add-Oci() {
$ociVersion = '2.0.12'
}
$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
}

View File

@ -34,7 +34,7 @@ add_client() {
arch='macos'
lib_ext='dylib'
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"
done
sudo ln -sf /opt/oracle/instantclient*/*.$lib_ext* $libs
@ -44,7 +44,7 @@ add_client() {
# Function to get PHP source.
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.
@ -73,7 +73,7 @@ restore_phpize() {
# Function to patch pdo_oci.
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
sudo sed -i '' "/PHP_CHECK_PDO_INCLUDES/d" config.m4 2>/dev/null || sudo sed -i "/PHP_CHECK_PDO_INCLUDES/d" config.m4
fi
@ -83,16 +83,9 @@ patch_pdo_oci_config() {
add_dependencies() {
if [ "$os" = 'Linux' ]; 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++
fi
else
! [[ ${version:?} =~ $nightly_versions ]] && update_lists && ${apt_install:?} --no-upgrade --no-install-recommends php"$version"-dev
${apt_install:?} --no-upgrade --no-install-recommends autoconf automake libaio-dev gcc g++
fi
sudo update-alternatives --set php-config /usr/bin/php-config"$version"
sudo update-alternatives --set phpize /usr/bin/phpize"$version"
! [[ ${version:?} =~ $nightly_versions ]] && add_devtools phpize
fi
}

View File

@ -5,9 +5,9 @@ Function Add-PhalconHelper() {
} else {
$domain = 'https://github.com'
$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
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
Copy-Item -Path "$ENV:RUNNER_TOOL_CACHE\phalcon\php_phalcon.dll" -Destination "$ext_dir\php_phalcon.dll"
Enable-PhpExtension -Extension phalcon -Path $php_dir

View File

@ -1,39 +1,10 @@
# 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;
# Function to setup environment for self-hosted runners.
self_hosted_helper() {
if ! command -v apt-fast >/dev/null; then
sudo ln -sf /usr/bin/apt-get /usr/bin/apt-fast
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() {
. /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}"
install_packages curl make software-properties-common unzip
add_ppa
}
# Function to backup and cleanup package lists.
@ -64,70 +35,24 @@ update_lists() {
[ "$DISTRIB_RELEASE" = "20.04" ] && add_ppa >/dev/null 2>&1
cleanup_lists
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
}
# Function to setup environment for self-hosted runners.
self_hosted_setup() {
if ! command -v apt-fast >/dev/null; then
sudo ln -sf /usr/bin/apt-get /usr/bin/apt-fast
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 install a package
install_packages() {
packages=("$@")
$apt_install "${packages[@]}" >/dev/null 2>&1 || update_lists && $apt_install "${packages[@]}" >/dev/null 2>&1
}
# Function to delete extensions.
delete_extension() {
extension=$1
sudo sed -i "/$extension/d" "$ini_file"
sudo sed -i "/$extension/d" "$pecl_file"
sudo rm -rf "$scan_dir"/*"$extension"* >/dev/null 2>&1
sudo rm -rf "$ext_dir"/"$extension".so >/dev/null 2>&1
if [ "$runner" = "self-hosted" ]; then
$apt_remove "php-$extension" >/dev/null 2>&1 || true
$apt_remove "php$version-$extension" >/dev/null 2>&1 || true
sudo sed -i "/$extension/d" "${ini_file:?}"
sudo sed -i "/$extension/d" "${pecl_file:?}"
sudo rm -rf "${scan_dir:?}"/*"$extension"* "${ext_dir:?}"/"$extension".so >/dev/null 2>&1
if [ "${runner:?}" = "self-hosted" ]; then
$apt_remove "php-$extension" "php$version-$extension" >/dev/null 2>&1 || true
fi
}
@ -135,21 +60,16 @@ delete_extension() {
remove_extension() {
extension=$1
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
echo "$extension" | sudo tee -a /tmp/setup_php_dismod >/dev/null 2>&1
fi
delete_extension "$extension"
(! check_extension "$extension" && add_log "$tick" ":$extension" "Removed") ||
add_log "$cross" ":$extension" "Could not remove $extension on PHP $semver"
(! check_extension "$extension" && add_log "${tick:?}" ":$extension" "Removed") ||
add_log "${cross:?}" ":$extension" "Could not remove $extension on PHP ${semver:?}"
else
add_log "$tick" ":$extension" "Could not find $extension on PHP $semver"
fi
}
# Function to enable existing extensions.
enable_extension() {
if ! check_extension "$1" && [ -e "$ext_dir/$1.so" ]; then
echo "$2=$1.so" >>"$pecl_file"
delete_extension "$extension"
add_log "${tick:?}" ":$extension" "Could not find $extension on PHP $semver"
fi
}
@ -157,19 +77,19 @@ enable_extension() {
add_pdo_extension() {
pdo_ext="pdo_$1"
if check_extension "$pdo_ext"; then
add_log "$tick" "$pdo_ext" "Enabled"
add_log "${tick:?}" "$pdo_ext" "Enabled"
else
read -r ext ext_name <<< "$1 $1"
ext=$1; ext_name=$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
enable_extension "mysqlnd" "extension"
ext_name="mysqli"
elif [ "$ext" = "sqlite" ]; then
read -r ext ext_name <<< "sqlite3 sqlite3"
ext="sqlite3"; ext_name="sqlite3";
fi
add_extension "$ext_name" "$apt_install php$version-$ext" "extension" >/dev/null 2>&1
add_extension "$pdo_ext" "pecl_install $pdo_ext" "extension" >/dev/null 2>&1
add_extension "$ext_name" "extension" >/dev/null 2>&1
add_extension "$pdo_ext" "extension" >/dev/null 2>&1
add_extension_log "$pdo_ext" "Enabled"
fi
}
@ -177,17 +97,18 @@ add_pdo_extension() {
# Function to add extensions.
add_extension() {
extension=$1
install_command=$2
prefix=$3
prefix=$2
enable_extension "$extension" "$prefix"
if check_extension "$extension"; then
add_log "$tick" "$extension" "Enabled"
add_log "${tick:?}" "$extension" "Enabled"
else
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
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"
fi
sudo chmod 777 "$ini_file"
@ -198,15 +119,13 @@ add_pecl_extension() {
extension=$1
pecl_version=$2
prefix=$3
if [[ $pecl_version =~ .*(alpha|beta|rc|snapshot).* ]]; then
if [[ $pecl_version =~ .*(alpha|beta|rc|snapshot|preview).* ]]; then
pecl_version=$(get_pecl_version "$extension" "$pecl_version")
fi
if ! check_extension "$extension" && [ -e "$ext_dir/$extension.so" ]; then
echo "$prefix=$ext_dir/$extension.so" >>"$pecl_file"
fi
enable_extension "$extension" "$prefix"
ext_version=$(php -r "echo phpversion('$extension');")
if [ "$ext_version" = "$pecl_version" ]; then
add_log "$tick" "$extension" "Enabled"
add_log "${tick:?}" "$extension" "Enabled"
else
delete_extension "$extension"
pecl_install "$extension-$pecl_version"
@ -214,15 +133,6 @@ add_pecl_extension() {
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
add_extension_from_source() {
extension=$1
@ -233,121 +143,37 @@ add_extension_from_source() {
(
add_devtools phpize
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
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"
) >/dev/null 2>&1
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.
add_devtools() {
tool=$1
if ! [ -e "/usr/bin/phpize$version" ] || ! [ -e "/usr/bin/php-config$version" ]; then
update_lists && $apt_install php"$version"-dev php"$version"-xml >/dev/null 2>&1
if ! command -v "$tool$version" >/dev/null; then
install_packages "php$version-dev" "php$version-xml"
fi
sudo update-alternatives --set php-config /usr/bin/php-config"$version" >/dev/null 2>&1
sudo update-alternatives --set phpize /usr/bin/phpize"$version" >/dev/null 2>&1
configure_pecl >/dev/null 2>&1
add_log "$tick" "$tool" "Added $tool $semver"
if command -v pecl >/dev/null; then
configure_pecl >/dev/null 2>&1
fi
add_log "${tick:?}" "$tool" "Added $tool $semver"
}
# Function to setup the nightly build from shivammathur/php-builder
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.
setup_old_versions() {
curl "${curl_opts[@]}" "$github"/php5-ubuntu/releases/latest/download/install.sh | bash -s "$version"
run_script "php5-ubuntu" "$version"
configure_pecl
release_version=$(php -v | head -n 1 | cut -d' ' -f 2)
}
@ -355,48 +181,40 @@ setup_old_versions() {
# Function to add PECL.
add_pecl() {
add_devtools phpize >/dev/null 2>&1
if [ ! -e /usr/bin/pecl ]; then
$apt_install php-pear >/dev/null 2>&1 || update_lists && $apt_install php-pear >/dev/null 2>&1
if ! command -v pecl >/dev/null; then
install_packages php-pear
fi
configure_pecl >/dev/null 2>&1
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.
switch_version() {
for tool in pear pecl php phar phar.phar php-cgi php-config phpize phpdbg; do
if [ -e "/usr/bin/$tool$version" ]; then
sudo update-alternatives --set $tool /usr/bin/"$tool$version"
sudo update-alternatives --set $tool /usr/bin/"$tool$version" &
to_wait+=( $! )
fi
done
}
# 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
wait "${to_wait[@]}"
}
# Function to install packaged PHP
add_packaged_php() {
if [ "$runner" = "self-hosted" ] || [ "${use_package_cache:-true}" = "false" ]; then
update_lists
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[@]}"
else
curl "${curl_opts[@]}" "$github"/php-ubuntu/releases/latest/download/install.sh | bash -s "$version"
run_script "php-ubuntu" "$version"
fi
}
# Function to update PHP.
update_php() {
initial_version=$(php_semver)
use_package_cache="false"
add_packaged_php
use_package_cache="false" add_packaged_php
updated_version=$(php_semver)
if [ "$updated_version" != "$initial_version" ]; then
status="Updated to"
@ -407,9 +225,9 @@ update_php() {
# Function to install PHP.
add_php() {
if [[ "$version" =~ $nightly_versions ]]; then
if [[ "$version" =~ ${nightly_versions:?} ]]; then
setup_nightly
elif [[ "$version" =~ $old_versions ]]; then
elif [[ "$version" =~ ${old_versions:?} ]]; then
setup_old_versions
else
add_packaged_php
@ -417,67 +235,52 @@ add_php() {
status="Installed"
}
# Variables
tick="✓"
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"
sudo mkdir -p /var/run /run/php
if [ "$existing_version" != "$version" ]; then
if [ ! -e "/usr/bin/php$version" ]; then
add_php >/dev/null 2>&1
# Function to Setup PHP
setup_php() {
step_log "Setup PHP"
sudo mkdir -m 777 -p /var/run /run/php
if [ "$(php-config --version 2>/dev/null | cut -c 1-3)" != "$version" ]; then
if [ ! -e "/usr/bin/php$version" ]; then
add_php >/dev/null 2>&1
else
if [ "${update:?}" = "true" ]; then
update_php >/dev/null 2>&1
else
status="Switched to"
fi
fi
if ! [[ "$version" =~ ${old_versions:?}|${nightly_versions:?} ]]; then
switch_version >/dev/null 2>&1
fi
else
if [ "$update" = "true" ]; then
update_php >/dev/null 2>&1
else
status="Switched to"
status="Found"
fi
fi
if ! [[ "$version" =~ $old_versions ]]; then
switch_version >/dev/null 2>&1
fi
else
if [ "$update" = "true" ]; then
update_php >/dev/null 2>&1
else
status="Found"
if [[ "$version" =~ $nightly_versions ]]; then
switch_version >/dev/null 2>&1
fi
fi
fi
semver=$(php_semver)
ext_dir=$(php -i | grep "extension_dir => /" | sed -e "s|.*=> s*||")
scan_dir=$(php --ini | grep additional | sed -e "s|.*: s*||")
ini_file=$(php --ini | grep "Loaded Configuration" | sed -e "s|.*:s*||" | sed "s/ //g")
pecl_file="$scan_dir"/99-pecl.ini
echo '' | sudo tee "$pecl_file" >/dev/null 2>&1
sudo rm -rf /usr/local/bin/phpunit >/dev/null 2>&1
sudo chmod 777 "$ini_file" "$pecl_file" "${tool_path_dir:?}"
sudo cp "$dist"/../src/configs/*.json "$RUNNER_TOOL_CACHE/"
add_log "${tick:?}" "PHP" "$status PHP $semver"
}
semver=$(php_semver)
ext_dir=$(php -i | grep "extension_dir => /" | sed -e "s|.*=> s*||")
scan_dir=$(php --ini | grep additional | sed -e "s|.*: s*||")
ini_file=$(php --ini | grep "Loaded Configuration" | sed -e "s|.*:s*||" | sed "s/ //g")
pecl_file="$scan_dir"/99-pecl.ini
echo '' | sudo tee "$pecl_file" >/dev/null 2>&1
sudo rm -rf /usr/local/bin/phpunit >/dev/null 2>&1
sudo chmod 777 "$ini_file" "$pecl_file" "$tool_path_dir"
sudo cp "$dist"/../src/configs/*.json "$RUNNER_TOOL_CACHE/"
add_log "$tick" "PHP" "$status PHP $semver"
# 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
$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
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"

View File

@ -1,6 +1,6 @@
add_blackfire_linux() {
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
sudo "${debconf_fix:?}" apt-get update
${apt_install:?} blackfire-agent

View File

@ -1,13 +1,12 @@
add_bazel() {
if [ ! "$(command -v bazel)" ]; then
os=$(uname -s)
if [ "$os" = "Linux" ]; then
if ! command -v bazel; then
if [ "$(uname -s)" = "Linux" ]; then
${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
sudo "${debconf_fix:?}" apt-get update -y
${apt_install:?} bazel
elif [ "$os" = "Darwin" ]; then
else
brew install bazel
fi
fi
@ -15,13 +14,13 @@ add_bazel() {
get_grpc_tag() {
if [ "$grpc_tag" = "latest" ]; then
grpc_tag=$(curl "${curl_opts[@]:?}" https://grpc.io/release)
grpc_tag=$(get -s -n "" https://grpc.io/release)
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
grpc_tag="v$grpc_tag"
else
grpc_tag=$(curl "${curl_opts[@]:?}" https://grpc.io/release)
grpc_tag=$(get -s -n "" https://grpc.io/release)
fi
fi
}
@ -30,11 +29,10 @@ add_grpc_php_plugin() {
grpc_tag=$1
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
add_bazel
echo "os: $os"
echo "release: $DISTRIB_RELEASE"
[ "$(uname -s)" = "Darwin" ] && sudo xcode-select -s /Applications/Xcode_11.7.app
if [ "$DISTRIB_RELEASE" = "16.04" ]; then
CC="$(command -v gcc)" CXX="$(command -v g++)" ./tools/bazel build src/compiler:grpc_php_plugin
else

View File

@ -27,7 +27,7 @@ Function Add-Protoc() {
$arch_num = '32'
}
$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
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"

View File

@ -1,12 +1,12 @@
get_protobuf_tag() {
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
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
protobuf_tag="v$protobuf_tag"
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
}
@ -17,7 +17,7 @@ add_protoc() {
(
platform='linux'
[ "$(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 chmod 777 /usr/local/bin/protoc -R /usr/local/include/google
) >/dev/null 2>&1

View File

@ -79,7 +79,7 @@ Function Add-Printf {
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
} 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
}
} else {
@ -96,16 +96,24 @@ Function Get-CleanPSProfile {
Add-ToProfile $profile $current_profile.replace('\', '\\') ". $current_profile"
}
# Function to install PhpManager.
Function Install-PhpManager() {
$module_path = "$bin_dir\PhpManager\PhpManager.psm1"
# Function to install a powershell package from GitHub.
Function Install-PSPackage() {
param(
[Parameter(Position = 0, Mandatory = $true)]
$package,
[Parameter(Position = 1, Mandatory = $true)]
$psm1_path,
[Parameter(Position = 2, Mandatory = $true)]
$url
)
$module_path = "$bin_dir\$psm1_path.psm1"
if(-not (Test-Path $module_path -PathType Leaf)) {
$zip_file = "$bin_dir\PhpManager.zip"
Invoke-WebRequest -UseBasicParsing -Uri 'https://github.com/mlocati/powershell-phpmanager/releases/latest/download/PhpManager.zip' -OutFile $zip_file
$zip_file = "$bin_dir\$package.zip"
Invoke-WebRequest -Uri $url -OutFile $zip_file
Expand-Archive -Path $zip_file -DestinationPath $bin_dir -Force
}
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.
@ -197,7 +205,7 @@ Function Edit-ComposerConfig() {
exit 1;
}
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) {
composer -q global config github-oauth.github.com $env:COMPOSER_TOKEN
}
@ -242,33 +250,40 @@ Function Add-Tool() {
}
if($url.Count -gt 1) { $url = $url[0] }
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
} else {
try {
Invoke-WebRequest -UseBasicParsing -Uri $url -OutFile $bin_dir\$tool
$bat_content = @()
$bat_content += "@ECHO off"
$bat_content += "setlocal DISABLEDELAYEDEXPANSION"
$bat_content += "SET BIN_TARGET=%~dp0/" + $tool
$bat_content += "php %BIN_TARGET% %*"
Set-Content -Path $bin_dir\$tool.bat -Value $bat_content
Add-ToProfile $current_profile $tool "New-Alias $tool $bin_dir\$tool.bat" >$null 2>&1
} catch { }
}
if($tool -eq "phan") {
Add-Extension fileinfo >$null 2>&1
Add-Extension ast >$null 2>&1
} elseif($tool -eq "phive") {
Add-Extension xml >$null 2>&1
} elseif($tool -eq "cs2pr") {
(Get-Content $bin_dir/cs2pr).replace('exit(9)', 'exit(0)') | Set-Content $bin_dir/cs2pr
} elseif($tool -eq "composer") {
Edit-ComposerConfig $bin_dir\$tool
} elseif($tool -eq "wp-cli") {
Copy-Item $bin_dir\wp-cli.bat -Destination $bin_dir\wp.bat
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 += "@ECHO off"
$bat_content += "setlocal DISABLEDELAYEDEXPANSION"
$bat_content += "SET BIN_TARGET=%~dp0/" + $tool
$bat_content += "php %BIN_TARGET% %*"
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
if($tool -eq "phan") {
Add-Extension fileinfo >$null 2>&1
Add-Extension ast >$null 2>&1
} elseif($tool -eq "phive") {
Add-Extension xml >$null 2>&1
} elseif($tool -eq "cs2pr") {
(Get-Content $bin_dir/cs2pr).replace('exit(9)', 'exit(0)') | Set-Content $bin_dir/cs2pr
} elseif($tool -eq "composer") {
Edit-ComposerConfig $bin_dir\$tool
} elseif($tool -eq "wp-cli") {
Copy-Item $bin_dir\wp-cli.bat -Destination $bin_dir\wp.bat
}
$tool_version = Get-ToolVersion $tool $ver_param
Add-Log $tick $tool "Added $tool $tool_version"
} else {
@ -297,6 +312,9 @@ Function Add-Composertool() {
)
composer global require $prefix$release 2>&1 | out-null
$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) {
$tool_version = Get-ToolVersion "Write-Output" "$json"
Add-Log $tick $tool "Added $tool $tool_version"
@ -316,10 +334,14 @@ $cross = ([char]10007)
$php_dir = 'C:\tools\php'
$ext_dir = "$php_dir\ext"
$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"
$ProgressPreference = 'SilentlyContinue'
$nightly_version = '8.[0-9]'
$cert_source='CurrentUser'
$enable_extensions = ('openssl', 'curl', 'mbstring')
$arch = 'x64'
if(-not([Environment]::Is64BitOperatingSystem) -or $version -lt '7.0') {
@ -358,7 +380,7 @@ if($env:RUNNER -eq 'self-hosted') {
Add-Printf >$null 2>&1
Step-Log "Setup PhpManager"
Install-PhpManager >$null 2>&1
Install-PSPackage PhpManager PhpManager\PhpManager "$github/mlocati/powershell-phpmanager/releases/latest/download/PhpManager.zip" >$null 2>&1
Add-Log $tick "PhpManager" "Installed"
Step-Log "Setup PHP"
@ -371,11 +393,11 @@ if (Test-Path -LiteralPath $php_dir -PathType Container) {
$status = "Installed"
if ($null -eq $installed -or -not("$($installed.Version).".StartsWith(($version -replace '^(\d+(\.\d+)*).*', '$1.'))) -or $ts -ne $installed.ThreadSafe) {
if ($version -lt '7.0' -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) {
Invoke-WebRequest -UseBasicParsing -Uri https://dl.bintray.com/shivammathur/php/Install-PhpNightly.ps1 -OutFile $php_dir\Install-PhpNightly.ps1 > $null 2>&1
& $php_dir\Install-PhpNightly.ps1 -Architecture $arch -ThreadSafe $ts -Path $php_dir -Version $version > $null 2>&1
Invoke-WebRequest -Uri $bintray/Get-PhpNightly.ps1 -OutFile $php_dir\Get-PhpNightly.ps1 > $null 2>&1
& $php_dir\Get-PhpNightly.ps1 -Architecture $arch -ThreadSafe $ts -Path $php_dir -Version $version > $null 2>&1
} else {
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
Set-PhpIniKey -Key 'date.timezone' -Value 'UTC' -Path $php_dir
Set-PhpIniKey -Key 'memory_limit' -Value '-1' -Path $php_dir
('date.timezone=UTC', 'memory_limit=-1') | foreach { $p=$_.split('='); Set-PhpIniKey -Key $p[0] -Value $p[1] -Path $php_dir }
if($version -lt "5.5") {
ForEach($lib in "libeay32.dll", "ssleay32.dll") {
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
('libeay32.dll', 'ssleay32.dll') | ForEach { Invoke-WebRequest -Uri $bintray/$_ -OutFile $php_dir\$_ >$null 2>&1 }
} 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
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)"

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
*
@ -280,15 +305,19 @@ export async function getWpCliUrl(version: string): Promise<string> {
*/
export async function addComposer(tools_list: string[]): Promise<string[]> {
const regex_any = /^composer($|:.*)/;
const regex_valid = /^composer:?($|preview$|snapshot$|v?[1-2]$)/;
const regex_valid = /^composer:?($|preview$|snapshot$|v?[1-2]$|v?\d+\.\d+\.\d+[\w-]*$)/;
const regex_composer1_tools = /hirak|prestissimo|narrowspark|composer-prefetcher/;
const matches: string[] = tools_list.filter(tool => regex_valid.test(tool));
let composer = 'composer';
tools_list = tools_list.filter(tool => !regex_any.test(tool));
switch (matches[0]) {
case undefined:
switch (true) {
case regex_composer1_tools.test(tools_list.join(' ')):
composer = 'composer:1';
break;
case matches[0] == undefined:
break;
default:
composer = matches[matches.length - 1].replace(/v([1-2])/, '$1');
composer = matches[matches.length - 1].replace(/v(\d\S*)/, '$1');
break;
}
tools_list.unshift(composer);
@ -301,21 +330,20 @@ export async function addComposer(tools_list: string[]): Promise<string[]> {
* @param version
*/
export async function getComposerUrl(version: string): Promise<string> {
const cache_url =
'https://github.com/shivammathur/composer-cache/releases/latest/download/composer-' +
version.replace('latest', 'stable') +
'.phar,';
switch (version) {
case 'snapshot':
return cache_url + 'https://getcomposer.org/composer.phar';
case 'preview':
case '1':
case '2':
return (
cache_url + 'https://getcomposer.org/composer-' + version + '.phar'
);
let cache_url = `https://github.com/shivammathur/composer-cache/releases/latest/download/composer-${version.replace(
'latest',
'stable'
)}.phar`;
switch (true) {
case /^snapshot$/.test(version):
return `${cache_url},https://getcomposer.org/composer.phar`;
case /^preview$|^[1-2]$/.test(version):
return `${cache_url},https://getcomposer.org/composer-${version}.phar`;
case /^\d+\.\d+\.\d+[\w-]*$/.test(version):
cache_url = `https://github.com/composer/composer/releases/download/${version}/composer.phar`;
return `${cache_url},https://getcomposer.org/composer-${version}.phar`;
default:
return 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);
break;
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"');
break;
case 'codeception':