Compare commits

..

77 Commits
2.5.0 ... 1.9.7

Author SHA1 Message Date
efbde18f4f Bump version to 1.9.7 2020-10-15 14:08:01 +05:30
a571b83a9a Move matchers setup to scripts 2020-10-15 14:08:01 +05:30
93544179be Prioritize with over env for inputs 2020-10-15 14:08:00 +05:30
b33e1bd5fb Switch to environment files. Apply GHSA-mfwh-5m23-j46w (CVE-2020-15228) 2020-10-15 14:07:59 +05:30
9b259cca75 Improve problem matchers section in README 2020-10-15 14:07:59 +05:30
7734ee36e7 Bump version to 1.9.6 2020-10-15 14:07:58 +05:30
077d3caefc Make sure printf is in PATH in Windows 2020-10-15 14:07:57 +05:30
446bccb14d Download release assets for PowerShell PhpManager
Downloading such assets is preferable since:
- they contain updated metadata (useful for debugging)
- they contain only the production files
- they are pre-built: GitHub doesn't have to create a ZIP from a tag
2020-09-07 02:31:33 +05:30
29d99c6866 Use releases instead of tags to download PowerShell PhpManager
I just started to publish PhpManager to GitHub Releases too
2020-09-07 02:20:16 +05:30
1444e002ab Replace fedora with valid platform name 2020-09-07 02:16:49 +05:30
03b97e24e9 Remove unnecessary parameter version from addArchive 2020-09-07 02:14:46 +05:30
f7fb800623 Bump version to 1.9.5
Switch to fixed getcomposer.org links

Add composer fallback
2020-08-16 07:26:49 +05:30
5593bd4bd3 Remove old PHPUnit on linux 2020-08-16 02:51:32 +05:30
3160874a27 Bump version to 1.9.4 2020-08-10 16:43:54 +05:30
db0bbd209b Change cURL opts 2020-08-10 16:43:54 +05:30
d920044a54 Limit swoole support to PHP 7.4 2020-08-10 16:43:53 +05:30
818ca89f55 Accept PECL default parameters 2020-08-10 16:43:47 +05:30
8876ac788f Use shivammathur/php-builder-windows for PHP 8 on Windows 2020-08-03 14:18:17 +05:30
0390a48770 Remove obsolete pcov.sh 2020-08-03 14:09:32 +05:30
274e348895 Use default packagist mirror for old PHP 2020-08-03 14:06:14 +05:30
37d7b37f43 Remove update_extension from linux.sh 2020-08-03 14:05:42 +05:30
d058d52012 Bump supported version in SECURITY.md 2020-08-03 14:00:18 +05:30
17983e66e5 Bump version to 1.9.3 2020-07-20 20:58:08 +05:30
33a005dd90 Fix logs 2020-07-20 20:58:07 +05:30
1870ffc08c Fix Typo 2020-07-20 17:32:29 +05:30
70fd71ab48 Set memory_limit=-1 on Windows and macOS 2020-07-20 17:28:41 +05:30
2f1900f7bc Fix support for pre-release extensions 2020-07-20 17:25:25 +05:30
19497a0597 Improve updating lists 2020-07-20 17:20:16 +05:30
5b2e081bc0 Install only cli on linux 2020-07-20 17:10:20 +05:30
66fa82fbca Fix coverage 2020-07-20 17:10:19 +05:30
4aa42214b1 Update extensions.test.ts 2020-07-20 17:10:18 +05:30
1e2c96a4b4 Fixed xdebug version for PHP 5.6 and 7.0 2020-07-20 17:10:17 +05:30
3e8d887b0d Set ini values after coverage setup 2020-07-20 17:10:16 +05:30
a3d5500a6a Improve composer setup 2020-07-20 17:10:09 +05:30
e763fddf01 Remove update_formulae in darwin.sh 2020-07-07 00:47:45 +05:30
3cd5c7fd3a Bump version to 1.9.2 2020-07-03 17:46:15 +05:30
988cef62da Add ondrej's PPA on focal 2020-07-03 15:18:11 +05:30
be3ee05178 Use shivammathur/extensions tap for grpc, swoole, protobuf on macos 2020-07-03 15:06:42 +05:30
a74c3369c5 Bump version to 1.9.1 2020-06-20 01:02:16 +05:30
b9ef39c812 Remove dashes from step ids 2020-06-20 01:02:16 +05:30
782615d572 Remove --no-suggest flag in examples 2020-06-20 01:02:15 +05:30
31411b0d4d Improve extension support 2020-06-20 01:02:10 +05:30
6b93e48d83 Fix Xdebug coverage 2020-06-19 17:36:28 +05:30
fe504c5e23 Bump version to 1.9.0 2020-06-09 07:17:38 +05:30
61d755bd59 Fix updating powershell profile 2020-06-08 03:02:40 +05:30
3455b4ca37 Add support for updating composer 2020-06-08 02:15:24 +05:30
35c24a7d2f Refactor linux.sh and fetch nightly script 2020-06-08 02:00:47 +05:30
da7361cc8f Use Invoke-RestMethod to get tag 2020-06-08 01:36:03 +05:30
3f4c1842a0 Remove empty line in logs 2020-06-08 01:34:16 +05:30
062567eeb1 Setup libwebp-dev with PHP8 on linux 2020-05-18 22:34:49 +05:30
00b0d694d0 Update PPA before phalcon setup 2020-05-18 18:03:51 +05:30
54afb29ef6 Update PPA in add_devtools in linux.sh 2020-05-18 17:43:52 +05:30
41329810ef Bump version to 1.8.8 2020-05-17 03:25:48 +05:30
90a6d88c24 Update README.md 2020-05-17 03:25:42 +05:30
8e6968c49e Fix support for phalcon and gearman 2020-05-15 23:34:59 +05:30
4ce413f558 Improve composer support 2020-05-15 23:34:58 +05:30
533e0949a8 cleanup darwin.sh 2020-05-15 23:34:57 +05:30
0ffe535b8e Refactor win32.ps1 2020-05-15 23:34:56 +05:30
55fe8db60d Refactor linux.sh 2020-05-15 23:34:51 +05:30
5af5f992ec Suppress php-config error 2020-05-13 20:36:57 +05:30
e9e024e600 Fix loading PECL extensions 2020-05-05 14:57:36 +05:30
a7ea0636d7 Fix icu4c version for PHP 5.6 and PHP 7.0 on darwin 2020-04-30 16:59:19 +05:30
c471c0a458 Fix libzip-dev error in PHP 8.0 on ubuntu 2020-04-30 07:36:55 +05:30
277239149a Fetch formulae before setup 2020-04-23 16:16:33 +05:30
9385896f2a Bump version to 1.8.7 2020-04-09 21:35:02 +05:30
9cabd8564d Recompile PCOV for PHP8 2020-04-09 21:26:32 +05:30
fdfa901941 Update all lists 2020-03-20 19:04:24 +05:30
527cd148c8 Bump version to 1.8.6 2020-03-18 16:15:06 +05:30
59b6e2b54a Install PhpManager from GitHub repo 2020-03-18 16:15:01 +05:30
5ad0888329 Fix db extensions 2020-03-16 08:04:49 +05:30
3cfc409e14 Bump version to 1.8.5 2020-03-14 09:12:58 +05:30
ebc671081f Bump ECMAScript version 2020-03-14 07:56:11 +05:30
efae663c0f Change case in README 2020-03-14 07:54:36 +05:30
fa8a671e6f Improve code quality 2020-03-14 07:53:43 +05:30
6a4159ba98 Improve extension support 2020-03-14 07:42:02 +05:30
0da52b1327 v1 maintenance release - 1.8.4 2020-03-02 20:40:27 +05:30
3579c7ef28 v1 maintenance release 2020-02-17 03:49:19 +05:30
72 changed files with 1115 additions and 2997 deletions

View File

@ -9,12 +9,11 @@ Please note that this project is released with a [Contributor Code of Conduct](C
* Fork the project. * Fork the project.
* Make your bug fix or feature addition. * Make your bug fix or feature addition.
* Add tests for it. This is important so we don't break it in a future version unintentionally. * Add tests for it. This is important so we don't break it in a future version unintentionally.
* If editing the scripts, create a demo integration test. * Send a pull request to the develop branch.
* Send a pull request to the develop branch with all the details.
Please make sure that you have [set up your user name and email address](https://git-scm.com/book/en/v2/Getting-Started-First-Time-Git-Setup) for use with Git. Strings such as `silly nick name <root@localhost>` look really stupid in the commit history of a project. Please make sure that you have [set up your user name and email address](https://git-scm.com/book/en/v2/Getting-Started-First-Time-Git-Setup) for use with Git. Strings such as `silly nick name <root@localhost>` look really stupid in the commit history of a project.
Due to time constraints, you may not always get a quick response. Please do not take delays personally and feel free to remind. Due to time constraints, you may not always get a quick response. Please do not take delays personal and feel free to remind.
## Coding Guidelines ## Coding Guidelines

View File

@ -1,42 +1,23 @@
--- ---
name: Bug report name: Bug report
about: Nice, you found a bug! about: Create a report to help us improve
title: '' title: ''
labels: 'bug' labels: ''
assignees: 'shivammathur' assignees: ''
--- ---
**Describe the bug** **Describe the bug**
<!-- Please describe the bug concisely. --> A clear and concise description of what the bug is.
**Version**
- [ ] I have checked releases and the bug exists in the latest patch version of `v1` or `v2`.
- [ ] `v2`
- [ ] `v1`
**Runners**
<!-- Please mark the GitHub Action runner your workflow uses. -->
- [ ] GitHub Hosted
- [ ] Self Hosted
**Operating systems**
<!-- Please mention the operating systems your workflow uses. -->
**PHP versions**
<!-- Please mention the PHP versions your workflow uses. -->
**To Reproduce** **To Reproduce**
<!-- Please provide the relevant steps of your workflow `.yml` file. --> Please provide the GitHub Action `.yml` file.
**Expected behavior** **Expected behavior**
<!-- A clear and concise description of what you expected to happen. --> A clear and concise description of what you expected to happen.
**Screenshots/Logs** **Screenshots**
<!-- If applicable, add screenshots or logs to help explain your problem. --> If applicable, add screenshots to help explain your problem.
**Additional context** **Additional context**
<!-- Add any other context about the problem here. --> Add any other context about the problem here.
**Are you willing to submit a PR?**
<!-- We accept pull requests targeting the develop branch. -->

View File

@ -1,26 +1,20 @@
--- ---
name: Feature request name: Feature request
about: Suggest a new feature about: Suggest an idea for this project
title: '' title: ''
labels: 'enhancement' labels: ''
assignees: 'shivammathur' assignees: ''
--- ---
**Describe the feature** **Is your feature request related to a problem? Please describe.**
<!-- Please describe concisely the feature you want to add. --> A clear and concise description of what the problem is. Ex. I want to improve [...]
**Version** **Describe the solution you'd like**
- [ ] I have checked releases and the feature is missing in the latest patch version of `v2`. A clear and concise description of what you want to happen.
**Underlying issue** **Describe alternatives you've considered**
<!-- Please describe the issue this would solve. --> A clear and concise description of any alternative solutions or features you've considered.
**Describe alternatives**
<!-- Please mention any alternative solutions you've considered. -->
**Additional context** **Additional context**
<!-- Add any other context or screenshots about the feature request here. --> Add any other context or screenshots about the feature request here.
**Are you willing to submit a PR?**
<!-- We accept pull requests targeting the develop branch. -->

View File

@ -7,13 +7,14 @@ labels: bug or enhancement
## A Pull Request should be associated with an Issue. ## A Pull Request should be associated with an Issue.
> If you're fixing a bug, adding a new feature or improving something please provide the details in Issues, > We wish to have discussions in Issues. A single issue may be targeted by multiple PRs.
> so that the development can be pointed in the intended direction. > If you're offering a new feature or fixing anything, we'd like to know beforehand in Issues,
> and potentially we'll be able to point development in a particular direction.
Related issue: <!-- Please link the related issue --> Related issue:
> Further notes in [Contribution Guidelines](.github/CONTRIBUTING.md) > Further notes in [Contribution Guidelines](.github/CONTRIBUTING.md)
> Thank you for your contribution. > Thank you! We are open to PRs, but please understand if for technical reasons we are unable to accept each and any PR
### Description ### Description
@ -25,12 +26,7 @@ This PR [briefly explain what it does]
- [ ] I have run `npm run format` before the commit. - [ ] I have run `npm run format` before the commit.
- [ ] I have run `npm run lint` before the commit. - [ ] I have run `npm run lint` before the commit.
- [ ] I have run `npm run release` before the commit. - [ ] I have run `npm run release` before the commit.
- [ ] `npm test` returns with no unit test errors and all code covered. - [ ] `npm test` returns with no unit test errors.
> 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).
<!-- <!--
- Please target the develop branch when submitting the pull request. - Please target the develop branch when submitting the pull request.

2
.github/SECURITY.md vendored
View File

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

View File

@ -3,17 +3,13 @@ on:
workflow_dispatch: workflow_dispatch:
pull_request: pull_request:
branches: branches:
- master - releases/v1
- develop
- verbose
paths-ignore: paths-ignore:
- '**.md' - '**.md'
- 'examples/**' - 'examples/**'
push: push:
branches: branches:
- master - releases/v1
- develop
- verbose
paths-ignore: paths-ignore:
- '**.md' - '**.md'
- 'examples/**' - 'examples/**'
@ -25,35 +21,17 @@ jobs:
fail-fast: false fail-fast: false
matrix: matrix:
operating-system: [ubuntu-20.04, ubuntu-18.04, ubuntu-16.04, windows-latest, macos-latest] operating-system: [ubuntu-20.04, ubuntu-18.04, ubuntu-16.04, windows-latest, macos-latest]
php-versions: ['5.3', '5.4', '5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0'] php-versions: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0']
env:
extensions: xml, opcache, xdebug, pcov
key: cache-v3
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Setup cache environment
id: extcache
uses: shivammathur/cache-extensions@develop
with:
php-version: ${{ matrix.php-versions }}
extensions: ${{ env.extensions }}
key: ${{ env.key }}
- name: Cache extensions
uses: actions/cache@v2
with:
path: ${{ steps.extcache.outputs.dir }}
key: ${{ steps.extcache.outputs.key }}
restore-keys: ${{ steps.extcache.outputs.key }}
- name: Setup PHP with extensions and custom config - name: Setup PHP with extensions and custom config
run: node dist/index.js run: node dist/index.js
env: env:
php-version: ${{ matrix.php-versions }} php-version: ${{ matrix.php-versions }}
extensions: ${{ env.extensions }} extensions: xml, opcache, xdebug, pcov #optional
ini-values: post_max_size=256M, short_open_tag=On, date.timezone=Asia/Kolkata ini-values: post_max_size=256M, short_open_tag=On, date.timezone=Asia/Kolkata #optional
- name: Testing PHP version - name: Testing PHP version
run: | run: |

View File

@ -2,17 +2,13 @@ name: Node workflow
on: on:
pull_request: pull_request:
branches: branches:
- master - releases/v1
- develop
- verbose
paths-ignore: paths-ignore:
- '**.md' - '**.md'
- 'examples/**' - 'examples/**'
push: push:
branches: branches:
- master - releases/v1
- develop
- verbose
paths-ignore: paths-ignore:
- '**.md' - '**.md'
- 'examples/**' - 'examples/**'

528
README.md
View File

@ -8,14 +8,9 @@
<p align="center"> <p align="center">
<a href="https://github.com/shivammathur/setup-php" title="GitHub action to setup PHP"><img alt="GitHub Actions status" src="https://github.com/shivammathur/setup-php/workflows/Main%20workflow/badge.svg"></a> <a href="https://github.com/shivammathur/setup-php" title="GitHub action to setup PHP"><img alt="GitHub Actions status" src="https://github.com/shivammathur/setup-php/workflows/Main%20workflow/badge.svg"></a>
<a href="https://codecov.io/gh/shivammathur/setup-php" title="Code coverage"><img alt="Codecov Code Coverage" src="https://codecov.io/gh/shivammathur/setup-php/branch/master/graph/badge.svg"></a> <a href="https://codecov.io/gh/shivammathur/setup-php" title="Code coverage"><img alt="Codecov Code Coverage" src="https://img.shields.io/codecov/c/github/shivammathur/setup-php?logo=codecov"></a>
<a href="https://github.com/shivammathur/setup-php/blob/master/LICENSE" title="license"><img alt="LICENSE" src="https://img.shields.io/badge/license-MIT-428f7e.svg?logo=open%20source%20initiative&logoColor=white&labelColor=555555"></a> <a href="https://github.com/shivammathur/setup-php/blob/master/LICENSE" title="license"><img alt="LICENSE" src="https://img.shields.io/badge/license-MIT-428f7e.svg"></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-%3E%3D%205.6-8892BF.svg"></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>
<a href="https://twitter.com/setup_php" title="setup-php twitter"><img alt="setup-php twitter" src="https://img.shields.io/badge/twitter-follow-1DA1F2?logo=twitter&logoColor=1DA1F2&labelColor=555555"></a>
<a href="https://setup-php.statuspage.io/" title="setup-php status"><img alt="setup-php status" src="https://img.shields.io/badge/status-subscribe-28A745?logo=statuspage&logoColor=28A745&labelColor=555555"></a>
</p> </p>
Setup PHP with required extensions, php.ini configuration, code-coverage support and various tools like composer in [GitHub Actions](https://github.com/features/actions "GitHub Actions"). This action gives you a cross platform interface to setup the PHP environment you need to test your application. Refer to [Usage](#memo-usage "How to use this") section and [examples](#examples "Examples of use") to see how to use this. Setup PHP with required extensions, php.ini configuration, code-coverage support and various tools like composer in [GitHub Actions](https://github.com/features/actions "GitHub Actions"). This action gives you a cross platform interface to setup the PHP environment you need to test your application. Refer to [Usage](#memo-usage "How to use this") section and [examples](#examples "Examples of use") to see how to use this.
@ -23,60 +18,43 @@ Setup PHP with required extensions, php.ini configuration, code-coverage support
## Contents ## Contents
- [PHP Support](#tada-php-support) - [PHP Support](#tada-php-support)
- [OS/Platform Support](#cloud-osplatform-support) - [GitHub-Hosted Runner Support](#cloud-github-hosted-runner-support)
- [GitHub-Hosted Runners](#github-hosted-runners)
- [Self-Hosted Runners](#self-hosted-runners)
- [PHP Extension Support](#heavy_plus_sign-php-extension-support) - [PHP Extension Support](#heavy_plus_sign-php-extension-support)
- [Tools Support](#wrench-tools-support) - [Tools Support](#wrench-tools-support)
- [Coverage Support](#signal_strength-coverage-support) - [Coverage Support](#signal_strength-coverage-support)
- [Xdebug](#xdebug) - [Xdebug](#xdebug)
- [PCOV](#pcov) - [PCOV](#pcov)
- [Disable Coverage](#disable-coverage) - [Disable coverage](#disable-coverage)
- [Usage](#memo-usage) - [Usage](#memo-usage)
- [Inputs](#inputs)
- [Basic Setup](#basic-setup) - [Basic Setup](#basic-setup)
- [Matrix Setup](#matrix-setup) - [Matrix Setup](#matrix-setup)
- [Nightly Build Setup](#nightly-build-setup) - [Nightly Build Setup](#nightly-build-setup)
- [Self Hosted Setup](#self-hosted-setup)
- [Local Testing Setup](#local-testing-setup)
- [Thread Safe Setup](#thread-safe-setup) - [Thread Safe Setup](#thread-safe-setup)
- [Force Update](#force-update) - [Cache Dependencies](#cache-dependencies)
- [Verbose Setup](#verbose-setup)
- [Cache Extensions](#cache-extensions)
- [Cache Composer Dependencies](#cache-composer-dependencies)
- [Cache Node.js Dependencies](#cache-nodejs-dependencies)
- [Composer GitHub OAuth](#composer-github-oauth) - [Composer GitHub OAuth](#composer-github-oauth)
- [Problem Matchers](#problem-matchers) - [Problem Matchers](#problem-matchers)
- [Examples](#examples) - [Examples](#examples)
- [Versioning](#bookmark-versioning)
- [License](#scroll-license) - [License](#scroll-license)
- [Contributions](#1-contributions) - [Contributions](#1-contributions)
- [Support This Project](#sparkling_heart-support-this-project) - [Support This project](#sparkling_heart-support-this-project)
- [Dependencies](#package-dependencies) - [Dependencies](#bookmark-dependencies)
- [Further Reading](#bookmark_tabs-further-reading) - [Further Reading](#bookmark_tabs-further-reading)
## :tada: PHP Support ## :tada: PHP Support
|PHP Version|Stability|Release Support|Runner Support| |PHP Version|Stability|Release Support|
|--- |--- |--- |--- | |--- |--- |--- |
|`5.3`|`Stable`|`End of life`|`GitHub-hosted`| |5.6|`Stable`|`End of life`|
|`5.4`|`Stable`|`End of life`|`GitHub-hosted`| |7.0|`Stable`|`End of life`|
|`5.5`|`Stable`|`End of life`|`GitHub-hosted`| |7.1|`Stable`|`End of life`|
|`5.6`|`Stable`|`End of life`|`GitHub-hosted`, `self-hosted`| |7.2|`Stable`|`Security fixes only`|
|`7.0`|`Stable`|`End of life`|`GitHub-hosted`, `self-hosted`| |7.3|`Stable`|`Active`|
|`7.1`|`Stable`|`End of life`|`GitHub-hosted`, `self-hosted`| |7.4|`Stable`|`Active`|
|`7.2`|`Stable`|`Security fixes only`|`GitHub-hosted`, `self-hosted`| |8.0|`Nightly`|`In development`|
|`7.3`|`Stable`|`Active`|`GitHub-hosted`, `self-hosted`|
|`7.4`|`Stable`|`Active`|`GitHub-hosted`, `self-hosted`|
|`8.0`|`Nightly`|`In development`|`GitHub-hosted`, `self-hosted`|
**Note:** Specifying `8.0` in `php-version` input installs a nightly build of `PHP 8.0.0-dev` with `PHP JIT`, `Union Types v2` and other [new features](https://wiki.php.net/rfc#php_80 "New features implemented in PHP 8"). See [nightly build setup](#nightly-build-setup) for more information. **Note:** Specifying `8.0` in `php-version` input installs a nightly build of `PHP 8.0.0-dev` with `PHP JIT`, `Union Types v2` and other [new features](https://wiki.php.net/rfc#php_80 "New features implemented in PHP 8"). See [nightly build setup](#nightly-build-setup) for more information.
## :cloud: OS/Platform Support ## :cloud: GitHub-Hosted Runner Support
Both `GitHub-hosted` runners and `self-hosted` runners are supported on the following operating systems.
### GitHub-Hosted Runners
|Virtual environment|YAML workflow label|Pre-installed PHP| |Virtual environment|YAML workflow label|Pre-installed PHP|
|--- |--- |--- | |--- |--- |--- |
@ -84,128 +62,49 @@ Both `GitHub-hosted` runners and `self-hosted` runners are supported on the foll
|Ubuntu 18.04|`ubuntu-latest` or `ubuntu-18.04`|`PHP 7.1` to `PHP 7.4`| |Ubuntu 18.04|`ubuntu-latest` or `ubuntu-18.04`|`PHP 7.1` to `PHP 7.4`|
|Ubuntu 20.04|`ubuntu-20.04`|`PHP 7.4`| |Ubuntu 20.04|`ubuntu-20.04`|`PHP 7.4`|
|Windows Server 2019|`windows-latest` or `windows-2019`|`PHP 7.4`| |Windows Server 2019|`windows-latest` or `windows-2019`|`PHP 7.4`|
|macOS Catalina 10.15|`macos-latest` or `macos-10.15`|`PHP 7.4`| |macOS 10.15 Catalina|`macos-latest` or `macos-10.15`|`PHP 7.4`|
### Self-Hosted Runners
|Host OS/Virtual environment|YAML workflow label|
|--- |--- |
|Ubuntu 16.04|`self-hosted` or `Linux`|
|Ubuntu 18.04|`self-hosted` or `Linux`|
|Ubuntu 20.04|`self-hosted` or `Linux`|
|Windows 7 and newer|`self-hosted` or `Windows`|
|Windows Server 2012 R2 and newer|`self-hosted` or `Windows`|
|macOS Catalina 10.15|`self-hosted` or `macOS`|
- Refer to the [self-hosted setup](#self-hosted-setup) to use the action on self-hosted runners.
## :heavy_plus_sign: PHP Extension Support ## :heavy_plus_sign: PHP Extension Support
- On `ubuntu` by default extensions which are available as a package can be installed. If the extension is not available as a package but it is on `PECL`, it can be installed by specifying `pecl` in the tools input.
- On `ubuntu` by default extensions which are available as a package can be installed. PECL extensions if not available as a package can be installed by specifying `pecl` in the tools input. - On `windows` extensions which have `windows` binary on `PECL` can be installed.
- On `macOS` extensions which are on `PECL` can be installed.
```yaml - Extensions which are installed along with PHP if specified are enabled.
- name: Setup PHP with pecl extension - Extensions on `PECL` which do not have a latest stable version, their pre-release versions can be installed by suffixing the extension with its state i.e `alpha`, `beta`, `devel` or `snapshot` separated by a `-` like `msgpack-beta`.
uses: shivammathur/setup-php@v2 - Extensions which cannot be installed gracefully leave an error message in the logs, the action is not interrupted.
with:
php-version: '7.4'
tools: pecl
extensions: swoole
```
- On `windows` PECL extensions which have the `DLL` binary can be installed.
- On `macOS` PECL extensions can be installed.
- Extensions installed along with PHP if specified are enabled.
- Specific versions of PECL extensions can be installed by suffixing the version. This is useful for installing old versions of extensions which support end of life PHP versions.
```yaml
- name: Setup PHP with specific version of PECL extension
uses: shivammathur/setup-php@v2
with:
php-version: '5.4'
tools: pecl
extensions: swoole-1.9.3
```
- Pre-release versions of PECL extensions can be setup by suffixing the extension with its state i.e `alpha`, `beta`, `devel` or `snapshot`.
```yaml
- name: Setup PHP with pre-release PECL extension
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
tools: pecl
extensions: xdebug-beta
```
- Shared extensions can be removed by prefixing them with a `:`.
```yaml
- name: Setup PHP and remove shared extension
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
extensions: :opcache
```
- Extension `intl` can be setup with specific `ICU` version for `PHP 5.6` to `PHP 7.4` in `Ubuntu` workflows by suffixing `intl` with the `ICU` version. `ICU 50.2` and newer versions are supported. Refer to [`ICU builds`](https://github.com/shivammathur/icu-intl#icu4c-builds) for the specific versions supported.
```yaml
- name: Setup PHP with intl
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
extensions: intl-67.1
```
- Extensions which cannot be added or removed gracefully leave an error message in the logs, the action is not interrupted.
- 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.
## :wrench: Tools Support ## :wrench: Tools Support
These tools can be setup globally using the `tools` input. These tools can be setup globally using the `tools` input.
`blackfire`, `blackfire-player`, `codeception`, `composer`, `composer-normalize`, `composer-prefetcher`, `composer-require-checker`, `composer-unused`, `cs2pr`, `deployer`, `flex`, `grpc_php_plugin`, `infection`, `pecl`, `phan`, `phing`, `phinx`, `phive`, `phpcbf`, `phpcpd`, `php-config`, `php-cs-fixer`, `phpcs`, `phpize`, `phpmd`, `phpstan`, `phpunit`, `prestissimo`, `protoc`, `psalm`, `symfony`, `vapor-cli` `codeception`, `composer`, `composer-prefetcher`, `cs2pr`, `deployer`, `pecl`, `phinx`, `phive`, `phpcbf`, `phpcpd`, `php-config`, `php-cs-fixer`, `phpcs`, `phpize`, `phpmd`, `phpstan`, `phpunit`, `prestissimo`, `psalm`, `symfony`
```yaml ```yaml
- name: Setup PHP with tools uses: shivammathur/setup-php@v1
uses: shivammathur/setup-php@v2
with: with:
php-version: '7.4' php-version: '7.4'
tools: php-cs-fixer, phpunit tools: php-cs-fixer, phpunit
``` ```
To setup a particular version of a tool, specify it in the form `tool:version`. To setup a particular version of a tool, specify it in the form `tool:version`.
Latest stable version of `composer` is setup by default. You can setup the required version by specifying `v1`, `v2`, `snapshot` or `preview` as version. Latest stable version of `composer` is setup by default and accepts `v1`, `v2`, `snapshot` and `preview` as versions.
```yaml ```yaml
- name: Setup PHP with composer v2 uses: shivammathur/setup-php@v1
uses: shivammathur/setup-php@v2
with: with:
php-version: '7.4' php-version: '7.4'
tools: composer:v2 tools: composer:v2
``` ```
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. 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 setup `PHPUnit` on `PHP 7.2`.
```yaml ```yaml
- name: Setup PHP with tools uses: shivammathur/setup-php@v1
uses: shivammathur/setup-php@v2
with: with:
php-version: '7.2' php-version: '7.4'
tools: phpunit:8.5.8 tools: php-cs-fixer:2.16.2, phpunit:8.5.1
``` ```
**Notes** Tools which cannot be installed gracefully leave an error message in the logs, the action is not interrupted.
- If you have a tool in your `composer.json`, do not setup it globally using this action as the two instances of the tool might conflict.
- Tools which cannot be setup gracefully leave an error message in the logs, the action is not interrupted.
## :signal_strength: Coverage Support ## :signal_strength: Coverage Support
@ -215,8 +114,7 @@ Specify `coverage: xdebug` to use `Xdebug`.
Runs on all [PHP versions supported](#tada-php-support "List of PHP versions supported on this GitHub Action"). Runs on all [PHP versions supported](#tada-php-support "List of PHP versions supported on this GitHub Action").
```yaml ```yaml
- name: Setup PHP with Xdebug uses: shivammathur/setup-php@v1
uses: shivammathur/setup-php@v2
with: with:
php-version: '7.4' php-version: '7.4'
coverage: xdebug coverage: xdebug
@ -225,43 +123,30 @@ Runs on all [PHP versions supported](#tada-php-support "List of PHP versions sup
### PCOV ### PCOV
Specify `coverage: pcov` to use `PCOV` and disable `Xdebug`. Specify `coverage: pcov` to use `PCOV` and disable `Xdebug`.
`PCOV` supports `PHP 7.1` and newer PHP versions. It is much faster than `Xdebug`.
Tests with `PCOV` run much faster than with `Xdebug`. `PCOV` needs `PHP >= 7.1`.
If your source code directory is other than `src`, `lib` or, `app`, specify `pcov.directory` using the `ini-values` input. If your source code directory is other than `src`, `lib` or, `app`, specify `pcov.directory` using the `ini-values` input.
```yaml ```yaml
- name: Setup PHP with PCOV uses: shivammathur/setup-php@v1
uses: shivammathur/setup-php@v2
with: with:
php-version: '7.4' php-version: '7.4'
ini-values: pcov.directory=api #optional, see above for usage. ini-values: pcov.directory=api #optional, see above for usage.
coverage: pcov coverage: pcov
``` ```
`PHPUnit` 8 and above supports `PCOV` out of the box.
If you are using `PHPUnit` 5, 6 or 7, you will need `krakjoe/pcov-clobber`.
Before executing your tests add the following step.
```yaml
- name: Setup PCOV
run: |
composer require pcov/clobber
vendor/bin/pcov clobber
```
### Disable Coverage ### Disable Coverage
Specify `coverage: none` to remove both `Xdebug` and `PCOV`. Specify `coverage: none` to disable both `Xdebug` and `PCOV`.
Consider disabling the coverage using this PHP action for these reasons. Consider disabling the coverage using this PHP action for these reasons.
- You are not generating coverage reports while testing. - You are not generating coverage reports while testing.
- It will remove `Xdebug`, which will have a positive impact on PHP performance. - It will remove `Xdebug`, which will have a positive impact on PHP performance.
- You are using `phpdbg` for running your tests. - You are using `phpdbg` for running your tests.
- You are profiling your code using `blackfire`.
```yaml ```yaml
- name: Setup PHP with no coverage driver uses: shivammathur/setup-php@v1
uses: shivammathur/setup-php@v2
with: with:
php-version: '7.4' php-version: '7.4'
coverage: none coverage: none
@ -269,39 +154,15 @@ Consider disabling the coverage using this PHP action for these reasons.
## :memo: Usage ## :memo: Usage
### Inputs Inputs supported by this GitHub Action.
#### `php-version` (required) - php-version `required`
- extensions `optional`
- ini-values `optional`
- coverage `optional`
- tools `optional`
- Specify the PHP version you want to setup. See [action.yml](action.yml "Metadata for this GitHub Action") and usage below for more info.
- Accepts a `string`. For example `'7.4'`.
- See [PHP support](#tada-php-support) for supported PHP versions.
#### `extensions` (optional)
- Specify the extensions you want to add or remove.
- Accepts a `string` in csv-format. For example `mbstring, :opcache`.
- Non-default extensions prefixed with `:` are removed.
- See [PHP extension support](#heavy_plus_sign-php-extension-support) for more info.
#### `ini-values` (optional)
- Specify the values you want to add to `php.ini`.
- Accepts a `string` in csv-format. For example `post_max_size=256M, short_open_tag=On`.
#### `coverage` (optional)
- Specify the code coverage driver you want to setup.
- Accepts `xdebug`, `pcov` or `none`.
- See [coverage support](#signal_strength-coverage-support) for more info.
#### `tools` (optional)
- Specify the tools you want to setup.
- Accepts a `string` in csv-format. For example `phpunit, phpcs`
- See [tools Support](#wrench-tools-support) for tools supported.
See below for more info.
### Basic Setup ### Basic Setup
@ -313,13 +174,13 @@ steps:
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Setup PHP - name: Setup PHP
uses: shivammathur/setup-php@v2 uses: shivammathur/setup-php@v1
with: with:
php-version: '7.4' php-version: '7.4'
extensions: mbstring, intl extensions: mbstring, intl #optional, setup extensions
ini-values: post_max_size=256M, short_open_tag=On ini-values: post_max_size=256M, short_open_tag=On #optional, setup php.ini configuration
coverage: xdebug coverage: xdebug #optional, setup coverage driver
tools: php-cs-fixer, phpunit tools: php-cs-fixer, phpunit #optional, setup tools globally
``` ```
### Matrix Setup ### Matrix Setup
@ -340,22 +201,21 @@ jobs:
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Setup PHP - name: Setup PHP
uses: shivammathur/setup-php@v2 uses: shivammathur/setup-php@v1
with: with:
php-version: ${{ matrix.php-versions }} php-version: ${{ matrix.php-versions }}
extensions: mbstring, intl extensions: mbstring, intl #optional, setup extensions
ini-values: post_max_size=256M, short_open_tag=On ini-values: post_max_size=256M, short_open_tag=On #optional, setup php.ini configuration
coverage: xdebug coverage: xdebug #optional, setup coverage driver
tools: php-cs-fixer, phpunit tools: php-cs-fixer, phpunit #optional, setup tools globally
``` ```
### Nightly Build Setup ### Nightly Build Setup
> Setup a nightly build of `PHP 8.0.0-dev` from the [master branch](https://github.com/php/php-src/tree/master "Master branch on PHP source repository") of PHP. > Setup a nightly build of `PHP 8.0.0-dev` from the [master branch](https://github.com/php/php-src/tree/master "Master branch on PHP source repository") of PHP.
- This version is currently in development. - `PECL` is installed by default with this version on `Ubuntu` and `macOS`.
- `PECL` is installed by default with this version on `ubuntu` and `macOS`. - Some extensions might not support this version currently.
- Some user space extensions might not support this version currently.
- Refer to this [RFC](https://wiki.php.net/rfc/jit "PHP JIT RFC configuration") for configuring `PHP JIT` on this version. - Refer to this [RFC](https://wiki.php.net/rfc/jit "PHP JIT RFC configuration") for configuring `PHP JIT` on this version.
- Refer to this [list of RFCs](https://wiki.php.net/rfc#php_80 "List of RFCs implemented in PHP8") implemented in this version. - Refer to this [list of RFCs](https://wiki.php.net/rfc#php_80 "List of RFCs implemented in PHP8") implemented in this version.
@ -364,92 +224,21 @@ steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Setup nightly PHP - name: Setup PHP
uses: shivammathur/setup-php@v2 uses: shivammathur/setup-php@v1
with: with:
php-version: '8.0' php-version: '8.0'
extensions: mbstring extensions: mbstring #optional, setup extensions
ini-values: opcache.jit_buffer_size=256M, opcache.jit=1235, pcre.jit=1 ini-values: opcache.jit_buffer_size=256M, opcache.jit=1235, pcre.jit=1 #optional, setup php.ini configuration
coverage: pcov coverage: pcov #optional, setup PCOV, Xdebug does not support this version yet.
tools: php-cs-fixer, phpunit tools: php-cs-fixer, phpunit #optional, setup tools globally
```
### Self Hosted Setup
> Setup PHP on a self-hosted runner.
- To setup a dockerized self-hosted runner, refer to this [guide](https://github.com/shivammathur/setup-php/wiki/Dockerized-self-hosted-runner-on-Ubuntu) to setup in an `Ubuntu` container and refer to this [guide](https://github.com/shivammathur/setup-php/wiki/Dockerized-self-hosted-runner-on-Windows) to setup in a `Windows` container.
- To setup the runner directly on the host OS or in a virtual machine, follow this [requirements guide](https://github.com/shivammathur/setup-php/wiki/Requirements-for-self-hosted-runners "Requirements guide for self-hosted runner to run setup-php") before setting up the self-hosted runner.
- If your workflow uses [services](https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idservices "GitHub Actions Services"), then setup the runner on a Linux host or in a Linux virtual machine. GitHub Actions does not support nested virtualization on Linux, so services will not work in a dockerized container.
Specify the environment variable `runner` with the value `self-hosted`. Without this your workflow will fail.
```yaml
jobs:
run:
runs-on: self-hosted
strategy:
matrix:
php-versions: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0']
name: PHP ${{ matrix.php-versions }}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
env:
runner: self-hosted # Specify the runner.
```
**Notes**
- Do not setup multiple self-hosted runners on the 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.
### Local Testing Setup
> Test your `Ubuntu` workflow locally using [`nektos/act`](https://github.com/nektos/act "Project to test GitHub Actions locally").
```yaml
jobs:
run:
runs-on: ubuntu-latest
name: PHP 7.4 Test
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 7.4
```
Run the workflow locally with `act` using [`shivammathur/node`](https://github.com/shivammathur/node-docker "Docker image to run setup-php") docker image.
```bash
# For runs-on: ubuntu-latest
act -P ubuntu-latest=shivammathur/node:latest
# For runs-on: ubuntu-20.04
act -P ubuntu-20.04=shivammathur/node:focal
# For runs-on: ubuntu-18.04
act -P ubuntu-18.04=shivammathur/node:bionic
# For runs-on: ubuntu-16.04
act -P ubuntu-16.04=shivammathur/node:xenial
``` ```
### Thread Safe Setup ### Thread Safe Setup
> Setup both `TS` and `NTS` PHP on `Windows`.
- `NTS` versions are setup by default. - `NTS` versions are setup by default.
- On `Ubuntu` and `macOS` only `NTS` versions are supported. - On `ubuntu` and `macOS` only NTS versions are supported.
- On `Windows` both `TS` and `NTS` versions are supported. - On `windows` both `TS` and `NTS` versions are supported.
```yaml ```yaml
jobs: jobs:
@ -461,50 +250,18 @@ jobs:
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Setup PHP - name: Setup PHP
uses: shivammathur/setup-php@v2 uses: shivammathur/setup-php@v1
with: with:
php-version: '7.4' php-version: '7.4'
env: env:
phpts: ts # specify ts or nts phpts: ts # specify ts or nts
``` ```
### Force Update ### Cache Dependencies
> Update to latest patch of PHP versions. You can persist composer's internal cache directory using the [`action/cache`](https://github.com/actions/cache "GitHub Action to cache files") GitHub Action. Dependencies cached are loaded directly instead of downloading them while installation. The files cached are available across check-runs and will reduce the workflow execution time.
- Pre-installed PHP versions on the GitHub Actions runner are not updated to their latest patch release by default. **Note:** Please do not cache `vendor` directory using `action/cache` as that will have side-effects.
- You can specify the `update` environment variable to `true` to force update to the latest release.
```yaml
- name: Setup PHP with latest versions
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
env:
update: true # specify true or false
```
### Verbose Setup
> Debug your workflow
To debug any issues, you can use the `verbose` tag instead of `v2`.
```yaml
- name: Setup PHP with logs
uses: shivammathur/setup-php@verbose
with:
php-version: '7.4'
```
### Cache Extensions
You can cache PHP extensions using `shivammathur/cache-extensions` and `action/cache` GitHub Actions. Extensions which take very long to setup when cached are available in the next workflow run and are enabled directly. This reduces the workflow execution time.
Refer to [`shivammathur/cache-extensions`](https://github.com/shivammathur/cache-extensions "GitHub Action to cache php extensions") for details.
### Cache Composer Dependencies
If your project uses composer, you can persist composer's internal cache directory. Dependencies cached are loaded directly instead of downloading them while installation. The files cached are available across check-runs and will reduce the workflow execution time.
```yaml ```yaml
- name: Get composer cache directory - name: Get composer cache directory
@ -518,40 +275,19 @@ If your project uses composer, you can persist composer's internal cache directo
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer- restore-keys: ${{ runner.os }}-composer-
- name: Install dependencies - name: Install Dependencies
run: composer install --prefer-dist run: composer install --prefer-dist
``` ```
**Notes** 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.
- 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.
```yaml ```yaml
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
``` ```
### Cache Node.js Dependencies
If your project has node.js dependencies, you can persist npm's or yarn's 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
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 }}
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} # Use '**/yarn.lock' for yarn
restore-keys: ${{ runner.os }}-node-
```
**Note:** Please do not cache `node_modules` directory as that will have side-effects.
### Composer GitHub OAuth ### Composer GitHub OAuth
If you have a number of workflows which setup multiple tools or have many composer dependencies, you might hit the GitHub's rate limit for composer. To avoid that you can add an `OAuth` token to the composer's config by setting `COMPOSER_TOKEN` environment variable. You can use [`GITHUB_TOKEN`](https://help.github.com/en/actions/configuring-and-managing-workflows/authenticating-with-the-github_token "GITHUB_TOKEN documentation") secret for this purpose. If you have a number of workflows which setup multiple tools or have many composer dependencies, you might hit the GitHub's rate limit for composer. To avoid that you can add a `OAuth` token to the composer's config by setting `COMPOSER_TOKEN` environment variable. You can use [`GITHUB_TOKEN`](https://help.github.com/en/actions/configuring-and-managing-workflows/authenticating-with-the-github_token "GITHUB_TOKEN documentation") secret for this purpose.
```yaml ```yaml
- name: Setup PHP - name: Setup PHP
@ -564,9 +300,11 @@ If you have a number of workflows which setup multiple tools or have many compos
### Problem Matchers ### Problem Matchers
Problem matchers are `json` configurations which identify errors and warnings in your logs and surface that information prominently in the GitHub Actions UI by highlighting them and creating code annotations.
#### PHP #### PHP
Setup problem matchers for your `PHP` output by adding this step after the `setup-php` step. This will scan the logs for PHP errors and warnings, and surface them prominently in the GitHub Actions UI by creating annotations and log file decorations. Setup problem matchers for your `PHP` output by adding this step after the `setup-php` step.
```yaml ```yaml
- name: Setup problem matchers for PHP - name: Setup problem matchers for PHP
@ -575,39 +313,67 @@ Setup problem matchers for your `PHP` output by adding this step after the `setu
#### PHPUnit #### PHPUnit
Setup problem matchers for your `PHPUnit` output by adding this step after the `setup-php` step. This will scan the logs for failing tests and surface that information prominently in the GitHub Actions UI by creating annotations and log file decorations. Setup problem matchers for your `PHPUnit` output by adding this step after the `setup-php` step.
```yaml ```yaml
- name: Setup problem matchers for PHPUnit - name: Setup problem matchers for PHPUnit
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
``` ```
#### Other Tools #### PHPStan
For tools that support `checkstyle` reporting like `phpstan`, `psalm`, `php-cs-fixer` and `phpcs` you can use `cs2pr` to annotate your code. PHPStan supports error reporting in GitHub Actions, so no problem matchers are required.
For examples refer to [cs2pr documentation](https://github.com/staabm/annotate-pull-request-from-checkstyle).
> Here is an example with `phpstan`.
```yaml ```yaml
- name: Setup PHP - name: Setup PHP
uses: shivammathur/setup-php@v2 uses: shivammathur/setup-php@v2
with: with:
php-version: '7.4' php-version: '7.4'
tools: cs2pr, phpstan tools: phpstan
- name: PHPStan - name: Run PHPStan
run: phpstan analyse src --error-format=checkstyle | cs2pr run: phpstan analyse src
```
#### Psalm
Psalm supports error reporting in GitHub Actions with an output format `github`.
```yaml
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
tools: psalm
- name: Run Psalm
run: psalm --output-format=github
```
#### Tools with checkstyle support
For tools that support `checkstyle` reporting like `phpstan`, `psalm`, `php-cs-fixer` and `phpcs` you can use `cs2pr` to annotate your code.
For examples refer to [cs2pr documentation](https://github.com/staabm/annotate-pull-request-from-checkstyle).
> Here is an example with `phpcs`.
```yaml
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
tools: cs2pr, phpcs
- name: Run phpcs
run: phpcs -q --report=checkstyle src | cs2pr
``` ```
### Examples ### Examples
Examples of using `setup-php` with various PHP Frameworks and Packages. Examples for setting up this GitHub Action with different PHP Frameworks/Packages.
|Framework/Package|Runs on|Workflow| |Framework/Package|Runs on|Workflow|
|--- |--- |--- | |--- |--- |--- |
|Blackfire|`macOS`, `ubuntu` and `windows`|[blackfire.yml](./examples/blackfire.yml "GitHub Action using Blackfire")|
|Blackfire Player|`macOS`, `ubuntu` and `windows`|[blackfire-player.yml](./examples/blackfire-player.yml "GitHub Action using Blackfire Player")|
|CakePHP with `MySQL` and `Redis`|`ubuntu`|[cakephp-mysql.yml](./examples/cakephp-mysql.yml "GitHub Action for CakePHP with MySQL and Redis")| |CakePHP with `MySQL` and `Redis`|`ubuntu`|[cakephp-mysql.yml](./examples/cakephp-mysql.yml "GitHub Action for CakePHP with MySQL and Redis")|
|CakePHP with `PostgreSQL` and `Redis`|`ubuntu`|[cakephp-postgres.yml](./examples/cakephp-postgres.yml "GitHub Action for CakePHP with Postgres and Redis")| |CakePHP with `PostgreSQL` and `Redis`|`ubuntu`|[cakephp-postgres.yml](./examples/cakephp-postgres.yml "GitHub Action for CakePHP with Postgres and Redis")|
|CakePHP without services|`macOS`, `ubuntu` and `windows`|[cakephp.yml](./examples/cakephp.yml "GitHub Action for CakePHP without services")| |CakePHP without services|`macOS`, `ubuntu` and `windows`|[cakephp.yml](./examples/cakephp.yml "GitHub Action for CakePHP without services")|
@ -630,73 +396,31 @@ Examples of using `setup-php` with various PHP Frameworks and Packages.
|Yii2 Starter Kit with `PostgreSQL`|`ubuntu`|[yii2-postgres.yml](./examples/yii2-postgres.yml "GitHub Action for Yii2 Starter Kit with PostgreSQL")| |Yii2 Starter Kit with `PostgreSQL`|`ubuntu`|[yii2-postgres.yml](./examples/yii2-postgres.yml "GitHub Action for Yii2 Starter Kit with PostgreSQL")|
|Zend Framework|`macOS`, `ubuntu` and `windows`|[zend-framework.yml](./examples/zend-framework.yml "GitHub Action for Zend Framework")| |Zend Framework|`macOS`, `ubuntu` and `windows`|[zend-framework.yml](./examples/zend-framework.yml "GitHub Action for Zend Framework")|
## :bookmark: Versioning
- It is highly recommended to use the `v2` tag as `setup-php` version. It is a rolling tag and is synced with latest minor and patch releases. With `v2` you automatically get the bug fixes, new features and support for latest PHP releases. For debugging any issues `verbose` tag can be used temporarily. It outputs all the logs and is also synced with the latest releases.
- Semantic release versions can also be used. It is recommended to [use dependabot](https://docs.github.com/en/github/administering-a-repository/keeping-your-actions-up-to-date-with-github-dependabot "Setup Dependabot with GitHub Actions") with semantic versioning to keep the actions in your workflows up to date.
- Commit SHA can also be used, but are not recommended. They have to be updated with every release manually, without which you will not get any bug fixes or new features.
- Using the `master` branch as version is highly discouraged, it might break your workflow after major releases as they have breaking changes.
- If you are using the `v1` tag or a `1.x.y` version, it is recommended that you [switch to v2](https://github.com/shivammathur/setup-php/wiki/Switch-to-v2 "Guide for switching from setup-php v1 to v2") as `v1` only gets critical bug fixes. Maintenance support for `v1` will be dropped with the last `PHP 8.0` release.
## :scroll: License ## :scroll: License
- The scripts and documentation in this project are released under the [MIT License](LICENSE "License for shivammathur/setup-php"). - The scripts and documentation in this project are released under the [MIT License](LICENSE "License for shivammathur/setup-php").
- This project has multiple [dependencies](#package-dependencies "Dependencies for this PHP Action"). Their licenses can be found in their respective repositories. - This project has multiple [dependencies](#bookmark-dependencies "Dependencies for this PHP Action"). Their licenses can be found in their respective repositories.
- The logo for `setup-php` is a derivative work of [php.net logo](https://www.php.net/download-logos.php) and is licensed under the [CC BY-SA 4.0 License](https://creativecommons.org/licenses/by-sa/4.0/ "Creative Commons License"). - The logo for `setup-php` is a derivative work of [php.net logo](https://www.php.net/download-logos.php) and is licensed under the [CC BY-SA 4.0 License](https://creativecommons.org/licenses/by-sa/4.0/ "Creative Commons License").
## :+1: Contributions ## :+1: Contributions
> Contributions are welcome! Contributions are welcome! See [Contributor's Guide](.github/CONTRIBUTING.md "shivammathur/setup-php contribution guide"). If you face any issues while using this or want to suggest a feature/improvement, create an issue [here](https://github.com/shivammathur/setup-php/issues "Issues reported").
- See [Contributor's Guide](.github/CONTRIBUTING.md "shivammathur/setup-php contribution guide") before you start.
- If you face any issues while using this or want to suggest a feature/improvement, create an issue [here](https://github.com/shivammathur/setup-php/issues "Issues reported").
*Join the list of setup-php contributors*
<p align="center">
<a href="https://github.com/shivammathur/setup-php/graphs/contributors">
<img src="https://opencollective.com/setup-php/contributors.svg?width=1024&button=false" alt="setup-php contributers" width="100%">
</a>
</p>
## :sparkling_heart: Support This Project ## :sparkling_heart: Support This Project
- Please star the project and share it. If you blog, please share your experience of using this action. If this action helped you.
- Please consider supporting our work by sponsoring using [Open Collective](https://opencollective.com/setup-php), [Paypal](https://www.paypal.me/shivammathur "Shivam Mathur PayPal") or [Patreon](https://www.patreon.com/shivammathur "Shivam Mathur Patreon").
- If you use `setup-php` at your company, please [reach out](mailto:contact@setup-php.com) to sponsor the project.
*Huge thanks to the following companies for supporting `setup-php`* - Sponsor the project by subscribing on [Patreon](https://www.patreon.com/shivammathur "Shivam Mathur Patreon") or by contributing using [Paypal](https://www.paypal.me/shivammathur "Shivam Mathur PayPal"). This project is also available as part of the [Tidelift Subscription](https://tidelift.com/subscription/pkg/npm-setup-php?utm_source=npm-setup-php&utm_medium=referral&utm_campaign=enterprise&utm_term=repo "Tidelift Subscription for setup-php") to support delivering enterprise-level maintenance.
- Please star the project and dependencies. If you blog, please share your experience of using this action with the community.
<p> ## :bookmark: Dependencies
<a href="https://www.jetbrains.com/?from=setup-php">
<img src="https://shivammathur.com/jetbrains.svg" alt="JetBrains" width="106" height="60">
</a>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<a href="https://blackfire.io/?utm_source=setup-php">
<img src="https://shivammathur.com/blackfire.svg" alt="Blackfire" width="212" height="60">
</a>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<a href="https://tidelift.com/subscription/pkg/npm-setup-php">
<img src="https://shivammathur.com/tidelift.png" alt="Tidelift" width="70" height="60">
</a>
</p>
## :package: Dependencies
- [Node.js dependencies](https://github.com/shivammathur/setup-php/network/dependencies "Node.js dependencies") - [Node.js dependencies](https://github.com/shivammathur/setup-php/network/dependencies "Node.js dependencies")
- [gplessis/dotdeb-php](https://github.com/gplessis/dotdeb-php "Packaging for end of life PHP versions")
- [mlocati/powershell-phpmanager](https://github.com/mlocati/powershell-phpmanager "Package to handle PHP on windows") - [mlocati/powershell-phpmanager](https://github.com/mlocati/powershell-phpmanager "Package to handle PHP on windows")
- [ppa:ondrej/php](https://launchpad.net/~ondrej/+archive/ubuntu/php "Packaging active PHP packages") - [ppa:ondrej/php](https://launchpad.net/~ondrej/+archive/ubuntu/php "Packaging active PHP packages")
- [shivammathur/cache-extensions](https://github.com/shivammathur/cache-extensions "GitHub action to help with caching PHP extensions") - [shivammathur/homebrew-php](https://github.com/shivammathur/homebrew-php "Tap for PHP builds for MacOS")
- [shivammathur/composer-cache](https://github.com/shivammathur/composer-cache "Cache composer releases") - [shivammathur/homebrew-extensions](https://github.com/shivammathur/homebrew-extensions "Tap for PHP extensions for MacOS")
- [shivammathur/homebrew-extensions](https://github.com/shivammathur/homebrew-extensions "Tap for PHP extensions on MacOS") - [shivammathur/php-builder](https://github.com/shivammathur/php-builder "Nightly PHP package")
- [shivammathur/homebrew-php](https://github.com/shivammathur/homebrew-php "Tap for PHP builds on MacOS")
- [shivammathur/icu-intl](https://github.com/shivammathur/icu-intl "icu4c and php-intl builds")
- [shivammathur/php-builder](https://github.com/shivammathur/php-builder "Nightly PHP package for Ubuntu")
- [shivammathur/php-builder-windows](https://github.com/shivammathur/php-builder-windows "Nightly PHP package for Windows")
- [shivammathur/php-ubuntu](https://github.com/shivammathur/php-ubuntu "Cache stable PHP Packages for Ubuntu")
- [shivammathur/php5-darwin](https://github.com/shivammathur/php5-darwin "Scripts to setup PHP5 versions on darwin")
- [shivammathur/php5-ubuntu](https://github.com/shivammathur/php5-ubuntu "Scripts to setup PHP5 versions on ubuntu")
## :bookmark_tabs: Further Reading ## :bookmark_tabs: Further Reading

View File

@ -7,7 +7,7 @@ describe('Config tests', () => {
'win32' 'win32'
); );
expect(win32).toContain( expect(win32).toContain(
'Add-Content "$php_dir\\php.ini" "post_max_size=256M\nshort_open_tag=On\ndate.timezone=Asia/Kolkata"' 'Add-Content C:\\tools\\php\\php.ini "post_max_size=256M\nshort_open_tag=On\ndate.timezone=Asia/Kolkata"'
); );
win32 = await config.addINIValues( win32 = await config.addINIValues(

View File

@ -1,9 +1,15 @@
import * as coverage from '../src/coverage'; import * as coverage from '../src/coverage';
jest.mock('../src/extensions', () => ({
addExtension: jest.fn().mockImplementation(extension => {
return 'add_extension ' + extension + '\n';
})
}));
describe('Config tests', () => { describe('Config tests', () => {
it('checking addCoverage with PCOV on windows', async () => { it('checking addCoverage with PCOV on windows', async () => {
let win32: string = await coverage.addCoverage('PCOV', '7.4', 'win32'); let win32: string = await coverage.addCoverage('PCOV', '7.4', 'win32');
expect(win32).toContain('Add-Extension pcov'); expect(win32).toContain('add_extension pcov');
expect(win32).toContain('Remove-Extension xdebug'); expect(win32).toContain('Remove-Extension xdebug');
win32 = await coverage.addCoverage('pcov', '7.0', 'win32'); win32 = await coverage.addCoverage('pcov', '7.0', 'win32');
@ -27,26 +33,14 @@ describe('Config tests', () => {
it('checking addCoverage with Xdebug on windows', async () => { it('checking addCoverage with Xdebug on windows', async () => {
const win32: string = await coverage.addCoverage('xdebug', '7.4', 'win32'); const win32: string = await coverage.addCoverage('xdebug', '7.4', 'win32');
expect(win32).toContain('Add-Extension xdebug'); expect(win32).toContain('add_extension xdebug');
}); });
it('checking addCoverage with Xdebug on linux', async () => { it('checking addCoverage with Xdebug on linux', async () => {
const linux: string = await coverage.addCoverage('xdebug', '8.0', 'linux'); const linux: string = await coverage.addCoverage('xdebug', '7.4', 'linux');
expect(linux).toContain('add_extension xdebug'); expect(linux).toContain('add_extension xdebug');
}); });
it('checking addCoverage with Xdebug3 on linux', async () => {
const linux: string = await coverage.addCoverage('xdebug3', '7.4', 'linux');
expect(linux).toContain('add_extension_from_source xdebug');
expect(linux).toContain('echo "xdebug.mode=coverage"');
});
it('checking addCoverage with Xdebug3 on linux', async () => {
const linux: string = await coverage.addCoverage('xdebug3', '8.0', 'linux');
expect(linux).toContain('add_extension xdebug');
expect(linux).toContain('echo "xdebug.mode=coverage"');
});
it('checking addCoverage with Xdebug on linux', async () => { it('checking addCoverage with Xdebug on linux', async () => {
const linux: string = await coverage.addCoverage('xdebug', '8.0', 'linux'); const linux: string = await coverage.addCoverage('xdebug', '8.0', 'linux');
expect(linux).toContain('add_extension xdebug'); expect(linux).toContain('add_extension xdebug');

View File

@ -3,26 +3,15 @@ import * as extensions from '../src/extensions';
describe('Extension tests', () => { describe('Extension tests', () => {
it('checking addExtensionOnWindows', async () => { it('checking addExtensionOnWindows', async () => {
let win32: string = await extensions.addExtension( let win32: string = await extensions.addExtension(
'Xdebug, pcov, sqlite, :intl, phalcon4, ioncube, oci8, pdo_oci, ast-beta, grpc-1.2.3, inotify-1.2.3alpha2', 'Xdebug, pcov, sqlite, phalcon4, ast-beta',
'7.4', '7.4',
'win32' 'win32'
); );
expect(win32).toContain('Add-Extension xdebug'); expect(win32).toContain('Add-Extension xdebug');
expect(win32).toContain('Add-Extension pcov'); expect(win32).toContain('Add-Extension pcov');
expect(win32).toContain('Add-Extension sqlite3'); expect(win32).toContain('Add-Extension sqlite3');
expect(win32).toContain('Remove-Extension intl'); expect(win32).toContain('phalcon.ps1 phalcon4');
expect(win32).toContain('Add-Phalcon phalcon4');
expect(win32).toContain('Add-Ioncube');
expect(win32).toContain('Add-Oci oci8');
expect(win32).toContain('Add-Oci pdo_oci');
expect(win32).toContain('Add-Extension ast beta'); expect(win32).toContain('Add-Extension ast beta');
expect(win32).toContain('Add-Extension grpc stable 1.2.3');
expect(win32).toContain('Add-Extension inotify alpha 1.2.3');
win32 = await extensions.addExtension('pcov', '5.6', 'win32');
expect(win32).toContain(
'Add-Log "$cross" "pcov" "pcov is not supported on PHP 5.6"'
);
win32 = await extensions.addExtension('mysql', '7.4', 'win32'); win32 = await extensions.addExtension('mysql', '7.4', 'win32');
expect(win32).toContain('Add-Extension mysqli'); expect(win32).toContain('Add-Extension mysqli');
@ -32,7 +21,7 @@ describe('Extension tests', () => {
expect(win32).toContain('Add-Extension mysqli'); expect(win32).toContain('Add-Extension mysqli');
expect(win32).toContain('Add-Extension mysqlnd'); expect(win32).toContain('Add-Extension mysqlnd');
win32 = await extensions.addExtension('mysql', '5.5', 'win32'); win32 = await extensions.addExtension('mysql', '5.6', 'win32');
expect(win32).toContain('Add-Extension mysql'); expect(win32).toContain('Add-Extension mysql');
expect(win32).toContain('Add-Extension mysqli'); expect(win32).toContain('Add-Extension mysqli');
expect(win32).toContain('Add-Extension mysqlnd'); expect(win32).toContain('Add-Extension mysqlnd');
@ -43,93 +32,53 @@ describe('Extension tests', () => {
'win32', 'win32',
true true
); );
expect(win32).toContain('Add-Phalcon phalcon3'); expect(win32).toContain('phalcon.ps1 phalcon3');
expect(win32).toContain('Add-Extension does_not_exist'); expect(win32).toContain('Add-Extension does_not_exist');
win32 = await extensions.addExtension('xdebug', '7.2', 'openbsd'); win32 = await extensions.addExtension('xdebug', '7.2', 'openbsd');
expect(win32).toContain('Platform openbsd is not supported'); expect(win32).toContain('Platform openbsd is not supported');
win32 = await extensions.addExtension('blackfire', '7.3', 'win32');
expect(win32).toContain('Add-Blackfire blackfire');
win32 = await extensions.addExtension('blackfire-1.31.0', '7.3', 'win32');
expect(win32).toContain('Add-Blackfire blackfire-1.31.0');
}); });
it('checking addExtensionOnLinux', async () => { it('checking addExtensionOnLinux', async () => {
let linux: string = await extensions.addExtension( let linux: string = await extensions.addExtension(
'Xdebug, xdebug3, pcov, sqlite, :intl, ast, uopz, ast-beta, pdo_mysql, pdo-odbc, xdebug-alpha, grpc-1.2.3', 'Xdebug, pcov, sqlite, ast-beta, xdebug-alpha',
'7.4', '7.4',
'linux' '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-pcov');
expect(linux).toContain( expect(linux).toContain(
'sudo $debconf_fix apt-get install -y php7.4-sqlite3' 'sudo $debconf_fix apt-get install -y php7.4-sqlite3'
); );
expect(linux).toContain('remove_extension intl');
expect(linux).toContain('sudo $debconf_fix apt-get install -y php-ast');
expect(linux).toContain('sudo $debconf_fix apt-get install -y php-uopz');
expect(linux).toContain('add_unstable_extension ast beta extension'); expect(linux).toContain('add_unstable_extension ast beta extension');
expect(linux).toContain('add_pdo_extension mysql');
expect(linux).toContain('add_pdo_extension odbc');
expect(linux).toContain('add_pecl_extension grpc 1.2.3 extension');
expect(linux).toContain( expect(linux).toContain(
'add_unstable_extension xdebug alpha zend_extension' 'add_unstable_extension xdebug alpha zend_extension'
); );
linux = await extensions.addExtension('xdebug3', '8.0', 'linux');
expect(linux).toContain(
'sudo $debconf_fix apt-get install -y php8.0-xdebug'
);
linux = await extensions.addExtension('pcov', '5.6', 'linux');
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', '7.0', 'linux');
expect(linux).toContain('add_gearman'); expect(linux).toContain('gearman.sh 7.0');
linux = await extensions.addExtension('gearman', '7.4', 'linux'); linux = await extensions.addExtension('gearman', '7.1', 'linux');
expect(linux).toContain('add_gearman'); expect(linux).toContain('gearman.sh 7.1');
linux = await extensions.addExtension('pdo_cubrid', '7.0', 'linux'); linux = await extensions.addExtension('gearman', '7.2', 'linux');
expect(linux).toContain('add_cubrid pdo_cubrid'); expect(linux).toContain('gearman.sh 7.2');
linux = await extensions.addExtension('cubrid', '7.4', 'linux');
expect(linux).toContain('add_cubrid cubrid'); linux = await extensions.addExtension('gearman', '7.3', 'linux');
expect(linux).toContain('gearman.sh 7.3');
linux = await extensions.addExtension('gearman', '7.4', 'linux');
expect(linux).toContain('gearman.sh 7.4');
linux = await extensions.addExtension('xdebug', '7.2', 'openbsd'); linux = await extensions.addExtension('xdebug', '7.2', 'openbsd');
expect(linux).toContain('Platform openbsd is not supported'); expect(linux).toContain('Platform openbsd is not supported');
linux = await extensions.addExtension('phalcon3, phalcon4', '7.3', 'linux'); linux = await extensions.addExtension('phalcon3, phalcon4', '7.3', 'linux');
expect(linux).toContain('add_phalcon phalcon3'); expect(linux).toContain('phalcon.sh phalcon3 7.3');
expect(linux).toContain('add_phalcon phalcon4'); expect(linux).toContain('phalcon.sh phalcon4 7.3');
linux = await extensions.addExtension('ioncube', '7.3', 'linux');
expect(linux).toContain('add_ioncube');
linux = await extensions.addExtension('oci8, pdo_oci', '7.3', 'linux');
expect(linux).toContain('add_oci oci8');
expect(linux).toContain('add_oci pdo_oci');
linux = await extensions.addExtension('blackfire', '7.3', 'linux');
expect(linux).toContain('add_blackfire blackfire');
linux = await extensions.addExtension('blackfire-1.31.0', '7.3', 'linux');
expect(linux).toContain('add_blackfire blackfire-1.31.0');
linux = await extensions.addExtension('intl-65.1', '5.6', 'linux');
expect(linux).toContain('add_intl intl-65.1');
linux = await extensions.addExtension('intl-67.1', '7.3', 'linux');
expect(linux).toContain('add_intl intl-67.1');
}); });
it('checking addExtensionOnDarwin', async () => { it('checking addExtensionOnDarwin', async () => {
let darwin: string = await extensions.addExtension( let darwin: string = await extensions.addExtension(
'Xdebug, pcov, grpc, protobuf, swoole, sqlite, oci8, pdo_oci, :intl, ast-beta, grpc-1.2.3', 'Xdebug, pcov, grpc, protobuf, swoole, sqlite, ast-beta',
'7.2', '7.2',
'darwin' 'darwin'
); );
@ -139,27 +88,16 @@ describe('Extension tests', () => {
expect(darwin).toContain('add_brew_extension protobuf'); expect(darwin).toContain('add_brew_extension protobuf');
expect(darwin).toContain('add_brew_extension swoole'); expect(darwin).toContain('add_brew_extension swoole');
expect(darwin).toContain('pecl_install sqlite3'); expect(darwin).toContain('pecl_install sqlite3');
expect(darwin).toContain('remove_extension intl');
expect(darwin).toContain('add_unstable_extension ast beta extension'); expect(darwin).toContain('add_unstable_extension ast beta extension');
expect(darwin).toContain('add_pecl_extension grpc 1.2.3 extension');
darwin = await extensions.addExtension('phalcon3', '7.0', 'darwin'); darwin = await extensions.addExtension('phalcon3', '7.0', 'darwin');
expect(darwin).toContain('add_phalcon phalcon3'); expect(darwin).toContain('phalcon_darwin.sh phalcon3 7.0');
darwin = await extensions.addExtension('phalcon4', '7.3', 'darwin'); darwin = await extensions.addExtension('phalcon4', '7.3', 'darwin');
expect(darwin).toContain('add_phalcon phalcon4'); expect(darwin).toContain('phalcon_darwin.sh phalcon4 7.3');
darwin = await extensions.addExtension('ioncube', '7.3', 'darwin');
expect(darwin).toContain('add_ioncube');
darwin = await extensions.addExtension('oci8, pdo_oci', '7.3', 'darwin');
expect(darwin).toContain('add_oci oci8');
expect(darwin).toContain('add_oci pdo_oci');
darwin = await extensions.addExtension('pcov', '5.6', 'darwin'); darwin = await extensions.addExtension('pcov', '5.6', 'darwin');
expect(darwin).toContain( expect(darwin).toContain('pecl_install pcov');
'add_log "$cross" "pcov" "pcov is not supported on PHP 5.6"'
);
darwin = await extensions.addExtension('pcov', '7.2', 'darwin'); darwin = await extensions.addExtension('pcov', '7.2', 'darwin');
expect(darwin).toContain('add_brew_extension pcov'); expect(darwin).toContain('add_brew_extension pcov');
@ -187,12 +125,6 @@ describe('Extension tests', () => {
expect(darwin).toContain('brew install pkg-config imagemagick'); expect(darwin).toContain('brew install pkg-config imagemagick');
expect(darwin).toContain('pecl_install imagick'); expect(darwin).toContain('pecl_install imagick');
darwin = await extensions.addExtension('blackfire', '7.3', 'darwin');
expect(darwin).toContain('add_blackfire blackfire');
darwin = await extensions.addExtension('blackfire-1.31.0', '7.3', 'darwin');
expect(darwin).toContain('add_blackfire blackfire-1.31.0');
darwin = await extensions.addExtension( darwin = await extensions.addExtension(
'does_not_exist', 'does_not_exist',
'7.2', '7.2',

View File

@ -70,6 +70,7 @@ jest.mock('../src/install', () => ({
* @param ini_values_csv * @param ini_values_csv
* @param coverage_driver * @param coverage_driver
* @param tools * @param tools
* @param pecl
*/ */
function setEnv( function setEnv(
version: string | number, version: string | number,
@ -77,7 +78,8 @@ function setEnv(
extension_csv: string, extension_csv: string,
ini_values_csv: string, ini_values_csv: string,
coverage_driver: string, coverage_driver: string,
tools: string tools: string,
pecl: string
): void { ): void {
process.env['php-version'] = version.toString(); process.env['php-version'] = version.toString();
process.env['RUNNER_OS'] = os; process.env['RUNNER_OS'] = os;
@ -85,23 +87,24 @@ function setEnv(
process.env['ini-values'] = ini_values_csv; process.env['ini-values'] = ini_values_csv;
process.env['coverage'] = coverage_driver; process.env['coverage'] = coverage_driver;
process.env['tools'] = tools; process.env['tools'] = tools;
process.env['pecl'] = pecl;
} }
describe('Install', () => { describe('Install', () => {
it('Test install on windows', async () => { it('Test install on windows', async () => {
setEnv('7.0', 'win32', '', '', '', ''); setEnv('7.0', 'win32', '', '', '', '', '');
let script: string = '' + (await install.run()); let script: string = '' + (await install.run());
expect(script).toContain('initial script'); expect(script).toContain('initial script');
expect(script).toContain('pwsh script.ps1 7.0 ' + __dirname); expect(script).toContain('pwsh script.ps1 7.0 ' + __dirname);
setEnv('7.3', 'win32', '', '', '', ''); setEnv('7.3', 'win32', '', '', '', '', '');
script = '' + (await install.run()); script = '' + (await install.run());
expect(script).toContain('initial script'); expect(script).toContain('initial script');
expect(script).toContain('pwsh script.ps1 7.3 ' + __dirname); expect(script).toContain('pwsh script.ps1 7.3 ' + __dirname);
setEnv('7.3', 'win32', 'a, b', 'a=b', 'x', ''); setEnv('7.3', 'win32', 'a, b', 'a=b', 'x', '', '');
script = '' + (await install.run()); script = '' + (await install.run());
expect(script).toContain('initial script'); expect(script).toContain('initial script');
@ -112,13 +115,23 @@ describe('Install', () => {
}); });
it('Test install on linux', async () => { it('Test install on linux', async () => {
setEnv('7.3', 'linux', '', '', '', ''); setEnv('7.3', 'linux', '', '', '', '', '');
let script: string = '' + (await install.run()); let script: string = '' + (await install.run());
expect(script).toContain('initial script'); expect(script).toContain('initial script');
expect(script).toContain('bash script.sh 7.3 '); expect(script).toContain('bash script.sh 7.3 ');
setEnv('7.3', 'linux', 'a, b', 'a=b', 'x', 'phpunit'); setEnv('7.4', 'linux', 'a, b', 'a=b', 'x', 'phpunit', 'true');
script = '' + (await install.run());
expect(script).toContain('initial script');
expect(script).toContain('install extensions');
expect(script).toContain('edit php.ini');
expect(script).toContain('set coverage driver');
expect(script).toContain('bash script.sh 7.4');
expect(script).toContain('add_tool');
setEnv('7.3', 'linux', 'a, b', 'a=b', 'x', 'phpunit', '');
script = '' + (await install.run()); script = '' + (await install.run());
expect(script).toContain('initial script'); expect(script).toContain('initial script');
@ -130,13 +143,13 @@ describe('Install', () => {
}); });
it('Test install on darwin', async () => { it('Test install on darwin', async () => {
setEnv('7.3', 'darwin', '', '', '', ''); setEnv('7.3', 'darwin', '', '', '', '', '');
let script: string = '' + (await install.run()); let script: string = '' + (await install.run());
expect(script).toContain('initial script'); expect(script).toContain('initial script');
expect(script).toContain('bash script.sh 7.3 ' + __dirname); expect(script).toContain('bash script.sh 7.3 ' + __dirname);
setEnv('7.3', 'darwin', 'a, b', 'a=b', 'x', ''); setEnv('7.3', 'darwin', 'a, b', 'a=b', 'x', '', '');
script = '' + (await install.run()); script = '' + (await install.run());
expect(script).toContain('initial script'); expect(script).toContain('initial script');
@ -147,19 +160,19 @@ describe('Install', () => {
}); });
it('Test malformed version inputs', async () => { it('Test malformed version inputs', async () => {
setEnv('7.4.1', 'darwin', '', '', '', ''); setEnv('7.4.1', 'darwin', '', '', '', '', '');
let script: string = '' + '' + (await install.run()); let script: string = '' + (await install.run());
expect(script).toContain('initial script'); expect(script).toContain('initial script');
expect(script).toContain('bash script.sh 7.4 ' + __dirname); expect(script).toContain('bash script.sh 7.4 ' + __dirname);
setEnv(8.0, 'darwin', '', '', '', ''); setEnv(8.0, 'darwin', '', '', '', '', '');
script = '' + (await install.run()); script = '' + (await install.run());
expect(script).toContain('initial script'); expect(script).toContain('initial script');
expect(script).toContain('bash script.sh 8.0 ' + __dirname); expect(script).toContain('bash script.sh 8.0 ' + __dirname);
setEnv(8, 'darwin', '', '', '', ''); setEnv(8, 'darwin', '', '', '', '', '');
script = '' + (await install.run()); script = '' + (await install.run());
expect(script).toContain('initial script'); expect(script).toContain('initial script');

View File

@ -1,41 +0,0 @@
import * as io from '@actions/io';
import * as matchers from '../src/matchers';
jest.mock('@actions/io');
describe('Matchers', () => {
it('Add matchers', async () => {
process.env['RUNNER_TOOL_CACHE'] = __dirname;
await matchers.addMatchers();
const spy = jest.spyOn(io, 'cp');
expect(spy).toHaveBeenCalledTimes(2);
});
it('Test PHPUnit Regex', async () => {
const regex1 = /^\d+\)\s.*$/;
const regex2 = /^(.*Failed\sasserting\sthat.*)$/;
const regex3 = /^\s*$/;
const regex4 = /^(.*):(\d+)$/;
expect(regex1.test('1) Tests\\Test::it_tests')).toBe(true);
expect(regex2.test('Failed asserting that false is true')).toBe(true);
expect(regex3.test('\n')).toBe(true);
expect(regex4.test('/path/to/file.php:42')).toBe(true);
});
it('Test PHP Regex', async () => {
const regex1 = /^(.*error):\s+\s+(.+) in (.+) on line (\d+)$/;
const regex2 = /^(.*Warning|.*Deprecated|.*Notice):\s+\s+(.+) in (.+) on line (\d+)$/;
expect(
regex1.test('PHP Parse error: error_message in file.php on line 10')
).toBe(true);
expect(
regex2.test('PHP Notice: info_message in file.php on line 10')
).toBe(true);
expect(
regex2.test('PHP Warning: warning_message in file.php on line 10')
).toBe(true);
expect(
regex2.test('PHP Deprecated: deprecated_message in file.php on line 10')
).toBe(true);
});
});

View File

@ -1,6 +1,39 @@
import * as tools from '../src/tools'; import * as tools from '../src/tools';
describe('Tools tests', () => { describe('Tools tests', () => {
it('checking getCommand', async () => {
expect(await tools.getCommand('linux', 'tool')).toBe('add_tool ');
expect(await tools.getCommand('darwin', 'tool')).toBe('add_tool ');
expect(await tools.getCommand('win32', 'tool')).toBe('Add-Tool ');
expect(await tools.getCommand('openbsd', 'tool')).toContain(
'Platform openbsd is not supported'
);
});
it('checking getCommand', async () => {
expect(await tools.getCommand('linux', 'composertool')).toBe(
'add_composertool '
);
expect(await tools.getCommand('darwin', 'composertool')).toBe(
'add_composertool '
);
expect(await tools.getCommand('win32', 'composertool')).toBe(
'Add-Composertool '
);
expect(await tools.getCommand('openbsd', 'composertool')).toContain(
'Platform openbsd is not supported'
);
});
it('checking getCommand', async () => {
expect(await tools.getCommand('linux', 'pecl')).toBe('add_pecl ');
expect(await tools.getCommand('darwin', 'pecl')).toBe('add_pecl ');
expect(await tools.getCommand('win32', 'pecl')).toBe('Add-Pecl ');
expect(await tools.getCommand('openbsd', 'pecl')).toContain(
'Platform openbsd is not supported'
);
});
it('checking parseToolVersion', async () => { it('checking parseToolVersion', async () => {
expect(await tools.getToolVersion('latest')).toBe('latest'); expect(await tools.getToolVersion('latest')).toBe('latest');
expect(await tools.getToolVersion('1.2.3')).toBe('1.2.3'); expect(await tools.getToolVersion('1.2.3')).toBe('1.2.3');
@ -178,7 +211,7 @@ describe('Tools tests', () => {
); );
}); });
it('checking getPharUri', async () => { it('checking getPhpunitUri', async () => {
expect(await tools.getPharUrl('domain', 'tool', '', 'latest')).toBe( expect(await tools.getPharUrl('domain', 'tool', '', 'latest')).toBe(
'domain/tool.phar' 'domain/tool.phar'
); );
@ -288,15 +321,6 @@ describe('Tools tests', () => {
]); ]);
}); });
it('checking getWpCliUri', async () => {
expect(await tools.getWpCliUrl('latest')).toBe(
'wp-cli/builds/blob/gh-pages/phar/wp-cli.phar?raw=true'
);
expect(await tools.getWpCliUrl('2.4.0')).toBe(
'wp-cli/wp-cli/releases/download/v2.4.0/wp-cli-2.4.0.phar'
);
});
it('checking addArchive', async () => { it('checking addArchive', async () => {
let script: string = await tools.addArchive( let script: string = await tools.addArchive(
'tool', 'tool',
@ -375,14 +399,10 @@ describe('Tools tests', () => {
it('checking addTools on linux', async () => { it('checking addTools on linux', async () => {
const script: string = await tools.addTools( const script: string = await tools.addTools(
'blackfire, blackfire-player, cs2pr, flex, grpc_php_plugin, php-cs-fixer, phplint, phpstan, phpunit, pecl, phing, phinx, phinx:1.2.3, phive, php-config, phpize, protoc, symfony, wp-cli', 'cs2pr, php-cs-fixer, phpstan, phpunit, pecl, phinx, phinx:1.2.3, phive, php-config, phpize, symfony',
'7.4', '7.4',
'linux' 'linux'
); );
expect(script).toContain('add_blackfire');
expect(script).toContain(
'add_tool https://get.blackfire.io/blackfire-player.phar blackfire-player'
);
expect(script).toContain( expect(script).toContain(
'add_tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-stable.phar,https://getcomposer.org/composer-stable.phar composer' 'add_tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-stable.phar,https://getcomposer.org/composer-stable.phar composer'
); );
@ -395,9 +415,6 @@ describe('Tools tests', () => {
expect(script).toContain( expect(script).toContain(
'add_tool https://github.com/phpstan/phpstan/releases/latest/download/phpstan.phar phpstan' 'add_tool https://github.com/phpstan/phpstan/releases/latest/download/phpstan.phar phpstan'
); );
expect(script).toContain(
'add_tool https://www.phing.info/get/phing-latest.phar phing'
);
expect(script).toContain( expect(script).toContain(
'add_tool https://phar.io/releases/phive.phar phive' 'add_tool https://phar.io/releases/phive.phar phive'
); );
@ -407,85 +424,25 @@ describe('Tools tests', () => {
expect(script).toContain( expect(script).toContain(
'add_tool https://github.com/symfony/cli/releases/latest/download/symfony_linux_amd64 symfony' 'add_tool https://github.com/symfony/cli/releases/latest/download/symfony_linux_amd64 symfony'
); );
expect(script).toContain(
'add_tool https://github.com/wp-cli/builds/blob/gh-pages/phar/wp-cli.phar?raw=true wp-cli'
);
expect(script).toContain('add_protoc latest');
expect(script).toContain('add_grpc_php_plugin latest');
expect(script).toContain('add_pecl'); expect(script).toContain('add_pecl');
expect(script).toContain('add_composertool flex flex symfony/');
expect(script).toContain('add_composertool phinx phinx robmorgan/'); expect(script).toContain('add_composertool phinx phinx robmorgan/');
expect(script).toContain('add_composertool phplint phplint overtrue/');
expect(script).toContain('add_composertool phinx phinx:1.2.3 robmorgan/'); expect(script).toContain('add_composertool phinx phinx:1.2.3 robmorgan/');
expect(script).toContain('add_devtools'); expect(script).toContain('add_devtools');
expect(script).toContain('add_log "$tick" "php-config" "Added"'); expect(script).toContain('add_log "$tick" "php-config" "Added"');
expect(script).toContain('add_log "$tick" "phpize" "Added"'); expect(script).toContain('add_log "$tick" "phpize" "Added"');
}); });
it('checking addTools on darwin', async () => { it('checking addTools on darwin', async () => {
const listOfTools = [
'blackfire',
'blackfire-player',
'composer-normalize',
'composer-prefetcher:1.2.3',
'composer-require-checker',
'composer-unused',
'cs2pr:1.2.3',
'flex',
'grpc_php_plugin:1.2.3',
'infection',
'phan',
'phan:2.7.2',
'phing:1.2.3',
'phinx',
'phive:1.2.3',
'php-config',
'phpcbf',
'phpcpd',
'phpcs',
'phpize',
'phpmd',
'protoc:v1.2.3',
'psalm',
'symfony',
'symfony:1.2.3',
'vapor-cli',
'wp-cli'
];
const script: string = await tools.addTools( const script: string = await tools.addTools(
listOfTools.join(', '), 'phpcs, phpcbf, phpcpd, phpmd, psalm, phinx, phive:1.2.3, cs2pr:1.2.3, composer-prefetcher:1.2.3, phpize, php-config, symfony, symfony:1.2.3',
'7.4', '7.4',
'darwin' 'darwin'
); );
expect(script).toContain('add_blackfire');
expect(script).toContain(
'add_tool https://get.blackfire.io/blackfire-player.phar blackfire-player'
);
expect(script).toContain( expect(script).toContain(
'add_tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-stable.phar,https://getcomposer.org/composer-stable.phar composer' 'add_tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-stable.phar,https://getcomposer.org/composer-stable.phar composer'
); );
expect(script).toContain(
'add_tool https://github.com/ergebnis/composer-normalize/releases/latest/download/composer-normalize.phar composer-normalize'
);
expect(script).toContain(
'add_tool https://github.com/maglnet/ComposerRequireChecker/releases/latest/download/composer-require-checker.phar composer-require-checker'
);
expect(script).toContain(
'add_tool https://github.com/composer-unused/composer-unused/releases/latest/download/composer-unused.phar composer-unused'
);
expect(script).toContain( expect(script).toContain(
'add_tool https://github.com/staabm/annotate-pull-request-from-checkstyle/releases/download/1.2.3/cs2pr cs2pr' 'add_tool https://github.com/staabm/annotate-pull-request-from-checkstyle/releases/download/1.2.3/cs2pr cs2pr'
); );
expect(script).toContain(
'add_tool https://github.com/infection/infection/releases/latest/download/infection.phar infection'
);
expect(script).toContain(
'add_tool https://github.com/phan/phan/releases/latest/download/phan.phar phan'
);
expect(script).toContain(
'add_tool https://www.phing.info/get/phing-1.2.3.phar phing'
);
expect(script).toContain( expect(script).toContain(
'add_tool https://github.com/squizlabs/PHP_CodeSniffer/releases/latest/download/phpcs.phar phpcs' 'add_tool https://github.com/squizlabs/PHP_CodeSniffer/releases/latest/download/phpcs.phar phpcs'
); );
@ -501,14 +458,7 @@ describe('Tools tests', () => {
expect(script).toContain( expect(script).toContain(
'https://github.com/vimeo/psalm/releases/latest/download/psalm.phar psalm' 'https://github.com/vimeo/psalm/releases/latest/download/psalm.phar psalm'
); );
expect(script).toContain('add_grpc_php_plugin 1.2.3');
expect(script).toContain('add_protoc 1.2.3');
expect(script).toContain('add_composertool vapor-cli vapor-cli laravel/');
expect(script).toContain('add_composertool flex flex symfony/');
expect(script).toContain('add_composertool phinx phinx robmorgan/'); expect(script).toContain('add_composertool phinx phinx robmorgan/');
expect(script).toContain(
'add_tool https://github.com/phan/phan/releases/download/2.7.2/phan.phar phan'
);
expect(script).toContain( expect(script).toContain(
'add_tool https://github.com/phar-io/phive/releases/download/1.2.3/phive-1.2.3.phar phive' 'add_tool https://github.com/phar-io/phive/releases/download/1.2.3/phive-1.2.3.phar phive'
); );
@ -521,48 +471,21 @@ describe('Tools tests', () => {
expect(script).toContain( expect(script).toContain(
'add_tool https://github.com/symfony/cli/releases/download/v1.2.3/symfony_darwin_amd64 symfony' 'add_tool https://github.com/symfony/cli/releases/download/v1.2.3/symfony_darwin_amd64 symfony'
); );
expect(script).toContain(
'add_tool https://github.com/wp-cli/builds/blob/gh-pages/phar/wp-cli.phar?raw=true wp-cli'
);
expect(script).toContain('add_log "$tick" "phpize" "Added"'); expect(script).toContain('add_log "$tick" "phpize" "Added"');
expect(script).toContain('add_log "$tick" "php-config" "Added"'); expect(script).toContain('add_log "$tick" "php-config" "Added"');
}); });
it('checking addTools on windows', async () => { it('checking addTools on windows', async () => {
const listOfTools = [
'blackfire',
'blackfire-player:1.8.1',
'codeception',
'cs2pr',
'deployer',
'does_not_exist',
'flex',
'phinx',
'phive:0.13.2',
'php-config',
'phpize',
'phpmd',
'prestissimo',
'symfony',
'wp-cli'
];
const script: string = await tools.addTools( const script: string = await tools.addTools(
listOfTools.join(', '), 'codeception, cs2pr, deployer, prestissimo, phpmd, phinx, phive:0.13.2, php-config, phpize, symfony, does_not_exist',
'7.4', '7.4',
'win32' 'win32'
); );
expect(script).toContain('Add-Blackfire');
expect(script).toContain(
'Add-Tool https://get.blackfire.io/blackfire-player-v1.8.1.phar blackfire-player'
);
expect(script).toContain( expect(script).toContain(
'Add-Tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-stable.phar,https://getcomposer.org/composer-stable.phar composer' 'Add-Tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-stable.phar,https://getcomposer.org/composer-stable.phar composer'
); );
expect(script).toContain( expect(script).toContain(
'Add-Tool https://github.com/staabm/annotate-pull-request-from-checkstyle/releases/latest/download/cs2pr cs2pr' 'Add-Tool https://github.com/staabm/annotate-pull-request-from-checkstyle/releases/latest/download/cs2pr cs2pr'
); );
expect(script).toContain('Add-Composertool flex flex symfony/');
expect(script).toContain( expect(script).toContain(
'Add-Tool https://deployer.org/deployer.phar deployer' 'Add-Tool https://deployer.org/deployer.phar deployer'
); );
@ -577,26 +500,16 @@ describe('Tools tests', () => {
expect(script).toContain( expect(script).toContain(
'Add-Tool https://github.com/symfony/cli/releases/latest/download/symfony_windows_amd64.exe symfony' 'Add-Tool https://github.com/symfony/cli/releases/latest/download/symfony_windows_amd64.exe symfony'
); );
expect(script).toContain(
'Add-Tool https://github.com/wp-cli/builds/blob/gh-pages/phar/wp-cli.phar?raw=true wp-cli'
);
expect(script).toContain('phpize is not a windows tool'); expect(script).toContain('phpize is not a windows tool');
expect(script).toContain('php-config is not a windows tool'); expect(script).toContain('php-config is not a windows tool');
expect(script).toContain('Tool does_not_exist is not supported'); expect(script).toContain('Tool does_not_exist is not supported');
}); });
it('checking addTools with composer tool using user/tool as input', async () => { it('checking addTools with composer tool using user/tool as input', async () => {
const listOfTools = [
'hirak/prestissimo',
'narrowspark/automatic-composer-prefetcher',
'robmorgan/phinx'
];
const script: string = await tools.addTools( const script: string = await tools.addTools(
listOfTools.join(', '), 'hirak/prestissimo, narrowspark/automatic-composer-prefetcher, robmorgan/phinx',
'7.4', '7.4',
'win32' 'win32'
); );
expect(script).toContain( expect(script).toContain(
'Add-Tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-stable.phar,https://getcomposer.org/composer-stable.phar composer' 'Add-Tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-stable.phar,https://getcomposer.org/composer-stable.phar composer'
); );
@ -607,14 +520,11 @@ describe('Tools tests', () => {
); );
}); });
it('checking composer setup', async () => { it('checking composer setup', async () => {
const listOfTools = ['composer', 'composer:v1'];
let script: string = await tools.addTools( let script: string = await tools.addTools(
listOfTools.join(', '), 'composer, composer:v1',
'7.4', '7.4',
'linux' 'linux'
); );
expect(script).toContain( expect(script).toContain(
'add_tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-1.phar,https://getcomposer.org/composer-1.phar composer' 'add_tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-1.phar,https://getcomposer.org/composer-1.phar composer'
); );

View File

@ -17,13 +17,19 @@ async function cleanup(path: string): Promise<void> {
} }
describe('Utils tests', () => { describe('Utils tests', () => {
it('checking getInput', async () => { it('checking readEnv', async () => {
process.env['test'] = 'setup-php'; process.env['test'] = 'setup-php';
process.env['undefined'] = ''; expect(await utils.readEnv('test')).toBe('setup-php');
expect(await utils.readEnv('undefined')).toBe('');
});
it('checking getInput', async () => {
expect(await utils.getInput('test', false)).toBe('setup-php'); expect(await utils.getInput('test', false)).toBe('setup-php');
expect(await utils.getInput('undefined', false)).toBe('');
expect(await utils.getInput('setup-php', false)).toBe('setup-php'); expect(await utils.getInput('setup-php', false)).toBe('setup-php');
expect(await utils.getInput('DoesNotExist', false)).toBe(''); expect(await utils.getInput('DoesNotExist', false)).toBe('');
expect(async () => {
await utils.getInput('DoesNotExist', true);
}).rejects.toThrow('Input required and not supplied: DoesNotExist');
}); });
it('checking asyncForEach', async () => { it('checking asyncForEach', async () => {
@ -155,7 +161,6 @@ describe('Utils tests', () => {
); );
expect(await utils.getExtensionPrefix('xsl')).toEqual('extension'); expect(await utils.getExtensionPrefix('xsl')).toEqual('extension');
expect(await utils.getExtensionPrefix('xdebug')).toEqual('zend_extension'); expect(await utils.getExtensionPrefix('xdebug')).toEqual('zend_extension');
expect(await utils.getExtensionPrefix('xdebug3')).toEqual('zend_extension');
expect(await utils.getExtensionPrefix('opcache')).toEqual('zend_extension'); expect(await utils.getExtensionPrefix('opcache')).toEqual('zend_extension');
}); });
@ -167,45 +172,4 @@ describe('Utils tests', () => {
'Platform openbsd is not supported' 'Platform openbsd is not supported'
); );
}); });
it('checking getUnsupportedLog', async () => {
expect(await utils.getUnsupportedLog('ext', '5.6', 'linux')).toContain(
'add_log "$cross" "ext" "ext is not supported on PHP 5.6"'
);
});
it('checking getCommand', async () => {
expect(await utils.getCommand('linux', 'tool')).toBe('add_tool ');
expect(await utils.getCommand('darwin', 'tool')).toBe('add_tool ');
expect(await utils.getCommand('win32', 'tool')).toBe('Add-Tool ');
expect(await utils.getCommand('openbsd', 'tool')).toContain(
'Platform openbsd is not supported'
);
});
it('checking joins', async () => {
expect(await utils.joins('a', 'b', 'c')).toBe('a b c');
});
it('checking scriptExtension', async () => {
expect(await utils.scriptExtension('linux')).toBe('.sh');
expect(await utils.scriptExtension('darwin')).toBe('.sh');
expect(await utils.scriptExtension('win32')).toBe('.ps1');
expect(await utils.scriptExtension('openbsd')).toContain(
'Platform openbsd is not supported'
);
});
it('checking customPackage', async () => {
const script_path: string = path.join('ext', 'pkg.sh');
expect(await utils.customPackage('pkg', 'ext', '1.2.3', 'linux')).toContain(
script_path + '\nadd_pkg 1.2.3'
);
expect(
await utils.customPackage('pdo_pkg', 'ext', '1.2.3', 'linux')
).toContain(script_path + '\nadd_pkg 1.2.3');
expect(
await utils.customPackage('pkg8', 'ext', '1.2.3', 'linux')
).toContain(script_path + '\nadd_pkg 1.2.3');
});
}); });

View File

@ -21,6 +21,18 @@ inputs:
tools: tools:
description: 'Setup popular tools globally.' description: 'Setup popular tools globally.'
required: false required: false
extension-csv:
description: 'Deprecated! Use extensions instead.'
deprecationMessage: 'The extension-csv property is deprecated. Use extensions instead.'
required: false
ini-values-csv:
description: 'Deprecated! Use ini-values instead.'
deprecationMessage: 'The ini-values-csv property is deprecated. Use ini-values instead.'
required: false
pecl:
description: 'Deprecated! Use tools instead to setup PECL.'
deprecationMessage: 'The pecl property is deprecated. Specify pecl in tools instead.'
required: false
runs: runs:
using: 'node12' using: 'node12'
main: 'dist/index.js' main: 'dist/index.js'

621
dist/index.js vendored
View File

@ -977,49 +977,6 @@ function toCommandValue(input) {
exports.toCommandValue = toCommandValue; exports.toCommandValue = toCommandValue;
//# sourceMappingURL=utils.js.map //# sourceMappingURL=utils.js.map
/***/ }),
/***/ 86:
/***/ (function(__unusedmodule, exports, __webpack_require__) {
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.addMatchers = void 0;
const path = __importStar(__webpack_require__(622));
const utils = __importStar(__webpack_require__(163));
const io = __importStar(__webpack_require__(1));
/**
* Cache json files for problem matchers
*/
async function addMatchers() {
const config_path = path.join(__dirname, '..', 'src', 'configs');
const runner_dir = await utils.getInput('RUNNER_TOOL_CACHE', false);
await io.cp(path.join(config_path, 'phpunit.json'), runner_dir);
await io.cp(path.join(config_path, 'php.json'), runner_dir);
}
exports.addMatchers = addMatchers;
/***/ }), /***/ }),
/***/ 87: /***/ 87:
@ -1097,10 +1054,25 @@ var __importStar = (this && this.__importStar) || function (mod) {
return result; return result;
}; };
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
exports.customPackage = exports.scriptExtension = exports.joins = exports.getCommand = exports.getUnsupportedLog = exports.suppressOutput = exports.getExtensionPrefix = exports.CSVArray = exports.extensionArray = exports.writeScript = exports.readScript = exports.addLog = exports.stepLog = exports.log = exports.color = exports.asyncForEach = exports.getInput = void 0; exports.suppressOutput = exports.getExtensionPrefix = exports.CSVArray = exports.extensionArray = exports.writeScript = exports.readScript = exports.addLog = exports.stepLog = exports.log = exports.color = exports.asyncForEach = exports.getInput = exports.readEnv = void 0;
const fs = __importStar(__webpack_require__(747)); const fs = __importStar(__webpack_require__(747));
const path = __importStar(__webpack_require__(622)); const path = __importStar(__webpack_require__(622));
const core = __importStar(__webpack_require__(470)); const core = __importStar(__webpack_require__(470));
/**
* Function to read environment variable and return a string value.
*
* @param property
*/
async function readEnv(property) {
const value = process.env[property];
switch (value) {
case undefined:
return '';
default:
return value;
}
}
exports.readEnv = readEnv;
/** /**
* Function to get inputs from both with and env annotations. * Function to get inputs from both with and env annotations.
* *
@ -1108,13 +1080,17 @@ const core = __importStar(__webpack_require__(470));
* @param mandatory * @param mandatory
*/ */
async function getInput(name, mandatory) { async function getInput(name, mandatory) {
const input = process.env[name]; const input = core.getInput(name);
switch (input) { const env_input = await readEnv(name);
case '': switch (true) {
case undefined: case input != '':
return core.getInput(name, { required: mandatory });
default:
return input; return input;
case input == '' && env_input != '':
return env_input;
case input == '' && env_input == '' && mandatory:
throw new Error(`Input required and not supplied: ${name}`);
default:
return '';
} }
} }
exports.getInput = getInput; exports.getInput = getInput;
@ -1280,17 +1256,13 @@ exports.CSVArray = CSVArray;
* @param extension * @param extension
*/ */
async function getExtensionPrefix(extension) { async function getExtensionPrefix(extension) {
const zend = [ const zend = ['xdebug', 'opcache', 'ioncube', 'eaccelerator'];
'xdebug',
'xdebug3',
'opcache',
'ioncube',
'eaccelerator'
];
switch (zend.indexOf(extension)) { switch (zend.indexOf(extension)) {
default: case 0:
case 1:
return 'zend_extension'; return 'zend_extension';
case -1: case -1:
default:
return 'extension'; return 'extension';
} }
} }
@ -1312,79 +1284,6 @@ async function suppressOutput(os_version) {
} }
} }
exports.suppressOutput = suppressOutput; exports.suppressOutput = suppressOutput;
/**
* Function to get script to log unsupported extensions.
*
* @param extension
* @param version
* @param os_version
*/
async function getUnsupportedLog(extension, version, os_version) {
return ('\n' +
(await addLog('$cross', extension, [extension, 'is not supported on PHP', version].join(' '), os_version)) +
'\n');
}
exports.getUnsupportedLog = getUnsupportedLog;
/**
* Function to get command to setup tools
*
* @param os_version
* @param suffix
*/
async function getCommand(os_version, suffix) {
switch (os_version) {
case 'linux':
case 'darwin':
return 'add_' + suffix + ' ';
case 'win32':
return 'Add-' + suffix.charAt(0).toUpperCase() + suffix.slice(1) + ' ';
default:
return await log('Platform ' + os_version + ' is not supported', os_version, 'error');
}
}
exports.getCommand = getCommand;
/**
* Function to join strings with space
*
* @param str
*/
async function joins(...str) {
return [...str].join(' ');
}
exports.joins = joins;
/**
* Function to get script extensions
*
* @param os_version
*/
async function scriptExtension(os_version) {
switch (os_version) {
case 'win32':
return '.ps1';
case 'linux':
case 'darwin':
return '.sh';
default:
return await log('Platform ' + os_version + ' is not supported', os_version, 'error');
}
}
exports.scriptExtension = scriptExtension;
/**
* Function to get script to add tools with custom support.
*
* @param pkg
* @param type
* @param version
* @param os_version
*/
async function customPackage(pkg, type, version, os_version) {
const pkg_name = pkg.replace(/\d+|pdo[_-]/, '');
const script_extension = await scriptExtension(os_version);
const script = path.join(__dirname, '../src/scripts/' + type + '/' + pkg_name + script_extension);
const command = await getCommand(os_version, pkg_name);
return '\n. ' + script + '\n' + command + version;
}
exports.customPackage = customPackage;
/***/ }), /***/ }),
@ -1752,8 +1651,26 @@ var __importStar = (this && this.__importStar) || function (mod) {
return result; return result;
}; };
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
exports.addTools = exports.addPackage = exports.addDevTools = exports.addArchive = exports.getCleanedToolsList = exports.getComposerUrl = exports.addComposer = exports.getWpCliUrl = exports.getSymfonyUri = exports.getDeployerUrl = exports.getPharUrl = exports.addPhive = exports.getCodeceptionUri = exports.getCodeceptionUriBuilder = exports.getUri = exports.parseTool = exports.getToolVersion = void 0; exports.addTools = exports.addPackage = exports.addDevTools = exports.addArchive = exports.getCleanedToolsList = exports.getComposerUrl = exports.addComposer = exports.getSymfonyUri = exports.getDeployerUrl = exports.getPharUrl = exports.addPhive = exports.getCodeceptionUri = exports.getCodeceptionUriBuilder = exports.getUri = exports.parseTool = exports.getToolVersion = exports.getCommand = void 0;
const utils = __importStar(__webpack_require__(163)); const utils = __importStar(__webpack_require__(163));
/**
* Function to get command to setup tools
*
* @param os_version
* @param suffix
*/
async function getCommand(os_version, suffix) {
switch (os_version) {
case 'linux':
case 'darwin':
return 'add_' + suffix + ' ';
case 'win32':
return 'Add-' + suffix.charAt(0).toUpperCase() + suffix.slice(1) + ' ';
default:
return await utils.log('Platform ' + os_version + ' is not supported', os_version, 'error');
}
}
exports.getCommand = getCommand;
/** /**
* Function to get tool version * Function to get tool version
* *
@ -1765,8 +1682,6 @@ async function getToolVersion(version) {
const composer_regex = /^stable$|^preview$|^snapshot$|^v?[1|2]$/; const composer_regex = /^stable$|^preview$|^snapshot$|^v?[1|2]$/;
version = version.replace(/[><=^]*/, ''); version = version.replace(/[><=^]*/, '');
switch (true) { switch (true) {
case version.charAt(0) == 'v':
return version.replace('v', '');
case composer_regex.test(version): case composer_regex.test(version):
case semver_regex.test(version): case semver_regex.test(version):
return version; return version;
@ -1901,10 +1816,10 @@ exports.getCodeceptionUri = getCodeceptionUri;
async function addPhive(version, os_version) { async function addPhive(version, os_version) {
switch (version) { switch (version) {
case 'latest': case 'latest':
return ((await utils.getCommand(os_version, 'tool')) + return ((await getCommand(os_version, 'tool')) +
'https://phar.io/releases/phive.phar phive'); 'https://phar.io/releases/phive.phar phive');
default: default:
return ((await utils.getCommand(os_version, 'tool')) + return ((await getCommand(os_version, 'tool')) +
'https://github.com/phar-io/phive/releases/download/' + 'https://github.com/phar-io/phive/releases/download/' +
version + version +
'/phive-' + '/phive-' +
@ -1972,20 +1887,6 @@ async function getSymfonyUri(version, os_version) {
} }
} }
exports.getSymfonyUri = getSymfonyUri; exports.getSymfonyUri = getSymfonyUri;
/**
* Function to get the WP-CLI url
*
* @param version
*/
async function getWpCliUrl(version) {
switch (version) {
case 'latest':
return 'wp-cli/builds/blob/gh-pages/phar/wp-cli.phar?raw=true';
default:
return await getUri('wp-cli', '-' + version + '.phar', version, 'wp-cli/wp-cli/releases', 'v', 'download');
}
}
exports.getWpCliUrl = getWpCliUrl;
/** /**
* Function to add/move composer in the tools list * Function to add/move composer in the tools list
* *
@ -2041,7 +1942,7 @@ async function getCleanedToolsList(tools_csv) {
.map(function (extension) { .map(function (extension) {
return extension return extension
.trim() .trim()
.replace(/-agent|hirak\/|laravel\/|narrowspark\/automatic-|overtrue\/|robmorgan\/|symfony\//, ''); .replace(/robmorgan\/|hirak\/|narrowspark\/automatic-/, '');
}) })
.filter(Boolean); .filter(Boolean);
return [...new Set(tools_list)]; return [...new Set(tools_list)];
@ -2055,7 +1956,7 @@ exports.getCleanedToolsList = getCleanedToolsList;
* @param os_version * @param os_version
*/ */
async function addArchive(tool, url, os_version) { async function addArchive(tool, url, os_version) {
return (await utils.getCommand(os_version, 'tool')) + url + ' ' + tool; return (await getCommand(os_version, 'tool')) + url + ' ' + tool;
} }
exports.addArchive = addArchive; exports.addArchive = addArchive;
/** /**
@ -2088,7 +1989,7 @@ exports.addDevTools = addDevTools;
* @param os_version * @param os_version
*/ */
async function addPackage(tool, release, prefix, os_version) { async function addPackage(tool, release, prefix, os_version) {
const tool_command = await utils.getCommand(os_version, 'composertool'); const tool_command = await getCommand(os_version, 'composertool');
return tool_command + tool + ' ' + release + ' ' + prefix; return tool_command + tool + ' ' + release + ' ' + prefix;
} }
exports.addPackage = addPackage; exports.addPackage = addPackage;
@ -2111,112 +2012,70 @@ async function addTools(tools_csv, php_version, os_version) {
script += '\n'; script += '\n';
let url = ''; let url = '';
switch (tool) { switch (tool) {
case 'blackfire': case 'cs2pr':
case 'grpc_php_plugin': uri = await getUri(tool, '', version, 'releases', '', 'download');
case 'protoc': url = github + 'staabm/annotate-pull-request-from-checkstyle/' + uri;
script += await utils.customPackage(tool, 'tools', version, os_version);
break;
case 'blackfire-player':
url = await getPharUrl('https://get.blackfire.io', tool, 'v', version);
script += await addArchive(tool, url, os_version); script += await addArchive(tool, url, os_version);
break; break;
case 'php-cs-fixer':
uri = await getUri(tool, '.phar', version, 'releases', 'v', 'download');
url = github + 'FriendsOfPHP/PHP-CS-Fixer/' + uri;
script += await addArchive(tool, url, os_version);
break;
case 'phpcs':
case 'phpcbf':
url = github + 'squizlabs/PHP_CodeSniffer/' + uri;
script += await addArchive(tool, url, os_version);
break;
case 'phive':
script += await addPhive(version, os_version);
break;
case 'phpstan':
url = github + 'phpstan/phpstan/' + uri;
script += await addArchive(tool, url, os_version);
break;
case 'phpmd':
url = github + 'phpmd/phpmd/' + uri;
script += await addArchive(tool, url, os_version);
break;
case 'psalm':
url = github + 'vimeo/psalm/' + uri;
script += await addArchive(tool, url, os_version);
break;
case 'composer':
url = await getComposerUrl(version);
script += await addArchive('composer', url, os_version);
break;
case 'codeception': case 'codeception':
url = url =
'https://codeception.com/' + 'https://codeception.com/' +
(await getCodeceptionUri(version, php_version)); (await getCodeceptionUri(version, php_version));
script += await addArchive(tool, url, os_version); script += await addArchive(tool, url, os_version);
break; break;
case 'composer': case 'phpcpd':
url = await getComposerUrl(version); case 'phpunit':
script += await addArchive('composer', url, os_version); url = await getPharUrl('https://phar.phpunit.de', tool, '', version);
break;
case 'composer-normalize':
uri = await getUri(tool, '.phar', version, 'releases', '', 'download');
url = github + 'ergebnis/composer-normalize/' + uri;
script += await addArchive(tool, url, os_version);
break;
case 'composer-prefetcher':
script += await addPackage(tool, release, 'narrowspark/automatic-', os_version);
break;
case 'composer-require-checker':
uri = await getUri(tool, '.phar', version, 'releases', '', 'download');
url = github + 'maglnet/ComposerRequireChecker/' + uri;
script += await addArchive(tool, url, os_version);
break;
case 'composer-unused':
uri = await getUri(tool, '.phar', version, 'releases', '', 'download');
url = github + 'composer-unused/composer-unused/' + uri;
script += await addArchive(tool, url, os_version);
break;
case 'cs2pr':
uri = await getUri(tool, '', version, 'releases', '', 'download');
url = github + 'staabm/annotate-pull-request-from-checkstyle/' + uri;
script += await addArchive(tool, url, os_version); script += await addArchive(tool, url, os_version);
break; break;
case 'deployer': case 'deployer':
url = await getDeployerUrl(version); url = await getDeployerUrl(version);
script += await addArchive(tool, url, os_version); script += await addArchive(tool, url, os_version);
break; break;
case 'flex':
script += await addPackage(tool, release, 'symfony/', os_version);
break;
case 'infection':
url = github + 'infection/infection/' + uri;
script += await addArchive(tool, url, os_version);
break;
case 'pecl':
script += await utils.getCommand(os_version, 'pecl');
break;
case 'phan':
url = github + 'phan/phan/' + uri;
script += await addArchive(tool, url, os_version);
break;
case 'phing':
url = 'https://www.phing.info/get/phing-' + version + '.phar';
script += await addArchive(tool, url, os_version);
break;
case 'phinx': case 'phinx':
script += await addPackage(tool, release, 'robmorgan/', os_version); script += await addPackage(tool, release, 'robmorgan/', os_version);
break; break;
case 'phive':
script += await addPhive(version, os_version);
break;
case 'php-config':
case 'phpize':
script += await addDevTools(tool, os_version);
break;
case 'php-cs-fixer':
uri = await getUri(tool, '.phar', version, 'releases', 'v', 'download');
url = github + 'FriendsOfPHP/PHP-CS-Fixer/' + uri;
script += await addArchive(tool, url, os_version);
break;
case 'phpcbf':
case 'phpcs':
url = github + 'squizlabs/PHP_CodeSniffer/' + uri;
script += await addArchive(tool, url, os_version);
break;
case 'phpcpd':
case 'phpunit':
url = await getPharUrl('https://phar.phpunit.de', tool, '', version);
script += await addArchive(tool, url, os_version);
break;
case 'phplint':
script += await addPackage(tool, release, 'overtrue/', os_version);
break;
case 'phpmd':
url = github + 'phpmd/phpmd/' + uri;
script += await addArchive(tool, url, os_version);
break;
case 'phpstan':
url = github + 'phpstan/phpstan/' + uri;
script += await addArchive(tool, url, os_version);
break;
case 'prestissimo': case 'prestissimo':
script += await addPackage(tool, release, 'hirak/', os_version); script += await addPackage(tool, release, 'hirak/', os_version);
break; break;
case 'psalm': case 'composer-prefetcher':
url = github + 'vimeo/psalm/' + uri; script += await addPackage(tool, release, 'narrowspark/automatic-', os_version);
script += await addArchive(tool, url, os_version); break;
case 'pecl':
script += await getCommand(os_version, 'pecl');
break;
case 'php-config':
case 'phpize':
script += await addDevTools(tool, os_version);
break; break;
case 'symfony': case 'symfony':
case 'symfony-cli': case 'symfony-cli':
@ -2224,13 +2083,6 @@ async function addTools(tools_csv, php_version, os_version) {
url = github + 'symfony/cli/' + uri; url = github + 'symfony/cli/' + uri;
script += await addArchive('symfony', url, os_version); script += await addArchive('symfony', url, os_version);
break; break;
case 'vapor-cli':
script += await addPackage(tool, release, 'laravel/', os_version);
break;
case 'wp-cli':
url = github + (await getWpCliUrl(version));
script += await addArchive(tool, url, os_version);
break;
default: default:
script += await utils.addLog('$cross', tool, 'Tool ' + tool + ' is not supported', os_version); script += await utils.addLog('$cross', tool, 'Tool ' + tool + ' is not supported', os_version);
break; break;
@ -2289,21 +2141,18 @@ const config = __importStar(__webpack_require__(641));
/** /**
* Function to setup Xdebug * Function to setup Xdebug
* *
* @param extension
* @param version * @param version
* @param os_version * @param os_version
* @param pipe * @param pipe
*/ */
async function addCoverageXdebug(extension, version, os_version, pipe) { async function addCoverageXdebug(version, os_version, pipe) {
const xdebug = (await extensions.addExtension(extension, version, os_version, true)) + const xdebug = (await extensions.addExtension('xdebug', version, os_version, true)) + pipe;
pipe;
const ini = await config.addINIValues('xdebug.mode=coverage', os_version, true); const ini = await config.addINIValues('xdebug.mode=coverage', os_version, true);
const log = await utils.addLog('$tick', extension, 'Xdebug enabled as coverage driver', os_version); const log = await utils.addLog('$tick', 'xdebug', 'Xdebug enabled as coverage driver', os_version);
switch (true) { switch (true) {
case /^xdebug3$/.test(extension): case /8.[0-9]/.test(version):
case /^8\.0$/.test(version): return xdebug + '\n' + ini + '\n' + log;
return '\n' + xdebug + '\n' + ini + '\n' + log; case /5\.[3-6]|7.[0-4]/.test(version):
case /^xdebug$/.test(extension):
default: default:
return xdebug + '\n' + log; return xdebug + '\n' + log;
} }
@ -2318,7 +2167,7 @@ exports.addCoverageXdebug = addCoverageXdebug;
*/ */
async function addCoveragePCOV(version, os_version, pipe) { async function addCoveragePCOV(version, os_version, pipe) {
let script = '\n'; let script = '\n';
switch (true) { switch (version) {
default: default:
script += script +=
(await extensions.addExtension('pcov', version, os_version, true)) + (await extensions.addExtension('pcov', version, os_version, true)) +
@ -2340,7 +2189,8 @@ async function addCoveragePCOV(version, os_version, pipe) {
script += await utils.addLog('$tick', 'coverage: pcov', 'PCOV enabled as coverage driver', os_version); script += await utils.addLog('$tick', 'coverage: pcov', 'PCOV enabled as coverage driver', os_version);
// version is not supported // version is not supported
break; break;
case /5\.[3-6]|7\.0/.test(version): case '5.6':
case '7.0':
script += await utils.addLog('$cross', 'pcov', 'PHP 7.1 or newer is required', os_version); script += await utils.addLog('$cross', 'pcov', 'PHP 7.1 or newer is required', os_version);
break; break;
} }
@ -2386,9 +2236,7 @@ async function addCoverage(coverage_driver, version, os_version) {
case 'pcov': case 'pcov':
return script + (await addCoveragePCOV(version, os_version, pipe)); return script + (await addCoveragePCOV(version, os_version, pipe));
case 'xdebug': case 'xdebug':
case 'xdebug3': return script + (await addCoverageXdebug(version, os_version, pipe));
return (script +
(await addCoverageXdebug(coverage_driver, version, os_version, pipe)));
case 'none': case 'none':
return script + (await disableCoverage(version, os_version, pipe)); return script + (await disableCoverage(version, os_version, pipe));
default: default:
@ -2434,10 +2282,10 @@ const utils = __importStar(__webpack_require__(163));
*/ */
async function addINIValuesUnix(ini_values_csv) { async function addINIValuesUnix(ini_values_csv) {
const ini_values = await utils.CSVArray(ini_values_csv); const ini_values = await utils.CSVArray(ini_values_csv);
let script = ''; let script = '\n';
await utils.asyncForEach(ini_values, async function (line) { await utils.asyncForEach(ini_values, async function (line) {
script += script +=
'\n' + (await utils.addLog('$tick', line, 'Added to php.ini', 'linux')); (await utils.addLog('$tick', line, 'Added to php.ini', 'linux')) + '\n';
}); });
return 'echo "' + ini_values.join('\n') + '" >> $ini_file' + script; return 'echo "' + ini_values.join('\n') + '" >> $ini_file' + script;
} }
@ -2454,7 +2302,10 @@ async function addINIValuesWindows(ini_values_csv) {
script += script +=
(await utils.addLog('$tick', line, 'Added to php.ini', 'win32')) + '\n'; (await utils.addLog('$tick', line, 'Added to php.ini', 'win32')) + '\n';
}); });
return ('Add-Content "$php_dir\\php.ini" "' + ini_values.join('\n') + '"' + script); return ('Add-Content C:\\tools\\php\\php.ini "' +
ini_values.join('\n') +
'"' +
script);
} }
exports.addINIValuesWindows = addINIValuesWindows; exports.addINIValuesWindows = addINIValuesWindows;
/** /**
@ -2526,7 +2377,6 @@ const coverage = __importStar(__webpack_require__(635));
const extensions = __importStar(__webpack_require__(911)); const extensions = __importStar(__webpack_require__(911));
const tools = __importStar(__webpack_require__(534)); const tools = __importStar(__webpack_require__(534));
const utils = __importStar(__webpack_require__(163)); const utils = __importStar(__webpack_require__(163));
const matchers = __importStar(__webpack_require__(86));
/** /**
* Build the script * Build the script
* *
@ -2535,18 +2385,19 @@ const matchers = __importStar(__webpack_require__(86));
* @param os_version * @param os_version
*/ */
async function build(filename, version, os_version) { async function build(filename, version, os_version) {
const name = 'setup-php';
const url = 'setup-php.com/support';
// taking inputs // taking inputs
const name = 'setup-php';
const url = 'https://setup-php.com/support';
const extension_csv = (await utils.getInput('extensions', false)) || const extension_csv = (await utils.getInput('extensions', false)) ||
(await utils.getInput('extension', false)); (await utils.getInput('extension', false)) ||
const ini_values_csv = await utils.getInput('ini-values', false); (await utils.getInput('extension-csv', false));
const ini_values_csv = (await utils.getInput('ini-values', false)) ||
(await utils.getInput('ini-values-csv', false));
const coverage_driver = await utils.getInput('coverage', false); const coverage_driver = await utils.getInput('coverage', false);
const pecl = await utils.getInput('pecl', false); const pecl = await utils.getInput('pecl', false);
let tools_csv = await utils.getInput('tools', false); let tools_csv = await utils.getInput('tools', false);
if (pecl == 'true' || if (pecl == 'true' ||
/.*-(beta|alpha|devel|snapshot).*/.test(extension_csv) || /.*-(beta|alpha|devel|snapshot).*/.test(extension_csv)) {
/.*-(\d+\.\d+\.\d+).*/.test(extension_csv)) {
tools_csv = 'pecl, ' + tools_csv; tools_csv = 'pecl, ' + tools_csv;
} }
let script = await utils.readScript(filename); let script = await utils.readScript(filename);
@ -2570,9 +2421,9 @@ exports.build = build;
*/ */
async function run() { async function run() {
try { try {
const os_version = process.platform;
let version = await utils.getInput('php-version', true); let version = await utils.getInput('php-version', true);
version = version.length > 1 ? version.slice(0, 3) : version + '.0'; version = version.length > 1 ? version.slice(0, 3) : version + '.0';
const os_version = process.platform;
// check the os version and run the respective script // check the os version and run the respective script
let script_path = ''; let script_path = '';
switch (os_version) { switch (os_version) {
@ -2586,7 +2437,6 @@ async function run() {
await exec_1.exec('pwsh ' + script_path + ' ' + version + ' ' + __dirname); await exec_1.exec('pwsh ' + script_path + ' ' + version + ' ' + __dirname);
break; break;
} }
await matchers.addMatchers();
} }
catch (error) { catch (error) {
core.setFailed(error.message); core.setFailed(error.message);
@ -2841,6 +2691,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
}; };
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
exports.addExtension = exports.addExtensionLinux = exports.addExtensionWindows = exports.addExtensionDarwin = void 0; exports.addExtension = exports.addExtensionLinux = exports.addExtensionWindows = exports.addExtensionDarwin = void 0;
const path = __importStar(__webpack_require__(622));
const utils = __importStar(__webpack_require__(163)); const utils = __importStar(__webpack_require__(163));
/** /**
* Install and enable extensions for darwin * Install and enable extensions for darwin
@ -2851,41 +2702,23 @@ const utils = __importStar(__webpack_require__(163));
*/ */
async function addExtensionDarwin(extension_csv, version, pipe) { async function addExtensionDarwin(extension_csv, version, pipe) {
const extensions = await utils.extensionArray(extension_csv); const extensions = await utils.extensionArray(extension_csv);
let add_script = '\n'; let script = '\n';
let remove_script = '';
await utils.asyncForEach(extensions, async function (extension) { await utils.asyncForEach(extensions, async function (extension) {
const version_extension = version + extension; const version_extension = version + extension;
const [ext_name, ext_version] = extension.split('-'); const [extension_name, stability] = extension.split('-');
const ext_prefix = await utils.getExtensionPrefix(ext_name); const ext_prefix = await utils.getExtensionPrefix(extension_name);
const command_prefix = 'pecl_install '; const command_prefix = 'pecl_install ';
let command = ''; let command = '';
switch (true) { switch (true) {
// match :extension // match pre-release versions
case /^:/.test(ext_name):
remove_script += '\nremove_extension ' + ext_name.slice(1);
return;
// match 5.3blackfire...5.6blackfire, 7.0blackfire...7.4blackfire
// match 5.3blackfire-1.31.0...5.6blackfire-1.31.0, 7.0blackfire-1.31.0...7.4blackfire-1.31.0
// match pdo_oci and oci8
// match 5.3ioncube...7.4ioncube, 7.0ioncube...7.4ioncube
// match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4
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):
add_script += await utils.customPackage(ext_name, 'ext', extension, 'darwin');
return;
// match pre-release versions. For example - xdebug-beta
case /.*-(beta|alpha|devel|snapshot)/.test(version_extension): case /.*-(beta|alpha|devel|snapshot)/.test(version_extension):
add_script += await utils.joins('\nadd_unstable_extension', ext_name, ext_version, ext_prefix); script +=
return; '\nadd_unstable_extension ' +
// match semver extension_name +
case /.*-\d+\.\d+\.\d+.*/.test(version_extension): ' ' +
add_script += await utils.joins('\nadd_pecl_extension', ext_name, ext_version, ext_prefix); stability +
return; ' ' +
// match 5.3pcov to 7.0pcov ext_prefix;
case /(5\.[3-6]|7\.0)pcov/.test(version_extension):
add_script += await utils.getUnsupportedLog('pcov', version, 'darwin');
return; return;
// match 5.6xdebug to 8.0xdebug, 5.6swoole to 8.0swoole // match 5.6xdebug to 8.0xdebug, 5.6swoole to 8.0swoole
// match 5.6grpc to 7.4grpc, 5.6protobuf to 7.4protobuf // match 5.6grpc to 7.4grpc, 5.6protobuf to 7.4protobuf
@ -2893,7 +2726,7 @@ async function addExtensionDarwin(extension_csv, version, pipe) {
case /(5\.6|7\.[0-4]|8\.[0-9])xdebug/.test(version_extension): case /(5\.6|7\.[0-4]|8\.[0-9])xdebug/.test(version_extension):
case /(5\.6|7\.[0-4])(grpc|protobuf|swoole)/.test(version_extension): case /(5\.6|7\.[0-4])(grpc|protobuf|swoole)/.test(version_extension):
case /(7\.[1-4]|8\.[0-9])pcov/.test(version_extension): case /(7\.[1-4]|8\.[0-9])pcov/.test(version_extension):
command = 'add_brew_extension ' + ext_name; command = 'add_brew_extension ' + extension_name;
break; break;
// match 5.6redis // match 5.6redis
case /5\.6redis/.test(version_extension): case /5\.6redis/.test(version_extension):
@ -2901,20 +2734,42 @@ async function addExtensionDarwin(extension_csv, version, pipe) {
break; break;
// match imagick // match imagick
case /^imagick$/.test(extension): case /^imagick$/.test(extension):
command = await utils.joins('brew install pkg-config imagemagick' + pipe, '&& ' + command_prefix + 'imagick' + pipe); command =
'brew install pkg-config imagemagick' +
pipe +
' && ' +
command_prefix +
'imagick' +
pipe;
break; break;
// match sqlite // match sqlite
case /^sqlite$/.test(extension): case /^sqlite$/.test(extension):
extension = 'sqlite3'; extension = 'sqlite3';
command = command_prefix + extension; command = command_prefix + extension;
break; break;
// match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
script +=
'\nbash ' +
path.join(__dirname, '../src/scripts/ext/phalcon_darwin.sh') +
' ' +
extension +
' ' +
version;
return;
default: default:
command = command_prefix + extension; command = command_prefix + extension;
break; break;
} }
add_script += await utils.joins('\nadd_extension', extension, '"' + command + '"', ext_prefix); script +=
'\nadd_extension ' +
extension +
' "' +
command +
'" ' +
(await utils.getExtensionPrefix(extension));
}); });
return add_script + remove_script; return script;
} }
exports.addExtensionDarwin = addExtensionDarwin; exports.addExtensionDarwin = addExtensionDarwin;
/** /**
@ -2925,69 +2780,48 @@ exports.addExtensionDarwin = addExtensionDarwin;
*/ */
async function addExtensionWindows(extension_csv, version) { async function addExtensionWindows(extension_csv, version) {
const extensions = await utils.extensionArray(extension_csv); const extensions = await utils.extensionArray(extension_csv);
let add_script = '\n'; let script = '\n';
let remove_script = '';
await utils.asyncForEach(extensions, async function (extension) { await utils.asyncForEach(extensions, async function (extension) {
const [ext_name, ext_version] = extension.split('-'); const [extension_name, stability] = extension.split('-');
const version_extension = version + extension; const version_extension = version + extension;
let matches;
switch (true) { switch (true) {
// Match :extension // match pre-release versions
case /^:/.test(ext_name):
remove_script += '\nRemove-Extension ' + ext_name.slice(1);
break;
// match 5.3blackfire...5.6blackfire, 7.0blackfire...7.4blackfire
// match 5.3blackfire-1.31.0...5.6blackfire-1.31.0, 7.0blackfire-1.31.0...7.4blackfire-1.31.0
// match pdo_oci and oci8
// match 5.3ioncube...7.4ioncube, 7.0ioncube...7.4ioncube
// match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4
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):
add_script += await utils.customPackage(ext_name, 'ext', extension, 'win32');
return;
// match pre-release versions. For example - xdebug-beta
case /.*-(beta|alpha|devel|snapshot)/.test(version_extension): case /.*-(beta|alpha|devel|snapshot)/.test(version_extension):
add_script += await utils.joins('\nAdd-Extension', ext_name, ext_version); script += '\nAdd-Extension ' + extension_name + ' ' + stability;
break; break;
// match semver without state // match 5.6mysql, 5.6mysqli, 5.6mysqlnd
case /.*-\d+\.\d+\.\d+$/.test(version_extension): case /^5\.6(mysql|mysqli|mysqlnd)$/.test(version_extension):
add_script += await utils.joins('\nAdd-Extension', ext_name, 'stable', ext_version); script +=
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]);
break;
// match 5.3pcov to 7.0pcov
case /(5\.[3-6]|7\.0)pcov/.test(version_extension):
add_script += await utils.getUnsupportedLog('pcov', version, 'win32');
break;
// match 5.3mysql..5.6mysql
// match 5.3mysqli..5.6mysqli
// match 5.3mysqlnd..5.6mysqlnd
case /^5\.\d(mysql|mysqli|mysqlnd)$/.test(version_extension):
add_script +=
'\nAdd-Extension mysql\nAdd-Extension mysqli\nAdd-Extension mysqlnd'; '\nAdd-Extension mysql\nAdd-Extension mysqli\nAdd-Extension mysqlnd';
break; break;
// match 7.0mysql..8.0mysql // match 7.0mysql..8.0mysql
// match 7.0mysqli..8.0mysqli // match 7.0mysqli..8.0mysqli
// match 7.0mysqlnd..8.0mysqlnd // match 7.0mysqlnd..8.0mysqlnd
case /[7-8]\.\d(mysql|mysqli|mysqlnd)$/.test(version_extension): case /[7-8]\.\d(mysql|mysqli|mysqlnd)$/.test(version_extension):
add_script += '\nAdd-Extension mysqli\nAdd-Extension mysqlnd'; script += '\nAdd-Extension mysqli\nAdd-Extension mysqlnd';
break; break;
// match sqlite // match sqlite
case /^sqlite$/.test(extension): case /^sqlite$/.test(extension):
extension = 'sqlite3'; extension = 'sqlite3';
add_script += await utils.joins('\nAdd-Extension', extension); script += '\nAdd-Extension ' + extension;
break;
// match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
script +=
'\n& ' +
path.join(__dirname, '../src/scripts/ext/phalcon.ps1') +
' ' +
extension +
' ' +
version +
'\n';
break; break;
default: default:
add_script += '\nAdd-Extension ' + extension; script += '\nAdd-Extension ' + extension;
break; break;
} }
}); });
return add_script + remove_script; return script;
} }
exports.addExtensionWindows = addExtensionWindows; exports.addExtensionWindows = addExtensionWindows;
/** /**
@ -2999,78 +2833,61 @@ exports.addExtensionWindows = addExtensionWindows;
*/ */
async function addExtensionLinux(extension_csv, version, pipe) { async function addExtensionLinux(extension_csv, version, pipe) {
const extensions = await utils.extensionArray(extension_csv); const extensions = await utils.extensionArray(extension_csv);
let add_script = '\n'; let script = '\n';
let remove_script = '';
await utils.asyncForEach(extensions, async function (extension) { await utils.asyncForEach(extensions, async function (extension) {
const version_extension = version + extension; const version_extension = version + extension;
const [ext_name, ext_version] = extension.split('-'); const [extension_name, stability] = extension.split('-');
const ext_prefix = await utils.getExtensionPrefix(ext_name); const ext_prefix = await utils.getExtensionPrefix(extension_name);
const command_prefix = 'sudo $debconf_fix apt-get install -y php'; const command_prefix = 'sudo $debconf_fix apt-get install -y php';
let command = ''; let command = '';
switch (true) { switch (true) {
// Match :extension // match pre-release versions
case /^:/.test(ext_name):
remove_script += '\nremove_extension ' + ext_name.slice(1);
return;
// match 5.3blackfire...5.6blackfire, 7.0blackfire...7.4blackfire
// match 5.3blackfire-1.31.0...5.6blackfire-1.31.0, 7.0blackfire-1.31.0...7.4blackfire-1.31.0
// match 5.3pdo_cubrid...7.2php_cubrid, 5.3cubrid...7.4cubrid
// 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
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):
add_script += await utils.customPackage(ext_name, 'ext', extension, 'linux');
return;
// match pre-release versions. For example - xdebug-beta
case /.*-(beta|alpha|devel|snapshot)/.test(version_extension): case /.*-(beta|alpha|devel|snapshot)/.test(version_extension):
add_script += await utils.joins('\nadd_unstable_extension', ext_name, ext_version, ext_prefix); script +=
'\nadd_unstable_extension ' +
extension_name +
' ' +
stability +
' ' +
ext_prefix;
return; return;
// match semver versions // match 5.6gearman..7.4gearman
case /.*-\d+\.\d+\.\d+.*/.test(version_extension): case /^((5\.6)|(7\.[0-4]))gearman$/.test(version_extension):
add_script += await utils.joins('\nadd_pecl_extension', ext_name, ext_version, ext_prefix); command =
return; '\nbash ' +
// match 5.3pcov to 7.0pcov path.join(__dirname, '../src/scripts/ext/gearman.sh') +
case /(5\.[3-6]|7\.0)pcov/.test(version_extension): ' ' +
add_script += await utils.getUnsupportedLog('pcov', version, 'linux'); version +
return; pipe;
// match 7.2xdebug3..7.4xdebug3
case /^7\.[2-4]xdebug3$/.test(version_extension):
add_script +=
'\nadd_extension_from_source xdebug xdebug/xdebug master --enable-xdebug zend_extension';
return;
// match 8.0xdebug3
case /^8\.[0-9]xdebug3$/.test(version_extension):
extension = 'xdebug';
command = command_prefix + version + '-' + extension + pipe;
break; break;
// match pdo extensions // match 7.0phalcon3...7.3phalcon3 or 7.2phalcon4...7.4phalcon4
case /.*pdo[_-].*/.test(version_extension): case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
extension = extension.replace(/pdo[_-]|3/, ''); script +=
add_script += '\nadd_pdo_extension ' + extension; '\nbash ' +
path.join(__dirname, '../src/scripts/ext/phalcon.sh') +
' ' +
extension +
' ' +
version;
return; return;
// match ast and uopz
case /^(ast|uopz)$/.test(extension):
command = command_prefix + '-' + extension + pipe;
break;
// match sqlite // match sqlite
case /^sqlite$/.test(extension): case /^sqlite$/.test(extension):
extension = 'sqlite3'; extension = 'sqlite3';
command = command_prefix + version + '-' + extension + pipe; command = command_prefix + version + '-' + extension + pipe;
break; break;
default: default:
command = command_prefix + version + '-' + extension + pipe; command =
command_prefix +
version +
'-' +
extension.replace('pdo_', '').replace('pdo-', '') +
pipe;
break; break;
} }
add_script += await utils.joins('\nadd_extension', extension, '"' + command + '"', ext_prefix); script +=
'\nadd_extension ' + extension + ' "' + command + '" ' + ext_prefix;
}); });
return add_script + remove_script; return script;
} }
exports.addExtensionLinux = addExtensionLinux; exports.addExtensionLinux = addExtensionLinux;
/** /**

View File

@ -13,7 +13,7 @@ jobs:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Setup PHP, with composer and extensions - name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php
with: with:
php-version: ${{ matrix.php-versions }} php-version: ${{ matrix.php-versions }}
- name: Get composer cache directory - name: Get composer cache directory

View File

@ -1,31 +0,0 @@
# GitHub Action for Blackfire Player
name: Play a Blackfire Scenario
on: [push, pull_request]
jobs:
blackfire-player:
name: Blackfire (PHP ${{ matrix.php-versions }})
# Add your Blackfire credentials securely using GitHub Secrets
env:
BLACKFIRE_SERVER_ID: ${{ secrets.BLACKFIRE_SERVER_ID }}
BLACKFIRE_SERVER_TOKEN: ${{ secrets.BLACKFIRE_SERVER_TOKEN }}
BLACKFIRE_CLIENT_ID: ${{ secrets.BLACKFIRE_CLIENT_ID }}
BLACKFIRE_CLIENT_TOKEN: ${{ secrets.BLACKFIRE_CLIENT_TOKEN }}
runs-on: ${{ matrix.operating-system }}
strategy:
fail-fast: false
matrix:
operating-system: [ubuntu-latest, windows-latest, macos-latest]
php-versions: ['7.2', '7.3', '7.4']
# blackfire-player supports PHP >= 5.5
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php
with:
php-version: ${{ matrix.php-versions }}
extensions: blackfire
tools: blackfire, blackfire-player #Setup Blackfire client, agent and player
coverage: none
- name: Play the scenario
run: blackfire-player run scenario.bkf # Refer to https://blackfire.io/docs/player/index#usage

View File

@ -1,31 +0,0 @@
# GitHub Action for Blackfire
name: Profiling with blackfire
on: [push, pull_request]
jobs:
blackfire:
name: Blackfire (PHP ${{ matrix.php-versions }})
# Add your Blackfire credentials securely using GitHub Secrets
env:
BLACKFIRE_SERVER_ID: ${{ secrets.BLACKFIRE_SERVER_ID }}
BLACKFIRE_SERVER_TOKEN: ${{ secrets.BLACKFIRE_SERVER_TOKEN }}
BLACKFIRE_CLIENT_ID: ${{ secrets.BLACKFIRE_CLIENT_ID }}
BLACKFIRE_CLIENT_TOKEN: ${{ secrets.BLACKFIRE_CLIENT_TOKEN }}
runs-on: ${{ matrix.operating-system }}
strategy:
fail-fast: false
matrix:
operating-system: [ubuntu-latest, windows-latest, macos-latest]
php-versions: ['7.2', '7.3', '7.4']
# Blackfire supports PHP >= 5.3 on ubuntu and macos and PHP >= 5.4 on windows
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php
with:
php-version: ${{ matrix.php-versions }}
extensions: blackfire
tools: blackfire #Setup Blackfire client and agent
coverage: none
- name: Profile
run: blackfire run php my-script.php # Refer to https://blackfire.io/docs/cookbooks/profiling-cli

View File

@ -27,7 +27,7 @@ jobs:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Setup PHP - name: Setup PHP
uses: shivammathur/setup-php@v2 uses: shivammathur/setup-php@v1
with: with:
php-version: ${{ matrix.php-versions }} php-version: ${{ matrix.php-versions }}
# You can also use ext-apcu or ext-memcached instead of ext-redis # You can also use ext-apcu or ext-memcached instead of ext-redis
@ -65,7 +65,7 @@ jobs:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Setup PHP - name: Setup PHP
uses: shivammathur/setup-php@v2 uses: shivammathur/setup-php@v1
with: with:
php-version: '7.3' php-version: '7.3'
extensions: mbstring, intl extensions: mbstring, intl
@ -92,7 +92,7 @@ jobs:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Setup PHP - name: Setup PHP
uses: shivammathur/setup-php@v2 uses: shivammathur/setup-php@v1
with: with:
php-version: '7.3' php-version: '7.3'
extensions: mbstring, intl extensions: mbstring, intl

View File

@ -27,7 +27,7 @@ jobs:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Setup PHP - name: Setup PHP
uses: shivammathur/setup-php@v2 uses: shivammathur/setup-php@v1
with: with:
php-version: ${{ matrix.php-versions }} php-version: ${{ matrix.php-versions }}
# You can also use ext-apcu or ext-memcached instead of ext-redis # You can also use ext-apcu or ext-memcached instead of ext-redis
@ -63,7 +63,7 @@ jobs:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Setup PHP - name: Setup PHP
uses: shivammathur/setup-php@v2 uses: shivammathur/setup-php@v1
with: with:
php-version: '7.3' php-version: '7.3'
extensions: mbstring, intl extensions: mbstring, intl
@ -90,7 +90,7 @@ jobs:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Setup PHP - name: Setup PHP
uses: shivammathur/setup-php@v2 uses: shivammathur/setup-php@v1
with: with:
php-version: '7.3' php-version: '7.3'
extensions: mbstring, intl extensions: mbstring, intl

View File

@ -13,7 +13,7 @@ jobs:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Setup PHP - name: Setup PHP
uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php
with: with:
php-version: ${{ matrix.php-versions }} php-version: ${{ matrix.php-versions }}
extensions: mbstring, intl, pdo_sqlite, pdo_mysql extensions: mbstring, intl, pdo_sqlite, pdo_mysql
@ -43,7 +43,7 @@ jobs:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Setup PHP - name: Setup PHP
uses: shivammathur/setup-php@v2 uses: shivammathur/setup-php@v1
with: with:
php-version: '7.3' php-version: '7.3'
extensions: mbstring, intl extensions: mbstring, intl
@ -70,7 +70,7 @@ jobs:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Setup PHP - name: Setup PHP
uses: shivammathur/setup-php@v2 uses: shivammathur/setup-php@v1
with: with:
php-version: '7.3' php-version: '7.3'
extensions: mbstring, intl extensions: mbstring, intl

View File

@ -12,7 +12,7 @@ jobs:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Setup PHP, with composer and extensions - name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php
with: with:
php-version: ${{ matrix.php-versions }} php-version: ${{ matrix.php-versions }}
extensions: mbstring, intl, curl, dom extensions: mbstring, intl, curl, dom

View File

@ -36,7 +36,7 @@ jobs:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Setup PHP, with composer and extensions - name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php
with: with:
php-version: ${{ matrix.php-versions }} php-version: ${{ matrix.php-versions }}
extensions: mbstring, dom, fileinfo, mysql extensions: mbstring, dom, fileinfo, mysql

View File

@ -38,7 +38,7 @@ jobs:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Setup PHP, with composer and extensions - name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php
with: with:
php-version: ${{ matrix.php-versions }} php-version: ${{ matrix.php-versions }}
extensions: mbstring, dom, fileinfo, pgsql extensions: mbstring, dom, fileinfo, pgsql

View File

@ -14,7 +14,7 @@ jobs:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Setup PHP, with composer and extensions - name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php
with: with:
php-version: ${{ matrix.php-versions }} php-version: ${{ matrix.php-versions }}
extensions: mbstring, dom, fileinfo extensions: mbstring, dom, fileinfo

View File

@ -36,7 +36,7 @@ jobs:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Setup PHP, with composer and extensions - name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php
with: with:
php-version: ${{ matrix.php-versions }} php-version: ${{ matrix.php-versions }}
extensions: mbstring, dom, fileinfo, mysql extensions: mbstring, dom, fileinfo, mysql

View File

@ -38,7 +38,7 @@ jobs:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Setup PHP, with composer and extensions - name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php
with: with:
php-version: ${{ matrix.php-versions }} php-version: ${{ matrix.php-versions }}
extensions: mbstring, dom, fileinfo, pgsql extensions: mbstring, dom, fileinfo, pgsql

View File

@ -14,7 +14,7 @@ jobs:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Setup PHP, with composer and extensions - name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php
with: with:
php-version: ${{ matrix.php-versions }} php-version: ${{ matrix.php-versions }}
extensions: mbstring, dom, fileinfo, mysql extensions: mbstring, dom, fileinfo, mysql

View File

@ -36,7 +36,7 @@ jobs:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Setup PHP, with composer and extensions - name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php
with: with:
php-version: ${{ matrix.php-versions }} php-version: ${{ matrix.php-versions }}
extensions: mbstring, dom, zip, phalcon4, mysql #use phalcon3 for the phalcon 3.x. extensions: mbstring, dom, zip, phalcon4, mysql #use phalcon3 for the phalcon 3.x.

View File

@ -37,7 +37,7 @@ jobs:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Setup PHP, with composer and extensions - name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php
with: with:
php-version: ${{ matrix.php-versions }} php-version: ${{ matrix.php-versions }}
extensions: mbstring, dom, zip, phalcon4, pgsql #use phalcon3 for the phalcon 3.x extensions: mbstring, dom, zip, phalcon4, pgsql #use phalcon3 for the phalcon 3.x

View File

@ -18,7 +18,7 @@ jobs:
with: with:
node-version: ${{ matrix.node-versions }} node-version: ${{ matrix.node-versions }}
- name: Setup PHP, with composer and extensions - name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php
with: with:
php-version: ${{ matrix.php-versions }} php-version: ${{ matrix.php-versions }}
extensions: mbstring extensions: mbstring

View File

@ -12,7 +12,7 @@ jobs:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Setup PHP, with composer and extensions - name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php
with: with:
php-version: ${{ matrix.php-versions }} php-version: ${{ matrix.php-versions }}
extensions: mbstring, simplexml, dom extensions: mbstring, simplexml, dom

View File

@ -23,7 +23,7 @@ jobs:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Setup PHP, with composer and extensions - name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php
with: with:
php-version: ${{ matrix.php-versions }} php-version: ${{ matrix.php-versions }}
extensions: mbstring, xml, ctype, iconv, intl, pdo_sqlite, mysql extensions: mbstring, xml, ctype, iconv, intl, pdo_sqlite, mysql

View File

@ -23,7 +23,7 @@ jobs:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Setup PHP, with composer and extensions - name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php
with: with:
php-version: ${{ matrix.php-versions }} php-version: ${{ matrix.php-versions }}
extensions: mbstring, xml, ctype, iconv, intl, pdo_sqlite, pgsql extensions: mbstring, xml, ctype, iconv, intl, pdo_sqlite, pgsql

View File

@ -14,7 +14,7 @@ jobs:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Setup PHP, with composer and extensions - name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php
with: with:
php-version: ${{ matrix.php-versions }} php-version: ${{ matrix.php-versions }}
extensions: mbstring, xml, ctype, iconv, intl, pdo_sqlite extensions: mbstring, xml, ctype, iconv, intl, pdo_sqlite

View File

@ -33,7 +33,7 @@ jobs:
with: with:
node-version: 10.x node-version: 10.x
- name: Setup PHP, with composer and extensions - name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php
with: with:
php-version: ${{ matrix.php-versions }} php-version: ${{ matrix.php-versions }}
extensions: mbstring, intl, gd, imagick, zip, dom, mysql extensions: mbstring, intl, gd, imagick, zip, dom, mysql

View File

@ -33,7 +33,7 @@ jobs:
with: with:
node-version: 10.x node-version: 10.x
- name: Setup PHP, with composer and extensions - name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php
with: with:
php-version: ${{ matrix.php-versions }} php-version: ${{ matrix.php-versions }}
extensions: mbstring, intl, gd, imagick, zip, dom, pgsql extensions: mbstring, intl, gd, imagick, zip, dom, pgsql

View File

@ -12,7 +12,7 @@ jobs:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Setup PHP, with composer and extensions - name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php uses: shivammathur/setup-php@v1 #https://github.com/shivammathur/setup-php
with: with:
php-version: ${{ matrix.php-versions }} php-version: ${{ matrix.php-versions }}
extensions: mbstring, bcmath, curl, intl extensions: mbstring, bcmath, curl, intl

27
package-lock.json generated
View File

@ -1,6 +1,6 @@
{ {
"name": "setup-php", "name": "setup-php",
"version": "2.5.0", "version": "1.9.7",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {
@ -1103,12 +1103,6 @@
"@babel/types": "^7.3.0" "@babel/types": "^7.3.0"
} }
}, },
"@types/color-name": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/@types/color-name/-/color-name-1.1.1.tgz",
"integrity": "sha512-rr+OQyAjxze7GgWrSaJwydHStIhHq2lvY3BOC2Mj7KnzI7XK0Uw1TOOdI9lDoajEbSWLiYgoo4f1R51erQfhPQ==",
"dev": true
},
"@types/graceful-fs": { "@types/graceful-fs": {
"version": "4.1.3", "version": "4.1.3",
"resolved": "https://registry.npmjs.org/@types/graceful-fs/-/graceful-fs-4.1.3.tgz", "resolved": "https://registry.npmjs.org/@types/graceful-fs/-/graceful-fs-4.1.3.tgz",
@ -1375,12 +1369,11 @@
"dev": true "dev": true
}, },
"ansi-styles": { "ansi-styles": {
"version": "4.2.1", "version": "4.3.0",
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.2.1.tgz", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
"integrity": "sha512-9VGjrMsG1vePxcSweQsN20KY/c4zN0h9fLjqAbwbPfahM3t+NL+M9HC8xeXG2I8pX5NoamTGNuomEUFI7fcUjA==", "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
"dev": true, "dev": true,
"requires": { "requires": {
"@types/color-name": "^1.1.1",
"color-convert": "^2.0.1" "color-convert": "^2.0.1"
} }
}, },
@ -1581,9 +1574,9 @@
} }
}, },
"babel-preset-current-node-syntax": { "babel-preset-current-node-syntax": {
"version": "0.1.3", "version": "0.1.4",
"resolved": "https://registry.npmjs.org/babel-preset-current-node-syntax/-/babel-preset-current-node-syntax-0.1.3.tgz", "resolved": "https://registry.npmjs.org/babel-preset-current-node-syntax/-/babel-preset-current-node-syntax-0.1.4.tgz",
"integrity": "sha512-uyexu1sVwcdFnyq9o8UQYsXwXflIh8LvrF5+cKrYam93ned1CStffB3+BEcsxGSgagoA3GEyjDqO4a/58hyPYQ==", "integrity": "sha512-5/INNCYhUGqw7VbVjT/hb3ucjgkVHKXY7lX3ZjlN4gm565VyFmJUrJ/h+h16ECVB38R/9SF6aACydpKMLZ/c9w==",
"dev": true, "dev": true,
"requires": { "requires": {
"@babel/plugin-syntax-async-generators": "^7.8.4", "@babel/plugin-syntax-async-generators": "^7.8.4",
@ -7317,9 +7310,9 @@
"dev": true "dev": true
}, },
"uuid": { "uuid": {
"version": "8.3.0", "version": "8.3.1",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.0.tgz", "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.1.tgz",
"integrity": "sha512-fX6Z5o4m6XsXBdli9g7DtWgAx+osMsRRZFKma1mIUsLCz6vRvv+pz5VNbyu9UEDzpMWulZfvpgb/cmDXVulYFQ==", "integrity": "sha512-FOmRr+FmWEIG8uhZv6C2bTgEVXsHk08kE7mPlrBbEe+c3r9pjceVPgupIfNIhc4yx55H69OXANrUaSuu9eInKg==",
"dev": true, "dev": true,
"optional": true "optional": true
}, },

View File

@ -1,6 +1,6 @@
{ {
"name": "setup-php", "name": "setup-php",
"version": "2.5.0", "version": "1.9.7",
"private": false, "private": false,
"description": "Setup PHP for use with GitHub Actions", "description": "Setup PHP for use with GitHub Actions",
"main": "dist/index.js", "main": "dist/index.js",
@ -30,27 +30,27 @@
"fs": "0.0.1-security" "fs": "0.0.1-security"
}, },
"devDependencies": { "devDependencies": {
"@types/jest": "^26.0.13", "@types/jest": "^26.0.14",
"@types/node": "^14.6.4", "@types/node": "^14.11.2",
"@typescript-eslint/eslint-plugin": "^4.0.1", "@typescript-eslint/eslint-plugin": "^4.3.0",
"@typescript-eslint/parser": "^4.0.1", "@typescript-eslint/parser": "^4.3.0",
"@zeit/ncc": "^0.22.3", "@zeit/ncc": "^0.22.3",
"eslint": "^7.8.1", "eslint": "^7.10.0",
"eslint-config-prettier": "^6.11.0", "eslint-config-prettier": "^6.12.0",
"eslint-plugin-import": "^2.22.0", "eslint-plugin-import": "^2.22.1",
"eslint-plugin-jest": "^24.0.0", "eslint-plugin-jest": "^24.0.2",
"eslint-plugin-prettier": "^3.1.4", "eslint-plugin-prettier": "^3.1.4",
"husky": "^4.2.5", "husky": "^4.3.0",
"jest": "^26.4.2", "jest": "^26.4.2",
"jest-circus": "^26.4.2", "jest-circus": "^26.4.2",
"prettier": "^2.1.1", "prettier": "^2.1.2",
"ts-jest": "^26.3.0", "ts-jest": "^26.4.1",
"typescript": "^4.0.2" "typescript": "^4.0.3"
}, },
"husky": { "husky": {
"skipCI": true, "skipCI": true,
"hooks": { "hooks": {
"pre-commit": "npm run format && npm run lint && npm run test && npm run build && npm run release" "pre-commit": "npm run format && npm run lint && npm run build && npm run release"
} }
} }
} }

View File

@ -9,10 +9,10 @@ export async function addINIValuesUnix(
ini_values_csv: string ini_values_csv: string
): Promise<string> { ): Promise<string> {
const ini_values: Array<string> = await utils.CSVArray(ini_values_csv); const ini_values: Array<string> = await utils.CSVArray(ini_values_csv);
let script = ''; let script = '\n';
await utils.asyncForEach(ini_values, async function (line: string) { await utils.asyncForEach(ini_values, async function (line: string) {
script += script +=
'\n' + (await utils.addLog('$tick', line, 'Added to php.ini', 'linux')); (await utils.addLog('$tick', line, 'Added to php.ini', 'linux')) + '\n';
}); });
return 'echo "' + ini_values.join('\n') + '" >> $ini_file' + script; return 'echo "' + ini_values.join('\n') + '" >> $ini_file' + script;
} }
@ -32,7 +32,10 @@ export async function addINIValuesWindows(
(await utils.addLog('$tick', line, 'Added to php.ini', 'win32')) + '\n'; (await utils.addLog('$tick', line, 'Added to php.ini', 'win32')) + '\n';
}); });
return ( return (
'Add-Content "$php_dir\\php.ini" "' + ini_values.join('\n') + '"' + script 'Add-Content C:\\tools\\php\\php.ini "' +
ini_values.join('\n') +
'"' +
script
); );
} }

View File

@ -1,29 +0,0 @@
{
"problemMatcher": [
{
"owner": "php_native_error",
"severity": "error",
"pattern": [
{
"regexp": "^(.*error):\\s+\\s+(.+) in (.+) on line (\\d+)$",
"code": 1,
"message": 2,
"file": 3,
"line": 4
}
]
}, {
"owner": "php_native_warning",
"severity": "warning",
"pattern": [
{
"regexp": "^(.*Warning|.*Deprecated|.*Notice):\\s+\\s+(.+) in (.+) on line (\\d+)$",
"code": 1,
"message": 2,
"file": 3,
"line": 4
}
]
}
]
}

View File

@ -5,20 +5,17 @@ import * as config from './config';
/** /**
* Function to setup Xdebug * Function to setup Xdebug
* *
* @param extension
* @param version * @param version
* @param os_version * @param os_version
* @param pipe * @param pipe
*/ */
export async function addCoverageXdebug( export async function addCoverageXdebug(
extension: string,
version: string, version: string,
os_version: string, os_version: string,
pipe: string pipe: string
): Promise<string> { ): Promise<string> {
const xdebug = const xdebug =
(await extensions.addExtension(extension, version, os_version, true)) + (await extensions.addExtension('xdebug', version, os_version, true)) + pipe;
pipe;
const ini = await config.addINIValues( const ini = await config.addINIValues(
'xdebug.mode=coverage', 'xdebug.mode=coverage',
os_version, os_version,
@ -26,15 +23,14 @@ export async function addCoverageXdebug(
); );
const log = await utils.addLog( const log = await utils.addLog(
'$tick', '$tick',
extension, 'xdebug',
'Xdebug enabled as coverage driver', 'Xdebug enabled as coverage driver',
os_version os_version
); );
switch (true) { switch (true) {
case /^xdebug3$/.test(extension): case /8.[0-9]/.test(version):
case /^8\.0$/.test(version): return xdebug + '\n' + ini + '\n' + log;
return '\n' + xdebug + '\n' + ini + '\n' + log; case /5\.[3-6]|7.[0-4]/.test(version):
case /^xdebug$/.test(extension):
default: default:
return xdebug + '\n' + log; return xdebug + '\n' + log;
} }
@ -53,7 +49,7 @@ export async function addCoveragePCOV(
pipe: string pipe: string
): Promise<string> { ): Promise<string> {
let script = '\n'; let script = '\n';
switch (true) { switch (version) {
default: default:
script += script +=
(await extensions.addExtension('pcov', version, os_version, true)) + (await extensions.addExtension('pcov', version, os_version, true)) +
@ -82,8 +78,8 @@ export async function addCoveragePCOV(
); );
// version is not supported // version is not supported
break; break;
case '5.6':
case /5\.[3-6]|7\.0/.test(version): case '7.0':
script += await utils.addLog( script += await utils.addLog(
'$cross', '$cross',
'pcov', 'pcov',
@ -150,11 +146,7 @@ export async function addCoverage(
case 'pcov': case 'pcov':
return script + (await addCoveragePCOV(version, os_version, pipe)); return script + (await addCoveragePCOV(version, os_version, pipe));
case 'xdebug': case 'xdebug':
case 'xdebug3': return script + (await addCoverageXdebug(version, os_version, pipe));
return (
script +
(await addCoverageXdebug(coverage_driver, version, os_version, pipe))
);
case 'none': case 'none':
return script + (await disableCoverage(version, os_version, pipe)); return script + (await disableCoverage(version, os_version, pipe));
default: default:

View File

@ -1,3 +1,4 @@
import * as path from 'path';
import * as utils from './utils'; import * as utils from './utils';
/** /**
@ -13,58 +14,23 @@ export async function addExtensionDarwin(
pipe: string pipe: string
): Promise<string> { ): Promise<string> {
const extensions: Array<string> = await utils.extensionArray(extension_csv); const extensions: Array<string> = await utils.extensionArray(extension_csv);
let add_script = '\n'; let script = '\n';
let remove_script = '';
await utils.asyncForEach(extensions, async function (extension: string) { await utils.asyncForEach(extensions, async function (extension: string) {
const version_extension: string = version + extension; const version_extension: string = version + extension;
const [ext_name, ext_version]: string[] = extension.split('-'); const [extension_name, stability]: string[] = extension.split('-');
const ext_prefix = await utils.getExtensionPrefix(ext_name); const ext_prefix = await utils.getExtensionPrefix(extension_name);
const command_prefix = 'pecl_install '; const command_prefix = 'pecl_install ';
let command = ''; let command = '';
switch (true) { switch (true) {
// match :extension // match pre-release versions
case /^:/.test(ext_name):
remove_script += '\nremove_extension ' + ext_name.slice(1);
return;
// match 5.3blackfire...5.6blackfire, 7.0blackfire...7.4blackfire
// match 5.3blackfire-1.31.0...5.6blackfire-1.31.0, 7.0blackfire-1.31.0...7.4blackfire-1.31.0
// match pdo_oci and oci8
// match 5.3ioncube...7.4ioncube, 7.0ioncube...7.4ioncube
// match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4
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):
add_script += await utils.customPackage(
ext_name,
'ext',
extension,
'darwin'
);
return;
// match pre-release versions. For example - xdebug-beta
case /.*-(beta|alpha|devel|snapshot)/.test(version_extension): case /.*-(beta|alpha|devel|snapshot)/.test(version_extension):
add_script += await utils.joins( script +=
'\nadd_unstable_extension', '\nadd_unstable_extension ' +
ext_name, extension_name +
ext_version, ' ' +
ext_prefix stability +
); ' ' +
return; ext_prefix;
// match semver
case /.*-\d+\.\d+\.\d+.*/.test(version_extension):
add_script += await utils.joins(
'\nadd_pecl_extension',
ext_name,
ext_version,
ext_prefix
);
return;
// match 5.3pcov to 7.0pcov
case /(5\.[3-6]|7\.0)pcov/.test(version_extension):
add_script += await utils.getUnsupportedLog('pcov', version, 'darwin');
return; return;
// match 5.6xdebug to 8.0xdebug, 5.6swoole to 8.0swoole // match 5.6xdebug to 8.0xdebug, 5.6swoole to 8.0swoole
// match 5.6grpc to 7.4grpc, 5.6protobuf to 7.4protobuf // match 5.6grpc to 7.4grpc, 5.6protobuf to 7.4protobuf
@ -72,7 +38,7 @@ export async function addExtensionDarwin(
case /(5\.6|7\.[0-4]|8\.[0-9])xdebug/.test(version_extension): case /(5\.6|7\.[0-4]|8\.[0-9])xdebug/.test(version_extension):
case /(5\.6|7\.[0-4])(grpc|protobuf|swoole)/.test(version_extension): case /(5\.6|7\.[0-4])(grpc|protobuf|swoole)/.test(version_extension):
case /(7\.[1-4]|8\.[0-9])pcov/.test(version_extension): case /(7\.[1-4]|8\.[0-9])pcov/.test(version_extension):
command = 'add_brew_extension ' + ext_name; command = 'add_brew_extension ' + extension_name;
break; break;
// match 5.6redis // match 5.6redis
case /5\.6redis/.test(version_extension): case /5\.6redis/.test(version_extension):
@ -80,28 +46,42 @@ export async function addExtensionDarwin(
break; break;
// match imagick // match imagick
case /^imagick$/.test(extension): case /^imagick$/.test(extension):
command = await utils.joins( command =
'brew install pkg-config imagemagick' + pipe, 'brew install pkg-config imagemagick' +
'&& ' + command_prefix + 'imagick' + pipe pipe +
); ' && ' +
command_prefix +
'imagick' +
pipe;
break; break;
// match sqlite // match sqlite
case /^sqlite$/.test(extension): case /^sqlite$/.test(extension):
extension = 'sqlite3'; extension = 'sqlite3';
command = command_prefix + extension; command = command_prefix + extension;
break; break;
// match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
script +=
'\nbash ' +
path.join(__dirname, '../src/scripts/ext/phalcon_darwin.sh') +
' ' +
extension +
' ' +
version;
return;
default: default:
command = command_prefix + extension; command = command_prefix + extension;
break; break;
} }
add_script += await utils.joins( script +=
'\nadd_extension', '\nadd_extension ' +
extension, extension +
'"' + command + '"', ' "' +
ext_prefix command +
); '" ' +
(await utils.getExtensionPrefix(extension));
}); });
return add_script + remove_script; return script;
} }
/** /**
@ -115,94 +95,48 @@ export async function addExtensionWindows(
version: string version: string
): Promise<string> { ): Promise<string> {
const extensions: Array<string> = await utils.extensionArray(extension_csv); const extensions: Array<string> = await utils.extensionArray(extension_csv);
let add_script = '\n'; let script = '\n';
let remove_script = '';
await utils.asyncForEach(extensions, async function (extension: string) { await utils.asyncForEach(extensions, async function (extension: string) {
const [ext_name, ext_version]: string[] = extension.split('-'); const [extension_name, stability]: string[] = extension.split('-');
const version_extension: string = version + extension; const version_extension: string = version + extension;
let matches: RegExpExecArray;
switch (true) { switch (true) {
// Match :extension // match pre-release versions
case /^:/.test(ext_name):
remove_script += '\nRemove-Extension ' + ext_name.slice(1);
break;
// match 5.3blackfire...5.6blackfire, 7.0blackfire...7.4blackfire
// match 5.3blackfire-1.31.0...5.6blackfire-1.31.0, 7.0blackfire-1.31.0...7.4blackfire-1.31.0
// match pdo_oci and oci8
// match 5.3ioncube...7.4ioncube, 7.0ioncube...7.4ioncube
// match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4
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):
add_script += await utils.customPackage(
ext_name,
'ext',
extension,
'win32'
);
return;
// match pre-release versions. For example - xdebug-beta
case /.*-(beta|alpha|devel|snapshot)/.test(version_extension): case /.*-(beta|alpha|devel|snapshot)/.test(version_extension):
add_script += await utils.joins( script += '\nAdd-Extension ' + extension_name + ' ' + stability;
'\nAdd-Extension',
ext_name,
ext_version
);
break; break;
// match semver without state // match 5.6mysql, 5.6mysqli, 5.6mysqlnd
case /.*-\d+\.\d+\.\d+$/.test(version_extension): case /^5\.6(mysql|mysqli|mysqlnd)$/.test(version_extension):
add_script += await utils.joins( script +=
'\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
) as RegExpExecArray;
add_script += await utils.joins(
'\nAdd-Extension',
ext_name,
matches[2],
matches[1]
);
break;
// match 5.3pcov to 7.0pcov
case /(5\.[3-6]|7\.0)pcov/.test(version_extension):
add_script += await utils.getUnsupportedLog('pcov', version, 'win32');
break;
// match 5.3mysql..5.6mysql
// match 5.3mysqli..5.6mysqli
// match 5.3mysqlnd..5.6mysqlnd
case /^5\.\d(mysql|mysqli|mysqlnd)$/.test(version_extension):
add_script +=
'\nAdd-Extension mysql\nAdd-Extension mysqli\nAdd-Extension mysqlnd'; '\nAdd-Extension mysql\nAdd-Extension mysqli\nAdd-Extension mysqlnd';
break; break;
// match 7.0mysql..8.0mysql // match 7.0mysql..8.0mysql
// match 7.0mysqli..8.0mysqli // match 7.0mysqli..8.0mysqli
// match 7.0mysqlnd..8.0mysqlnd // match 7.0mysqlnd..8.0mysqlnd
case /[7-8]\.\d(mysql|mysqli|mysqlnd)$/.test(version_extension): case /[7-8]\.\d(mysql|mysqli|mysqlnd)$/.test(version_extension):
add_script += '\nAdd-Extension mysqli\nAdd-Extension mysqlnd'; script += '\nAdd-Extension mysqli\nAdd-Extension mysqlnd';
break; break;
// match sqlite // match sqlite
case /^sqlite$/.test(extension): case /^sqlite$/.test(extension):
extension = 'sqlite3'; extension = 'sqlite3';
add_script += await utils.joins('\nAdd-Extension', extension); script += '\nAdd-Extension ' + extension;
break;
// match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
script +=
'\n& ' +
path.join(__dirname, '../src/scripts/ext/phalcon.ps1') +
' ' +
extension +
' ' +
version +
'\n';
break; break;
default: default:
add_script += '\nAdd-Extension ' + extension; script += '\nAdd-Extension ' + extension;
break; break;
} }
}); });
return add_script + remove_script; return script;
} }
/** /**
@ -218,104 +152,61 @@ export async function addExtensionLinux(
pipe: string pipe: string
): Promise<string> { ): Promise<string> {
const extensions: Array<string> = await utils.extensionArray(extension_csv); const extensions: Array<string> = await utils.extensionArray(extension_csv);
let add_script = '\n'; let script = '\n';
let remove_script = '';
await utils.asyncForEach(extensions, async function (extension: string) { await utils.asyncForEach(extensions, async function (extension: string) {
const version_extension: string = version + extension; const version_extension: string = version + extension;
const [ext_name, ext_version]: string[] = extension.split('-'); const [extension_name, stability]: string[] = extension.split('-');
const ext_prefix = await utils.getExtensionPrefix(ext_name); const ext_prefix = await utils.getExtensionPrefix(extension_name);
const command_prefix = 'sudo $debconf_fix apt-get install -y php'; const command_prefix = 'sudo $debconf_fix apt-get install -y php';
let command = ''; let command = '';
switch (true) { switch (true) {
// Match :extension // match pre-release versions
case /^:/.test(ext_name):
remove_script += '\nremove_extension ' + ext_name.slice(1);
return;
// match 5.3blackfire...5.6blackfire, 7.0blackfire...7.4blackfire
// match 5.3blackfire-1.31.0...5.6blackfire-1.31.0, 7.0blackfire-1.31.0...7.4blackfire-1.31.0
// match 5.3pdo_cubrid...7.2php_cubrid, 5.3cubrid...7.4cubrid
// 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
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):
add_script += await utils.customPackage(
ext_name,
'ext',
extension,
'linux'
);
return;
// match pre-release versions. For example - xdebug-beta
case /.*-(beta|alpha|devel|snapshot)/.test(version_extension): case /.*-(beta|alpha|devel|snapshot)/.test(version_extension):
add_script += await utils.joins( script +=
'\nadd_unstable_extension', '\nadd_unstable_extension ' +
ext_name, extension_name +
ext_version, ' ' +
ext_prefix stability +
); ' ' +
ext_prefix;
return; return;
// match semver versions // match 5.6gearman..7.4gearman
case /.*-\d+\.\d+\.\d+.*/.test(version_extension): case /^((5\.6)|(7\.[0-4]))gearman$/.test(version_extension):
add_script += await utils.joins( command =
'\nadd_pecl_extension', '\nbash ' +
ext_name, path.join(__dirname, '../src/scripts/ext/gearman.sh') +
ext_version, ' ' +
ext_prefix version +
); pipe;
return;
// match 5.3pcov to 7.0pcov
case /(5\.[3-6]|7\.0)pcov/.test(version_extension):
add_script += await utils.getUnsupportedLog('pcov', version, 'linux');
return;
// match 7.2xdebug3..7.4xdebug3
case /^7\.[2-4]xdebug3$/.test(version_extension):
add_script +=
'\nadd_extension_from_source xdebug xdebug/xdebug master --enable-xdebug zend_extension';
return;
// match 8.0xdebug3
case /^8\.[0-9]xdebug3$/.test(version_extension):
extension = 'xdebug';
command = command_prefix + version + '-' + extension + pipe;
break; break;
// match pdo extensions // match 7.0phalcon3...7.3phalcon3 or 7.2phalcon4...7.4phalcon4
case /.*pdo[_-].*/.test(version_extension): case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
extension = extension.replace(/pdo[_-]|3/, ''); script +=
add_script += '\nadd_pdo_extension ' + extension; '\nbash ' +
path.join(__dirname, '../src/scripts/ext/phalcon.sh') +
' ' +
extension +
' ' +
version;
return; return;
// match ast and uopz
case /^(ast|uopz)$/.test(extension):
command = command_prefix + '-' + extension + pipe;
break;
// match sqlite // match sqlite
case /^sqlite$/.test(extension): case /^sqlite$/.test(extension):
extension = 'sqlite3'; extension = 'sqlite3';
command = command_prefix + version + '-' + extension + pipe; command = command_prefix + version + '-' + extension + pipe;
break; break;
default: default:
command = command_prefix + version + '-' + extension + pipe; command =
command_prefix +
version +
'-' +
extension.replace('pdo_', '').replace('pdo-', '') +
pipe;
break; break;
} }
add_script += await utils.joins( script +=
'\nadd_extension', '\nadd_extension ' + extension + ' "' + command + '" ' + ext_prefix;
extension,
'"' + command + '"',
ext_prefix
);
}); });
return add_script + remove_script; return script;
} }
/** /**

View File

@ -5,7 +5,6 @@ import * as coverage from './coverage';
import * as extensions from './extensions'; import * as extensions from './extensions';
import * as tools from './tools'; import * as tools from './tools';
import * as utils from './utils'; import * as utils from './utils';
import * as matchers from './matchers';
/** /**
* Build the script * Build the script
@ -19,20 +18,22 @@ export async function build(
version: string, version: string,
os_version: string os_version: string
): Promise<string> { ): Promise<string> {
const name = 'setup-php';
const url = 'setup-php.com/support';
// taking inputs // taking inputs
const name = 'setup-php';
const url = 'https://setup-php.com/support';
const extension_csv: string = const extension_csv: string =
(await utils.getInput('extensions', false)) || (await utils.getInput('extensions', false)) ||
(await utils.getInput('extension', false)); (await utils.getInput('extension', false)) ||
const ini_values_csv: string = await utils.getInput('ini-values', false); (await utils.getInput('extension-csv', false));
const ini_values_csv: string =
(await utils.getInput('ini-values', false)) ||
(await utils.getInput('ini-values-csv', false));
const coverage_driver: string = await utils.getInput('coverage', false); const coverage_driver: string = await utils.getInput('coverage', false);
const pecl: string = await utils.getInput('pecl', false); const pecl: string = await utils.getInput('pecl', false);
let tools_csv: string = await utils.getInput('tools', false); let tools_csv: string = await utils.getInput('tools', false);
if ( if (
pecl == 'true' || pecl == 'true' ||
/.*-(beta|alpha|devel|snapshot).*/.test(extension_csv) || /.*-(beta|alpha|devel|snapshot).*/.test(extension_csv)
/.*-(\d+\.\d+\.\d+).*/.test(extension_csv)
) { ) {
tools_csv = 'pecl, ' + tools_csv; tools_csv = 'pecl, ' + tools_csv;
} }
@ -61,10 +62,9 @@ export async function build(
*/ */
export async function run(): Promise<void> { export async function run(): Promise<void> {
try { try {
const os_version: string = process.platform;
let version: string = await utils.getInput('php-version', true); let version: string = await utils.getInput('php-version', true);
version = version.length > 1 ? version.slice(0, 3) : version + '.0'; version = version.length > 1 ? version.slice(0, 3) : version + '.0';
const os_version: string = process.platform;
// check the os version and run the respective script // check the os version and run the respective script
let script_path = ''; let script_path = '';
switch (os_version) { switch (os_version) {
@ -78,7 +78,6 @@ export async function run(): Promise<void> {
await exec('pwsh ' + script_path + ' ' + version + ' ' + __dirname); await exec('pwsh ' + script_path + ' ' + version + ' ' + __dirname);
break; break;
} }
await matchers.addMatchers();
} catch (error) { } catch (error) {
core.setFailed(error.message); core.setFailed(error.message);
} }

View File

@ -1,13 +0,0 @@
import * as path from 'path';
import * as utils from './utils';
import * as io from '@actions/io';
/**
* Cache json files for problem matchers
*/
export async function addMatchers(): Promise<void> {
const config_path = path.join(__dirname, '..', 'src', 'configs');
const runner_dir: string = await utils.getInput('RUNNER_TOOL_CACHE', false);
await io.cp(path.join(config_path, 'phpunit.json'), runner_dir);
await io.cp(path.join(config_path, 'php.json'), runner_dir);
}

View File

@ -1,10 +1,10 @@
# Function to log start of a operation. # Function to log start of a operation
step_log() { step_log() {
message=$1 message=$1
printf "\n\033[90;1m==> \033[0m\033[37;1m%s\033[0m\n" "$message" printf "\n\033[90;1m==> \033[0m\033[37;1m%s\033[0m\n" "$message"
} }
# Function to log result of a operation. # Function to log result of a operation
add_log() { add_log() {
mark=$1 mark=$1
subject=$2 subject=$2
@ -16,48 +16,15 @@ add_log() {
fi fi
} }
# Function to log result of installing extension. # Function to remove extensions
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
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"
fi
}
# Function to remove extensions.
remove_extension() { remove_extension() {
extension=$1 extension=$1
if check_extension "$extension"; then
sudo sed -i '' "/$extension/d" "$ini_file" sudo sed -i '' "/$extension/d" "$ini_file"
sudo rm -rf "$scan_dir"/*"$extension"* >/dev/null 2>&1 sudo rm -rf "$scan_dir"/*"$extension"* >/dev/null 2>&1
sudo rm -rf "$ext_dir"/"$extension".so >/dev/null 2>&1 sudo rm -rf "$ext_dir"/"$extension".so >/dev/null 2>&1
(! check_extension "$extension" && add_log "$tick" ":$extension" "Removed") ||
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 test if extension is loaded. # Function to test if extension is loaded
check_extension() { check_extension() {
extension=$1 extension=$1
if [ "$extension" != "mysql" ]; then if [ "$extension" != "mysql" ]; then
@ -67,7 +34,13 @@ check_extension() {
fi fi
} }
# Fuction to get the 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
}
# Fuction to get the PECL version
get_pecl_version() { get_pecl_version() {
extension=$1 extension=$1
stability="$(echo "$2" | grep -m 1 -Eio "(alpha|beta|rc|snapshot)")" stability="$(echo "$2" | grep -m 1 -Eio "(alpha|beta|rc|snapshot)")"
@ -80,13 +53,7 @@ get_pecl_version() {
echo "$pecl_version" echo "$pecl_version"
} }
# Function to install PECL extensions and accept default options # Function to install a PECL version
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() { add_pecl_extension() {
extension=$1 extension=$1
pecl_version=$2 pecl_version=$2
@ -101,9 +68,12 @@ add_pecl_extension() {
if [ "$ext_version" = "$pecl_version" ]; then if [ "$ext_version" = "$pecl_version" ]; then
add_log "$tick" "$extension" "Enabled" add_log "$tick" "$extension" "Enabled"
else else
remove_extension "$extension" >/dev/null 2>&1 remove_extension "$extension"
pecl_install "$extension-$pecl_version" (
add_extension_log "$extension-$pecl_version" "Installed and enabled" pecl_install "$extension-$pecl_version" >/dev/null 2>&1 &&
check_extension "$extension" &&
add_log "$tick" "$extension" "Installed and enabled"
) || add_log "$cross" "$extension" "Could not install $extension-$pecl_version on PHP $semver"
fi fi
} }
@ -127,13 +97,15 @@ add_extension() {
elif check_extension "$extension"; then elif check_extension "$extension"; then
add_log "$tick" "$extension" "Enabled" add_log "$tick" "$extension" "Enabled"
elif ! check_extension "$extension"; then elif ! check_extension "$extension"; then
(
eval "$install_command" >/dev/null 2>&1 && eval "$install_command" >/dev/null 2>&1 &&
if [[ "$version" =~ $old_versions ]]; then echo "$prefix=$ext_dir/$extension.so" >>"$ini_file"; fi check_extension "$extension" &&
add_extension_log "$extension" "Installed and enabled" add_log "$tick" "$extension" "Installed and enabled"
) || add_log "$cross" "$extension" "Could not install $extension on PHP $semver"
fi fi
} }
# Function to setup pre-release extensions using PECL. # Function to pre-release extensions using PECL
add_unstable_extension() { add_unstable_extension() {
extension=$1 extension=$1
stability=$2 stability=$2
@ -149,10 +121,10 @@ configure_composer() {
php -r "try {\$p=new Phar('$tool_path.phar', 0);exit(0);} catch(Exception \$e) {exit(1);}" php -r "try {\$p=new Phar('$tool_path.phar', 0);exit(0);} catch(Exception \$e) {exit(1);}"
if [ $? -eq 1 ]; then if [ $? -eq 1 ]; then
add_log "$cross" "composer" "Could not download composer" add_log "$cross" "composer" "Could not download composer"
exit 1 exit 1;
fi fi
composer -q global config process-timeout 0 composer -q global config process-timeout 0
echo "/Users/$USER/.composer/vendor/bin" >> $GITHUB_PATH echo "/Users/$USER/.composer/vendor/bin" >> "$GITHUB_PATH"
if [ -n "$COMPOSER_TOKEN" ]; then if [ -n "$COMPOSER_TOKEN" ]; then
composer -q global config github-oauth.github.com "$COMPOSER_TOKEN" composer -q global config github-oauth.github.com "$COMPOSER_TOKEN"
fi fi
@ -188,8 +160,6 @@ add_tool() {
sudo sed -i '' 's/exit(9)/exit(0)/' "$tool_path" 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" 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" sudo chmod a+x "$tool_path"
elif [ "$tool" = "wp-cli" ]; then
sudo cp -p "$tool_path" "$tool_path_dir"/wp
fi fi
add_log "$tick" "$tool" "Added" add_log "$tick" "$tool" "Added"
else else
@ -197,39 +167,36 @@ add_tool() {
fi fi
} }
# Function to add a tool using composer. # Function to add a tool using composer
add_composertool() { add_composertool() {
tool=$1 tool=$1
release=$2 release=$2
prefix=$3 prefix=$3
( (
composer global require "$prefix$release" >/dev/null 2>&1 && add_log "$tick" "$tool" "Added" composer global require "$prefix$release" >/dev/null 2>&1 &&
add_log "$tick" "$tool" "Added"
) || add_log "$cross" "$tool" "Could not setup $tool" ) || add_log "$cross" "$tool" "Could not setup $tool"
} }
# Function to configure PECL # Function to configure PECL
configure_pecl() { configure_pecl() {
for tool in pear pecl; do for tool in pear pecl; do
sudo "$tool" config-set php_ini "$ini_file" sudo "$tool" config-set php_ini "$ini_file" >/dev/null 2>&1
sudo "$tool" channel-update "$tool".php.net sudo "$tool" config-set auto_discover 1 >/dev/null 2>&1
sudo "$tool" channel-update "$tool".php.net >/dev/null 2>&1
done done
} }
# Function to handle request to add PECL. # Function to log PECL, it is installed along with PHP
add_pecl() { add_pecl() {
add_log "$tick" "PECL" "Added" add_log "$tick" "PECL" "Added"
} }
# Function to setup PHP 5.6 and newer. # Function to setup PHP and composer
setup_php() { setup_php() {
action=$1
export HOMEBREW_NO_INSTALL_CLEANUP=TRUE export HOMEBREW_NO_INSTALL_CLEANUP=TRUE
brew tap --shallow shivammathur/homebrew-php brew tap --shallow shivammathur/homebrew-php
if brew list php@"$version" 2>/dev/null | grep -q "Error" && [ "$action" != "upgrade" ]; then brew install shivammathur/php/php@"$version"
brew unlink php@"$version"
else
brew "$action" shivammathur/php/php@"$version"
fi
brew link --force --overwrite php@"$version" brew link --force --overwrite php@"$version"
} }
@ -237,33 +204,16 @@ setup_php() {
tick="✓" tick="✓"
cross="✗" cross="✗"
version=$1 version=$1
nodot_version=${1/./} dist=$2
old_versions="5.[3-5]"
tool_path_dir="/usr/local/bin" tool_path_dir="/usr/local/bin"
curl_opts=(-sL) curl_opts=(-sL)
existing_version=$(php-config --version 2>/dev/null | cut -c 1-3) existing_version=$(php-config --version 2>/dev/null | cut -c 1-3)
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 # Setup PHP
step_log "Setup PHP" step_log "Setup PHP"
if [[ "$version" =~ $old_versions ]]; then if [ "$existing_version" != "$version" ]; then
curl "${curl_opts[@]}" https://github.com/shivammathur/php5-darwin/releases/latest/download/install.sh | bash -s "$nodot_version" >/dev/null 2>&1 setup_php >/dev/null 2>&1
status="Installed" 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 else
status="Found" status="Found"
fi fi
@ -274,5 +224,6 @@ ext_dir=$(php -i | grep -Ei "extension_dir => /" | sed -e "s|.*=> s*||")
scan_dir=$(php --ini | grep additional | sed -e "s|.*: s*||") scan_dir=$(php --ini | grep additional | sed -e "s|.*: s*||")
sudo mkdir -p "$ext_dir" sudo mkdir -p "$ext_dir"
semver=$(php -v | head -n 1 | cut -f 2 -d ' ') semver=$(php -v | head -n 1 | cut -f 2 -d ' ')
if [[ ! "$version" =~ $old_versions ]]; then configure_pecl >/dev/null 2>&1; fi configure_pecl
sudo mv "$dist"/../src/configs/*.json "$RUNNER_TOOL_CACHE/"
add_log "$tick" "PHP" "$status PHP $semver" add_log "$tick" "PHP" "$status PHP $semver"

View File

@ -1,28 +0,0 @@
# Function to install blackfire extension.
Function Add-Blackfire() {
Param (
[Parameter(Position = 0, Mandatory = $true)]
[ValidateNotNull()]
[string]
$extension
)
try {
$no_dot_version = $version.replace('.', '')
$extension_version = $extension.split('-')[1]
if ($extension_version -notmatch "\S") {
$extension_version = (Invoke-RestMethod https://blackfire.io/api/v1/releases).probe.php
}
if (Test-Path $ext_dir\blackfire.dll) {
Enable-PhpExtension -Extension blackfire -Path $php_dir
$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
Enable-PhpExtension -Extension blackfire -Path $php_dir
$status="Installed and enabled"
}
Add-Log $tick $extension $status
} catch {
Add-Log $cross $extension "Could not install $extension on PHP $($installed.FullVersion)"
}
}

View File

@ -1,17 +0,0 @@
# Function to install blackfire extension.
add_blackfire() {
extension=$1
version=${version:?}
no_dot_version=${version/./}
platform=$(uname -s | tr '[:upper:]' '[:lower:]')
extension_version=$(echo "$extension" | cut -d '-' -f 2)
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)
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
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

@ -1,50 +0,0 @@
# Function to log license details.
add_license_log() {
printf "::group::\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" "$ext" "Click to read the $ext related license information"
printf "Cubrid CCI package is required for %s extension.\n" "$ext"
printf "The extension %s and Cubrid CCI are provided under the license linked below.\n" "$ext"
printf "Refer to: \033[35;1m%s \033[0m\n" "https://github.com/CUBRID/cubrid-cci/blob/develop/COPYING"
echo "::endgroup::"
}
# Function to set cubrid repo for the extension.
set_cubrid_repo() {
case "${ext:?}" in
"cubrid") cubrid_repo="cubrid-php";;
"pdo_cubrid") cubrid_repo="cubrid-pdo";;
esac
}
# Function to set cubrid branch for a PHP version.
set_cubrid_branch() {
case "${version:?}" in
5.[3-6]) cubrid_branch="RB-9.3.0";;
*) cubrid_branch="develop";;
esac
}
add_cubrid_helper() {
if ! [ -e "${ext_dir:?}/$ext.so" ]; then
status='Installed and enabled'
set_cubrid_repo
set_cubrid_branch
(
git clone -b "$cubrid_branch" --recursive "https://github.com/CUBRID/$cubrid_repo" "/tmp/$cubrid_repo"
cd "/tmp/$cubrid_repo" || exit
! [[ "$version" =~ ${old_versions:?} ]] && add_devtools
phpize && ./configure --with-php-config="$(command -v php-config)" --with-"${ext/_/-}"=shared
make -j"$(nproc)"
sudo make install
)
echo "extension=$ext.so" | sudo tee "${scan_dir:?}/$ext.ini"
fi
}
# Function to add cubrid and pdo_cubrid.
add_cubrid() {
ext=$1
status='Enabled'
add_cubrid_helper >/dev/null 2>&1
add_extension_log "$ext" "$status"
check_extension "$ext" && add_license_log
}

View File

@ -1,23 +1,9 @@
# Helper function to add gearman extension. release_version=$(lsb_release -s -r)
add_gearman_helper() { sudo DEBIAN_FRONTEND=noninteractive add-apt-repository ppa:ondrej/pkg-gearman -y
sudo "${debconf_fix:?}" add-apt-repository ppa:ondrej/pkg-gearman -y sudo DEBIAN_FRONTEND=noninteractive apt-get update -y
if [ -e "${ext_dir:?}/gearman.so" ] && [ "$DISTRIB_RELEASE" != "16.04" ]; then
${apt_install:?} libgearman-dev
echo "extension=gearman.so" | sudo tee -a "${scan_dir:?}/20-gearman.ini" >/dev/null 2>&1
else
status="Installed and enabled"
if [ "$DISTRIB_RELEASE" = "16.04" ]; then
sudo "${debconf_fix:?}" apt-get update -y
${apt_install:?} php"${version:?}"-gearman
else
${apt_install:?} libgearman-dev php"${version:?}"-gearman
fi
fi
}
# Function to add gearman extension. if [ "$release_version" = "18.04" ]; then
add_gearman() { sudo DEBIAN_FRONTEND=noninteractive apt-fast install -y libgearman-dev php"$1"-gearman
status="Enabled" elif [ "$release_version" = "16.04" ]; then
add_gearman_helper >/dev/null 2>&1 sudo DEBIAN_FRONTEND=noninteractive apt-fast install -y php"$1"-gearman
add_extension_log "gearman" "$status" fi
}

View File

@ -1,23 +0,0 @@
# Function to install ICU
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"
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
}
# 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)
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"
enable_extension intl extension
add_extension_log intl "Installed and enabled with ICU $icu"
fi
}

View File

@ -1,32 +0,0 @@
# Function to log result of a operation.
Function Add-LicenseLog() {
printf "::group::\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" "ioncube" "Click to read the ioncube loader license information"
Get-Content $ext_dir\ioncube\LICENSE.txt
Write-Output "::endgroup::"
}
# Function to add ioncube extension.
Function Add-Ioncube() {
try {
if (-not(Test-Path $ext_dir\php_ioncube.dll)) {
$status = 'Installed and enabled'
$arch_part = $arch
if ($arch -eq 'x64') {
$arch_part = 'x86-64'
}
$vc = $installed.VCVersion
$ts_part = ""
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
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
}
"zend_extension=$ext_dir\php_ioncube.dll`r`n" + (Get-Content $php_dir\php.ini -Raw) | Set-Content $php_dir\php.ini
Add-Log $tick "ioncube" $status
Add-LicenseLog
} catch {
Add-Log $cross "ioncube" "Could not install ioncube on PHP $($installed.FullVersion)"
}
}

View File

@ -1,19 +0,0 @@
# Function to log result of a operation.
add_license_log() {
printf "::group::\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" "ioncube" "Click to read the ioncube loader license information"
cat /tmp/ioncube/LICENSE.txt
echo "::endgroup::"
}
# Function to install ioncube.
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
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
add_extension_log "ioncube" "$status"
check_extension "ioncube" && add_license_log
}

View File

@ -1,58 +0,0 @@
# Function to log license information.
Function Add-LicenseLog() {
printf "::group::\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" $extension "Click to read the $extension related license information"
printf "Oracle Instant Client package is required for %s extension.\n" $extension
printf "It is provided under the Oracle Technology Network Development and Distribution License.\n"
printf "Refer to: \033[35;1m%s \033[0m\n" "https://www.oracle.com/downloads/licenses/instant-client-lic.html"
Write-Output "::endgroup::"
}
# Function to get instantclinet.
Function Add-InstantClient() {
if (-not(Test-Path $php_dir\oci.dll)) {
$suffix = 'windows'
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
Expand-Archive -Path $php_dir\instantclient.zip -DestinationPath $php_dir -Force
Copy-Item $php_dir\instantclient*\* $php_dir
}
}
# Function to install oci8 and pdo_oci.
Function Add-Oci() {
Param (
[Parameter(Position = 0, Mandatory = $true)]
[ValidateNotNull()]
[ValidateSet('oci8', 'pdo_oci')]
[string]
$extension
)
try {
$status = 'Enabled'
Add-InstantClient
if ($extension -eq "pdo_oci") {
Enable-PhpExtension pdo_oci -Path $php_dir
} else {
if(-not(Test-Path $ext_dir\php_oci8.dll)) {
$status = 'Installed and enabled'
$ociVersion = '2.2.0'
if ($version -eq '7.0') {
$ociVersion = '2.1.8'
} elseif ($version -lt '7.0') {
$ociVersion = '2.0.12'
}
$ociUrl = Get-PeclArchiveUrl oci8 $ociVersion $installed
Invoke-WebRequest -UseBasicParsing -Uri $ociUrl -OutFile $php_dir\oci8.zip
Expand-Archive -Path $php_dir\oci8.zip -DestinationPath $ext_dir -Force
}
Add-Content -Value "`r`nextension=php_oci8.dll" -Path $php_dir\php.ini
}
Add-Log $tick $extension $status
Add-LicenseLog
} catch {
Add-Log $cross $extension "Could not install $extension on PHP $( $installed.FullVersion )"
}
}

View File

@ -1,125 +0,0 @@
# Function to log result of a operation.
add_license_log() {
printf "::group::\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" "$ext" "Click to read the $ext related license information"
printf "Oracle Instant Client package is required for %s extension.\n" "$ext"
printf "It is provided under the Oracle Technology Network Development and Distribution License.\n"
printf "Refer to: \033[35;1m%s \033[0m\n" "https://www.oracle.com/downloads/licenses/instant-client-lic.html"
echo "::endgroup::"
}
# Function to get the tag for a php version.
get_tag() {
master_version='8.0'
tag='master'
if [ ! "${version:?}" = "$master_version" ]; then
tag="php-$(php -v | head -n 1 | cut -f 2 -d ' ' | cut -f 1 -d '-')"
fi
echo "$tag"
}
# Function to install instantclient and SDK.
add_client() {
sudo mkdir -p -m 777 "$oracle_home"
if [ ! -e "$oracle_client" ]; then
for package in basiclite sdk; do
if [ "$os" = 'Linux' ]; then
libs='/usr/lib/'
os_name='linux'
arch='linuxx64'
lib_ext='so'
elif [ "$os" = 'Darwin' ]; then
libs='/usr/local/lib/'
os_name='mac'
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"
unzip "/opt/oracle/$package.zip" -d "$oracle_home"
done
sudo ln -sf /opt/oracle/instantclient*/*.$lib_ext* $libs
sudo ln -sf /opt/oracle/instantclient* "$oracle_client"
fi
}
# 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/"
}
# Function to get phpize location on darwin.
get_phpize() {
if [[ "$version" =~ 5.[3-5] ]]; then
echo '/opt/local/bin/phpize'
else
echo "/usr/local/bin/$(readlink /usr/local/bin/phpize)"
fi
}
# Function to patch phpize to link to php headers on darwin.
patch_phpize() {
if [ "$os" = "Darwin" ]; then
sudo cp "$phpize_orig" "$phpize_orig.bck"
sudo sed -i '' 's~includedir=.*~includedir="$(xcrun --show-sdk-path)/usr/include/php"~g' "$phpize_orig"
fi
}
# Function to restore phpize.
restore_phpize() {
if [ "$os" = "Darwin" ]; then
sudo mv "$phpize_orig.bck" "$phpize_orig" || true
fi
}
# Function to patch pdo_oci.
patch_pdo_oci_config() {
curl -O "${curl_opts[@]}" https://raw.githubusercontent.com/php/php-src/master/ext/pdo_oci/config.m4
sudo sed -i '' "/PHP_CHECK_PDO_INCLUDES/d" config.m4 || sudo sed -i "/PHP_CHECK_PDO_INCLUDES/d" config.m4
}
# Function to install the dependencies.
add_dependencies() {
if [ "$os" = 'Linux' ]; then
if [ "${runner:?}" = "self-hosted" ]; then
${apt_install:?} autoconf automake libaio-dev gcc g++ php"$version"-dev
else
update_lists
${apt_install:?} php"$version"-dev
fi
sudo update-alternatives --set php-config /usr/bin/php-config"$version"
sudo update-alternatives --set phpize /usr/bin/phpize"$version"
fi
}
# Function to install oci8 and pdo_oci.
add_oci_helper() {
if ! [ -e "${ext_dir:?}/$ext.so" ]; then
status='Installed and enabled'
phpize_orig=$(get_phpize)
tag=$(get_tag)
get_php
patch_phpize
(
cd "/opt/oracle/php-src-$tag/ext/$ext" || exit 1
[ "$ext" = "pdo_oci" ] && patch_pdo_oci_config
sudo phpize && ./configure --with-php-config="$(command -v php-config)" --with-"${ext/_/-}"=instantclient,"$oracle_client"
sudo make -j"$(nproc)"
sudo cp ./modules/* "$ext_dir/"
)
restore_phpize
fi
echo "extension=$ext.so" | sudo tee "${scan_dir:?}/99-$ext.ini"
}
# Function to add oci extension oci8 and pdo_oci.
add_oci() {
ext=$1
status='Enabled'
oracle_home='/opt/oracle'
oracle_client=$oracle_home/instantclient
os=$(uname -s)
add_client >/dev/null 2>&1
add_dependencies >/dev/null 2>&1
add_oci_helper >/dev/null 2>&1
add_extension_log "$ext" "$status"
check_extension "$ext" && add_license_log
}

View File

@ -1,9 +1,22 @@
Param (
[Parameter(Position = 0, Mandatory = $true)]
[ValidateNotNull()]
[ValidateSet('phalcon3', 'phalcon4')]
[string]
$extension,
[Parameter(Position = 1, Mandatory = $true)]
[ValidateNotNull()]
[ValidateLength(1, [int]::MaxValue)]
[string]
$version
)
# Function to install phalcon # Function to install phalcon
Function Add-PhalconHelper() { Function Install-Phalcon() {
if ($extension_version -eq '4') { if ($extension_version -eq '4') {
Install-Phpextension phalcon -MinimumStability stable -Path $php_dir Install-Phpextension phalcon -MinimumStability stable -Path $php_dir
} else { } else {
$domain = 'https://github.com' $installed = Get-Php -Path $php_dir
$nts = if (!$installed.ThreadSafe) { "_nts" } else { "" } $nts = if (!$installed.ThreadSafe) { "_nts" } else { "" }
$match = Invoke-WebRequest -UseBasicParsing -Uri $domain/phalcon/cphalcon/releases | Select-String -Pattern "href=`"(.*phalcon_x64_.*_php${version}_${extension_version}.*[0-9]${nts}.zip)`"" $match = Invoke-WebRequest -UseBasicParsing -Uri $domain/phalcon/cphalcon/releases | Select-String -Pattern "href=`"(.*phalcon_x64_.*_php${version}_${extension_version}.*[0-9]${nts}.zip)`""
$zip_file = $match.Matches[0].Groups[1].Value $zip_file = $match.Matches[0].Groups[1].Value
@ -12,18 +25,13 @@ Function Add-PhalconHelper() {
Copy-Item -Path "$ENV:RUNNER_TOOL_CACHE\phalcon\php_phalcon.dll" -Destination "$ext_dir\php_phalcon.dll" Copy-Item -Path "$ENV:RUNNER_TOOL_CACHE\phalcon\php_phalcon.dll" -Destination "$ext_dir\php_phalcon.dll"
Enable-PhpExtension -Extension phalcon -Path $php_dir Enable-PhpExtension -Extension phalcon -Path $php_dir
} }
printf "\033[%s;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" "32" $tick $extension "Installed and enabled"
} }
Function Add-Phalcon() { $tick = ([char]8730)
Param ( $domain = 'https://github.com'
[Parameter(Position = 0, Mandatory = $true)] $php_dir = 'C:\tools\php'
[ValidateNotNull()] $ext_dir = $php_dir + '\ext'
[ValidateSet('phalcon3', 'phalcon4')]
[string]
$extension
)
try {
$status = 'Enabled'
$extension_version = $extension.substring($extension.Length - 1) $extension_version = $extension.substring($extension.Length - 1)
if($extension_version -eq '4') { if($extension_version -eq '4') {
@ -38,18 +46,11 @@ Function Add-Phalcon() {
$phalcon = Get-PhpExtension $ext_dir\php_phalcon.dll $phalcon = Get-PhpExtension $ext_dir\php_phalcon.dll
if($phalcon.Version[0] -eq $extension_version) { if($phalcon.Version[0] -eq $extension_version) {
Enable-PhpExtension -Extension phalcon -Path $php_dir Enable-PhpExtension -Extension phalcon -Path $php_dir
printf "\033[%s;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" "32" $tick $extension "Enabled"
} else { } else {
$status = 'Installed and enabled'
Remove-Item $ext_dir\php_phalcon.dll Remove-Item $ext_dir\php_phalcon.dll
Add-PhalconHelper Install-Phalcon
} }
} else { } else {
$status = 'Installed and enabled' Install-Phalcon
Add-PhalconHelper
}
Add-Log $tick $extension $status
} catch [Exception] {
Write-Output $_.Exception|format-list -force
Add-Log $cross $extension "Could not install $extension on PHP $($installed.FullVersion)"
}
} }

View File

@ -1,65 +1,71 @@
# Helper function to add phalcon. # Function to log result of a operation
add_phalcon_helper() { add_log() {
status='Installed and enabled' mark=$1
if [ "$os_name" = "Linux" ]; then subject=$2
update_lists message=$3
${apt_install:?} "php${version:?}-$extension" 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 else
phalcon_ini_file=${ini_file:?} printf "\033[31;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s\033[0m\n" "$mark" "$subject" "$message"
sed -i '' '/extension.*psr/d' "${ini_file:?}"
brew tap shivammathur/homebrew-phalcon
brew install phalcon@"${version:?}"_"$extension_major_version"
sudo cp /usr/local/opt/psr@"${version:?}"/psr.so "${ext_dir:?}"
sudo cp /usr/local/opt/phalcon@"${version:?}"_"$extension_major_version"/phalcon.so "${ext_dir:?}"
fi fi
} }
# Function to add phalcon3. # Function to update php ppa
add_phalcon3() { update_ppa() {
if [ -e "${ext_dir:?}/phalcon.so" ]; then if [ "$ppa_updated" = "false" ]; then
phalcon_version=$(php -d="extension=phalcon.so" -r "echo phpversion('phalcon');" | cut -d'.' -f 1) find /etc/apt/sources.list.d -type f -name 'ondrej-ubuntu-php*.list' -exec sudo DEBIAN_FRONTEND=noninteractive apt-get update -o Dir::Etc::sourcelist="{}" ';' >/dev/null 2>&1
if [ "$phalcon_version" != "$extension_major_version" ]; then ppa_updated="true"
add_phalcon_helper
else
echo "extension=phalcon.so" | sudo tee -a "$phalcon_ini_file"
fi
else
add_phalcon_helper
fi fi
} }
# Function to add phalcon4. # Function to install phalcon
add_phalcon4() { install_phalcon() {
if [ -e "${ext_dir:?}/psr.so" ] && ! php -m | grep -i -q -w psr; then extension=$1
echo "extension=psr.so" | sudo tee -a "${ini_file:?}" version=$2
(update_ppa && sudo DEBIAN_FRONTEND=noninteractive apt-get install -y "php$version-$extension" >/dev/null 2>&1 && add_log "$tick" "$extension" "Installed and enabled") ||
add_log "$cross" "$extension" "Could not install $extension on PHP $semver"
}
ini_file="/etc/php/$2/cli/conf.d/50-phalcon.ini"
ext_dir=$(php -i | grep "extension_dir => /usr" | sed -e "s|.*=> s*||")
semver=$(php -v | head -n 1 | cut -f 2 -d ' ' | cut -f 1 -d '-')
extension_major_version=$(echo "$1" | grep -i -Po '\d')
ppa_updated="false"
tick="✓"
cross="✗"
if [ "$extension_major_version" = "4" ]; then
if [ -e "$ext_dir/psr.so" ] && ! php -m | grep -i -q -w psr; then
echo "extension=psr.so" | sudo tee -a "$ini_file" >/dev/null 2>&1
fi fi
if [ -e "$ext_dir/phalcon.so" ]; then if [ -e "$ext_dir/phalcon.so" ]; then
if php -m | grep -i -q -w psr; then if php -m | grep -i -q -w psr; then
phalcon_version=$(php -d="extension=phalcon" -r "echo phpversion('phalcon');" | cut -d'.' -f 1) phalcon_version=$(php -d="extension=phalcon" -r "echo phpversion('phalcon');" | cut -d'.' -f 1)
if [ "$phalcon_version" != "$extension_major_version" ]; then if [ "$phalcon_version" != "$extension_major_version" ]; then
add_phalcon_helper install_phalcon "$1" "$2"
else else
echo "extension=phalcon.so" | sudo tee -a "$phalcon_ini_file" echo "extension=phalcon.so" | sudo tee -a "$ini_file" >/dev/null 2>&1
add_log "$tick" "$1" "Enabled"
fi fi
else else
add_phalcon_helper install_phalcon "$1" "$2"
fi fi
else else
add_phalcon_helper install_phalcon "$1" "$2"
fi
fi fi
}
# Function to add phalcon. if [ "$extension_major_version" = "3" ]; then
add_phalcon() { if [ -e "$ext_dir/phalcon.so" ]; then
extension=$1 phalcon_version=$(php -d="extension=phalcon.so" -r "echo phpversion('phalcon');" | cut -d'.' -f 1)
status='Enabled' if [ "$phalcon_version" != "$extension_major_version" ]; then
os_name=$(uname -s) install_phalcon "$1" "$2"
phalcon_ini_file="${scan_dir:?}/50-phalcon.ini" else
extension_major_version=${extension: -1} echo "extension=phalcon.so" | sudo tee -a "$ini_file" >/dev/null 2>&1
if [ "$extension_major_version" = "4" ]; then add_log "$tick" "$1" "Enabled"
add_phalcon4 >/dev/null 2>&1 fi
elif [ "$extension_major_version" = "3" ]; then else
add_phalcon3 >/dev/null 2>&1 install_phalcon "$1" "$2"
fi
fi fi
add_extension_log "phalcon" "$status"
}

View File

@ -0,0 +1,47 @@
# Function to log result of a operation
add_log() {
mark=$1
subject=$2
message=$3
if [ "$mark" = "$tick" ]; then
printf "\033[32;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s\033[0m\n" "$mark" "$subject" "$message"
else
printf "\033[31;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s\033[0m\n" "$mark" "$subject" "$message"
fi
}
# Function to install phalcon
install_phalcon() {
(
sed -i '' '/extension.*psr/d' "$ini_file"
brew tap shivammathur/homebrew-phalcon >/dev/null 2>&1
brew install phalcon@"$php_version"_"$extension_major" >/dev/null 2>&1
sudo cp /usr/local/opt/psr@"$php_version"/psr.so "$ext_dir" >/dev/null 2>&1
sudo cp /usr/local/opt/phalcon@"$php_version"_"$extension_major"/phalcon.so "$ext_dir" >/dev/null 2>&1
add_log "$tick" "$extension" "Installed and enabled"
) || add_log "$cross" "$extension" "Could not install $extension on PHP $semver"
}
tick="✓"
cross="✗"
extension=$1
extension_major=${extension: -1}
php_version=$2
semver=$(php -v | head -n 1 | cut -f 2 -d ' ')
ini_file=$(php --ini | grep "Loaded Configuration" | sed -e "s|.*:s*||" | sed "s/ //g")
ext_dir=$(php -i | grep "extension_dir => /usr" | sed -e "s|.*=> s*||")
if [ -e "$ext_dir/psr.so" ] && [ -e "$ext_dir/phalcon.so" ]; then
phalcon_version=$(php -d="extension=psr.so" -d="extension=phalcon.so" -r "echo phpversion('phalcon');" 2>/dev/null | cut -d'.' -f 1)
if php -m | grep -i -q -w psr; then
phalcon_version=$(php -d="extension=phalcon.so" -r "echo phpversion('phalcon');" 2>/dev/null | cut -d'.' -f 1)
fi
if [ "$phalcon_version" != "$extension_major" ]; then
install_phalcon
else
if ! php -m | grep -i -q -w psr; then echo "extension=psr.so" >>"$ini_file"; fi
echo "extension=phalcon.so" >>"$ini_file"
add_log "$tick" "$extension" "Enabled"
fi
else
install_phalcon
fi

View File

@ -1,10 +1,10 @@
# Function to log start of a operation. # Function to log start of a operation
step_log() { step_log() {
message=$1 message=$1
printf "\n\033[90;1m==> \033[0m\033[37;1m%s\033[0m\n" "$message" printf "\n\033[90;1m==> \033[0m\033[37;1m%s\033[0m\n" "$message"
} }
# Function to log result of a operation. # Function to log result of a operation
add_log() { add_log() {
mark=$1 mark=$1
subject=$2 subject=$2
@ -16,80 +16,37 @@ add_log() {
fi fi
} }
# Function to log result of installing extension. # Function to backup and cleanup package lists
add_extension_log() {
extension=$1
status=$2
extension_name=$(echo "$extension" | cut -d '-' -f 1)
(
check_extension "$extension_name" && add_log "$tick" "$extension_name" "$status"
) || add_log "$cross" "$extension_name" "Could not install $extension on PHP $semver"
}
# Function to read env inputs.
read_env() {
. /etc/lsb-release
[[ -z "${update}" ]] && update='false' && UPDATE='false' || update="${update}"
[ "$update" = false ] && [[ -n ${UPDATE} ]] && update="${UPDATE}"
[[ -z "${runner}" ]] && runner='github' && RUNNER='github' || runner="${runner}"
[ "$runner" = false ] && [[ -n ${RUNNER} ]] && runner="${RUNNER}"
}
# Function to backup and cleanup package lists.
cleanup_lists() { cleanup_lists() {
if [ ! -e /etc/apt/sources.list.d.save ]; then if [ ! -e /etc/apt/sources.list.d.save ]; then
sudo mv /etc/apt/sources.list.d /etc/apt/sources.list.d.save sudo mv /etc/apt/sources.list.d /etc/apt/sources.list.d.save || true
sudo mkdir /etc/apt/sources.list.d sudo mkdir /etc/apt/sources.list.d
sudo mv /etc/apt/sources.list.d.save/*ondrej*.list /etc/apt/sources.list.d/ sudo mv /etc/apt/sources.list.d.save/*ondrej*.list /etc/apt/sources.list.d/ || true
sudo mv /etc/apt/sources.list.d.save/*dotdeb*.list /etc/apt/sources.list.d/ 2>/dev/null || true
trap "sudo mv /etc/apt/sources.list.d.save/*.list /etc/apt/sources.list.d/" exit trap "sudo mv /etc/apt/sources.list.d.save/*.list /etc/apt/sources.list.d/" exit
fi fi
} }
# Function to add ppa:ondrej/php. # Function to update php ppa
add_ppa() {
if ! apt-cache policy | grep -q ondrej/php; then
cleanup_lists
LC_ALL=C.UTF-8 sudo apt-add-repository ppa:ondrej/php -y
if [ "$DISTRIB_RELEASE" = "16.04" ]; then
sudo "$debconf_fix" apt-get update
fi
fi
}
# Function to update the package lists.
update_lists() { update_lists() {
if [ ! -e /tmp/setup_php ]; then if [ "$lists_updated" = "false" ]; then
[ "$DISTRIB_RELEASE" = "20.04" ] && add_ppa >/dev/null 2>&1 cleanup_lists >/dev/null 2>&1
cleanup_lists
sudo "$debconf_fix" apt-get update >/dev/null 2>&1 sudo "$debconf_fix" apt-get update >/dev/null 2>&1
echo '' | sudo tee "/tmp/setup_php" >/dev/null 2>&1
fi fi
} }
# Function to setup environment for self-hosted runners. # Function to configure PECL
self_hosted_setup() {
echo "Set disable_coredump false" | sudo tee -a /etc/sudo.conf
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() { configure_pecl() {
if [ "$pecl_config" = "false" ] && [ -e /usr/bin/pecl ]; then if [ "$pecl_config" = "false" ] && [ -e /usr/bin/pecl ]; then
for tool in pear pecl; do for tool in pear pecl; do
sudo "$tool" config-set php_ini "$scan_dir"/99-pecl.ini sudo "$tool" config-set php_ini "$pecl_file" >/dev/null 2>&1
sudo "$tool" channel-update "$tool".php.net sudo "$tool" config-set auto_discover 1 >/dev/null 2>&1
sudo "$tool" channel-update "$tool".php.net >/dev/null 2>&1
done done
pecl_config="true" pecl_config="true"
fi fi
} }
# Fuction to get the PECL version of an extension. # Fuction to get the PECL version
get_pecl_version() { get_pecl_version() {
extension=$1 extension=$1
stability="$(echo "$2" | grep -m 1 -Eio "(alpha|beta|rc|snapshot)")" stability="$(echo "$2" | grep -m 1 -Eio "(alpha|beta|rc|snapshot)")"
@ -108,7 +65,7 @@ pecl_install() {
yes '' | sudo pecl install -f "$extension" >/dev/null 2>&1 yes '' | sudo pecl install -f "$extension" >/dev/null 2>&1
} }
# Function to check if an extension is loaded. # Function to test if extension is loaded
check_extension() { check_extension() {
extension=$1 extension=$1
if [ "$extension" != "mysql" ]; then if [ "$extension" != "mysql" ]; then
@ -118,82 +75,44 @@ check_extension() {
fi fi
} }
# Function to delete extensions. # Function to delete extensions
delete_extension() { delete_extension() {
extension=$1 extension=$1
sudo sed -i "/$extension/d" "$ini_file" sudo sed -i "/$extension/d" "$ini_file"
sudo sed -i "/$extension/d" "$pecl_file" sudo sed -i "/$extension/d" "$pecl_file"
sudo rm -rf "$scan_dir"/*"$extension"* >/dev/null 2>&1 sudo rm -rf "$scan_dir"/*"$extension"* >/dev/null 2>&1
sudo rm -rf "$ext_dir"/"$extension".so >/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
fi
} }
# Function to disable and delete extensions. # Function to disable and delete extensions
remove_extension() { remove_extension() {
extension=$1 extension=$1
if check_extension "$extension"; then if [ -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"
sudo phpdismod -v "$version" "$extension" >/dev/null 2>&1
fi fi
delete_extension "$extension" delete_extension "$extension"
(! 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. # Function to setup extensions
enable_extension() {
if ! check_extension "$1" && [ -e "$ext_dir/$1.so" ]; then
echo "$2=$1.so" >>"$pecl_file"
fi
}
# Funcion to add PDO extension.
add_pdo_extension() {
pdo_ext="pdo_$1"
if check_extension "$pdo_ext"; then
add_log "$tick" "$pdo_ext" "Enabled"
else
read -r ext ext_name <<< "$1 $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 [ "$ext" = "mysql" ]; then
enable_extension "mysqlnd" "extension"
ext_name="mysqli"
elif [ "$ext" = "sqlite" ]; then
read -r ext ext_name <<< "sqlite3 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_log "$pdo_ext" "Enabled"
fi
}
# Function to add extensions.
add_extension() { add_extension() {
extension=$1 extension=$1
install_command=$2 install_command=$2
prefix=$3 prefix=$3
enable_extension "$extension" "$prefix" if ! check_extension "$extension" && [ -e "$ext_dir/$extension.so" ]; then
if check_extension "$extension"; then echo "$prefix=$extension.so" >>"$ini_file" && add_log "$tick" "$extension" "Enabled"
elif check_extension "$extension"; then
add_log "$tick" "$extension" "Enabled" add_log "$tick" "$extension" "Enabled"
else elif ! check_extension "$extension"; then
if [[ "$version" =~ 5.[4-5] ]]; then
install_command="update_lists && ${install_command/5\.[4-5]-$extension/5-$extension=$release_version}"
fi
eval "$install_command" >/dev/null 2>&1 || eval "$install_command" >/dev/null 2>&1 ||
(update_lists && eval "$install_command" >/dev/null 2>&1) || pecl_install "$extension" (update_lists && eval "$install_command" >/dev/null 2>&1) ||
add_extension_log "$extension" "Installed and enabled" sudo pecl install -f "$extension" >/dev/null 2>&1
(check_extension "$extension" && add_log "$tick" "$extension" "Installed and enabled") ||
add_log "$cross" "$extension" "Could not install $extension on PHP $semver"
fi fi
sudo chmod 777 "$ini_file" sudo chmod 777 "$ini_file"
} }
# Function to install a PECL version. # Function to install a PECL version
add_pecl_extension() { add_pecl_extension() {
extension=$1 extension=$1
pecl_version=$2 pecl_version=$2
@ -209,12 +128,15 @@ add_pecl_extension() {
add_log "$tick" "$extension" "Enabled" add_log "$tick" "$extension" "Enabled"
else else
delete_extension "$extension" delete_extension "$extension"
pecl_install "$extension-$pecl_version" (
add_extension_log "$extension-$pecl_version" "Installed and enabled" sudo pecl install -f "$extension-$pecl_version" >/dev/null 2>&1 &&
check_extension "$extension" &&
add_log "$tick" "$extension" "Installed and enabled"
) || add_log "$cross" "$extension" "Could not install $extension-$pecl_version on PHP $semver"
fi fi
} }
# Function to pre-release extensions using PECL. # Function to pre-release extensions using PECL
add_unstable_extension() { add_unstable_extension() {
extension=$1 extension=$1
stability=$2 stability=$2
@ -223,25 +145,6 @@ add_unstable_extension() {
add_pecl_extension "$extension" "$pecl_version" "$prefix" add_pecl_extension "$extension" "$pecl_version" "$prefix"
} }
# Function to install extension from source
add_extension_from_source() {
extension=$1
repo=$2
release=$3
args=$4
prefix=$5
(
add_devtools
delete_extension "$extension"
curl -o /tmp/"$extension".tar.gz "${curl_opts[@]}" 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
enable_extension "$extension" "$prefix"
) >/dev/null 2>&1
add_extension_log "$extension-$release" "Installed and enabled"
}
# Function to configure composer # Function to configure composer
configure_composer() { configure_composer() {
tool_path=$1 tool_path=$1
@ -252,7 +155,7 @@ configure_composer() {
exit 1; exit 1;
fi fi
composer -q global config process-timeout 0 composer -q global config process-timeout 0
echo "/home/$USER/.composer/vendor/bin" >> $GITHUB_PATH echo "/home/$USER/.composer/vendor/bin" >> "$GITHUB_PATH"
if [ -n "$COMPOSER_TOKEN" ]; then if [ -n "$COMPOSER_TOKEN" ]; then
composer -q global config github-oauth.github.com "$COMPOSER_TOKEN" composer -q global config github-oauth.github.com "$COMPOSER_TOKEN"
fi fi
@ -279,23 +182,19 @@ add_tool() {
configure_composer "$tool_path" configure_composer "$tool_path"
elif [ "$tool" = "cs2pr" ]; then elif [ "$tool" = "cs2pr" ]; then
sudo sed -i 's/\r$//; s/exit(9)/exit(0)/' "$tool_path" 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 elif [ "$tool" = "phive" ]; then
add_extension curl "$apt_install php$version-curl" extension >/dev/null 2>&1 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 mbstring "$apt_install php$version-mbstring" extension >/dev/null 2>&1
add_extension xml "$apt_install php$version-xml" 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 fi
add_log "$tick" "$tool" "Added" add_log "$tick" "$tool" "Added"
else else
add_log "$cross" "$tool" "Could not setup $tool" add_log "$cross" "$tool" "Could not setup $tool"
[ "$tool" = "composer" ] && exit 1
fi fi
} }
# Function to setup a tool using composer. # Function to setup a tool using composer
add_composertool() { add_composertool() {
tool=$1 tool=$1
release=$2 release=$2
@ -306,39 +205,32 @@ add_composertool() {
) || add_log "$cross" "$tool" "Could not setup $tool" ) || add_log "$cross" "$tool" "Could not setup $tool"
} }
# Function to setup phpize and php-config. # Function to setup phpize and php-config
add_devtools() { add_devtools() {
if ! [ -e "/usr/bin/phpize$version" ] || ! [ -e "/usr/bin/php-config$version" ]; then 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 update_lists && $apt_install php"$version"-dev php"$version"-xml >/dev/null 2>&1
fi fi
sudo update-alternatives --set php-config /usr/bin/php-config"$version" >/dev/null 2>&1 sudo update-alternatives --set php-config /usr/bin/php-config"$version" >/dev/null 2>&1
sudo update-alternatives --set phpize /usr/bin/phpize"$version" >/dev/null 2>&1 sudo update-alternatives --set phpize /usr/bin/phpize"$version" >/dev/null 2>&1
configure_pecl >/dev/null 2>&1
}
# Function to setup the nightly build from master branch.
setup_master() {
curl "${curl_opts[@]}" "$github"/php-builder/releases/latest/download/install.sh | bash -s "$runner"
}
# 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"
configure_pecl configure_pecl
release_version=$(php -v | head -n 1 | cut -d' ' -f 2)
} }
# Function to add PECL. # Function to setup the nightly build from master branch
setup_master() {
curl "${curl_opts[@]}" https://github.com/shivammathur/php-builder/releases/latest/download/install.sh | bash -s "github"
}
# Function to setup PECL
add_pecl() { add_pecl() {
add_devtools >/dev/null 2>&1 add_devtools
if [ ! -e /usr/bin/pecl ]; then if [ ! -e /usr/bin/pecl ]; then
$apt_install php-pear >/dev/null 2>&1 || update_lists && $apt_install php-pear >/dev/null 2>&1 $apt_install php-pear >/dev/null 2>&1
fi fi
configure_pecl >/dev/null 2>&1 configure_pecl
add_log "$tick" "PECL" "Added" add_log "$tick" "PECL" "Added"
} }
# Function to switch versions of PHP binaries. # Function to switch versions of PHP binaries
switch_version() { switch_version() {
for tool in pear pecl php phar phar.phar php-cgi php-config phpize phpdbg; do for tool in pear pecl php phar phar.phar php-cgi php-config phpize phpdbg; do
if [ -e "/usr/bin/$tool$version" ]; then if [ -e "/usr/bin/$tool$version" ]; then
@ -347,109 +239,65 @@ switch_version() {
done done
} }
# Function to get PHP version in semver format. # Function to get PHP version in semver format
php_semver() { php_semver() {
if [ ! "$version" = "$master_version" ]; then if [ ! "$version" = "8.0" ]; then
php"$version" -v | head -n 1 | cut -f 2 -d ' ' | cut -f 1 -d '-' php"$version" -v | head -n 1 | cut -f 2 -d ' ' | cut -f 1 -d '-'
else else
php -v | head -n 1 | cut -f 2 -d ' ' php -v | head -n 1 | cut -f 2 -d ' '
fi fi
} }
# 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")"
$apt_install "${packages[@]}"
else
curl "${curl_opts[@]}" "$github"/php-ubuntu/releases/latest/download/install.sh | bash -s "$version"
fi
}
# Function to update PHP.
update_php() {
initial_version=$(php_semver)
use_package_cache="false"
add_packaged_php
updated_version=$(php_semver)
if [ "$updated_version" != "$initial_version" ]; then
status="Updated to"
else
status="Switched to"
fi
}
# Function to install PHP.
add_php() {
if [ "$version" = "$master_version" ]; then
setup_master
elif [[ "$version" =~ $old_versions ]]; then
setup_old_versions
else
add_packaged_php
fi
status="Installed"
}
# Variables # Variables
tick="✓" tick="✓"
cross="✗" cross="✗"
lists_updated="false"
pecl_config="false" pecl_config="false"
version=$1 version=$1
master_version="8.0" dist=$2
old_versions="5.[3-5]"
debconf_fix="DEBIAN_FRONTEND=noninteractive" debconf_fix="DEBIAN_FRONTEND=noninteractive"
github="https://github.com/shivammathur"
apt_install="sudo $debconf_fix apt-fast install -y" apt_install="sudo $debconf_fix apt-fast install -y"
apt_remove="sudo $debconf_fix apt-fast remove -y"
tool_path_dir="/usr/local/bin" tool_path_dir="/usr/local/bin"
curl_opts=(-sL) curl_opts=(-sL)
existing_version=$(php-config --version 2>/dev/null | cut -c 1-3) existing_version=$(php-config --version 2>/dev/null | cut -c 1-3)
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 # Setup PHP
step_log "Setup PHP" step_log "Setup PHP"
sudo mkdir -p /var/run /run/php sudo mkdir -p /var/run /run/php
if [ "$existing_version" != "$version" ]; then . /etc/lsb-release
if [ ! -e "/usr/bin/php$version" ]; then if [ "$DISTRIB_RELEASE" = "20.04" ]; then
add_php >/dev/null 2>&1 if ! apt-cache policy | grep -q ondrej/php; then
else cleanup_lists >/dev/null 2>&1
if [ "$update" = "true" ]; then LC_ALL=C.UTF-8 sudo apt-add-repository ppa:ondrej/php -y >/dev/null 2>&1
update_php >/dev/null 2>&1
else
status="Switched to"
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" = "$master_version" ]; then
switch_version >/dev/null 2>&1
fi
fi fi
fi fi
if [ "$existing_version" != "$version" ]; then
if [ ! -e "/usr/bin/php$version" ]; then
if [ "$version" = "8.0" ]; then
setup_master >/dev/null 2>&1
else
update_lists
IFS=' ' read -r -a packages <<< "$(echo "cli curl mbstring xml intl" | sed "s/[^ ]*/php$version-&/g")"
$apt_install "${packages[@]}" >/dev/null 2>&1
fi
status="Installed"
else
status="Switched to"
fi
switch_version >/dev/null 2>&1
else
status="Found"
fi
semver=$(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*||") scan_dir=$(php --ini | grep additional | sed -e "s|.*: s*||")
ini_file=$(php --ini | grep "Loaded Configuration" | sed -e "s|.*:s*||" | sed "s/ //g") ini_file=$(php --ini | grep "Loaded Configuration" | sed -e "s|.*:s*||" | sed "s/ //g")
ext_dir=$(php -i | grep "extension_dir => /" | sed -e "s|.*=> s*||")
pecl_file="$scan_dir"/99-pecl.ini pecl_file="$scan_dir"/99-pecl.ini
echo '' | sudo tee "$pecl_file" >/dev/null 2>&1 echo '' | sudo tee "$pecl_file" >/dev/null 2>&1
sudo rm -rf /usr/local/bin/phpunit >/dev/null 2>&1 sudo rm -rf /usr/local/bin/phpunit >/dev/null 2>&1
sudo chmod 777 "$ini_file" "$pecl_file" "$tool_path_dir" sudo chmod 777 "$ini_file" "$pecl_file" "$tool_path_dir"
sudo mv "$dist"/../src/configs/*.json "$RUNNER_TOOL_CACHE/"
add_log "$tick" "PHP" "$status PHP $semver" add_log "$tick" "PHP" "$status PHP $semver"

View File

@ -1,21 +0,0 @@
# Function to add blackfire and blackfire-agent.
Function Add-Blackfire() {
$arch_name ='amd64'
if(-not([Environment]::Is64BitOperatingSystem) -or $version -lt '7.0') {
$arch_name = '386'
}
$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
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"
if ((Test-Path env:BLACKFIRE_SERVER_ID) -and (Test-Path env:BLACKFIRE_SERVER_TOKEN)) {
blackfire-agent --register --server-id=$env:BLACKFIRE_SERVER_ID --server-token=$env:BLACKFIRE_SERVER_TOKEN >$null 2>&1
}
if ((Test-Path env:BLACKFIRE_CLIENT_ID) -and (Test-Path env:BLACKFIRE_CLIENT_TOKEN)) {
blackfire config --client-id=$env:BLACKFIRE_CLIENT_ID --client-token=$env:BLACKFIRE_CLIENT_TOKEN --ca-cert=$php_dir\ssl\cacert.pem >$null 2>&1
}
Add-Log $tick "blackfire" "Added"
Add-Log $tick "blackfire-agent" "Added"
}

View File

@ -1,34 +0,0 @@
add_blackfire_linux() {
sudo mkdir -p /var/run/blackfire
sudo curl "${curl_opts[@]:?}" 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
}
add_blackfire_darwin() {
sudo mkdir -p /usr/local/var/run
brew tap --shallow blackfireio/homebrew-blackfire
brew install blackfire-agent
}
blackfire_config() {
if [[ -n $BLACKFIRE_SERVER_ID ]] && [[ -n $BLACKFIRE_SERVER_TOKEN ]]; then
sudo blackfire-agent --register --server-id="$BLACKFIRE_SERVER_ID" --server-token="$BLACKFIRE_SERVER_TOKEN"
[ "$os" = "Linux" ] && sudo /etc/init.d/blackfire-agent restart
[ "$os" = "Darwin" ] && brew services start blackfire-agent
fi
if [[ -n $BLACKFIRE_CLIENT_ID ]] && [[ -n $BLACKFIRE_CLIENT_TOKEN ]]; then
blackfire config --client-id="$BLACKFIRE_CLIENT_ID" --client-token="$BLACKFIRE_CLIENT_TOKEN"
fi
}
# Function to add blackfire and blackfire-agent.
add_blackfire() {
os="$(uname -s)"
[ "$os" = "Linux" ] && add_blackfire_linux >/dev/null 2>&1
[ "$os" = "Darwin" ] && add_blackfire_darwin >/dev/null 2>&1
blackfire_config >/dev/null 2>&1
add_log "${tick:?}" "blackfire" "Added"
add_log "${tick:?}" "blackfire-agent" "Added"
}

View File

@ -1,20 +0,0 @@
Function Add-Msys2() {
$msys_location = 'C:\msys64'
if (-not(Test-Path $msys_location)) {
choco install msys2 -y >$null 2>&1
$msys_location = 'C:\tools\msys64'
}
return $msys_location
}
Function Add-Grpc_php_plugin() {
$msys_location = Add-Msys2
. $msys_location\usr\bin\bash -l -c "pacman -S --noconfirm mingw-w64-x86_64-grpc" >$null 2>&1
Write-Output "$msys_location\mingw64\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8
Write-Output "::set-output name=grpc_php_plugin_path::$msys_location\mingw64\bin\grpc_php_plugin.exe"
Add-ToProfile $current_profile 'grpc_php_plugin' "New-Alias grpc_php_plugin $msys_location\mingw64\bin\grpc_php_plugin.exe"
Add-Log $tick "grpc_php_plugin" "Added"
printf "::group::\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" "grpc_php_plugin" "Click to read the grpc_php_plugin related license information"
Write-Output (Invoke-WebRequest https://raw.githubusercontent.com/grpc/grpc/master/LICENSE).Content
Write-Output "::endgroup::"
}

View File

@ -1,51 +0,0 @@
add_bazel() {
if [ ! "$(command -v bazel)" ]; then
os=$(uname -s)
if [ "$os" = "Linux" ]; then
${apt_install:?} curl gnupg
curl "${curl_opts[@]:?}" 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
brew install bazel
fi
fi
}
get_grpc_tag() {
if [ "$grpc_tag" = "latest" ]; then
grpc_tag=$(curl "${curl_opts[@]:?}" 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")
if [ "$status_code" = "200" ]; then
grpc_tag="v$grpc_tag"
else
grpc_tag=$(curl "${curl_opts[@]:?}" https://grpc.io/release)
fi
fi
}
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
cd "/tmp/grpc-${grpc_tag:1}" || exit
add_bazel
echo "os: $os"
echo "release: $DISTRIB_RELEASE"
if [ "$DISTRIB_RELEASE" = "16.04" ]; then
CC="$(command -v gcc)" CXX="$(command -v g++)" ./tools/bazel build src/compiler:grpc_php_plugin
else
./tools/bazel build src/compiler:grpc_php_plugin
fi
sudo mv ./bazel-bin/src/compiler/grpc_php_plugin /usr/local/bin/grpc_php_plugin
sudo chmod a+x /usr/local/bin/grpc_php_plugin
) >/dev/null 2>&1
echo "::set-output name=grpc_php_plugin_path::/usr/local/bin/grpc_php_plugin"
add_log "${tick:?}" "grpc_php_plugin" "Added"
printf "::group::\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" "grpc_php_plugin" "Click to read the grpc_php_plugin related license information"
cat "/tmp/grpc-${grpc_tag:1}/LICENSE"
echo "::endgroup::"
}

View File

@ -1,38 +0,0 @@
Function Get-ProtobufTag() {
if("$protobuf_tag" -eq "latest") {
$protobuf_tag = (Invoke-RestMethod https://api.github.com/repos/protocolbuffers/protobuf/tags).Name | Where-Object { $_ -match "v\d+.\d+.\d+$" } | Select-Object -First 1
} else {
try {
[net.httpWebRequest] $request = [net.webRequest]::create("https://github.com/protocolbuffers/protobuf/releases/tag/v$protobuf_tag")
$req.Method = "HEAD"
[net.httpWebResponse] $response = $request.getResponse()
$response.Close()
$protobuf_tag = "v$protobuf_tag"
} catch {
$protobuf_tag = (Invoke-RestMethod https://api.github.com/repos/protocolbuffers/protobuf/tags).Name | Where-Object { $_ -match "v\d+.\d+.\d+$" } | Select-Object -First 1
}
}
return $protobuf_tag
}
Function Add-Protoc() {
param(
[Parameter(Mandatory = $true, Position = 0, HelpMessage = 'The PHP version to be installed')]
[ValidatePattern('^latest$|^(v?)\d+\.\d+\.\d+$')]
[string] $protobuf_tag
)
$protobuf_tag = Get-ProtobufTag
$arch_num = '64'
if(-not([Environment]::Is64BitOperatingSystem)) {
$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
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"
Add-Log $tick "protoc" "Added"
printf "::group::\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" "protoc" "Click to read the protoc related license information"
Write-Output (Invoke-WebRequest https://raw.githubusercontent.com/protocolbuffers/protobuf/master/LICENSE).Content
Write-Output "::endgroup::"
}

View File

@ -1,28 +0,0 @@
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)
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")
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)
fi
fi
}
add_protoc() {
protobuf_tag=$1
get_protobuf_tag
(
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"
sudo unzip /tmp/protobuf.zip -d /usr/local/
sudo chmod 777 /usr/local/bin/protoc -R /usr/local/include/google
) >/dev/null 2>&1
add_log "${tick:?}" "protoc" "Added"
printf "::group::\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" "protoc" "Click to read the protoc related license information"
curl "${curl_opts[@]:?}" https://raw.githubusercontent.com/protocolbuffers/protobuf/master/LICENSE
echo "::endgroup::"
}

View File

@ -8,21 +8,18 @@ param (
[ValidateNotNull()] [ValidateNotNull()]
[ValidateLength(1, [int]::MaxValue)] [ValidateLength(1, [int]::MaxValue)]
[string] [string]
$dir $dist
) )
# Function to log start of a operation.
Function Step-Log($message) { Function Step-Log($message) {
printf "\n\033[90;1m==> \033[0m\033[37;1m%s \033[0m\n" $message printf "\n\033[90;1m==> \033[0m\033[37;1m%s \033[0m\n" $message
} }
# Function to log result of a operation.
Function Add-Log($mark, $subject, $message) { Function Add-Log($mark, $subject, $message) {
$code = if ($mark -eq $cross) { "31" } else { "32" } $code = if ($mark -eq $cross) { "31" } else { "32" }
printf "\033[%s;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" $code $mark $subject $message printf "\033[%s;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" $code $mark $subject $message
} }
# Function to add a line to a powershell profile safely.
Function Add-ToProfile { Function Add-ToProfile {
param( param(
[Parameter(Position = 0, Mandatory = $true)] [Parameter(Position = 0, Mandatory = $true)]
@ -46,61 +43,31 @@ Function Add-ToProfile {
} }
} }
# Function to fetch PATH from the registry.
Function Get-PathFromRegistry {
$env:Path = [System.Environment]::GetEnvironmentVariable("Path","User") + ";" +
[System.Environment]::GetEnvironmentVariable("Path","Machine")
Add-ToProfile $current_profile 'Get-PathFromRegistry' 'Function Get-PathFromRegistry { $env:Path = [System.Environment]::GetEnvironmentVariable("Path", "User") + ";" + [System.Environment]::GetEnvironmentVariable("Path", "Machine") }; Get-PathFromRegistry'
}
# Function to add a location to PATH.
Function Add-Path {
param(
[string]$PathItem
)
$newPath = (Get-ItemProperty -Path 'hkcu:\Environment' -Name PATH).Path.replace("$PathItem;", '')
$newPath = $PathItem + ';' + $newPath
Set-ItemProperty -Path 'hkcu:\Environment' -Name Path -Value $newPath
Get-PathFromRegistry
}
# Function to make sure printf is in PATH.
Function Add-Printf { Function Add-Printf {
if (-not(Test-Path "C:\Program Files\Git\usr\bin\printf.exe")) { if (-not(Test-Path "C:\Program Files\Git\usr\bin\printf.exe")) {
if(Test-Path "C:\msys64\usr\bin\printf.exe") { if(Test-Path "C:\msys64\usr\bin\printf.exe") {
New-Item -Path $bin_dir\printf.exe -ItemType SymbolicLink -Value C:\msys64\usr\bin\printf.exe New-Item -Path $php_dir\printf.exe -ItemType SymbolicLink -Value C:\msys64\usr\bin\printf.exe
} else { } else {
Invoke-WebRequest -UseBasicParsing -Uri "https://github.com/shivammathur/printf/releases/latest/download/printf-x64.zip" -OutFile "$bin_dir\printf.zip" Invoke-WebRequest -UseBasicParsing -Uri "https://github.com/shivammathur/printf/releases/latest/download/printf-x64.zip" -OutFile "$php_dir\printf.zip"
Expand-Archive -Path $bin_dir\printf.zip -DestinationPath $bin_dir -Force Expand-Archive -Path $php_dir\printf.zip -DestinationPath $php_dir -Force
} }
} else { } else {
New-Item -Path $bin_dir\printf.exe -ItemType SymbolicLink -Value "C:\Program Files\Git\usr\bin\printf.exe" New-Item -Path $php_dir\printf.exe -ItemType SymbolicLink -Value "C:\Program Files\Git\usr\bin\printf.exe"
} }
} }
# Function to get a clean Powershell profile.
Function Get-CleanPSProfile {
if(-not(Test-Path -LiteralPath $profile)) {
New-Item -Path $profile -ItemType "file" -Force
}
Set-Content $current_profile -Value ''
Add-ToProfile $profile $current_profile.replace('\', '\\') ". $current_profile"
}
# Function to install PhpManager.
Function Install-PhpManager() { Function Install-PhpManager() {
$module_path = "$bin_dir\PhpManager\PhpManager.psm1" $module_path = "$php_dir\PhpManager\PhpManager.psm1"
if(-not (Test-Path $module_path -PathType Leaf)) { if(-not (Test-Path $module_path -PathType Leaf)) {
$release = Invoke-RestMethod https://api.github.com/repos/mlocati/powershell-phpmanager/releases/latest $release = Invoke-RestMethod https://api.github.com/repos/mlocati/powershell-phpmanager/releases/latest
$zip_file = "$bin_dir\PhpManager.zip" $zip_file = "$php_dir\PhpManager.zip"
Invoke-WebRequest -UseBasicParsing -Uri $release.assets[0].browser_download_url -OutFile $zip_file Invoke-WebRequest -UseBasicParsing -Uri $release.assets[0].browser_download_url -OutFile $zip_file
Expand-Archive -Path $zip_file -DestinationPath $bin_dir -Force Expand-Archive -Path $zip_file -DestinationPath $php_dir -Force
} }
Import-Module $module_path Import-Module $module_path
Add-ToProfile $current_profile 'powershell-phpmanager' "Import-Module $module_path" Add-ToProfile $current_profile 'powershell-phpmanager' "Import-Module $module_path"
} }
# Function to add PHP extensions.
Function Add-Extension { Function Add-Extension {
Param ( Param (
[Parameter(Position = 0, Mandatory = $true)] [Parameter(Position = 0, Mandatory = $true)]
@ -150,7 +117,6 @@ Function Add-Extension {
} }
} }
# Function to remove PHP extensions.
Function Remove-Extension() { Function Remove-Extension() {
Param ( Param (
[Parameter(Position = 0, Mandatory = $true)] [Parameter(Position = 0, Mandatory = $true)]
@ -160,20 +126,14 @@ Function Remove-Extension() {
$extension $extension
) )
if(php -m | findstr -i $extension) { if(php -m | findstr -i $extension) {
try {
Disable-PhpExtension $extension $php_dir Disable-PhpExtension $extension $php_dir
}
if (Test-Path $ext_dir\php_$extension.dll) { if (Test-Path $ext_dir\php_$extension.dll) {
Remove-Item $ext_dir\php_$extension.dll Remove-Item $ext_dir\php_$extension.dll
} }
Add-Log $tick ":$extension" "Removed"
} catch {
Add-Log $cross ":$extension" "Could not remove $extension on PHP $($installed.FullVersion)"
}
} else {
Add-Log $tick ":$extension" "Could not find $extension on PHP $($installed.FullVersion)"
}
} }
Function Edit-ComposerConfig() { Function Edit-ComposerConfig() {
Param( Param(
[Parameter(Position = 0, Mandatory = $true)] [Parameter(Position = 0, Mandatory = $true)]
@ -195,7 +155,6 @@ Function Edit-ComposerConfig() {
} }
} }
# Function to add tools.
Function Add-Tool() { Function Add-Tool() {
Param ( Param (
[Parameter(Position = 0, Mandatory = $true)] [Parameter(Position = 0, Mandatory = $true)]
@ -207,45 +166,44 @@ Function Add-Tool() {
[string] [string]
$tool $tool
) )
if (Test-Path $bin_dir\$tool) { if (Test-Path $php_dir\$tool) {
Remove-Item $bin_dir\$tool Remove-Item $php_dir\$tool
} }
if($url.Count -gt 1) { $url = $url[0] } if($url.Count -gt 1) { $url = $url[0] }
if ($tool -eq "symfony") { if ($tool -eq "symfony") {
Invoke-WebRequest -UseBasicParsing -Uri $url -OutFile $bin_dir\$tool.exe Invoke-WebRequest -UseBasicParsing -Uri $url -OutFile $php_dir\$tool.exe
Add-ToProfile $current_profile $tool "New-Alias $tool $bin_dir\$tool.exe" >$null 2>&1 Add-ToProfile $current_profile $tool "New-Alias $tool $php_dir\$tool.exe" > $null 2>&1
} else { } else {
try { try {
Invoke-WebRequest -UseBasicParsing -Uri $url -OutFile $bin_dir\$tool Invoke-WebRequest -UseBasicParsing -Uri $url -OutFile $php_dir\$tool
$bat_content = @() $bat_content = @()
$bat_content += "@ECHO off" $bat_content += "@ECHO off"
$bat_content += "setlocal DISABLEDELAYEDEXPANSION" $bat_content += "setlocal DISABLEDELAYEDEXPANSION"
$bat_content += "SET BIN_TARGET=%~dp0/" + $tool $bat_content += "SET BIN_TARGET=%~dp0/" + $tool
$bat_content += "php %BIN_TARGET% %*" $bat_content += "php %BIN_TARGET% %*"
Set-Content -Path $bin_dir\$tool.bat -Value $bat_content Set-Content -Path $php_dir\$tool.bat -Value $bat_content
Add-ToProfile $current_profile $tool "New-Alias $tool $bin_dir\$tool.bat" >$null 2>&1 Add-ToProfile $current_profile $tool "New-Alias $tool $php_dir\$tool.bat" > $null 2>&1
} catch { } } catch { }
} }
if($tool -eq "phan") { if($tool -eq "phive") {
Add-Extension fileinfo >$null 2>&1 Add-Extension curl >$null 2>&1
Add-Extension ast >$null 2>&1 Add-Extension mbstring >$null 2>&1
} elseif($tool -eq "phive") {
Add-Extension xml >$null 2>&1 Add-Extension xml >$null 2>&1
} elseif($tool -eq "cs2pr") { } elseif($tool -eq "cs2pr") {
(Get-Content $bin_dir/cs2pr).replace('exit(9)', 'exit(0)') | Set-Content $bin_dir/cs2pr (Get-Content $php_dir/cs2pr).replace('exit(9)', 'exit(0)') | Set-Content $php_dir/cs2pr
} elseif($tool -eq "composer") { } elseif($tool -eq "composer") {
Edit-ComposerConfig $bin_dir\$tool Edit-ComposerConfig $php_dir\$tool
} elseif($tool -eq "wp-cli") { } elseif($tool -eq "wp-cli") {
Copy-Item $bin_dir\wp-cli.bat -Destination $bin_dir\wp.bat Copy-Item $php_dir\wp-cli.bat -Destination $php_dir\wp.bat
} }
if (((Get-ChildItem -Path $bin_dir/* | Where-Object Name -Match "^$tool(.exe|.phar)*$").Count -gt 0)) {
if (((Get-ChildItem -Path $php_dir/* | Where-Object Name -Match "^$tool(.exe|.phar)*$").Count -gt 0)) {
Add-Log $tick $tool "Added" Add-Log $tick $tool "Added"
} else { } else {
Add-Log $cross $tool "Could not add $tool" Add-Log $cross $tool "Could not add $tool"
} }
} }
# Function to setup a tool using composer.
Function Add-Composertool() { Function Add-Composertool() {
Param ( Param (
[Parameter(Position = 0, Mandatory = $true)] [Parameter(Position = 0, Mandatory = $true)]
@ -272,7 +230,6 @@ Function Add-Composertool() {
} }
} }
# Function to handle request to add PECL.
Function Add-Pecl() { Function Add-Pecl() {
Add-Log $tick "PECL" "Use extensions input to setup PECL extensions on windows" Add-Log $tick "PECL" "Use extensions input to setup PECL extensions on windows"
} }
@ -282,46 +239,17 @@ $tick = ([char]8730)
$cross = ([char]10007) $cross = ([char]10007)
$php_dir = 'C:\tools\php' $php_dir = 'C:\tools\php'
$ext_dir = "$php_dir\ext" $ext_dir = "$php_dir\ext"
$bin_dir = $php_dir $current_profile = "$PSHOME\Profile.ps1"
$current_profile = "$env:TEMP\setup-php.ps1"
$ProgressPreference = 'SilentlyContinue' $ProgressPreference = 'SilentlyContinue'
$master_version = '8.0' $master_version = '8.0'
$cert_source='CurrentUser'
$arch = 'x64' $arch = 'x64'
if(-not([Environment]::Is64BitOperatingSystem) -or $version -lt '7.0') {
$arch = 'x86'
}
$ts = $env:PHPTS -eq 'ts' $ts = $env:PHPTS -eq 'ts'
if($env:PHPTS -ne 'ts') { if($env:PHPTS -ne 'ts') {
$env:PHPTS = 'nts' $env:PHPTS = 'nts'
} }
if($env:RUNNER -eq 'self-hosted') {
$bin_dir = 'C:\tools\bin'
$php_dir = "$php_dir$version"
$ext_dir = "$php_dir\ext"
$cert_source='Curl'
Get-CleanPSProfile >$null 2>&1
New-Item $bin_dir -Type Directory 2>&1 | Out-Null
Add-Path -PathItem $bin_dir
if($version -lt 5.6) {
Add-Log $cross "PHP" "PHP $version is not supported on self-hosted runner"
Start-Sleep 1
exit 1
}
if ((Get-InstalledModule).Name -notcontains 'VcRedist') {
Install-Module -Name VcRedist -Force
}
New-Item $php_dir -Type Directory 2>&1 | Out-Null
Add-Path -PathItem $php_dir
setx PHPROOT $php_dir >$null 2>&1
} else {
$current_profile = "$PSHOME\Profile.ps1"
if(-not(Test-Path -LiteralPath $current_profile)) { if(-not(Test-Path -LiteralPath $current_profile)) {
New-Item -Path $current_profile -ItemType "file" -Force >$null 2>&1 New-Item -Path $current_profile -ItemType "file" -Force >$null 2>&1
} }
}
Add-Printf >$null 2>&1 Add-Printf >$null 2>&1
Step-Log "Setup PhpManager" Step-Log "Setup PhpManager"
@ -337,8 +265,9 @@ if (Test-Path -LiteralPath $php_dir -PathType Container) {
} }
$status = "Installed" $status = "Installed"
if ($null -eq $installed -or -not("$($installed.Version).".StartsWith(($version -replace '^(\d+(\.\d+)*).*', '$1.'))) -or $ts -ne $installed.ThreadSafe) { if ($null -eq $installed -or -not("$($installed.Version).".StartsWith(($version -replace '^(\d+(\.\d+)*).*', '$1.'))) -or $ts -ne $installed.ThreadSafe) {
if ($version -lt '7.0' -and (Get-InstalledModule).Name -notcontains 'VcRedist') { if ($version -lt '7.0') {
Install-Module -Name VcRedist -Force Install-Module -Name VcRedist -Force
$arch='x86'
} }
if ($version -eq $master_version) { if ($version -eq $master_version) {
$version = 'master' $version = 'master'
@ -347,25 +276,14 @@ if ($null -eq $installed -or -not("$($installed.Version).".StartsWith(($version
} else { } else {
Install-Php -Version $version -Architecture $arch -ThreadSafe $ts -InstallVC -Path $php_dir -TimeZone UTC -InitialPhpIni Production -Force > $null 2>&1 Install-Php -Version $version -Architecture $arch -ThreadSafe $ts -InstallVC -Path $php_dir -TimeZone UTC -InitialPhpIni Production -Force > $null 2>&1
} }
} else {
if($env:update -eq 'true') {
Update-Php $php_dir >$null 2>&1
$status = "Updated to"
} else { } else {
$status = "Found" $status = "Found"
} }
}
$installed = Get-Php -Path $php_dir $installed = Get-Php -Path $php_dir
Set-PhpIniKey -Key 'date.timezone' -Value 'UTC' -Path $php_dir Set-PhpIniKey -Key 'date.timezone' -Value 'UTC' -Path $php_dir
Set-PhpIniKey -Key 'memory_limit' -Value '-1' -Path $php_dir Set-PhpIniKey -Key 'memory_limit' -Value '-1' -Path $php_dir
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
} else {
Enable-PhpExtension -Extension openssl, curl, opcache, mbstring -Path $php_dir Enable-PhpExtension -Extension openssl, curl, opcache, mbstring -Path $php_dir
} Update-PhpCAInfo -Path $php_dir -Source CurrentUser
Update-PhpCAInfo -Path $php_dir -Source $cert_source Move-Item -path $dist\..\src\configs\*.json -Destination $env:RUNNER_TOOL_CACHE
Add-Log $tick "PHP" "$status PHP $($installed.FullVersion)" Add-Log $tick "PHP" "$status PHP $($installed.FullVersion)"

View File

@ -1,5 +1,30 @@
import * as utils from './utils'; import * as utils from './utils';
/**
* Function to get command to setup tools
*
* @param os_version
* @param suffix
*/
export async function getCommand(
os_version: string,
suffix: string
): Promise<string> {
switch (os_version) {
case 'linux':
case 'darwin':
return 'add_' + suffix + ' ';
case 'win32':
return 'Add-' + suffix.charAt(0).toUpperCase() + suffix.slice(1) + ' ';
default:
return await utils.log(
'Platform ' + os_version + ' is not supported',
os_version,
'error'
);
}
}
/** /**
* Function to get tool version * Function to get tool version
* *
@ -11,8 +36,6 @@ export async function getToolVersion(version: string): Promise<string> {
const composer_regex = /^stable$|^preview$|^snapshot$|^v?[1|2]$/; const composer_regex = /^stable$|^preview$|^snapshot$|^v?[1|2]$/;
version = version.replace(/[><=^]*/, ''); version = version.replace(/[><=^]*/, '');
switch (true) { switch (true) {
case version.charAt(0) == 'v':
return version.replace('v', '');
case composer_regex.test(version): case composer_regex.test(version):
case semver_regex.test(version): case semver_regex.test(version):
return version; return version;
@ -166,12 +189,12 @@ export async function addPhive(
switch (version) { switch (version) {
case 'latest': case 'latest':
return ( return (
(await utils.getCommand(os_version, 'tool')) + (await getCommand(os_version, 'tool')) +
'https://phar.io/releases/phive.phar phive' 'https://phar.io/releases/phive.phar phive'
); );
default: default:
return ( return (
(await utils.getCommand(os_version, 'tool')) + (await getCommand(os_version, 'tool')) +
'https://github.com/phar-io/phive/releases/download/' + 'https://github.com/phar-io/phive/releases/download/' +
version + version +
'/phive-' + '/phive-' +
@ -252,27 +275,6 @@ export async function getSymfonyUri(
} }
} }
/**
* Function to get the WP-CLI url
*
* @param version
*/
export async function getWpCliUrl(version: string): Promise<string> {
switch (version) {
case 'latest':
return 'wp-cli/builds/blob/gh-pages/phar/wp-cli.phar?raw=true';
default:
return await getUri(
'wp-cli',
'-' + version + '.phar',
version,
'wp-cli/wp-cli/releases',
'v',
'download'
);
}
}
/** /**
* Function to add/move composer in the tools list * Function to add/move composer in the tools list
* *
@ -333,10 +335,7 @@ export async function getCleanedToolsList(
.map(function (extension: string) { .map(function (extension: string) {
return extension return extension
.trim() .trim()
.replace( .replace(/robmorgan\/|hirak\/|narrowspark\/automatic-/, '');
/-agent|hirak\/|laravel\/|narrowspark\/automatic-|overtrue\/|robmorgan\/|symfony\//,
''
);
}) })
.filter(Boolean); .filter(Boolean);
return [...new Set(tools_list)]; return [...new Set(tools_list)];
@ -354,7 +353,7 @@ export async function addArchive(
url: string, url: string,
os_version: string os_version: string
): Promise<string> { ): Promise<string> {
return (await utils.getCommand(os_version, 'tool')) + url + ' ' + tool; return (await getCommand(os_version, 'tool')) + url + ' ' + tool;
} }
/** /**
@ -406,7 +405,7 @@ export async function addPackage(
prefix: string, prefix: string,
os_version: string os_version: string
): Promise<string> { ): Promise<string> {
const tool_command = await utils.getCommand(os_version, 'composertool'); const tool_command = await getCommand(os_version, 'composertool');
return tool_command + tool + ' ' + release + ' ' + prefix; return tool_command + tool + ' ' + release + ' ' + prefix;
} }
@ -440,30 +439,61 @@ export async function addTools(
script += '\n'; script += '\n';
let url = ''; let url = '';
switch (tool) { switch (tool) {
case 'blackfire': case 'cs2pr':
case 'grpc_php_plugin': uri = await getUri(tool, '', version, 'releases', '', 'download');
case 'protoc': url = github + 'staabm/annotate-pull-request-from-checkstyle/' + uri;
script += await utils.customPackage(tool, 'tools', version, os_version);
break;
case 'blackfire-player':
url = await getPharUrl('https://get.blackfire.io', tool, 'v', version);
script += await addArchive(tool, url, os_version); script += await addArchive(tool, url, os_version);
break; break;
case 'php-cs-fixer':
uri = await getUri(tool, '.phar', version, 'releases', 'v', 'download');
url = github + 'FriendsOfPHP/PHP-CS-Fixer/' + uri;
script += await addArchive(tool, url, os_version);
break;
case 'phpcs':
case 'phpcbf':
url = github + 'squizlabs/PHP_CodeSniffer/' + uri;
script += await addArchive(tool, url, os_version);
break;
case 'phive':
script += await addPhive(version, os_version);
break;
case 'phpstan':
url = github + 'phpstan/phpstan/' + uri;
script += await addArchive(tool, url, os_version);
break;
case 'phpmd':
url = github + 'phpmd/phpmd/' + uri;
script += await addArchive(tool, url, os_version);
break;
case 'psalm':
url = github + 'vimeo/psalm/' + uri;
script += await addArchive(tool, url, os_version);
break;
case 'composer':
url = await getComposerUrl(version);
script += await addArchive('composer', url, os_version);
break;
case 'codeception': case 'codeception':
url = url =
'https://codeception.com/' + 'https://codeception.com/' +
(await getCodeceptionUri(version, php_version)); (await getCodeceptionUri(version, php_version));
script += await addArchive(tool, url, os_version); script += await addArchive(tool, url, os_version);
break; break;
case 'composer': case 'phpcpd':
url = await getComposerUrl(version); case 'phpunit':
script += await addArchive('composer', url, os_version); url = await getPharUrl('https://phar.phpunit.de', tool, '', version);
break;
case 'composer-normalize':
uri = await getUri(tool, '.phar', version, 'releases', '', 'download');
url = github + 'ergebnis/composer-normalize/' + uri;
script += await addArchive(tool, url, os_version); script += await addArchive(tool, url, os_version);
break; break;
case 'deployer':
url = await getDeployerUrl(version);
script += await addArchive(tool, url, os_version);
break;
case 'phinx':
script += await addPackage(tool, release, 'robmorgan/', os_version);
break;
case 'prestissimo':
script += await addPackage(tool, release, 'hirak/', os_version);
break;
case 'composer-prefetcher': case 'composer-prefetcher':
script += await addPackage( script += await addPackage(
tool, tool,
@ -472,99 +502,19 @@ export async function addTools(
os_version os_version
); );
break; break;
case 'composer-require-checker':
uri = await getUri(tool, '.phar', version, 'releases', '', 'download');
url = github + 'maglnet/ComposerRequireChecker/' + uri;
script += await addArchive(tool, url, os_version);
break;
case 'composer-unused':
uri = await getUri(tool, '.phar', version, 'releases', '', 'download');
url = github + 'composer-unused/composer-unused/' + uri;
script += await addArchive(tool, url, os_version);
break;
case 'cs2pr':
uri = await getUri(tool, '', version, 'releases', '', 'download');
url = github + 'staabm/annotate-pull-request-from-checkstyle/' + uri;
script += await addArchive(tool, url, os_version);
break;
case 'deployer':
url = await getDeployerUrl(version);
script += await addArchive(tool, url, os_version);
break;
case 'flex':
script += await addPackage(tool, release, 'symfony/', os_version);
break;
case 'infection':
url = github + 'infection/infection/' + uri;
script += await addArchive(tool, url, os_version);
break;
case 'pecl': case 'pecl':
script += await utils.getCommand(os_version, 'pecl'); script += await getCommand(os_version, 'pecl');
break;
case 'phan':
url = github + 'phan/phan/' + uri;
script += await addArchive(tool, url, os_version);
break;
case 'phing':
url = 'https://www.phing.info/get/phing-' + version + '.phar';
script += await addArchive(tool, url, os_version);
break;
case 'phinx':
script += await addPackage(tool, release, 'robmorgan/', os_version);
break;
case 'phive':
script += await addPhive(version, os_version);
break; break;
case 'php-config': case 'php-config':
case 'phpize': case 'phpize':
script += await addDevTools(tool, os_version); script += await addDevTools(tool, os_version);
break; break;
case 'php-cs-fixer':
uri = await getUri(tool, '.phar', version, 'releases', 'v', 'download');
url = github + 'FriendsOfPHP/PHP-CS-Fixer/' + uri;
script += await addArchive(tool, url, os_version);
break;
case 'phpcbf':
case 'phpcs':
url = github + 'squizlabs/PHP_CodeSniffer/' + uri;
script += await addArchive(tool, url, os_version);
break;
case 'phpcpd':
case 'phpunit':
url = await getPharUrl('https://phar.phpunit.de', tool, '', version);
script += await addArchive(tool, url, os_version);
break;
case 'phplint':
script += await addPackage(tool, release, 'overtrue/', os_version);
break;
case 'phpmd':
url = github + 'phpmd/phpmd/' + uri;
script += await addArchive(tool, url, os_version);
break;
case 'phpstan':
url = github + 'phpstan/phpstan/' + uri;
script += await addArchive(tool, url, os_version);
break;
case 'prestissimo':
script += await addPackage(tool, release, 'hirak/', os_version);
break;
case 'psalm':
url = github + 'vimeo/psalm/' + uri;
script += await addArchive(tool, url, os_version);
break;
case 'symfony': case 'symfony':
case 'symfony-cli': case 'symfony-cli':
uri = await getSymfonyUri(version, os_version); uri = await getSymfonyUri(version, os_version);
url = github + 'symfony/cli/' + uri; url = github + 'symfony/cli/' + uri;
script += await addArchive('symfony', url, os_version); script += await addArchive('symfony', url, os_version);
break; break;
case 'vapor-cli':
script += await addPackage(tool, release, 'laravel/', os_version);
break;
case 'wp-cli':
url = github + (await getWpCliUrl(version));
script += await addArchive(tool, url, os_version);
break;
default: default:
script += await utils.addLog( script += await utils.addLog(
'$cross', '$cross',

View File

@ -2,6 +2,21 @@ import * as fs from 'fs';
import * as path from 'path'; import * as path from 'path';
import * as core from '@actions/core'; import * as core from '@actions/core';
/**
* Function to read environment variable and return a string value.
*
* @param property
*/
export async function readEnv(property: string): Promise<string> {
const value = process.env[property];
switch (value) {
case undefined:
return '';
default:
return value;
}
}
/** /**
* Function to get inputs from both with and env annotations. * Function to get inputs from both with and env annotations.
* *
@ -12,13 +27,17 @@ export async function getInput(
name: string, name: string,
mandatory: boolean mandatory: boolean
): Promise<string> { ): Promise<string> {
const input = process.env[name]; const input = core.getInput(name);
switch (input) { const env_input = await readEnv(name);
case '': switch (true) {
case undefined: case input != '':
return core.getInput(name, {required: mandatory});
default:
return input; return input;
case input == '' && env_input != '':
return env_input;
case input == '' && env_input == '' && mandatory:
throw new Error(`Input required and not supplied: ${name}`);
default:
return '';
} }
} }
@ -224,17 +243,13 @@ export async function CSVArray(values_csv: string): Promise<Array<string>> {
* @param extension * @param extension
*/ */
export async function getExtensionPrefix(extension: string): Promise<string> { export async function getExtensionPrefix(extension: string): Promise<string> {
const zend: Array<string> = [ const zend: Array<string> = ['xdebug', 'opcache', 'ioncube', 'eaccelerator'];
'xdebug',
'xdebug3',
'opcache',
'ioncube',
'eaccelerator'
];
switch (zend.indexOf(extension)) { switch (zend.indexOf(extension)) {
default: case 0:
case 1:
return 'zend_extension'; return 'zend_extension';
case -1: case -1:
default:
return 'extension'; return 'extension';
} }
} }
@ -259,106 +274,3 @@ export async function suppressOutput(os_version: string): Promise<string> {
); );
} }
} }
/**
* Function to get script to log unsupported extensions.
*
* @param extension
* @param version
* @param os_version
*/
export async function getUnsupportedLog(
extension: string,
version: string,
os_version: string
): Promise<string> {
return (
'\n' +
(await addLog(
'$cross',
extension,
[extension, 'is not supported on PHP', version].join(' '),
os_version
)) +
'\n'
);
}
/**
* Function to get command to setup tools
*
* @param os_version
* @param suffix
*/
export async function getCommand(
os_version: string,
suffix: string
): Promise<string> {
switch (os_version) {
case 'linux':
case 'darwin':
return 'add_' + suffix + ' ';
case 'win32':
return 'Add-' + suffix.charAt(0).toUpperCase() + suffix.slice(1) + ' ';
default:
return await log(
'Platform ' + os_version + ' is not supported',
os_version,
'error'
);
}
}
/**
* Function to join strings with space
*
* @param str
*/
export async function joins(...str: string[]): Promise<string> {
return [...str].join(' ');
}
/**
* Function to get script extensions
*
* @param os_version
*/
export async function scriptExtension(os_version: string): Promise<string> {
switch (os_version) {
case 'win32':
return '.ps1';
case 'linux':
case 'darwin':
return '.sh';
default:
return await log(
'Platform ' + os_version + ' is not supported',
os_version,
'error'
);
}
}
/**
* Function to get script to add tools with custom support.
*
* @param pkg
* @param type
* @param version
* @param os_version
*/
export async function customPackage(
pkg: string,
type: string,
version: string,
os_version: string
): Promise<string> {
const pkg_name: string = pkg.replace(/\d+|pdo[_-]/, '');
const script_extension: string = await scriptExtension(os_version);
const script: string = path.join(
__dirname,
'../src/scripts/' + type + '/' + pkg_name + script_extension
);
const command: string = await getCommand(os_version, pkg_name);
return '\n. ' + script + '\n' + command + version;
}