mirror of
https://github.com/shivammathur/setup-php.git
synced 2025-07-20 22:03:28 +07:00
Compare commits
115 Commits
Author | SHA1 | Date | |
---|---|---|---|
36d70683e9 | |||
7a9bf9ecf6 | |||
5210dd20ed | |||
e83d1a7f9e | |||
6ae3564af4 | |||
9e33c7b24e | |||
d37cc30485 | |||
412722b7c7 | |||
c19f6bbdcd | |||
dfd2c8da97 | |||
27eef9a04c | |||
f172a4dc76 | |||
c88ece8451 | |||
33ad931dbb | |||
4e4b26a024 | |||
228bfba836 | |||
34c35ecdad | |||
1828f05f7a | |||
927419e77f | |||
e29242d481 | |||
035c0a8550 | |||
e9884d0d9a | |||
02131e37d9 | |||
341d29a88f | |||
5e3bc57de0 | |||
a826799c7c | |||
62bd8f3ca4 | |||
4056d3f353 | |||
ddf8825c2f | |||
4678e809c3 | |||
b75c104ca8 | |||
94c859a50e | |||
293da043d1 | |||
808396c4e6 | |||
7205f47330 | |||
7ad352e12a | |||
5bf95cd61f | |||
18f3abac75 | |||
7854a0cae7 | |||
a72a638da4 | |||
46c34bb6a5 | |||
948917a97b | |||
d9cb143213 | |||
0cfde7beae | |||
ce2a129c36 | |||
78532b17de | |||
8b26e8d15a | |||
4dc94c27cf | |||
76555571a6 | |||
be43989cc9 | |||
6f6e534936 | |||
99a4a141f4 | |||
c1285cc7f3 | |||
57662657e0 | |||
8d4007321f | |||
8eb9866044 | |||
e554590514 | |||
5959fab498 | |||
408b70728f | |||
9d74a11420 | |||
5acd006232 | |||
0022878947 | |||
71d07ee7f4 | |||
8d1c02194f | |||
5187531b8b | |||
44ff4ed92d | |||
96857323bb | |||
cad2a1bda3 | |||
c2c73b16c1 | |||
63c7766312 | |||
175c9649c4 | |||
495989aff1 | |||
c09e310dc1 | |||
1db2ec93f3 | |||
0a601ebeee | |||
da21b560da | |||
c1efd614e8 | |||
dcf2f7f74f | |||
8109be4850 | |||
a0a791cada | |||
147905fd60 | |||
57db6baebb | |||
c38f1acc38 | |||
9ca9ab33ef | |||
fdbb31f707 | |||
14a9f0b4ae | |||
2ee6797b63 | |||
2b729b1130 | |||
0374a8ae84 | |||
7f951c9333 | |||
449da348c0 | |||
51476af47d | |||
9a70be75c2 | |||
282305f4d7 | |||
c2a765ed5b | |||
9ea5899759 | |||
62d47dd238 | |||
e480353a3d | |||
3a4acaaed8 | |||
f7f679181d | |||
f3010adf3e | |||
b7cdb2373c | |||
22ebe0d733 | |||
cb614c45fa | |||
e6e79e1717 | |||
45a631dbaf | |||
1fd26e45c8 | |||
de4fdb85b9 | |||
2fd8046c9d | |||
d189609ea9 | |||
3681a25ab6 | |||
092944b039 | |||
9e30788903 | |||
bca2d0b1b0 | |||
d78b8a6d49 |
78
.github/CONTRIBUTING.md
vendored
78
.github/CONTRIBUTING.md
vendored
@ -1,37 +1,26 @@
|
|||||||
# Contributing to setup-php
|
# Contributing to setup-php
|
||||||
|
|
||||||
|
## Welcome!
|
||||||
|
|
||||||
|
We look forward to your contributions! Here are some examples how you can contribute:
|
||||||
|
|
||||||
|
* [Ask any questions you may have](https://github.com/shivammathur/setup-php/discussions/new?category=Q-A-Help)
|
||||||
|
* [Report a bug](https://github.com/shivammathur/setup-php/issues/new?labels=type/bug&template=bug.md)
|
||||||
|
* [Propose a new feature](https://github.com/shivammathur/setup-php/issues/new?labels=enhancement&template=feature.md)
|
||||||
|
* [Send a pull request](https://github.com/shivammathur/setup-php/pulls)
|
||||||
|
|
||||||
## Contributor Code of Conduct
|
## Contributor Code of Conduct
|
||||||
|
|
||||||
Please note that this project is released with a [Contributor Code of Conduct](CODE_OF_CONDUCT.md). By participating in this project you agree to abide by its terms.
|
Please note that this project is released with a [Contributor Code of Conduct](CODE_OF_CONDUCT.md). By participating in this project you agree to abide by its terms.
|
||||||
|
|
||||||
## Workflow
|
## Getting Started
|
||||||
|
|
||||||
* Fork the project.
|
To get started fork `setup-php` and clone it using git:
|
||||||
* Make your bug fix or feature addition.
|
|
||||||
* Add tests for it, 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 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.
|
|
||||||
|
|
||||||
Due to time constraints, you may not always get a quick response. Please do not take delays personally and feel free to remind.
|
|
||||||
|
|
||||||
## Coding Guidelines
|
|
||||||
|
|
||||||
## Using setup-php from a Git checkout
|
|
||||||
|
|
||||||
The following commands can be used to perform the initial checkout of setup-php:
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
$ git clone https://github.com/shivammathur/setup-php.git
|
git clone https://github.com/<your-username>/setup-php.git
|
||||||
|
|
||||||
$ cd setup-php
|
cd setup-php
|
||||||
```
|
|
||||||
|
|
||||||
Install setup-php dependencies using [npm](https://www.npmjs.com/):
|
|
||||||
|
|
||||||
```bash
|
|
||||||
$ npm install
|
|
||||||
```
|
```
|
||||||
|
|
||||||
If you are using `Windows` configure `git` to handle line endings.
|
If you are using `Windows` configure `git` to handle line endings.
|
||||||
@ -40,31 +29,54 @@ If you are using `Windows` configure `git` to handle line endings.
|
|||||||
git config --local core.autocrlf true
|
git config --local core.autocrlf true
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Install `setup-php` dependencies using [npm](https://www.npmjs.com/):
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm install
|
||||||
|
```
|
||||||
|
|
||||||
|
## Workflow to create Pull Requests
|
||||||
|
|
||||||
|
* Fork the `setup-php` project and clone it.
|
||||||
|
* Create a new branch from the develop branch.
|
||||||
|
* Make your bug fix or feature addition.
|
||||||
|
* Add tests for it, so we don't break it in a future version unintentionally.
|
||||||
|
* Ensure the test suite passes and the code complies with our coding guidelines (see below).
|
||||||
|
* Send a pull request to the develop branch with all the details.
|
||||||
|
* If possible, create a GitHub Actions workflow with an integration test for the change in a demo repository and link it in your pull request.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
## Coding Guidelines
|
||||||
|
|
||||||
This project comes with `.prettierrc.json` and `eslintrc.json` configuration files. Please run the following commands to fix and verify the code quality.
|
This project comes with `.prettierrc.json` and `eslintrc.json` configuration files. Please run the following commands to fix and verify the code quality.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
$ npm run format
|
npm run format
|
||||||
$ npm run lint
|
npm run lint
|
||||||
```
|
```
|
||||||
|
|
||||||
## Running the test suite
|
### Running the test suite
|
||||||
|
|
||||||
After following the steps shown above, The `setup-php` tests in the `__tests__` directory can be run using this command:
|
After following the steps shown above, The `setup-php` tests in the `__tests__` directory can be run using this command:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
$ npm test
|
npm test
|
||||||
```
|
```
|
||||||
|
|
||||||
## Creating a release
|
### Creating a release
|
||||||
|
|
||||||
Create a release before you push your changes.
|
Creating a release means compiling all the TypeScript code to a single file which `setup-php` can run. Run this, before you push your changes.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
$ npm run release
|
npm run release
|
||||||
```
|
```
|
||||||
|
|
||||||
## Reporting issues
|
### Reporting issues and discussions
|
||||||
|
|
||||||
Please submit the issue using the appropriate template provided for a bug report or a feature request:
|
For questions or support, we prefer GitHub Discussions. For any bugs or new features you can create an issue using the appropriate template:
|
||||||
|
|
||||||
|
* [Discussions](https://github.com/shivammathur/setup-php/discussions)
|
||||||
* [Issues](https://github.com/shivammathur/setup-php/issues)
|
* [Issues](https://github.com/shivammathur/setup-php/issues)
|
||||||
|
11
.github/SECURITY.md
vendored
11
.github/SECURITY.md
vendored
@ -2,23 +2,18 @@
|
|||||||
|
|
||||||
## Supported Versions
|
## Supported Versions
|
||||||
|
|
||||||
The following versions of this project are supported for security updates.
|
The latest patch versions of `v1` and `v2` releases of this project are supported for security updates.
|
||||||
|
|
||||||
| Version | Supported |
|
|
||||||
| ------- | ------------------ |
|
|
||||||
| 1.11.x | :white_check_mark: |
|
|
||||||
| 2.14.x | :white_check_mark: |
|
|
||||||
|
|
||||||
## Supported PHP Versions
|
## Supported PHP Versions
|
||||||
|
|
||||||
This security policy only applies to the latest patches of the following PHP versions.
|
This security policy only applies to the latest patches of the following PHP versions.
|
||||||
|
|
||||||
| Version | Supported |
|
| Version | Supported |
|
||||||
| ------- | ------------------ |
|
|---------|--------------------|
|
||||||
| 7.3 | :white_check_mark: |
|
|
||||||
| 7.4 | :white_check_mark: |
|
| 7.4 | :white_check_mark: |
|
||||||
| 8.0 | :white_check_mark: |
|
| 8.0 | :white_check_mark: |
|
||||||
| 8.1 | :white_check_mark: |
|
| 8.1 | :white_check_mark: |
|
||||||
|
| 8.2 | :white_check_mark: |
|
||||||
|
|
||||||
## Reporting a Vulnerability
|
## Reporting a Vulnerability
|
||||||
|
|
||||||
|
4
.github/codeql/codeql-configuration.yml
vendored
Normal file
4
.github/codeql/codeql-configuration.yml
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
name : CodeQL Configuration
|
||||||
|
|
||||||
|
paths:
|
||||||
|
- './src'
|
25
.github/workflows/codeql.yml
vendored
Normal file
25
.github/workflows/codeql.yml
vendored
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
name: CodeQL Workflow
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
schedule:
|
||||||
|
- cron: '0 15 * * 6'
|
||||||
|
jobs:
|
||||||
|
codeql:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
fetch-depth: 2
|
||||||
|
|
||||||
|
- name: Initialize CodeQL
|
||||||
|
uses: github/codeql-action/init@v1
|
||||||
|
with:
|
||||||
|
config-file: ./.github/codeql/codeql-configuration.yml
|
||||||
|
languages: javascript
|
||||||
|
|
||||||
|
- name: Autobuild
|
||||||
|
uses: github/codeql-action/autobuild@v1
|
||||||
|
|
||||||
|
- name: Perform CodeQL Analysis
|
||||||
|
uses: github/codeql-action/analyze@v1
|
34
.github/workflows/docs.yml
vendored
34
.github/workflows/docs.yml
vendored
@ -10,18 +10,18 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
operating-system: [ubuntu-20.04, ubuntu-18.04, windows-2019, macos-10.15]
|
operating-system: [ubuntu-20.04, ubuntu-18.04, windows-2022, macos-11]
|
||||||
php-versions: ['5.3', '5.4', '5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2']
|
php-versions: ['5.3', '5.4', '5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2']
|
||||||
steps:
|
steps:
|
||||||
- name: Setup PHP
|
- name: Setup PHP
|
||||||
uses: shivammathur/setup-php@v2
|
uses: shivammathur/setup-php@v2
|
||||||
with:
|
with:
|
||||||
php-version: ${{ matrix.php-versions }}
|
php-version: ${{ matrix.php-versions }}
|
||||||
- name: Save unix
|
- name: Create for Linux and macOS
|
||||||
env:
|
env:
|
||||||
file: php${{ matrix.php-versions }}-${{ matrix.operating-system }}.md
|
file: php${{ matrix.php-versions }}-${{ matrix.operating-system }}.md
|
||||||
version: ${{ matrix.php-versions }}
|
version: ${{ matrix.php-versions }}
|
||||||
if: matrix.operating-system != 'windows-2019'
|
if: matrix.operating-system != 'windows-2022'
|
||||||
run: |
|
run: |
|
||||||
echo "## PHP $version" >> "$file"
|
echo "## PHP $version" >> "$file"
|
||||||
printf "\n" >> "$file"
|
printf "\n" >> "$file"
|
||||||
@ -29,17 +29,18 @@ jobs:
|
|||||||
php -m >> "$file"
|
php -m >> "$file"
|
||||||
echo "\`\`\`" >> "$file"
|
echo "\`\`\`" >> "$file"
|
||||||
printf "\n" >> "$file"
|
printf "\n" >> "$file"
|
||||||
- name: Save Windows
|
- name: Create for Windows
|
||||||
env:
|
env:
|
||||||
file: php${{ matrix.php-versions }}-${{ matrix.operating-system }}.md
|
file: php${{ matrix.php-versions }}-${{ matrix.operating-system }}.md
|
||||||
version: ${{ matrix.php-versions }}
|
version: ${{ matrix.php-versions }}
|
||||||
if: matrix.operating-system == 'windows-2019'
|
if: matrix.operating-system == 'windows-2022'
|
||||||
run: |
|
run: |
|
||||||
Write-Output "## PHP ${{ matrix.php-versions }}`n" | Out-File -FilePath "$env:file"
|
Write-Output "## PHP ${{ matrix.php-versions }}`n" | Out-File -FilePath "$env:file"
|
||||||
Write-Output "``````" | Out-File -FilePath "$env:file" -Append
|
Write-Output "``````" | Out-File -FilePath "$env:file" -Append
|
||||||
php -m | Out-File -FilePath "$env:file" -Append
|
php -m | Out-File -FilePath "$env:file" -Append
|
||||||
Write-Output "```````n" | Out-File -FilePath "$env:file" -Append
|
Write-Output "```````n" | Out-File -FilePath "$env:file" -Append
|
||||||
- uses: actions/upload-artifact@v2
|
- name: Upload artifacts
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: lists
|
name: lists
|
||||||
path: php${{ matrix.php-versions }}-${{ matrix.operating-system }}.md
|
path: php${{ matrix.php-versions }}-${{ matrix.operating-system }}.md
|
||||||
@ -49,27 +50,34 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
repository: ${{ github.repository }}.wiki
|
repository: ${{ github.repository }}.wiki
|
||||||
- uses: actions/download-artifact@v2
|
- name: Download artifacts
|
||||||
|
uses: actions/download-artifact@v3
|
||||||
with:
|
with:
|
||||||
path: ${{ github.workspace }}
|
path: ${{ github.workspace }}
|
||||||
- name: Combine
|
- name: Configure Git
|
||||||
run: |
|
run : |
|
||||||
git config --local user.email "${{ secrets.email }}"
|
git config --local user.email "${{ secrets.email }}"
|
||||||
git config --local user.name "${{ github.repository_owner }}"
|
git config --local user.name "${{ github.repository_owner }}"
|
||||||
for os in ubuntu-20.04 ubuntu-18.04 windows-2019 macos-10.15 macos-11; do
|
- name: Combine
|
||||||
|
run: |
|
||||||
|
for os in ubuntu-20.04 ubuntu-18.04 windows-2022 windows-2019 macos-11 macos-10.15; do
|
||||||
echo "These are extensions which are loaded by default on the following PHP versions. More extensions which are available as packages and available on pecl are supported by setup-php. Refer to [php extension support](https://github.com/shivammathur/setup-php#heavy_plus_sign-php-extension-support) for more details." > Php-extensions-loaded-on-"$os".md
|
echo "These are extensions which are loaded by default on the following PHP versions. More extensions which are available as packages and available on pecl are supported by setup-php. Refer to [php extension support](https://github.com/shivammathur/setup-php#heavy_plus_sign-php-extension-support) for more details." > Php-extensions-loaded-on-"$os".md
|
||||||
for version in 5.3 5.4 5.5 5.6 7.0 7.1 7.2 7.3 7.4 8.0 8.1 8.2; do
|
for version in 5.3 5.4 5.5 5.6 7.0 7.1 7.2 7.3 7.4 8.0 8.1 8.2; do
|
||||||
if [ "$os" = "macos-11" ]; then
|
if [ "$os" = "macos-10.15" ]; then
|
||||||
cat lists/php"$version"-macos-10.15.md >> Php-extensions-loaded-on-"$os".md
|
cat lists/php"$version"-macos-11.md >> Php-extensions-loaded-on-"$os".md
|
||||||
|
elif [ "$os" = "windows-2019" ]; then
|
||||||
|
cat lists/php"$version"-windows-2022.md >> Php-extensions-loaded-on-"$os".md
|
||||||
else
|
else
|
||||||
cat lists/php"$version"-"$os".md >> Php-extensions-loaded-on-"$os".md
|
cat lists/php"$version"-"$os".md >> Php-extensions-loaded-on-"$os".md
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
rm -rf ./lists
|
rm -rf ./lists
|
||||||
|
- name: Update
|
||||||
|
run: |
|
||||||
if [ "$(git status --porcelain=v1 2>/dev/null | wc -l)" != "0" ]; then
|
if [ "$(git status --porcelain=v1 2>/dev/null | wc -l)" != "0" ]; then
|
||||||
git add .
|
git add .
|
||||||
git commit -m "Update PHP extensions on wiki - $(date +'%d-%m-%y')"
|
git commit -m "Update PHP extensions on wiki - $(date +'%d-%m-%y')"
|
||||||
|
@ -25,20 +25,10 @@ jobs:
|
|||||||
matrix:
|
matrix:
|
||||||
operating-system: [ubuntu-latest, windows-latest, macos-latest]
|
operating-system: [ubuntu-latest, windows-latest, macos-latest]
|
||||||
steps:
|
steps:
|
||||||
- name: Harden Runner
|
|
||||||
uses: step-security/harden-runner@v1
|
|
||||||
with:
|
|
||||||
allowed-endpoints:
|
|
||||||
codecov.io.:443
|
|
||||||
github.com.:443
|
|
||||||
nodejs.org.:443
|
|
||||||
raw.githubusercontent.com.:443
|
|
||||||
registry.npmjs.org.:443
|
|
||||||
setup-php.com.:443
|
|
||||||
storage.googleapis.com.:443
|
|
||||||
|
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
fetch-depth: 2
|
||||||
|
|
||||||
- name: Setup Node.js 16.x
|
- name: Setup Node.js 16.x
|
||||||
uses: actions/setup-node@v1
|
uses: actions/setup-node@v1
|
||||||
@ -57,7 +47,14 @@ jobs:
|
|||||||
- name: Run tests
|
- name: Run tests
|
||||||
run: npm test
|
run: npm test
|
||||||
|
|
||||||
|
- name: Run npm audit
|
||||||
|
run: npm audit
|
||||||
|
|
||||||
- name: Send Coverage
|
- name: Send Coverage
|
||||||
continue-on-error: true
|
uses: codecov/codecov-action@v2
|
||||||
timeout-minutes: 1
|
with:
|
||||||
run: curl -s https://codecov.io/bash | bash -s -- -t ${{secrets.CODECOV_TOKEN}} -f coverage/lcov.info -n github-actions-codecov-${{ matrix.operating-system }}
|
token: ${{ secrets.CODECOV_TOKEN }}
|
||||||
|
files: coverage/lcov.info
|
||||||
|
name: github-actions-codecov-${{ matrix.operating-system }}
|
||||||
|
fail_ci_if_error: false
|
||||||
|
verbose: true
|
@ -24,14 +24,14 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
operating-system: [ubuntu-20.04, ubuntu-18.04, windows-latest, macos-latest]
|
operating-system: [ubuntu-20.04, ubuntu-18.04, windows-2019, macos-latest]
|
||||||
php-versions: ['5.3', '5.4', '5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2']
|
php-versions: ['5.3', '5.4', '5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2']
|
||||||
env:
|
env:
|
||||||
extensions: xml, opcache, xdebug, pcov
|
extensions: xml, opcache, xdebug, pcov
|
||||||
key: cache-v5
|
key: cache-v5
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Setup cache environment
|
- name: Setup cache environment
|
||||||
id: cache-env
|
id: cache-env
|
||||||
@ -42,7 +42,7 @@ jobs:
|
|||||||
key: ${{ env.key }}
|
key: ${{ env.key }}
|
||||||
|
|
||||||
- name: Cache extensions
|
- name: Cache extensions
|
||||||
uses: actions/cache@v2
|
uses: actions/cache@v3
|
||||||
with:
|
with:
|
||||||
path: ${{ steps.cache-env.outputs.dir }}
|
path: ${{ steps.cache-env.outputs.dir }}
|
||||||
key: ${{ steps.cache-env.outputs.key }}
|
key: ${{ steps.cache-env.outputs.key }}
|
@ -17,20 +17,12 @@ jobs:
|
|||||||
contents: read
|
contents: read
|
||||||
packages: write
|
packages: write
|
||||||
steps:
|
steps:
|
||||||
- name: Harden Runner
|
|
||||||
uses: step-security/harden-runner@v1
|
|
||||||
with:
|
|
||||||
allowed-endpoints:
|
|
||||||
github.com:443
|
|
||||||
npm.pkg.github.com:443
|
|
||||||
registry.npmjs.org:443
|
|
||||||
|
|
||||||
- name: Checkout release
|
- name: Checkout release
|
||||||
if: github.event_name != 'workflow_dispatch'
|
if: github.event_name != 'workflow_dispatch'
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Checkout tag
|
- name: Checkout tag
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
if: github.event_name == 'workflow_dispatch'
|
if: github.event_name == 'workflow_dispatch'
|
||||||
with:
|
with:
|
||||||
ref: ${{ github.event.inputs.tag }}
|
ref: ${{ github.event.inputs.tag }}
|
269
README.md
269
README.md
@ -11,22 +11,24 @@
|
|||||||
<a href="https://codecov.io/gh/shivammathur/setup-php" title="Code coverage"><img alt="Codecov Code Coverage" src="https://img.shields.io/codecov/c/github/shivammathur/setup-php?logo=codecov"></a>
|
<a href="https://codecov.io/gh/shivammathur/setup-php" title="Code coverage"><img alt="Codecov Code Coverage" src="https://img.shields.io/codecov/c/github/shivammathur/setup-php?logo=codecov"></a>
|
||||||
<a href="https://github.com/shivammathur/setup-php/blob/master/LICENSE" title="license"><img alt="LICENSE" src="https://img.shields.io/badge/license-MIT-428f7e.svg?logo=open%20source%20initiative&logoColor=white&labelColor=555555"></a>
|
<a href="https://github.com/shivammathur/setup-php/blob/master/LICENSE" title="license"><img alt="LICENSE" src="https://img.shields.io/badge/license-MIT-428f7e.svg?logo=open%20source%20initiative&logoColor=white&labelColor=555555"></a>
|
||||||
<a href="#tada-php-support" title="PHP Versions Supported"><img alt="PHP Versions Supported" src="https://img.shields.io/badge/php-5.3%20to%208.2-777bb3.svg?logo=php&logoColor=white&labelColor=555555"></a>
|
<a href="#tada-php-support" title="PHP Versions Supported"><img alt="PHP Versions Supported" src="https://img.shields.io/badge/php-5.3%20to%208.2-777bb3.svg?logo=php&logoColor=white&labelColor=555555"></a>
|
||||||
<a href="https://beta.stepsecurity.io/npm/setup-php"><img alt="release verified" src="https://img.shields.io/endpoint?url=https://beta.api.stepsecurity.io/v1/npm/setup-php/badge?q=1"></a>
|
|
||||||
</p>
|
</p>
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<a href="https://reddit.com/r/setup_php" title="setup-php reddit"><img alt="setup-php reddit" src="https://img.shields.io/badge/reddit-join-FF5700?logo=reddit&logoColor=FF5700&labelColor=555555"></a>
|
<a href="https://reddit.com/r/setup_php" title="setup-php reddit"><img alt="setup-php reddit" src="https://img.shields.io/badge/reddit-join-FF5700?logo=reddit&logoColor=FF5700&labelColor=555555"></a>
|
||||||
<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://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://status.setup-php.com" 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>
|
<a href="https://status.setup-php.com" 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>
|
||||||
|
<p align="center">
|
||||||
|
<a href="https://setup-php.com/support-ukraine" title="#StandWithUkraine"><img alt="#StandWithUkraine" src="https://raw.githubusercontent.com/vshymanskyy/StandWithUkraine/main/badges/StandWithUkraine.svg"></a>
|
||||||
|
</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 set up 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 set up the PHP environment you need to test your application. Refer to [Usage](#memo-usage "How to use this") section and [examples](#examples "Examples of use") to see how to use this.
|
||||||
|
|
||||||
## Contents
|
## Contents
|
||||||
|
|
||||||
- [OS/Platform Support](#cloud-osplatform-support)
|
- [OS/Platform Support](#cloud-osplatform-support)
|
||||||
- [GitHub-Hosted Runners](#github-hosted-runners)
|
- [GitHub-Hosted Runners](#github-hosted-runners)
|
||||||
- [Self-Hosted Runners](#self-hosted-runners)
|
- [Self-Hosted Runners](#self-hosted-runners)
|
||||||
- [PHP Support](#tada-php-support)
|
- [PHP Support](#tada-php-support)
|
||||||
- [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)
|
||||||
@ -38,11 +40,11 @@ Setup PHP with required extensions, php.ini configuration, code-coverage support
|
|||||||
- [Outputs](#outputs)
|
- [Outputs](#outputs)
|
||||||
- [Flags](#flags)
|
- [Flags](#flags)
|
||||||
- [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)
|
||||||
- [Thread Safe Setup](#thread-safe-setup)
|
- [Thread Safe Setup](#thread-safe-setup)
|
||||||
- [Force Update Setup](#force-update-setup)
|
- [Force Update Setup](#force-update-setup)
|
||||||
- [Verbose Setup](#verbose-setup)
|
- [Verbose Setup](#verbose-setup)
|
||||||
- [Multi-Arch Setup](#multi-arch-setup)
|
- [Multi-Arch Setup](#multi-arch-setup)
|
||||||
- [Self Hosted Setup](#self-hosted-setup)
|
- [Self Hosted Setup](#self-hosted-setup)
|
||||||
- [Local Testing Setup](#local-testing-setup)
|
- [Local Testing Setup](#local-testing-setup)
|
||||||
@ -62,36 +64,38 @@ Setup PHP with required extensions, php.ini configuration, code-coverage support
|
|||||||
|
|
||||||
## :cloud: OS/Platform Support
|
## :cloud: OS/Platform Support
|
||||||
|
|
||||||
Both `GitHub-hosted` and `self-hosted` runners are suppported by `setup-php` on the following OS/Platforms.
|
Both `GitHub-hosted` and `self-hosted` runners are supported by `setup-php` on the following OS/Platforms.
|
||||||
|
|
||||||
### GitHub-Hosted Runners
|
### GitHub-Hosted Runners
|
||||||
|
|
||||||
|Virtual environment|YAML workflow label|Pre-installed PHP|
|
| Virtual environment | YAML workflow label | Pre-installed PHP |
|
||||||
|--- |--- |--- |
|
|----------------------|------------------------------------|------------------------|
|
||||||
|Ubuntu 18.04|`ubuntu-18.04`|`PHP 7.1` to `PHP 8.0`|
|
| Ubuntu 20.04 | `ubuntu-latest` or `ubuntu-20.04` | `PHP 7.4` to `PHP 8.1` |
|
||||||
|Ubuntu 20.04|`ubuntu-latest` or `ubuntu-20.04`|`PHP 7.4` to `PHP 8.0`|
|
| Ubuntu 18.04 | `ubuntu-18.04` | `PHP 7.2` to `PHP 8.1` |
|
||||||
|Windows Server 2019|`windows-latest` or `windows-2019`|`PHP 8.0`|
|
| Windows Server 2022 | `windows-latest` or `windows-2022` | `PHP 8.1` |
|
||||||
|Windows Server 2022|`windows-2022`|`PHP 8.0`|
|
| Windows Server 2019 | `windows-2019` | `PHP 8.1` |
|
||||||
|macOS Catalina 10.15|`macos-latest` or `macos-10.15`|`PHP 8.0`|
|
| macOS Monterey 12.x | `macos-12` | `PHP 8.1` |
|
||||||
|macOS Big Sur 11.x|`macos-11`|`PHP 8.0`|
|
| macOS Big Sur 11.x | `macos-latest` or `macos-11` | `PHP 8.1` |
|
||||||
|
| macOS Catalina 10.15 | `macos-10.15` | `PHP 8.1` |
|
||||||
|
|
||||||
### Self-Hosted Runners
|
### Self-Hosted Runners
|
||||||
|
|
||||||
|Host OS/Virtual environment|YAML workflow label|
|
| Host OS/Virtual environment | YAML workflow label |
|
||||||
|--- |--- |
|
|----------------------------------|----------------------------|
|
||||||
|Ubuntu 18.04|`self-hosted` or `Linux`|
|
| Ubuntu 21.04 | `self-hosted` or `Linux` |
|
||||||
|Ubuntu 20.04|`self-hosted` or `Linux`|
|
| Ubuntu 20.04 | `self-hosted` or `Linux` |
|
||||||
|Ubuntu 21.04|`self-hosted` or `Linux`|
|
| Ubuntu 18.04 | `self-hosted` or `Linux` |
|
||||||
|Debian 9|`self-hosted` or `Linux`|
|
| Debian 11 | `self-hosted` or `Linux` |
|
||||||
|Debian 10|`self-hosted` or `Linux`|
|
| Debian 10 | `self-hosted` or `Linux` |
|
||||||
|Debian 11|`self-hosted` or `Linux`|
|
| Debian 9 | `self-hosted` or `Linux` |
|
||||||
|Windows 7 and newer|`self-hosted` or `Windows`|
|
| Windows 7 and newer | `self-hosted` or `Windows` |
|
||||||
|Windows Server 2012 R2 and newer|`self-hosted` or `Windows`|
|
| Windows Server 2012 R2 and newer | `self-hosted` or `Windows` |
|
||||||
|macOS Catalina 10.15|`self-hosted` or `macOS`|
|
| macOS Monterey 12.x x86_64/arm64 | `self-hosted` or `macOS` |
|
||||||
|macOS Big Sur 11.x x86_64/arm64|`self-hosted` or `macOS`|
|
| macOS Big Sur 11.x x86_64/arm64 | `self-hosted` or `macOS` |
|
||||||
|
| 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.
|
- Refer to the [self-hosted setup](#self-hosted-setup) to use the action on self-hosted runners.
|
||||||
- Operating systems based on the above Ubuntu and Debian versions are also supported on a best effort basis.
|
- Operating systems based on the above Ubuntu and Debian versions are also supported on best effort basis.
|
||||||
- If the requested PHP version is pre-installed, `setup-php` switches to it, otherwise it installs the PHP version.
|
- If the requested PHP version is pre-installed, `setup-php` switches to it, otherwise it installs the PHP version.
|
||||||
|
|
||||||
## :tada: PHP Support
|
## :tada: PHP Support
|
||||||
@ -101,22 +105,22 @@ On all supported OS/Platforms the following PHP versions are supported as per th
|
|||||||
- PHP 5.3 to PHP 8.2 on GitHub-hosted runners.
|
- PHP 5.3 to PHP 8.2 on GitHub-hosted runners.
|
||||||
- PHP 5.6 to PHP 8.2 on self-hosted runners.
|
- PHP 5.6 to PHP 8.2 on self-hosted runners.
|
||||||
|
|
||||||
|PHP Version|Stability|Release Support|Runner Support|
|
| PHP Version | Stability | Release Support | Runner Support |
|
||||||
|--- |--- |--- |--- |
|
|-------------|-----------|-----------------------|--------------------------------|
|
||||||
|`5.3`|`Stable`|`End of life`|`GitHub-hosted`|
|
| `5.3` | `Stable` | `End of life` | `GitHub-hosted` |
|
||||||
|`5.4`|`Stable`|`End of life`|`GitHub-hosted`|
|
| `5.4` | `Stable` | `End of life` | `GitHub-hosted` |
|
||||||
|`5.5`|`Stable`|`End of life`|`GitHub-hosted`|
|
| `5.5` | `Stable` | `End of life` | `GitHub-hosted` |
|
||||||
|`5.6`|`Stable`|`End of life`|`GitHub-hosted`, `self-hosted`|
|
| `5.6` | `Stable` | `End of life` | `GitHub-hosted`, `self-hosted` |
|
||||||
|`7.0`|`Stable`|`End of life`|`GitHub-hosted`, `self-hosted`|
|
| `7.0` | `Stable` | `End of life` | `GitHub-hosted`, `self-hosted` |
|
||||||
|`7.1`|`Stable`|`End of life`|`GitHub-hosted`, `self-hosted`|
|
| `7.1` | `Stable` | `End of life` | `GitHub-hosted`, `self-hosted` |
|
||||||
|`7.2`|`Stable`|`End of life`|`GitHub-hosted`, `self-hosted`|
|
| `7.2` | `Stable` | `End of life` | `GitHub-hosted`, `self-hosted` |
|
||||||
|`7.3`|`Stable`|`End of life`|`GitHub-hosted`, `self-hosted`|
|
| `7.3` | `Stable` | `End of life` | `GitHub-hosted`, `self-hosted` |
|
||||||
|`7.4`|`Stable`|`Security fixes only`|`GitHub-hosted`, `self-hosted`|
|
| `7.4` | `Stable` | `Security fixes only` | `GitHub-hosted`, `self-hosted` |
|
||||||
|`8.0`|`Stable`|`Active`|`GitHub-hosted`, `self-hosted`|
|
| `8.0` | `Stable` | `Active` | `GitHub-hosted`, `self-hosted` |
|
||||||
|`8.1`|`Stable`|`Active`|`GitHub-hosted`, `self-hosted`|
|
| `8.1` | `Stable` | `Active` | `GitHub-hosted`, `self-hosted` |
|
||||||
|`8.2`|`Nightly`|`In development`|`GitHub-hosted`, `self-hosted`|
|
| `8.2` | `Nightly` | `In development` | `GitHub-hosted`, `self-hosted` |
|
||||||
|
|
||||||
**Notes:**
|
**Notes:**
|
||||||
- Specifying `8.2` in `php-version` input installs a nightly build of `PHP 8.2.0-dev`. See [nightly build setup](#nightly-build-setup) for more information.
|
- Specifying `8.2` in `php-version` input installs a nightly build of `PHP 8.2.0-dev`. See [nightly build setup](#nightly-build-setup) for more information.
|
||||||
- To use JIT on `PHP 8.0` and above, refer to the [JIT configuration](#jit-configuration) section.
|
- To use JIT on `PHP 8.0` and above, refer to the [JIT configuration](#jit-configuration) section.
|
||||||
|
|
||||||
@ -130,7 +134,7 @@ PHP extensions can be set up using the `extensions` input. It accepts a `string`
|
|||||||
- name: Setup PHP with PECL extension
|
- name: Setup PHP with PECL extension
|
||||||
uses: shivammathur/setup-php@v2
|
uses: shivammathur/setup-php@v2
|
||||||
with:
|
with:
|
||||||
php-version: '8.0'
|
php-version: '8.1'
|
||||||
extensions: imagick, swoole
|
extensions: imagick, swoole
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -152,35 +156,37 @@ PHP extensions can be set up using the `extensions` input. It accepts a `string`
|
|||||||
extensions: swoole-1.9.3
|
extensions: swoole-1.9.3
|
||||||
```
|
```
|
||||||
|
|
||||||
- Pre-release versions extensions available on `PECL` can be set up by suffixing the extension's name with its state i.e `alpha`, `beta`, `devel` or `snapshot`.
|
- Extensions with pre-release versions available on `PECL` can be set up by suffixing the extension's name with its state i.e `alpha`, `beta`, `devel` or `snapshot`.
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- name: Setup PHP with pre-release PECL extension
|
- name: Setup PHP with pre-release PECL extension
|
||||||
uses: shivammathur/setup-php@v2
|
uses: shivammathur/setup-php@v2
|
||||||
with:
|
with:
|
||||||
php-version: '8.0'
|
php-version: '8.1'
|
||||||
extensions: xdebug-beta
|
extensions: xdebug-beta
|
||||||
```
|
```
|
||||||
|
|
||||||
|
- On `Ubuntu` and `macOS` to compile and install an extension from PECL with libraries or custom configuration follow this [guide](https://github.com/shivammathur/setup-php/wiki/Add-extension-from-PECL-with-libraries-and-custom-configuration "Guide to compile and install PHP extensions using PECL with libraries and custom configuration in setup-php").
|
||||||
|
|
||||||
- Shared extensions can be disabled by prefixing them with a `:`. All extensions depending on the specified extension will also be disabled.
|
- Shared extensions can be disabled by prefixing them with a `:`. All extensions depending on the specified extension will also be disabled.
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- name: Setup PHP and disable opcache
|
- name: Setup PHP and disable opcache
|
||||||
uses: shivammathur/setup-php@v2
|
uses: shivammathur/setup-php@v2
|
||||||
with:
|
with:
|
||||||
php-version: '8.0'
|
php-version: '8.1'
|
||||||
extensions: :opcache
|
extensions: :opcache
|
||||||
```
|
```
|
||||||
|
|
||||||
- All shared extensions can be disabled by specifying `none`. When `none` is specified along with other extensions, it is hoisted to the start of the input. So, all the shared extensions will be disabled first, then rest of the extensions in the input will be processed.
|
- All shared extensions can be disabled by specifying `none`. When `none` is specified along with other extensions, it is hoisted to the start of the input. So, all the shared extensions will be disabled first, then rest of the extensions in the input will be processed.
|
||||||
|
|
||||||
**Note:** This disables all core and third-party shared extensions and thus, can break some tools which need them. So, make sure you add the required extensions after `none` in the `extensions` input.
|
**Note:** This disables all core and third-party shared extensions and thus, can break some tools which need them. Required extensions are enabled again when the tools are set up on a best-effort basis. So it is recommended to add the extensions required for your tools after `none` in the `extensions` input to avoid any issues.
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- name: Setup PHP without any shared extensions except mbstring
|
- name: Setup PHP without any shared extensions except mbstring
|
||||||
uses: shivammathur/setup-php@v2
|
uses: shivammathur/setup-php@v2
|
||||||
with:
|
with:
|
||||||
php-version: '8.0'
|
php-version: '8.1'
|
||||||
extensions: none, mbstring
|
extensions: none, mbstring
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -190,8 +196,8 @@ PHP extensions can be set up using the `extensions` input. It accepts a `string`
|
|||||||
- name: Setup PHP with intl
|
- name: Setup PHP with intl
|
||||||
uses: shivammathur/setup-php@v2
|
uses: shivammathur/setup-php@v2
|
||||||
with:
|
with:
|
||||||
php-version: '8.0'
|
php-version: '8.1'
|
||||||
extensions: intl-69.1
|
extensions: intl-70.1
|
||||||
```
|
```
|
||||||
|
|
||||||
- Extensions loaded by default after `setup-php` runs can be found on the [wiki](https://github.com/shivammathur/setup-php/wiki).
|
- Extensions loaded by default after `setup-php` runs can be found on the [wiki](https://github.com/shivammathur/setup-php/wiki).
|
||||||
@ -201,13 +207,13 @@ PHP extensions can be set up using the `extensions` input. It accepts a `string`
|
|||||||
- `geos` on `Ubuntu` and `macOS`.
|
- `geos` on `Ubuntu` and `macOS`.
|
||||||
- `blackfire`, `couchbase`, `ioncube`, `oci8`, `pdo_firebird`, `pdo_oci`, `pecl_http`, `phalcon3` and `phalcon4` on all supported OS.
|
- `blackfire`, `couchbase`, `ioncube`, `oci8`, `pdo_firebird`, `pdo_oci`, `pecl_http`, `phalcon3` and `phalcon4` on all supported OS.
|
||||||
|
|
||||||
- By default, extensions which cannot be added or disabled gracefully leave an error message in the logs, the action is not interrupted. To change this behaviour you can set `fail-fast` flag to `true`.
|
- By default, extensions which cannot be added or disabled gracefully leave an error message in the logs, the execution is not interrupted. To change this behaviour you can set `fail-fast` flag to `true`.
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- name: Setup PHP with fail-fast
|
- name: Setup PHP with fail-fast
|
||||||
uses: shivammathur/setup-php@v2
|
uses: shivammathur/setup-php@v2
|
||||||
with:
|
with:
|
||||||
php-version: '8.0'
|
php-version: '8.1'
|
||||||
extensions: oci8
|
extensions: oci8
|
||||||
env:
|
env:
|
||||||
fail-fast: true
|
fail-fast: true
|
||||||
@ -217,13 +223,13 @@ PHP extensions can be set up using the `extensions` input. It accepts a `string`
|
|||||||
|
|
||||||
These tools can be set up globally using the `tools` input. It accepts a string in csv-format.
|
These tools can be set up globally using the `tools` input. It accepts a string in csv-format.
|
||||||
|
|
||||||
[`behat`], [`blackfire`], [`blackfire-player`], [`codeception`], [`composer`], [`composer-normalize`], [`composer-prefetcher`], [`composer-require-checker`], [`composer-unused`], [`cs2pr`], [`deployer`], [`flex`], [`grpc_php_plugin`], [`infection`], [`parallel-lint`], [`pecl`], [`phan`], [`phing`], [`phinx`], [`phive`], [`php-config`], [`php-cs-fixer`], [`phpcbf`], [`phpcpd`], [`phpcs`], [`phpdoc`] or [`phpDocumentor`], [`phpize`], [`phplint`], [`phpmd`], [`phpspec`], [`phpstan`], [`phpunit`], [`phpunit-bridge`], [`phpunit-polyfills`], [`prestissimo`], [`protoc`], [`psalm`], [`symfony`] or [`symfony-cli`], [`vapor`] or [`vapor-cli`], [`wp`] or [`wp-cli`]
|
[`behat`], [`blackfire`], [`blackfire-player`], [`churn`], [`codeception`], [`composer`], [`composer-normalize`], [`composer-prefetcher`], [`composer-require-checker`], [`composer-unused`], [`cs2pr`], [`deployer`], [`flex`], [`grpc_php_plugin`], [`infection`], [`parallel-lint`], [`pecl`], [`phan`], [`phing`], [`phinx`], [`phive`], [`php-config`], [`php-cs-fixer`], [`phpcbf`], [`phpcpd`], [`phpcs`], [`phpdoc`] or [`phpDocumentor`], [`phpize`], [`phplint`], [`phpmd`], [`phpspec`], [`phpstan`], [`phpunit`], [`phpunit-bridge`], [`phpunit-polyfills`], [`prestissimo`], [`protoc`], [`psalm`], [`symfony`] or [`symfony-cli`], [`vapor`] or [`vapor-cli`], [`wp`] or [`wp-cli`]
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- name: Setup PHP with tools
|
- name: Setup PHP with tools
|
||||||
uses: shivammathur/setup-php@v2
|
uses: shivammathur/setup-php@v2
|
||||||
with:
|
with:
|
||||||
php-version: '8.0'
|
php-version: '8.1'
|
||||||
tools: php-cs-fixer, phpunit
|
tools: php-cs-fixer, phpunit
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -233,7 +239,7 @@ These tools can be set up globally using the `tools` input. It accepts a string
|
|||||||
- name: Setup PHP with tools
|
- name: Setup PHP with tools
|
||||||
uses: shivammathur/setup-php@v2
|
uses: shivammathur/setup-php@v2
|
||||||
with:
|
with:
|
||||||
php-version: '8.0'
|
php-version: '8.1'
|
||||||
tools: vimeo/psalm
|
tools: vimeo/psalm
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -252,8 +258,8 @@ These tools can be set up globally using the `tools` input. It accepts a string
|
|||||||
- name: Setup PHP with tools
|
- name: Setup PHP with tools
|
||||||
uses: shivammathur/setup-php@v2
|
uses: shivammathur/setup-php@v2
|
||||||
with:
|
with:
|
||||||
php-version: '8.0'
|
php-version: '8.1'
|
||||||
tools: php-cs-fixer:3, phpunit:8.5
|
tools: php-cs-fixer:3.5, phpunit:9.5
|
||||||
env:
|
env:
|
||||||
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
```
|
```
|
||||||
@ -264,7 +270,7 @@ These tools can be set up globally using the `tools` input. It accepts a string
|
|||||||
- name: Setup PHP with composer v2
|
- name: Setup PHP with composer v2
|
||||||
uses: shivammathur/setup-php@v2
|
uses: shivammathur/setup-php@v2
|
||||||
with:
|
with:
|
||||||
php-version: '8.0'
|
php-version: '8.1'
|
||||||
tools: composer:v2
|
tools: composer:v2
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -274,32 +280,32 @@ These tools can be set up globally using the `tools` input. It accepts a string
|
|||||||
- name: Setup PHP without composer
|
- name: Setup PHP without composer
|
||||||
uses: shivammathur/setup-php@v2
|
uses: shivammathur/setup-php@v2
|
||||||
with:
|
with:
|
||||||
php-version: '8.0'
|
php-version: '8.1'
|
||||||
tools: none
|
tools: none
|
||||||
```
|
```
|
||||||
|
|
||||||
- Scripts `phpize` and `php-config` are set up with the same version as of the input PHP version.
|
- Tools `pear`, `pecl`, `phpize` and `php-config` are set up by default for all supported PHP versions on Linux and macOS.
|
||||||
|
|
||||||
- The latest version of `blackfire` cli is set up when `blackfire` is specified in tools input. Please refer to the [official documentation](https://blackfire.io/docs/integrations/ci/github-actions "Blackfire.io documentation for GitHub Actions") for using `blackfire` with GitHub Actions.
|
- The latest version of `blackfire` cli is set up 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.
|
||||||
|
|
||||||
- Tools `prestissimo` and `composer-prefetcher` will be skipped unless `composer:v1` is also specified in tools input. It is recommended to drop `prestissimo` and use `composer v2`.
|
- Tools `prestissimo` and `composer-prefetcher` will be skipped unless `composer:v1` is also specified in tools input. It is recommended to drop `prestissimo` and use `composer v2`.
|
||||||
|
|
||||||
- By default, tools which cannot be set up gracefully leave an error message in the logs, the action is not interrupted. To change this behaviour you can set `fail-fast` flag to `true`.
|
- By default, expect `composer` tools which cannot be set up gracefully leave an error message in the logs, the execution is not interrupted. To change this behaviour you can set `fail-fast` flag to `true`.
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- name: Setup PHP with fail-fast
|
- name: Setup PHP with fail-fast
|
||||||
uses: shivammathur/setup-php@v2
|
uses: shivammathur/setup-php@v2
|
||||||
with:
|
with:
|
||||||
php-version: '8.0'
|
php-version: '8.1'
|
||||||
tools: deployer
|
tools: deployer
|
||||||
env:
|
env:
|
||||||
fail-fast: true
|
fail-fast: true
|
||||||
```
|
```
|
||||||
|
|
||||||
**Notes**
|
**Notes**
|
||||||
- Input `tools` is useful to set up tools which you only use in GitHub Actions, thus keeping your `composer.json` tidy.
|
- Input `tools` is useful to set up tools which are only used in CI workflows, thus keeping your `composer.json` tidy.
|
||||||
- If you do not want to use all your dev-dependencies in GitHub Actions workflow, you can run composer with `--no-dev` and install required tools using `tools` input to speed up your workflow.
|
- If you do not want to use all your dev-dependencies in workflow, you can run composer with `--no-dev` and install required tools using `tools` input to speed up your workflow.
|
||||||
- If you have a tool in your `composer.json`, do not set up it with `tools` input as the two instances of the tool might conflict.
|
- By default, `COMPOSER_NO_INTERACTION` is set to `1` and `COMPOSER_PROCESS_TIMEOUT` is set to `0`. In effect, this means that Composer commands in your scripts do not need to specify `--no-interaction`.
|
||||||
|
|
||||||
## :signal_strength: Coverage Support
|
## :signal_strength: Coverage Support
|
||||||
|
|
||||||
@ -312,7 +318,7 @@ Runs on all [PHP versions supported](#tada-php-support "List of PHP versions sup
|
|||||||
- name: Setup PHP with Xdebug
|
- name: Setup PHP with Xdebug
|
||||||
uses: shivammathur/setup-php@v2
|
uses: shivammathur/setup-php@v2
|
||||||
with:
|
with:
|
||||||
php-version: '8.0'
|
php-version: '8.1'
|
||||||
coverage: xdebug
|
coverage: xdebug
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -340,7 +346,7 @@ Runs on PHP 7.1 and newer PHP versions.
|
|||||||
- name: Setup PHP with PCOV
|
- name: Setup PHP with PCOV
|
||||||
uses: shivammathur/setup-php@v2
|
uses: shivammathur/setup-php@v2
|
||||||
with:
|
with:
|
||||||
php-version: '8.0'
|
php-version: '8.1'
|
||||||
ini-values: pcov.directory=api #optional, see above for usage.
|
ini-values: pcov.directory=api #optional, see above for usage.
|
||||||
coverage: pcov
|
coverage: pcov
|
||||||
```
|
```
|
||||||
@ -370,7 +376,7 @@ Disable coverage for these reasons:
|
|||||||
- name: Setup PHP with no coverage driver
|
- name: Setup PHP with no coverage driver
|
||||||
uses: shivammathur/setup-php@v2
|
uses: shivammathur/setup-php@v2
|
||||||
with:
|
with:
|
||||||
php-version: '8.0'
|
php-version: '8.1'
|
||||||
coverage: none
|
coverage: none
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -397,6 +403,12 @@ Disable coverage for these reasons:
|
|||||||
- Shared extensions prefixed with `:` are disabled.
|
- Shared extensions prefixed with `:` are disabled.
|
||||||
- See [PHP extension support](#heavy_plus_sign-php-extension-support) for more info.
|
- See [PHP extension support](#heavy_plus_sign-php-extension-support) for more info.
|
||||||
|
|
||||||
|
#### `ini-file` (optional)
|
||||||
|
|
||||||
|
- Specify the base `php.ini` file.
|
||||||
|
- Accepts `production`, `development` or `none`.
|
||||||
|
- By default, production `php.ini` file is used.
|
||||||
|
|
||||||
#### `ini-values` (optional)
|
#### `ini-values` (optional)
|
||||||
|
|
||||||
- Specify the values you want to add to `php.ini`.
|
- Specify the values you want to add to `php.ini`.
|
||||||
@ -419,7 +431,7 @@ Disable coverage for these reasons:
|
|||||||
|
|
||||||
#### `php-version`
|
#### `php-version`
|
||||||
|
|
||||||
To use outputs, give the `setup-php` step an `id`, you can use the same to get the outputs in a later step.
|
On GitHub Actions you can assign the `setup-php` step an `id`, you can use the same to get the outputs in a later step.
|
||||||
|
|
||||||
- Provides the PHP version in semver format.
|
- Provides the PHP version in semver format.
|
||||||
|
|
||||||
@ -428,7 +440,7 @@ To use outputs, give the `setup-php` step an `id`, you can use the same to get t
|
|||||||
id: setup-php
|
id: setup-php
|
||||||
uses: shivammathur/setup-php@v2
|
uses: shivammathur/setup-php@v2
|
||||||
with:
|
with:
|
||||||
php-version: '8.0'
|
php-version: '8.1'
|
||||||
|
|
||||||
- name: Print PHP version
|
- name: Print PHP version
|
||||||
run: echo ${{ steps.setup-php.outputs.php-version }}
|
run: echo ${{ steps.setup-php.outputs.php-version }}
|
||||||
@ -463,14 +475,14 @@ See below for more info.
|
|||||||
|
|
||||||
### Basic Setup
|
### Basic Setup
|
||||||
|
|
||||||
> Setup a particular PHP version.
|
> Set up a particular PHP version.
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
steps:
|
steps:
|
||||||
- name: Setup PHP
|
- name: Setup PHP
|
||||||
uses: shivammathur/setup-php@v2
|
uses: shivammathur/setup-php@v2
|
||||||
with:
|
with:
|
||||||
php-version: '8.0'
|
php-version: '8.1'
|
||||||
extensions: mbstring, intl
|
extensions: mbstring, intl
|
||||||
ini-values: post_max_size=256M, max_execution_time=180
|
ini-values: post_max_size=256M, max_execution_time=180
|
||||||
coverage: xdebug
|
coverage: xdebug
|
||||||
@ -479,7 +491,7 @@ steps:
|
|||||||
|
|
||||||
### Matrix Setup
|
### Matrix Setup
|
||||||
|
|
||||||
> Setup multiple PHP versions on multiple operating systems.
|
> Set up multiple PHP versions on multiple operating systems.
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
jobs:
|
jobs:
|
||||||
@ -507,9 +519,9 @@ jobs:
|
|||||||
|
|
||||||
### Nightly Build Setup
|
### Nightly Build Setup
|
||||||
|
|
||||||
> Setup a nightly build of `PHP 8.2`.
|
> Set up a nightly build of `PHP 8.2`.
|
||||||
|
|
||||||
- This version is currently in development.
|
- This PHP version is currently in active development and might contain bugs and breaking changes.
|
||||||
- Some user space extensions might not support this version currently.
|
- Some user space extensions might not support this version currently.
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
@ -526,7 +538,7 @@ steps:
|
|||||||
|
|
||||||
### Thread Safe Setup
|
### Thread Safe Setup
|
||||||
|
|
||||||
> Setup `TS` or `NTS` PHP on `Windows`.
|
> Set up `TS` or `NTS` PHP on `Windows`.
|
||||||
|
|
||||||
- `NTS` versions are set up by default.
|
- `NTS` versions are set up by default.
|
||||||
- On `Ubuntu` and `macOS` only `NTS` versions are supported.
|
- On `Ubuntu` and `macOS` only `NTS` versions are supported.
|
||||||
@ -541,7 +553,7 @@ jobs:
|
|||||||
- name: Setup PHP
|
- name: Setup PHP
|
||||||
uses: shivammathur/setup-php@v2
|
uses: shivammathur/setup-php@v2
|
||||||
with:
|
with:
|
||||||
php-version: '8.0'
|
php-version: '8.1'
|
||||||
env:
|
env:
|
||||||
phpts: ts # specify ts or nts
|
phpts: ts # specify ts or nts
|
||||||
```
|
```
|
||||||
@ -550,14 +562,14 @@ jobs:
|
|||||||
|
|
||||||
> Update to the latest patch of PHP versions.
|
> Update to the latest patch of PHP versions.
|
||||||
|
|
||||||
- Pre-installed PHP versions on the GitHub Actions images are not updated to their latest patch release by default.
|
- Pre-installed PHP versions are not updated to their latest patch release by default.
|
||||||
- You can specify the `update` environment variable to `true` for updating to the latest release.
|
- You can specify the `update` environment variable to `true` for updating to the latest release.
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- name: Setup PHP with latest versions
|
- name: Setup PHP with latest versions
|
||||||
uses: shivammathur/setup-php@v2
|
uses: shivammathur/setup-php@v2
|
||||||
with:
|
with:
|
||||||
php-version: '8.0'
|
php-version: '8.1'
|
||||||
env:
|
env:
|
||||||
update: true # specify true or false
|
update: true # specify true or false
|
||||||
```
|
```
|
||||||
@ -572,15 +584,15 @@ To debug any issues, you can use the `verbose` tag instead of `v2`.
|
|||||||
- name: Setup PHP with logs
|
- name: Setup PHP with logs
|
||||||
uses: shivammathur/setup-php@verbose
|
uses: shivammathur/setup-php@verbose
|
||||||
with:
|
with:
|
||||||
php-version: '8.0'
|
php-version: '8.1'
|
||||||
```
|
```
|
||||||
|
|
||||||
### Multi-Arch Setup
|
### Multi-Arch Setup
|
||||||
|
|
||||||
> Setup PHP on multiple architecture on Ubuntu GitHub Runners.
|
> Set up PHP on multiple architecture on Ubuntu GitHub Runners.
|
||||||
|
|
||||||
- `PHP 5.6` to `PHP 8.0` are supported by `setup-php` on multiple architecture on `Ubuntu`.
|
- `PHP 5.6` to `PHP 8.1` are supported by `setup-php` on multiple architecture on `Ubuntu`.
|
||||||
- For this, you can use `shivammathur/node` images as containers. These have compatible `Nodejs` installed for JavaScript based GitHub Actions.
|
- For this, you can use `shivammathur/node` images as containers. These have compatible `Nodejs` installed for `setup-php`.
|
||||||
- Currently, for `ARM` based setup, you will need [self-hosted runners](#self-hosted-setup).
|
- Currently, for `ARM` based setup, you will need [self-hosted runners](#self-hosted-setup).
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
@ -595,12 +607,12 @@ jobs:
|
|||||||
- name: Install PHP
|
- name: Install PHP
|
||||||
uses: shivammathur/setup-php@v2
|
uses: shivammathur/setup-php@v2
|
||||||
with:
|
with:
|
||||||
php-version: '8.0'
|
php-version: '8.1'
|
||||||
```
|
```
|
||||||
|
|
||||||
### Self Hosted Setup
|
### Self Hosted Setup
|
||||||
|
|
||||||
> Setup PHP on a self-hosted runner.
|
> Set up PHP on a self-hosted runner.
|
||||||
|
|
||||||
- To set up a containerised self-hosted runner, refer to the following guides as per your base operating system.
|
- To set up a containerised self-hosted runner, refer to the following guides as per your base operating system.
|
||||||
- [Linux](https://github.com/shivammathur/setup-php/wiki/Dockerized-self-hosted-runner-on-Linux)
|
- [Linux](https://github.com/shivammathur/setup-php/wiki/Dockerized-self-hosted-runner-on-Linux)
|
||||||
@ -609,7 +621,7 @@ jobs:
|
|||||||
- To set up 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.
|
- To set up 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 [service containers](https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idservices "GitHub Actions Services"), then set up 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.
|
- If your workflow uses [service containers](https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idservices "GitHub Actions Services"), then set up 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.
|
It is recommended to specify the environment variable `runner` with the value `self-hosted` for self-hosted environments.
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
jobs:
|
jobs:
|
||||||
@ -625,7 +637,7 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
php-version: ${{ matrix.php-versions }}
|
php-version: ${{ matrix.php-versions }}
|
||||||
env:
|
env:
|
||||||
runner: self-hosted # Specify the runner.
|
runner: self-hosted
|
||||||
```
|
```
|
||||||
|
|
||||||
**Notes**
|
**Notes**
|
||||||
@ -645,7 +657,7 @@ jobs:
|
|||||||
- name: Setup PHP
|
- name: Setup PHP
|
||||||
uses: shivammathur/setup-php@v2
|
uses: shivammathur/setup-php@v2
|
||||||
with:
|
with:
|
||||||
php-version: '8.0'
|
php-version: '8.1'
|
||||||
```
|
```
|
||||||
|
|
||||||
Run the workflow locally with `act` using [`shivammathur/node`](https://github.com/shivammathur/node-docker "Docker image to run setup-php") docker images.
|
Run the workflow locally with `act` using [`shivammathur/node`](https://github.com/shivammathur/node-docker "Docker image to run setup-php") docker images.
|
||||||
@ -678,7 +690,7 @@ For example to enable JIT in `tracing` mode with buffer size of `64 MB`.
|
|||||||
- name: Setup PHP with JIT in tracing mode
|
- name: Setup PHP with JIT in tracing mode
|
||||||
uses: shivammathur/setup-php@v2
|
uses: shivammathur/setup-php@v2
|
||||||
with:
|
with:
|
||||||
php-version: '8.0'
|
php-version: '8.1'
|
||||||
coverage: none
|
coverage: none
|
||||||
ini-values: opcache.enable_cli=1, opcache.jit=tracing, opcache.jit_buffer_size=64M
|
ini-values: opcache.enable_cli=1, opcache.jit=tracing, opcache.jit_buffer_size=64M
|
||||||
```
|
```
|
||||||
@ -717,7 +729,7 @@ key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
|
|||||||
|
|
||||||
- If you support a range of `composer` dependencies and use `prefer-lowest` and `prefer-stable` options, you can store them in your matrix and add them to the keys.
|
- If you support a range of `composer` dependencies and use `prefer-lowest` and `prefer-stable` options, you can store them in your matrix and add them to the keys.
|
||||||
```yaml
|
```yaml
|
||||||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}-${{ matrix.prefer }}-
|
key: ${{ runner.os }}-composer-${{ matrix.prefer }}-${{ hashFiles('**/composer.lock') }}
|
||||||
restore-keys: ${{ runner.os }}-composer-${{ matrix.prefer }}-
|
restore-keys: ${{ runner.os }}-composer-${{ matrix.prefer }}-
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -729,7 +741,7 @@ If you have a number of workflows which set up multiple tools or have many compo
|
|||||||
- name: Setup PHP
|
- name: Setup PHP
|
||||||
uses: shivammathur/setup-php@v2
|
uses: shivammathur/setup-php@v2
|
||||||
with:
|
with:
|
||||||
php-version: '8.0'
|
php-version: '8.1'
|
||||||
env:
|
env:
|
||||||
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
```
|
```
|
||||||
@ -744,7 +756,7 @@ Put the code in the run property of a step and specify the shell as `php {0}`.
|
|||||||
- name: Setup PHP
|
- name: Setup PHP
|
||||||
uses: shivammathur/setup-php@v2
|
uses: shivammathur/setup-php@v2
|
||||||
with:
|
with:
|
||||||
php-version: '8.0'
|
php-version: '8.1'
|
||||||
|
|
||||||
- name: Run PHP code
|
- name: Run PHP code
|
||||||
shell: php {0}
|
shell: php {0}
|
||||||
@ -784,7 +796,7 @@ PHPStan supports error reporting in GitHub Actions, so it does not require probl
|
|||||||
- name: Setup PHP
|
- name: Setup PHP
|
||||||
uses: shivammathur/setup-php@v2
|
uses: shivammathur/setup-php@v2
|
||||||
with:
|
with:
|
||||||
php-version: '8.0'
|
php-version: '8.1'
|
||||||
tools: phpstan
|
tools: phpstan
|
||||||
|
|
||||||
- name: Run PHPStan
|
- name: Run PHPStan
|
||||||
@ -799,7 +811,7 @@ Psalm supports error reporting in GitHub Actions with an output format `github`.
|
|||||||
- name: Setup PHP
|
- name: Setup PHP
|
||||||
uses: shivammathur/setup-php@v2
|
uses: shivammathur/setup-php@v2
|
||||||
with:
|
with:
|
||||||
php-version: '8.0'
|
php-version: '8.1'
|
||||||
tools: psalm
|
tools: psalm
|
||||||
|
|
||||||
- name: Run Psalm
|
- name: Run Psalm
|
||||||
@ -817,7 +829,7 @@ For examples refer to [cs2pr documentation](https://github.com/staabm/annotate-p
|
|||||||
- name: Setup PHP
|
- name: Setup PHP
|
||||||
uses: shivammathur/setup-php@v2
|
uses: shivammathur/setup-php@v2
|
||||||
with:
|
with:
|
||||||
php-version: '8.0'
|
php-version: '8.1'
|
||||||
tools: cs2pr, phpcs
|
tools: cs2pr, phpcs
|
||||||
|
|
||||||
- name: Run phpcs
|
- name: Run phpcs
|
||||||
@ -828,37 +840,38 @@ For examples refer to [cs2pr documentation](https://github.com/staabm/annotate-p
|
|||||||
|
|
||||||
Examples of using `setup-php` with various PHP Frameworks and Packages.
|
Examples of using `setup-php` with various PHP Frameworks and 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 | `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")|
|
| 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") |
|
||||||
|CodeIgniter|`macOS`, `ubuntu` and `windows`|[codeigniter.yml](./examples/codeigniter.yml "GitHub Action for CodeIgniter")|
|
| CodeIgniter | `macOS`, `ubuntu` and `windows` | [codeigniter.yml](./examples/codeigniter.yml "GitHub Action for CodeIgniter") |
|
||||||
|Laminas MVC|`macOS`, `ubuntu` and `windows`|[laminas-mvc.yml](./examples/laminas-mvc.yml "GitHub Action for Laminas Framework MVC Projects")|
|
| Laminas MVC | `macOS`, `ubuntu` and `windows` | [laminas-mvc.yml](./examples/laminas-mvc.yml "GitHub Action for Laminas Framework MVC Projects") |
|
||||||
|Laravel with `MySQL` and `Redis`|`ubuntu`|[laravel-mysql.yml](./examples/laravel-mysql.yml "GitHub Action for Laravel with MySQL and Redis")|
|
| Laravel with `MySQL` and `Redis` | `ubuntu` | [laravel-mysql.yml](./examples/laravel-mysql.yml "GitHub Action for Laravel with MySQL and Redis") |
|
||||||
|Laravel with `PostgreSQL` and `Redis`|`ubuntu`|[laravel-postgres.yml](./examples/laravel-postgres.yml "GitHub Action for Laravel with PostgreSQL and Redis")|
|
| Laravel with `PostgreSQL` and `Redis` | `ubuntu` | [laravel-postgres.yml](./examples/laravel-postgres.yml "GitHub Action for Laravel with PostgreSQL and Redis") |
|
||||||
|Laravel without services|`macOS`, `ubuntu` and `windows`|[laravel.yml](./examples/laravel.yml "GitHub Action for Laravel without services")|
|
| Laravel without services | `macOS`, `ubuntu` and `windows` | [laravel.yml](./examples/laravel.yml "GitHub Action for Laravel without services") |
|
||||||
|Lumen with `MySQL` and `Redis`|`ubuntu`|[lumen-mysql.yml](./examples/lumen-mysql.yml "GitHub Action for Lumen with MySQL and Redis")|
|
| Lumen with `MySQL` and `Redis` | `ubuntu` | [lumen-mysql.yml](./examples/lumen-mysql.yml "GitHub Action for Lumen with MySQL and Redis") |
|
||||||
|Lumen with `PostgreSQL` and `Redis`|`ubuntu`|[lumen-postgres.yml](./examples/lumen-postgres.yml "GitHub Action for Lumen with PostgreSQL and Redis")|
|
| Lumen with `PostgreSQL` and `Redis` | `ubuntu` | [lumen-postgres.yml](./examples/lumen-postgres.yml "GitHub Action for Lumen with PostgreSQL and Redis") |
|
||||||
|Lumen without services|`macOS`, `ubuntu` and `windows`|[lumen.yml](./examples/lumen.yml "GitHub Action for Lumen without services")|
|
| Lumen without services | `macOS`, `ubuntu` and `windows` | [lumen.yml](./examples/lumen.yml "GitHub Action for Lumen without services") |
|
||||||
|Phalcon with `MySQL`|`ubuntu`|[phalcon-mysql.yml](./examples/phalcon-mysql.yml "GitHub Action for Phalcon with MySQL")|
|
| Phalcon with `MySQL` | `ubuntu` | [phalcon-mysql.yml](./examples/phalcon-mysql.yml "GitHub Action for Phalcon with MySQL") |
|
||||||
|Phalcon with `PostgreSQL`|`ubuntu`|[phalcon-postgres.yml](./examples/phalcon-postgres.yml "GitHub Action for Phalcon with PostgreSQL")|
|
| Phalcon with `PostgreSQL` | `ubuntu` | [phalcon-postgres.yml](./examples/phalcon-postgres.yml "GitHub Action for Phalcon with PostgreSQL") |
|
||||||
|Roots/bedrock|`ubuntu`|[bedrock.yml](./examples/bedrock.yml "GitHub Action for Wordpress Development using @roots/bedrock")|
|
| Roots/bedrock | `ubuntu` | [bedrock.yml](./examples/bedrock.yml "GitHub Action for Wordpress Development using @roots/bedrock") |
|
||||||
|Roots/sage|`ubuntu`|[sage.yml](./examples/sage.yml "GitHub Action for Wordpress Development using @roots/sage")|
|
| Roots/sage | `ubuntu` | [sage.yml](./examples/sage.yml "GitHub Action for Wordpress Development using @roots/sage") |
|
||||||
|Slim Framework|`macOS`, `ubuntu` and `windows`|[slim-framework.yml](./examples/slim-framework.yml "GitHub Action for Slim Framework")|
|
| Slim Framework | `macOS`, `ubuntu` and `windows` | [slim-framework.yml](./examples/slim-framework.yml "GitHub Action for Slim Framework") |
|
||||||
|Symfony with `MySQL`|`ubuntu`|[symfony-mysql.yml](./examples/symfony-mysql.yml "GitHub Action for Symfony with MySQL")|
|
| Symfony with `MySQL` | `ubuntu` | [symfony-mysql.yml](./examples/symfony-mysql.yml "GitHub Action for Symfony with MySQL") |
|
||||||
|Symfony with `PostgreSQL`|`ubuntu`|[symfony-postgres.yml](./examples/symfony-postgres.yml "GitHub Action for Symfony with PostgreSQL")|
|
| Symfony with `PostgreSQL` | `ubuntu` | [symfony-postgres.yml](./examples/symfony-postgres.yml "GitHub Action for Symfony with PostgreSQL") |
|
||||||
|Symfony without services|`macOS`, `ubuntu` and `windows`|[symfony.yml](./examples/symfony.yml "GitHub Action for Symfony without services")|
|
| Symfony without services | `macOS`, `ubuntu` and `windows` | [symfony.yml](./examples/symfony.yml "GitHub Action for Symfony without services") |
|
||||||
|Yii2 Starter Kit with `MySQL`|`ubuntu`|[yii2-mysql.yml](./examples/yii2-mysql.yml "GitHub Action for Yii2 Starter Kit with MySQL")|
|
| Yii2 Starter Kit with `MySQL` | `ubuntu` | [yii2-mysql.yml](./examples/yii2-mysql.yml "GitHub Action for Yii2 Starter Kit with MySQL") |
|
||||||
|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") |
|
||||||
|
|
||||||
## :bookmark: Versioning
|
## :bookmark: Versioning
|
||||||
|
|
||||||
- Use the `v2` tag as `setup-php` version. It is a rolling tag and is synced with the latest minor and patch releases. With `v2` you automatically get the bug fixes, security patches, 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.
|
- Use the `v2` tag as `setup-php` version. It is a rolling tag and is synced with the latest minor and patch releases. With `v2` you automatically get the bug fixes, security patches, new features and support for latest PHP 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.
|
- 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, security patches or new features.
|
- 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, security patches or new features.
|
||||||
|
- For debugging any issues `verbose` tag can be used temporarily. It outputs all the logs and is also synced with the latest releases.
|
||||||
- It is highly discouraged to use the `master` branch as version, it might break your workflow after major releases as they have breaking changes.
|
- It is highly discouraged to use the `master` branch as version, 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, you should [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.
|
- If you are using the `v1` tag or a `1.x.y` version, you should [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.
|
||||||
|
|
||||||
@ -885,7 +898,7 @@ Examples of using `setup-php` with various PHP Frameworks and Packages.
|
|||||||
|
|
||||||
## :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.
|
- Please star the project and share it. If you blog, please share your experience of using `setup-php`.
|
||||||
- Please [reach out](mailto:contact@setup-php.com) if you have any questions about sponsoring setup-php.
|
- Please [reach out](mailto:contact@setup-php.com) if you have any questions about sponsoring setup-php.
|
||||||
|
|
||||||
Many users and organisations support setup-php via [GitHub Sponsors](https://github.com/sponsors/shivammathur).
|
Many users and organisations support setup-php via [GitHub Sponsors](https://github.com/sponsors/shivammathur).
|
||||||
@ -909,6 +922,13 @@ These companies generously provide setup-php their products and services to aid
|
|||||||
<a href="https://tidelift.com/subscription/pkg/npm-setup-php">
|
<a href="https://tidelift.com/subscription/pkg/npm-setup-php">
|
||||||
<img src="https://setup-php.com/sponsors/tidelift.png" alt="Tidelift" width="70" height="60">
|
<img src="https://setup-php.com/sponsors/tidelift.png" alt="Tidelift" width="70" height="60">
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
|
<a href="https://www.scaleway.com/en/about-us/open-source-program#gh-light-mode-only">
|
||||||
|
<img src="https://setup-php.com/sponsors/scaleway.png" alt="Scaleway" width="174" height="60">
|
||||||
|
</a>
|
||||||
|
<a href="https://www.scaleway.com/en/about-us/open-source-program#gh-dark-mode-only">
|
||||||
|
<img src="https://setup-php.com/sponsors/scaleway-white.png" alt="Scaleway" width="174" height="60">
|
||||||
|
</a>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
## :package: Dependencies
|
## :package: Dependencies
|
||||||
@ -939,6 +959,7 @@ These companies generously provide setup-php their products and services to aid
|
|||||||
[`behat`]: https://docs.behat.org/en/latest/
|
[`behat`]: https://docs.behat.org/en/latest/
|
||||||
[`blackfire`]: https://blackfire.io/docs/php/index
|
[`blackfire`]: https://blackfire.io/docs/php/index
|
||||||
[`blackfire-player`]: https://blackfire.io/docs/builds-cookbooks/player
|
[`blackfire-player`]: https://blackfire.io/docs/builds-cookbooks/player
|
||||||
|
[`churn`]: https://github.com/bmitch/churn-php
|
||||||
[`codeception`]: https://codeception.com/
|
[`codeception`]: https://codeception.com/
|
||||||
[`composer`]: https://getcomposer.org/
|
[`composer`]: https://getcomposer.org/
|
||||||
[`composer-normalize`]: https://github.com/ergebnis/composer-normalize
|
[`composer-normalize`]: https://github.com/ergebnis/composer-normalize
|
||||||
|
@ -2,7 +2,7 @@ import * as config from '../src/config';
|
|||||||
|
|
||||||
describe('Config tests', () => {
|
describe('Config tests', () => {
|
||||||
it.each`
|
it.each`
|
||||||
ini_values | os_version | output
|
ini_values | os | output
|
||||||
${'a=b, c=d'} | ${'win32'} | ${'Add-Content "$php_dir\\php.ini" "a=b\nc=d"'}
|
${'a=b, c=d'} | ${'win32'} | ${'Add-Content "$php_dir\\php.ini" "a=b\nc=d"'}
|
||||||
${'a=b, c=d'} | ${'linux'} | ${'echo "a=b\nc=d" | sudo tee -a "${pecl_file:-${ini_file[@]}}"'}
|
${'a=b, c=d'} | ${'linux'} | ${'echo "a=b\nc=d" | sudo tee -a "${pecl_file:-${ini_file[@]}}"'}
|
||||||
${'a=b, c=d'} | ${'darwin'} | ${'echo "a=b\nc=d" | sudo tee -a "${pecl_file:-${ini_file[@]}}"'}
|
${'a=b, c=d'} | ${'darwin'} | ${'echo "a=b\nc=d" | sudo tee -a "${pecl_file:-${ini_file[@]}}"'}
|
||||||
@ -10,12 +10,7 @@ describe('Config tests', () => {
|
|||||||
${'a="~(b)"'} | ${'win32'} | ${'Add-Content "$php_dir\\php.ini" "a=\'~(b)\'"'}
|
${'a="~(b)"'} | ${'win32'} | ${'Add-Content "$php_dir\\php.ini" "a=\'~(b)\'"'}
|
||||||
${'a="b, c"'} | ${'win32'} | ${'Add-Content "$php_dir\\php.ini" "a=b, c"'}
|
${'a="b, c"'} | ${'win32'} | ${'Add-Content "$php_dir\\php.ini" "a=b, c"'}
|
||||||
${'a=b, c=d'} | ${'openbsd'} | ${'Platform openbsd is not supported'}
|
${'a=b, c=d'} | ${'openbsd'} | ${'Platform openbsd is not supported'}
|
||||||
`(
|
`('checking addINIValues on $os', async ({ini_values, os, output}) => {
|
||||||
'checking addINIValues on $os_version',
|
expect(await config.addINIValues(ini_values, os)).toContain(output);
|
||||||
async ({ini_values, os_version, output}) => {
|
});
|
||||||
expect(await config.addINIValues(ini_values, os_version)).toContain(
|
|
||||||
output
|
|
||||||
);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
@ -56,6 +56,7 @@ describe('Extension tests', () => {
|
|||||||
${'pdo_cubrid'} | ${'7.4'} | ${'add_pdo_extension cubrid'}
|
${'pdo_cubrid'} | ${'7.4'} | ${'add_pdo_extension cubrid'}
|
||||||
${'pdo_mysql'} | ${'7.4'} | ${'add_pdo_extension mysql'}
|
${'pdo_mysql'} | ${'7.4'} | ${'add_pdo_extension mysql'}
|
||||||
${'pdo_oci'} | ${'7.3'} | ${'add_oci pdo_oci'}
|
${'pdo_oci'} | ${'7.3'} | ${'add_oci pdo_oci'}
|
||||||
|
${'pdo_sqlsrv'} | ${'7.4'} | ${'add_sqlsrv pdo_sqlsrv'}
|
||||||
${'pecl_http'} | ${'7.3'} | ${'add_http'}
|
${'pecl_http'} | ${'7.3'} | ${'add_http'}
|
||||||
${'phalcon3'} | ${'7.3'} | ${'add_phalcon phalcon3'}
|
${'phalcon3'} | ${'7.3'} | ${'add_phalcon phalcon3'}
|
||||||
${'sqlite'} | ${'7.4'} | ${'add_extension sqlite3'}
|
${'sqlite'} | ${'7.4'} | ${'add_extension sqlite3'}
|
||||||
@ -92,6 +93,7 @@ describe('Extension tests', () => {
|
|||||||
${'pdo_oci'} | ${'7.3'} | ${'add_oci pdo_oci'}
|
${'pdo_oci'} | ${'7.3'} | ${'add_oci pdo_oci'}
|
||||||
${'pecl_http'} | ${'7.3'} | ${'add_http'}
|
${'pecl_http'} | ${'7.3'} | ${'add_http'}
|
||||||
${'sqlite'} | ${'7.2'} | ${'add_extension sqlite3'}
|
${'sqlite'} | ${'7.2'} | ${'add_extension sqlite3'}
|
||||||
|
${'sqlsrv'} | ${'7.3'} | ${'add_sqlsrv sqlsrv'}
|
||||||
`(
|
`(
|
||||||
'checking addExtensionOnDarwin for extension $extension on version $version',
|
'checking addExtensionOnDarwin for extension $extension on version $version',
|
||||||
async ({extension, version, output}) => {
|
async ({extension, version, output}) => {
|
||||||
@ -110,7 +112,9 @@ describe('Extension tests', () => {
|
|||||||
const [formula, extension]: string[] = line.split('=');
|
const [formula, extension]: string[] = line.split('=');
|
||||||
const prefix: string =
|
const prefix: string =
|
||||||
extension == 'xdebug' ? 'zend_extension' : 'extension';
|
extension == 'xdebug' ? 'zend_extension' : 'extension';
|
||||||
const output: string = fs.existsSync(`src/scripts/ext/${extension}.sh`)
|
const output: string = fs.existsSync(
|
||||||
|
`src/scripts/extensions/${extension}.sh`
|
||||||
|
)
|
||||||
? `add_${extension}`
|
? `add_${extension}`
|
||||||
: `add_brew_extension ${formula} ${prefix}`;
|
: `add_brew_extension ${formula} ${prefix}`;
|
||||||
return [formula, '7.3', output];
|
return [formula, '7.3', output];
|
||||||
|
39
__tests__/fetch.test.ts
Normal file
39
__tests__/fetch.test.ts
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
import * as fetch from '../src/fetch';
|
||||||
|
import nock = require('nock');
|
||||||
|
|
||||||
|
it('checking fetch', async () => {
|
||||||
|
const host_url = 'https://example.com';
|
||||||
|
const manifest_url = host_url + '/manifest';
|
||||||
|
const ping_url = host_url + '/ping';
|
||||||
|
|
||||||
|
nock(host_url)
|
||||||
|
.get('/manifest')
|
||||||
|
.reply(200, {latest: 'latest'})
|
||||||
|
.get('/manifest', '', {
|
||||||
|
reqheaders: {authorization: 'Bearer invalid_token'}
|
||||||
|
})
|
||||||
|
.reply(401, {error: '401: Unauthorized'})
|
||||||
|
.get('/ping')
|
||||||
|
.twice()
|
||||||
|
.reply(301, undefined, {
|
||||||
|
Location: host_url + '/pong'
|
||||||
|
})
|
||||||
|
.get('/pong')
|
||||||
|
.reply(200, 'pong');
|
||||||
|
|
||||||
|
let response: Record<string, string> = await fetch.fetch(manifest_url);
|
||||||
|
expect(response.error).toBe(undefined);
|
||||||
|
expect(response.data).toContain('latest');
|
||||||
|
|
||||||
|
response = await fetch.fetch(ping_url, '', 1);
|
||||||
|
expect(response.error).toBe(undefined);
|
||||||
|
expect(response.data).toContain('pong');
|
||||||
|
|
||||||
|
response = await fetch.fetch(ping_url, '', 0);
|
||||||
|
expect(response.error).toBe('301: Redirect error');
|
||||||
|
expect(response.data).toBe(undefined);
|
||||||
|
|
||||||
|
response = await fetch.fetch(manifest_url, 'invalid_token');
|
||||||
|
expect(response.error).not.toBe(undefined);
|
||||||
|
expect(response.data).toBe(undefined);
|
||||||
|
});
|
@ -5,96 +5,77 @@ import * as utils from '../src/utils';
|
|||||||
* Mock install.ts
|
* Mock install.ts
|
||||||
*/
|
*/
|
||||||
jest.mock('../src/install', () => ({
|
jest.mock('../src/install', () => ({
|
||||||
getScript: jest.fn().mockImplementation(async (): Promise<string> => {
|
getScript: jest
|
||||||
const extension_csv: string = process.env['extensions'] || '';
|
.fn()
|
||||||
const ini_values_csv: string = process.env['ini-values'] || '';
|
.mockImplementation(async (os: string): Promise<string> => {
|
||||||
const coverage_driver: string = process.env['coverage'] || '';
|
const filename = os + (await utils.scriptExtension(os));
|
||||||
const tools_csv: string = process.env['tools'] || '';
|
const version: string = await utils.parseVersion(
|
||||||
let script = 'initial script';
|
await utils.getInput('php-version', true)
|
||||||
script += tools_csv ? ' add_tool' : '';
|
);
|
||||||
script += extension_csv ? ' install extensions' : '';
|
const ini_file: string = await utils.parseIniFile(
|
||||||
script += coverage_driver ? ' set coverage driver' : '';
|
await utils.getInput('ini-file', false)
|
||||||
script += ini_values_csv ? ' edit php.ini' : '';
|
);
|
||||||
return script;
|
const extension_csv: string = process.env['extensions'] || '';
|
||||||
}),
|
const ini_values_csv: string = process.env['ini-values'] || '';
|
||||||
|
const coverage_driver: string = process.env['coverage'] || '';
|
||||||
|
const tools_csv: string = process.env['tools'] || '';
|
||||||
|
let script = await utils.joins(filename, version, ini_file);
|
||||||
|
script += extension_csv ? ' install extensions' : '';
|
||||||
|
script += tools_csv ? ' add_tool' : '';
|
||||||
|
script += coverage_driver ? ' set coverage driver' : '';
|
||||||
|
script += ini_values_csv ? ' edit php.ini' : '';
|
||||||
|
return script;
|
||||||
|
}),
|
||||||
run: jest.fn().mockImplementation(async (): Promise<string> => {
|
run: jest.fn().mockImplementation(async (): Promise<string> => {
|
||||||
const os_version: string = process.env['RUNNER_OS'] || '';
|
const os: string = process.env['RUNNER_OS'] || '';
|
||||||
const version: string = await utils.parseVersion(
|
const tool = await utils.scriptTool(os);
|
||||||
await utils.getInput('php-version', true)
|
return tool + (await install.getScript(os));
|
||||||
);
|
|
||||||
const tool = await utils.scriptTool(os_version);
|
|
||||||
const filename = os_version + (await utils.scriptExtension(os_version));
|
|
||||||
return [
|
|
||||||
await install.getScript(filename, version, os_version),
|
|
||||||
tool,
|
|
||||||
filename,
|
|
||||||
version,
|
|
||||||
__dirname
|
|
||||||
].join(' ');
|
|
||||||
})
|
})
|
||||||
}));
|
}));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function to set the process.env
|
* Mock fetch.ts
|
||||||
*
|
|
||||||
* @param version
|
|
||||||
* @param os
|
|
||||||
* @param extension_csv
|
|
||||||
* @param ini_values_csv
|
|
||||||
* @param coverage_driver
|
|
||||||
* @param tools
|
|
||||||
*/
|
*/
|
||||||
function setEnv(
|
jest.mock('../src/fetch', () => ({
|
||||||
version: string | number,
|
fetch: jest.fn().mockImplementation(() => {
|
||||||
os: string,
|
return {data: '{ "latest": "8.1", "5.x": "5.6" }'};
|
||||||
extension_csv: string,
|
})
|
||||||
ini_values_csv: string,
|
}));
|
||||||
coverage_driver: string,
|
|
||||||
tools: string
|
|
||||||
): void {
|
|
||||||
process.env['php-version'] = version.toString();
|
|
||||||
process.env['RUNNER_OS'] = os;
|
|
||||||
process.env['extensions'] = extension_csv;
|
|
||||||
process.env['ini-values'] = ini_values_csv;
|
|
||||||
process.env['coverage'] = coverage_driver;
|
|
||||||
process.env['tools'] = tools;
|
|
||||||
}
|
|
||||||
|
|
||||||
describe('Install', () => {
|
describe('Install', () => {
|
||||||
it.each`
|
it.each`
|
||||||
version | os | extension_csv | ini_values_csv | coverage_driver | tools | output
|
version | os | extension_csv | ini_file | ini_values_csv | coverage_driver | tools | output
|
||||||
${'7.3'} | ${'darwin'} | ${''} | ${''} | ${''} | ${''} | ${'initial script bash darwin.sh 7.3 ' + __dirname}
|
${'7.3'} | ${'darwin'} | ${''} | ${'production'} | ${''} | ${''} | ${''} | ${'bash darwin.sh 7.3 production'}
|
||||||
${'7.3'} | ${'darwin'} | ${'a, b'} | ${'a=b'} | ${'x'} | ${''} | ${'initial script install extensions set coverage driver edit php.ini bash darwin.sh 7.3 ' + __dirname}
|
${'7.3'} | ${'darwin'} | ${'a, b'} | ${'development'} | ${'a=b'} | ${'x'} | ${''} | ${'bash darwin.sh 7.3 development install extensions set coverage driver edit php.ini'}
|
||||||
${'7.4.1'} | ${'darwin'} | ${''} | ${''} | ${''} | ${''} | ${'initial script bash darwin.sh 7.4 ' + __dirname}
|
${'7.4.1'} | ${'darwin'} | ${''} | ${'none'} | ${''} | ${''} | ${''} | ${'bash darwin.sh 7.4 none'}
|
||||||
${'8'} | ${'darwin'} | ${''} | ${''} | ${''} | ${''} | ${'initial script bash darwin.sh 8.0 ' + __dirname}
|
${'8'} | ${'darwin'} | ${''} | ${''} | ${''} | ${''} | ${''} | ${'bash darwin.sh 8.0 production'}
|
||||||
${'8.0'} | ${'darwin'} | ${''} | ${''} | ${''} | ${''} | ${'initial script bash darwin.sh 8.0 ' + __dirname}
|
${'8.0'} | ${'darwin'} | ${''} | ${'development'} | ${''} | ${''} | ${''} | ${'bash darwin.sh 8.0 development'}
|
||||||
${'8.1'} | ${'darwin'} | ${''} | ${''} | ${''} | ${''} | ${'initial script bash darwin.sh 8.1 ' + __dirname}
|
${'8.1'} | ${'darwin'} | ${''} | ${'none'} | ${''} | ${''} | ${''} | ${'bash darwin.sh 8.1 none'}
|
||||||
${'7.3'} | ${'linux'} | ${''} | ${''} | ${''} | ${''} | ${'initial script bash linux.sh 7.3 ' + __dirname}
|
${'7.3'} | ${'linux'} | ${''} | ${'invalid'} | ${''} | ${''} | ${''} | ${'bash linux.sh 7.3 production'}
|
||||||
${'7.3'} | ${'linux'} | ${'a, b'} | ${'a=b'} | ${'x'} | ${'phpunit'} | ${'initial script add_tool install extensions set coverage driver edit php.ini bash linux.sh 7.3 ' + __dirname}
|
${'7.3'} | ${'linux'} | ${'a, b'} | ${'development'} | ${'a=b'} | ${'x'} | ${'phpunit'} | ${'bash linux.sh 7.3 development install extensions add_tool set coverage driver edit php.ini'}
|
||||||
${'latest'} | ${'linux'} | ${''} | ${''} | ${''} | ${''} | ${'initial script bash linux.sh 8.1 ' + __dirname}
|
${'latest'} | ${'linux'} | ${''} | ${'none'} | ${''} | ${''} | ${''} | ${'bash linux.sh 8.1 none'}
|
||||||
${'7.0'} | ${'win32'} | ${''} | ${''} | ${''} | ${''} | ${'initial script pwsh win32.ps1 7.0 ' + __dirname}
|
${'7.0'} | ${'win32'} | ${''} | ${'production'} | ${''} | ${''} | ${''} | ${'pwsh win32.ps1 7.0 production'}
|
||||||
${'7.3'} | ${'win32'} | ${''} | ${''} | ${''} | ${''} | ${'initial script pwsh win32.ps1 7.3 ' + __dirname}
|
${'7.3'} | ${'win32'} | ${''} | ${'development'} | ${''} | ${''} | ${''} | ${'pwsh win32.ps1 7.3 development'}
|
||||||
${'7.3'} | ${'win32'} | ${'a, b'} | ${'a=b'} | ${'x'} | ${''} | ${'initial script install extensions set coverage driver edit php.ini pwsh win32.ps1 7.3 ' + __dirname}
|
${'7.3'} | ${'win32'} | ${'a, b'} | ${'none'} | ${'a=b'} | ${'x'} | ${''} | ${'pwsh win32.ps1 7.3 none install extensions set coverage driver edit php.ini'}
|
||||||
`(
|
`(
|
||||||
'Test install on $os for $version with extensions=$extension_csv, ini_values=$ini_values_csv, coverage_driver=$coverage_driver, tools=$tools',
|
'Test install on $os for $version with extensions=$extension_csv, ini_values=$ini_values_csv, coverage_driver=$coverage_driver, tools=$tools',
|
||||||
async ({
|
async ({
|
||||||
version,
|
version,
|
||||||
os,
|
os,
|
||||||
extension_csv,
|
extension_csv,
|
||||||
|
ini_file,
|
||||||
ini_values_csv,
|
ini_values_csv,
|
||||||
coverage_driver,
|
coverage_driver,
|
||||||
tools,
|
tools,
|
||||||
output
|
output
|
||||||
}) => {
|
}) => {
|
||||||
setEnv(
|
process.env['php-version'] = version.toString();
|
||||||
version,
|
process.env['RUNNER_OS'] = os;
|
||||||
os,
|
process.env['extensions'] = extension_csv;
|
||||||
extension_csv,
|
process.env['ini-file'] = ini_file;
|
||||||
ini_values_csv,
|
process.env['ini-values'] = ini_values_csv;
|
||||||
coverage_driver,
|
process.env['coverage'] = coverage_driver;
|
||||||
tools
|
process.env['tools'] = tools;
|
||||||
);
|
|
||||||
|
|
||||||
expect(await install.run()).toBe(output);
|
expect(await install.run()).toBe(output);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -1,12 +1,11 @@
|
|||||||
import * as tools from '../src/tools';
|
import * as tools from '../src/tools';
|
||||||
import * as utils from '../src/utils';
|
|
||||||
|
|
||||||
interface IData {
|
interface IData {
|
||||||
tool: string;
|
tool: string;
|
||||||
version?: string;
|
version?: string;
|
||||||
domain?: string;
|
domain?: string;
|
||||||
extension?: string;
|
extension?: string;
|
||||||
os_version?: string;
|
os?: string;
|
||||||
php_version?: string;
|
php_version?: string;
|
||||||
release?: string;
|
release?: string;
|
||||||
repository?: string;
|
repository?: string;
|
||||||
@ -23,7 +22,7 @@ function getData(data: IData): Record<string, string> {
|
|||||||
version: data.version || '',
|
version: data.version || '',
|
||||||
domain: data.domain || 'https://example.com',
|
domain: data.domain || 'https://example.com',
|
||||||
extension: data.extension || '.phar',
|
extension: data.extension || '.phar',
|
||||||
os_version: data.os_version || 'linux',
|
os: data.os || 'linux',
|
||||||
php_version: data.php_version || '7.4',
|
php_version: data.php_version || '7.4',
|
||||||
release: data.release || [data.tool, data.version].join(':'),
|
release: data.release || [data.tool, data.version].join(':'),
|
||||||
repository: data.repository || '',
|
repository: data.repository || '',
|
||||||
@ -38,27 +37,34 @@ function getData(data: IData): Record<string, string> {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
jest
|
/**
|
||||||
.spyOn(utils, 'fetch')
|
* Mock fetch.ts
|
||||||
.mockImplementation(
|
*/
|
||||||
async (url: string, token?: string): Promise<Record<string, string>> => {
|
jest.mock('../src/fetch', () => ({
|
||||||
if (url.includes('atom') && !url.includes('no-release')) {
|
fetch: jest
|
||||||
return {
|
.fn()
|
||||||
data: '"releases/tag/1.2.3", "releases/tag/3.2.1", "releases/tag/2.3.1"'
|
.mockImplementation(
|
||||||
};
|
async (url: string, token?: string): Promise<Record<string, string>> => {
|
||||||
} else if (url.includes('no-release')) {
|
if (url.includes('atom') && !url.includes('no-')) {
|
||||||
return {data: ''};
|
return {
|
||||||
} else if (!token || token === 'valid_token') {
|
data: '"releases/tag/1.2.3", "releases/tag/3.2.1", "releases/tag/2.3.1"'
|
||||||
return {data: `[{"ref": "refs/tags/1.2.3", "url": "${url}"}]`};
|
};
|
||||||
} else if (token === 'beta_token') {
|
} else if (url.includes('no-data')) {
|
||||||
return {data: `[{"ref": "refs/tags/1.2.3-beta1", "url": "${url}"}]`};
|
return {};
|
||||||
} else if (token === 'no_data') {
|
} else if (url.includes('no-release')) {
|
||||||
return {data: '[]'};
|
return {data: 'no-release'};
|
||||||
} else {
|
} else if (!token || token === 'valid_token') {
|
||||||
return {error: 'Invalid token'};
|
return {data: `[{"ref": "refs/tags/1.2.3", "url": "${url}"}]`};
|
||||||
|
} else if (token === 'beta_token') {
|
||||||
|
return {data: `[{"ref": "refs/tags/1.2.3-beta1", "url": "${url}"}]`};
|
||||||
|
} else if (token === 'no_data') {
|
||||||
|
return {data: '[]'};
|
||||||
|
} else {
|
||||||
|
return {error: 'Invalid token'};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
)
|
||||||
);
|
}));
|
||||||
|
|
||||||
describe('Tools tests', () => {
|
describe('Tools tests', () => {
|
||||||
it.each`
|
it.each`
|
||||||
@ -77,6 +83,7 @@ describe('Tools tests', () => {
|
|||||||
it.each`
|
it.each`
|
||||||
tool | fetch_latest | version
|
tool | fetch_latest | version
|
||||||
${'tool'} | ${'true'} | ${'3.2.1'}
|
${'tool'} | ${'true'} | ${'3.2.1'}
|
||||||
|
${'tool-no-data'} | ${'true'} | ${'latest'}
|
||||||
${'tool-no-release'} | ${'true'} | ${'latest'}
|
${'tool-no-release'} | ${'true'} | ${'latest'}
|
||||||
${'tool'} | ${'false'} | ${'latest'}
|
${'tool'} | ${'false'} | ${'latest'}
|
||||||
`(
|
`(
|
||||||
@ -194,45 +201,42 @@ describe('Tools tests', () => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
it.each`
|
it.each`
|
||||||
os_version | script
|
os | script
|
||||||
${'linux'} | ${'add_tool https://example.com/tool.phar tool "-v"'}
|
${'linux'} | ${'add_tool https://example.com/tool.phar tool "-v"'}
|
||||||
${'darwin'} | ${'add_tool https://example.com/tool.phar tool "-v"'}
|
${'darwin'} | ${'add_tool https://example.com/tool.phar tool "-v"'}
|
||||||
${'win32'} | ${'Add-Tool https://example.com/tool.phar tool "-v"'}
|
${'win32'} | ${'Add-Tool https://example.com/tool.phar tool "-v"'}
|
||||||
${'openbsd'} | ${'Platform openbsd is not supported'}
|
${'openbsd'} | ${'Platform openbsd is not supported'}
|
||||||
`('checking addArchive: $os_version', async ({os_version, script}) => {
|
`('checking addArchive: $os', async ({os, script}) => {
|
||||||
const data = getData({
|
const data = getData({
|
||||||
tool: 'tool',
|
tool: 'tool',
|
||||||
version: 'latest',
|
version: 'latest',
|
||||||
version_parameter: JSON.stringify('-v'),
|
version_parameter: JSON.stringify('-v'),
|
||||||
os_version: os_version
|
os: os
|
||||||
});
|
});
|
||||||
data['url'] = 'https://example.com/tool.phar';
|
data['url'] = 'https://example.com/tool.phar';
|
||||||
expect(await tools.addArchive(data)).toContain(script);
|
expect(await tools.addArchive(data)).toContain(script);
|
||||||
});
|
});
|
||||||
|
|
||||||
it.each`
|
it.each`
|
||||||
os_version | script | scope
|
os | script | scope
|
||||||
${'linux'} | ${'add_composertool tool tool:1.2.3 user/ global'} | ${'global'}
|
${'linux'} | ${'add_composertool tool tool:1.2.3 user/ global'} | ${'global'}
|
||||||
${'darwin'} | ${'add_composertool tool tool:1.2.3 user/ scoped'} | ${'scoped'}
|
${'darwin'} | ${'add_composertool tool tool:1.2.3 user/ scoped'} | ${'scoped'}
|
||||||
${'win32'} | ${'Add-Composertool tool tool:1.2.3 user/ scoped'} | ${'scoped'}
|
${'win32'} | ${'Add-Composertool tool tool:1.2.3 user/ scoped'} | ${'scoped'}
|
||||||
${'openbsd'} | ${'Platform openbsd is not supported'} | ${'global'}
|
${'openbsd'} | ${'Platform openbsd is not supported'} | ${'global'}
|
||||||
`(
|
`('checking addPackage: $os, $scope', async ({os, script, scope}) => {
|
||||||
'checking addPackage: $os_version, $scope',
|
const data = getData({
|
||||||
async ({os_version, script, scope}) => {
|
tool: 'tool',
|
||||||
const data = getData({
|
version: '1.2.3',
|
||||||
tool: 'tool',
|
repository: 'user/tool',
|
||||||
version: '1.2.3',
|
os: os,
|
||||||
repository: 'user/tool',
|
scope: scope
|
||||||
os_version: os_version,
|
});
|
||||||
scope: scope
|
data['release'] = [data['tool'], data['version']].join(':');
|
||||||
});
|
expect(await tools.addPackage(data)).toContain(script);
|
||||||
data['release'] = [data['tool'], data['version']].join(':');
|
});
|
||||||
expect(await tools.addPackage(data)).toContain(script);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
it.each`
|
it.each`
|
||||||
version | php_version | os_version | script
|
version | php_version | os | script
|
||||||
${'latest'} | ${'7.4'} | ${'linux'} | ${'add_tool https://github.com/phar-io/phive/releases/download/3.2.1/phive-3.2.1.phar phive'}
|
${'latest'} | ${'7.4'} | ${'linux'} | ${'add_tool https://github.com/phar-io/phive/releases/download/3.2.1/phive-3.2.1.phar phive'}
|
||||||
${'1.2.3'} | ${'7.4'} | ${'darwin'} | ${'add_tool https://github.com/phar-io/phive/releases/download/1.2.3/phive-1.2.3.phar phive'}
|
${'1.2.3'} | ${'7.4'} | ${'darwin'} | ${'add_tool https://github.com/phar-io/phive/releases/download/1.2.3/phive-1.2.3.phar phive'}
|
||||||
${'1.2.3'} | ${'7.2'} | ${'win32'} | ${'Add-Tool https://github.com/phar-io/phive/releases/download/0.14.5/phive-0.14.5.phar phive'}
|
${'1.2.3'} | ${'7.2'} | ${'win32'} | ${'Add-Tool https://github.com/phar-io/phive/releases/download/0.14.5/phive-0.14.5.phar phive'}
|
||||||
@ -240,15 +244,15 @@ describe('Tools tests', () => {
|
|||||||
${'latest'} | ${'5.6'} | ${'win32'} | ${'Add-Tool https://github.com/phar-io/phive/releases/download/0.12.1/phive-0.12.1.phar phive'}
|
${'latest'} | ${'5.6'} | ${'win32'} | ${'Add-Tool https://github.com/phar-io/phive/releases/download/0.12.1/phive-0.12.1.phar phive'}
|
||||||
${'latest'} | ${'5.5'} | ${'win32'} | ${'Phive is not supported on PHP 5.5'}
|
${'latest'} | ${'5.5'} | ${'win32'} | ${'Phive is not supported on PHP 5.5'}
|
||||||
`(
|
`(
|
||||||
'checking addPhive: $version, $php_version, $os_version',
|
'checking addPhive: $version, $php_version, $os',
|
||||||
async ({version, php_version, os_version, script}) => {
|
async ({version, php_version, os, script}) => {
|
||||||
const data = getData({
|
const data = getData({
|
||||||
tool: 'phive',
|
tool: 'phive',
|
||||||
repository: 'phar-io/phive',
|
repository: 'phar-io/phive',
|
||||||
version_parameter: 'status',
|
version_parameter: 'status',
|
||||||
version: version,
|
version: version,
|
||||||
php_version: php_version,
|
php_version: php_version,
|
||||||
os_version: os_version
|
os: os
|
||||||
});
|
});
|
||||||
script = await tools.addPhive(data);
|
script = await tools.addPhive(data);
|
||||||
expect(script).toContain(script);
|
expect(script).toContain(script);
|
||||||
@ -318,28 +322,6 @@ describe('Tools tests', () => {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
it.each`
|
|
||||||
version | os_version | uri
|
|
||||||
${'latest'} | ${'linux'} | ${'releases/latest/download/symfony_linux_amd64'}
|
|
||||||
${'1.2.3'} | ${'linux'} | ${'releases/download/v1.2.3/symfony_linux_amd64'}
|
|
||||||
${'latest'} | ${'darwin'} | ${'releases/latest/download/symfony_darwin_amd64'}
|
|
||||||
${'1.2.3'} | ${'darwin'} | ${'releases/download/v1.2.3/symfony_darwin_amd64'}
|
|
||||||
${'latest'} | ${'win32'} | ${'releases/latest/download/symfony_windows_amd64.exe'}
|
|
||||||
${'1.2.3'} | ${'win32'} | ${'releases/download/v1.2.3/symfony_windows_amd64.exe'}
|
|
||||||
${'latest'} | ${'openbsd'} | ${'Platform openbsd is not supported'}
|
|
||||||
`(
|
|
||||||
'checking addSymfony: $version, $os_version',
|
|
||||||
async ({version, os_version, uri}) => {
|
|
||||||
const data = getData({
|
|
||||||
tool: 'symfony',
|
|
||||||
php_version: '7.4',
|
|
||||||
version: version,
|
|
||||||
os_version: os_version
|
|
||||||
});
|
|
||||||
expect(await tools.addSymfony(data)).toContain(uri);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
it.each`
|
it.each`
|
||||||
version | uri
|
version | uri
|
||||||
${'latest'} | ${'wp-cli/builds/blob/gh-pages/phar/wp-cli.phar?raw=true'}
|
${'latest'} | ${'wp-cli/builds/blob/gh-pages/phar/wp-cli.phar?raw=true'}
|
||||||
@ -356,7 +338,7 @@ describe('Tools tests', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it.each`
|
it.each`
|
||||||
tool | os_version | script
|
tool | os | script
|
||||||
${'phpize'} | ${'linux'} | ${'add_devtools phpize'}
|
${'phpize'} | ${'linux'} | ${'add_devtools phpize'}
|
||||||
${'php-config'} | ${'linux'} | ${'add_devtools php-config'}
|
${'php-config'} | ${'linux'} | ${'add_devtools php-config'}
|
||||||
${'phpize'} | ${'darwin'} | ${'add_devtools phpize'}
|
${'phpize'} | ${'darwin'} | ${'add_devtools phpize'}
|
||||||
@ -364,25 +346,23 @@ describe('Tools tests', () => {
|
|||||||
${'phpize'} | ${'win32'} | ${'Add-Log "$tick" "phpize" "phpize is not a windows tool"'}
|
${'phpize'} | ${'win32'} | ${'Add-Log "$tick" "phpize" "phpize is not a windows tool"'}
|
||||||
${'php-config'} | ${'win32'} | ${'Add-Log "$tick" "php-config" "php-config is not a windows tool"'}
|
${'php-config'} | ${'win32'} | ${'Add-Log "$tick" "php-config" "php-config is not a windows tool"'}
|
||||||
${'phpize'} | ${'openbsd'} | ${'Platform openbsd is not supported'}
|
${'phpize'} | ${'openbsd'} | ${'Platform openbsd is not supported'}
|
||||||
`(
|
`('checking addDevTools: $tool, $os', async ({tool, os, script}) => {
|
||||||
'checking addDevTools: $tool, $os_version',
|
const data = getData({
|
||||||
async ({tool, os_version, script}) => {
|
version: '7.4',
|
||||||
const data = getData({
|
tool: tool,
|
||||||
version: '7.4',
|
os: os
|
||||||
tool: tool,
|
});
|
||||||
os_version: os_version
|
expect(await tools.addDevTools(data)).toContain(script);
|
||||||
});
|
});
|
||||||
expect(await tools.addDevTools(data)).toContain(script);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
it.each([
|
it.each([
|
||||||
[
|
[
|
||||||
'blackfire, blackfire-player, cs2pr, flex, grpc_php_plugin, parallel-lint, php-cs-fixer, phpDocumentor, phplint, phpstan, phpunit, pecl, phing, phinx, phinx:1.2.3, phive, phpunit-bridge, phpunit-polyfills, php-config, phpize, protoc, symfony, vapor, wp',
|
'blackfire, blackfire-player, churn, cs2pr, flex, grpc_php_plugin, parallel-lint, php-cs-fixer, phpDocumentor, phplint, phpstan, phpunit, pecl, phing, phinx, phinx:1.2.3, phive, phpunit-bridge, phpunit-polyfills, php-config, phpize, protoc, symfony, vapor, wp',
|
||||||
[
|
[
|
||||||
'add_tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-7.4-stable.phar,https://getcomposer.org/composer-stable.phar composer',
|
'add_tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-7.4-stable.phar,https://getcomposer.org/composer-stable.phar composer',
|
||||||
'add_blackfire',
|
'add_blackfire',
|
||||||
'add_tool https://get.blackfire.io/blackfire-player.phar blackfire-player "-V"',
|
'add_tool https://get.blackfire.io/blackfire-player.phar blackfire-player "-V"',
|
||||||
|
'add_tool https://github.com/bmitch/churn-php/releases/latest/download/churn.phar churn "-V"',
|
||||||
'add_tool https://github.com/staabm/annotate-pull-request-from-checkstyle/releases/latest/download/cs2pr cs2pr "-V"',
|
'add_tool https://github.com/staabm/annotate-pull-request-from-checkstyle/releases/latest/download/cs2pr cs2pr "-V"',
|
||||||
'add_composertool flex flex symfony/ global',
|
'add_composertool flex flex symfony/ global',
|
||||||
'add_grpc_php_plugin latest',
|
'add_grpc_php_plugin latest',
|
||||||
@ -402,7 +382,7 @@ describe('Tools tests', () => {
|
|||||||
'add_devtools php-config',
|
'add_devtools php-config',
|
||||||
'add_devtools phpize',
|
'add_devtools phpize',
|
||||||
'add_protoc latest',
|
'add_protoc latest',
|
||||||
'add_tool https://github.com/symfony/cli/releases/latest/download/symfony_linux_amd64 symfony-cli "version"',
|
'add_symfony latest',
|
||||||
'add_composertool vapor-cli vapor-cli laravel/ scoped',
|
'add_composertool vapor-cli vapor-cli laravel/ scoped',
|
||||||
'add_tool https://github.com/wp-cli/builds/blob/gh-pages/phar/wp-cli.phar?raw=true wp-cli "--version"'
|
'add_tool https://github.com/wp-cli/builds/blob/gh-pages/phar/wp-cli.phar?raw=true wp-cli "--version"'
|
||||||
]
|
]
|
||||||
@ -416,12 +396,13 @@ describe('Tools tests', () => {
|
|||||||
|
|
||||||
it.each([
|
it.each([
|
||||||
[
|
[
|
||||||
'behat, blackfire, blackfire-player, composer-normalize, composer-require-checker, composer-unused, cs2pr:1.2.3, flex, grpc_php_plugin:1.2.3, infection, phan, phan:1.2.3, phing:1.2.3, phinx, phive:1.2.3, php-config, phpcbf, phpcpd, phpcs, phpdoc, phpize, phpmd, phpspec, phpunit-bridge:5.6, phpunit-polyfills:1.0.1, protoc:v1.2.3, psalm, symfony-cli, symfony:1.2.3, vapor-cli, wp-cli',
|
'behat, blackfire, blackfire-player, churn, composer-normalize, composer-require-checker, composer-unused, cs2pr:1.2.3, flex, grpc_php_plugin:1.2.3, infection, phan, phan:1.2.3, phing:1.2.3, phinx, phive:1.2.3, php-config, phpcbf, phpcpd, phpcs, phpdoc, phpize, phpmd, phpspec, phpunit-bridge:5.6, phpunit-polyfills:1.0.1, protoc:v1.2.3, psalm, symfony-cli, vapor-cli, wp-cli',
|
||||||
[
|
[
|
||||||
'add_tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-7.4-stable.phar,https://getcomposer.org/composer-stable.phar composer',
|
'add_tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-7.4-stable.phar,https://getcomposer.org/composer-stable.phar composer',
|
||||||
'add_composertool behat behat behat/ scoped',
|
'add_composertool behat behat behat/ scoped',
|
||||||
'add_blackfire',
|
'add_blackfire',
|
||||||
'add_tool https://get.blackfire.io/blackfire-player.phar blackfire-player "-V"',
|
'add_tool https://get.blackfire.io/blackfire-player.phar blackfire-player "-V"',
|
||||||
|
'add_tool https://github.com/bmitch/churn-php/releases/latest/download/churn.phar churn "-V"',
|
||||||
'add_tool https://github.com/ergebnis/composer-normalize/releases/latest/download/composer-normalize.phar composer-normalize "-V"',
|
'add_tool https://github.com/ergebnis/composer-normalize/releases/latest/download/composer-normalize.phar composer-normalize "-V"',
|
||||||
'add_composertool composer-require-checker composer-require-checker maglnet/ scoped',
|
'add_composertool composer-require-checker composer-require-checker maglnet/ scoped',
|
||||||
'add_composertool composer-unused composer-unused icanhazstring/ scoped',
|
'add_composertool composer-unused composer-unused icanhazstring/ scoped',
|
||||||
@ -431,7 +412,7 @@ describe('Tools tests', () => {
|
|||||||
'add_tool https://github.com/infection/infection/releases/latest/download/infection.phar infection "-V"',
|
'add_tool https://github.com/infection/infection/releases/latest/download/infection.phar infection "-V"',
|
||||||
'add_tool https://github.com/phan/phan/releases/latest/download/phan.phar phan "-v"',
|
'add_tool https://github.com/phan/phan/releases/latest/download/phan.phar phan "-v"',
|
||||||
'add_tool https://github.com/phan/phan/releases/download/1.2.3/phan.phar phan "-v"',
|
'add_tool https://github.com/phan/phan/releases/download/1.2.3/phan.phar phan "-v"',
|
||||||
'add_tool https://www.phing.info/get/phing-1.2.3.phar phing "-v"',
|
'add_tool https://www.phing.info/get/phing-1.2.3.phar,https://github.com/phingofficial/phing/releases/download/1.2.3/phing-1.2.3.phar phing "-v"',
|
||||||
'add_composertool phinx phinx robmorgan/ scoped',
|
'add_composertool phinx phinx robmorgan/ scoped',
|
||||||
'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',
|
||||||
'add_devtools php-config',
|
'add_devtools php-config',
|
||||||
@ -446,8 +427,7 @@ describe('Tools tests', () => {
|
|||||||
'add_composertool phpunit-polyfills phpunit-polyfills:1.0.1 yoast/ global',
|
'add_composertool phpunit-polyfills phpunit-polyfills:1.0.1 yoast/ global',
|
||||||
'add_protoc 1.2.3',
|
'add_protoc 1.2.3',
|
||||||
'add_tool https://github.com/vimeo/psalm/releases/latest/download/psalm.phar psalm "-v"',
|
'add_tool https://github.com/vimeo/psalm/releases/latest/download/psalm.phar psalm "-v"',
|
||||||
'add_tool https://github.com/symfony/cli/releases/latest/download/symfony_darwin_amd64 symfony-cli "version"',
|
'add_symfony latest',
|
||||||
'add_tool https://github.com/symfony/cli/releases/download/v1.2.3/symfony_darwin_amd64 symfony-cli "version"',
|
|
||||||
'add_composertool vapor-cli vapor-cli laravel/ scoped',
|
'add_composertool vapor-cli vapor-cli laravel/ scoped',
|
||||||
'add_tool https://github.com/wp-cli/builds/blob/gh-pages/phar/wp-cli.phar?raw=true wp-cli "--version"'
|
'add_tool https://github.com/wp-cli/builds/blob/gh-pages/phar/wp-cli.phar?raw=true wp-cli "--version"'
|
||||||
]
|
]
|
||||||
@ -461,12 +441,13 @@ describe('Tools tests', () => {
|
|||||||
|
|
||||||
it.each([
|
it.each([
|
||||||
[
|
[
|
||||||
'blackfire, blackfire-player:1.2.3, cs2pr, deployer, does_not_exist, flex, phinx, phive:0.13.2, php-config, phpize, phpmd, simple-phpunit, symfony, wp',
|
'blackfire, blackfire-player:1.2.3, cs2pr, churn, deployer, does_not_exist, flex, phinx, phive:0.13.2, php-config, phpize, phpmd, simple-phpunit, symfony, wp',
|
||||||
[
|
[
|
||||||
'Add-Tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-7.4-stable.phar,https://getcomposer.org/composer-stable.phar composer',
|
'Add-Tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-7.4-stable.phar,https://getcomposer.org/composer-stable.phar composer',
|
||||||
'Add-Blackfire',
|
'Add-Blackfire',
|
||||||
'Add-Tool https://get.blackfire.io/blackfire-player-v1.2.3.phar blackfire-player "-V"',
|
'Add-Tool https://get.blackfire.io/blackfire-player-v1.2.3.phar blackfire-player "-V"',
|
||||||
'Add-Tool https://github.com/staabm/annotate-pull-request-from-checkstyle/releases/latest/download/cs2pr cs2pr "-V"',
|
'Add-Tool https://github.com/staabm/annotate-pull-request-from-checkstyle/releases/latest/download/cs2pr cs2pr "-V"',
|
||||||
|
'Add-Tool https://github.com/bmitch/churn-php/releases/latest/download/churn.phar churn "-V"',
|
||||||
'Add-Tool https://deployer.org/deployer.phar deployer "-V"',
|
'Add-Tool https://deployer.org/deployer.phar deployer "-V"',
|
||||||
'Tool does_not_exist is not supported',
|
'Tool does_not_exist is not supported',
|
||||||
'Add-Composertool flex flex symfony/ global',
|
'Add-Composertool flex flex symfony/ global',
|
||||||
@ -476,7 +457,7 @@ describe('Tools tests', () => {
|
|||||||
'phpize is not a windows tool',
|
'phpize is not a windows tool',
|
||||||
'Add-Tool https://github.com/phpmd/phpmd/releases/latest/download/phpmd.phar phpmd "--version"',
|
'Add-Tool https://github.com/phpmd/phpmd/releases/latest/download/phpmd.phar phpmd "--version"',
|
||||||
'Add-Composertool phpunit-bridge phpunit-bridge symfony/ global',
|
'Add-Composertool phpunit-bridge phpunit-bridge symfony/ global',
|
||||||
'Add-Tool https://github.com/symfony/cli/releases/latest/download/symfony_windows_amd64.exe symfony-cli "version"',
|
'Add-Symfony',
|
||||||
'Add-Tool https://github.com/wp-cli/builds/blob/gh-pages/phar/wp-cli.phar?raw=true wp-cli "--version"'
|
'Add-Tool https://github.com/wp-cli/builds/blob/gh-pages/phar/wp-cli.phar?raw=true wp-cli "--version"'
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
|
@ -1,20 +1,23 @@
|
|||||||
import * as fs from 'fs';
|
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import * as utils from '../src/utils';
|
import * as utils from '../src/utils';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mock @actions/core
|
||||||
|
*/
|
||||||
jest.mock('@actions/core', () => ({
|
jest.mock('@actions/core', () => ({
|
||||||
getInput: jest.fn().mockImplementation(key => {
|
getInput: jest.fn().mockImplementation(key => {
|
||||||
return ['setup-php'].indexOf(key) !== -1 ? key : '';
|
return ['setup-php'].indexOf(key) !== -1 ? key : '';
|
||||||
})
|
})
|
||||||
}));
|
}));
|
||||||
|
|
||||||
async function cleanup(path: string): Promise<void> {
|
/**
|
||||||
fs.unlink(path, error => {
|
* Mock fetch.ts
|
||||||
if (error) {
|
*/
|
||||||
console.log(error);
|
jest.mock('../src/fetch', () => ({
|
||||||
}
|
fetch: jest.fn().mockImplementation(() => {
|
||||||
});
|
return {data: '{ "latest": "8.1", "5.x": "5.6" }'};
|
||||||
}
|
})
|
||||||
|
}));
|
||||||
|
|
||||||
describe('Utils tests', () => {
|
describe('Utils tests', () => {
|
||||||
it('checking readEnv', async () => {
|
it('checking readEnv', async () => {
|
||||||
@ -37,33 +40,11 @@ describe('Utils tests', () => {
|
|||||||
}).rejects.toThrow('Input required and not supplied: DoesNotExist');
|
}).rejects.toThrow('Input required and not supplied: DoesNotExist');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('checking fetch', async () => {
|
|
||||||
const manifest = await utils.getManifestURL();
|
|
||||||
let response: Record<string, string> = await utils.fetch(manifest);
|
|
||||||
expect(response.error).toBe(undefined);
|
|
||||||
expect(response.data).toContain('latest');
|
|
||||||
|
|
||||||
response = await utils.fetch(manifest, 'invalid_token');
|
|
||||||
expect(response.error).not.toBe(undefined);
|
|
||||||
expect(response.data).toBe(undefined);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('checking getManifestURL', async () => {
|
it('checking getManifestURL', async () => {
|
||||||
expect(await utils.getManifestURL()).toContain('php-versions.json');
|
expect(await utils.getManifestURL()).toContain('php-versions.json');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('checking parseVersion', async () => {
|
it('checking parseVersion', async () => {
|
||||||
jest
|
|
||||||
.spyOn(utils, 'fetch')
|
|
||||||
.mockImplementation(
|
|
||||||
async (url, token?): Promise<Record<string, string>> => {
|
|
||||||
if (!token || token === 'valid_token') {
|
|
||||||
return {data: `{ "latest": "8.0", "5.x": "5.6", "url": "${url}" }`};
|
|
||||||
} else {
|
|
||||||
return {error: 'Invalid token'};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
expect(await utils.parseVersion('latest')).toBe('8.1');
|
expect(await utils.parseVersion('latest')).toBe('8.1');
|
||||||
expect(await utils.parseVersion('7')).toBe('7.0');
|
expect(await utils.parseVersion('7')).toBe('7.0');
|
||||||
expect(await utils.parseVersion('7.4')).toBe('7.4');
|
expect(await utils.parseVersion('7.4')).toBe('7.4');
|
||||||
@ -71,6 +52,15 @@ describe('Utils tests', () => {
|
|||||||
expect(await utils.parseVersion('4.x')).toBe(undefined);
|
expect(await utils.parseVersion('4.x')).toBe(undefined);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('checking parseIniFile', async () => {
|
||||||
|
expect(await utils.parseIniFile('production')).toBe('production');
|
||||||
|
expect(await utils.parseIniFile('development')).toBe('development');
|
||||||
|
expect(await utils.parseIniFile('none')).toBe('none');
|
||||||
|
expect(await utils.parseIniFile('php.ini-production')).toBe('production');
|
||||||
|
expect(await utils.parseIniFile('php.ini-development')).toBe('development');
|
||||||
|
expect(await utils.parseIniFile('invalid')).toBe('production');
|
||||||
|
});
|
||||||
|
|
||||||
it('checking asyncForEach', async () => {
|
it('checking asyncForEach', async () => {
|
||||||
const array: Array<string> = ['a', 'b', 'c'];
|
const array: Array<string> = ['a', 'b', 'c'];
|
||||||
let concat = '';
|
let concat = '';
|
||||||
@ -90,41 +80,6 @@ describe('Utils tests', () => {
|
|||||||
expect(await utils.color('warning')).toBe('33');
|
expect(await utils.color('warning')).toBe('33');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('checking readFile', async () => {
|
|
||||||
const darwin: string = fs.readFileSync(
|
|
||||||
path.join(__dirname, '../src/scripts/darwin.sh'),
|
|
||||||
'utf8'
|
|
||||||
);
|
|
||||||
const linux: string = fs.readFileSync(
|
|
||||||
path.join(__dirname, '../src/scripts/linux.sh'),
|
|
||||||
'utf8'
|
|
||||||
);
|
|
||||||
const win32: string = fs.readFileSync(
|
|
||||||
path.join(__dirname, '../src/scripts/win32.ps1'),
|
|
||||||
'utf8'
|
|
||||||
);
|
|
||||||
expect(await utils.readFile('darwin.sh', 'src/scripts')).toBe(darwin);
|
|
||||||
expect(await utils.readFile('darwin.sh', 'src/scripts')).toBe(darwin);
|
|
||||||
expect(await utils.readFile('linux.sh', 'src/scripts')).toBe(linux);
|
|
||||||
expect(await utils.readFile('linux.sh', 'src/scripts')).toBe(linux);
|
|
||||||
expect(await utils.readFile('win32.ps1', 'src/scripts')).toBe(win32);
|
|
||||||
expect(await utils.readFile('win32.ps1', 'src/scripts')).toBe(win32);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('checking writeScripts', async () => {
|
|
||||||
const testString = 'sudo apt-get install php';
|
|
||||||
const runner_dir: string = process.env['RUNNER_TOOL_CACHE'] || '';
|
|
||||||
const script_path: string = path.join(runner_dir, 'test.sh');
|
|
||||||
await utils.writeScript('test.sh', testString);
|
|
||||||
await fs.readFile(
|
|
||||||
script_path,
|
|
||||||
function (error: Error | null, data: Buffer) {
|
|
||||||
expect(testString).toBe(data.toString());
|
|
||||||
}
|
|
||||||
);
|
|
||||||
await cleanup(script_path);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('checking extensionArray', async () => {
|
it('checking extensionArray', async () => {
|
||||||
expect(
|
expect(
|
||||||
await utils.extensionArray('a, :b, php_c, none, php-d, Zend e, :Zend f')
|
await utils.extensionArray('a, :b, php_c, none, php-d, Zend e, :Zend f')
|
||||||
@ -254,9 +209,9 @@ describe('Utils tests', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('checking scriptTool', async () => {
|
it('checking scriptTool', async () => {
|
||||||
expect(await utils.scriptTool('linux')).toBe('bash');
|
expect(await utils.scriptTool('linux')).toBe('bash ');
|
||||||
expect(await utils.scriptTool('darwin')).toBe('bash');
|
expect(await utils.scriptTool('darwin')).toBe('bash ');
|
||||||
expect(await utils.scriptTool('win32')).toBe('pwsh');
|
expect(await utils.scriptTool('win32')).toBe('pwsh ');
|
||||||
expect(await utils.scriptTool('openbsd')).toContain(
|
expect(await utils.scriptTool('openbsd')).toContain(
|
||||||
'Platform openbsd is not supported'
|
'Platform openbsd is not supported'
|
||||||
);
|
);
|
||||||
|
@ -12,6 +12,10 @@ inputs:
|
|||||||
extensions:
|
extensions:
|
||||||
description: 'Setup PHP extensions.'
|
description: 'Setup PHP extensions.'
|
||||||
required: false
|
required: false
|
||||||
|
ini-file:
|
||||||
|
description: 'Set base ini file.'
|
||||||
|
default: 'production'
|
||||||
|
required: false
|
||||||
ini-values:
|
ini-values:
|
||||||
description: 'Add values to php.ini.'
|
description: 'Add values to php.ini.'
|
||||||
required: false
|
required: false
|
||||||
|
451
dist/index.js
vendored
451
dist/index.js
vendored
@ -8,7 +8,11 @@
|
|||||||
|
|
||||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||||
if (k2 === undefined) k2 = k;
|
if (k2 === undefined) k2 = k;
|
||||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||||
|
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||||
|
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||||
|
}
|
||||||
|
Object.defineProperty(o, k2, desc);
|
||||||
}) : (function(o, m, k, k2) {
|
}) : (function(o, m, k, k2) {
|
||||||
if (k2 === undefined) k2 = k;
|
if (k2 === undefined) k2 = k;
|
||||||
o[k2] = m[k];
|
o[k2] = m[k];
|
||||||
@ -51,28 +55,28 @@ async function addINIValuesWindows(ini_values_csv) {
|
|||||||
return ('Add-Content "$php_dir\\php.ini" "' + ini_values.join('\n') + '"' + script);
|
return ('Add-Content "$php_dir\\php.ini" "' + ini_values.join('\n') + '"' + script);
|
||||||
}
|
}
|
||||||
exports.addINIValuesWindows = addINIValuesWindows;
|
exports.addINIValuesWindows = addINIValuesWindows;
|
||||||
async function addINIValues(ini_values_csv, os_version, no_step = false) {
|
async function addINIValues(ini_values_csv, os, no_step = false) {
|
||||||
let script = '\n';
|
let script = '\n';
|
||||||
switch (no_step) {
|
switch (no_step) {
|
||||||
case true:
|
case true:
|
||||||
script +=
|
script +=
|
||||||
(await utils.stepLog('Add php.ini values', os_version)) +
|
(await utils.stepLog('Add php.ini values', os)) +
|
||||||
(await utils.suppressOutput(os_version)) +
|
(await utils.suppressOutput(os)) +
|
||||||
'\n';
|
'\n';
|
||||||
break;
|
break;
|
||||||
case false:
|
case false:
|
||||||
default:
|
default:
|
||||||
script += (await utils.stepLog('Add php.ini values', os_version)) + '\n';
|
script += (await utils.stepLog('Add php.ini values', os)) + '\n';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
switch (os_version) {
|
switch (os) {
|
||||||
case 'win32':
|
case 'win32':
|
||||||
return script + (await addINIValuesWindows(ini_values_csv));
|
return script + (await addINIValuesWindows(ini_values_csv));
|
||||||
case 'darwin':
|
case 'darwin':
|
||||||
case 'linux':
|
case 'linux':
|
||||||
return script + (await addINIValuesUnix(ini_values_csv));
|
return script + (await addINIValuesUnix(ini_values_csv));
|
||||||
default:
|
default:
|
||||||
return await utils.log('Platform ' + os_version + ' is not supported', os_version, 'error');
|
return await utils.log('Platform ' + os + ' is not supported', os, 'error');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.addINIValues = addINIValues;
|
exports.addINIValues = addINIValues;
|
||||||
@ -87,7 +91,11 @@ exports.addINIValues = addINIValues;
|
|||||||
|
|
||||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||||
if (k2 === undefined) k2 = k;
|
if (k2 === undefined) k2 = k;
|
||||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||||
|
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||||
|
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||||
|
}
|
||||||
|
Object.defineProperty(o, k2, desc);
|
||||||
}) : (function(o, m, k, k2) {
|
}) : (function(o, m, k, k2) {
|
||||||
if (k2 === undefined) k2 = k;
|
if (k2 === undefined) k2 = k;
|
||||||
o[k2] = m[k];
|
o[k2] = m[k];
|
||||||
@ -117,69 +125,65 @@ async function checkXdebugError(extension, version) {
|
|||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
exports.checkXdebugError = checkXdebugError;
|
exports.checkXdebugError = checkXdebugError;
|
||||||
async function addCoverageXdebug(extension, version, os_version, pipe) {
|
async function addCoverageXdebug(extension, version, os, pipe) {
|
||||||
let script = '\n';
|
let script = '\n';
|
||||||
let message = await checkXdebugError(extension, version);
|
let message = await checkXdebugError(extension, version);
|
||||||
let status = '$cross';
|
let status = '$cross';
|
||||||
if (!message) {
|
if (!message) {
|
||||||
script +=
|
script +=
|
||||||
(await extensions.addExtension(':pcov:false', version, os_version, true)) + pipe;
|
(await extensions.addExtension(':pcov:false', version, os, true)) + pipe;
|
||||||
extension = extension == 'xdebug3' ? 'xdebug' : extension;
|
extension = extension == 'xdebug3' ? 'xdebug' : extension;
|
||||||
script +=
|
script +=
|
||||||
(await extensions.addExtension(extension, version, os_version, true)) +
|
(await extensions.addExtension(extension, version, os, true)) + pipe;
|
||||||
pipe;
|
|
||||||
message = 'Xdebug enabled as coverage driver';
|
message = 'Xdebug enabled as coverage driver';
|
||||||
status = '$tick';
|
status = '$tick';
|
||||||
}
|
}
|
||||||
script += await utils.addLog(status, extension, message, os_version);
|
script += await utils.addLog(status, extension, message, os);
|
||||||
return script;
|
return script;
|
||||||
}
|
}
|
||||||
exports.addCoverageXdebug = addCoverageXdebug;
|
exports.addCoverageXdebug = addCoverageXdebug;
|
||||||
async function addCoveragePCOV(version, os_version, pipe) {
|
async function addCoveragePCOV(version, os, pipe) {
|
||||||
let script = '\n';
|
let script = '\n';
|
||||||
switch (true) {
|
switch (true) {
|
||||||
default:
|
default:
|
||||||
script +=
|
script +=
|
||||||
(await extensions.addExtension(':xdebug:false', version, os_version, true)) + pipe;
|
(await extensions.addExtension(':xdebug:false', version, os, true)) +
|
||||||
script +=
|
|
||||||
(await extensions.addExtension('pcov', version, os_version, true)) +
|
|
||||||
pipe;
|
pipe;
|
||||||
script +=
|
script +=
|
||||||
(await config.addINIValues('pcov.enabled=1', os_version, true)) + '\n';
|
(await extensions.addExtension('pcov', version, os, true)) + pipe;
|
||||||
script += await utils.addLog('$tick', 'coverage: pcov', 'PCOV enabled as coverage driver', os_version);
|
script += (await config.addINIValues('pcov.enabled=1', os, true)) + '\n';
|
||||||
|
script += await utils.addLog('$tick', 'coverage: pcov', 'PCOV enabled as coverage driver', os);
|
||||||
break;
|
break;
|
||||||
case /5\.[3-6]|7\.0/.test(version):
|
case /5\.[3-6]|7\.0/.test(version):
|
||||||
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);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return script;
|
return script;
|
||||||
}
|
}
|
||||||
exports.addCoveragePCOV = addCoveragePCOV;
|
exports.addCoveragePCOV = addCoveragePCOV;
|
||||||
async function disableCoverage(version, os_version, pipe) {
|
async function disableCoverage(version, os, pipe) {
|
||||||
let script = '\n';
|
let script = '\n';
|
||||||
script +=
|
script +=
|
||||||
(await extensions.addExtension(':pcov:false', version, os_version, true)) +
|
(await extensions.addExtension(':pcov:false', version, os, true)) + pipe;
|
||||||
pipe;
|
|
||||||
script +=
|
script +=
|
||||||
(await extensions.addExtension(':xdebug:false', version, os_version, true)) + pipe;
|
(await extensions.addExtension(':xdebug:false', version, os, true)) + pipe;
|
||||||
script += await utils.addLog('$tick', 'none', 'Disabled Xdebug and PCOV', os_version);
|
script += await utils.addLog('$tick', 'none', 'Disabled Xdebug and PCOV', os);
|
||||||
return script;
|
return script;
|
||||||
}
|
}
|
||||||
exports.disableCoverage = disableCoverage;
|
exports.disableCoverage = disableCoverage;
|
||||||
async function addCoverage(coverage_driver, version, os_version) {
|
async function addCoverage(coverage_driver, version, os) {
|
||||||
coverage_driver = coverage_driver.toLowerCase();
|
coverage_driver = coverage_driver.toLowerCase();
|
||||||
const script = '\n' + (await utils.stepLog('Setup Coverage', os_version));
|
const script = '\n' + (await utils.stepLog('Setup Coverage', os));
|
||||||
const pipe = (await utils.suppressOutput(os_version)) + '\n';
|
const pipe = (await utils.suppressOutput(os)) + '\n';
|
||||||
switch (coverage_driver) {
|
switch (coverage_driver) {
|
||||||
case 'pcov':
|
case 'pcov':
|
||||||
return script + (await addCoveragePCOV(version, os_version, pipe));
|
return script + (await addCoveragePCOV(version, os, pipe));
|
||||||
case 'xdebug':
|
case 'xdebug':
|
||||||
case 'xdebug2':
|
case 'xdebug2':
|
||||||
case 'xdebug3':
|
case 'xdebug3':
|
||||||
return (script +
|
return (script + (await addCoverageXdebug(coverage_driver, version, os, pipe)));
|
||||||
(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, pipe));
|
||||||
default:
|
default:
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
@ -196,7 +200,11 @@ exports.addCoverage = addCoverage;
|
|||||||
|
|
||||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||||
if (k2 === undefined) k2 = k;
|
if (k2 === undefined) k2 = k;
|
||||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||||
|
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||||
|
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||||
|
}
|
||||||
|
Object.defineProperty(o, k2, desc);
|
||||||
}) : (function(o, m, k, k2) {
|
}) : (function(o, m, k, k2) {
|
||||||
if (k2 === undefined) k2 = k;
|
if (k2 === undefined) k2 = k;
|
||||||
o[k2] = m[k];
|
o[k2] = m[k];
|
||||||
@ -238,7 +246,8 @@ async function addExtensionDarwin(extension_csv, version) {
|
|||||||
case /^couchbase$|^geos$|^pdo_oci$|^oci8$|^(pecl_)?http|^pdo_firebird$/.test(extension):
|
case /^couchbase$|^geos$|^pdo_oci$|^oci8$|^(pecl_)?http|^pdo_firebird$/.test(extension):
|
||||||
case /^(5\.[3-6]|7\.[0-4])ioncube$/.test(version_extension):
|
case /^(5\.[3-6]|7\.[0-4])ioncube$/.test(version_extension):
|
||||||
case /(5\.6|7\.[0-3])phalcon3|7\.[2-4]phalcon4/.test(version_extension):
|
case /(5\.6|7\.[0-3])phalcon3|7\.[2-4]phalcon4/.test(version_extension):
|
||||||
add_script += await utils.customPackage(ext_name, 'ext', extension, 'darwin');
|
case /(?<!5\.[3-6])(pdo_)?sqlsrv$/.test(version_extension):
|
||||||
|
add_script += await utils.customPackage(ext_name, 'extensions', extension, 'darwin');
|
||||||
return;
|
return;
|
||||||
case /.+-(stable|beta|alpha|devel|snapshot|rc|preview)/.test(extension):
|
case /.+-(stable|beta|alpha|devel|snapshot|rc|preview)/.test(extension):
|
||||||
add_script += await utils.joins('\nadd_unstable_extension', ext_name, ext_version, ext_prefix);
|
add_script += await utils.joins('\nadd_unstable_extension', ext_name, ext_version, ext_prefix);
|
||||||
@ -249,7 +258,7 @@ async function addExtensionDarwin(extension_csv, version) {
|
|||||||
case /(5\.[3-6]|7\.0)pcov/.test(version_extension):
|
case /(5\.[3-6]|7\.0)pcov/.test(version_extension):
|
||||||
add_script += await utils.getUnsupportedLog('pcov', version, 'darwin');
|
add_script += await utils.getUnsupportedLog('pcov', version, 'darwin');
|
||||||
return;
|
return;
|
||||||
case /(?<!5\.[3-5])(amqp|apcu|expect|grpc|igbinary|imagick|imap|mailparse|memcache|memcached|mongodb|msgpack|protobuf|psr|raphf|rdkafka|redis|ssh2|swoole|xdebug|xdebug2|yaml|zmq)/.test(version_extension):
|
case /(?<!5\.[3-5])(amqp|apcu|expect|gnupg|grpc|igbinary|imagick|imap|mailparse|mcrypt|memcache|memcached|mongodb|msgpack|protobuf|psr|raphf|rdkafka|redis|ssh2|swoole|xdebug|xdebug2|yaml|zmq)/.test(version_extension):
|
||||||
case /(5\.6|7\.[0-4])propro/.test(version_extension):
|
case /(5\.6|7\.[0-4])propro/.test(version_extension):
|
||||||
case /(?<!5\.[3-6]|7\.0)pcov/.test(version_extension):
|
case /(?<!5\.[3-6]|7\.0)pcov/.test(version_extension):
|
||||||
case /(?<!5\.[3-6])(vips|xlswriter)/.test(version_extension):
|
case /(?<!5\.[3-6])(vips|xlswriter)/.test(version_extension):
|
||||||
@ -281,12 +290,12 @@ async function addExtensionWindows(extension_csv, version) {
|
|||||||
case /^none$/.test(ext_name):
|
case /^none$/.test(ext_name):
|
||||||
add_script += '\nDisable-AllShared';
|
add_script += '\nDisable-AllShared';
|
||||||
break;
|
break;
|
||||||
case /^(5\.[3-6]|7\.[0-4]|8\.0)blackfire(-\d+\.\d+\.\d+)?$/.test(version_extension):
|
case /^(5\.[3-6]|7\.[0-4]|8\.1)blackfire(-\d+\.\d+\.\d+)?$/.test(version_extension):
|
||||||
case /^pdo_oci$|^oci8$|^pdo_firebird$/.test(extension):
|
case /^pdo_oci$|^oci8$|^pdo_firebird$/.test(extension):
|
||||||
case /^(5\.[3-6]|7\.[0-4])ioncube$/.test(version_extension):
|
case /^(5\.[3-6]|7\.[0-4])ioncube$/.test(version_extension):
|
||||||
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
|
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
|
||||||
case /^(7\.[1-4]|8\.0)(pecl_)?http/.test(version_extension):
|
case /^(7\.[1-4]|8\.1)(pecl_)?http/.test(version_extension):
|
||||||
add_script += await utils.customPackage(ext_name, 'ext', extension, 'win32');
|
add_script += await utils.customPackage(ext_name, 'extensions', extension, 'win32');
|
||||||
return;
|
return;
|
||||||
case /.+-(stable|beta|alpha|devel|snapshot)/.test(extension):
|
case /.+-(stable|beta|alpha|devel|snapshot)/.test(extension):
|
||||||
add_script += await utils.joins('\nAdd-Extension', ext_name, ext_version.replace('stable', ''));
|
add_script += await utils.joins('\nAdd-Extension', ext_name, ext_version.replace('stable', ''));
|
||||||
@ -352,7 +361,8 @@ async function addExtensionLinux(extension_csv, version) {
|
|||||||
case /(?<!5\.[3-5])intl-[\d]+\.[\d]+$/.test(version_extension):
|
case /(?<!5\.[3-5])intl-[\d]+\.[\d]+$/.test(version_extension):
|
||||||
case /^(5\.[3-6]|7\.[0-4])ioncube$/.test(version_extension):
|
case /^(5\.[3-6]|7\.[0-4])ioncube$/.test(version_extension):
|
||||||
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
|
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
|
||||||
add_script += await utils.customPackage(ext_name, 'ext', extension, 'linux');
|
case /(?<!5\.[3-6])(pdo_)?sqlsrv$/.test(version_extension):
|
||||||
|
add_script += await utils.customPackage(ext_name, 'extensions', extension, 'linux');
|
||||||
return;
|
return;
|
||||||
case /.+-(stable|beta|alpha|devel|snapshot|rc|preview)/.test(extension):
|
case /.+-(stable|beta|alpha|devel|snapshot|rc|preview)/.test(extension):
|
||||||
add_script += await utils.joins('\nadd_unstable_extension', ext_name, ext_version, ext_prefix);
|
add_script += await utils.joins('\nadd_unstable_extension', ext_name, ext_version, ext_prefix);
|
||||||
@ -381,19 +391,19 @@ async function addExtensionLinux(extension_csv, version) {
|
|||||||
return add_script + remove_script;
|
return add_script + remove_script;
|
||||||
}
|
}
|
||||||
exports.addExtensionLinux = addExtensionLinux;
|
exports.addExtensionLinux = addExtensionLinux;
|
||||||
async function addExtension(extension_csv, version, os_version, no_step = false) {
|
async function addExtension(extension_csv, version, os, no_step = false) {
|
||||||
const log = await utils.stepLog('Setup Extensions', os_version);
|
const log = await utils.stepLog('Setup Extensions', os);
|
||||||
let script = '\n';
|
let script = '\n';
|
||||||
switch (no_step) {
|
switch (no_step) {
|
||||||
case true:
|
case true:
|
||||||
script += log + (await utils.suppressOutput(os_version));
|
script += log + (await utils.suppressOutput(os));
|
||||||
break;
|
break;
|
||||||
case false:
|
case false:
|
||||||
default:
|
default:
|
||||||
script += log;
|
script += log;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
switch (os_version) {
|
switch (os) {
|
||||||
case 'win32':
|
case 'win32':
|
||||||
return script + (await addExtensionWindows(extension_csv, version));
|
return script + (await addExtensionWindows(extension_csv, version));
|
||||||
case 'darwin':
|
case 'darwin':
|
||||||
@ -401,7 +411,7 @@ async function addExtension(extension_csv, version, os_version, no_step = false)
|
|||||||
case 'linux':
|
case 'linux':
|
||||||
return script + (await addExtensionLinux(extension_csv, version));
|
return script + (await addExtensionLinux(extension_csv, version));
|
||||||
default:
|
default:
|
||||||
return await utils.log('Platform ' + os_version + ' is not supported', os_version, 'error');
|
return await utils.log('Platform ' + os + ' is not supported', os, 'error');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.addExtension = addExtension;
|
exports.addExtension = addExtension;
|
||||||
@ -409,14 +419,18 @@ exports.addExtension = addExtension;
|
|||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
||||||
/***/ 39:
|
/***/ 387:
|
||||||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||||
if (k2 === undefined) k2 = k;
|
if (k2 === undefined) k2 = k;
|
||||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||||
|
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||||
|
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||||
|
}
|
||||||
|
Object.defineProperty(o, k2, desc);
|
||||||
}) : (function(o, m, k, k2) {
|
}) : (function(o, m, k, k2) {
|
||||||
if (k2 === undefined) k2 = k;
|
if (k2 === undefined) k2 = k;
|
||||||
o[k2] = m[k];
|
o[k2] = m[k];
|
||||||
@ -434,7 +448,86 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
|
exports.fetch = void 0;
|
||||||
|
const https = __importStar(__nccwpck_require__(687));
|
||||||
|
const url = __importStar(__nccwpck_require__(310));
|
||||||
|
async function fetch(input_url, auth_token, redirect_count = 5) {
|
||||||
|
const fetch_promise = new Promise(resolve => {
|
||||||
|
const url_object = new url.URL(input_url);
|
||||||
|
const headers = {
|
||||||
|
'User-Agent': `Mozilla/5.0 (${process.platform} ${process.arch}) setup-php`
|
||||||
|
};
|
||||||
|
if (auth_token) {
|
||||||
|
headers.authorization = 'Bearer ' + auth_token;
|
||||||
|
}
|
||||||
|
const options = {
|
||||||
|
hostname: url_object.hostname,
|
||||||
|
path: url_object.pathname,
|
||||||
|
headers: headers
|
||||||
|
};
|
||||||
|
const req = https.get(options, (res) => {
|
||||||
|
if (res.statusCode === 200) {
|
||||||
|
let body = '';
|
||||||
|
res.setEncoding('utf8');
|
||||||
|
res.on('data', chunk => (body += chunk));
|
||||||
|
res.on('end', () => resolve({ data: `${body}` }));
|
||||||
|
}
|
||||||
|
else if ([301, 302, 303, 307, 308].includes(res.statusCode)) {
|
||||||
|
if (redirect_count > 0 && res.headers.location) {
|
||||||
|
fetch(res.headers.location, auth_token, redirect_count--).then(resolve);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
resolve({ error: `${res.statusCode}: Redirect error` });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
resolve({ error: `${res.statusCode}: ${res.statusMessage}` });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
req.end();
|
||||||
|
});
|
||||||
|
return await fetch_promise;
|
||||||
|
}
|
||||||
|
exports.fetch = fetch;
|
||||||
|
//# sourceMappingURL=fetch.js.map
|
||||||
|
|
||||||
|
/***/ }),
|
||||||
|
|
||||||
|
/***/ 39:
|
||||||
|
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||||
|
if (k2 === undefined) k2 = k;
|
||||||
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||||
|
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||||
|
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||||
|
}
|
||||||
|
Object.defineProperty(o, k2, desc);
|
||||||
|
}) : (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;
|
||||||
|
};
|
||||||
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
|
};
|
||||||
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
exports.run = exports.getScript = void 0;
|
exports.run = exports.getScript = void 0;
|
||||||
|
const path_1 = __importDefault(__nccwpck_require__(17));
|
||||||
|
const fs_1 = __importDefault(__nccwpck_require__(147));
|
||||||
const exec_1 = __nccwpck_require__(514);
|
const exec_1 = __nccwpck_require__(514);
|
||||||
const core = __importStar(__nccwpck_require__(186));
|
const core = __importStar(__nccwpck_require__(186));
|
||||||
const config = __importStar(__nccwpck_require__(88));
|
const config = __importStar(__nccwpck_require__(88));
|
||||||
@ -442,50 +535,40 @@ const coverage = __importStar(__nccwpck_require__(730));
|
|||||||
const extensions = __importStar(__nccwpck_require__(390));
|
const extensions = __importStar(__nccwpck_require__(390));
|
||||||
const tools = __importStar(__nccwpck_require__(740));
|
const tools = __importStar(__nccwpck_require__(740));
|
||||||
const utils = __importStar(__nccwpck_require__(918));
|
const utils = __importStar(__nccwpck_require__(918));
|
||||||
async function getScript(filename, version, os_version) {
|
async function getScript(os) {
|
||||||
const url = 'https://setup-php.com/sponsor';
|
const url = 'https://setup-php.com/support-ukraine';
|
||||||
|
const filename = os + (await utils.scriptExtension(os));
|
||||||
|
const script_path = path_1.default.join(__dirname, '../src/scripts', filename);
|
||||||
|
const run_path = script_path.replace(os, 'run');
|
||||||
process.env['fail_fast'] = await utils.getInput('fail-fast', false);
|
process.env['fail_fast'] = await utils.getInput('fail-fast', false);
|
||||||
const extension_csv = await utils.getInput('extensions', false);
|
const extension_csv = await utils.getInput('extensions', false);
|
||||||
const ini_values_csv = await utils.getInput('ini-values', false);
|
const ini_values_csv = await utils.getInput('ini-values', false);
|
||||||
const coverage_driver = await utils.getInput('coverage', false);
|
const coverage_driver = await utils.getInput('coverage', false);
|
||||||
const tools_csv = await utils.getInput('tools', false);
|
const tools_csv = await utils.getInput('tools', false);
|
||||||
let script = await utils.readFile(filename, 'src/scripts');
|
const version = await utils.parseVersion(await utils.getInput('php-version', true));
|
||||||
script += await tools.addTools(tools_csv, version, os_version);
|
const ini_file = await utils.parseIniFile(await utils.getInput('ini-file', false));
|
||||||
|
let script = await utils.joins('.', script_path, version, ini_file);
|
||||||
if (extension_csv) {
|
if (extension_csv) {
|
||||||
script += await extensions.addExtension(extension_csv, version, os_version);
|
script += await extensions.addExtension(extension_csv, version, os);
|
||||||
}
|
}
|
||||||
|
script += await tools.addTools(tools_csv, version, os);
|
||||||
if (coverage_driver) {
|
if (coverage_driver) {
|
||||||
script += await coverage.addCoverage(coverage_driver, version, os_version);
|
script += await coverage.addCoverage(coverage_driver, version, os);
|
||||||
}
|
}
|
||||||
if (ini_values_csv) {
|
if (ini_values_csv) {
|
||||||
script += await config.addINIValues(ini_values_csv, os_version);
|
script += await config.addINIValues(ini_values_csv, os);
|
||||||
}
|
}
|
||||||
script += '\n' + (await utils.stepLog(`Sponsor setup-php`, os_version));
|
script += '\n' + (await utils.stepLog(`#StandWithUkraine`, os));
|
||||||
script += '\n' + (await utils.addLog('$tick', 'setup-php', url, os_version));
|
script += '\n' + (await utils.addLog('$tick', 'read-more', url, os));
|
||||||
return await utils.writeScript(filename, script);
|
fs_1.default.writeFileSync(run_path, script, { mode: 0o755 });
|
||||||
|
return run_path;
|
||||||
}
|
}
|
||||||
exports.getScript = getScript;
|
exports.getScript = getScript;
|
||||||
async function run() {
|
async function run() {
|
||||||
try {
|
const os = process.platform;
|
||||||
if ((await utils.readEnv('ImageOS')) == 'ubuntu16') {
|
const tool = await utils.scriptTool(os);
|
||||||
core.setFailed('setup-php is not supported on Ubuntu 16.04. Please upgrade to Ubuntu 18.04 or Ubuntu 20.04 - https://setup-php.com/i/452');
|
const run_path = await getScript(os);
|
||||||
return;
|
await (0, exec_1.exec)(tool + run_path);
|
||||||
}
|
|
||||||
const version = await utils.parseVersion(await utils.getInput('php-version', true));
|
|
||||||
if (version) {
|
|
||||||
const os_version = process.platform;
|
|
||||||
const tool = await utils.scriptTool(os_version);
|
|
||||||
const script = os_version + (await utils.scriptExtension(os_version));
|
|
||||||
const location = await getScript(script, version, os_version);
|
|
||||||
await (0, exec_1.exec)(await utils.joins(tool, location, version, __dirname));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
core.setFailed('Unable to get the PHP version');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (error) {
|
|
||||||
core.setFailed(error.message);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
exports.run = run;
|
exports.run = run;
|
||||||
(async () => {
|
(async () => {
|
||||||
@ -504,7 +587,11 @@ exports.run = run;
|
|||||||
|
|
||||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||||
if (k2 === undefined) k2 = k;
|
if (k2 === undefined) k2 = k;
|
||||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||||
|
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||||
|
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||||
|
}
|
||||||
|
Object.defineProperty(o, k2, desc);
|
||||||
}) : (function(o, m, k, k2) {
|
}) : (function(o, m, k, k2) {
|
||||||
if (k2 === undefined) k2 = k;
|
if (k2 === undefined) k2 = k;
|
||||||
o[k2] = m[k];
|
o[k2] = m[k];
|
||||||
@ -521,15 +608,21 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|||||||
__setModuleDefault(result, mod);
|
__setModuleDefault(result, mod);
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
|
};
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
exports.addTools = exports.functionRecord = exports.getData = exports.addWPCLI = exports.addSymfony = exports.addPHPUnitTools = exports.addPhive = exports.addPhing = exports.addPECL = exports.addDevTools = exports.addDeployer = exports.addComposer = exports.addBlackfirePlayer = exports.addPackage = exports.addArchive = exports.getPharUrl = exports.getUrl = exports.filterList = exports.getRelease = exports.getVersion = exports.getLatestVersion = exports.getSemverVersion = void 0;
|
exports.addTools = exports.functionRecord = exports.getData = exports.addWPCLI = exports.addPHPUnitTools = exports.addPhive = exports.addPhing = exports.addPECL = exports.addDevTools = exports.addDeployer = exports.addComposer = exports.addBlackfirePlayer = exports.addPackage = exports.addArchive = exports.getPharUrl = exports.getUrl = exports.filterList = exports.getRelease = exports.getVersion = exports.getLatestVersion = exports.getSemverVersion = void 0;
|
||||||
|
const path_1 = __importDefault(__nccwpck_require__(17));
|
||||||
|
const fs_1 = __importDefault(__nccwpck_require__(147));
|
||||||
|
const fetch = __importStar(__nccwpck_require__(387));
|
||||||
const utils = __importStar(__nccwpck_require__(918));
|
const utils = __importStar(__nccwpck_require__(918));
|
||||||
async function getSemverVersion(data) {
|
async function getSemverVersion(data) {
|
||||||
var _a;
|
var _a;
|
||||||
const search = data['version_prefix'] + data['version'];
|
const search = data['version_prefix'] + data['version'];
|
||||||
const url = `https://api.github.com/repos/${data['repository']}/git/matching-refs/tags%2F${search}.`;
|
const url = `https://api.github.com/repos/${data['repository']}/git/matching-refs/tags%2F${search}.`;
|
||||||
const token = await utils.readEnv('COMPOSER_TOKEN');
|
const token = await utils.readEnv('COMPOSER_TOKEN');
|
||||||
const response = await utils.fetch(url, token);
|
const response = await fetch.fetch(url, token);
|
||||||
if (response.error || response.data === '[]') {
|
if (response.error || response.data === '[]') {
|
||||||
data['error'] = (_a = response.error) !== null && _a !== void 0 ? _a : `No version found with prefix ${search}.`;
|
data['error'] = (_a = response.error) !== null && _a !== void 0 ? _a : `No version found with prefix ${search}.`;
|
||||||
return data['version'];
|
return data['version'];
|
||||||
@ -546,13 +639,16 @@ async function getLatestVersion(data) {
|
|||||||
if (!data['version'] && data['fetch_latest'] === 'false') {
|
if (!data['version'] && data['fetch_latest'] === 'false') {
|
||||||
return 'latest';
|
return 'latest';
|
||||||
}
|
}
|
||||||
const resp = await utils.fetch(`${data['github']}/${data['repository']}/releases.atom`);
|
const resp = await fetch.fetch(`${data['github']}/${data['repository']}/releases.atom`);
|
||||||
const releases = [
|
if (resp['data']) {
|
||||||
...resp['data'].matchAll(/releases\/tag\/([a-zA-Z]*)?(\d+.\d+.\d+)"/g)
|
const releases = [
|
||||||
].map(match => match[2]);
|
...resp['data'].matchAll(/releases\/tag\/([a-zA-Z]*)?(\d+.\d+.\d+)"/g)
|
||||||
return (releases
|
].map(match => match[2]);
|
||||||
.sort((a, b) => a.localeCompare(b, undefined, { numeric: true }))
|
return (releases
|
||||||
.pop() || 'latest');
|
.sort((a, b) => a.localeCompare(b, undefined, { numeric: true }))
|
||||||
|
.pop() || 'latest');
|
||||||
|
}
|
||||||
|
return 'latest';
|
||||||
}
|
}
|
||||||
exports.getLatestVersion = getLatestVersion;
|
exports.getLatestVersion = getLatestVersion;
|
||||||
async function getVersion(version, data) {
|
async function getVersion(version, data) {
|
||||||
@ -643,12 +739,12 @@ async function getPharUrl(data) {
|
|||||||
}
|
}
|
||||||
exports.getPharUrl = getPharUrl;
|
exports.getPharUrl = getPharUrl;
|
||||||
async function addArchive(data) {
|
async function addArchive(data) {
|
||||||
return ((await utils.getCommand(data['os_version'], 'tool')) +
|
return ((await utils.getCommand(data['os'], 'tool')) +
|
||||||
(await utils.joins(data['url'], data['tool'], data['version_parameter'])));
|
(await utils.joins(data['url'], data['tool'], data['version_parameter'])));
|
||||||
}
|
}
|
||||||
exports.addArchive = addArchive;
|
exports.addArchive = addArchive;
|
||||||
async function addPackage(data) {
|
async function addPackage(data) {
|
||||||
const command = await utils.getCommand(data['os_version'], 'composertool');
|
const command = await utils.getCommand(data['os'], 'composertool');
|
||||||
const parts = data['repository'].split('/');
|
const parts = data['repository'].split('/');
|
||||||
const args = await utils.joins(parts[1], data['release'], parts[0] + '/', data['scope']);
|
const args = await utils.joins(parts[1], data['release'], parts[0] + '/', data['scope']);
|
||||||
return command + args;
|
return command + args;
|
||||||
@ -699,31 +795,37 @@ async function addDeployer(data) {
|
|||||||
}
|
}
|
||||||
exports.addDeployer = addDeployer;
|
exports.addDeployer = addDeployer;
|
||||||
async function addDevTools(data) {
|
async function addDevTools(data) {
|
||||||
switch (data['os_version']) {
|
switch (data['os']) {
|
||||||
case 'linux':
|
case 'linux':
|
||||||
case 'darwin':
|
case 'darwin':
|
||||||
return 'add_devtools ' + data['tool'];
|
return 'add_devtools ' + data['tool'];
|
||||||
case 'win32':
|
case 'win32':
|
||||||
return await utils.addLog('$tick', data['tool'], data['tool'] + ' is not a windows tool', 'win32');
|
return await utils.addLog('$tick', data['tool'], data['tool'] + ' is not a windows tool', 'win32');
|
||||||
default:
|
default:
|
||||||
return await utils.log('Platform ' + data['os_version'] + ' is not supported', data['os_version'], 'error');
|
return await utils.log('Platform ' + data['os'] + ' is not supported', data['os'], 'error');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.addDevTools = addDevTools;
|
exports.addDevTools = addDevTools;
|
||||||
async function addPECL(data) {
|
async function addPECL(data) {
|
||||||
return await utils.getCommand(data['os_version'], 'pecl');
|
return await utils.getCommand(data['os'], 'pecl');
|
||||||
}
|
}
|
||||||
exports.addPECL = addPECL;
|
exports.addPECL = addPECL;
|
||||||
async function addPhing(data) {
|
async function addPhing(data) {
|
||||||
data['url'] =
|
data['url'] =
|
||||||
data['domain'] + '/get/phing-' + data['version'] + data['extension'];
|
data['domain'] + '/get/phing-' + data['version'] + data['extension'];
|
||||||
|
if (data['version'] != 'latest') {
|
||||||
|
[data['prefix'], data['verb']] = ['releases', 'download'];
|
||||||
|
data['domain'] = data['github'];
|
||||||
|
data['extension'] = '-' + data['version'] + data['extension'];
|
||||||
|
data['url'] += ',' + (await getUrl(data));
|
||||||
|
}
|
||||||
return await addArchive(data);
|
return await addArchive(data);
|
||||||
}
|
}
|
||||||
exports.addPhing = addPhing;
|
exports.addPhing = addPhing;
|
||||||
async function addPhive(data) {
|
async function addPhive(data) {
|
||||||
switch (true) {
|
switch (true) {
|
||||||
case /5\.[3-5]/.test(data['php_version']):
|
case /5\.[3-5]/.test(data['php_version']):
|
||||||
return await utils.addLog('$cross', 'phive', 'Phive is not supported on PHP ' + data['php_version'], data['os_version']);
|
return await utils.addLog('$cross', 'phive', 'Phive is not supported on PHP ' + data['php_version'], data['os']);
|
||||||
case /5\.6|7\.0/.test(data['php_version']):
|
case /5\.6|7\.0/.test(data['php_version']):
|
||||||
data['version'] = '0.12.1';
|
data['version'] = '0.12.1';
|
||||||
break;
|
break;
|
||||||
@ -747,29 +849,6 @@ async function addPHPUnitTools(data) {
|
|||||||
return await addArchive(data);
|
return await addArchive(data);
|
||||||
}
|
}
|
||||||
exports.addPHPUnitTools = addPHPUnitTools;
|
exports.addPHPUnitTools = addPHPUnitTools;
|
||||||
async function addSymfony(data) {
|
|
||||||
let filename;
|
|
||||||
switch (data['os_version']) {
|
|
||||||
case 'linux':
|
|
||||||
case 'darwin':
|
|
||||||
filename = 'symfony_' + data['os_version'] + '_amd64';
|
|
||||||
break;
|
|
||||||
case 'win32':
|
|
||||||
filename = 'symfony_windows_amd64.exe';
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return await utils.log('Platform ' + data['os_version'] + ' is not supported', data['os_version'], 'error');
|
|
||||||
}
|
|
||||||
if (data['version'] === 'latest') {
|
|
||||||
data['uri'] = ['releases/latest/download', filename].join('/');
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
data['uri'] = ['releases/download', 'v' + data['version'], filename].join('/');
|
|
||||||
}
|
|
||||||
data['url'] = [data['domain'], data['repository'], data['uri']].join('/');
|
|
||||||
return await addArchive(data);
|
|
||||||
}
|
|
||||||
exports.addSymfony = addSymfony;
|
|
||||||
async function addWPCLI(data) {
|
async function addWPCLI(data) {
|
||||||
if (data['version'] === 'latest') {
|
if (data['version'] === 'latest') {
|
||||||
data['uri'] = 'wp-cli/builds/blob/gh-pages/phar/wp-cli.phar?raw=true';
|
data['uri'] = 'wp-cli/builds/blob/gh-pages/phar/wp-cli.phar?raw=true';
|
||||||
@ -782,9 +861,10 @@ async function addWPCLI(data) {
|
|||||||
return await addArchive(data);
|
return await addArchive(data);
|
||||||
}
|
}
|
||||||
exports.addWPCLI = addWPCLI;
|
exports.addWPCLI = addWPCLI;
|
||||||
async function getData(release, php_version, os_version) {
|
async function getData(release, php_version, os) {
|
||||||
var _a, _b, _c, _d, _e;
|
var _a, _b, _c, _d, _e;
|
||||||
const json_file = await utils.readFile('tools.json', 'src/configs');
|
const json_file_path = path_1.default.join(__dirname, '../src/configs/tools.json');
|
||||||
|
const json_file = fs_1.default.readFileSync(json_file_path, 'utf8');
|
||||||
const json_objects = JSON.parse(json_file);
|
const json_objects = JSON.parse(json_file);
|
||||||
release = release.replace(/\s+/g, '');
|
release = release.replace(/\s+/g, '');
|
||||||
const parts = release.split(':');
|
const parts = release.split(':');
|
||||||
@ -815,7 +895,7 @@ async function getData(release, php_version, os_version) {
|
|||||||
data['github'] = 'https://github.com';
|
data['github'] = 'https://github.com';
|
||||||
(_a = data['domain']) !== null && _a !== void 0 ? _a : (data['domain'] = data['github']);
|
(_a = data['domain']) !== null && _a !== void 0 ? _a : (data['domain'] = data['github']);
|
||||||
(_b = data['extension']) !== null && _b !== void 0 ? _b : (data['extension'] = '.phar');
|
(_b = data['extension']) !== null && _b !== void 0 ? _b : (data['extension'] = '.phar');
|
||||||
data['os_version'] = os_version;
|
data['os'] = os;
|
||||||
data['php_version'] = php_version;
|
data['php_version'] = php_version;
|
||||||
data['prefix'] = data['github'] === data['domain'] ? 'releases' : '';
|
data['prefix'] = data['github'] === data['domain'] ? 'releases' : '';
|
||||||
data['verb'] = data['github'] === data['domain'] ? 'download' : '';
|
data['verb'] = data['github'] === data['domain'] ? 'download' : '';
|
||||||
@ -840,24 +920,23 @@ exports.functionRecord = {
|
|||||||
phing: addPhing,
|
phing: addPhing,
|
||||||
phpunit: addPHPUnitTools,
|
phpunit: addPHPUnitTools,
|
||||||
phpcpd: addPHPUnitTools,
|
phpcpd: addPHPUnitTools,
|
||||||
symfony: addSymfony,
|
|
||||||
wp_cli: addWPCLI
|
wp_cli: addWPCLI
|
||||||
};
|
};
|
||||||
async function addTools(tools_csv, php_version, os_version) {
|
async function addTools(tools_csv, php_version, os) {
|
||||||
let script = '\n';
|
let script = '\n';
|
||||||
if (tools_csv === 'none') {
|
if (tools_csv === 'none') {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
script += await utils.stepLog('Setup Tools', os_version);
|
script += await utils.stepLog('Setup Tools', os);
|
||||||
}
|
}
|
||||||
const tools_list = await filterList(await utils.CSVArray(tools_csv));
|
const tools_list = await filterList(await utils.CSVArray(tools_csv));
|
||||||
await utils.asyncForEach(tools_list, async function (release) {
|
await utils.asyncForEach(tools_list, async function (release) {
|
||||||
const data = await getData(release, php_version, os_version);
|
const data = await getData(release, php_version, os);
|
||||||
script += '\n';
|
script += '\n';
|
||||||
switch (true) {
|
switch (true) {
|
||||||
case data['error'] !== undefined:
|
case data['error'] !== undefined:
|
||||||
script += await utils.addLog('$cross', data['tool'], data['error'], data['os_version']);
|
script += await utils.addLog('$cross', data['tool'], data['error'], data['os']);
|
||||||
break;
|
break;
|
||||||
case 'phar' === data['type']:
|
case 'phar' === data['type']:
|
||||||
data['url'] = await getUrl(data);
|
data['url'] = await getUrl(data);
|
||||||
@ -867,7 +946,7 @@ async function addTools(tools_csv, php_version, os_version) {
|
|||||||
script += await addPackage(data);
|
script += await addPackage(data);
|
||||||
break;
|
break;
|
||||||
case 'custom-package' === data['type']:
|
case 'custom-package' === data['type']:
|
||||||
script += await utils.customPackage(data['tool'].split('-')[0], 'tools', data['version'], data['os_version']);
|
script += await utils.customPackage(data['tool'].split('-')[0], 'tools', data['version'], data['os']);
|
||||||
break;
|
break;
|
||||||
case 'custom-function' === data['type']:
|
case 'custom-function' === data['type']:
|
||||||
script += await exports.functionRecord[data['function']](data);
|
script += await exports.functionRecord[data['function']](data);
|
||||||
@ -875,7 +954,7 @@ async function addTools(tools_csv, php_version, os_version) {
|
|||||||
case /^none$/.test(data['tool']):
|
case /^none$/.test(data['tool']):
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
script += await utils.addLog('$cross', data['tool'], 'Tool ' + data['tool'] + ' is not supported', data['os_version']);
|
script += await utils.addLog('$cross', data['tool'], 'Tool ' + data['tool'] + ' is not supported', data['os']);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -893,7 +972,11 @@ exports.addTools = addTools;
|
|||||||
|
|
||||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||||
if (k2 === undefined) k2 = k;
|
if (k2 === undefined) k2 = k;
|
||||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||||
|
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||||
|
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||||
|
}
|
||||||
|
Object.defineProperty(o, k2, desc);
|
||||||
}) : (function(o, m, k, k2) {
|
}) : (function(o, m, k, k2) {
|
||||||
if (k2 === undefined) k2 = k;
|
if (k2 === undefined) k2 = k;
|
||||||
o[k2] = m[k];
|
o[k2] = m[k];
|
||||||
@ -911,12 +994,10 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
exports.parseExtensionSource = exports.customPackage = exports.scriptTool = exports.scriptExtension = exports.joins = exports.getCommand = exports.getUnsupportedLog = exports.suppressOutput = exports.getExtensionPrefix = exports.CSVArray = exports.extensionArray = exports.writeScript = exports.readFile = exports.addLog = exports.stepLog = exports.log = exports.color = exports.asyncForEach = exports.parseVersion = exports.getManifestURL = exports.fetch = exports.getInput = exports.readEnv = void 0;
|
exports.parseExtensionSource = exports.customPackage = exports.scriptTool = exports.scriptExtension = exports.joins = exports.getCommand = exports.getUnsupportedLog = exports.suppressOutput = exports.getExtensionPrefix = exports.CSVArray = exports.extensionArray = exports.addLog = exports.stepLog = exports.log = exports.color = exports.asyncForEach = exports.parseIniFile = exports.parseVersion = exports.getManifestURL = exports.getInput = exports.readEnv = void 0;
|
||||||
const fs = __importStar(__nccwpck_require__(147));
|
|
||||||
const https = __importStar(__nccwpck_require__(687));
|
|
||||||
const path = __importStar(__nccwpck_require__(17));
|
const path = __importStar(__nccwpck_require__(17));
|
||||||
const url = __importStar(__nccwpck_require__(310));
|
|
||||||
const core = __importStar(__nccwpck_require__(186));
|
const core = __importStar(__nccwpck_require__(186));
|
||||||
|
const fetch = __importStar(__nccwpck_require__(387));
|
||||||
async function readEnv(property) {
|
async function readEnv(property) {
|
||||||
const property_lc = property.toLowerCase();
|
const property_lc = property.toLowerCase();
|
||||||
const property_uc = property.toUpperCase();
|
const property_uc = property.toUpperCase();
|
||||||
@ -943,36 +1024,6 @@ async function getInput(name, mandatory) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.getInput = getInput;
|
exports.getInput = getInput;
|
||||||
async function fetch(input_url, auth_token) {
|
|
||||||
const fetch_promise = new Promise(resolve => {
|
|
||||||
const url_object = new url.URL(input_url);
|
|
||||||
const headers = {
|
|
||||||
'User-Agent': `Mozilla/5.0 (${process.platform} ${process.arch}) setup-php`
|
|
||||||
};
|
|
||||||
if (auth_token) {
|
|
||||||
headers.authorization = 'Bearer ' + auth_token;
|
|
||||||
}
|
|
||||||
const options = {
|
|
||||||
hostname: url_object.hostname,
|
|
||||||
path: url_object.pathname,
|
|
||||||
headers: headers
|
|
||||||
};
|
|
||||||
const req = https.get(options, (res) => {
|
|
||||||
if (res.statusCode != 200) {
|
|
||||||
resolve({ error: `${res.statusCode}: ${res.statusMessage}` });
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
let body = '';
|
|
||||||
res.setEncoding('utf8');
|
|
||||||
res.on('data', chunk => (body += chunk));
|
|
||||||
res.on('end', () => resolve({ data: `${body}` }));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
req.end();
|
|
||||||
});
|
|
||||||
return await fetch_promise;
|
|
||||||
}
|
|
||||||
exports.fetch = fetch;
|
|
||||||
async function getManifestURL() {
|
async function getManifestURL() {
|
||||||
return 'https://raw.githubusercontent.com/shivammathur/setup-php/develop/src/configs/php-versions.json';
|
return 'https://raw.githubusercontent.com/shivammathur/setup-php/develop/src/configs/php-versions.json';
|
||||||
}
|
}
|
||||||
@ -981,7 +1032,7 @@ async function parseVersion(version) {
|
|||||||
const manifest = await getManifestURL();
|
const manifest = await getManifestURL();
|
||||||
switch (true) {
|
switch (true) {
|
||||||
case /^(latest|nightly|\d+\.x)$/.test(version):
|
case /^(latest|nightly|\d+\.x)$/.test(version):
|
||||||
return JSON.parse((await fetch(manifest))['data'])[version];
|
return JSON.parse((await fetch.fetch(manifest))['data'])[version];
|
||||||
default:
|
default:
|
||||||
switch (true) {
|
switch (true) {
|
||||||
case version.length > 1:
|
case version.length > 1:
|
||||||
@ -992,6 +1043,17 @@ async function parseVersion(version) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.parseVersion = parseVersion;
|
exports.parseVersion = parseVersion;
|
||||||
|
async function parseIniFile(ini_file) {
|
||||||
|
switch (true) {
|
||||||
|
case /^(production|development|none)$/.test(ini_file):
|
||||||
|
return ini_file;
|
||||||
|
case /php\.ini-(production|development)$/.test(ini_file):
|
||||||
|
return ini_file.split('-')[1];
|
||||||
|
default:
|
||||||
|
return 'production';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exports.parseIniFile = parseIniFile;
|
||||||
async function asyncForEach(array, callback) {
|
async function asyncForEach(array, callback) {
|
||||||
for (let index = 0; index < array.length; index++) {
|
for (let index = 0; index < array.length; index++) {
|
||||||
await callback(array[index], index, array);
|
await callback(array[index], index, array);
|
||||||
@ -1010,8 +1072,8 @@ async function color(type) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.color = color;
|
exports.color = color;
|
||||||
async function log(message, os_version, log_type) {
|
async function log(message, os, log_type) {
|
||||||
switch (os_version) {
|
switch (os) {
|
||||||
case 'win32':
|
case 'win32':
|
||||||
return ('printf "\\033[' +
|
return ('printf "\\033[' +
|
||||||
(await color(log_type)) +
|
(await color(log_type)) +
|
||||||
@ -1025,41 +1087,30 @@ async function log(message, os_version, log_type) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.log = log;
|
exports.log = log;
|
||||||
async function stepLog(message, os_version) {
|
async function stepLog(message, os) {
|
||||||
switch (os_version) {
|
switch (os) {
|
||||||
case 'win32':
|
case 'win32':
|
||||||
return 'Step-Log "' + message + '"';
|
return 'Step-Log "' + message + '"';
|
||||||
case 'linux':
|
case 'linux':
|
||||||
case 'darwin':
|
case 'darwin':
|
||||||
return 'step_log "' + message + '"';
|
return 'step_log "' + message + '"';
|
||||||
default:
|
default:
|
||||||
return await log('Platform ' + os_version + ' is not supported', os_version, 'error');
|
return await log('Platform ' + os + ' is not supported', os, 'error');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.stepLog = stepLog;
|
exports.stepLog = stepLog;
|
||||||
async function addLog(mark, subject, message, os_version) {
|
async function addLog(mark, subject, message, os) {
|
||||||
switch (os_version) {
|
switch (os) {
|
||||||
case 'win32':
|
case 'win32':
|
||||||
return 'Add-Log "' + mark + '" "' + subject + '" "' + message + '"';
|
return 'Add-Log "' + mark + '" "' + subject + '" "' + message + '"';
|
||||||
case 'linux':
|
case 'linux':
|
||||||
case 'darwin':
|
case 'darwin':
|
||||||
return 'add_log "' + mark + '" "' + subject + '" "' + message + '"';
|
return 'add_log "' + mark + '" "' + subject + '" "' + message + '"';
|
||||||
default:
|
default:
|
||||||
return await log('Platform ' + os_version + ' is not supported', os_version, 'error');
|
return await log('Platform ' + os + ' is not supported', os, 'error');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.addLog = addLog;
|
exports.addLog = addLog;
|
||||||
async function readFile(filename, directory) {
|
|
||||||
return fs.readFileSync(path.join(__dirname, '../' + directory, filename), 'utf8');
|
|
||||||
}
|
|
||||||
exports.readFile = readFile;
|
|
||||||
async function writeScript(filename, script) {
|
|
||||||
const runner_dir = await getInput('RUNNER_TOOL_CACHE', false);
|
|
||||||
const script_path = path.join(runner_dir, filename);
|
|
||||||
fs.writeFileSync(script_path, script, { mode: 0o755 });
|
|
||||||
return script_path;
|
|
||||||
}
|
|
||||||
exports.writeScript = writeScript;
|
|
||||||
async function extensionArray(extension_csv) {
|
async function extensionArray(extension_csv) {
|
||||||
switch (extension_csv) {
|
switch (extension_csv) {
|
||||||
case '':
|
case '':
|
||||||
@ -1110,33 +1161,33 @@ async function getExtensionPrefix(extension) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.getExtensionPrefix = getExtensionPrefix;
|
exports.getExtensionPrefix = getExtensionPrefix;
|
||||||
async function suppressOutput(os_version) {
|
async function suppressOutput(os) {
|
||||||
switch (os_version) {
|
switch (os) {
|
||||||
case 'win32':
|
case 'win32':
|
||||||
return ' >$null 2>&1';
|
return ' >$null 2>&1';
|
||||||
case 'linux':
|
case 'linux':
|
||||||
case 'darwin':
|
case 'darwin':
|
||||||
return ' >/dev/null 2>&1';
|
return ' >/dev/null 2>&1';
|
||||||
default:
|
default:
|
||||||
return await log('Platform ' + os_version + ' is not supported', os_version, 'error');
|
return await log('Platform ' + os + ' is not supported', os, 'error');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.suppressOutput = suppressOutput;
|
exports.suppressOutput = suppressOutput;
|
||||||
async function getUnsupportedLog(extension, version, os_version) {
|
async function getUnsupportedLog(extension, version, os) {
|
||||||
return ('\n' +
|
return ('\n' +
|
||||||
(await addLog('$cross', extension, [extension, 'is not supported on PHP', version].join(' '), os_version)) +
|
(await addLog('$cross', extension, [extension, 'is not supported on PHP', version].join(' '), os)) +
|
||||||
'\n');
|
'\n');
|
||||||
}
|
}
|
||||||
exports.getUnsupportedLog = getUnsupportedLog;
|
exports.getUnsupportedLog = getUnsupportedLog;
|
||||||
async function getCommand(os_version, suffix) {
|
async function getCommand(os, suffix) {
|
||||||
switch (os_version) {
|
switch (os) {
|
||||||
case 'linux':
|
case 'linux':
|
||||||
case 'darwin':
|
case 'darwin':
|
||||||
return 'add_' + suffix + ' ';
|
return 'add_' + suffix + ' ';
|
||||||
case 'win32':
|
case 'win32':
|
||||||
return 'Add-' + suffix.charAt(0).toUpperCase() + suffix.slice(1) + ' ';
|
return 'Add-' + suffix.charAt(0).toUpperCase() + suffix.slice(1) + ' ';
|
||||||
default:
|
default:
|
||||||
return await log('Platform ' + os_version + ' is not supported', os_version, 'error');
|
return await log('Platform ' + os + ' is not supported', os, 'error');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.getCommand = getCommand;
|
exports.getCommand = getCommand;
|
||||||
@ -1144,40 +1195,40 @@ async function joins(...str) {
|
|||||||
return [...str].join(' ');
|
return [...str].join(' ');
|
||||||
}
|
}
|
||||||
exports.joins = joins;
|
exports.joins = joins;
|
||||||
async function scriptExtension(os_version) {
|
async function scriptExtension(os) {
|
||||||
switch (os_version) {
|
switch (os) {
|
||||||
case 'win32':
|
case 'win32':
|
||||||
return '.ps1';
|
return '.ps1';
|
||||||
case 'linux':
|
case 'linux':
|
||||||
case 'darwin':
|
case 'darwin':
|
||||||
return '.sh';
|
return '.sh';
|
||||||
default:
|
default:
|
||||||
return await log('Platform ' + os_version + ' is not supported', os_version, 'error');
|
return await log('Platform ' + os + ' is not supported', os, 'error');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.scriptExtension = scriptExtension;
|
exports.scriptExtension = scriptExtension;
|
||||||
async function scriptTool(os_version) {
|
async function scriptTool(os) {
|
||||||
switch (os_version) {
|
switch (os) {
|
||||||
case 'win32':
|
case 'win32':
|
||||||
return 'pwsh';
|
return 'pwsh ';
|
||||||
case 'linux':
|
case 'linux':
|
||||||
case 'darwin':
|
case 'darwin':
|
||||||
return 'bash';
|
return 'bash ';
|
||||||
default:
|
default:
|
||||||
return await log('Platform ' + os_version + ' is not supported', os_version, 'error');
|
return await log('Platform ' + os + ' is not supported', os, 'error');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.scriptTool = scriptTool;
|
exports.scriptTool = scriptTool;
|
||||||
async function customPackage(pkg, type, version, os_version) {
|
async function customPackage(pkg, type, version, os) {
|
||||||
const pkg_name = pkg.replace(/\d+|(pdo|pecl)[_-]/, '');
|
const pkg_name = pkg.replace(/\d+|(pdo|pecl)[_-]/, '');
|
||||||
const script_extension = await scriptExtension(os_version);
|
const script_extension = await scriptExtension(os);
|
||||||
const script = path.join(__dirname, '../src/scripts/' + type + '/' + pkg_name + script_extension);
|
const script = path.join(__dirname, '../src/scripts/' + type + '/' + pkg_name + script_extension);
|
||||||
const command = await getCommand(os_version, pkg_name);
|
const command = await getCommand(os, pkg_name);
|
||||||
return '\n. ' + script + '\n' + command + version;
|
return '\n. ' + script + '\n' + command + version;
|
||||||
}
|
}
|
||||||
exports.customPackage = customPackage;
|
exports.customPackage = customPackage;
|
||||||
async function parseExtensionSource(extension, prefix) {
|
async function parseExtensionSource(extension, prefix) {
|
||||||
const regex = /(\w+)-(.+:\/\/.+(?:[.:].+)+\/)?([\w.-]+)\/([\w.-]+)@(.+)/;
|
const regex = /(\w+)-(\w+:\/\/.{1,253}(?:[.:][^:/\s]{2,63})+\/)?([\w.-]+)\/([\w.-]+)@(.+)/;
|
||||||
const matches = regex.exec(extension);
|
const matches = regex.exec(extension);
|
||||||
matches[2] = matches[2] ? matches[2].slice(0, -1) : 'https://github.com';
|
matches[2] = matches[2] ? matches[2].slice(0, -1) : 'https://github.com';
|
||||||
return await joins('\nadd_extension_from_source', ...matches.splice(1, matches.length), prefix);
|
return await joins('\nadd_extension_from_source', ...matches.splice(1, matches.length), prefix);
|
||||||
|
@ -11,7 +11,7 @@ jobs:
|
|||||||
php-versions: ['7.4', '8.0', '8.1']
|
php-versions: ['7.4', '8.0', '8.1']
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
# Docs: https://github.com/shivammathur/setup-php
|
# Docs: https://github.com/shivammathur/setup-php
|
||||||
- name: Setup PHP
|
- name: Setup PHP
|
||||||
@ -23,7 +23,7 @@ jobs:
|
|||||||
id: composer-cache
|
id: composer-cache
|
||||||
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
||||||
|
|
||||||
- uses: actions/cache@v2
|
- uses: actions/cache@v3
|
||||||
with:
|
with:
|
||||||
path: ${{ steps.composer-cache.outputs.dir }}
|
path: ${{ steps.composer-cache.outputs.dir }}
|
||||||
# Use composer.json for key, if composer.lock is not committed.
|
# Use composer.json for key, if composer.lock is not committed.
|
||||||
|
@ -19,7 +19,7 @@ jobs:
|
|||||||
# blackfire-player supports PHP >= 5.5
|
# blackfire-player supports PHP >= 5.5
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
# Docs: https://github.com/shivammathur/setup-php
|
# Docs: https://github.com/shivammathur/setup-php
|
||||||
- name: Setup PHP
|
- name: Setup PHP
|
||||||
|
@ -19,7 +19,7 @@ jobs:
|
|||||||
# Blackfire supports PHP >= 5.3 on Ubuntu and macOS, and PHP >= 5.4 on Windows
|
# Blackfire supports PHP >= 5.3 on Ubuntu and macOS, and PHP >= 5.4 on Windows
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
# Docs: https://github.com/shivammathur/setup-php
|
# Docs: https://github.com/shivammathur/setup-php
|
||||||
- name: Setup PHP
|
- name: Setup PHP
|
||||||
|
@ -8,6 +8,8 @@ jobs:
|
|||||||
matrix:
|
matrix:
|
||||||
php-versions: ['7.4', '8.0', '8.1']
|
php-versions: ['7.4', '8.0', '8.1']
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
# Docs: https://docs.github.com/en/actions/using-containerized-services
|
||||||
services:
|
services:
|
||||||
mysql:
|
mysql:
|
||||||
image: mysql:latest
|
image: mysql:latest
|
||||||
@ -26,7 +28,7 @@ jobs:
|
|||||||
options: --health-cmd="redis-cli ping" --health-interval=10s --health-timeout=5s --health-retries=3
|
options: --health-cmd="redis-cli ping" --health-interval=10s --health-timeout=5s --health-retries=3
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
# Docs: https://github.com/shivammathur/setup-php
|
# Docs: https://github.com/shivammathur/setup-php
|
||||||
- name: Setup PHP
|
- name: Setup PHP
|
||||||
@ -38,15 +40,17 @@ jobs:
|
|||||||
extensions: mbstring, intl, redis, pdo_mysql
|
extensions: mbstring, intl, redis, pdo_mysql
|
||||||
coverage: pcov
|
coverage: pcov
|
||||||
|
|
||||||
- name: Start mysql service
|
# Local MySQL service in GitHub hosted environments is disabled by default.
|
||||||
run: sudo systemctl start mysql
|
# If you are using it instead of service containers, make sure you start it.
|
||||||
|
# - name: Start mysql service
|
||||||
|
# run: sudo systemctl start mysql.service
|
||||||
|
|
||||||
- name: Get composer cache directory
|
- name: Get composer cache directory
|
||||||
id: composer-cache
|
id: composer-cache
|
||||||
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
||||||
|
|
||||||
- name: Cache composer dependencies
|
- name: Cache composer dependencies
|
||||||
uses: actions/cache@v2
|
uses: actions/cache@v3
|
||||||
with:
|
with:
|
||||||
path: ${{ steps.composer-cache.outputs.dir }}
|
path: ${{ steps.composer-cache.outputs.dir }}
|
||||||
# Use composer.json for key, if composer.lock is not committed.
|
# Use composer.json for key, if composer.lock is not committed.
|
||||||
@ -57,7 +61,7 @@ jobs:
|
|||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
composer install --no-progress --prefer-dist --optimize-autoloader
|
composer install --no-progress --prefer-dist --optimize-autoloader
|
||||||
composer run-script post-install-cmd --no-interaction
|
composer run-script post-install-cmd
|
||||||
|
|
||||||
# Add a step to run migrations if required
|
# Add a step to run migrations if required
|
||||||
- name: Test with phpunit
|
- name: Test with phpunit
|
||||||
@ -71,7 +75,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
# Docs: https://github.com/shivammathur/setup-php
|
# Docs: https://github.com/shivammathur/setup-php
|
||||||
- name: Setup PHP
|
- name: Setup PHP
|
||||||
@ -85,7 +89,7 @@ jobs:
|
|||||||
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
||||||
|
|
||||||
- name: Cache composer dependencies
|
- name: Cache composer dependencies
|
||||||
uses: actions/cache@v2
|
uses: actions/cache@v3
|
||||||
with:
|
with:
|
||||||
path: ${{ steps.composer-cache.outputs.dir }}
|
path: ${{ steps.composer-cache.outputs.dir }}
|
||||||
# Use composer.json for key, if composer.lock is not committed.
|
# Use composer.json for key, if composer.lock is not committed.
|
||||||
@ -104,7 +108,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
# Docs: https://github.com/shivammathur/setup-php
|
# Docs: https://github.com/shivammathur/setup-php
|
||||||
- name: Setup PHP
|
- name: Setup PHP
|
||||||
@ -119,7 +123,7 @@ jobs:
|
|||||||
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
||||||
|
|
||||||
- name: Cache composer dependencies
|
- name: Cache composer dependencies
|
||||||
uses: actions/cache@v2
|
uses: actions/cache@v3
|
||||||
with:
|
with:
|
||||||
path: ${{ steps.composer-cache.outputs.dir }}
|
path: ${{ steps.composer-cache.outputs.dir }}
|
||||||
# Use composer.json for key, if composer.lock is not committed.
|
# Use composer.json for key, if composer.lock is not committed.
|
||||||
|
@ -8,6 +8,8 @@ jobs:
|
|||||||
matrix:
|
matrix:
|
||||||
php-versions: ['7.4', '8.0', '8.1']
|
php-versions: ['7.4', '8.0', '8.1']
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
# Docs: https://docs.github.com/en/actions/using-containerized-services
|
||||||
services:
|
services:
|
||||||
postgres:
|
postgres:
|
||||||
image: postgres:latest
|
image: postgres:latest
|
||||||
@ -26,7 +28,7 @@ jobs:
|
|||||||
options: --health-cmd="redis-cli ping" --health-interval=10s --health-timeout=5s --health-retries=3
|
options: --health-cmd="redis-cli ping" --health-interval=10s --health-timeout=5s --health-retries=3
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
# Docs: https://github.com/shivammathur/setup-php
|
# Docs: https://github.com/shivammathur/setup-php
|
||||||
- name: Setup PHP
|
- name: Setup PHP
|
||||||
@ -38,12 +40,17 @@ jobs:
|
|||||||
extensions: mbstring, intl, redis, pdo_pgsql
|
extensions: mbstring, intl, redis, pdo_pgsql
|
||||||
coverage: pcov
|
coverage: pcov
|
||||||
|
|
||||||
|
# Local PostgreSQL service in GitHub hosted environments is disabled by default.
|
||||||
|
# If you are using it instead of service containers, make sure you start it.
|
||||||
|
# - name: Start postgresql service
|
||||||
|
# run: sudo systemctl start postgresql.service
|
||||||
|
|
||||||
- name: Get composer cache directory
|
- name: Get composer cache directory
|
||||||
id: composer-cache
|
id: composer-cache
|
||||||
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
||||||
|
|
||||||
- name: Cache composer dependencies
|
- name: Cache composer dependencies
|
||||||
uses: actions/cache@v2
|
uses: actions/cache@v3
|
||||||
with:
|
with:
|
||||||
path: ${{ steps.composer-cache.outputs.dir }}
|
path: ${{ steps.composer-cache.outputs.dir }}
|
||||||
# Use composer.json for key, if composer.lock is not committed.
|
# Use composer.json for key, if composer.lock is not committed.
|
||||||
@ -54,7 +61,7 @@ jobs:
|
|||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
composer install --no-progress --prefer-dist --optimize-autoloader
|
composer install --no-progress --prefer-dist --optimize-autoloader
|
||||||
composer run-script post-install-cmd --no-interaction
|
composer run-script post-install-cmd
|
||||||
|
|
||||||
# Add a step to run migrations if required
|
# Add a step to run migrations if required
|
||||||
- name: Test with phpunit
|
- name: Test with phpunit
|
||||||
@ -68,7 +75,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
# Docs: https://github.com/shivammathur/setup-php
|
# Docs: https://github.com/shivammathur/setup-php
|
||||||
- name: Setup PHP
|
- name: Setup PHP
|
||||||
@ -82,7 +89,7 @@ jobs:
|
|||||||
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
||||||
|
|
||||||
- name: Cache composer dependencies
|
- name: Cache composer dependencies
|
||||||
uses: actions/cache@v2
|
uses: actions/cache@v3
|
||||||
with:
|
with:
|
||||||
path: ${{ steps.composer-cache.outputs.dir }}
|
path: ${{ steps.composer-cache.outputs.dir }}
|
||||||
# Use composer.json for key, if composer.lock is not committed.
|
# Use composer.json for key, if composer.lock is not committed.
|
||||||
@ -101,8 +108,9 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
# Docs: https://github.com/shivammathur/setup-php
|
||||||
- name: Setup PHP
|
- name: Setup PHP
|
||||||
uses: shivammathur/setup-php@v2
|
uses: shivammathur/setup-php@v2
|
||||||
with:
|
with:
|
||||||
@ -115,7 +123,7 @@ jobs:
|
|||||||
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
||||||
|
|
||||||
- name: Cache composer dependencies
|
- name: Cache composer dependencies
|
||||||
uses: actions/cache@v2
|
uses: actions/cache@v3
|
||||||
with:
|
with:
|
||||||
path: ${{ steps.composer-cache.outputs.dir }}
|
path: ${{ steps.composer-cache.outputs.dir }}
|
||||||
# Use composer.json for key, if composer.lock is not committed.
|
# Use composer.json for key, if composer.lock is not committed.
|
||||||
|
@ -11,7 +11,7 @@ jobs:
|
|||||||
runs-on: ${{ matrix.operating-system }}
|
runs-on: ${{ matrix.operating-system }}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
# Docs: https://github.com/shivammathur/setup-php
|
# Docs: https://github.com/shivammathur/setup-php
|
||||||
- name: Setup PHP
|
- name: Setup PHP
|
||||||
@ -26,7 +26,7 @@ jobs:
|
|||||||
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
||||||
|
|
||||||
- name: Cache composer dependencies
|
- name: Cache composer dependencies
|
||||||
uses: actions/cache@v2
|
uses: actions/cache@v3
|
||||||
with:
|
with:
|
||||||
path: ${{ steps.composer-cache.outputs.dir }}
|
path: ${{ steps.composer-cache.outputs.dir }}
|
||||||
# Use composer.json for key, if composer.lock is not committed.
|
# Use composer.json for key, if composer.lock is not committed.
|
||||||
@ -37,7 +37,7 @@ jobs:
|
|||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
composer install --no-progress --prefer-dist --optimize-autoloader
|
composer install --no-progress --prefer-dist --optimize-autoloader
|
||||||
composer run-script post-install-cmd --no-interaction
|
composer run-script post-install-cmd
|
||||||
|
|
||||||
- name: Test with phpunit
|
- name: Test with phpunit
|
||||||
run: vendor/bin/phpunit --coverage-text
|
run: vendor/bin/phpunit --coverage-text
|
||||||
@ -47,7 +47,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
# Docs: https://github.com/shivammathur/setup-php
|
# Docs: https://github.com/shivammathur/setup-php
|
||||||
- name: Setup PHP
|
- name: Setup PHP
|
||||||
@ -60,7 +60,7 @@ jobs:
|
|||||||
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
||||||
|
|
||||||
- name: Cache composer dependencies
|
- name: Cache composer dependencies
|
||||||
uses: actions/cache@v2
|
uses: actions/cache@v3
|
||||||
with:
|
with:
|
||||||
path: ${{ steps.composer-cache.outputs.dir }}
|
path: ${{ steps.composer-cache.outputs.dir }}
|
||||||
# Use composer.json for key, if composer.lock is not committed.
|
# Use composer.json for key, if composer.lock is not committed.
|
||||||
@ -79,7 +79,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
# Docs: https://github.com/shivammathur/setup-php
|
# Docs: https://github.com/shivammathur/setup-php
|
||||||
- name: Setup PHP
|
- name: Setup PHP
|
||||||
@ -94,7 +94,7 @@ jobs:
|
|||||||
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
||||||
|
|
||||||
- name: Cache composer dependencies
|
- name: Cache composer dependencies
|
||||||
uses: actions/cache@v2
|
uses: actions/cache@v3
|
||||||
with:
|
with:
|
||||||
path: ${{ steps.composer-cache.outputs.dir }}
|
path: ${{ steps.composer-cache.outputs.dir }}
|
||||||
# Use composer.json for key, if composer.lock is not committed.
|
# Use composer.json for key, if composer.lock is not committed.
|
||||||
|
@ -10,7 +10,7 @@ jobs:
|
|||||||
runs-on: ${{ matrix.operating-system }}
|
runs-on: ${{ matrix.operating-system }}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
# Docs: https://github.com/shivammathur/setup-php
|
# Docs: https://github.com/shivammathur/setup-php
|
||||||
- name: Setup PHP
|
- name: Setup PHP
|
||||||
@ -25,7 +25,7 @@ jobs:
|
|||||||
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
||||||
|
|
||||||
- name: Cache composer dependencies
|
- name: Cache composer dependencies
|
||||||
uses: actions/cache@v2
|
uses: actions/cache@v3
|
||||||
with:
|
with:
|
||||||
path: ${{ steps.composer-cache.outputs.dir }}
|
path: ${{ steps.composer-cache.outputs.dir }}
|
||||||
# Use composer.json for key, if composer.lock is not committed.
|
# Use composer.json for key, if composer.lock is not committed.
|
||||||
|
@ -10,7 +10,7 @@ jobs:
|
|||||||
runs-on: ${{ matrix.operating-system }}
|
runs-on: ${{ matrix.operating-system }}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
# Docs: https://github.com/shivammathur/setup-php
|
# Docs: https://github.com/shivammathur/setup-php
|
||||||
- name: Setup PHP
|
- name: Setup PHP
|
||||||
@ -24,7 +24,7 @@ jobs:
|
|||||||
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
||||||
|
|
||||||
- name: Cache composer dependencies
|
- name: Cache composer dependencies
|
||||||
uses: actions/cache@v2
|
uses: actions/cache@v3
|
||||||
with:
|
with:
|
||||||
path: ${{ steps.composer-cache.outputs.dir }}
|
path: ${{ steps.composer-cache.outputs.dir }}
|
||||||
# Use composer.json for key, if composer.lock is not committed.
|
# Use composer.json for key, if composer.lock is not committed.
|
||||||
|
@ -12,7 +12,9 @@ jobs:
|
|||||||
BROADCAST_DRIVER: log
|
BROADCAST_DRIVER: log
|
||||||
CACHE_DRIVER: redis
|
CACHE_DRIVER: redis
|
||||||
QUEUE_CONNECTION: redis
|
QUEUE_CONNECTION: redis
|
||||||
SESSION_DRIVER: redis
|
SESSION_DRIVER: redis
|
||||||
|
|
||||||
|
# Docs: https://docs.github.com/en/actions/using-containerized-services
|
||||||
services:
|
services:
|
||||||
mysql:
|
mysql:
|
||||||
image: mysql:latest
|
image: mysql:latest
|
||||||
@ -35,7 +37,7 @@ jobs:
|
|||||||
php-versions: ['7.4', '8.0', '8.1']
|
php-versions: ['7.4', '8.0', '8.1']
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
# Docs: https://github.com/shivammathur/setup-php
|
# Docs: https://github.com/shivammathur/setup-php
|
||||||
- name: Setup PHP
|
- name: Setup PHP
|
||||||
@ -45,15 +47,17 @@ jobs:
|
|||||||
extensions: mbstring, dom, fileinfo, mysql
|
extensions: mbstring, dom, fileinfo, mysql
|
||||||
coverage: xdebug
|
coverage: xdebug
|
||||||
|
|
||||||
- name: Start mysql service
|
# Local MySQL service in GitHub hosted environments is disabled by default.
|
||||||
run: sudo systemctl start mysql
|
# If you are using it instead of service containers, make sure you start it.
|
||||||
|
# - name: Start mysql service
|
||||||
|
# run: sudo systemctl start mysql.service
|
||||||
|
|
||||||
- name: Get composer cache directory
|
- name: Get composer cache directory
|
||||||
id: composer-cache
|
id: composer-cache
|
||||||
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
||||||
|
|
||||||
- name: Cache composer dependencies
|
- name: Cache composer dependencies
|
||||||
uses: actions/cache@v2
|
uses: actions/cache@v3
|
||||||
with:
|
with:
|
||||||
path: ${{ steps.composer-cache.outputs.dir }}
|
path: ${{ steps.composer-cache.outputs.dir }}
|
||||||
# Use composer.json for key, if composer.lock is not committed.
|
# Use composer.json for key, if composer.lock is not committed.
|
||||||
|
@ -15,6 +15,8 @@ jobs:
|
|||||||
DB_PASSWORD: postgres
|
DB_PASSWORD: postgres
|
||||||
DB_USERNAME: postgres
|
DB_USERNAME: postgres
|
||||||
DB_DATABASE: postgres
|
DB_DATABASE: postgres
|
||||||
|
|
||||||
|
# Docs: https://docs.github.com/en/actions/using-containerized-services
|
||||||
services:
|
services:
|
||||||
postgres:
|
postgres:
|
||||||
image: postgres:latest
|
image: postgres:latest
|
||||||
@ -37,7 +39,7 @@ jobs:
|
|||||||
php-versions: ['7.4', '8.0', '8.1']
|
php-versions: ['7.4', '8.0', '8.1']
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
# Docs: https://github.com/shivammathur/setup-php
|
# Docs: https://github.com/shivammathur/setup-php
|
||||||
- name: Setup PHP
|
- name: Setup PHP
|
||||||
@ -47,12 +49,17 @@ jobs:
|
|||||||
extensions: mbstring, dom, fileinfo, pgsql
|
extensions: mbstring, dom, fileinfo, pgsql
|
||||||
coverage: xdebug
|
coverage: xdebug
|
||||||
|
|
||||||
|
# Local PostgreSQL service in GitHub hosted environments is disabled by default.
|
||||||
|
# If you are using it instead of service containers, make sure you start it.
|
||||||
|
# - name: Start postgresql service
|
||||||
|
# run: sudo systemctl start postgresql.service
|
||||||
|
|
||||||
- name: Get composer cache directory
|
- name: Get composer cache directory
|
||||||
id: composer-cache
|
id: composer-cache
|
||||||
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
||||||
|
|
||||||
- name: Cache composer dependencies
|
- name: Cache composer dependencies
|
||||||
uses: actions/cache@v2
|
uses: actions/cache@v3
|
||||||
with:
|
with:
|
||||||
path: ${{ steps.composer-cache.outputs.dir }}
|
path: ${{ steps.composer-cache.outputs.dir }}
|
||||||
# Use composer.json for key, if composer.lock is not committed.
|
# Use composer.json for key, if composer.lock is not committed.
|
||||||
|
@ -12,7 +12,7 @@ jobs:
|
|||||||
php-versions: ['7.4', '8.0', '8.1']
|
php-versions: ['7.4', '8.0', '8.1']
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
# Docs: https://github.com/shivammathur/setup-php
|
# Docs: https://github.com/shivammathur/setup-php
|
||||||
- name: Setup PHP
|
- name: Setup PHP
|
||||||
@ -27,7 +27,7 @@ jobs:
|
|||||||
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
||||||
|
|
||||||
- name: Cache composer dependencies
|
- name: Cache composer dependencies
|
||||||
uses: actions/cache@v2
|
uses: actions/cache@v3
|
||||||
with:
|
with:
|
||||||
path: ${{ steps.composer-cache.outputs.dir }}
|
path: ${{ steps.composer-cache.outputs.dir }}
|
||||||
# Use composer.json for key, if composer.lock is not committed.
|
# Use composer.json for key, if composer.lock is not committed.
|
||||||
|
@ -13,6 +13,8 @@ jobs:
|
|||||||
CACHE_DRIVER: redis
|
CACHE_DRIVER: redis
|
||||||
QUEUE_CONNECTION: redis
|
QUEUE_CONNECTION: redis
|
||||||
SESSION_DRIVER: redis
|
SESSION_DRIVER: redis
|
||||||
|
|
||||||
|
# Docs: https://docs.github.com/en/actions/using-containerized-services
|
||||||
services:
|
services:
|
||||||
mysql:
|
mysql:
|
||||||
image: mysql:latest
|
image: mysql:latest
|
||||||
@ -35,7 +37,7 @@ jobs:
|
|||||||
php-versions: ['7.4', '8.0', '8.1']
|
php-versions: ['7.4', '8.0', '8.1']
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
# Docs: https://github.com/shivammathur/setup-php
|
# Docs: https://github.com/shivammathur/setup-php
|
||||||
- name: Setup PHP
|
- name: Setup PHP
|
||||||
@ -45,15 +47,17 @@ jobs:
|
|||||||
extensions: mbstring, dom, fileinfo, mysql
|
extensions: mbstring, dom, fileinfo, mysql
|
||||||
coverage: xdebug
|
coverage: xdebug
|
||||||
|
|
||||||
- name: Start mysql service
|
# Local MySQL service in GitHub hosted environments is disabled by default.
|
||||||
run: sudo systemctl start mysql
|
# If you are using it instead of service containers, make sure you start it.
|
||||||
|
# - name: Start mysql service
|
||||||
|
# run: sudo systemctl start mysql.service
|
||||||
|
|
||||||
- name: Get composer cache directory
|
- name: Get composer cache directory
|
||||||
id: composer-cache
|
id: composer-cache
|
||||||
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
||||||
|
|
||||||
- name: Cache composer dependencies
|
- name: Cache composer dependencies
|
||||||
uses: actions/cache@v2
|
uses: actions/cache@v3
|
||||||
with:
|
with:
|
||||||
path: ${{ steps.composer-cache.outputs.dir }}
|
path: ${{ steps.composer-cache.outputs.dir }}
|
||||||
# Use composer.json for key, if composer.lock is not committed.
|
# Use composer.json for key, if composer.lock is not committed.
|
||||||
|
@ -15,6 +15,8 @@ jobs:
|
|||||||
DB_PASSWORD: postgres
|
DB_PASSWORD: postgres
|
||||||
DB_USERNAME: postgres
|
DB_USERNAME: postgres
|
||||||
DB_DATABASE: postgres
|
DB_DATABASE: postgres
|
||||||
|
|
||||||
|
# Docs: https://docs.github.com/en/actions/using-containerized-services
|
||||||
services:
|
services:
|
||||||
postgres:
|
postgres:
|
||||||
image: postgres:latest
|
image: postgres:latest
|
||||||
@ -37,7 +39,7 @@ jobs:
|
|||||||
php-versions: ['7.4', '8.0', '8.1']
|
php-versions: ['7.4', '8.0', '8.1']
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
# Docs: https://github.com/shivammathur/setup-php
|
# Docs: https://github.com/shivammathur/setup-php
|
||||||
- name: Setup PHP
|
- name: Setup PHP
|
||||||
@ -47,12 +49,17 @@ jobs:
|
|||||||
extensions: mbstring, dom, fileinfo, pgsql
|
extensions: mbstring, dom, fileinfo, pgsql
|
||||||
coverage: xdebug
|
coverage: xdebug
|
||||||
|
|
||||||
|
# Local PostgreSQL service in GitHub hosted environments is disabled by default.
|
||||||
|
# If you are using it instead of service containers, make sure you start it.
|
||||||
|
# - name: Start postgresql service
|
||||||
|
# run: sudo systemctl start postgresql.service
|
||||||
|
|
||||||
- name: Get composer cache directory
|
- name: Get composer cache directory
|
||||||
id: composer-cache
|
id: composer-cache
|
||||||
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
||||||
|
|
||||||
- name: Cache composer dependencies
|
- name: Cache composer dependencies
|
||||||
uses: actions/cache@v2
|
uses: actions/cache@v3
|
||||||
with:
|
with:
|
||||||
path: ${{ steps.composer-cache.outputs.dir }}
|
path: ${{ steps.composer-cache.outputs.dir }}
|
||||||
# Use composer.json for key, if composer.lock is not committed.
|
# Use composer.json for key, if composer.lock is not committed.
|
||||||
|
@ -12,7 +12,7 @@ jobs:
|
|||||||
php-versions: ['7.4', '8.0', '8.1']
|
php-versions: ['7.4', '8.0', '8.1']
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
# Docs: https://github.com/shivammathur/setup-php
|
# Docs: https://github.com/shivammathur/setup-php
|
||||||
- name: Setup PHP
|
- name: Setup PHP
|
||||||
@ -27,7 +27,7 @@ jobs:
|
|||||||
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
||||||
|
|
||||||
- name: Cache composer dependencies
|
- name: Cache composer dependencies
|
||||||
uses: actions/cache@v2
|
uses: actions/cache@v3
|
||||||
with:
|
with:
|
||||||
path: ${{ steps.composer-cache.outputs.dir }}
|
path: ${{ steps.composer-cache.outputs.dir }}
|
||||||
# Use composer.json for key, if composer.lock is not committed.
|
# Use composer.json for key, if composer.lock is not committed.
|
||||||
|
@ -16,6 +16,8 @@ jobs:
|
|||||||
DB_PASSWORD: password
|
DB_PASSWORD: password
|
||||||
CODECEPTION_URL: 127.0.0.1
|
CODECEPTION_URL: 127.0.0.1
|
||||||
CODECEPTION_PORT: 8888
|
CODECEPTION_PORT: 8888
|
||||||
|
|
||||||
|
# Docs: https://docs.github.com/en/actions/using-containerized-services
|
||||||
services:
|
services:
|
||||||
mysql:
|
mysql:
|
||||||
image: mysql:latest
|
image: mysql:latest
|
||||||
@ -34,7 +36,7 @@ jobs:
|
|||||||
# php-versions: ['7.0', '7.1', '7.2', '7.3']
|
# php-versions: ['7.0', '7.1', '7.2', '7.3']
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
# Docs: https://github.com/shivammathur/setup-php
|
# Docs: https://github.com/shivammathur/setup-php
|
||||||
- name: Setup PHP
|
- name: Setup PHP
|
||||||
@ -45,15 +47,17 @@ jobs:
|
|||||||
extensions: mbstring, dom, zip, phalcon4, mysql
|
extensions: mbstring, dom, zip, phalcon4, mysql
|
||||||
coverage: xdebug
|
coverage: xdebug
|
||||||
|
|
||||||
- name: Start mysql service
|
# Local MySQL service in GitHub hosted environments is disabled by default.
|
||||||
run: sudo systemctl start mysql
|
# If you are using it instead of service containers, make sure you start it.
|
||||||
|
# - name: Start mysql service
|
||||||
|
# run: sudo systemctl start mysql.service
|
||||||
|
|
||||||
- name: Get composer cache directory
|
- name: Get composer cache directory
|
||||||
id: composer-cache
|
id: composer-cache
|
||||||
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
||||||
|
|
||||||
- name: Cache composer dependencies
|
- name: Cache composer dependencies
|
||||||
uses: actions/cache@v2
|
uses: actions/cache@v3
|
||||||
with:
|
with:
|
||||||
path: ${{ steps.composer-cache.outputs.dir }}
|
path: ${{ steps.composer-cache.outputs.dir }}
|
||||||
# Use composer.json for key, if composer.lock is not committed.
|
# Use composer.json for key, if composer.lock is not committed.
|
||||||
|
@ -17,6 +17,8 @@ jobs:
|
|||||||
CODECEPTION_URL: 127.0.0.1
|
CODECEPTION_URL: 127.0.0.1
|
||||||
CODECEPTION_PORT: 8888
|
CODECEPTION_PORT: 8888
|
||||||
DB_CONNECTION: pgsql
|
DB_CONNECTION: pgsql
|
||||||
|
|
||||||
|
# Docs: https://docs.github.com/en/actions/using-containerized-services
|
||||||
services:
|
services:
|
||||||
postgres:
|
postgres:
|
||||||
image: postgres:latest
|
image: postgres:latest
|
||||||
@ -35,7 +37,7 @@ jobs:
|
|||||||
# php-versions: ['7.0', '7.1', '7.2', '7.3']
|
# php-versions: ['7.0', '7.1', '7.2', '7.3']
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
# Docs: https://github.com/shivammathur/setup-php
|
# Docs: https://github.com/shivammathur/setup-php
|
||||||
- name: Setup PHP
|
- name: Setup PHP
|
||||||
@ -46,11 +48,16 @@ jobs:
|
|||||||
extensions: mbstring, dom, zip, phalcon4, pgsql
|
extensions: mbstring, dom, zip, phalcon4, pgsql
|
||||||
coverage: xdebug
|
coverage: xdebug
|
||||||
|
|
||||||
|
# Local PostgreSQL service in GitHub hosted environments is disabled by default.
|
||||||
|
# If you are using it instead of service containers, make sure you start it.
|
||||||
|
# - name: Start postgresql service
|
||||||
|
# run: sudo systemctl start postgresql.service
|
||||||
|
|
||||||
- name: Get composer cache directory
|
- name: Get composer cache directory
|
||||||
id: composer-cache
|
id: composer-cache
|
||||||
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
||||||
- name: Cache composer dependencies
|
- name: Cache composer dependencies
|
||||||
uses: actions/cache@v2
|
uses: actions/cache@v3
|
||||||
with:
|
with:
|
||||||
path: ${{ steps.composer-cache.outputs.dir }}
|
path: ${{ steps.composer-cache.outputs.dir }}
|
||||||
# Use composer.json for key, if composer.lock is not committed.
|
# Use composer.json for key, if composer.lock is not committed.
|
||||||
|
@ -12,7 +12,7 @@ jobs:
|
|||||||
node-versions: [16']
|
node-versions: [16']
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Setup Node.js
|
- name: Setup Node.js
|
||||||
uses: actions/setup-node@v1
|
uses: actions/setup-node@v1
|
||||||
@ -33,7 +33,7 @@ jobs:
|
|||||||
id: yarn-cache
|
id: yarn-cache
|
||||||
run: echo "::set-output name=dir::$(yarn cache dir)"
|
run: echo "::set-output name=dir::$(yarn cache dir)"
|
||||||
|
|
||||||
- uses: actions/cache@v2
|
- uses: actions/cache@v3
|
||||||
with:
|
with:
|
||||||
path: ${{ steps.yarn-cache.outputs.dir }}
|
path: ${{ steps.yarn-cache.outputs.dir }}
|
||||||
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
|
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
|
||||||
@ -44,7 +44,7 @@ jobs:
|
|||||||
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
||||||
|
|
||||||
- name: Cache composer dependencies
|
- name: Cache composer dependencies
|
||||||
uses: actions/cache@v2
|
uses: actions/cache@v3
|
||||||
with:
|
with:
|
||||||
path: ${{ steps.composer-cache.outputs.dir }}
|
path: ${{ steps.composer-cache.outputs.dir }}
|
||||||
# Use composer.json for key, if composer.lock is not committed.
|
# Use composer.json for key, if composer.lock is not committed.
|
||||||
|
@ -10,7 +10,7 @@ jobs:
|
|||||||
runs-on: ${{ matrix.operating-system }}
|
runs-on: ${{ matrix.operating-system }}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
# Docs: https://github.com/shivammathur/setup-php
|
# Docs: https://github.com/shivammathur/setup-php
|
||||||
- name: Setup PHP
|
- name: Setup PHP
|
||||||
@ -25,7 +25,7 @@ jobs:
|
|||||||
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
||||||
|
|
||||||
- name: Cache composer dependencies
|
- name: Cache composer dependencies
|
||||||
uses: actions/cache@v2
|
uses: actions/cache@v3
|
||||||
with:
|
with:
|
||||||
path: ${{ steps.composer-cache.outputs.dir }}
|
path: ${{ steps.composer-cache.outputs.dir }}
|
||||||
# Use composer.json for key, if composer.lock is not committed.
|
# Use composer.json for key, if composer.lock is not committed.
|
||||||
|
@ -5,6 +5,8 @@ jobs:
|
|||||||
symfony:
|
symfony:
|
||||||
name: Symfony (PHP ${{ matrix.php-versions }})
|
name: Symfony (PHP ${{ matrix.php-versions }})
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
# Docs: https://docs.github.com/en/actions/using-containerized-services
|
||||||
services:
|
services:
|
||||||
mysql:
|
mysql:
|
||||||
image: mysql:latest
|
image: mysql:latest
|
||||||
@ -21,7 +23,7 @@ jobs:
|
|||||||
php-versions: ['7.4', '8.0', '8.1']
|
php-versions: ['7.4', '8.0', '8.1']
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
# Docs: https://github.com/shivammathur/setup-php
|
# Docs: https://github.com/shivammathur/setup-php
|
||||||
- name: Setup PHP
|
- name: Setup PHP
|
||||||
@ -32,15 +34,17 @@ jobs:
|
|||||||
extensions: mbstring, xml, ctype, iconv, intl, pdo_sqlite, mysql
|
extensions: mbstring, xml, ctype, iconv, intl, pdo_sqlite, mysql
|
||||||
coverage: xdebug
|
coverage: xdebug
|
||||||
|
|
||||||
- name: Start mysql service
|
# Local MySQL service in GitHub hosted environments is disabled by default.
|
||||||
run: sudo systemctl start mysql
|
# If you are using it instead of service containers, make sure you start it.
|
||||||
|
# - name: Start mysql service
|
||||||
|
# run: sudo systemctl start mysql.service
|
||||||
|
|
||||||
- name: Get composer cache directory
|
- name: Get composer cache directory
|
||||||
id: composer-cache
|
id: composer-cache
|
||||||
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
||||||
|
|
||||||
- name: Cache composer dependencies
|
- name: Cache composer dependencies
|
||||||
uses: actions/cache@v2
|
uses: actions/cache@v3
|
||||||
with:
|
with:
|
||||||
path: ${{ steps.composer-cache.outputs.dir }}
|
path: ${{ steps.composer-cache.outputs.dir }}
|
||||||
# Use composer.json for key, if composer.lock is not committed.
|
# Use composer.json for key, if composer.lock is not committed.
|
||||||
|
@ -5,6 +5,8 @@ jobs:
|
|||||||
symfony:
|
symfony:
|
||||||
name: Symfony (PHP ${{ matrix.php-versions }})
|
name: Symfony (PHP ${{ matrix.php-versions }})
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
# Docs: https://docs.github.com/en/actions/using-containerized-services
|
||||||
services:
|
services:
|
||||||
postgres:
|
postgres:
|
||||||
image: postgres:latest
|
image: postgres:latest
|
||||||
@ -21,7 +23,7 @@ jobs:
|
|||||||
php-versions: ['7.4', '8.0', '8.1']
|
php-versions: ['7.4', '8.0', '8.1']
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
# Docs: https://github.com/shivammathur/setup-php
|
# Docs: https://github.com/shivammathur/setup-php
|
||||||
- name: Setup PHP
|
- name: Setup PHP
|
||||||
@ -32,12 +34,17 @@ jobs:
|
|||||||
extensions: mbstring, xml, ctype, iconv, intl, pdo_sqlite, pgsql
|
extensions: mbstring, xml, ctype, iconv, intl, pdo_sqlite, pgsql
|
||||||
coverage: xdebug
|
coverage: xdebug
|
||||||
|
|
||||||
|
# Local PostgreSQL service in GitHub hosted environments is disabled by default.
|
||||||
|
# If you are using it instead of service containers, make sure you start it.
|
||||||
|
# - name: Start postgresql service
|
||||||
|
# run: sudo systemctl start postgresql.service
|
||||||
|
|
||||||
- name: Get composer cache directory
|
- name: Get composer cache directory
|
||||||
id: composer-cache
|
id: composer-cache
|
||||||
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
||||||
|
|
||||||
- name: Cache composer dependencies
|
- name: Cache composer dependencies
|
||||||
uses: actions/cache@v2
|
uses: actions/cache@v3
|
||||||
with:
|
with:
|
||||||
path: ${{ steps.composer-cache.outputs.dir }}
|
path: ${{ steps.composer-cache.outputs.dir }}
|
||||||
# Use composer.json for key, if composer.lock is not committed.
|
# Use composer.json for key, if composer.lock is not committed.
|
||||||
|
@ -12,7 +12,7 @@ jobs:
|
|||||||
php-versions: ['7.4', '8.0', '8.1']
|
php-versions: ['7.4', '8.0', '8.1']
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
# Docs: https://github.com/shivammathur/setup-php
|
# Docs: https://github.com/shivammathur/setup-php
|
||||||
- name: Setup PHP
|
- name: Setup PHP
|
||||||
@ -28,7 +28,7 @@ jobs:
|
|||||||
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
||||||
|
|
||||||
- name: Cache composer dependencies
|
- name: Cache composer dependencies
|
||||||
uses: actions/cache@v2
|
uses: actions/cache@v3
|
||||||
with:
|
with:
|
||||||
path: ${{ steps.composer-cache.outputs.dir }}
|
path: ${{ steps.composer-cache.outputs.dir }}
|
||||||
# Use composer.json for key, if composer.lock is not committed.
|
# Use composer.json for key, if composer.lock is not committed.
|
||||||
|
@ -11,6 +11,8 @@ jobs:
|
|||||||
TEST_DB_USERNAME: root
|
TEST_DB_USERNAME: root
|
||||||
TEST_DB_PASSWORD: yii
|
TEST_DB_PASSWORD: yii
|
||||||
DB_CHARSET: utf8
|
DB_CHARSET: utf8
|
||||||
|
|
||||||
|
# Docs: https://docs.github.com/en/actions/using-containerized-services
|
||||||
services:
|
services:
|
||||||
mysql:
|
mysql:
|
||||||
image: mysql:latest
|
image: mysql:latest
|
||||||
@ -27,7 +29,7 @@ jobs:
|
|||||||
php-versions: ['7.4', '8.0']
|
php-versions: ['7.4', '8.0']
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Set Node.js 10.x
|
- name: Set Node.js 10.x
|
||||||
uses: actions/setup-node@v1
|
uses: actions/setup-node@v1
|
||||||
@ -42,15 +44,17 @@ jobs:
|
|||||||
extensions: mbstring, intl, gd, imagick, zip, dom, mysql
|
extensions: mbstring, intl, gd, imagick, zip, dom, mysql
|
||||||
coverage: xdebug
|
coverage: xdebug
|
||||||
|
|
||||||
- name: Start mysql service
|
# Local MySQL service in GitHub hosted environments is disabled by default.
|
||||||
run: sudo systemctl start mysql
|
# If you are using it instead of service containers, make sure you start it.
|
||||||
|
# - name: Start mysql service
|
||||||
|
# run: sudo systemctl start mysql.service
|
||||||
|
|
||||||
- name: Get composer cache directory
|
- name: Get composer cache directory
|
||||||
id: composer-cache
|
id: composer-cache
|
||||||
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
||||||
|
|
||||||
- name: Cache composer dependencies
|
- name: Cache composer dependencies
|
||||||
uses: actions/cache@v2
|
uses: actions/cache@v3
|
||||||
with:
|
with:
|
||||||
path: ${{ steps.composer-cache.outputs.dir }}
|
path: ${{ steps.composer-cache.outputs.dir }}
|
||||||
# Use composer.json for key, if composer.lock is not committed.
|
# Use composer.json for key, if composer.lock is not committed.
|
||||||
|
@ -11,6 +11,8 @@ jobs:
|
|||||||
TEST_DB_USERNAME: postgres
|
TEST_DB_USERNAME: postgres
|
||||||
TEST_DB_PASSWORD: postgres
|
TEST_DB_PASSWORD: postgres
|
||||||
DB_CHARSET: utf8
|
DB_CHARSET: utf8
|
||||||
|
|
||||||
|
# Docs: https://docs.github.com/en/actions/using-containerized-services
|
||||||
services:
|
services:
|
||||||
postgres:
|
postgres:
|
||||||
image: postgres:latest
|
image: postgres:latest
|
||||||
@ -27,7 +29,7 @@ jobs:
|
|||||||
php-versions: ['7.4', '8.0']
|
php-versions: ['7.4', '8.0']
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Set Node.js 10.x
|
- name: Set Node.js 10.x
|
||||||
uses: actions/setup-node@v1
|
uses: actions/setup-node@v1
|
||||||
@ -42,12 +44,17 @@ jobs:
|
|||||||
extensions: mbstring, intl, gd, imagick, zip, dom, pgsql
|
extensions: mbstring, intl, gd, imagick, zip, dom, pgsql
|
||||||
coverage: xdebug
|
coverage: xdebug
|
||||||
|
|
||||||
|
# Local PostgreSQL service in GitHub hosted environments is disabled by default.
|
||||||
|
# If you are using it instead of service containers, make sure you start it.
|
||||||
|
# - name: Start postgresql service
|
||||||
|
# run: sudo systemctl start postgresql.service
|
||||||
|
|
||||||
- name: Get composer cache directory
|
- name: Get composer cache directory
|
||||||
id: composer-cache
|
id: composer-cache
|
||||||
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
||||||
|
|
||||||
- name: Cache composer dependencies
|
- name: Cache composer dependencies
|
||||||
uses: actions/cache@v2
|
uses: actions/cache@v3
|
||||||
with:
|
with:
|
||||||
path: ${{ steps.composer-cache.outputs.dir }}
|
path: ${{ steps.composer-cache.outputs.dir }}
|
||||||
# Use composer.json for key, if composer.lock is not committed.
|
# Use composer.json for key, if composer.lock is not committed.
|
||||||
|
3763
package-lock.json
generated
3763
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
41
package.json
41
package.json
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "setup-php",
|
"name": "setup-php",
|
||||||
"version": "2.16.0",
|
"version": "2.18.0",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "Setup PHP for use with GitHub Actions",
|
"description": "Setup PHP for use with GitHub Actions",
|
||||||
"main": "lib/install.js",
|
"main": "lib/install.js",
|
||||||
@ -16,9 +16,9 @@
|
|||||||
],
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "tsc",
|
"build": "tsc",
|
||||||
"lint": "eslint **/src/*.ts --cache --fix",
|
"lint": "eslint **/src/*.ts **/__tests__/*.ts --cache --fix",
|
||||||
"format": "prettier --write **/src/*.ts && git add -f src/",
|
"format": "prettier --write **/src/*.ts **/__tests__/*.ts && git add -f src/",
|
||||||
"format-check": "prettier --check **/src/*.ts",
|
"format-check": "prettier --check **/src/*.ts **/__tests__/*.ts",
|
||||||
"release": "ncc build -o dist && git add -f dist/",
|
"release": "ncc build -o dist && git add -f dist/",
|
||||||
"test": "jest"
|
"test": "jest"
|
||||||
},
|
},
|
||||||
@ -35,27 +35,28 @@
|
|||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^1.6.0",
|
"@actions/core": "^1.6.0",
|
||||||
"@actions/exec": "^1.1.0",
|
"@actions/exec": "^1.1.1",
|
||||||
"@actions/io": "^1.1.1",
|
"@actions/io": "^1.1.2",
|
||||||
"fs": "0.0.1-security"
|
"fs": "0.0.1-security"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/jest": "^27.0.3",
|
"@types/jest": "^27.4.1",
|
||||||
"@types/node": "^16.11.10",
|
"@types/node": "^17.0.22",
|
||||||
"@typescript-eslint/eslint-plugin": "^5.4.0",
|
"@typescript-eslint/eslint-plugin": "^5.16.0",
|
||||||
"@typescript-eslint/parser": "^5.4.0",
|
"@typescript-eslint/parser": "^5.16.0",
|
||||||
"@vercel/ncc": "^0.32.0",
|
"@vercel/ncc": "^0.33.3",
|
||||||
"eslint": "^8.3.0",
|
"eslint": "^8.11.0",
|
||||||
"eslint-config-prettier": "^8.3.0",
|
"eslint-config-prettier": "^8.5.0",
|
||||||
"eslint-plugin-import": "^2.25.3",
|
"eslint-plugin-import": "^2.25.4",
|
||||||
"eslint-plugin-jest": "^25.3.0",
|
"eslint-plugin-jest": "^26.1.2",
|
||||||
"eslint-plugin-prettier": "^4.0.0",
|
"eslint-plugin-prettier": "^4.0.0",
|
||||||
"jest": "^27.3.1",
|
"jest": "^27.5.1",
|
||||||
"jest-circus": "^27.3.1",
|
"jest-circus": "^27.5.1",
|
||||||
"prettier": "^2.5.0",
|
"nock": "^13.2.4",
|
||||||
|
"prettier": "^2.6.0",
|
||||||
"simple-git-hooks": "^2.7.0",
|
"simple-git-hooks": "^2.7.0",
|
||||||
"ts-jest": "^27.0.7",
|
"ts-jest": "^27.1.3",
|
||||||
"typescript": "^4.5.2"
|
"typescript": "^4.6.2"
|
||||||
},
|
},
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://github.com/shivammathur/setup-php/issues"
|
"url": "https://github.com/shivammathur/setup-php/issues"
|
||||||
|
@ -45,28 +45,28 @@ export async function addINIValuesWindows(
|
|||||||
* Function to add custom ini values
|
* Function to add custom ini values
|
||||||
*
|
*
|
||||||
* @param ini_values_csv
|
* @param ini_values_csv
|
||||||
* @param os_version
|
* @param os
|
||||||
* @param no_step
|
* @param no_step
|
||||||
*/
|
*/
|
||||||
export async function addINIValues(
|
export async function addINIValues(
|
||||||
ini_values_csv: string,
|
ini_values_csv: string,
|
||||||
os_version: string,
|
os: string,
|
||||||
no_step = false
|
no_step = false
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
let script = '\n';
|
let script = '\n';
|
||||||
switch (no_step) {
|
switch (no_step) {
|
||||||
case true:
|
case true:
|
||||||
script +=
|
script +=
|
||||||
(await utils.stepLog('Add php.ini values', os_version)) +
|
(await utils.stepLog('Add php.ini values', os)) +
|
||||||
(await utils.suppressOutput(os_version)) +
|
(await utils.suppressOutput(os)) +
|
||||||
'\n';
|
'\n';
|
||||||
break;
|
break;
|
||||||
case false:
|
case false:
|
||||||
default:
|
default:
|
||||||
script += (await utils.stepLog('Add php.ini values', os_version)) + '\n';
|
script += (await utils.stepLog('Add php.ini values', os)) + '\n';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
switch (os_version) {
|
switch (os) {
|
||||||
case 'win32':
|
case 'win32':
|
||||||
return script + (await addINIValuesWindows(ini_values_csv));
|
return script + (await addINIValuesWindows(ini_values_csv));
|
||||||
case 'darwin':
|
case 'darwin':
|
||||||
@ -74,8 +74,8 @@ export async function addINIValues(
|
|||||||
return script + (await addINIValuesUnix(ini_values_csv));
|
return script + (await addINIValuesUnix(ini_values_csv));
|
||||||
default:
|
default:
|
||||||
return await utils.log(
|
return await utils.log(
|
||||||
'Platform ' + os_version + ' is not supported',
|
'Platform ' + os + ' is not supported',
|
||||||
os_version,
|
os,
|
||||||
'error'
|
'error'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
amqp=amqp
|
amqp=amqp
|
||||||
apcu=apcu
|
apcu=apcu
|
||||||
expect=expect
|
expect=expect
|
||||||
|
gnupg=gnupg
|
||||||
grpc=grpc
|
grpc=grpc
|
||||||
igbinary=igbinary
|
igbinary=igbinary
|
||||||
imagick=imagick
|
imagick=imagick
|
||||||
imap=imap
|
imap=imap
|
||||||
mailparse=mailparse
|
mailparse=mailparse
|
||||||
|
mcrypt=mcrypt
|
||||||
memcache=memcache
|
memcache=memcache
|
||||||
memcached=memcached
|
memcached=memcached
|
||||||
mongodb=mongodb
|
mongodb=mongodb
|
||||||
|
2
src/configs/composer.env
Normal file
2
src/configs/composer.env
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
COMPOSER_PROCESS_TIMEOUT=0
|
||||||
|
COMPOSER_NO_INTERACTION=1
|
3
src/configs/ini/jit.ini
Normal file
3
src/configs/ini/jit.ini
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
opcache.enable=1
|
||||||
|
opcache.jit_buffer_size=256M
|
||||||
|
opcache.jit=1235
|
2
src/configs/ini/php.ini
Normal file
2
src/configs/ini/php.ini
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
date.timezone=UTC
|
||||||
|
memory_limit=-1
|
1
src/configs/ini/xdebug.ini
Normal file
1
src/configs/ini/xdebug.ini
Normal file
@ -0,0 +1 @@
|
|||||||
|
xdebug.mode=coverage
|
@ -3,6 +3,7 @@
|
|||||||
10,buster
|
10,buster
|
||||||
11,bullseye
|
11,bullseye
|
||||||
12,bookworm
|
12,bookworm
|
||||||
|
13,trixie
|
||||||
16.04 LTS,xenial
|
16.04 LTS,xenial
|
||||||
16.10,yakkety
|
16.10,yakkety
|
||||||
17.04,zesty
|
17.04,zesty
|
||||||
@ -15,3 +16,4 @@
|
|||||||
20.10,groovy
|
20.10,groovy
|
||||||
21.04,hirsute
|
21.04,hirsute
|
||||||
21.10,impish
|
21.10,impish
|
||||||
|
22.04,jammy
|
||||||
|
|
12
src/configs/php_packages
Normal file
12
src/configs/php_packages
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
cgi
|
||||||
|
cli
|
||||||
|
curl
|
||||||
|
dev
|
||||||
|
fpm
|
||||||
|
intl
|
||||||
|
mbstring
|
||||||
|
mysql
|
||||||
|
opcache
|
||||||
|
pgsql
|
||||||
|
xml
|
||||||
|
zip
|
@ -1,4 +1,12 @@
|
|||||||
{
|
{
|
||||||
|
"churn": {
|
||||||
|
"type": "phar",
|
||||||
|
"repository": "bmitch/churn-php",
|
||||||
|
"extension": ".phar",
|
||||||
|
"domain": "https://github.com",
|
||||||
|
"version_prefix": "",
|
||||||
|
"version_parameter": "-V"
|
||||||
|
},
|
||||||
"composer-normalize": {
|
"composer-normalize": {
|
||||||
"type": "phar",
|
"type": "phar",
|
||||||
"repository": "ergebnis/composer-normalize",
|
"repository": "ergebnis/composer-normalize",
|
||||||
@ -184,6 +192,13 @@
|
|||||||
"domain": "https://github.com",
|
"domain": "https://github.com",
|
||||||
"version_prefix": "v"
|
"version_prefix": "v"
|
||||||
},
|
},
|
||||||
|
"symfony-cli": {
|
||||||
|
"alias": "symfony",
|
||||||
|
"type": "custom-package",
|
||||||
|
"repository": "symfony-cli/symfony-cli",
|
||||||
|
"domain": "https://github.com",
|
||||||
|
"version_prefix": "-V"
|
||||||
|
},
|
||||||
"blackfire-player": {
|
"blackfire-player": {
|
||||||
"type": "custom-function",
|
"type": "custom-function",
|
||||||
"domain": "https://get.blackfire.io",
|
"domain": "https://get.blackfire.io",
|
||||||
@ -251,15 +266,6 @@
|
|||||||
"type": "custom-function",
|
"type": "custom-function",
|
||||||
"function": "dev_tools"
|
"function": "dev_tools"
|
||||||
},
|
},
|
||||||
"symfony-cli": {
|
|
||||||
"type": "custom-function",
|
|
||||||
"function": "symfony",
|
|
||||||
"alias": "symfony",
|
|
||||||
"domain": "https://github.com",
|
|
||||||
"repository": "symfony/cli",
|
|
||||||
"version_prefix": "v",
|
|
||||||
"version_parameter": "version"
|
|
||||||
},
|
|
||||||
"wp-cli": {
|
"wp-cli": {
|
||||||
"type": "custom-function",
|
"type": "custom-function",
|
||||||
"function": "wp_cli",
|
"function": "wp_cli",
|
||||||
|
@ -20,13 +20,13 @@ export async function checkXdebugError(
|
|||||||
*
|
*
|
||||||
* @param extension
|
* @param extension
|
||||||
* @param version
|
* @param version
|
||||||
* @param os_version
|
* @param os
|
||||||
* @param pipe
|
* @param pipe
|
||||||
*/
|
*/
|
||||||
export async function addCoverageXdebug(
|
export async function addCoverageXdebug(
|
||||||
extension: string,
|
extension: string,
|
||||||
version: string,
|
version: string,
|
||||||
os_version: string,
|
os: string,
|
||||||
pipe: string
|
pipe: string
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
let script = '\n';
|
let script = '\n';
|
||||||
@ -34,20 +34,14 @@ export async function addCoverageXdebug(
|
|||||||
let status = '$cross';
|
let status = '$cross';
|
||||||
if (!message) {
|
if (!message) {
|
||||||
script +=
|
script +=
|
||||||
(await extensions.addExtension(
|
(await extensions.addExtension(':pcov:false', version, os, true)) + pipe;
|
||||||
':pcov:false',
|
|
||||||
version,
|
|
||||||
os_version,
|
|
||||||
true
|
|
||||||
)) + pipe;
|
|
||||||
extension = extension == 'xdebug3' ? 'xdebug' : extension;
|
extension = extension == 'xdebug3' ? 'xdebug' : extension;
|
||||||
script +=
|
script +=
|
||||||
(await extensions.addExtension(extension, version, os_version, true)) +
|
(await extensions.addExtension(extension, version, os, true)) + pipe;
|
||||||
pipe;
|
|
||||||
message = 'Xdebug enabled as coverage driver';
|
message = 'Xdebug enabled as coverage driver';
|
||||||
status = '$tick';
|
status = '$tick';
|
||||||
}
|
}
|
||||||
script += await utils.addLog(status, extension, message, os_version);
|
script += await utils.addLog(status, extension, message, os);
|
||||||
return script;
|
return script;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,36 +49,30 @@ export async function addCoverageXdebug(
|
|||||||
* Function to setup PCOV
|
* Function to setup PCOV
|
||||||
*
|
*
|
||||||
* @param version
|
* @param version
|
||||||
* @param os_version
|
* @param os
|
||||||
* @param pipe
|
* @param pipe
|
||||||
*/
|
*/
|
||||||
export async function addCoveragePCOV(
|
export async function addCoveragePCOV(
|
||||||
version: string,
|
version: string,
|
||||||
os_version: string,
|
os: string,
|
||||||
pipe: string
|
pipe: string
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
let script = '\n';
|
let script = '\n';
|
||||||
switch (true) {
|
switch (true) {
|
||||||
default:
|
default:
|
||||||
script +=
|
script +=
|
||||||
(await extensions.addExtension(
|
(await extensions.addExtension(':xdebug:false', version, os, true)) +
|
||||||
':xdebug:false',
|
|
||||||
version,
|
|
||||||
os_version,
|
|
||||||
true
|
|
||||||
)) + pipe;
|
|
||||||
script +=
|
|
||||||
(await extensions.addExtension('pcov', version, os_version, true)) +
|
|
||||||
pipe;
|
pipe;
|
||||||
script +=
|
script +=
|
||||||
(await config.addINIValues('pcov.enabled=1', os_version, true)) + '\n';
|
(await extensions.addExtension('pcov', version, os, true)) + pipe;
|
||||||
|
script += (await config.addINIValues('pcov.enabled=1', os, true)) + '\n';
|
||||||
|
|
||||||
// success
|
// success
|
||||||
script += await utils.addLog(
|
script += await utils.addLog(
|
||||||
'$tick',
|
'$tick',
|
||||||
'coverage: pcov',
|
'coverage: pcov',
|
||||||
'PCOV enabled as coverage driver',
|
'PCOV enabled as coverage driver',
|
||||||
os_version
|
os
|
||||||
);
|
);
|
||||||
// version is not supported
|
// version is not supported
|
||||||
break;
|
break;
|
||||||
@ -94,7 +82,7 @@ export async function addCoveragePCOV(
|
|||||||
'$cross',
|
'$cross',
|
||||||
'pcov',
|
'pcov',
|
||||||
'PHP 7.1 or newer is required',
|
'PHP 7.1 or newer is required',
|
||||||
os_version
|
os
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -106,31 +94,20 @@ export async function addCoveragePCOV(
|
|||||||
* Function to disable Xdebug and PCOV
|
* Function to disable Xdebug and PCOV
|
||||||
*
|
*
|
||||||
* @param version
|
* @param version
|
||||||
* @param os_version
|
* @param os
|
||||||
* @param pipe
|
* @param pipe
|
||||||
*/
|
*/
|
||||||
export async function disableCoverage(
|
export async function disableCoverage(
|
||||||
version: string,
|
version: string,
|
||||||
os_version: string,
|
os: string,
|
||||||
pipe: string
|
pipe: string
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
let script = '\n';
|
let script = '\n';
|
||||||
script +=
|
script +=
|
||||||
(await extensions.addExtension(':pcov:false', version, os_version, true)) +
|
(await extensions.addExtension(':pcov:false', version, os, true)) + pipe;
|
||||||
pipe;
|
|
||||||
script +=
|
script +=
|
||||||
(await extensions.addExtension(
|
(await extensions.addExtension(':xdebug:false', version, os, true)) + pipe;
|
||||||
':xdebug:false',
|
script += await utils.addLog('$tick', 'none', 'Disabled Xdebug and PCOV', os);
|
||||||
version,
|
|
||||||
os_version,
|
|
||||||
true
|
|
||||||
)) + pipe;
|
|
||||||
script += await utils.addLog(
|
|
||||||
'$tick',
|
|
||||||
'none',
|
|
||||||
'Disabled Xdebug and PCOV',
|
|
||||||
os_version
|
|
||||||
);
|
|
||||||
|
|
||||||
return script;
|
return script;
|
||||||
}
|
}
|
||||||
@ -140,29 +117,27 @@ export async function disableCoverage(
|
|||||||
*
|
*
|
||||||
* @param coverage_driver
|
* @param coverage_driver
|
||||||
* @param version
|
* @param version
|
||||||
* @param os_version
|
* @param os
|
||||||
*/
|
*/
|
||||||
export async function addCoverage(
|
export async function addCoverage(
|
||||||
coverage_driver: string,
|
coverage_driver: string,
|
||||||
version: string,
|
version: string,
|
||||||
os_version: string
|
os: string
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
coverage_driver = coverage_driver.toLowerCase();
|
coverage_driver = coverage_driver.toLowerCase();
|
||||||
const script: string =
|
const script: string = '\n' + (await utils.stepLog('Setup Coverage', os));
|
||||||
'\n' + (await utils.stepLog('Setup Coverage', os_version));
|
const pipe: string = (await utils.suppressOutput(os)) + '\n';
|
||||||
const pipe: string = (await utils.suppressOutput(os_version)) + '\n';
|
|
||||||
switch (coverage_driver) {
|
switch (coverage_driver) {
|
||||||
case 'pcov':
|
case 'pcov':
|
||||||
return script + (await addCoveragePCOV(version, os_version, pipe));
|
return script + (await addCoveragePCOV(version, os, pipe));
|
||||||
case 'xdebug':
|
case 'xdebug':
|
||||||
case 'xdebug2':
|
case 'xdebug2':
|
||||||
case 'xdebug3':
|
case 'xdebug3':
|
||||||
return (
|
return (
|
||||||
script +
|
script + (await addCoverageXdebug(coverage_driver, version, os, pipe))
|
||||||
(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, pipe));
|
||||||
default:
|
default:
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
@ -44,9 +44,10 @@ export async function addExtensionDarwin(
|
|||||||
):
|
):
|
||||||
case /^(5\.[3-6]|7\.[0-4])ioncube$/.test(version_extension):
|
case /^(5\.[3-6]|7\.[0-4])ioncube$/.test(version_extension):
|
||||||
case /(5\.6|7\.[0-3])phalcon3|7\.[2-4]phalcon4/.test(version_extension):
|
case /(5\.6|7\.[0-3])phalcon3|7\.[2-4]phalcon4/.test(version_extension):
|
||||||
|
case /(?<!5\.[3-6])(pdo_)?sqlsrv$/.test(version_extension):
|
||||||
add_script += await utils.customPackage(
|
add_script += await utils.customPackage(
|
||||||
ext_name,
|
ext_name,
|
||||||
'ext',
|
'extensions',
|
||||||
extension,
|
extension,
|
||||||
'darwin'
|
'darwin'
|
||||||
);
|
);
|
||||||
@ -73,11 +74,11 @@ export async function addExtensionDarwin(
|
|||||||
case /(5\.[3-6]|7\.0)pcov/.test(version_extension):
|
case /(5\.[3-6]|7\.0)pcov/.test(version_extension):
|
||||||
add_script += await utils.getUnsupportedLog('pcov', version, 'darwin');
|
add_script += await utils.getUnsupportedLog('pcov', version, 'darwin');
|
||||||
return;
|
return;
|
||||||
// match 5.6 and newer - amqp, apcu, expect, grpc, igbinary, imagick, imap, memcache, memcached, mongodb, msgpack, protobuf, raphf, rdkafka, redis, ssh2, swoole, xdebug, xdebug2, yaml, zmq
|
// match 5.6 and newer - amqp, apcu, expect, gnupg, grpc, igbinary, imagick, imap, memcache, memcached, mongodb, msgpack, protobuf, raphf, rdkafka, redis, ssh2, swoole, xdebug, xdebug2, yaml, zmq
|
||||||
// match 7.1 and newer - pcov
|
// match 7.1 and newer - pcov
|
||||||
// match 5.6 to 7.4 - propro
|
// match 5.6 to 7.4 - propro
|
||||||
// match 7.0 and newer - vips, xlswriter
|
// match 7.0 and newer - vips, xlswriter
|
||||||
case /(?<!5\.[3-5])(amqp|apcu|expect|grpc|igbinary|imagick|imap|mailparse|memcache|memcached|mongodb|msgpack|protobuf|psr|raphf|rdkafka|redis|ssh2|swoole|xdebug|xdebug2|yaml|zmq)/.test(
|
case /(?<!5\.[3-5])(amqp|apcu|expect|gnupg|grpc|igbinary|imagick|imap|mailparse|mcrypt|memcache|memcached|mongodb|msgpack|protobuf|psr|raphf|rdkafka|redis|ssh2|swoole|xdebug|xdebug2|yaml|zmq)/.test(
|
||||||
version_extension
|
version_extension
|
||||||
):
|
):
|
||||||
case /(5\.6|7\.[0-4])propro/.test(version_extension):
|
case /(5\.6|7\.[0-4])propro/.test(version_extension):
|
||||||
@ -127,22 +128,22 @@ export async function addExtensionWindows(
|
|||||||
case /^none$/.test(ext_name):
|
case /^none$/.test(ext_name):
|
||||||
add_script += '\nDisable-AllShared';
|
add_script += '\nDisable-AllShared';
|
||||||
break;
|
break;
|
||||||
// match 5.3blackfire...8.0blackfire
|
// match 5.3blackfire...8.1blackfire
|
||||||
// match 5.3blackfire-(semver)...8.0blackfire-(semver)
|
// match 5.3blackfire-(semver)...8.1blackfire-(semver)
|
||||||
// match pdo_oci and oci8
|
// match pdo_oci and oci8
|
||||||
// match 5.3ioncube...7.4ioncube
|
// match 5.3ioncube...7.4ioncube
|
||||||
// match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4
|
// match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4
|
||||||
// match 7.1pecl_http...8.0pecl_http and 7.1http...8.0http
|
// match 7.1pecl_http...8.1pecl_http and 7.1http...8.1http
|
||||||
case /^(5\.[3-6]|7\.[0-4]|8\.0)blackfire(-\d+\.\d+\.\d+)?$/.test(
|
case /^(5\.[3-6]|7\.[0-4]|8\.1)blackfire(-\d+\.\d+\.\d+)?$/.test(
|
||||||
version_extension
|
version_extension
|
||||||
):
|
):
|
||||||
case /^pdo_oci$|^oci8$|^pdo_firebird$/.test(extension):
|
case /^pdo_oci$|^oci8$|^pdo_firebird$/.test(extension):
|
||||||
case /^(5\.[3-6]|7\.[0-4])ioncube$/.test(version_extension):
|
case /^(5\.[3-6]|7\.[0-4])ioncube$/.test(version_extension):
|
||||||
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
|
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
|
||||||
case /^(7\.[1-4]|8\.0)(pecl_)?http/.test(version_extension):
|
case /^(7\.[1-4]|8\.1)(pecl_)?http/.test(version_extension):
|
||||||
add_script += await utils.customPackage(
|
add_script += await utils.customPackage(
|
||||||
ext_name,
|
ext_name,
|
||||||
'ext',
|
'extensions',
|
||||||
extension,
|
extension,
|
||||||
'win32'
|
'win32'
|
||||||
);
|
);
|
||||||
@ -267,9 +268,10 @@ export async function addExtensionLinux(
|
|||||||
case /(?<!5\.[3-5])intl-[\d]+\.[\d]+$/.test(version_extension):
|
case /(?<!5\.[3-5])intl-[\d]+\.[\d]+$/.test(version_extension):
|
||||||
case /^(5\.[3-6]|7\.[0-4])ioncube$/.test(version_extension):
|
case /^(5\.[3-6]|7\.[0-4])ioncube$/.test(version_extension):
|
||||||
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
|
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
|
||||||
|
case /(?<!5\.[3-6])(pdo_)?sqlsrv$/.test(version_extension):
|
||||||
add_script += await utils.customPackage(
|
add_script += await utils.customPackage(
|
||||||
ext_name,
|
ext_name,
|
||||||
'ext',
|
'extensions',
|
||||||
extension,
|
extension,
|
||||||
'linux'
|
'linux'
|
||||||
);
|
);
|
||||||
@ -327,20 +329,20 @@ export async function addExtensionLinux(
|
|||||||
*
|
*
|
||||||
* @param extension_csv
|
* @param extension_csv
|
||||||
* @param version
|
* @param version
|
||||||
* @param os_version
|
* @param os
|
||||||
* @param no_step
|
* @param no_step
|
||||||
*/
|
*/
|
||||||
export async function addExtension(
|
export async function addExtension(
|
||||||
extension_csv: string,
|
extension_csv: string,
|
||||||
version: string,
|
version: string,
|
||||||
os_version: string,
|
os: string,
|
||||||
no_step = false
|
no_step = false
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
const log: string = await utils.stepLog('Setup Extensions', os_version);
|
const log: string = await utils.stepLog('Setup Extensions', os);
|
||||||
let script = '\n';
|
let script = '\n';
|
||||||
switch (no_step) {
|
switch (no_step) {
|
||||||
case true:
|
case true:
|
||||||
script += log + (await utils.suppressOutput(os_version));
|
script += log + (await utils.suppressOutput(os));
|
||||||
break;
|
break;
|
||||||
case false:
|
case false:
|
||||||
default:
|
default:
|
||||||
@ -348,7 +350,7 @@ export async function addExtension(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (os_version) {
|
switch (os) {
|
||||||
case 'win32':
|
case 'win32':
|
||||||
return script + (await addExtensionWindows(extension_csv, version));
|
return script + (await addExtensionWindows(extension_csv, version));
|
||||||
case 'darwin':
|
case 'darwin':
|
||||||
@ -357,8 +359,8 @@ export async function addExtension(
|
|||||||
return script + (await addExtensionLinux(extension_csv, version));
|
return script + (await addExtensionLinux(extension_csv, version));
|
||||||
default:
|
default:
|
||||||
return await utils.log(
|
return await utils.log(
|
||||||
'Platform ' + os_version + ' is not supported',
|
'Platform ' + os + ' is not supported',
|
||||||
os_version,
|
os,
|
||||||
'error'
|
'error'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
54
src/fetch.ts
Normal file
54
src/fetch.ts
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
import {IncomingMessage, OutgoingHttpHeaders} from 'http';
|
||||||
|
import * as https from 'https';
|
||||||
|
import * as url from 'url';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function to fetch an URL
|
||||||
|
*
|
||||||
|
* @param input_url
|
||||||
|
* @param auth_token
|
||||||
|
*/
|
||||||
|
export async function fetch(
|
||||||
|
input_url: string,
|
||||||
|
auth_token?: string,
|
||||||
|
redirect_count = 5
|
||||||
|
): Promise<Record<string, string>> {
|
||||||
|
const fetch_promise: Promise<Record<string, string>> = new Promise(
|
||||||
|
resolve => {
|
||||||
|
const url_object: url.UrlObject = new url.URL(input_url);
|
||||||
|
const headers: OutgoingHttpHeaders = {
|
||||||
|
'User-Agent': `Mozilla/5.0 (${process.platform} ${process.arch}) setup-php`
|
||||||
|
};
|
||||||
|
if (auth_token) {
|
||||||
|
headers.authorization = 'Bearer ' + auth_token;
|
||||||
|
}
|
||||||
|
const options: https.RequestOptions = {
|
||||||
|
hostname: url_object.hostname,
|
||||||
|
path: url_object.pathname,
|
||||||
|
headers: headers
|
||||||
|
};
|
||||||
|
const req = https.get(options, (res: IncomingMessage) => {
|
||||||
|
if (res.statusCode === 200) {
|
||||||
|
let body = '';
|
||||||
|
res.setEncoding('utf8');
|
||||||
|
res.on('data', chunk => (body += chunk));
|
||||||
|
res.on('end', () => resolve({data: `${body}`}));
|
||||||
|
} else if (
|
||||||
|
[301, 302, 303, 307, 308].includes(res.statusCode as number)
|
||||||
|
) {
|
||||||
|
if (redirect_count > 0 && res.headers.location) {
|
||||||
|
fetch(res.headers.location, auth_token, redirect_count--).then(
|
||||||
|
resolve
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
resolve({error: `${res.statusCode}: Redirect error`});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
resolve({error: `${res.statusCode}: ${res.statusMessage}`});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
req.end();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
return await fetch_promise;
|
||||||
|
}
|
@ -1,3 +1,5 @@
|
|||||||
|
import path from 'path';
|
||||||
|
import fs from 'fs';
|
||||||
import {exec} from '@actions/exec';
|
import {exec} from '@actions/exec';
|
||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
import * as config from './config';
|
import * as config from './config';
|
||||||
@ -9,66 +11,51 @@ import * as utils from './utils';
|
|||||||
/**
|
/**
|
||||||
* Build the script
|
* Build the script
|
||||||
*
|
*
|
||||||
* @param filename
|
* @param os
|
||||||
* @param version
|
|
||||||
* @param os_version
|
|
||||||
*/
|
*/
|
||||||
export async function getScript(
|
export async function getScript(os: string): Promise<string> {
|
||||||
filename: string,
|
const url = 'https://setup-php.com/support-ukraine';
|
||||||
version: string,
|
const filename = os + (await utils.scriptExtension(os));
|
||||||
os_version: string
|
const script_path = path.join(__dirname, '../src/scripts', filename);
|
||||||
): Promise<string> {
|
const run_path = script_path.replace(os, 'run');
|
||||||
const url = 'https://setup-php.com/sponsor';
|
|
||||||
// taking inputs
|
|
||||||
process.env['fail_fast'] = await utils.getInput('fail-fast', false);
|
process.env['fail_fast'] = await utils.getInput('fail-fast', false);
|
||||||
const extension_csv: string = await utils.getInput('extensions', false);
|
const extension_csv: string = await utils.getInput('extensions', false);
|
||||||
const ini_values_csv: string = await utils.getInput('ini-values', false);
|
const ini_values_csv: string = await utils.getInput('ini-values', false);
|
||||||
const coverage_driver: string = await utils.getInput('coverage', false);
|
const coverage_driver: string = await utils.getInput('coverage', false);
|
||||||
const tools_csv: string = await utils.getInput('tools', false);
|
const tools_csv: string = await utils.getInput('tools', false);
|
||||||
|
const version: string = await utils.parseVersion(
|
||||||
let script: string = await utils.readFile(filename, 'src/scripts');
|
await utils.getInput('php-version', true)
|
||||||
script += await tools.addTools(tools_csv, version, os_version);
|
);
|
||||||
|
const ini_file: string = await utils.parseIniFile(
|
||||||
|
await utils.getInput('ini-file', false)
|
||||||
|
);
|
||||||
|
let script = await utils.joins('.', script_path, version, ini_file);
|
||||||
if (extension_csv) {
|
if (extension_csv) {
|
||||||
script += await extensions.addExtension(extension_csv, version, os_version);
|
script += await extensions.addExtension(extension_csv, version, os);
|
||||||
}
|
}
|
||||||
|
script += await tools.addTools(tools_csv, version, os);
|
||||||
if (coverage_driver) {
|
if (coverage_driver) {
|
||||||
script += await coverage.addCoverage(coverage_driver, version, os_version);
|
script += await coverage.addCoverage(coverage_driver, version, os);
|
||||||
}
|
}
|
||||||
if (ini_values_csv) {
|
if (ini_values_csv) {
|
||||||
script += await config.addINIValues(ini_values_csv, os_version);
|
script += await config.addINIValues(ini_values_csv, os);
|
||||||
}
|
}
|
||||||
script += '\n' + (await utils.stepLog(`Sponsor setup-php`, os_version));
|
script += '\n' + (await utils.stepLog(`#StandWithUkraine`, os));
|
||||||
script += '\n' + (await utils.addLog('$tick', 'setup-php', url, os_version));
|
script += '\n' + (await utils.addLog('$tick', 'read-more', url, os));
|
||||||
|
|
||||||
return await utils.writeScript(filename, script);
|
fs.writeFileSync(run_path, script, {mode: 0o755});
|
||||||
|
|
||||||
|
return run_path;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Run the script
|
* Run the script
|
||||||
*/
|
*/
|
||||||
export async function run(): Promise<void> {
|
export async function run(): Promise<void> {
|
||||||
try {
|
const os: string = process.platform;
|
||||||
if ((await utils.readEnv('ImageOS')) == 'ubuntu16') {
|
const tool = await utils.scriptTool(os);
|
||||||
core.setFailed(
|
const run_path = await getScript(os);
|
||||||
'setup-php is not supported on Ubuntu 16.04. Please upgrade to Ubuntu 18.04 or Ubuntu 20.04 - https://setup-php.com/i/452'
|
await exec(tool + run_path);
|
||||||
);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const version: string = await utils.parseVersion(
|
|
||||||
await utils.getInput('php-version', true)
|
|
||||||
);
|
|
||||||
if (version) {
|
|
||||||
const os_version: string = process.platform;
|
|
||||||
const tool = await utils.scriptTool(os_version);
|
|
||||||
const script = os_version + (await utils.scriptExtension(os_version));
|
|
||||||
const location = await getScript(script, version, os_version);
|
|
||||||
await exec(await utils.joins(tool, location, version, __dirname));
|
|
||||||
} else {
|
|
||||||
core.setFailed('Unable to get the PHP version');
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
core.setFailed((error as Error).message);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// call the run function
|
// call the run function
|
||||||
|
@ -1,380 +0,0 @@
|
|||||||
# Variables
|
|
||||||
export tick="✓"
|
|
||||||
export cross="✗"
|
|
||||||
export curl_opts=(-sL)
|
|
||||||
export old_versions="5.[3-5]"
|
|
||||||
export jit_versions="8.[0-9]"
|
|
||||||
export nightly_versions="8.[2-9]"
|
|
||||||
export xdebug3_versions="7.[2-4]|8.[0-9]"
|
|
||||||
export tool_path_dir="/usr/local/bin"
|
|
||||||
export composer_home="$HOME/.composer"
|
|
||||||
export composer_bin="$composer_home/vendor/bin"
|
|
||||||
export composer_json="$composer_home/composer.json"
|
|
||||||
export composer_lock="$composer_home/composer.lock"
|
|
||||||
export latest="releases/latest/download"
|
|
||||||
export github="https://github.com/shivammathur"
|
|
||||||
export jsdeliver="https://cdn.jsdelivr.net/gh/shivammathur"
|
|
||||||
export setup_php="https://setup-php.com"
|
|
||||||
|
|
||||||
# Function to log start of a operation.
|
|
||||||
step_log() {
|
|
||||||
message=$1
|
|
||||||
printf "\n\033[90;1m==> \033[0m\033[37;1m%s\033[0m\n" "$message"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Function to log result of a operation.
|
|
||||||
add_log() {
|
|
||||||
mark=$1
|
|
||||||
subject=$2
|
|
||||||
message=$3
|
|
||||||
if [ "$mark" = "$tick" ]; then
|
|
||||||
printf "\033[32;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s\033[0m\n" "$mark" "$subject" "$message"
|
|
||||||
else
|
|
||||||
printf "\033[31;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s\033[0m\n" "$mark" "$subject" "$message"
|
|
||||||
[ "$fail_fast" = "true" ] && exit 1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# Function to log result of installing extension.
|
|
||||||
add_extension_log() {
|
|
||||||
(
|
|
||||||
check_extension "$(echo "$1" | cut -d '-' -f 1)" && add_log "$tick" "$1" "$2"
|
|
||||||
) || add_log "$cross" "$1" "Could not install $1 on PHP ${semver:?}"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Function to read env inputs.
|
|
||||||
read_env() {
|
|
||||||
[[ -z "${update}" ]] && update='false' && UPDATE='false' || update="${update}"
|
|
||||||
[ "$update" = false ] && [[ -n ${UPDATE} ]] && update="${UPDATE}"
|
|
||||||
[[ -z "${runner}" ]] && runner='github' && RUNNER='github' || runner="${runner}"
|
|
||||||
[ "$runner" = false ] && [[ -n ${RUNNER} ]] && runner="${RUNNER}"
|
|
||||||
[[ -z "${fail_fast}" ]] && fail_fast='false' || fail_fast="${fail_fast}"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Function to download a file using cURL.
|
|
||||||
# mode: -s pipe to stdout, -v save file and return status code
|
|
||||||
# execute: -e save file as executable
|
|
||||||
get() {
|
|
||||||
mode=$1
|
|
||||||
execute=$2
|
|
||||||
file_path=$3
|
|
||||||
shift 3
|
|
||||||
links=("$@")
|
|
||||||
if [ "$mode" = "-s" ]; then
|
|
||||||
sudo curl "${curl_opts[@]}" "${links[0]}"
|
|
||||||
else
|
|
||||||
for link in "${links[@]}"; do
|
|
||||||
status_code=$(sudo curl -w "%{http_code}" -o "$file_path" "${curl_opts[@]}" "$link")
|
|
||||||
[ "$status_code" = "200" ] && break
|
|
||||||
done
|
|
||||||
[ "$execute" = "-e" ] && sudo chmod a+x "$file_path"
|
|
||||||
[ "$mode" = "-v" ] && echo "$status_code"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# Function to download and run scripts from GitHub releases with jsdeliver fallback.
|
|
||||||
run_script() {
|
|
||||||
repo=$1
|
|
||||||
shift
|
|
||||||
args=("$@")
|
|
||||||
get -q -e /tmp/install.sh "$github/$repo/$latest/install.sh" "$jsdeliver/$repo@main/scripts/install.sh" "$setup_php/$repo/install.sh"
|
|
||||||
bash /tmp/install.sh "${args[@]}"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Function to install required packages on self-hosted runners.
|
|
||||||
self_hosted_setup() {
|
|
||||||
if [ "$runner" = "self-hosted" ]; then
|
|
||||||
if [[ "${version:?}" =~ $old_versions ]]; then
|
|
||||||
add_log "$cross" "PHP" "PHP $version is not supported on self-hosted runner"
|
|
||||||
exit 1
|
|
||||||
else
|
|
||||||
self_hosted_helper >/dev/null 2>&1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# Function to test if extension is loaded.
|
|
||||||
check_extension() {
|
|
||||||
local extension=$1
|
|
||||||
if [ "$extension" != "mysql" ]; then
|
|
||||||
php -m | grep -i -q -w "$extension"
|
|
||||||
else
|
|
||||||
php -m | grep -i -q "$extension"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# Function to check if extension is shared
|
|
||||||
shared_extension() {
|
|
||||||
[ -e "${ext_dir:?}/$1.so" ]
|
|
||||||
}
|
|
||||||
|
|
||||||
# Function to enable cached extension's dependencies.
|
|
||||||
enable_cache_extension_dependencies() {
|
|
||||||
if [ -d /tmp/extcache ] && shared_extension "$1"; then
|
|
||||||
cache_dir=$(find /tmp/extcache -maxdepth 1 -type d -regex ".*$1[0-9]*")
|
|
||||||
if [[ -n "$cache_dir" ]]; then
|
|
||||||
IFS=" " read -r -a deps <<<"$(find "$cache_dir" -maxdepth 1 -type f -name "*" -exec basename {} \; | tr '\n' ' ')"
|
|
||||||
if [[ -n "${deps[*]}" ]] && php "${deps[@]/#/-d ${2}=}" -d "${2}=$1" -m 2>/dev/null | grep -i -q "$1"; then
|
|
||||||
for ext in "${deps[@]}"; do
|
|
||||||
sudo rm -rf /tmp/extcache/"$ext"
|
|
||||||
enable_extension "$ext" "$2"
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# Function to enable existing extensions.
|
|
||||||
enable_extension() {
|
|
||||||
modules_dir="/var/lib/php/modules/$version"
|
|
||||||
[ -d "$modules_dir" ] && sudo find "$modules_dir" -path "*disabled*$1" -delete
|
|
||||||
enable_extension_dependencies "$1" "$2"
|
|
||||||
enable_cache_extension_dependencies "$1" "$2"
|
|
||||||
if ! check_extension "$1" && shared_extension "$1"; then
|
|
||||||
echo "$2=${ext_dir:?}/$1.so" | sudo tee -a "${pecl_file:-${ini_file[@]}}" >/dev/null
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# Function to get a map of extensions and their dependent shared extensions.
|
|
||||||
get_extension_map() {
|
|
||||||
php -d'error_reporting=0' "${dist:?}"/../src/scripts/ext/extension_map.php
|
|
||||||
}
|
|
||||||
|
|
||||||
# Function to enable extension dependencies which are also extensions.
|
|
||||||
enable_extension_dependencies() {
|
|
||||||
local extension=$1
|
|
||||||
prefix=$2
|
|
||||||
if ! [ -e /tmp/map.orig ]; then
|
|
||||||
get_extension_map | sudo tee /tmp/map.orig >/dev/null
|
|
||||||
fi
|
|
||||||
for dependency in $(grep "$extension:" /tmp/map.orig | cut -d ':' -f 2 | tr '\n' ' '); do
|
|
||||||
enable_extension "$dependency" "$prefix"
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
# Function to disable dependent extensions.
|
|
||||||
disable_extension_dependents() {
|
|
||||||
local extension=$1
|
|
||||||
for dependent in $(get_extension_map | grep -E ".*:.*\s$extension(\s|$)" | cut -d ':' -f 1 | tr '\n' ' '); do
|
|
||||||
disable_extension_helper "$dependent" true
|
|
||||||
add_log "${tick:?}" ":$extension" "Disabled $dependent as it depends on $extension"
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
# Function to disable an extension.
|
|
||||||
disable_extension() {
|
|
||||||
local extension=$1
|
|
||||||
if check_extension "$extension"; then
|
|
||||||
if shared_extension "$extension"; then
|
|
||||||
disable_extension_helper "$extension" true
|
|
||||||
(! check_extension "$extension" && add_log "${tick:?}" ":$extension" "Disabled") ||
|
|
||||||
add_log "${cross:?}" ":$extension" "Could not disable $extension on PHP ${semver:?}"
|
|
||||||
else
|
|
||||||
add_log "${cross:?}" ":$extension" "Could not disable $extension on PHP $semver as it not a shared extension"
|
|
||||||
fi
|
|
||||||
elif shared_extension "$extension"; then
|
|
||||||
add_log "${tick:?}" ":$extension" "Disabled"
|
|
||||||
else
|
|
||||||
add_log "${tick:?}" ":$extension" "Could not find $extension on PHP $semver"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# Function to disable shared extensions.
|
|
||||||
disable_all_shared() {
|
|
||||||
sudo sed -i.orig -E -e "/^(zend_)?extension\s*=/d" "${ini_file[@]}" "$pecl_file" 2>/dev/null || true
|
|
||||||
sudo find "${ini_dir:-$scan_dir}"/.. -name "*.ini" -not -path "*php.ini" -not -path "*mods-available*" -delete >/dev/null 2>&1 || true
|
|
||||||
add_log "${tick:?}" "none" "Disabled all shared extensions"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Function to configure PHP
|
|
||||||
configure_php() {
|
|
||||||
(
|
|
||||||
echo -e "date.timezone=UTC\nmemory_limit=-1"
|
|
||||||
[[ "$version" =~ $jit_versions ]] && echo -e "opcache.enable=1\nopcache.jit_buffer_size=256M\nopcache.jit=1235"
|
|
||||||
[[ "$version" =~ $xdebug3_versions ]] && echo -e "xdebug.mode=coverage"
|
|
||||||
) | sudo tee -a "${pecl_file:-${ini_file[@]}}" >/dev/null
|
|
||||||
}
|
|
||||||
|
|
||||||
# Function to configure PECL.
|
|
||||||
configure_pecl() {
|
|
||||||
if ! [ -e /tmp/pecl_config ]; then
|
|
||||||
for script in pear pecl; do
|
|
||||||
sudo "$script" config-set php_ini "${pecl_file:-${ini_file[@]}}"
|
|
||||||
sudo "$script" channel-update "$script".php.net
|
|
||||||
done
|
|
||||||
echo '' | sudo tee /tmp/pecl_config >/dev/null 2>&1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# Function to get the PECL version of an extension.
|
|
||||||
get_pecl_version() {
|
|
||||||
local extension=$1
|
|
||||||
stability="$(echo "$2" | grep -m 1 -Eio "(stable|alpha|beta|rc|snapshot|preview)")"
|
|
||||||
pecl_rest='https://pecl.php.net/rest/r/'
|
|
||||||
response=$(get -s -n "" "$pecl_rest$extension"/allreleases.xml)
|
|
||||||
pecl_version=$(echo "$response" | grep -m 1 -Eio "([0-9]+\.[0-9]+\.[0-9]+${stability}[0-9]+)")
|
|
||||||
if [ ! "$pecl_version" ]; then
|
|
||||||
pecl_version=$(echo "$response" | grep -m 1 -Eo "([0-9]+\.[0-9]+\.[0-9]+)")
|
|
||||||
fi
|
|
||||||
echo "$pecl_version"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Function to install PECL extensions and accept default options
|
|
||||||
pecl_install() {
|
|
||||||
local extension=$1
|
|
||||||
add_pecl >/dev/null 2>&1
|
|
||||||
yes '' 2>/dev/null | sudo pecl install -f "$extension" >/dev/null 2>&1
|
|
||||||
}
|
|
||||||
|
|
||||||
# Function to install a specific version of PECL extension.
|
|
||||||
add_pecl_extension() {
|
|
||||||
local extension=$1
|
|
||||||
pecl_version=$2
|
|
||||||
prefix=$3
|
|
||||||
enable_extension "$extension" "$prefix"
|
|
||||||
if [[ $pecl_version =~ .*(alpha|beta|rc|snapshot|preview).* ]]; then
|
|
||||||
pecl_version=$(get_pecl_version "$extension" "$pecl_version")
|
|
||||||
fi
|
|
||||||
ext_version=$(php -r "echo phpversion('$extension');")
|
|
||||||
if [ "${ext_version/-/}" = "$pecl_version" ]; then
|
|
||||||
add_log "${tick:?}" "$extension" "Enabled"
|
|
||||||
else
|
|
||||||
disable_extension_helper "$extension" >/dev/null 2>&1
|
|
||||||
pecl_install "$extension-$pecl_version"
|
|
||||||
add_extension_log "$extension-$pecl_version" "Installed and enabled"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# Function to setup pre-release extensions using PECL.
|
|
||||||
add_unstable_extension() {
|
|
||||||
local extension=$1
|
|
||||||
stability=$2
|
|
||||||
prefix=$3
|
|
||||||
pecl_version=$(get_pecl_version "$extension" "$stability")
|
|
||||||
add_pecl_extension "$extension" "$pecl_version" "$prefix"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Function to extract tool version.
|
|
||||||
get_tool_version() {
|
|
||||||
tool=$1
|
|
||||||
param=$2
|
|
||||||
alp="[a-zA-Z0-9]"
|
|
||||||
version_regex="[0-9]+((\.{1}$alp+)+)(\.{0})(-$alp+){0,1}"
|
|
||||||
if [ "$tool" = "composer" ]; then
|
|
||||||
composer_alias_version="$(grep -Ea "const\sBRANCH_ALIAS_VERSION" "$tool_path_dir/composer" | grep -Eo "$version_regex")"
|
|
||||||
if [[ -n "$composer_alias_version" ]]; then
|
|
||||||
composer_version="$composer_alias_version+$(grep -Ea "const\sVERSION" "$tool_path_dir/composer" | grep -Eo "$alp+" | tail -n 1)"
|
|
||||||
else
|
|
||||||
composer_version="$(grep -Ea "const\sVERSION" "$tool_path_dir/composer" | grep -Eo "$version_regex")"
|
|
||||||
fi
|
|
||||||
echo "$composer_version" | sudo tee /tmp/composer_version
|
|
||||||
else
|
|
||||||
$tool "$param" 2>/dev/null | sed -Ee "s/[Cc]omposer(.)?$version_regex//g" | grep -Eo "$version_regex" | head -n 1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# Function to configure composer
|
|
||||||
configure_composer() {
|
|
||||||
tool_path=$1
|
|
||||||
sudo ln -sf "$tool_path" "$tool_path.phar"
|
|
||||||
php -r "try {\$p=new Phar('$tool_path.phar', 0);exit(0);} catch(Exception \$e) {exit(1);}"
|
|
||||||
if [ $? -eq 1 ]; then
|
|
||||||
add_log "$cross" "composer" "Could not download composer"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
if ! [ -d "$composer_home" ]; then
|
|
||||||
sudo -u "$(id -un)" -g "$(id -gn)" mkdir -p -m=00755 "$composer_home"
|
|
||||||
else
|
|
||||||
sudo chown -R "$(id -un)":"$(id -gn)" "$composer_home"
|
|
||||||
fi
|
|
||||||
if ! [ -e "$composer_json" ]; then
|
|
||||||
echo '{}' | tee "$composer_json" >/dev/null
|
|
||||||
chmod 644 "$composer_json"
|
|
||||||
fi
|
|
||||||
composer -q config -g process-timeout 0
|
|
||||||
echo "$composer_bin" >>"$GITHUB_PATH"
|
|
||||||
if [ -n "$COMPOSER_TOKEN" ]; then
|
|
||||||
composer -q config -g github-oauth.github.com "$COMPOSER_TOKEN"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# Function to setup a remote tool.
|
|
||||||
add_tool() {
|
|
||||||
url=$1
|
|
||||||
tool=$2
|
|
||||||
ver_param=$3
|
|
||||||
tool_path="$tool_path_dir/$tool"
|
|
||||||
if ! [[ "$PATH" =~ $tool_path_dir ]]; then
|
|
||||||
export PATH=$PATH:"$tool_path_dir"
|
|
||||||
echo "export PATH=\$PATH:$tool_path_dir" | sudo tee -a "$GITHUB_ENV" >/dev/null
|
|
||||||
fi
|
|
||||||
if [ ! -e "$tool_path" ]; then
|
|
||||||
rm -rf "$tool_path"
|
|
||||||
fi
|
|
||||||
IFS="," read -r -a url <<<"$url"
|
|
||||||
status_code=$(get -v -e "$tool_path" "${url[@]}")
|
|
||||||
if [ "$status_code" != "200" ] && [[ "${url[0]}" =~ .*github.com.*releases.*latest.* ]]; then
|
|
||||||
url[0]="${url[0]//releases\/latest\/download/releases/download/$(get -s -n "" "$(echo "${url[0]}" | cut -d '/' -f '1-5')/releases" | grep -Eo -m 1 "([0-9]+\.[0-9]+\.[0-9]+)/$(echo "${url[0]}" | sed -e "s/.*\///")" | cut -d '/' -f 1)}"
|
|
||||||
status_code=$(get -v -e "$tool_path" "${url[0]}")
|
|
||||||
fi
|
|
||||||
if [ "$status_code" = "200" ]; then
|
|
||||||
add_tools_helper "$tool"
|
|
||||||
tool_version=$(get_tool_version "$tool" "$ver_param")
|
|
||||||
add_log "$tick" "$tool" "Added $tool $tool_version"
|
|
||||||
else
|
|
||||||
add_log "$cross" "$tool" "Could not setup $tool"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# Function to setup a tool using composer.
|
|
||||||
add_composertool() {
|
|
||||||
tool=$1
|
|
||||||
release=$2
|
|
||||||
prefix=$3
|
|
||||||
scope=$4
|
|
||||||
if [[ "$tool" =~ prestissimo|composer-prefetcher ]]; then
|
|
||||||
composer_version=$(cat /tmp/composer_version)
|
|
||||||
if [ "$(echo "$composer_version" | cut -d'.' -f 1)" != "1" ]; then
|
|
||||||
echo "::warning:: Skipping $tool, as it does not support Composer $composer_version. Specify composer:v1 in tools to use $tool"
|
|
||||||
add_log "$cross" "$tool" "Skipped"
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
(
|
|
||||||
if [ "$scope" = "global" ]; then
|
|
||||||
sudo rm -f "$composer_lock" >/dev/null 2>&1 || true
|
|
||||||
composer global require "$prefix$release" 2>&1 | tee /tmp/composer.log >/dev/null 2>&1
|
|
||||||
else
|
|
||||||
scoped_dir="$composer_bin/_tools/$tool-$(echo -n "$release" | shasum -a 256 | cut -d ' ' -f 1)"
|
|
||||||
if ! [ -e "$scoped_dir" ]; then
|
|
||||||
mkdir -p "$scoped_dir"
|
|
||||||
composer require "$prefix$release" -d "$scoped_dir" 2>&1 | tee /tmp/composer.log >/dev/null 2>&1
|
|
||||||
export PATH=$PATH:"$scoped_dir"/vendor/bin
|
|
||||||
echo "${tool}"_bin="$scoped_dir"/vendor/bin | sudo tee -a "$GITHUB_ENV" >/dev/null
|
|
||||||
echo "$scoped_dir"/vendor/bin >>"$GITHUB_PATH"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
log=$(grep "$prefix$tool" /tmp/composer.log) &&
|
|
||||||
tool_version=$(get_tool_version 'echo' "$log") &&
|
|
||||||
add_log "$tick" "$tool" "Added $tool $tool_version"
|
|
||||||
) || add_log "$cross" "$tool" "Could not setup $tool"
|
|
||||||
add_tools_helper "$tool"
|
|
||||||
if [ -e "$composer_bin/composer" ]; then
|
|
||||||
sudo cp -p "$tool_path_dir/composer" "$composer_bin"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# Function to get PHP version in semver format.
|
|
||||||
php_semver() {
|
|
||||||
php -v | grep -Eo -m 1 "[0-9]+\.[0-9]+\.[0-9]+((-?[a-zA-Z]+([0-9]+)?)?){2}" | head -n 1
|
|
||||||
}
|
|
||||||
|
|
||||||
# Function to get the tag for a php version.
|
|
||||||
php_src_tag() {
|
|
||||||
commit=$(php_extra_version | grep -Eo "[0-9a-zA-Z]+")
|
|
||||||
if [[ -n "${commit}" ]]; then
|
|
||||||
echo "$commit"
|
|
||||||
else
|
|
||||||
echo "php-$semver"
|
|
||||||
fi
|
|
||||||
}
|
|
@ -23,11 +23,14 @@ disable_dependency_extensions() {
|
|||||||
disable_extension_helper() {
|
disable_extension_helper() {
|
||||||
local extension=$1
|
local extension=$1
|
||||||
local disable_dependents=${2:-false}
|
local disable_dependents=${2:-false}
|
||||||
|
get_extension_map
|
||||||
if [ "$disable_dependents" = "true" ]; then
|
if [ "$disable_dependents" = "true" ]; then
|
||||||
disable_extension_dependents "$extension"
|
disable_extension_dependents "$extension"
|
||||||
fi
|
fi
|
||||||
sudo sed -Ei '' "/=(.*\/)?\"?$extension(.so)?$/d" "${ini_file:?}"
|
sudo sed -Ei '' "/=(.*\/)?\"?$extension(.so)?$/d" "${ini_file:?}"
|
||||||
sudo rm -rf "$scan_dir"/*"$extension"*
|
sudo rm -rf "$scan_dir"/*"$extension"* /tmp/php"$version"_extensions
|
||||||
|
mkdir -p /tmp/extdisabled/"$version"
|
||||||
|
echo '' | sudo tee /tmp/extdisabled/"$version"/"$extension" >/dev/null 2>&1
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to fetch a brew tap.
|
# Function to fetch a brew tap.
|
||||||
@ -57,12 +60,32 @@ add_brew_tap() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Function to get extension name from brew formula.
|
||||||
|
get_extension_from_formula() {
|
||||||
|
local formula=$1
|
||||||
|
local extension
|
||||||
|
extension=$(grep "$formula=" "$src"/configs/brew_extensions | cut -d '=' -f 2)
|
||||||
|
[[ -z "$extension" ]] && extension="$(echo "$formula" | sed -E "s/pecl_|[0-9]//g")"
|
||||||
|
echo "$extension"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to copy extension binaries to the extension directory.
|
||||||
|
copy_brew_extensions() {
|
||||||
|
local formula=$1
|
||||||
|
formula_file="$tap_dir/$ext_tap/Formula/$formula@$version.rb"
|
||||||
|
deps="$(grep -Eo 'depends_on "shivammathur[^"]+' "$formula_file" | cut -d '/' -f 3 | tr '\n' ' ')"
|
||||||
|
IFS=' ' read -r -a deps <<< "$formula@$version $deps"
|
||||||
|
for dependency in "${deps[@]}"; do
|
||||||
|
extension_file="$brew_prefix/opt/$dependency/$(get_extension_from_formula "${dependency%@*}").so"
|
||||||
|
[ -e "$extension_file" ] && sudo cp "$extension_file" "$ext_dir"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
# Function to install a php extension from shivammathur/extensions tap.
|
# Function to install a php extension from shivammathur/extensions tap.
|
||||||
add_brew_extension() {
|
add_brew_extension() {
|
||||||
formula=$1
|
formula=$1
|
||||||
prefix=$2
|
prefix=$2
|
||||||
extension=$(grep "$formula=" "$dist"/../src/configs/brew_extensions | cut -d '=' -f 2)
|
extension="$(get_extension_from_formula "$formula")"
|
||||||
[[ -z "$extension" ]] && extension="$(echo "$formula" | sed -E "s/pecl_|[0-9]//g")"
|
|
||||||
enable_extension "$extension" "$prefix"
|
enable_extension "$extension" "$prefix"
|
||||||
if check_extension "$extension"; then
|
if check_extension "$extension"; then
|
||||||
add_log "${tick:?}" "$extension" "Enabled"
|
add_log "${tick:?}" "$extension" "Enabled"
|
||||||
@ -73,27 +96,22 @@ add_brew_extension() {
|
|||||||
update_dependencies >/dev/null 2>&1
|
update_dependencies >/dev/null 2>&1
|
||||||
disable_dependency_extensions "$extension" >/dev/null 2>&1
|
disable_dependency_extensions "$extension" >/dev/null 2>&1
|
||||||
brew install -f "$formula@$version" >/dev/null 2>&1
|
brew install -f "$formula@$version" >/dev/null 2>&1
|
||||||
sudo cp "$brew_prefix/opt/$formula@$version/$extension.so" "$ext_dir"
|
copy_brew_extensions "$formula"
|
||||||
add_extension_log "$extension" "Installed and enabled"
|
add_extension_log "$extension" "Installed and enabled"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to setup extensions.
|
# Helper function to add an extension.
|
||||||
add_extension() {
|
add_extension_helper() {
|
||||||
local extension=$1
|
local extension=$1
|
||||||
prefix=$2
|
prefix=$2
|
||||||
enable_extension "$extension" "$prefix"
|
if [[ "$version" =~ ${old_versions:?} ]] && [ "$extension" = "imagick" ]; then
|
||||||
if check_extension "$extension"; then
|
run_script "php5-darwin" "${version/./}" "$extension" >/dev/null 2>&1
|
||||||
add_log "${tick:?}" "$extension" "Enabled"
|
|
||||||
else
|
else
|
||||||
if [[ "$version" =~ ${old_versions:?} ]] && [ "$extension" = "imagick" ]; then
|
pecl_install "$extension" >/dev/null 2>&1 &&
|
||||||
run_script "php5-darwin" "${version/./}" "$extension" >/dev/null 2>&1
|
if [[ "$version" =~ ${old_versions:?} ]]; then echo "$prefix=$ext_dir/$extension.so" >>"$ini_file"; fi
|
||||||
else
|
|
||||||
pecl_install "$extension" >/dev/null 2>&1 &&
|
|
||||||
if [[ "$version" =~ ${old_versions:?} ]]; then echo "$prefix=$ext_dir/$extension.so" >>"$ini_file"; fi
|
|
||||||
fi
|
|
||||||
add_extension_log "$extension" "Installed and enabled"
|
|
||||||
fi
|
fi
|
||||||
|
add_extension_log "$extension" "Installed and enabled"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to handle request to add phpize and php-config.
|
# Function to handle request to add phpize and php-config.
|
||||||
@ -104,6 +122,7 @@ add_devtools() {
|
|||||||
|
|
||||||
# Function to handle request to add PECL.
|
# Function to handle request to add PECL.
|
||||||
add_pecl() {
|
add_pecl() {
|
||||||
|
enable_extension xml extension >/dev/null 2>&1
|
||||||
configure_pecl >/dev/null 2>&1
|
configure_pecl >/dev/null 2>&1
|
||||||
pear_version=$(get_tool_version "pecl" "version")
|
pear_version=$(get_tool_version "pecl" "version")
|
||||||
add_log "${tick:?}" "PECL" "Found PECL $pear_version"
|
add_log "${tick:?}" "PECL" "Found PECL $pear_version"
|
||||||
@ -123,10 +142,10 @@ link_libraries() {
|
|||||||
# Patch brew to overwrite packages.
|
# Patch brew to overwrite packages.
|
||||||
patch_brew() {
|
patch_brew() {
|
||||||
formula_installer="$brew_repo"/Library/Homebrew/formula_installer.rb
|
formula_installer="$brew_repo"/Library/Homebrew/formula_installer.rb
|
||||||
code=" keg.link(verbose: verbose?"
|
code=" keg.link\(verbose: verbose\?"
|
||||||
sudo sed -i '' "s/$code)/$code, overwrite: true)/" "$formula_installer"
|
sudo sed -Ei '' "s/$code.*/$code, overwrite: true\)/" "$formula_installer"
|
||||||
# shellcheck disable=SC2064
|
# shellcheck disable=SC2064
|
||||||
trap "sudo sed -i '' 's/$code, overwrite: true)/$code)/' $formula_installer" exit
|
trap "sudo sed -Ei '' 's/$code.*/$code, overwrite: overwrite?\)/' $formula_installer" exit
|
||||||
}
|
}
|
||||||
|
|
||||||
# Helper function to update the dependencies.
|
# Helper function to update the dependencies.
|
||||||
@ -168,7 +187,7 @@ fix_dependencies() {
|
|||||||
get_brewed_php() {
|
get_brewed_php() {
|
||||||
php_cellar="$brew_prefix"/Cellar/php
|
php_cellar="$brew_prefix"/Cellar/php
|
||||||
if [ -d "$php_cellar" ] && ! [[ "$(find "$php_cellar" -maxdepth 1 -name "$version*" | wc -l 2>/dev/null)" -eq 0 ]]; then
|
if [ -d "$php_cellar" ] && ! [[ "$(find "$php_cellar" -maxdepth 1 -name "$version*" | wc -l 2>/dev/null)" -eq 0 ]]; then
|
||||||
php-config --version 2>/dev/null | cut -c 1-3
|
php_semver | cut -c 1-3
|
||||||
else
|
else
|
||||||
echo 'false';
|
echo 'false';
|
||||||
fi
|
fi
|
||||||
@ -196,9 +215,31 @@ php_extra_version() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Function to set php.ini
|
||||||
|
add_php_config() {
|
||||||
|
if ! [ -e "$ini_dir"/php.ini-development ]; then
|
||||||
|
sudo cp "$ini_dir"/php.ini "$ini_dir"/php.ini-development
|
||||||
|
fi
|
||||||
|
if [[ "$ini" = "production" || "$ini" = "development" ]]; then
|
||||||
|
sudo cp "$ini_dir"/php.ini-"$ini" "$ini_dir"/php.ini
|
||||||
|
elif [ "$ini" = "none" ]; then
|
||||||
|
echo '' | sudo tee "${ini_file[@]}" >/dev/null 2>&1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to get scan directory.
|
||||||
|
get_scan_dir() {
|
||||||
|
if [[ "$version" =~ ${old_versions:?} ]]; then
|
||||||
|
php --ini | grep additional | sed -e "s|.*: s*||"
|
||||||
|
else
|
||||||
|
echo "$ini_dir"/conf.d
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# Function to Setup PHP.
|
# Function to Setup PHP.
|
||||||
setup_php() {
|
setup_php() {
|
||||||
step_log "Setup PHP"
|
step_log "Setup PHP"
|
||||||
|
php_config="$(command -v php-config 2>/dev/null)"
|
||||||
existing_version=$(get_brewed_php)
|
existing_version=$(get_brewed_php)
|
||||||
if [[ "$version" =~ ${old_versions:?} ]]; then
|
if [[ "$version" =~ ${old_versions:?} ]]; then
|
||||||
run_script "php5-darwin" "${version/./}" >/dev/null 2>&1
|
run_script "php5-darwin" "${version/./}" >/dev/null 2>&1
|
||||||
@ -213,45 +254,52 @@ setup_php() {
|
|||||||
status="Found"
|
status="Found"
|
||||||
fix_dependencies >/dev/null 2>&1
|
fix_dependencies >/dev/null 2>&1
|
||||||
fi
|
fi
|
||||||
ini_file=$(php -d "date.timezone=UTC" --ini | grep "Loaded Configuration" | sed -e "s|.*:s*||" | sed "s/ //g")
|
php_config="$(command -v php-config)"
|
||||||
sudo chmod 777 "$ini_file" "${tool_path_dir:?}"
|
ext_dir="$(grep 'extension_dir=' "$php_config" | cut -d "'" -f 2)"
|
||||||
configure_php
|
ini_dir="$(php_ini_path)"
|
||||||
ext_dir=$(php -i | grep -Ei "extension_dir => /" | sed -e "s|.*=> s*||")
|
scan_dir="$(get_scan_dir)"
|
||||||
scan_dir=$(php --ini | grep additional | sed -e "s|.*: s*||")
|
ini_file="$ini_dir"/php.ini
|
||||||
sudo mkdir -m 777 -p "$ext_dir" "$HOME/.composer"
|
sudo mkdir -m 777 -p "$ext_dir" "$HOME/.composer"
|
||||||
semver=$(php_semver)
|
sudo chmod 777 "$ini_file" "${tool_path_dir:?}"
|
||||||
extra_version=$(php_extra_version)
|
semver="$(php_semver)"
|
||||||
|
extra_version="$(php_extra_version)"
|
||||||
|
configure_php
|
||||||
|
set_output "php-version" "$semver"
|
||||||
if [ "${semver%.*}" != "$version" ]; then
|
if [ "${semver%.*}" != "$version" ]; then
|
||||||
add_log "${cross:?}" "PHP" "Could not setup PHP $version"
|
add_log "${cross:?}" "PHP" "Could not setup PHP $version"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
sudo cp "$dist"/../src/configs/pm/*.json "$RUNNER_TOOL_CACHE/"
|
sudo cp "$src"/configs/pm/*.json "$RUNNER_TOOL_CACHE/"
|
||||||
echo "::set-output name=php-version::$semver"
|
|
||||||
add_log "$tick" "PHP" "$status PHP $semver$extra_version"
|
add_log "$tick" "PHP" "$status PHP $semver$extra_version"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Variables
|
# Variables
|
||||||
version=$1
|
version=${1:-'8.1'}
|
||||||
dist=$2
|
ini=${2:-'production'}
|
||||||
|
src=${0%/*}/..
|
||||||
php_formula=shivammathur/php/php@"$version"
|
php_formula=shivammathur/php/php@"$version"
|
||||||
brew_prefix="$(brew --prefix)"
|
brew_path="$(command -v brew)"
|
||||||
brew_repo="$(brew --repository)"
|
brew_path_dir="$(dirname "$brew_path")"
|
||||||
|
brew_prefix="$brew_path_dir"/..
|
||||||
|
brew_repo="$brew_path_dir/$(dirname "$(readlink "$brew_path")")"/..
|
||||||
tap_dir="$brew_repo"/Library/Taps
|
tap_dir="$brew_repo"/Library/Taps
|
||||||
core_repo="$tap_dir"/homebrew/homebrew-core
|
core_repo="$tap_dir"/homebrew/homebrew-core
|
||||||
scripts="${dist}"/../src/scripts
|
scripts="$src"/scripts
|
||||||
ext_tap=shivammathur/homebrew-extensions
|
ext_tap=shivammathur/homebrew-extensions
|
||||||
php_tap=shivammathur/homebrew-php
|
php_tap=shivammathur/homebrew-php
|
||||||
export HOMEBREW_CHANGE_ARCH_TO_ARM=1
|
export HOMEBREW_CHANGE_ARCH_TO_ARM=1
|
||||||
export HOMEBREW_DEVELOPER=1
|
export HOMEBREW_DEVELOPER=1
|
||||||
export HOMEBREW_NO_INSTALL_CLEANUP=1
|
|
||||||
export HOMEBREW_NO_AUTO_UPDATE=1
|
export HOMEBREW_NO_AUTO_UPDATE=1
|
||||||
|
export HOMEBREW_NO_ENV_HINTS=1
|
||||||
|
export HOMEBREW_NO_INSTALL_CLEANUP=1
|
||||||
export HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1
|
export HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1
|
||||||
|
|
||||||
# shellcheck source=.
|
# shellcheck source=.
|
||||||
. "${scripts:?}"/ext/source.sh
|
. "${scripts:?}"/unix.sh
|
||||||
. "${scripts:?}"/tools/add_tools.sh
|
. "${scripts:?}"/tools/add_tools.sh
|
||||||
. "${scripts:?}"/common.sh
|
. "${scripts:?}"/extensions/source.sh
|
||||||
|
. "${scripts:?}"/extensions/add_extensions.sh
|
||||||
read_env
|
read_env
|
||||||
self_hosted_setup
|
self_hosted_setup
|
||||||
setup_php
|
setup_php
|
||||||
|
194
src/scripts/extensions/add_extensions.ps1
Normal file
194
src/scripts/extensions/add_extensions.ps1
Normal file
@ -0,0 +1,194 @@
|
|||||||
|
# Function to link dependencies to PHP directory.
|
||||||
|
Function Set-ExtensionPrerequisites
|
||||||
|
{
|
||||||
|
Param (
|
||||||
|
[Parameter(Position = 0, Mandatory = $true)]
|
||||||
|
[ValidateNotNull()]
|
||||||
|
[ValidateLength(1, [int]::MaxValue)]
|
||||||
|
[string]
|
||||||
|
$deps_dir
|
||||||
|
)
|
||||||
|
$deps = Get-ChildItem -Recurse -Path $deps_dir
|
||||||
|
if ($deps.Count -ne 0) {
|
||||||
|
# Symlink dependencies instead of adding the directory to PATH ...
|
||||||
|
# as other actions change the PATH thus breaking extensions.
|
||||||
|
$deps | ForEach-Object {
|
||||||
|
New-Item -Itemtype SymbolicLink -Path $php_dir -Name $_.Name -Target $_.FullName -Force > $null 2>&1
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Remove-Item $deps_dir -Recurse -Force
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to add PHP extensions.
|
||||||
|
Function Add-Extension {
|
||||||
|
Param (
|
||||||
|
[Parameter(Position = 0, Mandatory = $true)]
|
||||||
|
[ValidateNotNull()]
|
||||||
|
[ValidateLength(1, [int]::MaxValue)]
|
||||||
|
[string]
|
||||||
|
$extension,
|
||||||
|
[Parameter(Position = 1, Mandatory = $false)]
|
||||||
|
[ValidateNotNull()]
|
||||||
|
[ValidateSet('stable', 'beta', 'alpha', 'devel', 'snapshot')]
|
||||||
|
[string]
|
||||||
|
$stability = 'stable',
|
||||||
|
[Parameter(Position = 2, Mandatory = $false)]
|
||||||
|
[ValidateNotNull()]
|
||||||
|
[ValidatePattern('^\d+(\.\d+){0,2}$')]
|
||||||
|
[string]
|
||||||
|
$extension_version = ''
|
||||||
|
)
|
||||||
|
try {
|
||||||
|
$extension_info = Get-PhpExtension -Path $php_dir | Where-Object { $_.Name -eq $extension -or $_.Handle -eq $extension }
|
||||||
|
$deps_dir = "$ext_dir\$extension-vc$($installed.VCVersion)-$arch"
|
||||||
|
New-Item $deps_dir -Type Directory -Force > $null 2>&1
|
||||||
|
if ($null -ne $extension_info) {
|
||||||
|
switch ($extension_info.State) {
|
||||||
|
'Builtin' {
|
||||||
|
Add-Log $tick $extension "Enabled"
|
||||||
|
}
|
||||||
|
'Enabled' {
|
||||||
|
Add-Log $tick $extension "Enabled"
|
||||||
|
}
|
||||||
|
default {
|
||||||
|
Enable-ExtensionDependencies $extension
|
||||||
|
Enable-PhpExtension -Extension $extension_info.Handle -Path $php_dir
|
||||||
|
Set-ExtensionPrerequisites $deps_dir
|
||||||
|
Add-Log $tick $extension "Enabled"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
# Patch till PHP 8.1 DLLs are released as stable.
|
||||||
|
$minimumStability = $stability
|
||||||
|
if($version -eq '8.1' -and $stability -eq 'stable') {
|
||||||
|
$minimumStability = 'snapshot'
|
||||||
|
}
|
||||||
|
|
||||||
|
$params = @{ Extension = $extension; MinimumStability = $minimumStability; MaximumStability = $stability; Path = $php_dir; AdditionalFilesPath = $deps_dir; NoDependencies = $true }
|
||||||
|
if($extension_version -ne '') {
|
||||||
|
$params["Version"] = $extension_version
|
||||||
|
}
|
||||||
|
Install-PhpExtension @params
|
||||||
|
Set-ExtensionPrerequisites $deps_dir
|
||||||
|
Add-Log $tick $extension "Installed and enabled"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
Add-Log $cross $extension "Could not install $extension on PHP $($installed.FullVersion)"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to get a map of extensions and their dependent shared extensions.
|
||||||
|
Function Get-ExtensionMap {
|
||||||
|
php -d'error_reporting=0' $src\scripts\extensions\extension_map.php $env:TEMP\map$version.orig
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to enable extension dependencies which are also extensions.
|
||||||
|
Function Enable-ExtensionDependencies {
|
||||||
|
Param (
|
||||||
|
[Parameter(Position = 0, Mandatory = $true)]
|
||||||
|
[ValidateNotNull()]
|
||||||
|
[ValidateLength(1, [int]::MaxValue)]
|
||||||
|
[string]
|
||||||
|
$extension
|
||||||
|
)
|
||||||
|
if (-not(Test-Path $env:TEMP\extdisabled\$extension)) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
Get-ExtensionMap
|
||||||
|
$entry = findstr /r "$extension`:.*" $env:TEMP\map$version.orig
|
||||||
|
if($entry) {
|
||||||
|
$entry.split(':')[1].trim().split(' ') | ForEach-Object {
|
||||||
|
if (-not(php -m | findstr -i $_)) {
|
||||||
|
Enable-PhpExtension -Extension $_ -Path $php_dir
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Remove-Item $env:TEMP\extdisabled\$extension -Force
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to disable dependent extensions.
|
||||||
|
Function Disable-DependentExtensions() {
|
||||||
|
Param (
|
||||||
|
[Parameter(Position = 0, Mandatory = $true)]
|
||||||
|
[ValidateNotNull()]
|
||||||
|
[ValidateLength(1, [int]::MaxValue)]
|
||||||
|
[string]
|
||||||
|
$extension
|
||||||
|
)
|
||||||
|
Select-String -Pattern ".*:.*\s$extension(\s|$)" $env:TEMP\map$version.orig | ForEach-Object {
|
||||||
|
$dependent = $_.Matches[0].Value.split(':')[0];
|
||||||
|
Disable-ExtensionHelper -Extension $dependent -DisableDependents
|
||||||
|
Add-Log $tick ":$extension" "Disabled $dependent as it depends on $extension"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Helper function to disable an extension.
|
||||||
|
Function Disable-ExtensionHelper() {
|
||||||
|
Param (
|
||||||
|
[Parameter(Position = 0, Mandatory = $true)]
|
||||||
|
[ValidateNotNull()]
|
||||||
|
[ValidateLength(1, [int]::MaxValue)]
|
||||||
|
[string]
|
||||||
|
$extension,
|
||||||
|
[switch] $DisableDependents
|
||||||
|
)
|
||||||
|
Get-ExtensionMap
|
||||||
|
if($DisableDependents) {
|
||||||
|
Disable-DependentExtensions $extension
|
||||||
|
}
|
||||||
|
Disable-PhpExtension -Extension $extension -Path $php_dir
|
||||||
|
New-Item $env:TEMP\extdisabled -Type Directory -Force > $null 2>&1
|
||||||
|
New-Item $env:TEMP\extdisabled\$extension -Type File -Force > $null 2>&1
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to disable an extension.
|
||||||
|
Function Disable-Extension() {
|
||||||
|
Param (
|
||||||
|
[Parameter(Position = 0, Mandatory = $true)]
|
||||||
|
[ValidateNotNull()]
|
||||||
|
[ValidateLength(1, [int]::MaxValue)]
|
||||||
|
[string]
|
||||||
|
$extension,
|
||||||
|
[Parameter(Position = 1, Mandatory = $false)]
|
||||||
|
[ValidateNotNull()]
|
||||||
|
[ValidateLength(1, [int]::MaxValue)]
|
||||||
|
[string]
|
||||||
|
$DisableDependents
|
||||||
|
)
|
||||||
|
if(php -m | findstr -i $extension) {
|
||||||
|
if(Test-Path $ext_dir\php_$extension.dll) {
|
||||||
|
try {
|
||||||
|
$params = @{ Extension = $extension; DisableDependents = ($DisableDependents -ne 'false') }
|
||||||
|
Disable-ExtensionHelper @params
|
||||||
|
Add-Log $tick ":$extension" "Disabled"
|
||||||
|
} catch {
|
||||||
|
Add-Log $cross ":$extension" "Could not disable $extension on PHP $($installed.FullVersion)"
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Add-Log $cross ":$extension" "Could not disable $extension on PHP $($installed.FullVersion) as it not a shared extension"
|
||||||
|
}
|
||||||
|
} elseif(Test-Path $ext_dir\php_$extension.dll) {
|
||||||
|
Add-Log $tick ":$extension" "Disabled"
|
||||||
|
} else {
|
||||||
|
Add-Log $tick ":$extension" "Could not find $extension on PHP $($installed.FullVersion)"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to disable shared extensions.
|
||||||
|
Function Disable-AllShared() {
|
||||||
|
Get-ExtensionMap
|
||||||
|
(Get-Content $php_dir\php.ini) | Where-Object {$_ -notmatch '^(zend_)?extension\s*='} | Set-Content $php_dir\php.ini
|
||||||
|
New-Item $env:TEMP\extdisabled\$version -Type Directory -Force > $null 2>&1
|
||||||
|
Get-Childitem $ext_dir\*.dll | ForEach-Object {
|
||||||
|
New-Item ("$env:TEMP\extdisabled\$version\" + ($_.Name.split('.')[0].split('_')[1])) -Type File -Force > $null 2>&1
|
||||||
|
}
|
||||||
|
Add-Log $tick "none" "Disabled all shared extensions"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to handle request to add PECL.
|
||||||
|
Function Add-Pecl() {
|
||||||
|
Add-Log $tick "PECL" "Use extensions input to setup PECL extensions on windows"
|
||||||
|
}
|
194
src/scripts/extensions/add_extensions.sh
Normal file
194
src/scripts/extensions/add_extensions.sh
Normal file
@ -0,0 +1,194 @@
|
|||||||
|
# Function to log result of installing extension.
|
||||||
|
add_extension_log() {
|
||||||
|
(
|
||||||
|
check_extension "$(echo "$1" | cut -d '-' -f 1)" && add_log "${tick:?}" "$1" "$2"
|
||||||
|
) || add_log "${cross:?}" "$1" "Could not install $1 on PHP ${semver:?}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to test if extension is loaded.
|
||||||
|
check_extension() {
|
||||||
|
local extension=$1
|
||||||
|
local extension_list=/tmp/php${version:?}_extensions
|
||||||
|
if [ ! -e "$extension_list" ]; then
|
||||||
|
php -m > "$extension_list"
|
||||||
|
fi
|
||||||
|
if [ "$extension" != "mysql" ]; then
|
||||||
|
grep -i -q -w "$extension" "$extension_list" || php -m | grep -i -q -w "$extension"
|
||||||
|
else
|
||||||
|
grep -i -q "$extension" "$extension_list" || php -m | grep -i -q "$extension"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to check if extension is shared
|
||||||
|
shared_extension() {
|
||||||
|
[ -e "${ext_dir:?}/$1.so" ]
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to enable cached extension's dependencies.
|
||||||
|
enable_cache_extension_dependencies() {
|
||||||
|
if [ -d /tmp/extcache ] && shared_extension "$1"; then
|
||||||
|
cache_dir=$(find /tmp/extcache -maxdepth 1 -type d -regex ".*$1[0-9]*")
|
||||||
|
if [[ -n "$cache_dir" ]]; then
|
||||||
|
IFS=" " read -r -a deps <<<"$(find "$cache_dir" -maxdepth 1 -type f -name "*" -exec basename {} \; | tr '\n' ' ')"
|
||||||
|
if [[ -n "${deps[*]}" ]] && php "${deps[@]/#/-d ${2}=}" -d "${2}=$1" -m 2>/dev/null | grep -i -q "$1"; then
|
||||||
|
for ext in "${deps[@]}"; do
|
||||||
|
sudo rm -rf /tmp/extcache/"$ext"
|
||||||
|
enable_extension "$ext" "$2"
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to enable existing extensions.
|
||||||
|
enable_extension() {
|
||||||
|
if ! check_extension "$1" && shared_extension "$1"; then
|
||||||
|
modules_dir="/var/lib/php/modules/${version:?}"
|
||||||
|
[ -d "$modules_dir" ] && sudo find "$modules_dir" -path "*disabled*$1" -delete
|
||||||
|
enable_extension_dependencies "$1" "$2"
|
||||||
|
enable_cache_extension_dependencies "$1" "$2"
|
||||||
|
echo "$2=${ext_dir:?}/$1.so" | sudo tee -a "${pecl_file:-${ini_file[@]}}" >/dev/null
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to enable array of extensions
|
||||||
|
enable_extensions() {
|
||||||
|
local extensions=("$@")
|
||||||
|
to_wait=()
|
||||||
|
for ext in "${extensions[@]}"; do
|
||||||
|
enable_extension "$ext" extension >/dev/null 2>&1 &
|
||||||
|
to_wait+=($!)
|
||||||
|
done
|
||||||
|
wait "${to_wait[@]}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to get a map of extensions and their dependent shared extensions.
|
||||||
|
get_extension_map() {
|
||||||
|
php -d'error_reporting=0' "${src:?}"/scripts/extensions/extension_map.php /tmp/map"$version".orig >/dev/null 2>&1
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to enable extension dependencies which are also extensions.
|
||||||
|
enable_extension_dependencies() {
|
||||||
|
local extension=$1
|
||||||
|
local prefix=$2
|
||||||
|
[ -e /tmp/extdisabled/"$version"/"$extension" ] || return;
|
||||||
|
get_extension_map
|
||||||
|
for dependency in $(grep "$extension:" /tmp/map"$version".orig | cut -d ':' -f 2 | tr '\n' ' '); do
|
||||||
|
enable_extension "$dependency" "$prefix"
|
||||||
|
done
|
||||||
|
rm /tmp/extdisabled/"$version"/"$extension"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to disable dependent extensions.
|
||||||
|
disable_extension_dependents() {
|
||||||
|
local extension=$1
|
||||||
|
for dependent in $(grep -E ".*:.*\s$extension(\s|$)" /tmp/map"$version".orig | cut -d ':' -f 1 | tr '\n' ' '); do
|
||||||
|
disable_extension_helper "$dependent" true
|
||||||
|
add_log "${tick:?}" ":$extension" "Disabled $dependent as it depends on $extension"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to disable an extension.
|
||||||
|
disable_extension() {
|
||||||
|
local extension=$1
|
||||||
|
if check_extension "$extension"; then
|
||||||
|
if shared_extension "$extension"; then
|
||||||
|
disable_extension_helper "$extension" true
|
||||||
|
(! check_extension "$extension" && add_log "${tick:?}" ":$extension" "Disabled") ||
|
||||||
|
add_log "${cross:?}" ":$extension" "Could not disable $extension on PHP ${semver:?}"
|
||||||
|
else
|
||||||
|
add_log "${cross:?}" ":$extension" "Could not disable $extension on PHP $semver as it not a shared extension"
|
||||||
|
fi
|
||||||
|
elif shared_extension "$extension"; then
|
||||||
|
add_log "${tick:?}" ":$extension" "Disabled"
|
||||||
|
else
|
||||||
|
add_log "${tick:?}" ":$extension" "Could not find $extension on PHP $semver"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to disable shared extensions.
|
||||||
|
disable_all_shared() {
|
||||||
|
get_extension_map
|
||||||
|
sudo sed -i.orig -E -e "/^(zend_)?extension\s*=/d" "${ini_file[@]}" "$pecl_file" 2>/dev/null || true
|
||||||
|
sudo find "${ini_dir:-$scan_dir}"/.. -name "*.ini" -not -path "*php.ini" -not -path "*phar.ini" -not -path "*pecl.ini" -not -path "*mods-available*" -delete >/dev/null 2>&1 || true
|
||||||
|
mkdir -p /tmp/extdisabled/"$version"
|
||||||
|
sudo rm -f /tmp/php"$version"_extensions
|
||||||
|
sudo find "$ext_dir" -name '*.so' -print0 | xargs -0 -n 1 basename -s .so | xargs -n 1 -I{} touch /tmp/extdisabled/"$version"/{}
|
||||||
|
add_log "${tick:?}" "none" "Disabled all shared extensions"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to configure PECL.
|
||||||
|
configure_pecl() {
|
||||||
|
if ! [ -e /tmp/pecl_config ]; then
|
||||||
|
for script in pear pecl; do
|
||||||
|
sudo "$script" config-set php_ini "${pecl_file:-${ini_file[@]}}"
|
||||||
|
sudo "$script" channel-update "$script".php.net
|
||||||
|
done
|
||||||
|
echo '' | sudo tee /tmp/pecl_config >/dev/null 2>&1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to add an extension.
|
||||||
|
add_extension() {
|
||||||
|
local extension=$1
|
||||||
|
local prefix=$2
|
||||||
|
enable_extension "$extension" "$prefix"
|
||||||
|
if check_extension "$extension"; then
|
||||||
|
add_log "${tick:?}" "$extension" "Enabled"
|
||||||
|
else
|
||||||
|
add_extension_helper "$extension" "$prefix"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to get the PECL version of an extension.
|
||||||
|
get_pecl_version() {
|
||||||
|
local extension=$1
|
||||||
|
stability="$(echo "$2" | grep -m 1 -Eio "(stable|alpha|beta|rc|snapshot|preview)")"
|
||||||
|
pecl_rest='https://pecl.php.net/rest/r/'
|
||||||
|
response=$(get -s -n "" "$pecl_rest$extension"/allreleases.xml)
|
||||||
|
pecl_version=$(echo "$response" | grep -m 1 -Eio "([0-9]+\.[0-9]+\.[0-9]+${stability}[0-9]+)")
|
||||||
|
if [ ! "$pecl_version" ]; then
|
||||||
|
pecl_version=$(echo "$response" | grep -m 1 -Eo "([0-9]+\.[0-9]+\.[0-9]+)")
|
||||||
|
fi
|
||||||
|
echo "$pecl_version"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to install PECL extensions and accept default options
|
||||||
|
pecl_install() {
|
||||||
|
local extension=$1
|
||||||
|
add_pecl >/dev/null 2>&1
|
||||||
|
cpu_count="$(nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || echo '1')"
|
||||||
|
prefix_opts="$(parse_args "$extension" CONFIGURE_PREFIX_OPTS) MAKEFLAGS='-j $cpu_count'"
|
||||||
|
suffix_opts="$(parse_args "$extension" CONFIGURE_OPTS) $(parse_args "$extension" CONFIGURE_SUFFIX_OPTS)"
|
||||||
|
IFS=' ' read -r -a libraries <<<"$(parse_args "$extension" LIBS) $(parse_args "$extension" "$(uname -s)"_LIBS)"
|
||||||
|
(( ${#libraries[@]} )) && add_libs "${libraries[@]}" >/dev/null 2>&1
|
||||||
|
yes '' 2>/dev/null | sudo "$prefix_opts" pecl install -f -D "$(parse_pecl_configure_options "$suffix_opts")" "$extension" >/dev/null 2>&1
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to install a specific version of PECL extension.
|
||||||
|
add_pecl_extension() {
|
||||||
|
local extension=$1
|
||||||
|
local pecl_version=$2
|
||||||
|
local prefix=$3
|
||||||
|
enable_extension "$extension" "$prefix"
|
||||||
|
if [[ $pecl_version =~ .*(alpha|beta|rc|snapshot|preview).* ]]; then
|
||||||
|
pecl_version=$(get_pecl_version "$extension" "$pecl_version")
|
||||||
|
fi
|
||||||
|
ext_version=$(php -r "echo phpversion('$extension');")
|
||||||
|
if [ "${ext_version/-/}" = "$pecl_version" ]; then
|
||||||
|
add_log "${tick:?}" "$extension" "Enabled"
|
||||||
|
else
|
||||||
|
disable_extension_helper "$extension" >/dev/null 2>&1
|
||||||
|
pecl_install "$extension-$pecl_version"
|
||||||
|
add_extension_log "$extension-$pecl_version" "Installed and enabled"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to setup pre-release extensions using PECL.
|
||||||
|
add_unstable_extension() {
|
||||||
|
local extension=$1
|
||||||
|
local stability=$2
|
||||||
|
local prefix=$3
|
||||||
|
pecl_version=$(get_pecl_version "$extension" "$stability")
|
||||||
|
add_pecl_extension "$extension" "$pecl_version" "$prefix"
|
||||||
|
}
|
@ -1,10 +1,10 @@
|
|||||||
# Function to log license details.
|
# Function to log license details.
|
||||||
add_license_log() {
|
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 "$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 "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 "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"
|
printf "Refer to: \033[35;1m%s \033[0m\n" "https://github.com/CUBRID/cubrid-cci/blob/develop/COPYING"
|
||||||
echo "::endgroup::"
|
echo "$END_GROUP"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to setup gcc-7 and g++-7
|
# Function to setup gcc-7 and g++-7
|
||||||
@ -57,4 +57,4 @@ add_cubrid() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# shellcheck source=.
|
# shellcheck source=.
|
||||||
. "${scripts:?}"/ext/patches/phpize.sh
|
. "${scripts:?}"/extensions/patches/phpize.sh
|
@ -15,7 +15,7 @@ class ExtensionMap {
|
|||||||
/** @var string Prefix in PHP extension file. */
|
/** @var string Prefix in PHP extension file. */
|
||||||
private $file_prefix;
|
private $file_prefix;
|
||||||
|
|
||||||
/** @var string String to store the map */
|
/** @var array Array to store the map */
|
||||||
private $map;
|
private $map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -25,7 +25,23 @@ class ExtensionMap {
|
|||||||
$this->extension_dir = ini_get('extension_dir');
|
$this->extension_dir = ini_get('extension_dir');
|
||||||
$this->file_extension = (PHP_OS == 'WINNT' ? '.dll' : '.so');
|
$this->file_extension = (PHP_OS == 'WINNT' ? '.dll' : '.so');
|
||||||
$this->file_prefix = (PHP_OS == 'WINNT' ? 'php_' : '');
|
$this->file_prefix = (PHP_OS == 'WINNT' ? 'php_' : '');
|
||||||
$this->map = '';
|
$this->map = array();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function to read the extension map.
|
||||||
|
*/
|
||||||
|
private function parseMap($path) {
|
||||||
|
if(file_exists($path)) {
|
||||||
|
$handle = fopen($path, "r");
|
||||||
|
if ($handle) {
|
||||||
|
while (($line = fgets($handle)) !== false) {
|
||||||
|
$line_parts = explode(':', $line);
|
||||||
|
$this->map[$line_parts[0]] = explode(' ', trim($line_parts[1]));
|
||||||
|
}
|
||||||
|
fclose($handle);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -34,7 +50,7 @@ class ExtensionMap {
|
|||||||
* @param string $extension
|
* @param string $extension
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function checkSharedExtension($extension) {
|
private function checkSharedExtension($extension) {
|
||||||
$extension_file = $this->extension_dir. DIRECTORY_SEPARATOR . $this->file_prefix . $extension . $this->file_extension;
|
$extension_file = $this->extension_dir. DIRECTORY_SEPARATOR . $this->file_prefix . $extension . $this->file_extension;
|
||||||
return file_exists($extension_file);
|
return file_exists($extension_file);
|
||||||
}
|
}
|
||||||
@ -44,7 +60,7 @@ class ExtensionMap {
|
|||||||
*
|
*
|
||||||
* @return string[]
|
* @return string[]
|
||||||
*/
|
*/
|
||||||
public function getSharedExtensions() {
|
private function getSharedExtensions() {
|
||||||
$files = scandir($this->extension_dir);
|
$files = scandir($this->extension_dir);
|
||||||
$extensions = array_diff($files, array('.','..'));
|
$extensions = array_diff($files, array('.','..'));
|
||||||
$filter_pattern = "/$this->file_extension|$this->file_prefix/";
|
$filter_pattern = "/$this->file_extension|$this->file_prefix/";
|
||||||
@ -60,7 +76,7 @@ class ExtensionMap {
|
|||||||
* @param array $dependencies
|
* @param array $dependencies
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function patchDependencies($extension, $dependencies) {
|
private function patchDependencies($extension, $dependencies) {
|
||||||
// memcached 2.2.0 has no dependencies in reflection data.
|
// memcached 2.2.0 has no dependencies in reflection data.
|
||||||
if($extension == 'memcached') {
|
if($extension == 'memcached') {
|
||||||
$dependencies = array_unique(array_merge($dependencies, array('igbinary', 'json', 'msgpack')));
|
$dependencies = array_unique(array_merge($dependencies, array('igbinary', 'json', 'msgpack')));
|
||||||
@ -74,7 +90,10 @@ class ExtensionMap {
|
|||||||
* @param string $extension
|
* @param string $extension
|
||||||
* @throws ReflectionException
|
* @throws ReflectionException
|
||||||
*/
|
*/
|
||||||
public function addExtensionToMap($extension) {
|
private function addExtensionToMap($extension) {
|
||||||
|
if($this->map && array_key_exists($extension, $this->map) && !empty($this->map[$extension])) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
// PHP 5.3 does not allow using $this.
|
// PHP 5.3 does not allow using $this.
|
||||||
$self = $this;
|
$self = $this;
|
||||||
|
|
||||||
@ -84,15 +103,15 @@ class ExtensionMap {
|
|||||||
$dependencies = array_filter($dependencies, function ($dependency) use ($self) {
|
$dependencies = array_filter($dependencies, function ($dependency) use ($self) {
|
||||||
return $self->checkSharedExtension($dependency);
|
return $self->checkSharedExtension($dependency);
|
||||||
});
|
});
|
||||||
$self->map .= $extension . ': ' . implode(' ', $dependencies) . PHP_EOL;
|
$self->map[$extension] = $dependencies;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function to print the map of shared extensions and their dependent extensions.
|
* Function to write the map of shared extensions and their dependent extensions.
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
*/
|
||||||
public function __toString() {
|
public function write() {
|
||||||
|
$path = $_SERVER['argv'][1];
|
||||||
|
$this->parseMap($path);
|
||||||
$extensions = array_map('strtolower', $this->getSharedExtensions());
|
$extensions = array_map('strtolower', $this->getSharedExtensions());
|
||||||
foreach ($extensions as $extension) {
|
foreach ($extensions as $extension) {
|
||||||
try {
|
try {
|
||||||
@ -101,9 +120,13 @@ class ExtensionMap {
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $this->map;
|
$map_string = '';
|
||||||
|
foreach($this->map as $extension => $dependencies) {
|
||||||
|
$map_string .= $extension . ': ' . implode(' ', $dependencies) . PHP_EOL;
|
||||||
|
}
|
||||||
|
file_put_contents($path, $map_string);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$extension_map = new ExtensionMap();
|
$extension_map = new ExtensionMap();
|
||||||
echo $extension_map;
|
$extension_map->write();
|
@ -40,6 +40,7 @@ Function Repair-ICU() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Function Add-Http() {
|
Function Add-Http() {
|
||||||
|
Add-Extension iconv >$null 2>&1
|
||||||
Add-Extension raphf >$null 2>&1
|
Add-Extension raphf >$null 2>&1
|
||||||
if($version -lt '8.0') {
|
if($version -lt '8.0') {
|
||||||
Add-Extension propro >$null 2>&1
|
Add-Extension propro >$null 2>&1
|
@ -11,33 +11,27 @@ get_http_version() {
|
|||||||
|
|
||||||
# Function to enable http extension.
|
# Function to enable http extension.
|
||||||
enable_http() {
|
enable_http() {
|
||||||
|
enable_extension iconv extension
|
||||||
enable_extension propro extension
|
enable_extension propro extension
|
||||||
enable_extension raphf extension
|
enable_extension raphf extension
|
||||||
if (! [[ ${version:?} =~ ${jit_versions:?} ]] && check_extension propro && check_extension raphf) ||
|
if (! [[ ${version:?} =~ ${jit_versions:?} ]] && check_extension iconv && check_extension propro && check_extension raphf) ||
|
||||||
( [[ ${version:?} =~ ${jit_versions:?} ]] && check_extension raphf); then
|
( [[ ${version:?} =~ ${jit_versions:?} ]] && check_extension iconv && check_extension raphf); then
|
||||||
enable_extension http extension
|
enable_extension http extension
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to install extensions.
|
|
||||||
add_extension_helper() {
|
|
||||||
if [ "$os" = "Linux" ]; then
|
|
||||||
add_extension "$1" extension
|
|
||||||
else
|
|
||||||
add_brew_extension "$1" extension
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# Function to install http dependencies.
|
# Function to install http dependencies.
|
||||||
add_http_dependencies() {
|
add_http_dependencies() {
|
||||||
if [[ ${version:?} =~ ${old_versions:?} ]]; then
|
if [[ ${version:?} =~ ${old_versions:?} ]]; then
|
||||||
add_pecl_extension raphf 1.1.2 extension
|
add_pecl_extension raphf 1.1.2 extension
|
||||||
add_pecl_extension propro 1.0.2 extension
|
add_pecl_extension propro 1.0.2 extension
|
||||||
elif [[ ${version:?} =~ 5.6|7.[0-4] ]]; then
|
elif [[ ${version:?} =~ 5.6|7.[0-4] ]]; then
|
||||||
add_extension_helper propro
|
add_extension iconv extension
|
||||||
add_extension_helper raphf
|
add_extension propro extension
|
||||||
|
add_extension raphf extension
|
||||||
else
|
else
|
||||||
add_extension_helper raphf
|
add_extension iconv extension
|
||||||
|
add_extension raphf extension
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,8 +72,8 @@ add_http_helper() {
|
|||||||
add_http_latest() {
|
add_http_latest() {
|
||||||
enable_http
|
enable_http
|
||||||
if ! check_extension http; then
|
if ! check_extension http; then
|
||||||
add_http_dependencies
|
|
||||||
if [ "$os" = "Linux" ]; then
|
if [ "$os" = "Linux" ]; then
|
||||||
|
add_http_dependencies
|
||||||
package="php$version-http"
|
package="php$version-http"
|
||||||
add_ppa ondrej/php >/dev/null 2>&1 || update_ppa ondrej/php
|
add_ppa ondrej/php >/dev/null 2>&1 || update_ppa ondrej/php
|
||||||
(check_package "$package" && install_packages "$package") || add_http_helper "$(get_http_version)" "$os"
|
(check_package "$package" && install_packages "$package") || add_http_helper "$(get_http_version)" "$os"
|
||||||
@ -97,6 +91,7 @@ add_http_version() {
|
|||||||
ext=$1
|
ext=$1
|
||||||
enable_http
|
enable_http
|
||||||
if [ "x$(php -r "echo phpversion('http');")" != "x${ext##*-}" ]; then
|
if [ "x$(php -r "echo phpversion('http');")" != "x${ext##*-}" ]; then
|
||||||
|
add_http_dependencies
|
||||||
disable_extension_helper http >/dev/null
|
disable_extension_helper http >/dev/null
|
||||||
add_http_helper pecl_http-"${ext##*-}" "$os"
|
add_http_helper pecl_http-"${ext##*-}" "$os"
|
||||||
status="Installed and enabled"
|
status="Installed and enabled"
|
@ -1,8 +1,8 @@
|
|||||||
# Function to log result of a operation.
|
# Function to log result of a operation.
|
||||||
Function Add-LicenseLog() {
|
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"
|
printf "$env: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
|
Get-Content $ext_dir\ioncube\LICENSE.txt
|
||||||
Write-Output "::endgroup::"
|
Write-Output "$env:END_GROUP"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to add ioncube extension.
|
# Function to add ioncube extension.
|
@ -1,8 +1,8 @@
|
|||||||
# Function to log result of a operation.
|
# Function to log result of a operation.
|
||||||
add_license_log() {
|
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"
|
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 "${ext_dir:?}"/IONCUBE_LICENSE.txt
|
cat "${ext_dir:?}"/IONCUBE_LICENSE.txt
|
||||||
echo "::endgroup::"
|
echo "$END_GROUP"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to install ioncube.
|
# Function to install ioncube.
|
@ -1,10 +1,10 @@
|
|||||||
# Function to log license information.
|
# Function to log license information.
|
||||||
Function Add-LicenseLog() {
|
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 "$env: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 "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 "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"
|
printf "Refer to: \033[35;1m%s \033[0m\n" "https://www.oracle.com/downloads/licenses/instant-client-lic.html"
|
||||||
Write-Output "::endgroup::"
|
Write-Output "$env:END_GROUP"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to get instantclinet.
|
# Function to get instantclinet.
|
@ -1,10 +1,10 @@
|
|||||||
# Function to log result of a operation.
|
# Function to log result of a operation.
|
||||||
add_license_log() {
|
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 "$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 "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 "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"
|
printf "Refer to: \033[35;1m%s \033[0m\n" "https://www.oracle.com/downloads/licenses/instant-client-lic.html"
|
||||||
echo "::endgroup::"
|
echo "$END_GROUP"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to install instantclient and SDK.
|
# Function to install instantclient and SDK.
|
||||||
@ -62,4 +62,4 @@ add_oci() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# shellcheck source=.
|
# shellcheck source=.
|
||||||
. "${scripts:?}"/ext/patches/phpize.sh
|
. "${scripts:?}"/extensions/patches/phpize.sh
|
@ -1,6 +1,6 @@
|
|||||||
# Function to parse extension environment variables
|
# Function to parse extension environment variables
|
||||||
parse_args() {
|
parse_args() {
|
||||||
extension=$1
|
local extension=${1%-*}
|
||||||
suffix=$(echo "$2" | tr '[:lower:]' '[:upper:]')
|
suffix=$(echo "$2" | tr '[:lower:]' '[:upper:]')
|
||||||
up_ext_name=$(echo "$extension" | tr '[:lower:]' '[:upper:]')
|
up_ext_name=$(echo "$extension" | tr '[:lower:]' '[:upper:]')
|
||||||
var="${extension}_${suffix}"
|
var="${extension}_${suffix}"
|
||||||
@ -10,9 +10,22 @@ parse_args() {
|
|||||||
echo "$output" | xargs -n 1 | sort | uniq | xargs
|
echo "$output" | xargs -n 1 | sort | uniq | xargs
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Function to parse configure options for pecl
|
||||||
|
# Make sure we have all options in name="value" form i.e XML properties.
|
||||||
|
parse_pecl_configure_options() {
|
||||||
|
configure_opts=$(echo "$1" | sed -r -e "s#['\"]|--##g")
|
||||||
|
IFS=' ' read -r -a opts_array <<< "$configure_opts"
|
||||||
|
output_opts=()
|
||||||
|
for opt in "${opts_array[@]}"; do
|
||||||
|
[ "${opt##*=}" != "${opt%=*}" ] && value="${opt##*=}" || value=yes
|
||||||
|
output_opts+=("${opt%=*}=\"$value\"")
|
||||||
|
done
|
||||||
|
echo "${output_opts[@]}"
|
||||||
|
}
|
||||||
|
|
||||||
# Function to log if a library is installed
|
# Function to log if a library is installed
|
||||||
add_lib_log() {
|
add_lib_log() {
|
||||||
lib=$1
|
local lib=$1
|
||||||
if check_lib "$lib"; then
|
if check_lib "$lib"; then
|
||||||
add_log "${tick:?}" "$lib" "Installed"
|
add_log "${tick:?}" "$lib" "Installed"
|
||||||
else
|
else
|
||||||
@ -22,7 +35,7 @@ add_lib_log() {
|
|||||||
|
|
||||||
# Function to check if a library is installed
|
# Function to check if a library is installed
|
||||||
check_lib() {
|
check_lib() {
|
||||||
lib=$1
|
local lib=$1
|
||||||
if [ "$(uname -s)" = "Linux" ]; then
|
if [ "$(uname -s)" = "Linux" ]; then
|
||||||
[ "x$(dpkg -s "$lib" 2>/dev/null | grep Status)" != "x" ]
|
[ "x$(dpkg -s "$lib" 2>/dev/null | grep Status)" != "x" ]
|
||||||
else
|
else
|
||||||
@ -32,7 +45,7 @@ check_lib() {
|
|||||||
|
|
||||||
# Function to add a library on linux
|
# Function to add a library on linux
|
||||||
add_linux_libs() {
|
add_linux_libs() {
|
||||||
lib=$1
|
local lib=$1
|
||||||
if ! check_lib "$lib"; then
|
if ! check_lib "$lib"; then
|
||||||
install_packages "$lib" >/dev/null 2>&1 || true
|
install_packages "$lib" >/dev/null 2>&1 || true
|
||||||
fi
|
fi
|
||||||
@ -41,7 +54,7 @@ add_linux_libs() {
|
|||||||
|
|
||||||
# Function to add a library on macOS
|
# Function to add a library on macOS
|
||||||
add_darwin_libs() {
|
add_darwin_libs() {
|
||||||
lib=$1
|
local lib=$1
|
||||||
if ! check_lib "$lib"; then
|
if ! check_lib "$lib"; then
|
||||||
brew install "$lib" >/dev/null 2>&1 || true
|
brew install "$lib" >/dev/null 2>&1 || true
|
||||||
if [[ "$lib" = *@* ]]; then
|
if [[ "$lib" = *@* ]]; then
|
||||||
@ -53,7 +66,7 @@ add_darwin_libs() {
|
|||||||
|
|
||||||
# Function to add required libraries
|
# Function to add required libraries
|
||||||
add_libs() {
|
add_libs() {
|
||||||
all_libs=("$@")
|
local all_libs=("$@")
|
||||||
for lib in "${all_libs[@]}"; do
|
for lib in "${all_libs[@]}"; do
|
||||||
if [ "$(uname -s)" = "Linux" ]; then
|
if [ "$(uname -s)" = "Linux" ]; then
|
||||||
add_linux_libs "$lib"
|
add_linux_libs "$lib"
|
||||||
@ -65,26 +78,27 @@ add_libs() {
|
|||||||
|
|
||||||
# Function to run command in a group
|
# Function to run command in a group
|
||||||
run_group() {
|
run_group() {
|
||||||
command=$1
|
local command=$1
|
||||||
log=$2
|
local log=$2
|
||||||
echo "$command" | sudo tee ./run_group.sh >/dev/null 2>&1
|
echo "$command" | sudo tee ./run_group.sh >/dev/null 2>&1
|
||||||
echo "::group::$log"
|
echo "$GROUP$log"
|
||||||
. ./run_group.sh
|
. ./run_group.sh
|
||||||
rm ./run_group.sh
|
rm ./run_group.sh
|
||||||
echo "::endgroup::"
|
echo "$END_GROUP"
|
||||||
}
|
}
|
||||||
|
|
||||||
patch_extension() {
|
patch_extension() {
|
||||||
extension=$1
|
local extension=$1
|
||||||
if [ -e "${scripts:?}"/ext/patches/"$extension".sh ]; then
|
if [ -e "${scripts:?}"/extensions/patches/"$extension".sh ]; then
|
||||||
# shellcheck source=.
|
# shellcheck source=.
|
||||||
. "${scripts:?}"/ext/patches/"$extension".sh
|
. "${scripts:?}"/extensions/patches/"$extension".sh
|
||||||
patch_"${extension}"
|
patch_"${extension}"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
fetch_extension() {
|
fetch_extension() {
|
||||||
fetch=$1
|
local extension=$1
|
||||||
|
local fetch=$2
|
||||||
if [ "$fetch" = "clone" ]; then
|
if [ "$fetch" = "clone" ]; then
|
||||||
run_group "git clone -nv $url/$org/$repo /tmp/$repo-$release" "git clone"
|
run_group "git clone -nv $url/$org/$repo /tmp/$repo-$release" "git clone"
|
||||||
cd /tmp/"$repo-$release" || exit 1
|
cd /tmp/"$repo-$release" || exit 1
|
||||||
@ -109,13 +123,13 @@ fetch_extension() {
|
|||||||
|
|
||||||
# Function to install extension from a git repository
|
# Function to install extension from a git repository
|
||||||
add_extension_from_source() {
|
add_extension_from_source() {
|
||||||
extension="${1/pecl_/}"
|
local extension="${1/pecl_/}"
|
||||||
url=$2
|
local url=$2
|
||||||
org=$3
|
local org=$3
|
||||||
repo=$4
|
local repo=$4
|
||||||
release=$5
|
local release=$5
|
||||||
prefix=$6
|
local prefix=$6
|
||||||
fetch=${7:-clone}
|
local fetch=${7:-clone}
|
||||||
slug="$extension-$release"
|
slug="$extension-$release"
|
||||||
source="$url/$org/$repo"
|
source="$url/$org/$repo"
|
||||||
libraries="$(parse_args "$extension" LIBS) $(parse_args "$extension" "$(uname -s)"_LIBS)"
|
libraries="$(parse_args "$extension" LIBS) $(parse_args "$extension" "$(uname -s)"_LIBS)"
|
||||||
@ -127,7 +141,7 @@ add_extension_from_source() {
|
|||||||
(
|
(
|
||||||
add_devtools phpize >/dev/null 2>&1
|
add_devtools phpize >/dev/null 2>&1
|
||||||
disable_extension_helper "$extension"
|
disable_extension_helper "$extension"
|
||||||
fetch_extension "$fetch"
|
fetch_extension "$extension" "$fetch"
|
||||||
if ! [ "$(find . -maxdepth 1 -name '*.m4' -exec grep -H 'PHP_NEW_EXTENSION' {} \; | wc -l)" != "0" ]; then
|
if ! [ "$(find . -maxdepth 1 -name '*.m4' -exec grep -H 'PHP_NEW_EXTENSION' {} \; | wc -l)" != "0" ]; then
|
||||||
add_log "${cross:?}" "$source" "$source does not have a PHP extension"
|
add_log "${cross:?}" "$source" "$source does not have a PHP extension"
|
||||||
else
|
else
|
15
src/scripts/extensions/sqlsrv.sh
Normal file
15
src/scripts/extensions/sqlsrv.sh
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
# Function to get sqlsrv and pdo_sqlsrv version.
|
||||||
|
get_sqlsrv_version() {
|
||||||
|
if [[ "${version:?}" =~ 7.[0-3] ]]; then
|
||||||
|
echo '5.9.0'
|
||||||
|
else
|
||||||
|
echo '5.10.0'
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to install sqlsrv and pdo_sqlsrv.
|
||||||
|
add_sqlsrv() {
|
||||||
|
ext=$1
|
||||||
|
ext_version=$(get_sqlsrv_version)
|
||||||
|
add_pecl_extension "$ext" "$ext_version" extension
|
||||||
|
}
|
@ -1,9 +1,13 @@
|
|||||||
|
# Function to add sudo
|
||||||
|
add_sudo() {
|
||||||
|
if ! command -v sudo >/dev/null; then
|
||||||
|
check_package sudo || apt-get update
|
||||||
|
apt-get install -y sudo
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# Function to setup environment for self-hosted runners.
|
# Function to setup environment for self-hosted runners.
|
||||||
self_hosted_helper() {
|
self_hosted_helper() {
|
||||||
if ! command -v sudo >/dev/null; then
|
|
||||||
apt-get update
|
|
||||||
apt-get install -y sudo || add_log "${cross:?}" "sudo" "Could not install sudo"
|
|
||||||
fi
|
|
||||||
if ! command -v apt-fast >/dev/null; then
|
if ! command -v apt-fast >/dev/null; then
|
||||||
sudo ln -sf /usr/bin/apt-get /usr/bin/apt-fast
|
sudo ln -sf /usr/bin/apt-get /usr/bin/apt-fast
|
||||||
trap "sudo rm -f /usr/bin/apt-fast 2>/dev/null" exit
|
trap "sudo rm -f /usr/bin/apt-fast 2>/dev/null" exit
|
||||||
@ -21,11 +25,15 @@ install_packages() {
|
|||||||
disable_extension_helper() {
|
disable_extension_helper() {
|
||||||
local extension=$1
|
local extension=$1
|
||||||
local disable_dependents=${2:-false}
|
local disable_dependents=${2:-false}
|
||||||
|
get_extension_map
|
||||||
if [ "$disable_dependents" = "true" ]; then
|
if [ "$disable_dependents" = "true" ]; then
|
||||||
disable_extension_dependents "$extension"
|
disable_extension_dependents "$extension"
|
||||||
fi
|
fi
|
||||||
sudo sed -Ei "/=(.*\/)?\"?$extension(.so)?$/d" "${ini_file[@]}" "$pecl_file"
|
sudo sed -Ei "/=(.*\/)?\"?$extension(.so)?$/d" "${ini_file[@]}" "$pecl_file"
|
||||||
sudo find "$ini_dir"/.. -name "*$extension.ini" -not -path "*mods-available*" -delete >/dev/null 2>&1 || true
|
sudo find "$ini_dir"/.. -name "*$extension.ini" -not -path "*phar.ini" -not -path "*pecl.ini" -not -path "*mods-available*" -delete >/dev/null 2>&1 || true
|
||||||
|
sudo rm -f /tmp/php"$version"_extensions
|
||||||
|
mkdir -p /tmp/extdisabled/"$version"
|
||||||
|
echo '' | sudo tee /tmp/extdisabled/"$version"/"$extension" >/dev/null 2>&1
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to add PDO extension.
|
# Function to add PDO extension.
|
||||||
@ -61,22 +69,16 @@ add_pdo_extension() {
|
|||||||
|
|
||||||
# Function to check if a package exists
|
# Function to check if a package exists
|
||||||
check_package() {
|
check_package() {
|
||||||
sudo apt-cache policy "$1" 2>/dev/null | grep -q 'Candidate'
|
apt-cache policy "$1" 2>/dev/null | grep -q 'Candidate'
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to add extensions.
|
# Helper function to add an extension.
|
||||||
add_extension() {
|
add_extension_helper() {
|
||||||
local extension=$1
|
local extension=$1
|
||||||
prefix=$2
|
|
||||||
package=php"$version"-"$extension"
|
package=php"$version"-"$extension"
|
||||||
enable_extension "$extension" "$prefix"
|
add_ppa ondrej/php >/dev/null 2>&1 || update_ppa ondrej/php
|
||||||
if check_extension "$extension"; then
|
(check_package "$package" && install_packages "$package") || pecl_install "$extension"
|
||||||
add_log "${tick:?}" "$extension" "Enabled"
|
add_extension_log "$extension" "Installed and enabled"
|
||||||
else
|
|
||||||
add_ppa ondrej/php >/dev/null 2>&1 || update_ppa ondrej/php
|
|
||||||
(check_package "$package" && install_packages "$package") || pecl_install "$extension"
|
|
||||||
add_extension_log "$extension" "Installed and enabled"
|
|
||||||
fi
|
|
||||||
sudo chmod 777 "${ini_file[@]}"
|
sudo chmod 777 "${ini_file[@]}"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,8 +86,9 @@ add_extension() {
|
|||||||
add_devtools() {
|
add_devtools() {
|
||||||
tool=$1
|
tool=$1
|
||||||
if ! command -v "$tool$version" >/dev/null; then
|
if ! command -v "$tool$version" >/dev/null; then
|
||||||
install_packages "php$version-dev" "php$version-xml"
|
install_packages "php$version-dev"
|
||||||
fi
|
fi
|
||||||
|
add_extension xml extension >/dev/null 2>&1
|
||||||
switch_version "phpize" "php-config"
|
switch_version "phpize" "php-config"
|
||||||
add_log "${tick:?}" "$tool" "Added $tool $semver"
|
add_log "${tick:?}" "$tool" "Added $tool $semver"
|
||||||
}
|
}
|
||||||
@ -113,8 +116,14 @@ add_pecl() {
|
|||||||
|
|
||||||
# Function to switch versions of PHP binaries.
|
# Function to switch versions of PHP binaries.
|
||||||
switch_version() {
|
switch_version() {
|
||||||
tools=("$@") && ! (( ${#tools[@]} )) && tools+=(pear pecl php phar phar.phar php-cgi php-config phpize phpdbg)
|
tools=("$@")
|
||||||
to_wait=()
|
to_wait=()
|
||||||
|
if ! (( ${#tools[@]} )); then
|
||||||
|
tools+=(pear pecl php phar phar.phar php-cgi php-config phpize phpdbg)
|
||||||
|
[ -e /usr/lib/cgi-bin/php"$version" ] && sudo update-alternatives --set php-cgi-bin /usr/lib/cgi-bin/php"$version" & to_wait+=($!)
|
||||||
|
[ -e /usr/sbin/php-fpm"$version" ] && sudo update-alternatives --set php-fpm /usr/sbin/php-fpm"$version" & to_wait+=($!)
|
||||||
|
[ -e /run/php/php"$version"-fpm.sock ] && sudo update-alternatives --set php-fpm.sock /run/php/php"$version"-fpm.sock & to_wait+=($!)
|
||||||
|
fi
|
||||||
for tool in "${tools[@]}"; do
|
for tool in "${tools[@]}"; do
|
||||||
if [ -e "/usr/bin/$tool$version" ]; then
|
if [ -e "/usr/bin/$tool$version" ]; then
|
||||||
sudo update-alternatives --set "$tool" /usr/bin/"$tool$version" &
|
sudo update-alternatives --set "$tool" /usr/bin/"$tool$version" &
|
||||||
@ -128,8 +137,9 @@ switch_version() {
|
|||||||
add_packaged_php() {
|
add_packaged_php() {
|
||||||
if [ "$runner" = "self-hosted" ] || [ "${use_package_cache:-true}" = "false" ]; then
|
if [ "$runner" = "self-hosted" ] || [ "${use_package_cache:-true}" = "false" ]; then
|
||||||
add_ppa ondrej/php >/dev/null 2>&1 || update_ppa ondrej/php
|
add_ppa ondrej/php >/dev/null 2>&1 || update_ppa ondrej/php
|
||||||
IFS=' ' read -r -a packages <<<"$(echo "cli curl dev mbstring xml intl" | sed "s/[^ ]*/php$version-&/g")"
|
IFS=' ' read -r -a packages <<<"$(sed "s/[^ ]*/php$version-&/g" "$src"/configs/php_packages | tr '\n' ' ')"
|
||||||
install_packages "${packages[@]}"
|
install_packages "${packages[@]}"
|
||||||
|
add_pecl
|
||||||
else
|
else
|
||||||
run_script "php-ubuntu" "$version"
|
run_script "php-ubuntu" "$version"
|
||||||
fi
|
fi
|
||||||
@ -165,7 +175,10 @@ link_pecl_file() {
|
|||||||
echo '' | sudo tee "$pecl_file" >/dev/null 2>&1
|
echo '' | sudo tee "$pecl_file" >/dev/null 2>&1
|
||||||
for file in "${ini_file[@]}"; do
|
for file in "${ini_file[@]}"; do
|
||||||
sapi_scan_dir="$(realpath -m "$(dirname "$file")")/conf.d"
|
sapi_scan_dir="$(realpath -m "$(dirname "$file")")/conf.d"
|
||||||
[ "$sapi_scan_dir" != "$scan_dir" ] && ! [ -h "$sapi_scan_dir" ] && sudo ln -sf "$pecl_file" "$sapi_scan_dir/99-pecl.ini"
|
if [ "$sapi_scan_dir" != "$scan_dir" ] && ! [ -h "$sapi_scan_dir" ]; then
|
||||||
|
sudo mkdir -p "$sapi_scan_dir"
|
||||||
|
sudo ln -sf "$pecl_file" "$sapi_scan_dir/99-pecl.ini"
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -176,12 +189,34 @@ php_extra_version() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Function to set php.ini
|
||||||
|
add_php_config() {
|
||||||
|
php_lib_dir=/usr/lib/php/"$version"
|
||||||
|
current_ini="$php_lib_dir"/php.ini-current
|
||||||
|
current=$(cat "$current_ini" 2>/dev/null)
|
||||||
|
if [ "$current" = "$ini" ]; then
|
||||||
|
return;
|
||||||
|
fi
|
||||||
|
if [[ "$ini" = "production" && "x$current" != "xproduction" ]]; then
|
||||||
|
echo "${ini_file[@]}" | xargs -n 1 -P 6 sudo cp "$php_lib_dir"/php.ini-production
|
||||||
|
if [ -e "$php_lib_dir"/php.ini-production.cli ]; then
|
||||||
|
sudo cp "$php_lib_dir"/php.ini-production.cli "$ini_dir"/php.ini
|
||||||
|
fi
|
||||||
|
elif [ "$ini" = "development" ]; then
|
||||||
|
echo "${ini_file[@]}" | xargs -n 1 -P 6 sudo cp "$php_lib_dir"/php.ini-development
|
||||||
|
elif [ "$ini" = "none" ]; then
|
||||||
|
echo '' | sudo tee "${ini_file[@]}" >/dev/null 2>&1
|
||||||
|
fi
|
||||||
|
echo "$ini" | sudo tee "$current_ini" >/dev/null 2>&1
|
||||||
|
}
|
||||||
|
|
||||||
# Function to Setup PHP
|
# Function to Setup PHP
|
||||||
setup_php() {
|
setup_php() {
|
||||||
step_log "Setup PHP"
|
step_log "Setup PHP"
|
||||||
sudo mkdir -m 777 -p /var/run /run/php
|
sudo mkdir -m 777 -p /var/run /run/php
|
||||||
if [ "$(php-config --version 2>/dev/null | cut -c 1-3)" != "$version" ]; then
|
php_config="$(command -v php-config)"
|
||||||
if [ ! -e "/usr/bin/php$version" ]; then
|
if [[ -z "$php_config" ]] || [ "$(php_semver | cut -c 1-3)" != "$version" ]; then
|
||||||
|
if [ ! -e "/usr/bin/php$version" ] || [ ! -e "/usr/bin/php-config$version" ]; then
|
||||||
add_php >/dev/null 2>&1
|
add_php >/dev/null 2>&1
|
||||||
else
|
else
|
||||||
if ! [[ "$version" =~ ${old_versions:?} ]]; then
|
if ! [[ "$version" =~ ${old_versions:?} ]]; then
|
||||||
@ -193,6 +228,7 @@ setup_php() {
|
|||||||
status="Switched to"
|
status="Switched to"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
php_config="$(command -v php-config)"
|
||||||
else
|
else
|
||||||
if [ "$update" = "true" ]; then
|
if [ "$update" = "true" ]; then
|
||||||
update_php >/dev/null 2>&1
|
update_php >/dev/null 2>&1
|
||||||
@ -201,39 +237,43 @@ setup_php() {
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
if ! command -v php"$version" >/dev/null; then
|
if ! command -v php"$version" >/dev/null; then
|
||||||
add_log "$cross" "PHP" "Could not setup PHP $version"
|
add_log "${cross:?}" "PHP" "Could not setup PHP $version"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
semver=$(php_semver)
|
ext_dir="/usr/$(grep -Po "extension_dir=..[^/]*/\K[^'\"]*" "$php_config")"
|
||||||
extra_version=$(php_extra_version)
|
ini_dir="$(php_ini_path)"
|
||||||
ext_dir=$(php -i | grep "extension_dir => /" | sed -e "s|.*=> s*||")
|
scan_dir="$ini_dir"/conf.d
|
||||||
scan_dir=$(php --ini | grep additional | sed -e "s|.*: s*||")
|
|
||||||
ini_dir=$(php --ini | grep "(php.ini)" | sed -e "s|.*: s*||")
|
|
||||||
pecl_file="$scan_dir"/99-pecl.ini
|
pecl_file="$scan_dir"/99-pecl.ini
|
||||||
|
semver="$(php_semver)"
|
||||||
|
extra_version="$(php_extra_version)"
|
||||||
export ext_dir
|
export ext_dir
|
||||||
mapfile -t ini_file < <(sudo find "$ini_dir/.." -name "php.ini" -exec readlink -m {} +)
|
mapfile -t ini_file < <(sudo find "$ini_dir/.." -name "php.ini" -exec readlink -m {} +)
|
||||||
link_pecl_file
|
link_pecl_file
|
||||||
configure_php
|
configure_php
|
||||||
|
set_output "php-version" "$semver"
|
||||||
sudo rm -rf /usr/local/bin/phpunit >/dev/null 2>&1
|
sudo rm -rf /usr/local/bin/phpunit >/dev/null 2>&1
|
||||||
sudo chmod 777 "${ini_file[@]}" "$pecl_file" "${tool_path_dir:?}"
|
sudo chmod 777 "${ini_file[@]}" "$pecl_file" "${tool_path_dir:?}"
|
||||||
sudo cp "$dist"/../src/configs/pm/*.json "$RUNNER_TOOL_CACHE/"
|
sudo cp "$src"/configs/pm/*.json "$RUNNER_TOOL_CACHE/"
|
||||||
echo "::set-output name=php-version::$semver"
|
|
||||||
add_log "${tick:?}" "PHP" "$status PHP $semver$extra_version"
|
add_log "${tick:?}" "PHP" "$status PHP $semver$extra_version"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Variables
|
# Variables
|
||||||
version=$1
|
version=${1:-'8.1'}
|
||||||
dist=$2
|
ini=${2:-'production'}
|
||||||
|
src=${0%/*}/..
|
||||||
debconf_fix="DEBIAN_FRONTEND=noninteractive"
|
debconf_fix="DEBIAN_FRONTEND=noninteractive"
|
||||||
apt_install="sudo $debconf_fix apt-fast install -y --no-install-recommends"
|
apt_install="sudo $debconf_fix apt-fast install -y --no-install-recommends"
|
||||||
scripts="${dist}"/../src/scripts
|
scripts="$src"/scripts
|
||||||
|
|
||||||
|
add_sudo >/dev/null 2>&1
|
||||||
|
|
||||||
. /etc/os-release
|
. /etc/os-release
|
||||||
# shellcheck source=.
|
# shellcheck source=.
|
||||||
. "${scripts:?}"/ext/source.sh
|
. "${scripts:?}"/unix.sh
|
||||||
. "${scripts:?}"/tools/ppa.sh
|
. "${scripts:?}"/tools/ppa.sh
|
||||||
. "${scripts:?}"/tools/add_tools.sh
|
. "${scripts:?}"/tools/add_tools.sh
|
||||||
. "${scripts:?}"/common.sh
|
. "${scripts:?}"/extensions/source.sh
|
||||||
|
. "${scripts:?}"/extensions/add_extensions.sh
|
||||||
read_env
|
read_env
|
||||||
self_hosted_setup
|
self_hosted_setup
|
||||||
setup_php
|
setup_php
|
||||||
|
@ -1,29 +1,239 @@
|
|||||||
|
# Variables
|
||||||
|
$composer_bin = "$env:APPDATA\Composer\vendor\bin"
|
||||||
|
$composer_json = "$env:APPDATA\Composer\composer.json"
|
||||||
|
$composer_lock = "$env:APPDATA\Composer\composer.lock"
|
||||||
|
|
||||||
|
# Function to configure composer.
|
||||||
|
Function Edit-ComposerConfig() {
|
||||||
|
Param(
|
||||||
|
[Parameter(Position = 0, Mandatory = $true)]
|
||||||
|
[ValidateNotNull()]
|
||||||
|
[ValidateLength(1, [int]::MaxValue)]
|
||||||
|
[string]
|
||||||
|
$tool_path
|
||||||
|
)
|
||||||
|
Copy-Item $tool_path -Destination "$tool_path.phar"
|
||||||
|
php -r "try {`$p=new Phar('$tool_path.phar', 0);exit(0);} catch(Exception `$e) {exit(1);}"
|
||||||
|
if ($? -eq $False) {
|
||||||
|
Add-Log "$cross" "composer" "Could not download composer"
|
||||||
|
exit 1;
|
||||||
|
}
|
||||||
|
New-Item -ItemType Directory -Path $composer_bin -Force > $null 2>&1
|
||||||
|
if (-not(Test-Path $composer_json)) {
|
||||||
|
Set-Content -Path $composer_json -Value "{}"
|
||||||
|
}
|
||||||
|
Add-EnvPATH $src\configs\composer.env
|
||||||
|
Add-Path $composer_bin
|
||||||
|
if (Test-Path env:COMPOSER_TOKEN) {
|
||||||
|
Add-Env COMPOSER_AUTH ('{"github-oauth": {"github.com": "' + $env:COMPOSER_TOKEN + '"}}')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to extract tool version.
|
||||||
|
Function Get-ToolVersion() {
|
||||||
|
Param (
|
||||||
|
[Parameter(Position = 0, Mandatory = $true)]
|
||||||
|
$tool,
|
||||||
|
[Parameter(Position = 1, Mandatory = $true)]
|
||||||
|
$param
|
||||||
|
)
|
||||||
|
$alp = "[a-zA-Z0-9]"
|
||||||
|
$version_regex = "[0-9]+((\.{1}$alp+)+)(\.{0})(-$alp+){0,1}"
|
||||||
|
if($tool -eq 'composer') {
|
||||||
|
$composer_branch_alias = Select-String -Pattern "const\sBRANCH_ALIAS_VERSION" -Path $bin_dir\composer -Raw | Select-String -Pattern $version_regex | ForEach-Object { $_.matches.Value }
|
||||||
|
if ($composer_branch_alias) {
|
||||||
|
$composer_version = $composer_branch_alias + '+' + (Select-String -Pattern "const\sVERSION" -Path $bin_dir\composer -Raw | Select-String -Pattern "[a-zA-Z0-9]+" -AllMatches | ForEach-Object { $_.matches[2].Value })
|
||||||
|
} else {
|
||||||
|
$composer_version = Select-String -Pattern "const\sVERSION" -Path $bin_dir\composer -Raw | Select-String -Pattern $version_regex | ForEach-Object { $_.matches.Value }
|
||||||
|
}
|
||||||
|
Set-Variable -Name 'composer_version' -Value $composer_version -Scope Global
|
||||||
|
return "$composer_version"
|
||||||
|
}
|
||||||
|
return . $tool $param 2> $null | ForEach-Object { $_ -replace "composer $version_regex", '' } | Select-String -Pattern $version_regex | Select-Object -First 1 | ForEach-Object { $_.matches.Value }
|
||||||
|
}
|
||||||
|
|
||||||
|
# Helper function to configure tools.
|
||||||
Function Add-ToolsHelper() {
|
Function Add-ToolsHelper() {
|
||||||
Param (
|
Param (
|
||||||
[Parameter(Position = 0, Mandatory = $true)]
|
[Parameter(Position = 0, Mandatory = $true)]
|
||||||
[ValidateNotNull()]
|
[ValidateNotNull()]
|
||||||
$tool
|
$tool
|
||||||
)
|
)
|
||||||
|
$extensions = @();
|
||||||
if($tool -eq "codeception") {
|
if($tool -eq "codeception") {
|
||||||
Copy-Item $codeception_bin\codecept.bat -Destination $codeception_bin\codeception.bat
|
$extensions += @('json', 'mbstring')
|
||||||
|
Copy-Item $env:codeception_bin\codecept.bat -Destination $env:codeception_bin\codeception.bat
|
||||||
} elseif($tool -eq "composer") {
|
} elseif($tool -eq "composer") {
|
||||||
Edit-ComposerConfig $bin_dir\$tool
|
Edit-ComposerConfig $bin_dir\$tool
|
||||||
} 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 $bin_dir/cs2pr).replace('exit(9)', 'exit(0)') | Set-Content $bin_dir/cs2pr
|
||||||
} elseif($tool -eq "phan") {
|
} elseif($tool -eq "phan") {
|
||||||
Add-Extension fileinfo >$null 2>&1
|
$extensions += @('fileinfo', 'ast')
|
||||||
Add-Extension ast >$null 2>&1
|
} elseif($tool -eq "phinx") {
|
||||||
|
$extensions += @('mbstring')
|
||||||
} elseif($tool -eq "phive") {
|
} elseif($tool -eq "phive") {
|
||||||
Add-Extension xml >$null 2>&1
|
$extensions += @('curl', 'mbstring', 'xml')
|
||||||
|
} elseif($tool -match "phpc(df|s)") {
|
||||||
|
$extensions += @('tokenizer', 'xmlwriter', 'simplexml')
|
||||||
|
} elseif($tool -match "php-cs-fixer") {
|
||||||
|
$extensions += @('json', 'tokenizer')
|
||||||
} elseif($tool -eq "phpDocumentor") {
|
} elseif($tool -eq "phpDocumentor") {
|
||||||
|
$extensions+=('ctype', 'hash', 'json', 'fileinfo', 'iconv', 'mbstring', 'simplexml', 'xml')
|
||||||
Add-Extension fileinfo >$null 2>&1
|
Add-Extension fileinfo >$null 2>&1
|
||||||
Copy-Item $bin_dir\phpDocumentor.bat -Destination $bin_dir\phpdoc.bat
|
Copy-Item $bin_dir\phpDocumentor.bat -Destination $bin_dir\phpdoc.bat
|
||||||
} elseif($tool -eq "symfony-cli") {
|
} elseif($tool -eq "phpunit") {
|
||||||
Add-ToProfile $current_profile "symfony" "New-Alias symfony $bin_dir\symfony-cli.exe"
|
$extensions += @('dom', 'json', 'libxml', 'mbstring', 'xml', 'xmlwriter')
|
||||||
Add-ToProfile $current_profile "symfony_cli" "New-Alias symfony-cli $bin_dir\symfony-cli.exe"
|
} elseif($tool -eq "phpunit-bridge") {
|
||||||
} elseif($tool -match "vapor-cli") {
|
$extensions += @('dom', 'pdo', 'tokenizer', 'xmlwriter')
|
||||||
Copy-Item $vapor_cli_bin\vapor.bat -Destination $vapor_cli_bin\vapor-cli.bat
|
} elseif($tool -eq "vapor-cli") {
|
||||||
|
$extensions += @('fileinfo', 'json', 'mbstring', 'zip', 'simplexml')
|
||||||
|
Copy-Item $env:vapor_cli_bin\vapor.bat -Destination $env:vapor_cli_bin\vapor-cli.bat
|
||||||
} elseif($tool -eq "wp-cli") {
|
} elseif($tool -eq "wp-cli") {
|
||||||
Copy-Item $bin_dir\wp-cli.bat -Destination $bin_dir\wp.bat
|
Copy-Item $bin_dir\wp-cli.bat -Destination $bin_dir\wp.bat
|
||||||
}
|
}
|
||||||
}
|
foreach($extension in $extensions) {
|
||||||
|
Add-Extension $extension >$null 2>&1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to add tools.
|
||||||
|
Function Add-Tool() {
|
||||||
|
Param (
|
||||||
|
[Parameter(Position = 0, Mandatory = $true)]
|
||||||
|
[ValidateNotNull()]
|
||||||
|
$urls,
|
||||||
|
[Parameter(Position = 1, Mandatory = $true)]
|
||||||
|
[ValidateNotNull()]
|
||||||
|
$tool,
|
||||||
|
[Parameter(Position = 2, Mandatory = $true)]
|
||||||
|
[ValidateNotNull()]
|
||||||
|
$ver_param
|
||||||
|
)
|
||||||
|
if (Test-Path $bin_dir\$tool) {
|
||||||
|
Copy-Item $bin_dir\$tool -Destination $bin_dir\$tool.old -Force
|
||||||
|
}
|
||||||
|
$tool_path = "$bin_dir\$tool"
|
||||||
|
foreach ($url in $urls){
|
||||||
|
if (($url | Split-Path -Extension) -eq ".exe") {
|
||||||
|
$tool_path = "$tool_path.exe"
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
$status_code = (Invoke-WebRequest -Passthru -Uri $url -OutFile $tool_path).StatusCode
|
||||||
|
} catch {
|
||||||
|
if($url -match '.*github.com.*releases.*latest.*') {
|
||||||
|
try {
|
||||||
|
$url = $url.replace("releases/latest/download", "releases/download/" + ([regex]::match((Invoke-WebRequest -Uri ($url.split('/release')[0] + "/releases")).Content, "([0-9]+\.[0-9]+\.[0-9]+)/" + ($url.Substring($url.LastIndexOf("/") + 1))).Groups[0].Value).split('/')[0])
|
||||||
|
$status_code = (Invoke-WebRequest -Passthru -Uri $url -OutFile $tool_path).StatusCode
|
||||||
|
} catch { }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if($status_code -eq 200 -and (Test-Path $tool_path)) {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (((Get-ChildItem -Path $bin_dir/* | Where-Object Name -Match "^$tool(.exe|.phar)*$").Count -gt 0)) {
|
||||||
|
$bat_content = @()
|
||||||
|
$bat_content += "@ECHO off"
|
||||||
|
$bat_content += "setlocal DISABLEDELAYEDEXPANSION"
|
||||||
|
$bat_content += "SET BIN_TARGET=%~dp0/" + $tool
|
||||||
|
$bat_content += "php %BIN_TARGET% %*"
|
||||||
|
Set-Content -Path $bin_dir\$tool.bat -Value $bat_content
|
||||||
|
Add-ToolsHelper $tool
|
||||||
|
Add-ToProfile $current_profile $tool "New-Alias $tool $bin_dir\$tool.bat" >$null 2>&1
|
||||||
|
$tool_version = Get-ToolVersion $tool $ver_param
|
||||||
|
Add-Log $tick $tool "Added $tool $tool_version"
|
||||||
|
} else {
|
||||||
|
if($tool -eq "composer") {
|
||||||
|
$env:fail_fast = 'true'
|
||||||
|
} elseif (Test-Path $bin_dir\$tool.old) {
|
||||||
|
Copy-Item $bin_dir\$tool.old -Destination $bin_dir\$tool -Force
|
||||||
|
}
|
||||||
|
Add-Log $cross $tool "Could not add $tool"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Function Add-ComposertoolHelper() {
|
||||||
|
Param (
|
||||||
|
[Parameter(Position = 0, Mandatory = $true)]
|
||||||
|
[string]
|
||||||
|
$tool,
|
||||||
|
[Parameter(Position = 1, Mandatory = $true)]
|
||||||
|
[string]
|
||||||
|
$release,
|
||||||
|
[Parameter(Position = 2, Mandatory = $true)]
|
||||||
|
[string]
|
||||||
|
$prefix,
|
||||||
|
[Parameter(Position = 3, Mandatory = $true)]
|
||||||
|
[string]
|
||||||
|
$scope,
|
||||||
|
[Parameter(Position = 4, Mandatory = $false)]
|
||||||
|
[string]
|
||||||
|
$composer_args
|
||||||
|
)
|
||||||
|
if($scope -eq 'global') {
|
||||||
|
if(Test-Path $composer_lock) {
|
||||||
|
Remove-Item -Path $composer_lock -Force
|
||||||
|
}
|
||||||
|
composer global require $prefix$release $composer_args >$null 2>&1
|
||||||
|
return composer global show $prefix$tool 2>&1 | findstr '^versions'
|
||||||
|
} else {
|
||||||
|
$release_stream = [System.IO.MemoryStream]::New([System.Text.Encoding]::ASCII.GetBytes($release))
|
||||||
|
$scoped_dir_suffix = (Get-FileHash -InputStream $release_stream -Algorithm sha256).Hash
|
||||||
|
$scoped_dir = "$composer_bin\_tools\$tool-$scoped_dir_suffix"
|
||||||
|
$unix_scoped_dir = $scoped_dir.replace('\', '/')
|
||||||
|
if(-not(Test-Path $scoped_dir)) {
|
||||||
|
New-Item -ItemType Directory -Force -Path $scoped_dir > $null 2>&1
|
||||||
|
composer require $prefix$release -d $unix_scoped_dir $composer_args >$null 2>&1
|
||||||
|
}
|
||||||
|
[System.Environment]::SetEnvironmentVariable(($tool.replace('-', '_') + '_bin'), "$scoped_dir\vendor\bin")
|
||||||
|
Add-Path $scoped_dir\vendor\bin
|
||||||
|
return composer show $prefix$tool -d $unix_scoped_dir 2>&1 | findstr '^versions'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to setup a tool using composer.
|
||||||
|
Function Add-Composertool() {
|
||||||
|
Param (
|
||||||
|
[Parameter(Position = 0, Mandatory = $true)]
|
||||||
|
[ValidateNotNull()]
|
||||||
|
[ValidateLength(1, [int]::MaxValue)]
|
||||||
|
[string]
|
||||||
|
$tool,
|
||||||
|
[Parameter(Position = 1, Mandatory = $true)]
|
||||||
|
[ValidateNotNull()]
|
||||||
|
[ValidateLength(1, [int]::MaxValue)]
|
||||||
|
[string]
|
||||||
|
$release,
|
||||||
|
[Parameter(Position = 2, Mandatory = $true)]
|
||||||
|
[ValidateNotNull()]
|
||||||
|
[ValidateLength(1, [int]::MaxValue)]
|
||||||
|
[string]
|
||||||
|
$prefix,
|
||||||
|
[Parameter(Position = 3, Mandatory = $true)]
|
||||||
|
[ValidateNotNull()]
|
||||||
|
[ValidateLength(1, [int]::MaxValue)]
|
||||||
|
[string]
|
||||||
|
$scope
|
||||||
|
)
|
||||||
|
if($composer_version.split('.')[0] -ne "1") {
|
||||||
|
$composer_args = "--ignore-platform-req=ext-*"
|
||||||
|
if($tool -match "prestissimo|composer-prefetcher") {
|
||||||
|
Write-Output "::warning:: Skipping $tool, as it does not support Composer $composer_version. Specify composer:v1 in tools to use $tool"
|
||||||
|
Add-Log $cross $tool "Skipped"
|
||||||
|
Return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Enable-PhpExtension -Extension curl, mbstring, openssl -Path $php_dir
|
||||||
|
$log = Add-ComposertoolHelper $tool $release $prefix $scope $composer_args
|
||||||
|
if(Test-Path $composer_bin\composer) {
|
||||||
|
Copy-Item -Path "$bin_dir\composer" -Destination "$composer_bin\composer" -Force
|
||||||
|
}
|
||||||
|
Add-ToolsHelper $tool
|
||||||
|
if($log) {
|
||||||
|
$tool_version = Get-ToolVersion "Write-Output" "$log"
|
||||||
|
Add-Log $tick $tool "Added $tool $tool_version"
|
||||||
|
} else {
|
||||||
|
Add-Log $cross $tool "Could not setup $tool"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -1,29 +1,175 @@
|
|||||||
|
# Variables
|
||||||
|
export tool_path_dir="/usr/local/bin"
|
||||||
|
export composer_home="$HOME/.composer"
|
||||||
|
export composer_bin="$composer_home/vendor/bin"
|
||||||
|
export composer_json="$composer_home/composer.json"
|
||||||
|
export composer_lock="$composer_home/composer.lock"
|
||||||
|
|
||||||
|
# Function to extract tool version.
|
||||||
|
get_tool_version() {
|
||||||
|
tool=$1
|
||||||
|
param=$2
|
||||||
|
alp="[a-zA-Z0-9]"
|
||||||
|
version_regex="[0-9]+((\.{1}$alp+)+)(\.{0})(-$alp+){0,1}"
|
||||||
|
if [ "$tool" = "composer" ]; then
|
||||||
|
composer_alias_version="$(grep -Ea "const\sBRANCH_ALIAS_VERSION" "$tool_path_dir/composer" | grep -Eo "$version_regex")"
|
||||||
|
if [[ -n "$composer_alias_version" ]]; then
|
||||||
|
composer_version="$composer_alias_version+$(grep -Ea "const\sVERSION" "$tool_path_dir/composer" | grep -Eo "$alp+" | tail -n 1)"
|
||||||
|
else
|
||||||
|
composer_version="$(grep -Ea "const\sVERSION" "$tool_path_dir/composer" | grep -Eo "$version_regex")"
|
||||||
|
fi
|
||||||
|
echo "$composer_version" | sudo tee /tmp/composer_version
|
||||||
|
else
|
||||||
|
$tool "$param" 2>/dev/null | sed -Ee "s/[Cc]omposer(.)?$version_regex//g" | grep -Eo "$version_regex" | head -n 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to configure composer
|
||||||
|
configure_composer() {
|
||||||
|
tool_path=$1
|
||||||
|
sudo ln -sf "$tool_path" "$tool_path.phar"
|
||||||
|
php -r "try {\$p=new Phar('$tool_path.phar', 0);exit(0);} catch(Exception \$e) {exit(1);}"
|
||||||
|
if [ $? -eq 1 ]; then
|
||||||
|
add_log "${cross:?}" "composer" "Could not download composer"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if ! [ -d "$composer_home" ]; then
|
||||||
|
sudo -u "$(id -un)" -g "$(id -gn)" mkdir -p -m=00755 "$composer_home"
|
||||||
|
else
|
||||||
|
sudo chown -R "$(id -un)":"$(id -gn)" "$composer_home"
|
||||||
|
fi
|
||||||
|
if ! [ -e "$composer_json" ]; then
|
||||||
|
echo '{}' | tee "$composer_json" >/dev/null
|
||||||
|
chmod 644 "$composer_json"
|
||||||
|
fi
|
||||||
|
add_env_path "${src:?}"/configs/composer.env
|
||||||
|
add_path "$composer_bin"
|
||||||
|
if [ -n "$COMPOSER_TOKEN" ]; then
|
||||||
|
add_env COMPOSER_AUTH '{"github-oauth": {"github.com": "'"$COMPOSER_TOKEN"'"}}'
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Helper function to configure tools.
|
||||||
add_tools_helper() {
|
add_tools_helper() {
|
||||||
tool=$1
|
tool=$1
|
||||||
|
extensions=()
|
||||||
if [ "$tool" = "codeception" ]; then
|
if [ "$tool" = "codeception" ]; then
|
||||||
codeception_bin=$(grep codeception_bin "${GITHUB_ENV:?}" | cut -d '=' -f 2)
|
extensions+=(json mbstring)
|
||||||
sudo ln -s "${codeception_bin:?}"/codecept "${codeception_bin:?}"/codeception
|
sudo ln -s "$scoped_dir"/vendor/bin/codecept "$scoped_dir"/vendor/bin/codeception
|
||||||
elif [ "$tool" = "composer" ]; then
|
elif [ "$tool" = "composer" ]; then
|
||||||
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:?}" 2>/dev/null ||
|
sudo sed -i 's/\r$//; s/exit(9)/exit(0)/' "$tool_path" 2>/dev/null ||
|
||||||
sudo sed -i '' 's/\r$//; s/exit(9)/exit(0)/' "${tool_path:?}"
|
sudo sed -i '' 's/\r$//; s/exit(9)/exit(0)/' "$tool_path"
|
||||||
elif [ "$tool" = "phan" ]; then
|
elif [ "$tool" = "phan" ]; then
|
||||||
add_extension fileinfo extension >/dev/null 2>&1
|
extensions+=(fileinfo ast)
|
||||||
add_extension ast extension >/dev/null 2>&1
|
elif [ "$tool" = "phinx" ]; then
|
||||||
|
extensions+=(mbstring)
|
||||||
elif [ "$tool" = "phive" ]; then
|
elif [ "$tool" = "phive" ]; then
|
||||||
add_extension curl extension >/dev/null 2>&1
|
extensions+=(curl mbstring xml)
|
||||||
add_extension mbstring extension >/dev/null 2>&1
|
elif [[ "$tool" =~ phpc(bf|s) ]]; then
|
||||||
add_extension xml extension >/dev/null 2>&1
|
extensions+=(tokenizer simplexml xmlwriter)
|
||||||
|
elif [[ "$tool" =~ phpc(bf|s) ]]; then
|
||||||
|
extensions+=(tokenizer xmlwriter simplexml)
|
||||||
|
elif [ "$tool" = "php-cs-fixer" ]; then
|
||||||
|
extensions+=(json tokenizer)
|
||||||
elif [ "$tool" = "phpDocumentor" ]; then
|
elif [ "$tool" = "phpDocumentor" ]; then
|
||||||
add_extension fileinfo extension >/dev/null 2>&1
|
extensions+=(ctype hash json fileinfo iconv mbstring simplexml xml)
|
||||||
sudo ln -s "${tool_path:?}" "${tool_path_dir:?}"/phpdocumentor 2>/dev/null || true
|
sudo ln -s "$tool_path" "$tool_path_dir"/phpdocumentor 2>/dev/null || true
|
||||||
sudo ln -s "${tool_path:?}" "${tool_path_dir:?}"/phpdoc
|
sudo ln -s "$tool_path" "$tool_path_dir"/phpdoc
|
||||||
|
elif [ "$tool" = "phpunit" ]; then
|
||||||
|
extensions+=(dom json libxml mbstring xml xmlwriter)
|
||||||
|
elif [ "$tool" = "phpunit-bridge" ]; then
|
||||||
|
extensions+=(dom pdo tokenizer xmlwriter xmlreader)
|
||||||
elif [[ "$tool" =~ phpunit(-polyfills)?$ ]]; then
|
elif [[ "$tool" =~ phpunit(-polyfills)?$ ]]; then
|
||||||
if [ -e "${tool_path_dir:?}"/phpunit ]; then
|
if [ -e "$tool_path_dir"/phpunit ] && [ -d "$composer_bin" ]; then
|
||||||
sudo cp "${tool_path_dir:?}"/phpunit "${composer_bin:?}"
|
sudo cp "$tool_path_dir"/phpunit "$composer_bin"
|
||||||
fi
|
fi
|
||||||
elif [[ "$tool" =~ (symfony|vapor|wp)-cli ]]; then
|
elif [ "$tool" = "vapor-cli" ]; then
|
||||||
sudo ln -s "${tool_path:?}" "${tool_path_dir:?}"/"${tool%-*}"
|
extensions+=(fileinfo json mbstring zip simplexml)
|
||||||
|
sudo ln -s "$scoped_dir"/vendor/bin/vapor "$scoped_dir"/vendor/bin/vapor-cli
|
||||||
|
elif [ "$tool" = wp-cli ]; then
|
||||||
|
sudo ln -s "$tool_path" "$tool_path_dir"/"${tool%-*}"
|
||||||
fi
|
fi
|
||||||
}
|
for extension in "${extensions[@]}"; do
|
||||||
|
add_extension "$extension" extension >/dev/null 2>&1
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to setup a remote tool.
|
||||||
|
add_tool() {
|
||||||
|
url=$1
|
||||||
|
tool=$2
|
||||||
|
ver_param=$3
|
||||||
|
tool_path="$tool_path_dir/$tool"
|
||||||
|
add_path "$tool_path_dir"
|
||||||
|
if [ -e "$tool_path" ]; then
|
||||||
|
sudo cp -aL "$tool_path" /tmp/"$tool"
|
||||||
|
fi
|
||||||
|
IFS="," read -r -a url <<<"$url"
|
||||||
|
status_code=$(get -v -e "$tool_path" "${url[@]}")
|
||||||
|
if [ "$status_code" != "200" ] && [[ "${url[0]}" =~ .*github.com.*releases.*latest.* ]]; then
|
||||||
|
url[0]="${url[0]//releases\/latest\/download/releases/download/$(get -s -n "" "$(echo "${url[0]}" | cut -d '/' -f '1-5')/releases" | grep -Eo -m 1 "([0-9]+\.[0-9]+\.[0-9]+)/$(echo "${url[0]}" | sed -e "s/.*\///")" | cut -d '/' -f 1)}"
|
||||||
|
status_code=$(get -v -e "$tool_path" "${url[0]}")
|
||||||
|
fi
|
||||||
|
if [ "$status_code" = "200" ]; then
|
||||||
|
add_tools_helper "$tool"
|
||||||
|
tool_version=$(get_tool_version "$tool" "$ver_param")
|
||||||
|
add_log "${tick:?}" "$tool" "Added $tool $tool_version"
|
||||||
|
else
|
||||||
|
if [ "$tool" = "composer" ]; then
|
||||||
|
export fail_fast=true
|
||||||
|
elif [ -e /tmp/"$tool" ]; then
|
||||||
|
sudo cp -a /tmp/"$tool" "$tool_path"
|
||||||
|
fi
|
||||||
|
add_log "$cross" "$tool" "Could not setup $tool"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to setup a tool using composer in a different scope.
|
||||||
|
add_composertool_helper() {
|
||||||
|
tool=$1
|
||||||
|
release=$2
|
||||||
|
prefix=$3
|
||||||
|
scope=$4
|
||||||
|
composer_args=$5
|
||||||
|
enable_extensions curl mbstring openssl
|
||||||
|
if [ "$scope" = "global" ]; then
|
||||||
|
sudo rm -f "$composer_lock" >/dev/null 2>&1 || true
|
||||||
|
composer global require "$prefix$release" "$composer_args" >/dev/null 2>&1
|
||||||
|
composer global show "$prefix$tool" 2>&1 | grep -E ^versions | sudo tee /tmp/composer.log >/dev/null 2>&1
|
||||||
|
else
|
||||||
|
scoped_dir="$composer_bin/_tools/$tool-$(echo -n "$release" | shasum -a 256 | cut -d ' ' -f 1)"
|
||||||
|
if ! [ -d "$scoped_dir" ]; then
|
||||||
|
mkdir -p "$scoped_dir"
|
||||||
|
composer require "$prefix$release" -d "$scoped_dir" "$composer_args" >/dev/null 2>&1
|
||||||
|
composer show "$prefix$tool" -d "$scoped_dir" 2>&1 | grep -E ^versions | sudo tee /tmp/composer.log >/dev/null 2>&1
|
||||||
|
fi
|
||||||
|
add_path "$scoped_dir"/vendor/bin
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to setup a tool using composer.
|
||||||
|
add_composertool() {
|
||||||
|
tool=$1
|
||||||
|
release=$2
|
||||||
|
prefix=$3
|
||||||
|
scope=$4
|
||||||
|
composer_major_version=$(cut -d'.' -f 1 /tmp/composer_version)
|
||||||
|
if [ "$composer_major_version" != "1" ]; then
|
||||||
|
composer_args="--ignore-platform-req=ext-*"
|
||||||
|
if [[ "$tool" =~ prestissimo|composer-prefetcher ]]; then
|
||||||
|
echo "::warning:: Skipping $tool, as it does not support Composer $composer_version. Specify composer:v1 in tools to use $tool"
|
||||||
|
add_log "$cross" "$tool" "Skipped"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
add_composertool_helper "$tool" "$release" "$prefix" "$scope" "$composer_args"
|
||||||
|
tool_version=$(get_tool_version cat /tmp/composer.log)
|
||||||
|
([ -s /tmp/composer.log ] && add_log "$tick" "$tool" "Added $tool $tool_version"
|
||||||
|
) || add_log "$cross" "$tool" "Could not setup $tool"
|
||||||
|
add_tools_helper "$tool"
|
||||||
|
if [ -e "$composer_bin/composer" ]; then
|
||||||
|
sudo cp -a "$tool_path_dir/composer" "$composer_bin"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
@ -11,11 +11,11 @@ Function Add-Grpc_php_plugin() {
|
|||||||
$msys_location = Add-Msys2
|
$msys_location = Add-Msys2
|
||||||
$logs = . $msys_location\usr\bin\bash -l -c "pacman -S --noconfirm mingw-w64-x86_64-grpc" >$null 2>&1
|
$logs = . $msys_location\usr\bin\bash -l -c "pacman -S --noconfirm mingw-w64-x86_64-grpc" >$null 2>&1
|
||||||
$grpc_version = Get-ToolVersion 'Write-Output' "$logs"
|
$grpc_version = Get-ToolVersion 'Write-Output' "$logs"
|
||||||
Write-Output "$msys_location\mingw64\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8
|
Add-Path $msys_location\mingw64\bin
|
||||||
Write-Output "::set-output name=grpc_php_plugin_path::$msys_location\mingw64\bin\grpc_php_plugin.exe"
|
Set-Output 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-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 grpc_php_plugin $grpc_version"
|
Add-Log $tick "grpc_php_plugin" "Added grpc_php_plugin $grpc_version"
|
||||||
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"
|
printf "$env: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 (Invoke-WebRequest https://raw.githubusercontent.com/grpc/grpc/master/LICENSE).Content
|
||||||
Write-Output "::endgroup::"
|
Write-Output "$env:END_GROUP"
|
||||||
}
|
}
|
||||||
|
@ -50,9 +50,9 @@ add_grpc_php_plugin() {
|
|||||||
else
|
else
|
||||||
add_grpc_php_plugin_compile >/dev/null 2>&1
|
add_grpc_php_plugin_compile >/dev/null 2>&1
|
||||||
fi
|
fi
|
||||||
echo "::set-output name=grpc_php_plugin_path::$(command -v grpc_php_plugin)"
|
set_output grpc_php_plugin_path "$(command -v grpc_php_plugin)"
|
||||||
add_log "${tick:?}" "grpc_php_plugin" "Added grpc_php_plugin ${grpc_tag:1}"
|
add_log "${tick:?}" "grpc_php_plugin" "Added grpc_php_plugin ${grpc_tag:1}"
|
||||||
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"
|
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 "$license_path"
|
cat "$license_path"
|
||||||
echo "::endgroup::"
|
echo "$END_GROUP"
|
||||||
}
|
}
|
||||||
|
@ -54,14 +54,17 @@ update_lists_helper() {
|
|||||||
update_lists() {
|
update_lists() {
|
||||||
local ppa=${1:-}
|
local ppa=${1:-}
|
||||||
local ppa_search=${2:-}
|
local ppa_search=${2:-}
|
||||||
if [ ! -e /tmp/setup_php ] || [[ -n $ppa && -n $ppa_search ]]; then
|
local list=
|
||||||
if [[ -n "$ppa" && -n "$ppa_search" ]]; then
|
status_file=/tmp/os_lists
|
||||||
list="$list_dir"/"$(basename "$(grep -lr "$ppa_search" "$list_dir")")"
|
if [[ -n "$ppa" && -n "$ppa_search" ]]; then
|
||||||
elif grep -Eq '^deb ' "$list_file"; then
|
list="$list_dir"/"$(basename "$(grep -lr "$ppa_search" "$list_dir")")"
|
||||||
list="$list_file"
|
status_file=/tmp/"${ppa/\//_}"
|
||||||
fi
|
elif grep -Eq '^deb ' "$list_file"; then
|
||||||
|
list="$list_file"
|
||||||
|
fi
|
||||||
|
if [ ! -e "$status_file" ]; then
|
||||||
update_lists_helper "$list" >/dev/null 2>&1
|
update_lists_helper "$list" >/dev/null 2>&1
|
||||||
echo '' | tee /tmp/setup_php >/dev/null 2>&1
|
echo '' | tee "$status_file" >/dev/null 2>&1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -156,9 +159,9 @@ add_ppa() {
|
|||||||
else
|
else
|
||||||
add_list "$ppa"
|
add_list "$ppa"
|
||||||
fi
|
fi
|
||||||
status="$?"
|
exit_code="$?"
|
||||||
. /etc/os-release
|
. /etc/os-release
|
||||||
return $status
|
return $exit_code
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to update a PPA.
|
# Function to update a PPA.
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
Function Get-ProtobufTag() {
|
Function Get-ProtobufTag() {
|
||||||
if("$protobuf_tag" -eq "latest") {
|
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
|
$protobuf_tag = (Invoke-RestMethod https://api.github.com/repos/protocolbuffers/protobuf/releases).tag_name | Where-Object { $_ -match "v\d+.\d+.\d+$" } | Select-Object -First 1
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
[net.httpWebRequest] $request = [net.webRequest]::create("https://github.com/protocolbuffers/protobuf/releases/tag/v$protobuf_tag")
|
[net.httpWebRequest] $request = [net.webRequest]::create("https://github.com/protocolbuffers/protobuf/releases/tag/v$protobuf_tag")
|
||||||
@ -9,7 +9,7 @@ Function Get-ProtobufTag() {
|
|||||||
$response.Close()
|
$response.Close()
|
||||||
$protobuf_tag = "v$protobuf_tag"
|
$protobuf_tag = "v$protobuf_tag"
|
||||||
} catch {
|
} 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
|
$protobuf_tag = (Invoke-RestMethod https://api.github.com/repos/protocolbuffers/protobuf/releases).tag_name | Where-Object { $_ -match "v\d+.\d+.\d+$" } | Select-Object -First 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $protobuf_tag
|
return $protobuf_tag
|
||||||
@ -32,7 +32,7 @@ Function Add-Protoc() {
|
|||||||
Move-Item -Path $bin_dir\protoc\bin\protoc.exe -Destination $bin_dir\protoc.exe
|
Move-Item -Path $bin_dir\protoc\bin\protoc.exe -Destination $bin_dir\protoc.exe
|
||||||
Add-ToProfile $current_profile 'protoc' "New-Alias protoc $bin_dir\protoc.exe"
|
Add-ToProfile $current_profile 'protoc' "New-Alias protoc $bin_dir\protoc.exe"
|
||||||
Add-Log $tick "protoc" "Added protoc $($protobuf_tag -replace 'v', '')"
|
Add-Log $tick "protoc" "Added protoc $($protobuf_tag -replace 'v', '')"
|
||||||
printf "::group::\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" "protoc" "Click to read the protoc related license information"
|
printf "$env: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 (Invoke-WebRequest https://raw.githubusercontent.com/protocolbuffers/protobuf/master/LICENSE).Content
|
||||||
Write-Output "::endgroup::"
|
Write-Output "$env:END_GROUP"
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ add_protoc() {
|
|||||||
sudo chmod -R 777 /usr/local/bin/protoc /usr/local/include/google
|
sudo chmod -R 777 /usr/local/bin/protoc /usr/local/include/google
|
||||||
) >/dev/null 2>&1
|
) >/dev/null 2>&1
|
||||||
add_log "${tick:?}" "protoc" "Added protoc ${protobuf_tag:1}"
|
add_log "${tick:?}" "protoc" "Added protoc ${protobuf_tag:1}"
|
||||||
printf "::group::\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" "protoc" "Click to read the protoc related license information"
|
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
|
curl "${curl_opts[@]:?}" https://raw.githubusercontent.com/protocolbuffers/protobuf/master/LICENSE
|
||||||
echo "::endgroup::"
|
echo "$END_GROUP"
|
||||||
}
|
}
|
||||||
|
18
src/scripts/tools/symfony.ps1
Normal file
18
src/scripts/tools/symfony.ps1
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
Function Add-Symfony() {
|
||||||
|
$arch_name ='amd64'
|
||||||
|
if(-not([Environment]::Is64BitOperatingSystem) -or $version -lt '7.0') {
|
||||||
|
$arch_name = '386'
|
||||||
|
}
|
||||||
|
$url = "https://github.com/symfony-cli/symfony-cli/releases/latest/download/symfony-cli_windows_${arch_name}.zip"
|
||||||
|
Invoke-WebRequest -Uri $url -OutFile $bin_dir\symfony.zip >$null 2>&1
|
||||||
|
Expand-Archive -Path $bin_dir\symfony.zip -DestinationPath $bin_dir -Force >$null 2>&1
|
||||||
|
if(Test-Path $bin_dir\symfony.exe) {
|
||||||
|
Copy-Item -Path $bin_dir\symfony.exe -Destination $bin_dir\symfony-cli.exe > $null 2>&1
|
||||||
|
Add-ToProfile $current_profile 'symfony' "New-Alias symfony $bin_dir\symfony.exe"
|
||||||
|
Add-ToProfile $current_profile 'symfony_cli' "New-Alias symfony-cli $bin_dir\symfony-cli.exe"
|
||||||
|
$tool_version = Get-ToolVersion symfony "-V"
|
||||||
|
Add-Log $tick "symfony-cli" "Added symfony-cli $tool_version"
|
||||||
|
} else {
|
||||||
|
Add-Log $cross "symfony-cli" "Could not setup symfony-cli"
|
||||||
|
}
|
||||||
|
}
|
18
src/scripts/tools/symfony.sh
Normal file
18
src/scripts/tools/symfony.sh
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
add_symfony() {
|
||||||
|
if [ "$(uname -s)" = "Linux" ]; then
|
||||||
|
echo 'deb [trusted=yes] https://repo.symfony.com/apt/ /' | sudo tee /etc/apt/sources.list.d/symfony-cli.list >/dev/null 2>&1
|
||||||
|
update_lists symfony repo.symfony.com
|
||||||
|
install_packages symfony-cli
|
||||||
|
elif [ "$(uname -s)" = "Darwin" ]; then
|
||||||
|
add_brew_tap symfony-cli/homebrew-tap
|
||||||
|
brew install symfony-cli/tap/symfony-cli >/dev/null 2>&1
|
||||||
|
fi
|
||||||
|
symfony_path="$(command -v symfony)"
|
||||||
|
if [[ -n "$symfony_path" ]]; then
|
||||||
|
sudo ln -s "$symfony_path" "${tool_path_dir:?}"/symfony-cli
|
||||||
|
tool_version=$(get_tool_version "symfony" "-V")
|
||||||
|
add_log "${tick:?}" "symfony-cli" "Added symfony-cli $tool_version"
|
||||||
|
else
|
||||||
|
add_log "${cross:?}" "symfony-cli" "Could not setup symfony-cli"
|
||||||
|
fi
|
||||||
|
}
|
186
src/scripts/unix.sh
Normal file
186
src/scripts/unix.sh
Normal file
@ -0,0 +1,186 @@
|
|||||||
|
# Variables
|
||||||
|
export tick="✓"
|
||||||
|
export cross="✗"
|
||||||
|
export curl_opts=(-sL)
|
||||||
|
export old_versions="5.[3-5]"
|
||||||
|
export jit_versions="8.[0-9]"
|
||||||
|
export nightly_versions="8.[2-9]"
|
||||||
|
export xdebug3_versions="7.[2-4]|8.[0-9]"
|
||||||
|
export latest="releases/latest/download"
|
||||||
|
export github="https://github.com/shivammathur"
|
||||||
|
export jsdeliver="https://cdn.jsdelivr.net/gh/shivammathur"
|
||||||
|
export setup_php="https://setup-php.com"
|
||||||
|
|
||||||
|
if [ -n "${GITHUB_ACTIONS}" ]; then
|
||||||
|
export GROUP='::group::'
|
||||||
|
export END_GROUP='::endgroup::'
|
||||||
|
else
|
||||||
|
export GROUP=''
|
||||||
|
export END_GROUP=''
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Function to log start of a operation.
|
||||||
|
step_log() {
|
||||||
|
local message=$1
|
||||||
|
printf "\n\033[90;1m==> \033[0m\033[37;1m%s\033[0m\n" "$message"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to log result of a operation.
|
||||||
|
add_log() {
|
||||||
|
local mark=$1
|
||||||
|
local subject=$2
|
||||||
|
local message=$3
|
||||||
|
if [ "$mark" = "$tick" ]; then
|
||||||
|
printf "\033[32;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s\033[0m\n" "$mark" "$subject" "$message"
|
||||||
|
else
|
||||||
|
printf "\033[31;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s\033[0m\n" "$mark" "$subject" "$message"
|
||||||
|
[ "$fail_fast" = "true" ] && exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to set output on GitHub Actions.
|
||||||
|
set_output() {
|
||||||
|
name=$1
|
||||||
|
value=$2
|
||||||
|
if [ "${GITHUB_ACTIONS}" = "true" ]; then
|
||||||
|
echo "::set-output name=${name}::${value}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to read env inputs.
|
||||||
|
read_env() {
|
||||||
|
update="${update:-${UPDATE:-false}}"
|
||||||
|
fail_fast="${fail_fast:-${FAIL_FAST:-false}}"
|
||||||
|
[[ -z "${ImageOS}" && -z "${ImageVersion}" ]] && _runner=self-hosted || _runner=github
|
||||||
|
runner="${runner:-${RUNNER:-$_runner}}"
|
||||||
|
|
||||||
|
if [[ "$runner" = "github" && $_runner = "self-hosted" ]]; then
|
||||||
|
fail_fast=true
|
||||||
|
add_log "$cross" "Runner" "Runner set as github in self-hosted environment"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to download a file using cURL.
|
||||||
|
# mode: -s pipe to stdout, -v save file and return status code
|
||||||
|
# execute: -e save file as executable
|
||||||
|
get() {
|
||||||
|
mode=$1
|
||||||
|
execute=$2
|
||||||
|
file_path=$3
|
||||||
|
shift 3
|
||||||
|
links=("$@")
|
||||||
|
if [ "$mode" = "-s" ]; then
|
||||||
|
sudo curl "${curl_opts[@]}" "${links[0]}"
|
||||||
|
else
|
||||||
|
for link in "${links[@]}"; do
|
||||||
|
status_code=$(sudo curl -w "%{http_code}" -o "$file_path" "${curl_opts[@]}" "$link")
|
||||||
|
[ "$status_code" = "200" ] && break
|
||||||
|
done
|
||||||
|
[ "$execute" = "-e" ] && sudo chmod a+x "$file_path"
|
||||||
|
[ "$mode" = "-v" ] && echo "$status_code"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to get shell profile.
|
||||||
|
get_shell_profile() {
|
||||||
|
case "$SHELL" in
|
||||||
|
*bash*)
|
||||||
|
echo "${HOME}/.bashrc"
|
||||||
|
;;
|
||||||
|
*zsh*)
|
||||||
|
echo "${HOME}/.zshrc"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "${HOME}/.profile"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to add a path to the PATH variable.
|
||||||
|
add_path() {
|
||||||
|
path_to_add=$1
|
||||||
|
[[ ":$PATH:" == *":$path_to_add:"* ]] && return
|
||||||
|
if [[ -n "$GITHUB_PATH" ]]; then
|
||||||
|
echo "$path_to_add" | tee -a "$GITHUB_PATH" >/dev/null 2>&1
|
||||||
|
else
|
||||||
|
profile=$(get_shell_profile)
|
||||||
|
([ -e "$profile" ] && grep -q ":$path_to_add\"" "$profile" 2>/dev/null) || echo "export PATH=\"\${PATH:+\${PATH}:}\"$path_to_add" | sudo tee -a "$profile" >/dev/null 2>&1
|
||||||
|
fi
|
||||||
|
export PATH="${PATH:+${PATH}:}$path_to_add"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to add environment variables using a PATH.
|
||||||
|
add_env_path() {
|
||||||
|
env_path=$1
|
||||||
|
[ -e "$env_path" ] || return
|
||||||
|
if [[ -n "$GITHUB_ENV" ]]; then
|
||||||
|
cat "$env_path" >> "$GITHUB_ENV"
|
||||||
|
else
|
||||||
|
profile=$(get_shell_profile)
|
||||||
|
cat "$env_path" >> "$profile"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to add an environment variable.
|
||||||
|
add_env() {
|
||||||
|
env_name=$1
|
||||||
|
env_value=$2
|
||||||
|
if [[ -n "$GITHUB_ENV" ]]; then
|
||||||
|
echo "$env_name=$env_value" | tee -a "$GITHUB_ENV" >/dev/null 2>&1
|
||||||
|
else
|
||||||
|
profile=$(get_shell_profile)
|
||||||
|
echo "export $env_name=\"$env_value\"" | sudo tee -a "$profile" >/dev/null 2>&1
|
||||||
|
fi
|
||||||
|
export "$env_name"="$env_value"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to download and run scripts from GitHub releases with jsdeliver fallback.
|
||||||
|
run_script() {
|
||||||
|
repo=$1
|
||||||
|
shift
|
||||||
|
args=("$@")
|
||||||
|
get -q -e /tmp/install.sh "$github/$repo/$latest/install.sh" "$jsdeliver/$repo@main/scripts/install.sh" "$setup_php/$repo/install.sh"
|
||||||
|
bash /tmp/install.sh "${args[@]}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to install required packages on self-hosted runners.
|
||||||
|
self_hosted_setup() {
|
||||||
|
if [ "$runner" = "self-hosted" ]; then
|
||||||
|
if [[ "${version:?}" =~ $old_versions ]]; then
|
||||||
|
add_log "$cross" "PHP" "PHP $version is not supported on self-hosted runner"
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
self_hosted_helper >/dev/null 2>&1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to configure PHP
|
||||||
|
configure_php() {
|
||||||
|
add_php_config
|
||||||
|
ini_config_dir="${src:?}"/configs/ini
|
||||||
|
ini_files=("$ini_config_dir"/php.ini)
|
||||||
|
[[ "$version" =~ $jit_versions ]] && ini_files+=("$ini_config_dir"/jit.ini)
|
||||||
|
[[ "$version" =~ $xdebug3_versions ]] && ini_files+=("$ini_config_dir"/xdebug.ini)
|
||||||
|
cat "${ini_files[@]}" | sudo tee -a "${pecl_file:-${ini_file[@]}}" >/dev/null 2>&1
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to get PHP version in semver format.
|
||||||
|
php_semver() {
|
||||||
|
grep -Eo 'version="[0-9]+(\.[0-9]+){2}((-?[a-zA-Z]+([0-9]+)?)?){2}' "${php_config:?}" | cut -d '"' -f 2
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to get ini_path.
|
||||||
|
php_ini_path() {
|
||||||
|
cut -d '"' -f 2 < <(grep "ini_path=" "$php_config" || php --ini | grep '(php.ini)' | sed -e "s|.*: s*||")
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to get the tag for a php version.
|
||||||
|
php_src_tag() {
|
||||||
|
commit=$(php_extra_version | grep -Eo "[0-9a-zA-Z]+")
|
||||||
|
if [[ -n "${commit}" ]]; then
|
||||||
|
echo "$commit"
|
||||||
|
else
|
||||||
|
echo "php-${semver:?}"
|
||||||
|
fi
|
||||||
|
}
|
@ -8,7 +8,7 @@ param (
|
|||||||
[ValidateNotNull()]
|
[ValidateNotNull()]
|
||||||
[ValidateLength(1, [int]::MaxValue)]
|
[ValidateLength(1, [int]::MaxValue)]
|
||||||
[string]
|
[string]
|
||||||
$dist
|
$ini = 'production'
|
||||||
)
|
)
|
||||||
|
|
||||||
# Function to log start of a operation.
|
# Function to log start of a operation.
|
||||||
@ -28,6 +28,25 @@ Function Add-Log($mark, $subject, $message) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Function to set output on GitHub Actions.
|
||||||
|
Function Set-Output() {
|
||||||
|
param(
|
||||||
|
[Parameter(Position = 0, Mandatory = $true)]
|
||||||
|
[ValidateNotNull()]
|
||||||
|
[ValidateLength(1, [int]::MaxValue)]
|
||||||
|
[string]
|
||||||
|
$output,
|
||||||
|
[Parameter(Position = 1, Mandatory = $true)]
|
||||||
|
[ValidateNotNull()]
|
||||||
|
[ValidateLength(1, [int]::MaxValue)]
|
||||||
|
[string]
|
||||||
|
$value
|
||||||
|
)
|
||||||
|
if ($env:GITHUB_ACTIONS -eq 'true') {
|
||||||
|
Write-Output "::set-output name=$output::$value"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
# Function to add a line to a powershell profile safely.
|
# Function to add a line to a powershell profile safely.
|
||||||
Function Add-ToProfile {
|
Function Add-ToProfile {
|
||||||
param(
|
param(
|
||||||
@ -64,10 +83,48 @@ Function Add-Path {
|
|||||||
param(
|
param(
|
||||||
[string]$PathItem
|
[string]$PathItem
|
||||||
)
|
)
|
||||||
$newPath = (Get-ItemProperty -Path 'hkcu:\Environment' -Name PATH).Path.replace("$PathItem;", '')
|
if("$env:PATH;".contains("$PathItem;")) {
|
||||||
$newPath = $PathItem + ';' + $newPath
|
return
|
||||||
Set-ItemProperty -Path 'hkcu:\Environment' -Name Path -Value $newPath
|
}
|
||||||
Get-PathFromRegistry
|
if ($env:GITHUB_PATH) {
|
||||||
|
Add-Content $PathItem -Path $env:GITHUB_PATH -Encoding utf8
|
||||||
|
} else {
|
||||||
|
$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 add an environment variable.
|
||||||
|
Function Add-Env {
|
||||||
|
param(
|
||||||
|
[string]$EnvName,
|
||||||
|
[string]$EnvValue
|
||||||
|
)
|
||||||
|
if ($env:GITHUB_ENV) {
|
||||||
|
Add-Content "$EnvName=$EnvValue" -Path $env:GITHUB_ENV -Encoding utf8
|
||||||
|
} else {
|
||||||
|
Set-ItemProperty -Path 'hkcu:\Environment' -Name $EnvName -Value $EnvValue
|
||||||
|
Add-ToProfile $current_profile $EnvName "`$env:$EnvName=`"$EnvValue`""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to add environment variables using a PATH.
|
||||||
|
Function Add-EnvPATH {
|
||||||
|
param(
|
||||||
|
[string]$EnvPATH
|
||||||
|
)
|
||||||
|
if(-not(Test-Path $EnvPATH)) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
$env_file = $env:GITHUB_ENV
|
||||||
|
$env_data = Get-Content -Path $EnvPATH
|
||||||
|
if (-not($env:GITHUB_ENV)) {
|
||||||
|
$env_file = $current_profile
|
||||||
|
$env_data = $env_data | ForEach-Object { '$env:' + $_ }
|
||||||
|
}
|
||||||
|
$env_data | Add-Content -Path $env_file -Encoding utf8
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to make sure printf is in PATH.
|
# Function to make sure printf is in PATH.
|
||||||
@ -112,32 +169,10 @@ Function Install-PSPackage() {
|
|||||||
Expand-Archive -Path $zip_file -DestinationPath $bin_dir -Force
|
Expand-Archive -Path $zip_file -DestinationPath $bin_dir -Force
|
||||||
}
|
}
|
||||||
Import-Module $module_path
|
Import-Module $module_path
|
||||||
Add-ToProfile $current_profile "$package-search" "Import-Module $module_path"
|
|
||||||
|
|
||||||
if($null -eq (Get-Command $cmdlet -ErrorAction SilentlyContinue)) {
|
if($null -eq (Get-Command $cmdlet -ErrorAction SilentlyContinue)) {
|
||||||
Install-Module -Name $cmdlet -Force
|
Install-Module -Name $package -Force
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Function to link dependencies to PHP directory.
|
|
||||||
Function Set-ExtensionPrerequisites
|
|
||||||
{
|
|
||||||
Param (
|
|
||||||
[Parameter(Position = 0, Mandatory = $true)]
|
|
||||||
[ValidateNotNull()]
|
|
||||||
[ValidateLength(1, [int]::MaxValue)]
|
|
||||||
[string]
|
|
||||||
$deps_dir
|
|
||||||
)
|
|
||||||
$deps = Get-ChildItem -Recurse -Path $deps_dir
|
|
||||||
if ($deps.Count -ne 0) {
|
|
||||||
# Symlink dependencies instead of adding the directory to PATH ...
|
|
||||||
# as other actions change the PATH thus breaking extensions.
|
|
||||||
$deps | ForEach-Object {
|
|
||||||
New-Item -Itemtype SymbolicLink -Path $php_dir -Name $_.Name -Target $_.FullName -Force > $null 2>&1
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
Remove-Item $deps_dir -Recurse -Force
|
Add-ToProfile $current_profile "$package-search" "Import-Module $module_path"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -151,324 +186,56 @@ Function Add-PhpCAInfo {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to add PHP extensions.
|
# Function to set OpenSSL config.
|
||||||
Function Add-Extension {
|
Function Add-OpenSSLConf {
|
||||||
Param (
|
|
||||||
[Parameter(Position = 0, Mandatory = $true)]
|
|
||||||
[ValidateNotNull()]
|
|
||||||
[ValidateLength(1, [int]::MaxValue)]
|
|
||||||
[string]
|
|
||||||
$extension,
|
|
||||||
[Parameter(Position = 1, Mandatory = $false)]
|
|
||||||
[ValidateNotNull()]
|
|
||||||
[ValidateSet('stable', 'beta', 'alpha', 'devel', 'snapshot')]
|
|
||||||
[string]
|
|
||||||
$stability = 'stable',
|
|
||||||
[Parameter(Position = 2, Mandatory = $false)]
|
|
||||||
[ValidateNotNull()]
|
|
||||||
[ValidatePattern('^\d+(\.\d+){0,2}$')]
|
|
||||||
[string]
|
|
||||||
$extension_version = ''
|
|
||||||
)
|
|
||||||
try {
|
try {
|
||||||
$extension_info = Get-PhpExtension -Path $php_dir | Where-Object { $_.Name -eq $extension -or $_.Handle -eq $extension }
|
Set-OpenSSLConf -Target User
|
||||||
$deps_dir = "$ext_dir\$extension-vc$($installed.VCVersion)-$arch"
|
|
||||||
New-Item $deps_dir -Type Directory -Force > $null 2>&1
|
|
||||||
if ($null -ne $extension_info) {
|
|
||||||
switch ($extension_info.State) {
|
|
||||||
'Builtin' {
|
|
||||||
Add-Log $tick $extension "Enabled"
|
|
||||||
}
|
|
||||||
'Enabled' {
|
|
||||||
Add-Log $tick $extension "Enabled"
|
|
||||||
}
|
|
||||||
default {
|
|
||||||
Enable-ExtensionDependencies $extension
|
|
||||||
Enable-PhpExtension -Extension $extension_info.Handle -Path $php_dir
|
|
||||||
Set-ExtensionPrerequisites $deps_dir
|
|
||||||
Add-Log $tick $extension "Enabled"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
# Patch till PHP 8.1 DLLs are released as stable.
|
|
||||||
$minimumStability = 'stable'
|
|
||||||
if($version -eq '8.1' -and $stability -eq 'stable') {
|
|
||||||
$minimumStability = 'snapshot'
|
|
||||||
}
|
|
||||||
|
|
||||||
$params = @{ Extension = $extension; MinimumStability = $minimumStability; MaximumStability = $stability; Path = $php_dir; AdditionalFilesPath = $deps_dir; NoDependencies = $true }
|
|
||||||
if($extension_version -ne '') {
|
|
||||||
$params["Version"] = $extension_version
|
|
||||||
}
|
|
||||||
Install-PhpExtension @params
|
|
||||||
Set-ExtensionPrerequisites $deps_dir
|
|
||||||
Add-Log $tick $extension "Installed and enabled"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch {
|
|
||||||
Add-Log $cross $extension "Could not install $extension on PHP $($installed.FullVersion)"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Function to get a map of extensions and their dependent shared extensions.
|
|
||||||
Function Get-ExtensionMap {
|
|
||||||
php -d'error_reporting=0' $dist\..\src\scripts\ext\extension_map.php
|
|
||||||
}
|
|
||||||
|
|
||||||
# Function to enable extension dependencies which are also extensions.
|
|
||||||
Function Enable-ExtensionDependencies {
|
|
||||||
Param (
|
|
||||||
[Parameter(Position = 0, Mandatory = $true)]
|
|
||||||
[ValidateNotNull()]
|
|
||||||
[ValidateLength(1, [int]::MaxValue)]
|
|
||||||
[string]
|
|
||||||
$extension
|
|
||||||
)
|
|
||||||
if (-not(Test-Path $env:TEMP\map.orig)) {
|
|
||||||
Get-ExtensionMap | Set-Content -Path $env:TEMP\map.orig
|
|
||||||
}
|
|
||||||
$entry = findstr /r "$extension`:.*" $env:TEMP\map.orig
|
|
||||||
if($entry) {
|
|
||||||
$entry.split(':')[1].trim().split(' ') | ForEach-Object {
|
|
||||||
if (-not(php -m | findstr -i $_)) {
|
|
||||||
Enable-PhpExtension -Extension $_ -Path $php_dir
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Function to disable dependent extensions.
|
|
||||||
Function Disable-DependentExtensions() {
|
|
||||||
Param (
|
|
||||||
[Parameter(Position = 0, Mandatory = $true)]
|
|
||||||
[ValidateNotNull()]
|
|
||||||
[ValidateLength(1, [int]::MaxValue)]
|
|
||||||
[string]
|
|
||||||
$extension
|
|
||||||
)
|
|
||||||
Get-ExtensionMap | Select-String -Pattern ".*:.*\s$extension(\s|$)" | ForEach-Object {
|
|
||||||
$dependent = $_.Matches[0].Value.split(':')[0];
|
|
||||||
Disable-ExtensionHelper -Extension $dependent -DisableDependents
|
|
||||||
Add-Log $tick ":$extension" "Disabled $dependent as it depends on $extension"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Helper function to disable an extension.
|
|
||||||
Function Disable-ExtensionHelper() {
|
|
||||||
Param (
|
|
||||||
[Parameter(Position = 0, Mandatory = $true)]
|
|
||||||
[ValidateNotNull()]
|
|
||||||
[ValidateLength(1, [int]::MaxValue)]
|
|
||||||
[string]
|
|
||||||
$extension,
|
|
||||||
[switch] $DisableDependents
|
|
||||||
)
|
|
||||||
if($DisableDependents) {
|
|
||||||
Disable-DependentExtensions $extension
|
|
||||||
}
|
|
||||||
Disable-PhpExtension -Extension $extension -Path $php_dir
|
|
||||||
}
|
|
||||||
|
|
||||||
# Function to disable an extension.
|
|
||||||
Function Disable-Extension() {
|
|
||||||
Param (
|
|
||||||
[Parameter(Position = 0, Mandatory = $true)]
|
|
||||||
[ValidateNotNull()]
|
|
||||||
[ValidateLength(1, [int]::MaxValue)]
|
|
||||||
[string]
|
|
||||||
$extension,
|
|
||||||
[Parameter(Position = 1, Mandatory = $false)]
|
|
||||||
[ValidateNotNull()]
|
|
||||||
[ValidateLength(1, [int]::MaxValue)]
|
|
||||||
[string]
|
|
||||||
$DisableDependents
|
|
||||||
)
|
|
||||||
if(php -m | findstr -i $extension) {
|
|
||||||
if(Test-Path $ext_dir\php_$extension.dll) {
|
|
||||||
try {
|
|
||||||
$params = @{ Extension = $extension; DisableDependents = ($DisableDependents -ne 'false') }
|
|
||||||
Disable-ExtensionHelper @params
|
|
||||||
Add-Log $tick ":$extension" "Disabled"
|
|
||||||
} catch {
|
|
||||||
Add-Log $cross ":$extension" "Could not disable $extension on PHP $($installed.FullVersion)"
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Add-Log $cross ":$extension" "Could not disable $extension on PHP $($installed.FullVersion) as it not a shared extension"
|
|
||||||
}
|
|
||||||
} elseif(Test-Path $ext_dir\php_$extension.dll) {
|
|
||||||
Add-Log $tick ":$extension" "Disabled"
|
|
||||||
} else {
|
|
||||||
Add-Log $tick ":$extension" "Could not find $extension on PHP $($installed.FullVersion)"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Function to disable shared extensions.
|
|
||||||
Function Disable-AllShared() {
|
|
||||||
(Get-Content $php_dir\php.ini) | Where-Object {$_ -notmatch '^(zend_)?extension\s*='} | Set-Content $php_dir\php.ini
|
|
||||||
Add-Log $tick "none" "Disabled all shared extensions"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Function to configure composer.
|
|
||||||
Function Edit-ComposerConfig() {
|
|
||||||
Param(
|
|
||||||
[Parameter(Position = 0, Mandatory = $true)]
|
|
||||||
[ValidateNotNull()]
|
|
||||||
[ValidateLength(1, [int]::MaxValue)]
|
|
||||||
[string]
|
|
||||||
$tool_path
|
|
||||||
)
|
|
||||||
Copy-Item $tool_path -Destination "$tool_path.phar"
|
|
||||||
php -r "try {`$p=new Phar('$tool_path.phar', 0);exit(0);} catch(Exception `$e) {exit(1);}"
|
|
||||||
if ($? -eq $False) {
|
|
||||||
Add-Log "$cross" "composer" "Could not download composer"
|
|
||||||
exit 1;
|
|
||||||
}
|
|
||||||
if (-not(Test-Path $composer_json)) {
|
|
||||||
Set-Content -Path $composer_json -Value "{}"
|
|
||||||
}
|
|
||||||
composer -q config -g process-timeout 0
|
|
||||||
Write-Output $composer_bin | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8
|
|
||||||
if (Test-Path env:COMPOSER_TOKEN) {
|
|
||||||
composer -q config -g github-oauth.github.com $env:COMPOSER_TOKEN
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Function to extract tool version.
|
|
||||||
Function Get-ToolVersion() {
|
|
||||||
Param (
|
|
||||||
[Parameter(Position = 0, Mandatory = $true)]
|
|
||||||
$tool,
|
|
||||||
[Parameter(Position = 1, Mandatory = $true)]
|
|
||||||
$param
|
|
||||||
)
|
|
||||||
$alp = "[a-zA-Z0-9]"
|
|
||||||
$version_regex = "[0-9]+((\.{1}$alp+)+)(\.{0})(-$alp+){0,1}"
|
|
||||||
if($tool -eq 'composer') {
|
|
||||||
$composer_branch_alias = Select-String -Pattern "const\sBRANCH_ALIAS_VERSION" -Path $bin_dir\composer -Raw | Select-String -Pattern $version_regex | ForEach-Object { $_.matches.Value }
|
|
||||||
if ($composer_branch_alias) {
|
|
||||||
$composer_version = $composer_branch_alias + '+' + (Select-String -Pattern "const\sVERSION" -Path $bin_dir\composer -Raw | Select-String -Pattern "[a-zA-Z0-9]+" -AllMatches | ForEach-Object { $_.matches[2].Value })
|
|
||||||
} else {
|
|
||||||
$composer_version = Select-String -Pattern "const\sVERSION" -Path $bin_dir\composer -Raw | Select-String -Pattern $version_regex | ForEach-Object { $_.matches.Value }
|
|
||||||
}
|
|
||||||
Set-Variable -Name 'composer_version' -Value $composer_version -Scope Global
|
|
||||||
return "$composer_version"
|
|
||||||
}
|
|
||||||
return . $tool $param 2> $null | ForEach-Object { $_ -replace "composer $version_regex", '' } | Select-String -Pattern $version_regex | Select-Object -First 1 | ForEach-Object { $_.matches.Value }
|
|
||||||
}
|
|
||||||
|
|
||||||
# Function to add tools.
|
|
||||||
Function Add-Tool() {
|
|
||||||
Param (
|
|
||||||
[Parameter(Position = 0, Mandatory = $true)]
|
|
||||||
[ValidateNotNull()]
|
|
||||||
$url,
|
|
||||||
[Parameter(Position = 1, Mandatory = $true)]
|
|
||||||
[ValidateNotNull()]
|
|
||||||
$tool,
|
|
||||||
[Parameter(Position = 2, Mandatory = $true)]
|
|
||||||
[ValidateNotNull()]
|
|
||||||
$ver_param
|
|
||||||
)
|
|
||||||
if (Test-Path $bin_dir\$tool) {
|
|
||||||
Remove-Item $bin_dir\$tool
|
|
||||||
}
|
|
||||||
if($url.Count -gt 1) {
|
|
||||||
$url = $url[0]
|
|
||||||
}
|
|
||||||
$tool_path = "$bin_dir\$tool"
|
|
||||||
if (($url | Split-Path -Extension) -eq ".exe") {
|
|
||||||
$tool_path = "$tool_path.exe"
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
Invoke-WebRequest -Uri $url -OutFile $tool_path
|
|
||||||
} catch {
|
} catch {
|
||||||
if($url -match '.*github.com.*releases.*latest.*') {
|
New-Item $php_dir\extras\openssl.cnf -Type File -Force > $null 2>&1
|
||||||
try {
|
Set-OpenSSLConf -Path $php_dir\extras\openssl.cnf -Target User
|
||||||
$url = $url.replace("releases/latest/download", "releases/download/" + ([regex]::match((Invoke-WebRequest -Uri ($url.split('/release')[0] + "/releases")).Content, "([0-9]+\.[0-9]+\.[0-9]+)/" + ($url.Substring($url.LastIndexOf("/") + 1))).Groups[0].Value).split('/')[0])
|
|
||||||
Invoke-WebRequest -Uri $url -OutFile $tool_path
|
|
||||||
} catch { }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (((Get-ChildItem -Path $bin_dir/* | Where-Object Name -Match "^$tool(.exe|.phar)*$").Count -gt 0)) {
|
|
||||||
$bat_content = @()
|
|
||||||
$bat_content += "@ECHO off"
|
|
||||||
$bat_content += "setlocal DISABLEDELAYEDEXPANSION"
|
|
||||||
$bat_content += "SET BIN_TARGET=%~dp0/" + $tool
|
|
||||||
$bat_content += "php %BIN_TARGET% %*"
|
|
||||||
Set-Content -Path $bin_dir\$tool.bat -Value $bat_content
|
|
||||||
Add-ToolsHelper $tool
|
|
||||||
Add-ToProfile $current_profile $tool "New-Alias $tool $bin_dir\$tool.bat" >$null 2>&1
|
|
||||||
$tool_version = Get-ToolVersion $tool $ver_param
|
|
||||||
Add-Log $tick $tool "Added $tool $tool_version"
|
|
||||||
} else {
|
|
||||||
Add-Log $cross $tool "Could not add $tool"
|
|
||||||
}
|
}
|
||||||
|
Add-Env -EnvName OPENSSL_CONF -EnvValue $env:OPENSSL_CONF
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to setup a tool using composer.
|
# Function to set PHP config.
|
||||||
Function Add-Composertool() {
|
Function Add-PhpConfig {
|
||||||
Param (
|
$current = Get-Content -Path $php_dir\php.ini-current -ErrorAction SilentlyContinue
|
||||||
[Parameter(Position = 0, Mandatory = $true)]
|
if($ini -eq 'development' -or ($ini -eq 'production' -and $current -and $current -ne 'production')) {
|
||||||
[ValidateNotNull()]
|
Copy-Item -Path $php_dir\php.ini-$ini -Destination $php_dir\php.ini -Force
|
||||||
[ValidateLength(1, [int]::MaxValue)]
|
} elseif ($ini -eq 'none') {
|
||||||
[string]
|
Set-Content -Path $php_dir\php.ini -Value ''
|
||||||
$tool,
|
|
||||||
[Parameter(Position = 1, Mandatory = $true)]
|
|
||||||
[ValidateNotNull()]
|
|
||||||
[ValidateLength(1, [int]::MaxValue)]
|
|
||||||
[string]
|
|
||||||
$release,
|
|
||||||
[Parameter(Position = 2, Mandatory = $true)]
|
|
||||||
[ValidateNotNull()]
|
|
||||||
[ValidateLength(1, [int]::MaxValue)]
|
|
||||||
[string]
|
|
||||||
$prefix,
|
|
||||||
[Parameter(Position = 3, Mandatory = $true)]
|
|
||||||
[ValidateNotNull()]
|
|
||||||
[ValidateLength(1, [int]::MaxValue)]
|
|
||||||
[string]
|
|
||||||
$scope
|
|
||||||
)
|
|
||||||
if($tool -match "prestissimo|composer-prefetcher" -and $composer_version.split('.')[0] -ne "1") {
|
|
||||||
Write-Output "::warning:: Skipping $tool, as it does not support Composer $composer_version. Specify composer:v1 in tools to use $tool"
|
|
||||||
Add-Log $cross $tool "Skipped"
|
|
||||||
Return
|
|
||||||
}
|
|
||||||
if($scope -eq 'global') {
|
|
||||||
if(Test-Path $composer_lock) {
|
|
||||||
Remove-Item -Path $composer_lock -Force
|
|
||||||
}
|
|
||||||
(composer global require $prefix$release 2>&1 | Tee-Object -FilePath $env:APPDATA\Composer\composer.log) >$null 2>&1
|
|
||||||
$json = findstr $prefix$tool $env:APPDATA\Composer\composer.json
|
|
||||||
} else {
|
|
||||||
$release_stream = [System.IO.MemoryStream]::New([System.Text.Encoding]::ASCII.GetBytes($release))
|
|
||||||
$scoped_tool_dir_suffix = (Get-FileHash -InputStream $release_stream -Algorithm sha256).Hash
|
|
||||||
$scoped_tool_dir = "$composer_bin\_tools\$tool-$scoped_tool_dir_suffix"
|
|
||||||
if(-not(Test-Path $scoped_tool_dir)) {
|
|
||||||
New-Item -ItemType Directory -Force -Path $scoped_tool_dir > $null 2>&1
|
|
||||||
(composer global require $prefix$release -d $scoped_tool_dir.replace('\', '/') 2>&1 | Tee-Object -FilePath $env:APPDATA\Composer\composer.log) >$null 2>&1
|
|
||||||
Add-Content $scoped_tool_dir\vendor\bin -Path $env:GITHUB_PATH -Encoding utf8
|
|
||||||
New-Variable -Name ($tool.replace('-', '_') + '_bin') -Value $scoped_tool_dir\vendor\bin
|
|
||||||
}
|
|
||||||
$json = (Test-Path $scoped_tool_dir\composer.json) -and (findstr $prefix$tool $scoped_tool_dir\composer.json)
|
|
||||||
}
|
|
||||||
$log = findstr $prefix$tool $env:APPDATA\Composer\composer.log
|
|
||||||
if(Test-Path $composer_bin\composer) {
|
|
||||||
Copy-Item -Path "$bin_dir\composer" -Destination "$composer_bin\composer" -Force
|
|
||||||
}
|
|
||||||
Add-ToolsHelper $tool
|
|
||||||
if($json) {
|
|
||||||
$tool_version = Get-ToolVersion "Write-Output" "$log"
|
|
||||||
Add-Log $tick $tool "Added $tool $tool_version"
|
|
||||||
} else {
|
|
||||||
Add-Log $cross $tool "Could not setup $tool"
|
|
||||||
}
|
}
|
||||||
|
Set-Content -Path $php_dir\php.ini-current -Value $ini
|
||||||
|
$ini_config_dir = "$src\configs\ini"
|
||||||
|
$ini_files = @("$ini_config_dir\php.ini")
|
||||||
|
$version -match $jit_versions -and ($ini_files += ("$ini_config_dir\jit.ini")) > $null 2>&1
|
||||||
|
$version -match $xdebug3_versions -and ($ini_files += ("$ini_config_dir\xdebug.ini")) > $null 2>&1
|
||||||
|
Add-Content -Path $ini_config_dir\php.ini -Value extension_dir=$ext_dir
|
||||||
|
Get-Content -Path $ini_files | Add-Content -Path $php_dir\php.ini
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to handle request to add PECL.
|
# Function to get PHP from GitHub releases cache
|
||||||
Function Add-Pecl() {
|
Function Set-PhpCache {
|
||||||
Add-Log $tick "PECL" "Use extensions input to setup PECL extensions on windows"
|
try {
|
||||||
|
$release = Invoke-RestMethod https://api.github.com/repos/shivammathur/php-builder-windows/releases/tags/php$version
|
||||||
|
$asset = $release.assets | ForEach-Object {
|
||||||
|
if($_.name -match "php-$version.[0-9]+$env:PHPTS-Win32-.*-$arch.zip") {
|
||||||
|
return $_.name
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Invoke-WebRequest -UseBasicParsing -Uri $php_builder/releases/download/php$version/$asset -OutFile $php_dir\$asset
|
||||||
|
Set-PhpDownloadCache -Path $php_dir CurrentUser
|
||||||
|
} catch { }
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to install nightly version of PHP
|
||||||
|
Function Install-PhpNightly {
|
||||||
|
Invoke-WebRequest -UseBasicParsing -Uri $php_builder/releases/latest/download/Get-PhpNightly.ps1 -OutFile $php_dir\Get-PhpNightly.ps1 > $null 2>&1
|
||||||
|
& $php_dir\Get-PhpNightly.ps1 -Architecture $arch -ThreadSafe $ts -Path $php_dir -Version $version > $null 2>&1
|
||||||
|
if(Test-Path $php_dir\COMMIT) {
|
||||||
|
return " ($( Get-Content $php_dir\COMMIT ))"
|
||||||
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Variables
|
# Variables
|
||||||
@ -479,13 +246,11 @@ $ext_dir = "$php_dir\ext"
|
|||||||
$bin_dir = $php_dir
|
$bin_dir = $php_dir
|
||||||
$github = 'https://github.com'
|
$github = 'https://github.com'
|
||||||
$php_builder = "$github/shivammathur/php-builder-windows"
|
$php_builder = "$github/shivammathur/php-builder-windows"
|
||||||
$composer_bin = "$env:APPDATA\Composer\vendor\bin"
|
|
||||||
$composer_json = "$env:APPDATA\Composer\composer.json"
|
|
||||||
$composer_lock = "$env:APPDATA\Composer\composer.lock"
|
|
||||||
$current_profile = "$env:TEMP\setup-php.ps1"
|
$current_profile = "$env:TEMP\setup-php.ps1"
|
||||||
$ProgressPreference = 'SilentlyContinue'
|
$ProgressPreference = 'SilentlyContinue'
|
||||||
$jit_versions = '8.[0-9]'
|
$jit_versions = '8.[0-9]'
|
||||||
$nightly_versions = '8.[2-9]'
|
$nightly_versions = '8.[2-9]'
|
||||||
|
$xdebug3_versions = "7.[2-4]|8.[0-9]"
|
||||||
$enable_extensions = ('openssl', 'curl', 'mbstring')
|
$enable_extensions = ('openssl', 'curl', 'mbstring')
|
||||||
|
|
||||||
$arch = 'x64'
|
$arch = 'x64'
|
||||||
@ -495,9 +260,24 @@ if(-not([Environment]::Is64BitOperatingSystem) -or $version -lt '7.0') {
|
|||||||
|
|
||||||
$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'
|
||||||
|
} else {
|
||||||
|
$env:PHPTS = ''
|
||||||
}
|
}
|
||||||
if($env:RUNNER -eq 'self-hosted') {
|
|
||||||
|
if ( $env:GITHUB_ACTIONS -eq 'true') {
|
||||||
|
$env:GROUP = '::group::'
|
||||||
|
$env:END_GROUP = '::endgroup::'
|
||||||
|
} else {
|
||||||
|
$env:GROUP = ''
|
||||||
|
$env:END_GROUP = ''
|
||||||
|
}
|
||||||
|
|
||||||
|
if(-not($env:ImageOS) -and -not($env:ImageVersion)) {
|
||||||
|
if($env:RUNNER -eq 'github') {
|
||||||
|
Add-Log $cross "Runner" "Runner set as github in self-hosted environment"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
$bin_dir = 'C:\tools\bin'
|
$bin_dir = 'C:\tools\bin'
|
||||||
$php_dir = "$php_dir$version"
|
$php_dir = "$php_dir$version"
|
||||||
$ext_dir = "$php_dir\ext"
|
$ext_dir = "$php_dir\ext"
|
||||||
@ -509,7 +289,7 @@ if($env:RUNNER -eq 'self-hosted') {
|
|||||||
Start-Sleep 1
|
Start-Sleep 1
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
if ((Get-InstalledModule).Name -notcontains 'VcRedist') {
|
if ($null -eq (Get-Module -ListAvailable -Name VcRedist)) {
|
||||||
Install-Module -Name VcRedist -Force
|
Install-Module -Name VcRedist -Force
|
||||||
}
|
}
|
||||||
New-Item $php_dir -Type Directory -Force > $null 2>&1
|
New-Item $php_dir -Type Directory -Force > $null 2>&1
|
||||||
@ -522,7 +302,9 @@ if($env:RUNNER -eq 'self-hosted') {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
. $dist\..\src\scripts\tools\add_tools.ps1
|
$src = Join-Path -Path $PSScriptRoot -ChildPath \..
|
||||||
|
. $src\scripts\tools\add_tools.ps1
|
||||||
|
. $src\scripts\extensions\add_extensions.ps1
|
||||||
|
|
||||||
Add-Printf >$null 2>&1
|
Add-Printf >$null 2>&1
|
||||||
Step-Log "Setup PhpManager"
|
Step-Log "Setup PhpManager"
|
||||||
@ -545,31 +327,26 @@ if (Test-Path -LiteralPath $php_dir -PathType Container) {
|
|||||||
$status = "Installed"
|
$status = "Installed"
|
||||||
$extra_version = ""
|
$extra_version = ""
|
||||||
if ($null -eq $installed -or -not("$($installed.Version).".StartsWith(($version -replace '^(\d+(\.\d+)*).*', '$1.'))) -or $ts -ne $installed.ThreadSafe) {
|
if ($null -eq $installed -or -not("$($installed.Version).".StartsWith(($version -replace '^(\d+(\.\d+)*).*', '$1.'))) -or $ts -ne $installed.ThreadSafe) {
|
||||||
if ($version -lt '7.0' -and (Get-InstalledModule).Name -notcontains 'VcRedist') {
|
if ($version -lt '7.0' -and ($null -eq (Get-Module -ListAvailable -Name VcRedist))) {
|
||||||
Install-PSPackage VcRedist VcRedist-main\VcRedist\VcRedist "$github/aaronparker/VcRedist/archive/main.zip" Get-VcList >$null 2>&1
|
Install-PSPackage VcRedist VcRedist-main\VcRedist\VcRedist "$github/aaronparker/VcRedist/archive/main.zip" Get-VcList >$null 2>&1
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
if ($version -match $nightly_versions) {
|
if ($version -match $nightly_versions) {
|
||||||
Invoke-WebRequest -UseBasicParsing -Uri $php_builder/releases/latest/download/Get-PhpNightly.ps1 -OutFile $php_dir\Get-PhpNightly.ps1 > $null 2>&1
|
$extra_version = Install-PhpNightly
|
||||||
& $php_dir\Get-PhpNightly.ps1 -Architecture $arch -ThreadSafe $ts -Path $php_dir -Version $version > $null 2>&1
|
|
||||||
if(Test-Path $php_dir\COMMIT) {
|
|
||||||
$extra_version = " ($( Get-Content $php_dir\COMMIT ))"
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
Install-Php -Version $version -Architecture $arch -ThreadSafe $ts -InstallVC -Path $php_dir -TimeZone UTC -InitialPhpIni Production -Force > $null 2>&1
|
Set-PhpCache
|
||||||
|
Install-Php -Version $version -Architecture $arch -ThreadSafe $ts -InstallVC -Path $php_dir -TimeZone UTC -InitialPhpIni production -Force > $null 2>&1
|
||||||
}
|
}
|
||||||
|
Add-PhpConfig
|
||||||
} catch { }
|
} catch { }
|
||||||
} else {
|
} else {
|
||||||
Set-PhpIniKey -Key 'extension_dir' -Value $ext_dir -Path $php_dir
|
|
||||||
if($version -match $jit_versions) {
|
|
||||||
('opcache.enable=1', 'opcache.jit_buffer_size=256M', 'opcache.jit=1235') | ForEach-Object { $p=$_.split('='); Set-PhpIniKey -Key $p[0] -Value $p[1] -Path $php_dir }
|
|
||||||
}
|
|
||||||
if($env:update -eq 'true') {
|
if($env:update -eq 'true') {
|
||||||
Update-Php $php_dir >$null 2>&1
|
Update-Php $php_dir >$null 2>&1
|
||||||
$status = "Updated to"
|
$status = "Updated to"
|
||||||
} else {
|
} else {
|
||||||
$status = "Found"
|
$status = "Found"
|
||||||
}
|
}
|
||||||
|
Add-PhpConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
$installed = Get-Php -Path $php_dir
|
$installed = Get-Php -Path $php_dir
|
||||||
@ -577,15 +354,14 @@ if($installed.MajorMinorVersion -ne $version) {
|
|||||||
Add-Log $cross "PHP" "Could not setup PHP $version"
|
Add-Log $cross "PHP" "Could not setup PHP $version"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
('date.timezone=UTC', 'memory_limit=-1', 'xdebug.mode=coverage') | ForEach-Object { $p=$_.split('='); Set-PhpIniKey -Key $p[0] -Value $p[1] -Path $php_dir }
|
|
||||||
if($version -lt "5.5") {
|
if($version -lt "5.5") {
|
||||||
('libeay32.dll', 'ssleay32.dll') | ForEach-Object { Invoke-WebRequest -Uri "$php_builder/releases/download/openssl-1.0.2u/$_" -OutFile $php_dir\$_ >$null 2>&1 }
|
('libeay32.dll', 'ssleay32.dll') | ForEach-Object -Parallel { Invoke-WebRequest -Uri "$using:php_builder/releases/download/openssl-1.0.2u/$_" -OutFile $using:php_dir\$_ >$null 2>&1 }
|
||||||
} else {
|
} else {
|
||||||
$enable_extensions += ('opcache')
|
$enable_extensions += ('opcache')
|
||||||
}
|
}
|
||||||
Enable-PhpExtension -Extension $enable_extensions -Path $php_dir
|
Enable-PhpExtension -Extension $enable_extensions -Path $php_dir
|
||||||
Add-PhpCAInfo
|
Add-PhpCAInfo
|
||||||
Copy-Item -Path $dist\..\src\configs\pm\*.json -Destination $env:RUNNER_TOOL_CACHE
|
Add-OpenSSLConf
|
||||||
New-Item -ItemType Directory -Path $composer_bin -Force > $null 2>&1
|
Copy-Item -Path $src\configs\pm\*.json -Destination $env:RUNNER_TOOL_CACHE
|
||||||
Write-Output "::set-output name=php-version::$($installed.FullVersion)"
|
Set-Output php-version $($installed.FullVersion)
|
||||||
Add-Log $tick "PHP" "$status PHP $($installed.FullVersion)$extra_version"
|
Add-Log $tick "PHP" "$status PHP $($installed.FullVersion)$extra_version"
|
||||||
|
107
src/tools.ts
107
src/tools.ts
@ -1,3 +1,6 @@
|
|||||||
|
import path from 'path';
|
||||||
|
import fs from 'fs';
|
||||||
|
import * as fetch from './fetch';
|
||||||
import * as utils from './utils';
|
import * as utils from './utils';
|
||||||
|
|
||||||
type RS = Record<string, string>;
|
type RS = Record<string, string>;
|
||||||
@ -19,7 +22,7 @@ export async function getSemverVersion(data: RS): Promise<string> {
|
|||||||
const search: string = data['version_prefix'] + data['version'];
|
const search: string = data['version_prefix'] + data['version'];
|
||||||
const url = `https://api.github.com/repos/${data['repository']}/git/matching-refs/tags%2F${search}.`;
|
const url = `https://api.github.com/repos/${data['repository']}/git/matching-refs/tags%2F${search}.`;
|
||||||
const token: string = await utils.readEnv('COMPOSER_TOKEN');
|
const token: string = await utils.readEnv('COMPOSER_TOKEN');
|
||||||
const response: RS = await utils.fetch(url, token);
|
const response: RS = await fetch.fetch(url, token);
|
||||||
if (response.error || response.data === '[]') {
|
if (response.error || response.data === '[]') {
|
||||||
data['error'] = response.error ?? `No version found with prefix ${search}.`;
|
data['error'] = response.error ?? `No version found with prefix ${search}.`;
|
||||||
return data['version'];
|
return data['version'];
|
||||||
@ -40,20 +43,23 @@ export async function getLatestVersion(data: RS): Promise<string> {
|
|||||||
if (!data['version'] && data['fetch_latest'] === 'false') {
|
if (!data['version'] && data['fetch_latest'] === 'false') {
|
||||||
return 'latest';
|
return 'latest';
|
||||||
}
|
}
|
||||||
const resp: Record<string, string> = await utils.fetch(
|
const resp: Record<string, string> = await fetch.fetch(
|
||||||
`${data['github']}/${data['repository']}/releases.atom`
|
`${data['github']}/${data['repository']}/releases.atom`
|
||||||
);
|
);
|
||||||
const releases: string[] = [
|
if (resp['data']) {
|
||||||
...resp['data'].matchAll(/releases\/tag\/([a-zA-Z]*)?(\d+.\d+.\d+)"/g)
|
const releases: string[] = [
|
||||||
].map(match => match[2]);
|
...resp['data'].matchAll(/releases\/tag\/([a-zA-Z]*)?(\d+.\d+.\d+)"/g)
|
||||||
|
].map(match => match[2]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
releases
|
releases
|
||||||
.sort((a: string, b: string) =>
|
.sort((a: string, b: string) =>
|
||||||
a.localeCompare(b, undefined, {numeric: true})
|
a.localeCompare(b, undefined, {numeric: true})
|
||||||
)
|
)
|
||||||
.pop() || 'latest'
|
.pop() || 'latest'
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
return 'latest';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -180,7 +186,7 @@ export async function getPharUrl(data: RS): Promise<string> {
|
|||||||
*/
|
*/
|
||||||
export async function addArchive(data: RS): Promise<string> {
|
export async function addArchive(data: RS): Promise<string> {
|
||||||
return (
|
return (
|
||||||
(await utils.getCommand(data['os_version'], 'tool')) +
|
(await utils.getCommand(data['os'], 'tool')) +
|
||||||
(await utils.joins(data['url'], data['tool'], data['version_parameter']))
|
(await utils.joins(data['url'], data['tool'], data['version_parameter']))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -191,7 +197,7 @@ export async function addArchive(data: RS): Promise<string> {
|
|||||||
* @param data
|
* @param data
|
||||||
*/
|
*/
|
||||||
export async function addPackage(data: RS): Promise<string> {
|
export async function addPackage(data: RS): Promise<string> {
|
||||||
const command = await utils.getCommand(data['os_version'], 'composertool');
|
const command = await utils.getCommand(data['os'], 'composertool');
|
||||||
const parts: string[] = data['repository'].split('/');
|
const parts: string[] = data['repository'].split('/');
|
||||||
const args: string = await utils.joins(
|
const args: string = await utils.joins(
|
||||||
parts[1],
|
parts[1],
|
||||||
@ -270,7 +276,7 @@ export async function addDeployer(data: RS): Promise<string> {
|
|||||||
* @param data
|
* @param data
|
||||||
*/
|
*/
|
||||||
export async function addDevTools(data: RS): Promise<string> {
|
export async function addDevTools(data: RS): Promise<string> {
|
||||||
switch (data['os_version']) {
|
switch (data['os']) {
|
||||||
case 'linux':
|
case 'linux':
|
||||||
case 'darwin':
|
case 'darwin':
|
||||||
return 'add_devtools ' + data['tool'];
|
return 'add_devtools ' + data['tool'];
|
||||||
@ -283,8 +289,8 @@ export async function addDevTools(data: RS): Promise<string> {
|
|||||||
);
|
);
|
||||||
default:
|
default:
|
||||||
return await utils.log(
|
return await utils.log(
|
||||||
'Platform ' + data['os_version'] + ' is not supported',
|
'Platform ' + data['os'] + ' is not supported',
|
||||||
data['os_version'],
|
data['os'],
|
||||||
'error'
|
'error'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -296,7 +302,7 @@ export async function addDevTools(data: RS): Promise<string> {
|
|||||||
* @param data
|
* @param data
|
||||||
*/
|
*/
|
||||||
export async function addPECL(data: RS): Promise<string> {
|
export async function addPECL(data: RS): Promise<string> {
|
||||||
return await utils.getCommand(data['os_version'], 'pecl');
|
return await utils.getCommand(data['os'], 'pecl');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -307,6 +313,12 @@ export async function addPECL(data: RS): Promise<string> {
|
|||||||
export async function addPhing(data: RS): Promise<string> {
|
export async function addPhing(data: RS): Promise<string> {
|
||||||
data['url'] =
|
data['url'] =
|
||||||
data['domain'] + '/get/phing-' + data['version'] + data['extension'];
|
data['domain'] + '/get/phing-' + data['version'] + data['extension'];
|
||||||
|
if (data['version'] != 'latest') {
|
||||||
|
[data['prefix'], data['verb']] = ['releases', 'download'];
|
||||||
|
data['domain'] = data['github'];
|
||||||
|
data['extension'] = '-' + data['version'] + data['extension'];
|
||||||
|
data['url'] += ',' + (await getUrl(data));
|
||||||
|
}
|
||||||
return await addArchive(data);
|
return await addArchive(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -322,7 +334,7 @@ export async function addPhive(data: RS): Promise<string> {
|
|||||||
'$cross',
|
'$cross',
|
||||||
'phive',
|
'phive',
|
||||||
'Phive is not supported on PHP ' + data['php_version'],
|
'Phive is not supported on PHP ' + data['php_version'],
|
||||||
data['os_version']
|
data['os']
|
||||||
);
|
);
|
||||||
case /5\.6|7\.0/.test(data['php_version']):
|
case /5\.6|7\.0/.test(data['php_version']):
|
||||||
data['version'] = '0.12.1';
|
data['version'] = '0.12.1';
|
||||||
@ -352,39 +364,6 @@ export async function addPHPUnitTools(data: RS): Promise<string> {
|
|||||||
return await addArchive(data);
|
return await addArchive(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Function to add Symfony
|
|
||||||
*
|
|
||||||
* @param data
|
|
||||||
*/
|
|
||||||
export async function addSymfony(data: RS): Promise<string> {
|
|
||||||
let filename: string;
|
|
||||||
switch (data['os_version']) {
|
|
||||||
case 'linux':
|
|
||||||
case 'darwin':
|
|
||||||
filename = 'symfony_' + data['os_version'] + '_amd64';
|
|
||||||
break;
|
|
||||||
case 'win32':
|
|
||||||
filename = 'symfony_windows_amd64.exe';
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return await utils.log(
|
|
||||||
'Platform ' + data['os_version'] + ' is not supported',
|
|
||||||
data['os_version'],
|
|
||||||
'error'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
if (data['version'] === 'latest') {
|
|
||||||
data['uri'] = ['releases/latest/download', filename].join('/');
|
|
||||||
} else {
|
|
||||||
data['uri'] = ['releases/download', 'v' + data['version'], filename].join(
|
|
||||||
'/'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
data['url'] = [data['domain'], data['repository'], data['uri']].join('/');
|
|
||||||
return await addArchive(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function to add WP-CLI
|
* Function to add WP-CLI
|
||||||
*
|
*
|
||||||
@ -406,14 +385,15 @@ export async function addWPCLI(data: RS): Promise<string> {
|
|||||||
*
|
*
|
||||||
* @param release
|
* @param release
|
||||||
* @param php_version
|
* @param php_version
|
||||||
* @param os_version
|
* @param os
|
||||||
*/
|
*/
|
||||||
export async function getData(
|
export async function getData(
|
||||||
release: string,
|
release: string,
|
||||||
php_version: string,
|
php_version: string,
|
||||||
os_version: string
|
os: string
|
||||||
): Promise<RS> {
|
): Promise<RS> {
|
||||||
const json_file: string = await utils.readFile('tools.json', 'src/configs');
|
const json_file_path = path.join(__dirname, '../src/configs/tools.json');
|
||||||
|
const json_file: string = fs.readFileSync(json_file_path, 'utf8');
|
||||||
const json_objects: RSRS = JSON.parse(json_file);
|
const json_objects: RSRS = JSON.parse(json_file);
|
||||||
release = release.replace(/\s+/g, '');
|
release = release.replace(/\s+/g, '');
|
||||||
const parts: string[] = release.split(':');
|
const parts: string[] = release.split(':');
|
||||||
@ -444,7 +424,7 @@ export async function getData(
|
|||||||
data['github'] = 'https://github.com';
|
data['github'] = 'https://github.com';
|
||||||
data['domain'] ??= data['github'];
|
data['domain'] ??= data['github'];
|
||||||
data['extension'] ??= '.phar';
|
data['extension'] ??= '.phar';
|
||||||
data['os_version'] = os_version;
|
data['os'] = os;
|
||||||
data['php_version'] = php_version;
|
data['php_version'] = php_version;
|
||||||
data['prefix'] = data['github'] === data['domain'] ? 'releases' : '';
|
data['prefix'] = data['github'] === data['domain'] ? 'releases' : '';
|
||||||
data['verb'] = data['github'] === data['domain'] ? 'download' : '';
|
data['verb'] = data['github'] === data['domain'] ? 'download' : '';
|
||||||
@ -469,7 +449,6 @@ export const functionRecord: Record<string, (data: RS) => Promise<string>> = {
|
|||||||
phing: addPhing,
|
phing: addPhing,
|
||||||
phpunit: addPHPUnitTools,
|
phpunit: addPHPUnitTools,
|
||||||
phpcpd: addPHPUnitTools,
|
phpcpd: addPHPUnitTools,
|
||||||
symfony: addSymfony,
|
|
||||||
wp_cli: addWPCLI
|
wp_cli: addWPCLI
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -478,22 +457,22 @@ export const functionRecord: Record<string, (data: RS) => Promise<string>> = {
|
|||||||
*
|
*
|
||||||
* @param tools_csv
|
* @param tools_csv
|
||||||
* @param php_version
|
* @param php_version
|
||||||
* @param os_version
|
* @param os
|
||||||
*/
|
*/
|
||||||
export async function addTools(
|
export async function addTools(
|
||||||
tools_csv: string,
|
tools_csv: string,
|
||||||
php_version: string,
|
php_version: string,
|
||||||
os_version: string
|
os: string
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
let script = '\n';
|
let script = '\n';
|
||||||
if (tools_csv === 'none') {
|
if (tools_csv === 'none') {
|
||||||
return '';
|
return '';
|
||||||
} else {
|
} else {
|
||||||
script += await utils.stepLog('Setup Tools', os_version);
|
script += await utils.stepLog('Setup Tools', os);
|
||||||
}
|
}
|
||||||
const tools_list = await filterList(await utils.CSVArray(tools_csv));
|
const tools_list = await filterList(await utils.CSVArray(tools_csv));
|
||||||
await utils.asyncForEach(tools_list, async function (release: string) {
|
await utils.asyncForEach(tools_list, async function (release: string) {
|
||||||
const data: RS = await getData(release, php_version, os_version);
|
const data: RS = await getData(release, php_version, os);
|
||||||
script += '\n';
|
script += '\n';
|
||||||
switch (true) {
|
switch (true) {
|
||||||
case data['error'] !== undefined:
|
case data['error'] !== undefined:
|
||||||
@ -501,7 +480,7 @@ export async function addTools(
|
|||||||
'$cross',
|
'$cross',
|
||||||
data['tool'],
|
data['tool'],
|
||||||
data['error'],
|
data['error'],
|
||||||
data['os_version']
|
data['os']
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case 'phar' === data['type']:
|
case 'phar' === data['type']:
|
||||||
@ -516,7 +495,7 @@ export async function addTools(
|
|||||||
data['tool'].split('-')[0],
|
data['tool'].split('-')[0],
|
||||||
'tools',
|
'tools',
|
||||||
data['version'],
|
data['version'],
|
||||||
data['os_version']
|
data['os']
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case 'custom-function' === data['type']:
|
case 'custom-function' === data['type']:
|
||||||
@ -529,7 +508,7 @@ export async function addTools(
|
|||||||
'$cross',
|
'$cross',
|
||||||
data['tool'],
|
data['tool'],
|
||||||
'Tool ' + data['tool'] + ' is not supported',
|
'Tool ' + data['tool'] + ' is not supported',
|
||||||
data['os_version']
|
data['os']
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user