Compare commits

..

No commits in common. "main" and "2.21.0" have entirely different histories.
main ... 2.21.0

123 changed files with 12578 additions and 9197 deletions

16
.eslintrc.json Normal file
View File

@ -0,0 +1,16 @@
{
"env": { "node": true, "jest": true },
"parser": "@typescript-eslint/parser",
"parserOptions": { "ecmaVersion": 2021, "sourceType": "module" },
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"plugin:import/errors",
"plugin:import/warnings",
"plugin:import/typescript",
"plugin:prettier/recommended",
"prettier"
],
"plugins": ["@typescript-eslint", "jest"]
}

View File

@ -71,7 +71,6 @@ npm test
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. 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 build
npm run release npm run release
``` ```

42
.github/ISSUE_TEMPLATE/bug.md vendored Normal file
View File

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

View File

@ -1,94 +0,0 @@
name: Bug report
description: Nice, you found a bug!
title: "Bug: "
labels: ["bug"]
assignees: ["shivammathur"]
body:
- type: markdown
attributes:
value: "Please fill out the sections below to help us address your issue."
- type: textarea
id: bug-description
attributes:
label: "Describe the bug"
placeholder: "Please describe the bug concisely."
validations:
required: true
- type: checkboxes
id: version
attributes:
label: "Version"
description: "I have checked releases, and the bug exists in the latest patch version of `v1` or `v2`."
options:
- label: "v2"
- label: "v1"
validations:
required: true
- type: dropdown
id: runners
attributes:
label: "Runners"
description: "Please choose the GitHub Action runner your workflow uses."
options:
- "GitHub Hosted"
- "Self Hosted"
validations:
required: true
- type: textarea
id: operating-systems
attributes:
label: "Operating systems"
placeholder: "e.g., Ubuntu 22.04, Windows Server 2022, etc."
validations:
required: true
- type: textarea
id: php-versions
attributes:
label: "PHP versions"
placeholder: "e.g., PHP 7.4, PHP 8.0, etc."
validations:
required: true
- type: textarea
id: steps-to-reproduce
attributes:
label: "To Reproduce"
placeholder: "Please provide the relevant steps of your workflow `.yml` file."
validations:
required: true
- type: textarea
id: expected-behavior
attributes:
label: "Expected behavior"
placeholder: "A clear and concise description of what you expected to happen."
validations:
required: true
- type: textarea
id: screenshots-logs
attributes:
label: "Screenshots/Logs"
placeholder: "Drag and drop images or paste logs here..."
- type: textarea
id: additional-context
attributes:
label: "Additional context"
placeholder: "Add any other context about the problem here."
- type: dropdown
id: willing-to-submit-pr
attributes:
label: "Are you willing to submit a PR?"
description: "We accept pull requests targeting the develop branch."
options:
- "Yes"
- "No"
validations:
required: true

26
.github/ISSUE_TEMPLATE/feature.md vendored Normal file
View File

@ -0,0 +1,26 @@
---
name: Feature request
about: Suggest a new feature
title: ''
labels: 'enhancement'
assignees: 'shivammathur'
---
**Describe the feature**
<!-- Please describe concisely the feature you want to add. -->
**Version**
- [ ] I have checked releases, and the feature is missing in the latest patch version of `v2`.
**Underlying issue**
<!-- Please describe the issue this would solve. -->
**Describe alternatives**
<!-- Please mention any alternative solutions you've considered. -->
**Additional context**
<!-- Add any other context or screenshots about the feature request here. -->
**Are you willing to submit a PR?**
<!-- We accept pull requests targeting the develop branch. -->

View File

@ -1,58 +0,0 @@
name: Feature request
description: Suggest a new feature
title: "Feature: "
labels: ["enhancement"]
assignees: ["shivammathur"]
body:
- type: markdown
attributes:
value: "Please fill out the sections below to help us understand your new feature proposal."
- type: textarea
id: feature-description
attributes:
label: "Describe the feature"
placeholder: "A clear and concise description of what you want and why."
validations:
required: true
- type: checkboxes
id: version-check
attributes:
label: "Please check the latest release"
options:
- label: "I have checked releases, and the feature is missing in the latest patch version of `v2`."
required: true
- type: textarea
id: underlying-issue
attributes:
label: "Underlying issue"
placeholder: "Please describe the issue this would solve."
validations:
required: true
- type: textarea
id: alternatives
attributes:
label: "Describe alternatives"
placeholder: "Please mention any alternative solutions you've considered."
validations:
required: false
- type: textarea
id: additional-context
attributes:
label: "Additional context"
placeholder: "Drag and drop images or paste any additional information here..."
- type: dropdown
id: willing-to-submit-pr
attributes:
label: "Are you willing to submit a PR?"
description: "We accept pull requests targeting the develop branch."
options:
- "Yes"
- "No"
validations:
required: true

14
.github/SECURITY.md vendored
View File

@ -2,20 +2,24 @@
## Supported Versions ## Supported Versions
The latest patch version of `v2` release of this project is supported for security updates. The latest patch versions of `v1` and `v2` releases of this project are supported for security updates.
## Supported PHP Versions ## Supported PHP Versions
This security policy only applies to the latest patch releases of the following PHP versions. This security policy only applies to the latest patches of the following PHP versions.
| Version | Supported | | Version | Supported |
|---------|--------------------| |---------|--------------------|
| 7.4 | :white_check_mark: |
| 8.0 | :white_check_mark: |
| 8.1 | :white_check_mark: | | 8.1 | :white_check_mark: |
| 8.2 | :white_check_mark: | | 8.2 | :white_check_mark: |
| 8.3 | :white_check_mark: |
| 8.4 | :white_check_mark: |
## Reporting a Vulnerability ## Reporting a Vulnerability
If you have found any issues that might have security implications in the versions supported, please send a report privately to [contact@setup-php.com](mailto:contact@setup-php.com). If you have found any issues that might have security implications in the versions supported, please send a report privately to [contact@shivammathur.com](mailto:contact@shivammathur.com).
Do not report security reports publicly. Do not report security reports publicly.
## Tidelift
If you use this GitHub Action through a Tidelift subscription, please refer to [https://tidelift.com/security](https://tidelift.com/security).

View File

@ -8,7 +8,6 @@ permissions:
jobs: jobs:
codeql: codeql:
if: github.event.repository.fork == false
permissions: permissions:
actions: read # for github/codeql-action/init to get workflow details actions: read # for github/codeql-action/init to get workflow details
contents: read # for actions/checkout to fetch code contents: read # for actions/checkout to fetch code
@ -16,18 +15,18 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v6 uses: actions/checkout@v3
with: with:
fetch-depth: 2 fetch-depth: 2
- name: Initialize CodeQL - name: Initialize CodeQL
uses: github/codeql-action/init@v4 uses: github/codeql-action/init@v2
with: with:
config-file: ./.github/codeql/codeql-configuration.yml config-file: ./.github/codeql/codeql-configuration.yml
languages: javascript languages: javascript
- name: Autobuild - name: Autobuild
uses: github/codeql-action/autobuild@v4 uses: github/codeql-action/autobuild@v2
- name: Perform CodeQL Analysis - name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v4 uses: github/codeql-action/analyze@v2

View File

@ -8,7 +8,6 @@ permissions:
jobs: jobs:
create: create:
if: github.event.repository.fork == false
permissions: permissions:
contents: none contents: none
name: Create name: Create
@ -16,35 +15,14 @@ jobs:
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
operating-system: [ubuntu-24.04, ubuntu-22.04, windows-2022, macos-15-intel] operating-system: [ubuntu-22.04, 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', '8.3', '8.4', '8.5', '8.6'] 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 }}
tools: none - name: Create for Linux and macOS
- name: Create file with all extensions for Linux and macOS
env:
file: php${{ matrix.php-versions }}-${{ matrix.operating-system }}.md
version: ${{ matrix.php-versions }}
if: matrix.operating-system != 'windows-2022'
run: |
php -m >> "$file.all"
- name: Create file with all extensions for Windows
env:
file: php${{ matrix.php-versions }}-${{ matrix.operating-system }}.md
version: ${{ matrix.php-versions }}
if: matrix.operating-system == 'windows-2022'
run: |
php -m | Out-File -FilePath "$env:file.all" -Append
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: none
tools: none
- name: Create final file 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 }}
@ -53,20 +31,10 @@ jobs:
echo "## PHP $version" >> "$file" echo "## PHP $version" >> "$file"
printf "\n" >> "$file" printf "\n" >> "$file"
echo "\`\`\`" >> "$file" echo "\`\`\`" >> "$file"
php -m >> "$file.builtin" php -m >> "$file"
while IFS= read -r line; do
if [[ $line == [* || -z "${line// }" ]]; then
echo "$line" >> "$file"
elif grep -q "^$line" "$file.builtin"; then
echo "$line (builtin)" >> "$file"
else
echo "$line (shared)" >> "$file"
fi
done < "$file.all"
echo "\`\`\`" >> "$file" echo "\`\`\`" >> "$file"
printf "\n" >> "$file" printf "\n" >> "$file"
rm "$file.all" "$file.builtin" - name: Create for Windows
- name: Create final file 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 }}
@ -74,26 +42,14 @@ jobs:
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.builtin" -Append php -m | Out-File -FilePath "$env:file" -Append
Get-Content "$env:file.all" | ForEach-Object {
if ($_.startsWith('[') -or -not $_.trim()) {
Write-Output "$_" | Out-File -FilePath "$env:file" -Append
} elseif ($_ -in (Get-Content "$env:file.builtin")) {
Write-Output "$_ (builtin)" | Out-File -FilePath "$env:file" -Append
} else {
Write-Output "$_ (shared)" | Out-File -FilePath "$env:file" -Append
}
}
Write-Output "```````n" | Out-File -FilePath "$env:file" -Append Write-Output "```````n" | Out-File -FilePath "$env:file" -Append
Remove-Item "$env:file.all" -Force
Remove-Item "$env:file.builtin" -Force
- name: Upload artifacts - name: Upload artifacts
uses: actions/upload-artifact@v7 uses: actions/upload-artifact@v3
with: with:
name: lists-php${{ matrix.php-versions }}-${{ matrix.operating-system }}.md name: lists
path: php${{ matrix.php-versions }}-${{ matrix.operating-system }}.md path: php${{ matrix.php-versions }}-${{ matrix.operating-system }}.md
update: update:
if: github.event.repository.fork == false
permissions: permissions:
contents: write # for Git to git push contents: write # for Git to git push
name: Update name: Update
@ -101,27 +57,25 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v6 uses: actions/checkout@v3
with: with:
repository: ${{ github.repository }}.wiki repository: ${{ github.repository }}.wiki
- name: Download artifacts - name: Download artifacts
uses: actions/download-artifact@v8 uses: actions/download-artifact@v3
with: with:
path: ${{ github.workspace }}/lists path: ${{ github.workspace }}
pattern: lists-*
merge-multiple: true
- name: Configure Git - 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 }}"
- name: Combine - name: Combine
run: | run: |
for os in ubuntu-24.04 ubuntu-22.04 windows-2025 windows-2022 windows-2019 macos-13 macos-14 macos-15 macos-26; do for os in ubuntu-22.04 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 8.3 8.4 8.5 8.6; 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" ]]; then if [ "$os" = "macos-10.15" ]; then
cat lists/php"$version"-macos-15-intel.md >> Php-extensions-loaded-on-"$os".md cat lists/php"$version"-macos-11.md >> Php-extensions-loaded-on-"$os".md
elif [ "${os%-*}" = "windows" ]; then elif [ "$os" = "windows-2019" ]; then
cat lists/php"$version"-windows-2022.md >> Php-extensions-loaded-on-"$os".md 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

View File

@ -2,7 +2,7 @@ name: Node workflow
on: on:
pull_request: pull_request:
branches: branches:
- main - master
- develop - develop
- verbose - verbose
paths-ignore: paths-ignore:
@ -10,7 +10,7 @@ on:
- 'examples/**' - 'examples/**'
push: push:
branches: branches:
- main - master
- develop - develop
- verbose - verbose
paths-ignore: paths-ignore:
@ -29,14 +29,14 @@ jobs:
operating-system: [ubuntu-latest, windows-latest, macos-latest] operating-system: [ubuntu-latest, windows-latest, macos-latest]
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v6 uses: actions/checkout@v3
with: with:
fetch-depth: 2 fetch-depth: 2
- name: Setup Node.js 24.x - name: Setup Node.js 16.x
uses: actions/setup-node@v6 uses: actions/setup-node@v3
with: with:
node-version: 24.x node-version: 16.x
- name: Install dependencies - name: Install dependencies
run: npm install run: npm install
@ -52,9 +52,10 @@ jobs:
- name: Run npm audit - name: Run npm audit
run: npm audit run: npm audit
continue-on-error: true
- name: Send Coverage - name: Send Coverage
uses: codecov/codecov-action@v5 uses: codecov/codecov-action@v3
with: with:
token: ${{ secrets.CODECOV_TOKEN }} token: ${{ secrets.CODECOV_TOKEN }}
files: coverage/lcov.info files: coverage/lcov.info

View File

@ -3,7 +3,7 @@ on:
workflow_dispatch: workflow_dispatch:
pull_request: pull_request:
branches: branches:
- main - master
- develop - develop
- verbose - verbose
paths-ignore: paths-ignore:
@ -11,7 +11,7 @@ on:
- 'examples/**' - 'examples/**'
push: push:
branches: branches:
- main - master
- develop - develop
- verbose - verbose
paths-ignore: paths-ignore:
@ -19,8 +19,7 @@ on:
- 'examples/**' - 'examples/**'
permissions: permissions:
contents: read contents: read
env:
default-php-version: '8.2'
jobs: jobs:
run: run:
name: Run name: Run
@ -28,51 +27,41 @@ jobs:
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
operating-system: [ubuntu-24.04, ubuntu-22.04, windows-2022, macos-15-intel] operating-system: [ubuntu-22.04, 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', '8.3', '8.4', '8.5', '8.6'] 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']
include:
- operating-system: ubuntu-24.04
php-versions: ''
php-version-file: 'php-version-file'
env: env:
extensions: xml, opcache, xdebug, pcov, gd extensions: xml, opcache, xdebug, pcov, gd
key: cache-v5 key: cache-v5
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v6 uses: actions/checkout@v3
- name: Setup cache environment - name: Setup cache environment
id: cache-env id: cache-env
uses: shivammathur/cache-extensions@develop uses: shivammathur/cache-extensions@develop
with: with:
php-version: ${{ matrix.php-versions || env.default-php-version }} php-version: ${{ matrix.php-versions }}
extensions: ${{ env.extensions }} extensions: ${{ env.extensions }}
key: ${{ env.key }} key: ${{ env.key }}
- name: Cache extensions - name: Cache extensions
uses: actions/cache@v5 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 }}
restore-keys: ${{ steps.cache-env.outputs.key }} restore-keys: ${{ steps.cache-env.outputs.key }}
- name: Stage php-version-file
if: ${{ matrix.php-version-file == 'php-version-file' }}
run: |
echo ${{ env.default-php-version }} > php-version-file
- name: Setup PHP with extensions and custom config - name: Setup PHP with extensions and custom config
run: node dist/index.js run: node dist/index.js
env: env:
php-version: ${{ matrix.php-versions }} php-version: ${{ matrix.php-versions }}
php-version-file: ${{ matrix.php-version-file }}
extensions: ${{ env.extensions }} extensions: ${{ env.extensions }}
ini-values: post_max_size=256M, short_open_tag=On, date.timezone=Asia/Kolkata ini-values: post_max_size=256M, short_open_tag=On, date.timezone=Asia/Kolkata
- name: Testing PHP version - name: Testing PHP version
run: | run: |
php -v php -v
php -r "if(strpos(phpversion(), '${{ matrix.php-versions || env.default-php-version }}') === false) {throw new Exception('Wrong PHP version Installed');}" php -r "if(strpos(phpversion(), '${{ matrix.php-versions }}') === false) {throw new Exception('Wrong PHP version Installed');}"
- name: Testing Composer version - name: Testing Composer version
run: | run: |
@ -90,4 +79,4 @@ jobs:
php -r "if(ini_get('memory_limit')!='-1') {throw new Exception('memory_limit not disabled');}" php -r "if(ini_get('memory_limit')!='-1') {throw new Exception('memory_limit not disabled');}"
php -r "if(ini_get('post_max_size')!='256M') {throw new Exception('post_max_size not added');}" php -r "if(ini_get('post_max_size')!='256M') {throw new Exception('post_max_size not added');}"
php -r "if(ini_get('short_open_tag')!=1) {throw new Exception('short_open_tag not added');}" php -r "if(ini_get('short_open_tag')!=1) {throw new Exception('short_open_tag not added');}"
php -r "if(ini_get('date.timezone')!='Asia/Kolkata') {throw new Exception('date.timezone not added');}" php -r "if(ini_get('date.timezone')!='Asia/Kolkata') {throw new Exception('date.timezone not added');}"

View File

@ -19,18 +19,18 @@ jobs:
steps: steps:
- name: Checkout release - name: Checkout release
if: github.event_name != 'workflow_dispatch' if: github.event_name != 'workflow_dispatch'
uses: actions/checkout@v6 uses: actions/checkout@v3
- name: Checkout tag - name: Checkout tag
uses: actions/checkout@v6 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 }}
- name: Setup Node.js - name: Setup Node.js
uses: actions/setup-node@v6 uses: actions/setup-node@v3
with: with:
node-version: '20.x' node-version: '16.x'
registry-url: https://registry.npmjs.org registry-url: https://registry.npmjs.org
- name: Install dependencies and add lib - name: Install dependencies and add lib
@ -46,7 +46,7 @@ jobs:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Change to GitHub Packages registry - name: Change to GitHub Packages registry
uses: actions/setup-node@v6 uses: actions/setup-node@v3
with: with:
registry-url: https://npm.pkg.github.com registry-url: https://npm.pkg.github.com
scope: '@shivammathur' scope: '@shivammathur'

2
.gitignore vendored
View File

@ -3,7 +3,7 @@ node_modules/
__tests__/runner/* __tests__/runner/*
lib/ lib/
# Rest of the file pulled from https://github.com/github/gitignore/blob/main/Node.gitignore # Rest of the file pulled from https://github.com/github/gitignore/blob/master/Node.gitignore
# Logs # Logs
logs logs
*.log *.log

View File

@ -1 +0,0 @@
20

454
README.md
View File

@ -9,14 +9,17 @@
<p align="center"> <p align="center">
<a href="https://github.com/shivammathur/setup-php" title="GitHub action to setup PHP"><img alt="GitHub Actions status" src="https://github.com/shivammathur/setup-php/workflows/Main%20workflow/badge.svg"></a> <a href="https://github.com/shivammathur/setup-php" title="GitHub action to setup PHP"><img alt="GitHub Actions status" src="https://github.com/shivammathur/setup-php/workflows/Main%20workflow/badge.svg"></a>
<a href="https://codecov.io/gh/shivammathur/setup-php" title="Code coverage"><img alt="Codecov Code Coverage" src="https://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/main/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.6-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>
</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.
@ -39,7 +42,6 @@ Setup PHP with required extensions, php.ini configuration, code-coverage support
- [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)
- [Debug Build Setup](#debug-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)
@ -68,34 +70,31 @@ Both `GitHub-hosted` and `self-hosted` runners are supported by `setup-php` on t
### GitHub-Hosted Runners ### GitHub-Hosted Runners
| Virtual environment | Arch | YAML workflow label | Pre-installed PHP | | Virtual environment | YAML workflow label | Pre-installed PHP |
|---------------------|---------|------------------------------------|-------------------| |----------------------|------------------------------------|------------------------|
| Ubuntu 24.04 | x86_64 | `ubuntu-latest` or `ubuntu-24.04` | `PHP 8.3` | | Ubuntu 22.04 | `ubuntu-22.04` | `PHP 8.1` |
| Ubuntu 22.04 | x86_64 | `ubuntu-22.04` | `PHP 8.1` | | Ubuntu 20.04 | `ubuntu-latest` or `ubuntu-20.04` | `PHP 7.4` to `PHP 8.1` |
| Ubuntu 24.04 | aarch64 | `ubuntu-24.04-arm` | `PHP 8.3` | | Ubuntu 18.04 | `ubuntu-18.04` | `PHP 7.2` to `PHP 8.1` |
| Ubuntu 22.04 | aarch64 | `ubuntu-22.04-arm` | `PHP 8.1` | | Windows Server 2022 | `windows-latest` or `windows-2022` | `PHP 8.1` |
| Windows Server 2025 | x64 | `windows-2025` | `PHP 8.5` | | Windows Server 2019 | `windows-2019` | `PHP 8.1` |
| Windows Server 2022 | x64 | `windows-latest` or `windows-2022` | `PHP 8.5` | | macOS Monterey 12.x | `macos-12` | `PHP 8.1` |
| macOS Tahoe 26.x | arm64 | `macos-26` | - | | macOS Big Sur 11.x | `macos-latest` or `macos-11` | `PHP 8.1` |
| macOS Sequoia 15.x | arm64 | `macos-latest` or `macos-15` | - | | macOS Catalina 10.15 | `macos-10.15` | `PHP 8.1` |
| macOS Sonoma 14.x | arm64 | `macos-14` | - |
| macOS Tahoe 26.x | x86_64 | `macos-26-intel` | `PHP 8.5` |
| macOS Sequoia 15.x | x86_64 | `macos-15-intel` | `PHP 8.5` |
### Self-Hosted Runners ### Self-Hosted Runners
| Host OS/Virtual environment | YAML workflow label | | Host OS/Virtual environment | YAML workflow label |
|----------------------------------|----------------------------| |----------------------------------|----------------------------|
| Ubuntu 24.04 | `self-hosted` or `Linux` |
| Ubuntu 22.04 | `self-hosted` or `Linux` | | Ubuntu 22.04 | `self-hosted` or `Linux` |
| Debian 13 | `self-hosted` or `Linux` | | Ubuntu 20.04 | `self-hosted` or `Linux` |
| Debian 12 | `self-hosted` or `Linux` | | Ubuntu 18.04 | `self-hosted` or `Linux` |
| Debian 11 | `self-hosted` or `Linux` | | Debian 11 | `self-hosted` or `Linux` |
| Debian 10 | `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 Tahoe 26.x x86_64/arm64 | `self-hosted` or `macOS` | | macOS Monterey 12.x x86_64/arm64 | `self-hosted` or `macOS` |
| macOS Sequoia 15.x x86_64/arm64 | `self-hosted` or `macOS` | | macOS Big Sur 11.x x86_64/arm64 | `self-hosted` or `macOS` |
| macOS Sonoma 14.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 best effort basis. - Operating systems based on the above Ubuntu and Debian versions are also supported on best effort basis.
@ -103,11 +102,10 @@ Both `GitHub-hosted` and `self-hosted` runners are supported by `setup-php` on t
## :tada: PHP Support ## :tada: PHP Support
On all supported OS/Platforms, the following PHP versions can be set up as per the runner. On all supported OS/Platforms the following PHP versions are supported as per the runner.
- PHP 5.3 to PHP 8.6 on GitHub-hosted runners, except for macOS ARM64 runners (macos-14). - PHP 5.3 to PHP 8.2 on GitHub-hosted runners.
- PHP 5.6 to PHP 8.6 on GitHub-hosted macOS ARM64 runners (macos-14). - PHP 5.6 to PHP 8.2 on self-hosted runners.
- PHP 5.6 to PHP 8.6 on self-hosted runners.
| PHP Version | Stability | Release Support | Runner Support | | PHP Version | Stability | Release Support | Runner Support |
|-------------|-----------|-----------------------|--------------------------------| |-------------|-----------|-----------------------|--------------------------------|
@ -119,19 +117,14 @@ On all supported OS/Platforms, the following PHP versions can be set up as per t
| `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` | `End of life` | `GitHub-hosted`, `self-hosted` | | `7.4` | `Stable` | `Security fixes only` | `GitHub-hosted`, `self-hosted` |
| `8.0` | `Stable` | `End of life` | `GitHub-hosted`, `self-hosted` | | `8.0` | `Stable` | `Active` | `GitHub-hosted`, `self-hosted` |
| `8.1` | `Stable` | `End of life` | `GitHub-hosted`, `self-hosted` | | `8.1` | `Stable` | `Active` | `GitHub-hosted`, `self-hosted` |
| `8.2` | `Stable` | `Security fixes only` | `GitHub-hosted`, `self-hosted` | | `8.2` | `Nightly` | `In development` | `GitHub-hosted`, `self-hosted` |
| `8.3` | `Stable` | `Security fixes only` | `GitHub-hosted`, `self-hosted` |
| `8.4` | `Stable` | `Active` | `GitHub-hosted`, `self-hosted` |
| `8.5` | `Stable` | `Active` | `GitHub-hosted`, `self-hosted` |
| `8.6` | `Nightly` | `In development` | `GitHub-hosted`, `self-hosted` |
**Notes:**
> [!Note] - 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.6` in `php-version` input installs a nightly build of `PHP 8.6.0-dev` from the master branch of PHP. 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.
## :heavy_plus_sign: PHP Extension Support ## :heavy_plus_sign: PHP Extension Support
@ -143,8 +136,8 @@ 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.5' php-version: '8.1'
extensions: imagick, redis extensions: imagick, swoole
``` ```
- On `Windows`, extensions available on `PECL` which have the `DLL` binary can be set up. - On `Windows`, extensions available on `PECL` which have the `DLL` binary can be set up.
@ -171,7 +164,7 @@ PHP extensions can be set up using the `extensions` input. It accepts a `string`
- 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.5' php-version: '8.1'
extensions: xdebug-beta extensions: xdebug-beta
``` ```
@ -183,38 +176,38 @@ PHP extensions can be set up using the `extensions` input. It accepts a `string`
- 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.5' php-version: '8.1'
extensions: :mbstring 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.
This disables all core and third-party shared extensions and thus, can break some tools that 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. **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.5' php-version: '8.1'
extensions: none, mbstring extensions: none, mbstring
``` ```
- Extension `intl` can be set up with specific `ICU` version for `PHP 5.6` and above in `Ubuntu` workflows by suffixing `intl` with the `ICU` version. `ICU 50.2` and newer versions are supported for PHP 8.4 and lower, `ICU 57.2` and newer versions are supported for PHP 8.5 and above. Refer to [`ICU builds`](https://github.com/shivammathur/icu-intl#icu4c-builds) for the specific versions supported. - Extension `intl` can be set up with specific `ICU` version for `PHP 5.6` and above in `Ubuntu` workflows by suffixing `intl` with the `ICU` version. `ICU 50.2` and newer versions are supported. Refer to [`ICU builds`](https://github.com/shivammathur/icu-intl#icu4c-builds) for the specific versions supported.
```yaml ```yaml
- 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.5' php-version: '8.1'
extensions: intl-77.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).
- These extensions have custom support: - These extensions have custom support:
- `cubrid` and `pdo_cubrid` on `Ubuntu`. - `cubrid`, `pdo_cubrid` and `gearman` on `Ubuntu`.
- `event`, `gearman`, `geos` and `relay` on `Ubuntu` and `macOS`. - `geos` and `event` on `Ubuntu` and `macOS`.
- `blackfire`, `couchbase`, `ibm_db2`, `ioncube`, `oci8`, `pdo_firebird`, `pdo_ibm`, `pdo_oci`, `pecl_http`, `phalcon3`, `phalcon4`, `phalcon5`, and `zephir_parser` on all supported OS. - `blackfire`, `couchbase`, `ioncube`, `oci8`, `pdo_firebird`, `pdo_oci`, `pecl_http`, `phalcon3`, `phalcon4` and `phalcon5` on all supported OS.
- 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`. - 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`.
@ -222,7 +215,7 @@ This disables all core and third-party shared extensions and thus, can break som
- 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.5' php-version: '8.1'
extensions: oci8 extensions: oci8
env: env:
fail-fast: true fail-fast: true
@ -232,13 +225,13 @@ This disables all core and third-party shared extensions and thus, can break som
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.
[`backward-compatibility-check`], [`behat`], [`blackfire`], [`blackfire-player`], [`box`], [`castor`], [`churn`], [`codeception`], [`composer`], [`composer-dependency-analyser`], [`composer-normalize`], [`composer-prefetcher`], [`composer-require-checker`], [`composer-unused`], [`cs2pr`], [`deployer`], [`ecs`], [`flex`], [`grpc_php_plugin`], [`infection`], [`mago`], [`name-collision-detector`], [`parallel-lint`], [`pecl`], [`phan`], [`phing`], [`phinx`], [`phive`], [`php-config`], [`php-cs-fixer`], [`php-scoper`], [`phpcbf`], [`phpcpd`], [`phpcs`], [`phpdoc`] or [`phpDocumentor`], [`phpize`], [`phplint`], [`phpmd`], [`phpspec`], [`phpstan`], [`phpunit`], [`phpunit-bridge`], [`phpunit-polyfills`], [`pie`], [`pint`], [`prestissimo`], [`protoc`], [`psalm`], [`rector`], [`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`], [`pint`], [`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.5' php-version: '8.1'
tools: php-cs-fixer, phpunit tools: php-cs-fixer, phpunit
``` ```
@ -248,27 +241,40 @@ 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.5' php-version: '8.1'
tools: vimeo/psalm tools: vimeo/psalm
``` ```
- To set up a particular version of a tool, specify it in the form `tool:version`. - To set up a particular version of a tool, specify it in the form `tool:version`.
Version can be in the following format: Version can be in the following format:
- Semver. For example `tool:1.2.3` or `tool:1.2.3-beta1`. - Semver. For example `tool:1.2.3` or `tool:1.2.3-beta1`.
- Major version. For example `tool:1` or `tool:1.x`. - Major version. For example `tool:1` or `tool:1.x`.
- Major and minor version. For example `tool:1.2` or `tool:1.2.x`. - Major and minor version. For example `tool:1.2` or `tool:1.2.x`.
When you specify just the major version or the version in `major.minor` format, the latest patch version matching the input will be setup.
When you specify just the major version or the version in `major.minor` format, the latest patch version matching the input will be setup. Except for major versions of `composer`, For other tools when you specify only the `major` version or the version in `major.minor` format for any tool you can get rate limited by GitHub's API. To avoid this, it is recommended to provide a [`GitHub` OAuth token](https://github.com/shivammathur/setup-php#composer-github-oauth "Composer GitHub OAuth").
You can do that by setting `GITHUB_TOKEN` environment variable. The `COMPOSER_TOKEN` environment variable has been deprecated in favor of `GITHUB_TOKEN` and will be removed in the next major version.
- The latest stable version of `composer` is set up by default. You can set up the required `composer` version by specifying the major version `v1` or `v2`, or the version in `major.minor` or `semver` format. Additionally, for composer `snapshot` and `preview` can also be specified to set up the respective releases. ```yaml
- name: Setup PHP with tools
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
tools: php-cs-fixer:3.5, phpunit:9.5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
```
- The latest stable version of `composer` is set up by default. You can set up the required `composer` version by specifying the major version `v1` or `v2`, or the version in `major.minor` or `semver` format. Additionally for composer `snapshot` and `preview` can also be specified to set up the respective releases.
```yaml ```yaml
- 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.5' php-version: '8.1'
tools: composer:v1 tools: composer:v2
``` ```
- If you do not use composer in your workflow, you can specify `tools: none` to skip it. - If you do not use composer in your workflow, you can specify `tools: none` to skip it.
@ -277,7 +283,7 @@ 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.5' php-version: '8.1'
tools: none tools: none
``` ```
@ -287,44 +293,22 @@ These tools can be set up globally using the `tools` input. It accepts a string
- 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, except `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`. - 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.5' php-version: '8.1'
tools: deployer tools: deployer
env: env:
fail-fast: true fail-fast: true
``` ```
- By default, `composer` blocks all its plugins. If you are using the `tools` input to install a composer plugin it will be added to the allow list, alternatively if your dependencies have composer plugins, you can allow them by setting `COMPOSER_ALLOW_PLUGINS` that accepts a csv string of plugin names. **Notes**
- Input `tools` is useful to set up tools which are only used in CI workflows, thus keeping your `composer.json` tidy.
```yaml - 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.
- name: Setup PHP with fail-fast - 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`.
uses: shivammathur/setup-php@v2
with:
php-version: '8.5'
env:
COMPOSER_ALLOW_PLUGINS: composer/installers, composer/satis
```
> [!NOTE]
> - 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 workflow, you can run composer with `--no-dev` and install required tools using `tools` input to speed up your workflow.
> - 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`.
> - Also, `COMPOSER_NO_AUDIT` is set to `1`. So if you want to audit your dependencies for security vulnerabilities, it is recommended to add a `composer audit` step before you install them.
> - If you want to set a different `COMPOSER_PROCESS_TIMEOUT`, you can set it in your workflow file using the `env` keyword.
```yaml
- name: Setup PHP with composer and custom process timeout
uses: shivammathur/setup-php@v2
with:
php-version: '8.5'
env:
COMPOSER_PROCESS_TIMEOUT: 300
```
## :signal_strength: Coverage Support ## :signal_strength: Coverage Support
@ -337,7 +321,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.5' php-version: '8.1'
coverage: xdebug coverage: xdebug
``` ```
@ -352,26 +336,25 @@ Runs on all [PHP versions supported](#tada-php-support "List of PHP versions sup
coverage: xdebug2 coverage: xdebug2
``` ```
> [!NOTE] **Note**: Xdebug is enabled by default on Ubuntu GitHub Actions images, so if you are not using it in your workflow it is recommended to disable it as that will have a positive impact on your PHP performance. Please refer to the [disable coverage](#disable-coverage) section for details.
> Xdebug is enabled by default on Ubuntu GitHub Actions images, so if you are not using it in your workflow it is recommended to disable it as that will have a positive impact on your PHP performance. Please refer to the [disable coverage](#disable-coverage) section for details.
### PCOV ### PCOV
Specify `coverage: pcov` to use `PCOV` and disable `Xdebug`. Specify `coverage: pcov` to use `PCOV` and disable `Xdebug`.
Runs on PHP 7.1 and newer PHP versions. Runs on PHP 7.1 and newer PHP versions.
- If your source code directory is other than `src`, `lib` or, `app`, specify `pcov.directory` using the `ini-values` input. - If your source code directory is other than `src`, `lib` or, `app`, specify `pcov.directory` using the `ini-values` input.
```yaml ```yaml
- name: Setup PHP with PCOV - name: Setup PHP with PCOV
uses: shivammathur/setup-php@v2 uses: shivammathur/setup-php@v2
with: with:
php-version: '8.5' 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
``` ```
- PHPUnit 8.x and above support PCOV out of the box. - PHPUnit 8.x and above supports PCOV out of the box.
- If you are using PHPUnit 5.x, 6.x or 7.x, you need to set up `pcov/clobber` before executing your tests. - If you are using PHPUnit 5.x, 6.x or 7.x, you need to set up `pcov/clobber` before executing your tests.
```yaml ```yaml
@ -396,7 +379,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.5' php-version: '8.1'
coverage: none coverage: none
``` ```
@ -406,30 +389,14 @@ Disable coverage for these reasons:
> Specify using `with` keyword > Specify using `with` keyword
#### `php-version` (optional) #### `php-version` (required)
- Specify the PHP version you want to set up. - Specify the PHP version you want to set up.
- Accepts a `string`. For example `'8.5'`. - Accepts a `string`. For example `'8.0'`.
- Accepts `lowest` to set up the lowest supported PHP version. - Accepts `latest` to set up the latest stable PHP version.
- Accepts `highest` or `latest` to set up the latest stable PHP version.
- Accepts `nightly` to set up a nightly build from the master branch of PHP. - Accepts `nightly` to set up a nightly build from the master branch of PHP.
- Accepts `pre-installed` to set up the highest pre-installed PHP version. You can combine this with `update: true` to update the pre-installed PHP version. - Accepts the format `d.x`, where `d` is the major version. For example `5.x`, `7.x` and `8.x`.
- Accepts the format `d.x`, where `d` is the major version. For example `5.x`, `7.x` and `8.x`. - See [PHP support](#tada-php-support) for supported PHP versions.
- See [PHP support](#tada-php-support) for the supported PHP versions.
- If not specified, it looks for the following in order:
- The `php-version-file` input if it exists
- A `composer.lock` file and the `platform-overrides.php` value
- A `composer.json` file and the `config.platform.php` value
- If the `composer.lock` or `composer.json` file is in a subdirectory in your repository, please specify the subdirectory path in `COMPOSER_PROJECT_DIR` env.
#### `php-version-file` (optional)
- Specify a file with the PHP version you want to set up.
- Accepts a `string`. For example `'.phpenv-version'`.
- See [PHP support](#tada-php-support) for the supported PHP versions.
- By default, `.php-version` file is used.
- The file needs to either have the PHP version as its content or follows the asdf `.tool-versions` format.
- If not specified and the default `.php-version` file is not found, the latest stable PHP version is set up.
#### `extensions` (optional) #### `extensions` (optional)
@ -447,9 +414,9 @@ Disable coverage for these reasons:
#### `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`.
- Accepts a `string` in csv-format. For example `post_max_size=256M, max_execution_time=180`. - Accepts a `string` in csv-format. For example `post_max_size=256M, max_execution_time=180`.
- Accepts ini values with commas if wrapped in quotes. For example `xdebug.mode="develop,coverage"`. - Accepts ini values with commas if wrapped in quotes. For example `xdebug.mode="develop,coverage"`.
#### `coverage` (optional) #### `coverage` (optional)
@ -463,13 +430,6 @@ Disable coverage for these reasons:
- Accepts a `string` in csv-format. For example: `phpunit, phpcs` - Accepts a `string` in csv-format. For example: `phpunit, phpcs`
- See [tools support](#wrench-tools-support) for tools supported. - See [tools support](#wrench-tools-support) for tools supported.
#### `github-token` (optional)
- Specify the GitHub token to use for authentication.
- Accepts a `string`.
- By default, `GITHUB_TOKEN` secret provided by GitHub Actions is used.
- For GitHub Enterprise users, it is recommended to use a Personal Access Token (PAT).
### Outputs ### Outputs
#### `php-version` #### `php-version`
@ -483,7 +443,7 @@ On GitHub Actions you can assign the `setup-php` step an `id`, you can use the s
id: setup-php id: setup-php
uses: shivammathur/setup-php@v2 uses: shivammathur/setup-php@v2
with: with:
php-version: '8.5' 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 }}
@ -502,8 +462,8 @@ On GitHub Actions you can assign the `setup-php` step an `id`, you can use the s
#### `phpts` (optional) #### `phpts` (optional)
- Specify to set up a thread-safe build of PHP. - Specify to set up thread-safe version of PHP on Windows.
- Accepts `nts` for non-thread-safe and `zts` or `ts` for thread-safe. - Accepts `ts` and `nts`.
- By default, it is set to `nts`. - By default, it is set to `nts`.
- See [thread safe setup](#thread-safe-setup) for more info. - See [thread safe setup](#thread-safe-setup) for more info.
@ -525,7 +485,7 @@ steps:
- name: Setup PHP - name: Setup PHP
uses: shivammathur/setup-php@v2 uses: shivammathur/setup-php@v2
with: with:
php-version: '8.5' 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
@ -543,12 +503,12 @@ jobs:
strategy: strategy:
matrix: matrix:
operating-system: ['ubuntu-latest', 'windows-latest', 'macos-latest'] operating-system: ['ubuntu-latest', 'windows-latest', 'macos-latest']
php-versions: ['8.2', '8.3', '8.4', '8.5'] php-versions: ['7.4', '8.0', '8.1']
phpunit-versions: ['latest'] phpunit-versions: ['latest']
include: include:
- operating-system: 'ubuntu-latest' - operating-system: 'ubuntu-latest'
php-versions: '8.1' php-versions: '7.2'
phpunit-versions: 10 phpunit-versions: '8.5.21'
steps: steps:
- name: Setup PHP - name: Setup PHP
uses: shivammathur/setup-php@v2 uses: shivammathur/setup-php@v2
@ -562,61 +522,41 @@ jobs:
### Nightly Build Setup ### Nightly Build Setup
> Set up a nightly build of `PHP 8.6`. > Set up a nightly build of `PHP 8.2`.
- These PHP versions are currently in active development and might contain bugs and breaking changes. - This PHP version is currently in active development and might contain bugs and breaking changes.
- Some user space extensions might not support these versions currently. - Some user space extensions might not support this version currently.
```yaml ```yaml
steps: steps:
- name: Setup nightly PHP - name: Setup nightly PHP
uses: shivammathur/setup-php@v2 uses: shivammathur/setup-php@v2
with: with:
php-version: '8.6' php-version: '8.2'
extensions: mbstring extensions: mbstring
ini-values: post_max_size=256M, max_execution_time=180 ini-values: post_max_size=256M, max_execution_time=180
coverage: xdebug coverage: xdebug
tools: php-cs-fixer, phpunit tools: php-cs-fixer, phpunit
``` ```
### Debug Build Setup
> Set up a PHP build with debugging symbols.
- Production release builds of PHP without debugging symbols are set up by default.
- You can use the `debug` environment variable to set up a build with debugging symbols for PHP 5.6 and above.
> [!NOTE]
> - On Linux, the debug symbols are added as [debug info files](https://sourceware.org/gdb/current/onlinedocs/gdb.html/Separate-Debug-Files.html) in the `/usr/lib/debug/.build-id` directory. These files match the `build-id` in the ELF section of the PHP binaries and debugging tools like `gdb` are able to resolve the symbols from these files.
> - On Windows, the debug symbols are added as `pdb` files in the PHP installation directory.
> - On macOS, the debug symbols are compiled into the binaries.
```yaml
steps:
- name: Setup PHP with debugging symbols
uses: shivammathur/setup-php@v2
with:
php-version: '8.5'
env:
debug: true # specify true or false
```
### Thread Safe Setup ### Thread Safe Setup
> Set up `TS` or `NTS` PHP. > 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 `Windows` both `TS` and `NTS` versions are supported.
```yaml ```yaml
jobs: jobs:
run: run:
runs-on: [ubuntu-latest, windows-latest, macos-latest] runs-on: windows-latest
name: Setup PHP TS name: Setup PHP TS on Windows
steps: steps:
- name: Setup PHP - name: Setup PHP
uses: shivammathur/setup-php@v2 uses: shivammathur/setup-php@v2
with: with:
php-version: '8.5' php-version: '8.1'
env: env:
phpts: ts # specify ts or nts phpts: ts # specify ts or nts
``` ```
@ -626,14 +566,13 @@ jobs:
> Update to the latest patch of PHP versions. > Update to the latest patch of PHP versions.
- Pre-installed PHP versions are not updated to their latest patch release by default. - Pre-installed PHP versions are not updated to their latest patch release by default.
- If `ppa:ondrej/php` is missing on the Ubuntu GitHub environment, the PHP version is updated to the latest patch release.
- 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.5' php-version: '8.1'
env: env:
update: true # specify true or false update: true # specify true or false
``` ```
@ -648,35 +587,30 @@ 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.5' php-version: '8.1'
``` ```
### Multi-Arch Setup ### Multi-Arch Setup
> Set up PHP on multiple architecture on Ubuntu GitHub Runners. > Set up PHP on multiple architecture on Ubuntu GitHub Runners.
- `PHP 5.6` to `PHP 8.5` are supported by `setup-php` on multiple architecture on `Ubuntu` and `Debian`. - `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` and `PHP` installed for `setup-php`. - 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).
```yaml ```yaml
jobs: jobs:
run: run:
runs-on: ${{ matrix.os }} runs-on: ubuntu-latest
container: shivammathur/node:php-${{ matrix.php-versions }}-24.04-${{ matrix.arch }} container: shivammathur/node:latest-${{ matrix.arch }}
strategy: strategy:
matrix: matrix:
arch: ["amd64", "arm64v8"] arch: ["amd64", "i386"]
php-versions: [8.4, 8.5]
include:
- arch: "amd64"
os: "ubuntu-24.04"
- arch: "arm64v8"
os: "ubuntu-24.04-arm"
steps: steps:
- name: Install PHP - name: Install PHP
uses: shivammathur/setup-php@v2 uses: shivammathur/setup-php@v2
with: with:
php-version: ${{ matrix.php-versions }} php-version: '8.1'
``` ```
### Self Hosted Setup ### Self Hosted Setup
@ -698,7 +632,7 @@ jobs:
runs-on: self-hosted runs-on: self-hosted
strategy: strategy:
matrix: matrix:
php-versions: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5'] php-versions: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0']
name: PHP ${{ matrix.php-versions }} name: PHP ${{ matrix.php-versions }}
steps: steps:
- name: Setup PHP - name: Setup PHP
@ -709,10 +643,10 @@ jobs:
runner: self-hosted runner: self-hosted
``` ```
> [!NOTE] **Notes**
> - Do not set up multiple self-hosted runners on a single server instance as parallel workflow will conflict with each other. - Do not set up multiple self-hosted runners on a single server instance as parallel workflow will conflict with each other.
> - Do not set up self-hosted runners on the side of your development environment or your production server. - Do not set up self-hosted runners on the side on your development environment or your production server.
> - Avoid using the same labels for your `self-hosted` runners which are used by `GitHub-hosted` runners. - Avoid using the same labels for your `self-hosted` runners which are used by `GitHub-hosted` runners.
### Local Testing Setup ### Local Testing Setup
@ -726,22 +660,25 @@ jobs:
- name: Setup PHP - name: Setup PHP
uses: shivammathur/setup-php@v2 uses: shivammathur/setup-php@v2
with: with:
php-version: '8.5' 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.
Choose the image tag which matches the `runs-on` property in your workflow. For example, if you are using `ubuntu-22.04` in your workflow, run `act -P ubuntu-22.04=shivammathur/node:22.04`. Choose the image tag which matches the `runs-on` property in your workflow. For example, if you are using `ubuntu-20.04` in your workflow, run `act -P ubuntu-20.04=shivammathur/node:2004`.
```bash ```bash
# For runs-on: ubuntu-latest # For runs-on: ubuntu-latest
act -P ubuntu-latest=shivammathur/node:latest act -P ubuntu-latest=shivammathur/node:latest
# For runs-on: ubuntu-24.04
act -P ubuntu-24.04=shivammathur/node:24.04
# For runs-on: ubuntu-22.04 # For runs-on: ubuntu-22.04
act -P ubuntu-22.04=shivammathur/node:22.04 act -P ubuntu-22.04=shivammathur/node:2204
# For runs-on: ubuntu-20.04
act -P ubuntu-20.04=shivammathur/node:2004
# For runs-on: ubuntu-18.04
act -P ubuntu-18.04=shivammathur/node:1804
``` ```
### JIT Configuration ### JIT Configuration
@ -750,16 +687,16 @@ act -P ubuntu-22.04=shivammathur/node:22.04
- To enable JIT, enable `opcache` in cli mode by setting `opcache.enable_cli=1`. - To enable JIT, enable `opcache` in cli mode by setting `opcache.enable_cli=1`.
- JIT conflicts with `Xdebug`, `PCOV`, and other extensions which override `zend_execute_ex` function, so set `coverage: none` and disable any such extension if added. - JIT conflicts with `Xdebug`, `PCOV`, and other extensions which override `zend_execute_ex` function, so set `coverage: none` and disable any such extension if added.
- By default, `opcache.jit=1235` and `opcache.jit_buffer_size=256M` (`opcache.jit_buffer_size=128M` on ARM-based environments) are set which can be changed using `ini-values` input. - By default, `opcache.jit=1235` and `opcache.jit_buffer_size=256M` are set which can be changed using `ini-values` input.
- For detailed information about JIT related directives refer to the [`official PHP documentation`](https://www.php.net/manual/en/opcache.configuration.php#ini.opcache.jit "opcache.jit documentation"). - For detailed information about JIT related directives refer to the [`official PHP documentation`](https://www.php.net/manual/en/opcache.configuration.php#ini.opcache.jit "opcache.jit documentation").
For example to enable JIT in `tracing` mode with buffer size of `64 MB`. For example to enable JIT in `tracing` mode with buffer size of `64 MB`.
```yaml ```yaml
- 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.5' 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
``` ```
@ -776,10 +713,10 @@ If your project uses composer, you can persist the composer's internal cache dir
```yaml ```yaml
- name: Get composer cache directory - name: Get composer cache directory
id: composer-cache id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache dependencies - name: Cache dependencies
uses: actions/cache@v4 uses: actions/cache@v2
with: with:
path: ${{ steps.composer-cache.outputs.dir }} path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
@ -789,9 +726,9 @@ If your project uses composer, you can persist the composer's internal cache dir
run: composer install --prefer-dist run: composer install --prefer-dist
``` ```
> [!NOTE] **Notes**
> - Please do not cache `vendor` directory using `action/cache` as that will have side effects. - Please do not cache `vendor` directory using `action/cache` as that will have side effects.
> - If you do not commit `composer.lock`, you can use the hash of `composer.json` as the key for your cache. - If you do not commit `composer.lock`, you can use the hash of `composer.json` as the key for your cache.
```yaml ```yaml
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
``` ```
@ -804,20 +741,19 @@ restore-keys: ${{ runner.os }}-composer-${{ matrix.prefer }}-
### GitHub Composer Authentication ### GitHub Composer Authentication
By default, setup-php uses the `GITHUB_TOKEN` secret that is generated for each workflow run. In case you want to use a Personal Access Token (PAT) instead, you can set the `github-token` input. If you have a number of workflows which set up multiple tools or have many composer dependencies, you might hit the GitHub's rate limit for composer. Also, if you specify only the major version or the version in `major.minor` format, you can hit the rate limit. To avoid this you can specify an `OAuth` token by setting `GITHUB_TOKEN` environment variable. You can use [`GITHUB_TOKEN`](https://help.github.com/en/actions/configuring-and-managing-workflows/authenticating-with-the-github_token "GITHUB_TOKEN documentation") secret for this purpose.
The `COMPOSER_TOKEN` environment variable has been deprecated in favor of `GITHUB_TOKEN` and will be removed in the next major version.
```yaml ```yaml
- name: Setup PHP - name: Setup PHP
uses: shivammathur/setup-php@v2 uses: shivammathur/setup-php@v2
with: with:
php-version: '8.5' php-version: '8.1'
github-token: ${{ secrets.YOUR_PAT_TOKEN }} env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
``` ```
The `COMPOSER_TOKEN` and `GITHUB_TOKEN` environment variables have been deprecated in favor of the `github-token` input and will be removed in the next major version.
For GitHub Enterprise users, the `github-token` input does not default to the `GITHUB_TOKEN` secret. Therefore, it's recommended to set the `github-token` input to a Personal Access Token (PAT).
### Private Packagist Authentication ### Private Packagist Authentication
If you use Private Packagist for your private composer dependencies, you can set the `PACKAGIST_TOKEN` environment variable to authenticate. If you use Private Packagist for your private composer dependencies, you can set the `PACKAGIST_TOKEN` environment variable to authenticate.
@ -826,7 +762,7 @@ If you use Private Packagist for your private composer dependencies, you can set
- name: Setup PHP - name: Setup PHP
uses: shivammathur/setup-php@v2 uses: shivammathur/setup-php@v2
with: with:
php-version: '8.5' php-version: '8.1'
env: env:
PACKAGIST_TOKEN: ${{ secrets.PACKAGIST_TOKEN }} PACKAGIST_TOKEN: ${{ secrets.PACKAGIST_TOKEN }}
``` ```
@ -840,7 +776,7 @@ Please refer to the authentication section in [`composer documentation`](https:/
- name: Setup PHP - name: Setup PHP
uses: shivammathur/setup-php@v2 uses: shivammathur/setup-php@v2
with: with:
php-version: '8.5' php-version: '8.1'
env: env:
COMPOSER_AUTH_JSON: | COMPOSER_AUTH_JSON: |
{ {
@ -863,7 +799,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.5' php-version: '8.1'
- name: Run PHP code - name: Run PHP code
shell: php {0} shell: php {0}
@ -903,7 +839,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.5' php-version: '8.1'
tools: phpstan tools: phpstan
- name: Run PHPStan - name: Run PHPStan
@ -918,7 +854,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.5' php-version: '8.1'
tools: psalm tools: psalm
- name: Run Psalm - name: Run Psalm
@ -928,7 +864,7 @@ Psalm supports error reporting in GitHub Actions with an output format `github`.
#### Tools with checkstyle support #### Tools with checkstyle support
For tools that support `checkstyle` reporting like `phpstan`, `psalm`, `php-cs-fixer` and `phpcs` you can use `cs2pr` to annotate your code. For tools that support `checkstyle` reporting like `phpstan`, `psalm`, `php-cs-fixer` and `phpcs` you can use `cs2pr` to annotate your code.
For examples refer to the [cs2pr documentation](https://github.com/staabm/annotate-pull-request-from-checkstyle). For examples refer to [cs2pr documentation](https://github.com/staabm/annotate-pull-request-from-checkstyle).
> Here is an example with `phpcs`. > Here is an example with `phpcs`.
@ -936,7 +872,7 @@ For examples refer to the [cs2pr documentation](https://github.com/staabm/annota
- name: Setup PHP - name: Setup PHP
uses: shivammathur/setup-php@v2 uses: shivammathur/setup-php@v2
with: with:
php-version: '8.5' php-version: '8.1'
tools: cs2pr, phpcs tools: cs2pr, phpcs
- name: Run phpcs - name: Run phpcs
@ -977,15 +913,14 @@ Examples of using `setup-php` with various PHP frameworks and packages.
- 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. - 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 unless you set up tooling to update them with each release of the action. - 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.
- A new major version of the action will only be tagged when there are breaking changes in the setup-php API i.e. inputs, outputs, and environment flags.
- For debugging any issues `verbose` tag can be used temporarily. It outputs all the logs and is also synced with the latest releases. - 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 `main` 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` is not supported anymore. - 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.
## :scroll: License ## :scroll: License
- The scripts and documentation in this project are under the [MIT License](LICENSE "License for shivammathur/setup-php"). - The scripts and documentation in this project are under the [MIT License](LICENSE "License for shivammathur/setup-php").
- This project has multiple [dependencies](#package-dependencies "Dependencies for this PHP Action"). Their licenses can be found in their respective repositories. - This project has multiple [dependencies](#package-dependencies "Dependencies for this PHP Action"). Their licenses can be found in their respective repositories.
- The logo for `setup-php` is a derivative work of [php.net logo](https://www.php.net/download-logos.php) and is licensed under the [CC BY-SA 4.0 License](https://creativecommons.org/licenses/by-sa/4.0/ "Creative Commons License"). - The logo for `setup-php` is a derivative work of [php.net logo](https://www.php.net/download-logos.php) and is licensed under the [CC BY-SA 4.0 License](https://creativecommons.org/licenses/by-sa/4.0/ "Creative Commons License").
@ -1006,45 +941,38 @@ Examples of using `setup-php` with various PHP frameworks and packages.
## :sparkling_heart: Support This Project ## :sparkling_heart: Support This Project
These companies generously provide setup-php their products and services to aid in the development of this project. - 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.
<p> Many users and organisations support setup-php via [GitHub Sponsors](https://github.com/sponsors/shivammathur).
<a target="_blank" href="https://www.jetbrains.com/?from=setup-php#gh-light-mode-only">
<img src="https://setup-php.com/sponsors/jetbrains.svg" alt="JetBrains" width="140" height="100">
</a>
<a target="_blank" href="https://www.jetbrains.com/?from=setup-php#gh-dark-mode-only">
<img src="https://setup-php.com/sponsors/jetbrains-white.svg" alt="JetBrains" width="140" height="100">
</a>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<a target="_blank" href="https://www.cloudflare.com/lp/project-alexandria/#gh-light-mode-only">
<img src="https://setup-php.com/sponsors/cloudflare.svg" alt="Cloudflare" width="240" height="80">
</a>
<a target="_blank" href="https://www.cloudflare.com/lp/project-alexandria/#gh-dark-mode-only">
<img src="https://setup-php.com/sponsors/cloudflare-white.svg" alt="Cloudflare" width="240" height="80">
</a>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<a target="_blank" href="https://www.macstadium.com/company/opensource#gh-light-mode-only">
<img src="https://setup-php.com/sponsors/macstadium.png" alt="Mac Stadium" width="200" height="80">
</a>
<a target="_blank" href="https://www.macstadium.com/company/opensource#gh-dark-mode-only">
<img src="https://setup-php.com/sponsors/macstadium-white.png" alt="Mac Stadium" width="200" height="80">
</a>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<a target="_blank" href="https://m.do.co/c/f1a8ee1277b0#gh-light-mode-only">
<img src="https://setup-php.com/sponsors/digitalocean.svg" alt="Digitalocean" width="100" height="100">
</a>
<a target="_blank" href="https://m.do.co/c/f1a8ee1277b0#gh-dark-mode-only">
<img src="https://setup-php.com/sponsors/digitalocean-white.svg" alt="Digitalocean" width="100" height="100">
</a>
</p>
Many users and organizations support setup-php via [GitHub Sponsors](https://github.com/sponsors/shivammathur).
<a href="https://github.com/sponsors/shivammathur"><img src="https://setup-php.com/sponsors.svg?" alt="Sponsor shivammathur"></a> <a href="https://github.com/sponsors/shivammathur"><img src="https://setup-php.com/sponsors.svg?" alt="Sponsor shivammathur"></a>
- If you use setup-php, please consider starring the project and share it. These companies generously provide setup-php their products and services to aid in the development of this project.
- 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. <p>
<a href="https://www.jetbrains.com/?from=setup-php">
<img src="https://setup-php.com/sponsors/jetbrains.svg" alt="JetBrains" width="106" height="60">
</a>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<a href="https://www.macstadium.com/opensource/members#gh-light-mode-only">
<img src="https://setup-php.com/sponsors/macstadium.png" alt="Mac Stadium" width="148" height="60">
</a>
<a href="https://www.macstadium.com/opensource/members#gh-dark-mode-only">
<img src="https://setup-php.com/sponsors/macstadium-white.png" alt="Mac Stadium" width="148" height="60">
</a>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<a href="https://tidelift.com/subscription/pkg/npm-setup-php">
<img src="https://setup-php.com/sponsors/tidelift.png" alt="Tidelift" width="70" height="60">
</a>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<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>
## :package: Dependencies ## :package: Dependencies
@ -1071,28 +999,21 @@ Many users and organizations support setup-php via [GitHub Sponsors](https://git
<!-- Links to tools --> <!-- Links to tools -->
[`backward-compatibility-check`]: https://github.com/Roave/BackwardCompatibilityCheck
[`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
[`box`]: https://github.com/humbug/box
[`castor`]: https://github.com/jolicode/castor
[`churn`]: https://github.com/bmitch/churn-php [`churn`]: https://github.com/bmitch/churn-php
[`codeception`]: https://codeception.com/ [`codeception`]: https://codeception.com/
[`composer`]: https://getcomposer.org/ [`composer`]: https://getcomposer.org/
[`composer-dependency-analyser`]: https://github.com/shipmonk-rnd/composer-dependency-analyser
[`composer-normalize`]: https://github.com/ergebnis/composer-normalize [`composer-normalize`]: https://github.com/ergebnis/composer-normalize
[`composer-prefetcher`]: https://github.com/narrowspark/automatic-composer-prefetcher [`composer-prefetcher`]: https://github.com/narrowspark/automatic-composer-prefetcher
[`composer-require-checker`]: https://github.com/maglnet/ComposerRequireChecker [`composer-require-checker`]: https://github.com/maglnet/ComposerRequireChecker
[`composer-unused`]: https://github.com/composer-unused/composer-unused [`composer-unused`]: https://github.com/composer-unused/composer-unused
[`cs2pr`]: https://github.com/staabm/annotate-pull-request-from-checkstyle [`cs2pr`]: https://github.com/staabm/annotate-pull-request-from-checkstyle
[`deployer`]: https://deployer.org/ [`deployer`]: https://deployer.org/
[`ecs`]: https://github.com/easy-coding-standard/easy-coding-standard [`flex`]: https://flex.symfony.com/
[`flex`]: https://github.com/symfony/flex
[`grpc_php_plugin`]: https://grpc.io/ [`grpc_php_plugin`]: https://grpc.io/
[`infection`]: https://infection.github.io/ [`infection`]: https://infection.github.io/
[`mago`]: https://github.com/carthage-software/mago
[`name-collision-detector`]: https://github.com/shipmonk/name-collision-detector
[`parallel-lint`]: https://github.com/php-parallel-lint/PHP-Parallel-Lint [`parallel-lint`]: https://github.com/php-parallel-lint/PHP-Parallel-Lint
[`pecl`]: https://pecl.php.net/ [`pecl`]: https://pecl.php.net/
[`phan`]: https://github.com/phan/phan/wiki [`phan`]: https://github.com/phan/phan/wiki
@ -1101,10 +1022,9 @@ Many users and organizations support setup-php via [GitHub Sponsors](https://git
[`phive`]: https://phar.io/ [`phive`]: https://phar.io/
[`php-config`]: https://www.php.net/manual/en/install.pecl.php-config.php [`php-config`]: https://www.php.net/manual/en/install.pecl.php-config.php
[`php-cs-fixer`]: https://cs.symfony.com/ [`php-cs-fixer`]: https://cs.symfony.com/
[`php-scoper`]: https://github.com/humbug/php-scoper [`phpcbf`]: https://github.com/squizlabs/php_codesniffer
[`phpcbf`]: https://github.com/PHPCSStandards/php_codesniffer
[`phpcpd`]: https://github.com/sebastianbergmann/phpcpd [`phpcpd`]: https://github.com/sebastianbergmann/phpcpd
[`phpcs`]: https://github.com/PHPCSStandards/php_codesniffer [`phpcs`]: https://github.com/squizlabs/php_codesniffer
[`phpdoc`]: https://phpdoc.org/ [`phpdoc`]: https://phpdoc.org/
[`phpDocumentor`]: https://phpdoc.org/ [`phpDocumentor`]: https://phpdoc.org/
[`phpize`]: https://www.php.net/manual/en/install.pecl.phpize.php [`phpize`]: https://www.php.net/manual/en/install.pecl.phpize.php
@ -1115,12 +1035,10 @@ Many users and organizations support setup-php via [GitHub Sponsors](https://git
[`phpunit`]: https://phpunit.de/ [`phpunit`]: https://phpunit.de/
[`phpunit-bridge`]: https://symfony.com/doc/current/components/phpunit_bridge.html [`phpunit-bridge`]: https://symfony.com/doc/current/components/phpunit_bridge.html
[`phpunit-polyfills`]: https://github.com/Yoast/PHPUnit-Polyfills [`phpunit-polyfills`]: https://github.com/Yoast/PHPUnit-Polyfills
[`pie`]: https://github.com/php/pie
[`pint`]: https://github.com/laravel/pint [`pint`]: https://github.com/laravel/pint
[`prestissimo`]: https://github.com/hirak/prestissimo [`prestissimo`]: https://github.com/hirak/prestissimo
[`protoc`]: https://developers.google.com/protocol-buffers/ [`protoc`]: https://developers.google.com/protocol-buffers/
[`psalm`]: https://psalm.dev/ [`psalm`]: https://psalm.dev/
[`rector`]: https://getrector.org/
[`symfony`]: https://symfony.com/download [`symfony`]: https://symfony.com/download
[`symfony-cli`]: https://symfony.com/download [`symfony-cli`]: https://symfony.com/download
[`vapor`]: https://docs.vapor.build/ [`vapor`]: https://docs.vapor.build/

View File

@ -1,106 +0,0 @@
import * as core from '../src/core';
describe('Core tests', () => {
const originalEnv = process.env;
const originalExitCode = process.exitCode;
let stdoutOutput: string;
const originalWrite = process.stdout.write;
beforeEach(() => {
process.env = {...originalEnv};
process.exitCode = undefined;
stdoutOutput = '';
process.stdout.write = jest.fn((chunk: string | Uint8Array): boolean => {
stdoutOutput += chunk.toString();
return true;
}) as unknown as typeof process.stdout.write;
});
afterEach(() => {
process.env = originalEnv;
process.exitCode = originalExitCode;
process.stdout.write = originalWrite;
});
it('checking issueCommand with no properties', () => {
core.issueCommand('warning', {}, 'test message');
expect(stdoutOutput).toContain('::warning::test message');
});
it('checking issueCommand with properties', () => {
core.issueCommand('error', {file: 'test.ts', line: '10'}, 'error message');
expect(stdoutOutput).toContain(
'::error file=test.ts,line=10::error message'
);
});
it('checking issueCommand escapes special characters in message', () => {
core.issueCommand('warning', {}, 'line1\nline2\rline3%percent');
expect(stdoutOutput).toContain(
'::warning::line1%0Aline2%0Dline3%25percent'
);
});
it('checking issueCommand escapes special characters in properties', () => {
core.issueCommand('error', {file: 'path:to,file'}, 'message');
expect(stdoutOutput).toContain('::error file=path%3Ato%2Cfile::message');
});
it('checking issueCommand with Error object', () => {
const error = new Error('test error');
core.issueCommand('error', {}, error);
expect(stdoutOutput).toContain('::error::Error: test error');
});
it('checking issueCommand filters empty properties', () => {
core.issueCommand('warning', {file: 'test.ts', line: ''}, 'message');
expect(stdoutOutput).toContain('::warning file=test.ts::message');
});
it('checking error', () => {
core.error('error message');
expect(stdoutOutput).toContain('::error::error message');
});
it('checking error with Error object', () => {
core.error(new Error('error instance'));
expect(stdoutOutput).toContain('::error::Error: error instance');
});
it('checking setFailed', () => {
core.setFailed('failure message');
expect(process.exitCode).toBe(1);
expect(stdoutOutput).toContain('::error::failure message');
});
it('checking setFailed with Error object', () => {
core.setFailed(new Error('failure error'));
expect(process.exitCode).toBe(1);
expect(stdoutOutput).toContain('::error::Error: failure error');
});
it('checking getInput returns value', () => {
process.env['INPUT_TEST-INPUT'] = 'test value';
expect(core.getInput('test-input')).toBe('test value');
});
it('checking getInput trims value', () => {
process.env['INPUT_TEST-INPUT'] = ' trimmed ';
expect(core.getInput('test-input')).toBe('trimmed');
});
it('checking getInput returns empty string for missing input', () => {
expect(core.getInput('missing-input')).toBe('');
});
it('checking getInput throws for required missing input', () => {
expect(() => core.getInput('missing-input', true)).toThrow(
'Input required and not supplied: missing-input'
);
});
it('checking getInput handles spaces in name', () => {
process.env['INPUT_INPUT_WITH_SPACES'] = 'spaced value';
expect(core.getInput('input with spaces')).toBe('spaced value');
});
});

View File

@ -18,19 +18,13 @@ describe('Extension tests', () => {
${'oci8'} | ${'7.4'} | ${'Add-Oci oci8'} ${'oci8'} | ${'7.4'} | ${'Add-Oci oci8'}
${'pcov'} | ${'5.6'} | ${'Add-Log "$cross" "pcov" "pcov is not supported on PHP 5.6"'} ${'pcov'} | ${'5.6'} | ${'Add-Log "$cross" "pcov" "pcov is not supported on PHP 5.6"'}
${'pdo_oci'} | ${'7.4'} | ${'Add-Oci pdo_oci'} ${'pdo_oci'} | ${'7.4'} | ${'Add-Oci pdo_oci'}
${'ibm_db2'} | ${'7.4'} | ${'Add-Ibm ibm_db2'}
${'pdo_ibm'} | ${'7.4'} | ${'Add-Ibm pdo_ibm'}
${'pecl_http'} | ${'7.4'} | ${'Add-Http'} ${'pecl_http'} | ${'7.4'} | ${'Add-Http'}
${'pdo_sqlsrv'} | ${'7.4'} | ${'Add-Sqlsrv pdo_sqlsrv'}
${'phalcon3'} | ${'7.2'} | ${'Add-Phalcon phalcon3'} ${'phalcon3'} | ${'7.2'} | ${'Add-Phalcon phalcon3'}
${'phalcon4'} | ${'7.4'} | ${'Add-Phalcon phalcon4'} ${'phalcon4'} | ${'7.4'} | ${'Add-Phalcon phalcon4'}
${'sqlite'} | ${'7.4'} | ${'Add-Extension sqlite3'} ${'sqlite'} | ${'7.4'} | ${'Add-Extension sqlite3'}
${'sqlsrv'} | ${'5.6'} | ${'Add-Extension sqlsrv'}
${'sqlsrv'} | ${'7.4'} | ${'Add-Sqlsrv sqlsrv'}
${'sqlsrv-1.2.3preview1'} | ${'7.4'} | ${'Add-Extension sqlsrv devel 1.2.3'} ${'sqlsrv-1.2.3preview1'} | ${'7.4'} | ${'Add-Extension sqlsrv devel 1.2.3'}
${'Xdebug'} | ${'7.4'} | ${'Add-Extension xdebug'} ${'Xdebug'} | ${'7.4'} | ${'Add-Extension xdebug'}
${'xdebug2'} | ${'7.2'} | ${'Add-Extension xdebug stable 2.9.8'} ${'xdebug2'} | ${'7.2'} | ${'Add-Extension xdebug stable 2.9.8'}
${'zephir_parser'} | ${'7.2'} | ${'Add-ZephirParser zephir_parser'}
`( `(
'checking addExtensionOnWindows for extension $extension on version $version', 'checking addExtensionOnWindows for extension $extension on version $version',
async ({extension, version, output}) => { async ({extension, version, output}) => {
@ -54,28 +48,22 @@ describe('Extension tests', () => {
${'http-1.2.3'} | ${'7.3'} | ${'add_http http-1.2.3'} ${'http-1.2.3'} | ${'7.3'} | ${'add_http http-1.2.3'}
${'intl-65.1'} | ${'5.6'} | ${'add_intl intl-65.1'} ${'intl-65.1'} | ${'5.6'} | ${'add_intl intl-65.1'}
${'ioncube'} | ${'7.3'} | ${'add_ioncube'} ${'ioncube'} | ${'7.3'} | ${'add_ioncube'}
${'memcache-8.2'} | ${'8.2'} | ${'add_pecl_extension memcache 8.2 extension'}
${'mongodb-mongodb/mongo-php-driver@master'} | ${'7.3'} | ${'add_extension_from_source mongodb https://github.com mongodb mongo-php-driver master extension'} ${'mongodb-mongodb/mongo-php-driver@master'} | ${'7.3'} | ${'add_extension_from_source mongodb https://github.com mongodb mongo-php-driver master extension'}
${'oci8'} | ${'7.3'} | ${'add_oci oci8'} ${'oci8'} | ${'7.3'} | ${'add_oci oci8'}
${'pcov'} | ${'5.6'} | ${'add_log "$cross" "pcov" "pcov is not supported on PHP 5.6'} ${'pcov'} | ${'5.6'} | ${'add_log "$cross" "pcov" "pcov is not supported on PHP 5.6'}
${'ibm_db2'} | ${'7.3'} | ${'add_ibm ibm_db2'}
${'pdo-odbc'} | ${'7.4'} | ${'add_pdo_extension odbc'} ${'pdo-odbc'} | ${'7.4'} | ${'add_pdo_extension odbc'}
${'pdo_cubrid'} | ${'7.0'} | ${'add_cubrid pdo_cubrid'} ${'pdo_cubrid'} | ${'7.0'} | ${'add_cubrid pdo_cubrid'}
${'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_ibm'} | ${'7.3'} | ${'add_ibm pdo_ibm'}
${'pdo_sqlsrv'} | ${'7.4'} | ${'add_sqlsrv pdo_sqlsrv'} ${'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'}
${'relay'} | ${'7.4'} | ${'add_relay relay'}
${'relay-v1.2.3'} | ${'7.4'} | ${'add_relay relay-v1.2.3'}
${'sqlite'} | ${'7.4'} | ${'add_extension sqlite3'} ${'sqlite'} | ${'7.4'} | ${'add_extension sqlite3'}
${'sqlsrv-1.2.3-beta1'} | ${'7.4'} | ${'add_pecl_extension sqlsrv 1.2.3beta1 extension'} ${'sqlsrv-1.2.3-beta1'} | ${'7.4'} | ${'add_pecl_extension sqlsrv 1.2.3beta1 extension'}
${'Xdebug'} | ${'7.4'} | ${'add_extension xdebug'} ${'Xdebug'} | ${'7.4'} | ${'add_extension xdebug'}
${'xdebug-alpha'} | ${'7.4'} | ${'add_unstable_extension xdebug alpha zend_extension'} ${'xdebug-alpha'} | ${'7.4'} | ${'add_unstable_extension xdebug alpha zend_extension'}
${'xdebug2'} | ${'7.2'} | ${'add_pecl_extension xdebug 2.9.8 zend_extension'} ${'xdebug2'} | ${'7.2'} | ${'add_pecl_extension xdebug 2.9.8 zend_extension'}
${'zephir_parser-1.2.3'} | ${'7.2'} | ${'add_zephir_parser zephir_parser-1.2.3'}
`( `(
'checking addExtensionOnLinux for extension $extension on version $version', 'checking addExtensionOnLinux for extension $extension on version $version',
async ({extension, version, output}) => { async ({extension, version, output}) => {
@ -104,9 +92,8 @@ describe('Extension tests', () => {
${'pcov'} | ${'5.6'} | ${'add_log "$cross" "pcov" "pcov is not supported on PHP 5.6"'} ${'pcov'} | ${'5.6'} | ${'add_log "$cross" "pcov" "pcov is not supported on PHP 5.6"'}
${'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'}
${'relay-1.2.3'} | ${'7.4'} | ${'add_relay relay-1.2.3'}
${'sqlite'} | ${'7.2'} | ${'add_extension sqlite3'} ${'sqlite'} | ${'7.2'} | ${'add_extension sqlite3'}
${'zephir_parser-v1.2.3'} | ${'7.2'} | ${'add_zephir_parser zephir_parser-v1.2.3'} ${'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}) => {
@ -125,17 +112,12 @@ 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 ext_name = extension.replace(/\d+|(pdo|pecl)[_-]/, '');
const output: string = fs.existsSync( const output: string = fs.existsSync(
`src/scripts/extensions/${ext_name}.sh` `src/scripts/extensions/${extension}.sh`
) )
? `add_${ext_name}` ? `add_${extension}`
: `add_brew_extension ${formula} ${prefix}`; : `add_brew_extension ${formula} ${prefix}`;
return [ return [formula, formula === 'phalcon3' ? '7.3' : '7.4', output];
formula,
formula.match(/phalcon3|lua|propro/) ? '7.3' : '8.1',
output
];
}); });
it.each(data)( it.each(data)(

View File

@ -1,5 +1,5 @@
import * as fetch from '../src/fetch'; import * as fetch from '../src/fetch';
import nock from 'nock'; import nock = require('nock');
it('checking fetch', async () => { it('checking fetch', async () => {
const host_url = 'https://example.com'; const host_url = 'https://example.com';
@ -19,9 +19,7 @@ it('checking fetch', async () => {
Location: host_url + '/pong' Location: host_url + '/pong'
}) })
.get('/pong') .get('/pong')
.reply(200, 'pong') .reply(200, 'pong');
.get('/error')
.replyWithError('Network failure');
let response: Record<string, string> = await fetch.fetch(manifest_url); let response: Record<string, string> = await fetch.fetch(manifest_url);
expect(response.error).toBe(undefined); expect(response.error).toBe(undefined);
@ -38,8 +36,4 @@ it('checking fetch', async () => {
response = await fetch.fetch(manifest_url, 'invalid_token'); response = await fetch.fetch(manifest_url, 'invalid_token');
expect(response.error).not.toBe(undefined); expect(response.error).not.toBe(undefined);
expect(response.data).toBe(undefined); expect(response.data).toBe(undefined);
response = await fetch.fetch(host_url + '/error');
expect(response.error).toContain('Fetch error:');
expect(response.data).toBe(undefined);
}); });

View File

@ -10,7 +10,7 @@ jest.mock('../src/install', () => ({
.mockImplementation(async (os: string): Promise<string> => { .mockImplementation(async (os: string): Promise<string> => {
const filename = os + (await utils.scriptExtension(os)); const filename = os + (await utils.scriptExtension(os));
const version: string = await utils.parseVersion( const version: string = await utils.parseVersion(
await utils.readPHPVersion() await utils.getInput('php-version', true)
); );
const ini_file: string = await utils.parseIniFile( const ini_file: string = await utils.parseIniFile(
await utils.getInput('ini-file', false) await utils.getInput('ini-file', false)
@ -38,30 +38,25 @@ jest.mock('../src/install', () => ({
*/ */
jest.mock('../src/fetch', () => ({ jest.mock('../src/fetch', () => ({
fetch: jest.fn().mockImplementation(() => { fetch: jest.fn().mockImplementation(() => {
return { return {data: '{ "latest": "8.1", "5.x": "5.6" }'};
data: '{ "latest": "8.3", "lowest": "8.1", "highest": "8.3", "nightly": "8.4", "5.x": "5.6" }'
};
}) })
})); }));
describe('Install', () => { describe('Install', () => {
it.each` it.each`
version | os | extension_csv | ini_file | ini_values_csv | coverage_driver | tools | output version | os | extension_csv | ini_file | ini_values_csv | coverage_driver | tools | output
${'7.3'} | ${'darwin'} | ${''} | ${'production'} | ${''} | ${''} | ${''} | ${'bash darwin.sh 7.3 production'} ${'7.3'} | ${'darwin'} | ${''} | ${'production'} | ${''} | ${''} | ${''} | ${'bash darwin.sh 7.3 production'}
${'7.3'} | ${'darwin'} | ${'a, b'} | ${'development'} | ${'a=b'} | ${'x'} | ${''} | ${'bash darwin.sh 7.3 development install extensions set coverage driver edit php.ini'} ${'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'} | ${''} | ${'none'} | ${''} | ${''} | ${''} | ${'bash darwin.sh 7.4 none'} ${'7.4.1'} | ${'darwin'} | ${''} | ${'none'} | ${''} | ${''} | ${''} | ${'bash darwin.sh 7.4 none'}
${'8'} | ${'darwin'} | ${''} | ${''} | ${''} | ${''} | ${''} | ${'bash darwin.sh 8.0 production'} ${'8'} | ${'darwin'} | ${''} | ${''} | ${''} | ${''} | ${''} | ${'bash darwin.sh 8.0 production'}
${'8.0'} | ${'darwin'} | ${''} | ${'development'} | ${''} | ${''} | ${''} | ${'bash darwin.sh 8.0 development'} ${'8.0'} | ${'darwin'} | ${''} | ${'development'} | ${''} | ${''} | ${''} | ${'bash darwin.sh 8.0 development'}
${'8.1'} | ${'darwin'} | ${''} | ${'none'} | ${''} | ${''} | ${''} | ${'bash darwin.sh 8.1 none'} ${'8.1'} | ${'darwin'} | ${''} | ${'none'} | ${''} | ${''} | ${''} | ${'bash darwin.sh 8.1 none'}
${'7.3'} | ${'linux'} | ${''} | ${'invalid'} | ${''} | ${''} | ${''} | ${'bash linux.sh 7.3 production'} ${'7.3'} | ${'linux'} | ${''} | ${'invalid'} | ${''} | ${''} | ${''} | ${'bash linux.sh 7.3 production'}
${'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'} ${'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'} | ${''} | ${'none'} | ${''} | ${''} | ${''} | ${'bash linux.sh 8.3 none'} ${'latest'} | ${'linux'} | ${''} | ${'none'} | ${''} | ${''} | ${''} | ${'bash linux.sh 8.1 none'}
${'lowest'} | ${'linux'} | ${''} | ${'none'} | ${''} | ${''} | ${''} | ${'bash linux.sh 8.1 none'} ${'7.0'} | ${'win32'} | ${''} | ${'production'} | ${''} | ${''} | ${''} | ${'pwsh win32.ps1 7.0 production'}
${'highest'} | ${'linux'} | ${''} | ${'none'} | ${''} | ${''} | ${''} | ${'bash linux.sh 8.3 none'} ${'7.3'} | ${'win32'} | ${''} | ${'development'} | ${''} | ${''} | ${''} | ${'pwsh win32.ps1 7.3 development'}
${'nightly'} | ${'linux'} | ${''} | ${'none'} | ${''} | ${''} | ${''} | ${'bash linux.sh 8.4 none'} ${'7.3'} | ${'win32'} | ${'a, b'} | ${'none'} | ${'a=b'} | ${'x'} | ${''} | ${'pwsh win32.ps1 7.3 none install extensions set coverage driver edit php.ini'}
${'7.0'} | ${'win32'} | ${''} | ${'production'} | ${''} | ${''} | ${''} | ${'pwsh win32.ps1 7.0 production'}
${'7.3'} | ${'win32'} | ${''} | ${'development'} | ${''} | ${''} | ${''} | ${'pwsh win32.ps1 7.3 development'}
${'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 ({

View File

@ -1,50 +0,0 @@
import * as packagist from '../src/packagist';
import nock from 'nock';
describe('search function', () => {
const mockResponse = {
packages: {
'test-package': [
{
require: {
php: '8.0.0'
},
version: '1.0.0'
},
{
version: '2.0.0'
}
]
}
};
test('should return the version if matching php version is found', async () => {
nock('https://repo.packagist.org')
.get('/p2/test-package.json')
.reply(200, mockResponse);
const result = await packagist.search('test-package', '8.0');
expect(result).toBe('1.0.0');
});
test('should return null if no matching php version is found', async () => {
nock('https://repo.packagist.org')
.get('/p2/test-package.json')
.reply(200, mockResponse);
const result = await packagist.search('test-package', '5.6');
expect(result).toBeNull();
});
test('should return null if fetch fails', async () => {
nock('https://repo.packagist.org').get('/p2/test-package.json').reply(404);
const result = await packagist.search('test-package', '8.0');
expect(result).toBeNull();
});
test('should return null if the response is empty', async () => {
nock('https://repo.packagist.org')
.get('/p2/test-package.json')
.reply(200, {error: true, data: '[]'});
const result = await packagist.search('test-package', '8.0');
expect(result).toBeNull();
});
});

View File

@ -1,33 +1,39 @@
import * as fs from 'fs';
import * as tools from '../src/tools'; import * as tools from '../src/tools';
import {ToolData, ToolInput} from '../src/tools';
function getData(data: Partial<ToolData>): ToolData { interface IData {
const tool = data.tool || 'tool'; tool: string;
const version = data.version || ''; version?: string;
domain?: string;
extension?: string;
os?: string;
php_version?: string;
release?: string;
repository?: string;
scope?: string;
type?: string;
fetch_latest?: string;
version_parameter?: string;
version_prefix?: string;
}
function getData(data: IData): Record<string, string> {
return { return {
tool, tool: data.tool,
version, version: data.version || '',
url: data.url || '',
domain: data.domain || 'https://example.com', domain: data.domain || 'https://example.com',
extension: data.extension || '.phar', extension: data.extension || '.phar',
os: data.os || 'linux', os: data.os || 'linux',
php_version: data.php_version || '7.4', php_version: data.php_version || '7.4',
release: data.release || [tool, version].join(':'), release: data.release || [data.tool, data.version].join(':'),
repository: data.repository || '', repository: data.repository || '',
scope: data.scope || 'global', scope: data.scope || 'global',
type: data.type || 'phar', type: data.type || 'phar',
fetch_latest: data.fetch_latest || 'false', fetch_latest: data.fetch_latest || 'false',
version_parameter: data.version_parameter || '-V', version_parameter: data.version_parameter || '-V',
version_prefix: data.version_prefix || '', version_prefix: data.version_prefix || '',
github: data.github || 'https://github.com', github: 'https://github.com',
prefix: data.prefix || 'releases', prefix: 'releases',
verb: data.verb || 'download', verb: 'download'
packagist: data.packagist || data.repository || '',
function: data.function,
alias: data.alias,
uri: data.uri,
error: data.error
}; };
} }
@ -54,23 +60,7 @@ jest.mock('../src/fetch', () => ({
} else if (!token || token === 'valid_token') { } else if (!token || token === 'valid_token') {
return {data: `[{"ref": "refs/tags/1.2.3", "url": "${url}"}]`}; return {data: `[{"ref": "refs/tags/1.2.3", "url": "${url}"}]`};
} else if (token === 'beta_token') { } else if (token === 'beta_token') {
return {data: `[{"ref": "refs/tags/1.2.3beta1", "url": "${url}"}]`}; return {data: `[{"ref": "refs/tags/1.2.3-beta1", "url": "${url}"}]`};
} else if (token === 'rc_token') {
return {
data: `[{"ref":"refs/tags/3.0.0RC1"},{"ref":"refs/tags/3.0.0RC2"}]`
};
} else if (token === 'non_semver_tags') {
return {
data: `[{"ref":"refs/tags/release-2025-09-18"},{"ref":"refs/tags/release-2025-09-17"}]`
};
} else if (token === 'undefined_ref') {
return {
data: `[{"url":"${url}"},{"ref":"refs/tags/v1.2.4","url":"${url}"}]`
};
} else if (token === 'multi_refs') {
return {
data: `[{"ref":"refs/tags/v1.2.3","url":"${url}"},{"ref":"refs/tags/1.2.4","url":"${url}"}]`
};
} else if (token === 'no_data') { } else if (token === 'no_data') {
return {data: '[]'}; return {data: '[]'};
} else { } else {
@ -80,59 +70,20 @@ jest.mock('../src/fetch', () => ({
) )
})); }));
jest.mock('../src/packagist', () => ({
search: jest
.fn()
.mockImplementation(
async (
package_name: string,
php_version: string
): Promise<string | null> => {
if (package_name === 'phpunit/phpunit') {
return php_version + '.0';
}
return null;
}
)
}));
describe('Tools tests', () => { describe('Tools tests', () => {
it.each` it.each`
token | version token | version
${'invalid_token'} | ${'1.2'} ${'invalid_token'} | ${'1.2'}
${'valid_token'} | ${'1.2.3'} ${'valid_token'} | ${'1.2.3'}
${'beta_token'} | ${'1.2.3beta1'} ${'beta_token'} | ${'1.2.3-beta1'}
${'undefined_ref'} | ${'1.2.4'} ${''} | ${'1.2.3'}
${'multi_refs'} | ${'1.2.4'}
${'non_semver_tags'} | ${'release-2025-09-18'}
${''} | ${'1.2.3'}
`('checking getSemverVersion: $token', async ({token, version}) => { `('checking getSemverVersion: $token', async ({token, version}) => {
process.env['GITHUB_TOKEN'] = token; process.env['COMPOSER_TOKEN'] = token;
expect( expect(
await tools.getSemverVersion(getData({tool: 'tool', version: '1.2'})) await tools.getSemverVersion(getData({tool: 'tool', version: '1.2'}))
).toBe(version); ).toBe(version);
}); });
it('checking getSemverVersion triggers ?? fallback via Map#get mock', async () => {
process.env['GITHUB_TOKEN'] = 'rc_token';
const spy = jest
.spyOn(Map.prototype as Map<string, string>, 'get')
.mockImplementation(function (
this: Map<string, string>,
key: string
): string | undefined {
if (key === '3.0.0-RC2') {
return undefined;
}
return Map.prototype.get.call(this, key);
});
const result = await tools.getSemverVersion(
getData({tool: 'tool', version: '3.0.0'})
);
expect(result).toBe('3.0.0-RC2');
spy.mockRestore();
});
it.each` it.each`
tool | fetch_latest | version tool | fetch_latest | version
${'tool'} | ${'true'} | ${'3.2.1'} ${'tool'} | ${'true'} | ${'3.2.1'}
@ -154,18 +105,6 @@ describe('Tools tests', () => {
} }
); );
it('checking getLatestVersion with fetch_latest=true but no repository', async () => {
expect(
await tools.getLatestVersion(
getData({
tool: 'tool',
repository: '',
fetch_latest: 'true'
})
)
).toBe('latest');
});
it.each` it.each`
version | tool | type | expected version | tool | type | expected
${'latest'} | ${'tool'} | ${'phar'} | ${'latest'} ${'latest'} | ${'tool'} | ${'phar'} | ${'latest'}
@ -249,21 +188,6 @@ describe('Tools tests', () => {
} }
); );
it('checking getUrl handles undefined version without double slash', async () => {
const data: ToolInput = {
...getData({
tool: 'cs2pr',
repository: 'staabm/annotate-pull-request-from-checkstyle',
domain: 'https://github.com'
}),
version: undefined
};
data.extension = '';
expect(await tools.getUrl(data)).toBe(
'https://github.com/staabm/annotate-pull-request-from-checkstyle/releases/latest/download/cs2pr'
);
});
it.each` it.each`
version | version_prefix | url version | version_prefix | url
${'latest'} | ${''} | ${'https://example.com/tool.phar'} ${'latest'} | ${''} | ${'https://example.com/tool.phar'}
@ -291,18 +215,18 @@ describe('Tools tests', () => {
tool: 'tool', tool: 'tool',
version: 'latest', version: 'latest',
version_parameter: JSON.stringify('-v'), version_parameter: JSON.stringify('-v'),
os: os, os: os
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 | script | scope os | script | scope
${'linux'} | ${'add_composer_tool tool tool:1.2.3 user/ global'} | ${'global'} ${'linux'} | ${'add_composertool tool tool:1.2.3 user/ global'} | ${'global'}
${'darwin'} | ${'add_composer_tool 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, $scope', async ({os, script, scope}) => {
const data = getData({ const data = getData({
tool: 'tool', tool: 'tool',
@ -317,9 +241,8 @@ describe('Tools tests', () => {
it.each` it.each`
version | php_version | os | script version | php_version | os | script
${'latest'} | ${'8.0'} | ${'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'} | ${'8.0'} | ${'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.4'} | ${'win32'} | ${'Add-Tool https://github.com/phar-io/phive/releases/download/0.15.3/phive-0.15.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'}
${'1.2.3'} | ${'7.1'} | ${'win32'} | ${'Add-Tool https://github.com/phar-io/phive/releases/download/0.13.5/phive-0.13.5.phar phive'} ${'1.2.3'} | ${'7.1'} | ${'win32'} | ${'Add-Tool https://github.com/phar-io/phive/releases/download/0.13.5/phive-0.13.5.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.6'} | ${'win32'} | ${'Add-Tool https://github.com/phar-io/phive/releases/download/0.12.1/phive-0.12.1.phar phive'}
@ -341,18 +264,15 @@ describe('Tools tests', () => {
); );
it.each` it.each`
os | version | php_version | url version | php_version | url
${'linux'} | ${'latest'} | ${'8.1'} | ${'https://get.blackfire.io/blackfire-player.phar'} ${'latest'} | ${'7.4'} | ${'https://get.blackfire.io/blackfire-player.phar'}
${'linux'} | ${'1.2.3'} | ${'7.4'} | ${'https://get.blackfire.io/blackfire-player-v1.2.3.phar'} ${'1.2.3'} | ${'7.4'} | ${'https://get.blackfire.io/blackfire-player-v1.2.3.phar'}
${'linux'} | ${'latest'} | ${'7.4'} | ${'https://get.blackfire.io/blackfire-player-v1.22.0.phar'} ${'latest'} | ${'5.5'} | ${'https://get.blackfire.io/blackfire-player-v1.9.3.phar'}
${'linux'} | ${'latest'} | ${'5.5'} | ${'https://get.blackfire.io/blackfire-player-v1.9.3.phar'} ${'latest'} | ${'7.0'} | ${'https://get.blackfire.io/blackfire-player-v1.9.3.phar'}
${'linux'} | ${'latest'} | ${'7.0'} | ${'https://get.blackfire.io/blackfire-player-v1.9.3.phar'}
${'win32'} | ${'latest'} | ${'7.0'} | ${'blackfire-player is not a windows tool'}
`( `(
'checking addBlackfirePlayer: $os, $version, $php_version', 'checking addBlackfirePlayer: $version, $php_version',
async ({os, version, php_version, url}) => { async ({version, php_version, url}) => {
const data = getData({ const data = getData({
os: os,
tool: 'blackfire-player', tool: 'blackfire-player',
domain: 'https://get.blackfire.io', domain: 'https://get.blackfire.io',
version_prefix: 'v', version_prefix: 'v',
@ -391,20 +311,14 @@ describe('Tools tests', () => {
${'preview'} | ${'7.4'} | ${'true'} | ${'https://dl.cloudsmith.io/public/shivammathur/composer-cache/raw/files/composer-7.4-preview.phar'} | ${'https://getcomposer.org/composer-preview.phar'} ${'preview'} | ${'7.4'} | ${'true'} | ${'https://dl.cloudsmith.io/public/shivammathur/composer-cache/raw/files/composer-7.4-preview.phar'} | ${'https://getcomposer.org/composer-preview.phar'}
${'1'} | ${'7.4'} | ${'false'} | ${'https://dl.cloudsmith.io/public/shivammathur/composer-cache/raw/files/composer-7.4-1.phar'} | ${'https://getcomposer.org/composer-1.phar'} ${'1'} | ${'7.4'} | ${'false'} | ${'https://dl.cloudsmith.io/public/shivammathur/composer-cache/raw/files/composer-7.4-1.phar'} | ${'https://getcomposer.org/composer-1.phar'}
${'2'} | ${'7.4'} | ${'false'} | ${'https://dl.cloudsmith.io/public/shivammathur/composer-cache/raw/files/composer-7.4-2.phar'} | ${'https://getcomposer.org/composer-2.phar'} ${'2'} | ${'7.4'} | ${'false'} | ${'https://dl.cloudsmith.io/public/shivammathur/composer-cache/raw/files/composer-7.4-2.phar'} | ${'https://getcomposer.org/composer-2.phar'}
${'latest'} | ${'7.4'} | ${'true'} | ${'https://artifacts.setup-php.com/composer/composer-7.4-stable.phar'} | ${'https://getcomposer.org/composer-stable.phar'}
${'stable'} | ${'7.4'} | ${'true'} | ${'https://artifacts.setup-php.com/composer/composer-7.4-stable.phar'} | ${'https://getcomposer.org/composer-stable.phar'}
${'snapshot'} | ${'7.4'} | ${'true'} | ${'https://artifacts.setup-php.com/composer/composer-7.4-snapshot.phar'} | ${'https://getcomposer.org/composer.phar'}
${'preview'} | ${'7.4'} | ${'true'} | ${'https://artifacts.setup-php.com/composer/composer-7.4-preview.phar'} | ${'https://getcomposer.org/composer-preview.phar'}
${'1'} | ${'7.4'} | ${'false'} | ${'https://artifacts.setup-php.com/composer/composer-7.4-1.phar'} | ${'https://getcomposer.org/composer-1.phar'}
${'2'} | ${'7.4'} | ${'false'} | ${'https://artifacts.setup-php.com/composer/composer-7.4-2.phar'} | ${'https://getcomposer.org/composer-2.phar'}
${'latest'} | ${'7.1'} | ${'true'} | ${'https://github.com/shivammathur/composer-cache/releases/latest/download/composer-7.1-stable.phar'} | ${'https://getcomposer.org/download/latest-2.2.x/composer.phar'} ${'latest'} | ${'7.1'} | ${'true'} | ${'https://github.com/shivammathur/composer-cache/releases/latest/download/composer-7.1-stable.phar'} | ${'https://getcomposer.org/download/latest-2.2.x/composer.phar'}
${'stable'} | ${'7.1'} | ${'true'} | ${'https://github.com/shivammathur/composer-cache/releases/latest/download/composer-7.1-stable.phar'} | ${'https://getcomposer.org/download/latest-2.2.x/composer.phar'} ${'stable'} | ${'7.1'} | ${'true'} | ${'https://github.com/shivammathur/composer-cache/releases/latest/download/composer-7.1-stable.phar'} | ${'https://getcomposer.org/download/latest-2.2.x/composer.phar'}
${'snapshot'} | ${'7.1'} | ${'true'} | ${'https://github.com/shivammathur/composer-cache/releases/latest/download/composer-7.1-snapshot.phar'} | ${'https://getcomposer.org/download/latest-2.2.x/composer.phar'} ${'snapshot'} | ${'7.1'} | ${'true'} | ${'https://github.com/shivammathur/composer-cache/releases/latest/download/composer-7.1-snapshot.phar'} | ${'https://getcomposer.org/download/latest-2.2.x/composer.phar'}
${'preview'} | ${'7.1'} | ${'true'} | ${'https://github.com/shivammathur/composer-cache/releases/latest/download/composer-7.1-preview.phar'} | ${'https://getcomposer.org/download/latest-2.2.x/composer.phar'} ${'preview'} | ${'7.1'} | ${'true'} | ${'https://github.com/shivammathur/composer-cache/releases/latest/download/composer-7.1-preview.phar'} | ${'https://getcomposer.org/download/latest-2.2.x/composer.phar'}
${'1'} | ${'7.1'} | ${'false'} | ${'https://github.com/shivammathur/composer-cache/releases/latest/download/composer-7.1-1.phar'} | ${'https://getcomposer.org/composer-1.phar'} ${'1'} | ${'7.1'} | ${'false'} | ${'https://github.com/shivammathur/composer-cache/releases/latest/download/composer-7.1-1.phar'} | ${'https://getcomposer.org/composer-1.phar'}
${'2'} | ${'7.1'} | ${'false'} | ${'https://github.com/shivammathur/composer-cache/releases/latest/download/composer-7.1-2.phar'} | ${'https://getcomposer.org/download/latest-2.2.x/composer.phar'} ${'2'} | ${'7.1'} | ${'false'} | ${'https://github.com/shivammathur/composer-cache/releases/latest/download/composer-7.1-2.phar'} | ${'https://getcomposer.org/download/latest-2.2.x/composer.phar'}
${'1.2.3'} | ${'7.4'} | ${'false'} | ${'https://github.com/composer/composer/releases/download/1.2.3/composer.phar'} | ${'https://getcomposer.org/download/1.2.3/composer.phar'} ${'1.2.3'} | ${'7.4'} | ${'false'} | ${'https://github.com/composer/composer/releases/download/1.2.3/composer.phar'} | ${'https://getcomposer.org/composer-1.2.3.phar'}
${'1.2.3-RC1'} | ${'7.4'} | ${'false'} | ${'https://github.com/composer/composer/releases/download/1.2.3-RC1/composer.phar'} | ${'https://getcomposer.org/download/1.2.3-RC1/composer.phar'} ${'1.2.3-RC1'} | ${'7.4'} | ${'false'} | ${'https://github.com/composer/composer/releases/download/1.2.3-RC1/composer.phar'} | ${'https://getcomposer.org/composer-1.2.3-RC1.phar'}
`( `(
'checking addComposer: $version, $php_version, $no_tool_cache', 'checking addComposer: $version, $php_version, $no_tool_cache',
async ({version, php_version, no_tool_cache, cache_url, source_url}) => { async ({version, php_version, no_tool_cache, cache_url, source_url}) => {
@ -458,40 +372,35 @@ describe('Tools tests', () => {
it.each([ it.each([
[ [
'blackfire, blackfire-player, box, churn, cs2pr, flex, grpc_php_plugin, mago, name-collision-detector, parallel-lint, php-cs-fixer, php-scoper, phpDocumentor, phplint, phpstan, phpunit, pecl, phing, phinx, phinx:1.2.3, phive, phpunit-bridge, phpunit-polyfills, pint, php-config, phpize, protoc, symfony, vapor, wp, pie', '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, pint, php-config, phpize, protoc, symfony, vapor, wp',
[ [
'add_tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-7.4-stable.phar,https://artifacts.setup-php.com/composer/composer-7.4-stable.phar,https://dl.cloudsmith.io/public/shivammathur/composer-cache/raw/files/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://dl.cloudsmith.io/public/shivammathur/composer-cache/raw/files/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.22.0.phar blackfire-player "-V"', 'add_tool https://get.blackfire.io/blackfire-player.phar blackfire-player "-V"',
'add_tool https://github.com/box-project/box/releases/latest/download/box.phar box "--version"',
'add_tool https://github.com/bmitch/churn-php/releases/latest/download/churn.phar churn "-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_composer_tool flex flex symfony/ global', 'add_composertool flex flex symfony/ global',
'add_grpc_php_plugin latest', 'add_grpc_php_plugin latest',
'add_mago',
'add_composer_tool name-collision-detector name-collision-detector shipmonk/ scoped',
'add_tool https://github.com/php-parallel-lint/PHP-Parallel-Lint/releases/latest/download/parallel-lint.phar parallel-lint "--version"', 'add_tool https://github.com/php-parallel-lint/PHP-Parallel-Lint/releases/latest/download/parallel-lint.phar parallel-lint "--version"',
'add_tool https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/releases/download/v3.2.1/php-cs-fixer.phar php-cs-fixer "-V"', 'add_tool https://github.com/FriendsOfPHP/PHP-CS-Fixer/releases/download/v3.2.1/php-cs-fixer.phar php-cs-fixer "-V"',
'add_tool https://github.com/humbug/php-scoper/releases/latest/download/php-scoper.phar php-scoper "--version"',
'add_tool https://github.com/phpDocumentor/phpDocumentor/releases/latest/download/phpDocumentor.phar phpDocumentor "--version"', 'add_tool https://github.com/phpDocumentor/phpDocumentor/releases/latest/download/phpDocumentor.phar phpDocumentor "--version"',
'add_composer_tool phplint phplint overtrue/', 'add_composertool phplint phplint overtrue/',
'add_tool https://github.com/phpstan/phpstan/releases/latest/download/phpstan.phar phpstan "-V"', 'add_tool https://github.com/phpstan/phpstan/releases/latest/download/phpstan.phar phpstan "-V"',
'add_tool https://phar.phpunit.de/phpunit-7.4.0.phar,https://phar.phpunit.de/phpunit-7.phar phpunit "--version"', 'add_tool https://phar.phpunit.de/phpunit.phar phpunit "--version"',
'add_pecl', 'add_pecl',
'add_tool https://www.phing.info/get/phing-latest.phar phing "-v"', 'add_tool https://www.phing.info/get/phing-latest.phar phing "-v"',
'add_composer_tool phinx phinx robmorgan/ scoped', 'add_composertool phinx phinx robmorgan/ scoped',
'add_composer_tool phinx phinx:1.2.3 robmorgan/ scoped', 'add_composertool phinx phinx:1.2.3 robmorgan/ scoped',
'add_tool https://github.com/phar-io/phive/releases/download/0.15.3/phive-0.15.3.phar phive "status"', 'add_tool https://github.com/phar-io/phive/releases/download/3.2.1/phive-3.2.1.phar phive "status"',
'add_composer_tool phpunit-bridge phpunit-bridge symfony/ global', 'add_composertool phpunit-bridge phpunit-bridge symfony/ global',
'add_composer_tool phpunit-polyfills phpunit-polyfills yoast/ global', 'add_composertool phpunit-polyfills phpunit-polyfills yoast/ global',
'add_tool https://github.com/laravel/pint/releases/latest/download/pint.phar pint "-V"', 'add_tool https://github.com/laravel/pint/releases/latest/download/pint.phar pint "-V"',
'add_devtools php-config', 'add_devtools php-config',
'add_devtools phpize', 'add_devtools phpize',
'add_protoc latest', 'add_protoc latest',
'add_symfony latest', 'add_symfony latest',
'add_composer_tool 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"'
'add_tool https://github.com/php/pie/releases/latest/download/pie.phar pie "-V"'
] ]
] ]
])('checking addTools on linux', async (tools_csv, scripts) => { ])('checking addTools on linux', async (tools_csv, scripts) => {
@ -503,47 +412,40 @@ describe('Tools tests', () => {
it.each([ it.each([
[ [
'backward-compatibility-check, behat, blackfire, blackfire-player, churn, composer-dependency-analyser, composer-normalize, composer-require-checker, composer-unused, cs2pr:1.2.3, ecs, flex, grpc_php_plugin:1.2.3, infection, mago:0.26.1, name-collision-detector, 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, rector, symfony-cli, vapor-cli, wp-cli, pie', '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://artifacts.setup-php.com/composer/composer-7.4-stable.phar,https://dl.cloudsmith.io/public/shivammathur/composer-cache/raw/files/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://dl.cloudsmith.io/public/shivammathur/composer-cache/raw/files/composer-7.4-stable.phar,https://getcomposer.org/composer-stable.phar composer',
'add_composer_tool behat behat behat/ scoped', 'add_composertool behat behat behat/ scoped',
'add_blackfire', 'add_blackfire',
'add_tool https://get.blackfire.io/blackfire-player-v1.22.0.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/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 "diagnose"', 'add_tool https://github.com/ergebnis/composer-normalize/releases/latest/download/composer-normalize.phar composer-normalize "-V"',
'add_composer_tool composer-dependency-analyser composer-dependency-analyser shipmonk/ scoped', 'add_composertool composer-require-checker composer-require-checker maglnet/ scoped',
'add_composer_tool composer-require-checker composer-require-checker maglnet/ scoped', 'add_composertool composer-unused composer-unused icanhazstring/ scoped',
'add_tool https://github.com/composer-unused/composer-unused/releases/latest/download/composer-unused.phar composer-unused "-V"',
'add_tool https://github.com/staabm/annotate-pull-request-from-checkstyle/releases/download/1.2.3/cs2pr cs2pr "-V"', 'add_tool https://github.com/staabm/annotate-pull-request-from-checkstyle/releases/download/1.2.3/cs2pr cs2pr "-V"',
'add_composer_tool flex flex symfony/ global', 'add_composertool flex flex symfony/ global',
'add_grpc_php_plugin 1.2.3', 'add_grpc_php_plugin 1.2.3',
'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_mago 0.26.1',
'add_composer_tool name-collision-detector name-collision-detector shipmonk/ scoped',
'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,https://github.com/phingofficial/phing/releases/download/1.2.3/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_composer_tool phinx phinx robmorgan/ scoped', 'add_composertool phinx phinx robmorgan/ scoped',
'add_tool https://github.com/phar-io/phive/releases/download/0.15.3/phive-0.15.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',
'add_tool https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/latest/download/phpcbf.phar phpcbf "--version"', 'add_tool https://github.com/squizlabs/PHP_CodeSniffer/releases/latest/download/phpcbf.phar phpcbf "--version"',
'add_tool https://phar.phpunit.de/phpcpd.phar phpcpd "--version"', 'add_tool https://phar.phpunit.de/phpcpd.phar phpcpd "--version"',
'add_tool https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/latest/download/phpcs.phar phpcs "--version"', 'add_tool https://github.com/squizlabs/PHP_CodeSniffer/releases/latest/download/phpcs.phar phpcs "--version"',
'add_tool https://github.com/phpDocumentor/phpDocumentor/releases/latest/download/phpDocumentor.phar phpDocumentor "--version"', 'add_tool https://github.com/phpDocumentor/phpDocumentor/releases/latest/download/phpDocumentor.phar phpDocumentor "--version"',
'add_devtools phpize', 'add_devtools phpize',
'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_tool https://github.com/phpspec/phpspec/releases/latest/download/phpspec.phar phpspec "-V"', 'add_tool https://github.com/phpspec/phpspec/releases/latest/download/phpspec.phar phpspec "-V"',
'add_composer_tool phpunit-bridge phpunit-bridge:5.6.* symfony/ global', 'add_composertool phpunit-bridge phpunit-bridge:5.6.* symfony/ global',
'add_composer_tool 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_composer_tool rector rector rector/ scoped',
'add_composer_tool backward-compatibility-check backward-compatibility-check roave/ scoped',
'add_symfony latest', 'add_symfony latest',
'add_composer_tool 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"'
'add_composer_tool easy-coding-standard easy-coding-standard symplify/ scoped',
'add_tool https://github.com/php/pie/releases/latest/download/pie.phar pie "-V"'
] ]
] ]
])('checking addTools on darwin', async (tools_csv, scripts) => { ])('checking addTools on darwin', async (tools_csv, scripts) => {
@ -555,27 +457,24 @@ describe('Tools tests', () => {
it.each([ it.each([
[ [
'blackfire, blackfire-player:1.2.3, cs2pr, churn, deployer, does_not_exist, flex, mago, name-collision-detector, phinx, phive:0.13.2, php-config, phpize, phpmd, simple-phpunit, symfony, wp, pie', '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://artifacts.setup-php.com/composer/composer-7.4-stable.phar,https://dl.cloudsmith.io/public/shivammathur/composer-cache/raw/files/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://dl.cloudsmith.io/public/shivammathur/composer-cache/raw/files/composer-7.4-stable.phar,https://getcomposer.org/composer-stable.phar composer',
'Add-Blackfire', 'Add-Blackfire',
'blackfire-player is not a windows tool', '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://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',
'Add-Mago', 'Add-Composertool phinx phinx robmorgan/ scoped',
'Add-ComposerTool name-collision-detector name-collision-detector shipmonk/ scoped', 'Add-Tool https://github.com/phar-io/phive/releases/download/0.13.2/phive-0.13.2.phar phive "status"',
'Add-ComposerTool phinx phinx robmorgan/ scoped',
'Add-Tool https://github.com/phar-io/phive/releases/download/0.15.3/phive-0.15.3.phar phive "status"',
'php-config is not a windows tool', 'php-config is not a windows tool',
'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-Symfony', '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"'
'Add-Tool https://github.com/php/pie/releases/latest/download/pie.phar pie "-V"'
] ]
] ]
])('checking addTools on Windows', async (tools_csv, scripts) => { ])('checking addTools on Windows', async (tools_csv, scripts) => {
@ -589,14 +488,14 @@ describe('Tools tests', () => {
[ [
'composer:v1, codeception/codeception, prestissimo, hirak/prestissimo, composer-prefetcher, narrowspark/automatic-composer-prefetcher, phinx: 1.2, robmorgan/phinx: ^1.2, user/tool:1.2.3, user/tool:~1.2', 'composer:v1, codeception/codeception, prestissimo, hirak/prestissimo, composer-prefetcher, narrowspark/automatic-composer-prefetcher, phinx: 1.2, robmorgan/phinx: ^1.2, user/tool:1.2.3, user/tool:~1.2',
[ [
'Add-Tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-7.4-1.phar,https://artifacts.setup-php.com/composer/composer-7.4-1.phar,https://dl.cloudsmith.io/public/shivammathur/composer-cache/raw/files/composer-7.4-1.phar,https://getcomposer.org/composer-1.phar composer', 'Add-Tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-7.4-1.phar,https://dl.cloudsmith.io/public/shivammathur/composer-cache/raw/files/composer-7.4-1.phar,https://getcomposer.org/composer-1.phar composer',
'Add-ComposerTool codeception codeception codeception/ global', 'Add-Composertool codeception codeception codeception/ global',
'Add-ComposerTool prestissimo prestissimo hirak/ global', 'Add-Composertool prestissimo prestissimo hirak/ global',
'Add-ComposerTool automatic-composer-prefetcher automatic-composer-prefetcher narrowspark/ global', 'Add-Composertool automatic-composer-prefetcher automatic-composer-prefetcher narrowspark/ global',
'Add-ComposerTool phinx phinx:1.2.* robmorgan/ scoped', 'Add-Composertool phinx phinx:1.2.* robmorgan/ scoped',
'Add-ComposerTool phinx phinx:^1.2 robmorgan/ global', 'Add-Composertool phinx phinx:^1.2 robmorgan/ global',
'Add-ComposerTool tool tool:1.2.3 user/ global', 'Add-Composertool tool tool:1.2.3 user/ global',
'Add-ComposerTool tool tool:~1.2 user/ global' 'Add-Composertool tool tool:~1.2 user/ global'
] ]
] ]
])( ])(
@ -610,39 +509,23 @@ describe('Tools tests', () => {
); );
it.each` it.each`
version | os | uri tools_csv | script
${'latest'} | ${'linux'} | ${'releases/latest/download/castor.linux-amd64.phar'} ${'none'} | ${''}
${'0.5.1'} | ${'linux'} | ${'releases/download/v0.5.1/castor.linux-amd64.phar'} ${'none, phpunit'} | ${'\nstep_log "Setup Tools"\nadd_tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-7.4-stable.phar,https://dl.cloudsmith.io/public/shivammathur/composer-cache/raw/files/composer-7.4-stable.phar,https://getcomposer.org/composer-stable.phar composer latest\n\nadd_tool https://phar.phpunit.de/phpunit.phar phpunit "--version"'}
${'latest'} | ${'darwin'} | ${'releases/latest/download/castor.darwin-amd64.phar'} ${'composer:preview'} | ${'add_tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-7.4-preview.phar,https://dl.cloudsmith.io/public/shivammathur/composer-cache/raw/files/composer-7.4-preview.phar,https://getcomposer.org/composer-preview.phar composer preview'}
${'0.5.1'} | ${'darwin'} | ${'releases/download/v0.5.1/castor.darwin-amd64.phar'} ${'composer, composer:v1'} | ${'add_tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-7.4-1.phar,https://dl.cloudsmith.io/public/shivammathur/composer-cache/raw/files/composer-7.4-1.phar,https://getcomposer.org/composer-1.phar composer'}
${'latest'} | ${'win32'} | ${'releases/latest/download/castor.windows-amd64.phar'} ${'composer:v1, composer:preview, composer:snapshot'} | ${'add_tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-7.4-snapshot.phar,https://dl.cloudsmith.io/public/shivammathur/composer-cache/raw/files/composer-7.4-snapshot.phar,https://getcomposer.org/composer.phar composer snapshot'}
${'0.5.1'} | ${'win32'} | ${'releases/download/v0.5.1/castor.windows-amd64.phar castor -V'} `('checking composer setup: $tools_csv', async ({tools_csv, script}) => {
${'latest'} | ${'openbsd'} | ${'Platform openbsd is not supported'} expect(await tools.addTools(tools_csv, '7.4', 'linux')).toContain(script);
`('checking addCastor: $version, $os', async ({version, os, uri}) => {
const data = getData({
tool: 'castor',
php_version: '8.1',
version_prefix: 'v',
version: version,
os: os
});
if (os === 'win32' && version === '0.5.1') {
fs.writeFileSync('castor.php', '');
expect(await tools.addCastor(data)).toContain(uri);
fs.unlinkSync('castor.php');
} else {
expect(await tools.addCastor(data)).toContain(uri);
}
}); });
it.each` it.each`
tools_csv | script tools_csv | token | script
${'none'} | ${''} ${'cs2pr:1.2'} | ${'invalid_token'} | ${'add_log "$cross" "cs2pr" "Invalid token"'}
${'none, phpunit'} | ${'\nstep_log "Setup Tools"\nadd_tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-7.4-stable.phar,https://artifacts.setup-php.com/composer/composer-7.4-stable.phar,https://dl.cloudsmith.io/public/shivammathur/composer-cache/raw/files/composer-7.4-stable.phar,https://getcomposer.org/composer-stable.phar composer latest\n\nadd_tool https://phar.phpunit.de/phpunit-7.4.0.phar,https://phar.phpunit.de/phpunit-7.phar phpunit "--version"'} ${'phpunit:1.2'} | ${'invalid_token'} | ${'add_log "$cross" "phpunit" "Invalid token"'}
${'composer:preview'} | ${'add_tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-7.4-preview.phar,https://artifacts.setup-php.com/composer/composer-7.4-preview.phar,https://dl.cloudsmith.io/public/shivammathur/composer-cache/raw/files/composer-7.4-preview.phar,https://getcomposer.org/composer-preview.phar composer preview'} ${'phpunit:0.1'} | ${'no_data'} | ${'add_log "$cross" "phpunit" "No version found with prefix 0.1."'}
${'composer, composer:v1'} | ${'add_tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-7.4-1.phar,https://artifacts.setup-php.com/composer/composer-7.4-1.phar,https://dl.cloudsmith.io/public/shivammathur/composer-cache/raw/files/composer-7.4-1.phar,https://getcomposer.org/composer-1.phar composer'} `('checking error: $tools_csv', async ({tools_csv, token, script}) => {
${'composer:v1, composer:preview, composer:snapshot'} | ${'add_tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-7.4-snapshot.phar,https://artifacts.setup-php.com/composer/composer-7.4-snapshot.phar,https://dl.cloudsmith.io/public/shivammathur/composer-cache/raw/files/composer-7.4-snapshot.phar,https://getcomposer.org/composer.phar composer snapshot'} process.env['COMPOSER_TOKEN'] = token;
`('checking composer setup: $tools_csv', async ({tools_csv, script}) => {
expect(await tools.addTools(tools_csv, '7.4', 'linux')).toContain(script); expect(await tools.addTools(tools_csv, '7.4', 'linux')).toContain(script);
}); });
@ -655,61 +538,4 @@ describe('Tools tests', () => {
process.env['GITHUB_TOKEN'] = token; process.env['GITHUB_TOKEN'] = token;
expect(await tools.addTools(tools_csv, '7.4', 'linux')).toContain(script); expect(await tools.addTools(tools_csv, '7.4', 'linux')).toContain(script);
}); });
it('checking error when custom-function tool is missing function field', async () => {
const brokenToolsJson = JSON.stringify({
composer: {
type: 'custom-function',
domain: 'https://getcomposer.org',
repository: 'composer/composer',
function: 'composer'
},
'broken-tool': {
type: 'custom-function'
}
});
let result: string = '';
await jest.isolateModulesAsync(async () => {
jest.doMock('fs', () => ({
...jest.requireActual('fs'),
readFileSync: (
filePath: fs.PathOrFileDescriptor,
options?: unknown
) => {
if (String(filePath).includes('tools.json')) {
return brokenToolsJson;
}
return (jest.requireActual('fs') as typeof fs).readFileSync(
filePath,
options as fs.ObjectEncodingOptions & {flag?: string}
);
}
}));
const isolatedTools = await import('../src/tools');
result = await isolatedTools.addTools('broken-tool', '7.4', 'linux');
});
expect(result).toContain(
'add_log "$cross" "broken-tool" "broken-tool has no function defined. Please report this issue."'
);
});
it.each`
tools_csv | php_version | resolved
${'phpunit'} | ${'8.2'} | ${'/phpunit-8.2.0.phar'}
${'phpunit'} | ${'8.1'} | ${'/phpunit-8.1.0.phar'}
${'phpunit'} | ${'8.0'} | ${'/phpunit-8.0.0.phar'}
${'phpunit'} | ${'7.3'} | ${'/phpunit-7.3.0.phar'}
${'phpunit'} | ${'7.2'} | ${'/phpunit-7.2.0.phar'}
${'phpunit'} | ${'7.1'} | ${'/phpunit-7.1.0.phar'}
${'phpunit'} | ${'7.0'} | ${'/phpunit-7.0.0.phar'}
`(
'checking error: $tools_csv',
async ({tools_csv, php_version, resolved}) => {
expect(await tools.addTools(tools_csv, php_version, 'linux')).toContain(
resolved
);
}
);
}); });

View File

@ -1,7 +1,23 @@
import 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';
import * as fetchModule from '../src/fetch';
/**
* Mock @actions/core
*/
jest.mock('@actions/core', () => ({
getInput: jest.fn().mockImplementation(key => {
return ['setup-php'].indexOf(key) !== -1 ? key : '';
})
}));
/**
* Mock fetch.ts
*/
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 () => {
@ -16,38 +32,24 @@ describe('Utils tests', () => {
it('checking getInput', async () => { it('checking getInput', async () => {
process.env['test'] = 'setup-php'; process.env['test'] = 'setup-php';
process.env['INPUT_SETUP-PHP'] = 'setup-php';
expect(await utils.getInput('test', false)).toBe('setup-php'); expect(await utils.getInput('test', false)).toBe('setup-php');
expect(await utils.getInput('setup-php', false)).toBe('setup-php'); expect(await utils.getInput('setup-php', false)).toBe('setup-php');
expect(await utils.getInput('DoesNotExist', false)).toBe(''); expect(await utils.getInput('DoesNotExist', false)).toBe('');
await expect(async () => { await expect(async () => {
await utils.getInput('DoesNotExist', true); await utils.getInput('DoesNotExist', true);
}).rejects.toThrow('Input required and not supplied: DoesNotExist'); }).rejects.toThrow('Input required and not supplied: DoesNotExist');
delete process.env['INPUT_SETUP-PHP'];
}); });
it('checking getManifestURL', async () => { it('checking getManifestURL', async () => {
for (const url of await utils.getManifestURLS()) { expect(await utils.getManifestURL()).toContain('php-versions.json');
expect(url).toContain('php-versions.json');
}
}); });
it('checking parseVersion', async () => { it('checking parseVersion', async () => {
const fetchSpy = jest
.spyOn(fetchModule, 'fetch')
.mockResolvedValue({data: '{ "latest": "8.1", "5.x": "5.6" }'});
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');
expect(await utils.parseVersion('5.x')).toBe('5.6'); expect(await utils.parseVersion('5.x')).toBe('5.6');
expect(await utils.parseVersion('4.x')).toBe(undefined); expect(await utils.parseVersion('4.x')).toBe(undefined);
fetchSpy.mockReset();
fetchSpy.mockResolvedValueOnce({}).mockResolvedValueOnce({});
await expect(utils.parseVersion('latest')).rejects.toThrow(
'Could not fetch the PHP version manifest.'
);
expect(fetchSpy).toHaveBeenCalledTimes(2);
}); });
it('checking parseIniFile', async () => { it('checking parseIniFile', async () => {
@ -107,9 +109,6 @@ describe('Utils tests', () => {
expect( expect(
await utils.CSVArray('a=E_ALL, b=E_ALL & ~ E_ALL, c="E_ALL", d=\'E_ALL\'') await utils.CSVArray('a=E_ALL, b=E_ALL & ~ E_ALL, c="E_ALL", d=\'E_ALL\'')
).toEqual(['a=E_ALL', 'b=E_ALL & ~ E_ALL', 'c=E_ALL', 'd=E_ALL']); ).toEqual(['a=E_ALL', 'b=E_ALL & ~ E_ALL', 'c=E_ALL', 'd=E_ALL']);
expect(
await utils.CSVArray('a="b=c;d=e", b=\'c=d,e\', c="g=h,i=j", d=g=h, a===')
).toEqual(["a='b=c;d=e'", "b='c=d,e'", "c='g=h,i=j'", "d='g=h'", "a='=='"]);
expect(await utils.CSVArray('')).toEqual([]); expect(await utils.CSVArray('')).toEqual([]);
expect(await utils.CSVArray(' ')).toEqual([]); expect(await utils.CSVArray(' ')).toEqual([]);
}); });
@ -191,7 +190,6 @@ describe('Utils tests', () => {
expect(await utils.getCommand('linux', 'tool')).toBe('add_tool '); expect(await utils.getCommand('linux', 'tool')).toBe('add_tool ');
expect(await utils.getCommand('darwin', 'tool')).toBe('add_tool '); expect(await utils.getCommand('darwin', 'tool')).toBe('add_tool ');
expect(await utils.getCommand('win32', 'tool')).toBe('Add-Tool '); expect(await utils.getCommand('win32', 'tool')).toBe('Add-Tool ');
expect(await utils.getCommand('win32', 'tool_name')).toBe('Add-ToolName ');
expect(await utils.getCommand('openbsd', 'tool')).toContain( expect(await utils.getCommand('openbsd', 'tool')).toContain(
'Platform openbsd is not supported' 'Platform openbsd is not supported'
); );
@ -259,55 +257,6 @@ describe('Utils tests', () => {
); );
}); });
it('checking readPHPVersion', async () => {
expect(await utils.readPHPVersion()).toBe('latest');
process.env['php-version-file'] = '.phpenv-version';
await expect(utils.readPHPVersion()).rejects.toThrow(
"Could not find '.phpenv-version' file."
);
const existsSync = jest.spyOn(fs, 'existsSync').mockImplementation();
const readFileSync = jest.spyOn(fs, 'readFileSync').mockImplementation();
existsSync.mockReturnValue(true);
readFileSync.mockReturnValue('8.1');
expect(await utils.readPHPVersion()).toBe('8.1');
process.env['php-version'] = '8.2';
expect(await utils.readPHPVersion()).toBe('8.2');
delete process.env['php-version-file'];
delete process.env['php-version'];
existsSync.mockReturnValue(true);
readFileSync.mockReturnValue('ruby 1.2.3\nphp 8.4.2\nnode 20.1.2');
expect(await utils.readPHPVersion()).toBe('8.4.2');
existsSync.mockReturnValue(true);
readFileSync.mockReturnValue('setup-php');
expect(await utils.readPHPVersion()).toBe('setup-php');
existsSync.mockReturnValueOnce(false).mockReturnValueOnce(true);
readFileSync.mockReturnValue(
'{ "platform-overrides": { "php": "7.3.25" } }'
);
expect(await utils.readPHPVersion()).toBe('7.3.25');
existsSync
.mockReturnValueOnce(false)
.mockReturnValueOnce(false)
.mockReturnValueOnce(true);
readFileSync.mockReturnValue(
'{ "config": { "platform": { "php": "7.4.33" } } }'
);
expect(await utils.readPHPVersion()).toBe('7.4.33');
existsSync.mockClear();
readFileSync.mockClear();
});
it('checking setVariable', async () => { it('checking setVariable', async () => {
let script: string = await utils.setVariable('var', 'command', 'linux'); let script: string = await utils.setVariable('var', 'command', 'linux');
expect(script).toEqual('\nvar="$(command)"\n'); expect(script).toEqual('\nvar="$(command)"\n');

View File

@ -7,17 +7,15 @@ branding:
inputs: inputs:
php-version: php-version:
description: 'Setup PHP version.' description: 'Setup PHP version.'
required: false default: '8.1'
php-version-file: required: true
description: 'Setup PHP version from a file.'
required: false
extensions: extensions:
description: 'Setup PHP extensions.' description: 'Setup PHP extensions.'
required: false required: false
ini-file: ini-file:
description: 'Set base ini file.' description: 'Set base ini file.'
required: false
default: 'production' default: 'production'
required: false
ini-values: ini-values:
description: 'Add values to php.ini.' description: 'Add values to php.ini.'
required: false required: false
@ -27,12 +25,9 @@ inputs:
tools: tools:
description: 'Setup popular tools globally.' description: 'Setup popular tools globally.'
required: false required: false
github-token:
description: 'GitHub token to use for authentication.'
default: ${{ github.token }}
outputs: outputs:
php-version: php-version:
description: 'PHP version in semver format' description: 'PHP version in semver format'
runs: runs:
using: 'node24' using: 'node16'
main: 'dist/index.js' main: 'dist/index.js'

4721
dist/index.js vendored

File diff suppressed because one or more lines are too long

View File

@ -1,49 +0,0 @@
import typescriptEslint from '@typescript-eslint/eslint-plugin';
import importPlugin from 'eslint-plugin-import';
import jest from 'eslint-plugin-jest';
import prettierRecommended from 'eslint-plugin-prettier/recommended';
import eslintConfigPrettier from 'eslint-config-prettier';
import globals from 'globals';
import tsParser from '@typescript-eslint/parser';
import js from '@eslint/js';
export default [
js.configs.recommended,
...typescriptEslint.configs['flat/recommended'],
importPlugin.flatConfigs.errors,
importPlugin.flatConfigs.warnings,
importPlugin.flatConfigs.typescript,
prettierRecommended,
eslintConfigPrettier,
{
plugins: {
jest
},
languageOptions: {
globals: {
...globals.node,
...globals.jest
},
parser: tsParser,
ecmaVersion: 2021,
sourceType: 'module'
},
settings: {
'import/resolver': {
typescript: {
alwaysTryTypes: true,
project: './tsconfig.json'
},
node: {
extensions: ['.js', '.ts']
}
},
'import/parsers': {
'@typescript-eslint/parser': ['.ts']
}
}
}
];

View File

@ -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@v6 uses: actions/checkout@v3
# Docs: https://github.com/shivammathur/setup-php # Docs: https://github.com/shivammathur/setup-php
- name: Setup PHP - name: Setup PHP
@ -21,7 +21,7 @@ jobs:
- name: Get composer cache directory - name: Get composer cache directory
id: composer-cache id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- uses: actions/cache@v3 - uses: actions/cache@v3
with: with:

View File

@ -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@v6 uses: actions/checkout@v3
# Docs: https://github.com/shivammathur/setup-php # Docs: https://github.com/shivammathur/setup-php
- name: Setup PHP - name: Setup PHP

View File

@ -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@v6 uses: actions/checkout@v3
# Docs: https://github.com/shivammathur/setup-php # Docs: https://github.com/shivammathur/setup-php
- name: Setup PHP - name: Setup PHP

View File

@ -28,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@v6 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,7 +47,7 @@ jobs:
- name: Get composer cache directory - name: Get composer cache directory
id: composer-cache id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache composer dependencies - name: Cache composer dependencies
uses: actions/cache@v3 uses: actions/cache@v3
@ -75,7 +75,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v6 uses: actions/checkout@v3
# Docs: https://github.com/shivammathur/setup-php # Docs: https://github.com/shivammathur/setup-php
- name: Setup PHP - name: Setup PHP
@ -86,7 +86,7 @@ jobs:
- name: Get composer cache directory - name: Get composer cache directory
id: composer-cache id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache composer dependencies - name: Cache composer dependencies
uses: actions/cache@v3 uses: actions/cache@v3
@ -108,7 +108,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v6 uses: actions/checkout@v3
# Docs: https://github.com/shivammathur/setup-php # Docs: https://github.com/shivammathur/setup-php
- name: Setup PHP - name: Setup PHP
@ -120,7 +120,7 @@ jobs:
- name: Get composer cache directory - name: Get composer cache directory
id: composer-cache id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache composer dependencies - name: Cache composer dependencies
uses: actions/cache@v3 uses: actions/cache@v3

View File

@ -28,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@v6 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,7 +47,7 @@ jobs:
- name: Get composer cache directory - name: Get composer cache directory
id: composer-cache id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache composer dependencies - name: Cache composer dependencies
uses: actions/cache@v3 uses: actions/cache@v3
@ -75,7 +75,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v6 uses: actions/checkout@v3
# Docs: https://github.com/shivammathur/setup-php # Docs: https://github.com/shivammathur/setup-php
- name: Setup PHP - name: Setup PHP
@ -86,7 +86,7 @@ jobs:
- name: Get composer cache directory - name: Get composer cache directory
id: composer-cache id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache composer dependencies - name: Cache composer dependencies
uses: actions/cache@v3 uses: actions/cache@v3
@ -108,7 +108,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v6 uses: actions/checkout@v3
# Docs: https://github.com/shivammathur/setup-php # Docs: https://github.com/shivammathur/setup-php
- name: Setup PHP - name: Setup PHP
@ -120,7 +120,7 @@ jobs:
- name: Get composer cache directory - name: Get composer cache directory
id: composer-cache id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache composer dependencies - name: Cache composer dependencies
uses: actions/cache@v3 uses: actions/cache@v3

View File

@ -11,7 +11,7 @@ jobs:
runs-on: ${{ matrix.operating-system }} runs-on: ${{ matrix.operating-system }}
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v6 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:
- name: Get composer cache directory - name: Get composer cache directory
id: composer-cache id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache composer dependencies - name: Cache composer dependencies
uses: actions/cache@v3 uses: actions/cache@v3
@ -47,7 +47,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v6 uses: actions/checkout@v3
# Docs: https://github.com/shivammathur/setup-php # Docs: https://github.com/shivammathur/setup-php
- name: Setup PHP - name: Setup PHP
@ -57,7 +57,7 @@ jobs:
extensions: mbstring, intl extensions: mbstring, intl
- name: Get composer cache directory - name: Get composer cache directory
id: composer-cache id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache composer dependencies - name: Cache composer dependencies
uses: actions/cache@v3 uses: actions/cache@v3
@ -79,7 +79,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v6 uses: actions/checkout@v3
# Docs: https://github.com/shivammathur/setup-php # Docs: https://github.com/shivammathur/setup-php
- name: Setup PHP - name: Setup PHP
@ -91,7 +91,7 @@ jobs:
- name: Get composer cache directory - name: Get composer cache directory
id: composer-cache id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache composer dependencies - name: Cache composer dependencies
uses: actions/cache@v3 uses: actions/cache@v3

View File

@ -10,7 +10,7 @@ jobs:
runs-on: ${{ matrix.operating-system }} runs-on: ${{ matrix.operating-system }}
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v6 uses: actions/checkout@v3
# Docs: https://github.com/shivammathur/setup-php # Docs: https://github.com/shivammathur/setup-php
- name: Setup PHP - name: Setup PHP
@ -22,7 +22,7 @@ jobs:
- name: Get composer cache directory - name: Get composer cache directory
id: composer-cache id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache composer dependencies - name: Cache composer dependencies
uses: actions/cache@v3 uses: actions/cache@v3

View File

@ -10,7 +10,7 @@ jobs:
runs-on: ${{ matrix.operating-system }} runs-on: ${{ matrix.operating-system }}
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v6 uses: actions/checkout@v3
# Docs: https://github.com/shivammathur/setup-php # Docs: https://github.com/shivammathur/setup-php
- name: Setup PHP - name: Setup PHP
@ -21,7 +21,7 @@ jobs:
- name: Get composer cache directory - name: Get composer cache directory
id: composer-cache id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache composer dependencies - name: Cache composer dependencies
uses: actions/cache@v3 uses: actions/cache@v3

View File

@ -37,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@v6 uses: actions/checkout@v3
# Docs: https://github.com/shivammathur/setup-php # Docs: https://github.com/shivammathur/setup-php
- name: Setup PHP - name: Setup PHP
@ -54,7 +54,7 @@ jobs:
- name: Get composer cache directory - name: Get composer cache directory
id: composer-cache id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache composer dependencies - name: Cache composer dependencies
uses: actions/cache@v3 uses: actions/cache@v3

View File

@ -39,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@v6 uses: actions/checkout@v3
# Docs: https://github.com/shivammathur/setup-php # Docs: https://github.com/shivammathur/setup-php
- name: Setup PHP - name: Setup PHP
@ -56,7 +56,7 @@ jobs:
- name: Get composer cache directory - name: Get composer cache directory
id: composer-cache id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache composer dependencies - name: Cache composer dependencies
uses: actions/cache@v3 uses: actions/cache@v3

View File

@ -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@v6 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:
- name: Get composer cache directory - name: Get composer cache directory
id: composer-cache id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache composer dependencies - name: Cache composer dependencies
uses: actions/cache@v3 uses: actions/cache@v3

View File

@ -37,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@v6 uses: actions/checkout@v3
# Docs: https://github.com/shivammathur/setup-php # Docs: https://github.com/shivammathur/setup-php
- name: Setup PHP - name: Setup PHP
@ -54,7 +54,7 @@ jobs:
- name: Get composer cache directory - name: Get composer cache directory
id: composer-cache id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache composer dependencies - name: Cache composer dependencies
uses: actions/cache@v3 uses: actions/cache@v3

View File

@ -39,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@v6 uses: actions/checkout@v3
# Docs: https://github.com/shivammathur/setup-php # Docs: https://github.com/shivammathur/setup-php
- name: Setup PHP - name: Setup PHP
@ -56,7 +56,7 @@ jobs:
- name: Get composer cache directory - name: Get composer cache directory
id: composer-cache id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache composer dependencies - name: Cache composer dependencies
uses: actions/cache@v3 uses: actions/cache@v3

View File

@ -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@v6 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:
- name: Get composer cache directory - name: Get composer cache directory
id: composer-cache id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache composer dependencies - name: Cache composer dependencies
uses: actions/cache@v3 uses: actions/cache@v3

View File

@ -36,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@v6 uses: actions/checkout@v3
# Docs: https://github.com/shivammathur/setup-php # Docs: https://github.com/shivammathur/setup-php
- name: Setup PHP - name: Setup PHP
@ -54,7 +54,7 @@ jobs:
- name: Get composer cache directory - name: Get composer cache directory
id: composer-cache id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache composer dependencies - name: Cache composer dependencies
uses: actions/cache@v3 uses: actions/cache@v3

View File

@ -37,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@v6 uses: actions/checkout@v3
# Docs: https://github.com/shivammathur/setup-php # Docs: https://github.com/shivammathur/setup-php
- name: Setup PHP - name: Setup PHP
@ -55,7 +55,7 @@ jobs:
- name: Get composer cache directory - name: Get composer cache directory
id: composer-cache id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache composer dependencies - name: Cache composer dependencies
uses: actions/cache@v3 uses: actions/cache@v3
with: with:

View File

@ -9,13 +9,13 @@ jobs:
fail-fast: false fail-fast: false
matrix: matrix:
php-versions: ['7.4', '8.0', '8.1'] php-versions: ['7.4', '8.0', '8.1']
node-versions: ['16'] node-versions: [16']
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v6 uses: actions/checkout@v3
- name: Setup Node.js - name: Setup Node.js
uses: actions/setup-node@v5 uses: actions/setup-node@v1
with: with:
node-version: ${{ matrix.node-versions }} node-version: ${{ matrix.node-versions }}
@ -31,7 +31,7 @@ jobs:
- name: Get yarn cache - name: Get yarn cache
id: yarn-cache id: yarn-cache
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v3 - uses: actions/cache@v3
with: with:
@ -41,7 +41,7 @@ jobs:
- name: Get composer cache directory - name: Get composer cache directory
id: composer-cache id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache composer dependencies - name: Cache composer dependencies
uses: actions/cache@v3 uses: actions/cache@v3

View File

@ -10,7 +10,7 @@ jobs:
runs-on: ${{ matrix.operating-system }} runs-on: ${{ matrix.operating-system }}
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v6 uses: actions/checkout@v3
# Docs: https://github.com/shivammathur/setup-php # Docs: https://github.com/shivammathur/setup-php
- name: Setup PHP - name: Setup PHP
@ -22,7 +22,7 @@ jobs:
- name: Get composer cache directory - name: Get composer cache directory
id: composer-cache id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache composer dependencies - name: Cache composer dependencies
uses: actions/cache@v3 uses: actions/cache@v3

View File

@ -23,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@v6 uses: actions/checkout@v3
# Docs: https://github.com/shivammathur/setup-php # Docs: https://github.com/shivammathur/setup-php
- name: Setup PHP - name: Setup PHP
@ -41,7 +41,7 @@ jobs:
- name: Get composer cache directory - name: Get composer cache directory
id: composer-cache id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache composer dependencies - name: Cache composer dependencies
uses: actions/cache@v3 uses: actions/cache@v3

View File

@ -23,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@v6 uses: actions/checkout@v3
# Docs: https://github.com/shivammathur/setup-php # Docs: https://github.com/shivammathur/setup-php
- name: Setup PHP - name: Setup PHP
@ -41,7 +41,7 @@ jobs:
- name: Get composer cache directory - name: Get composer cache directory
id: composer-cache id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache composer dependencies - name: Cache composer dependencies
uses: actions/cache@v3 uses: actions/cache@v3

View File

@ -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@v6 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:
- name: Get composer cache directory - name: Get composer cache directory
id: composer-cache id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache composer dependencies - name: Cache composer dependencies
uses: actions/cache@v3 uses: actions/cache@v3

View File

@ -29,10 +29,10 @@ jobs:
php-versions: ['7.4', '8.0'] php-versions: ['7.4', '8.0']
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v6 uses: actions/checkout@v3
- name: Set Node.js 10.x - name: Set Node.js 10.x
uses: actions/setup-node@v5 uses: actions/setup-node@v1
with: with:
node-version: 10.x node-version: 10.x
@ -51,7 +51,7 @@ jobs:
- name: Get composer cache directory - name: Get composer cache directory
id: composer-cache id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache composer dependencies - name: Cache composer dependencies
uses: actions/cache@v3 uses: actions/cache@v3

View File

@ -29,10 +29,10 @@ jobs:
php-versions: ['7.4', '8.0'] php-versions: ['7.4', '8.0']
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v6 uses: actions/checkout@v3
- name: Set Node.js 10.x - name: Set Node.js 10.x
uses: actions/setup-node@v5 uses: actions/setup-node@v1
with: with:
node-version: 10.x node-version: 10.x
@ -51,7 +51,7 @@ jobs:
- name: Get composer cache directory - name: Get composer cache directory
id: composer-cache id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache composer dependencies - name: Cache composer dependencies
uses: actions/cache@v3 uses: actions/cache@v3

11188
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
{ {
"name": "setup-php", "name": "setup-php",
"version": "2.36.0", "version": "2.21.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",
@ -19,7 +19,7 @@
"lint": "eslint **/src/*.ts **/__tests__/*.ts --cache --fix", "lint": "eslint **/src/*.ts **/__tests__/*.ts --cache --fix",
"format": "prettier --write **/src/*.ts **/__tests__/*.ts && git add -f __tests__/ ", "format": "prettier --write **/src/*.ts **/__tests__/*.ts && git add -f __tests__/ ",
"format-check": "prettier --check **/src/*.ts **/__tests__/*.ts", "format-check": "prettier --check **/src/*.ts **/__tests__/*.ts",
"release": "ncc build -m -o dist && git add -f dist/", "release": "ncc build -o dist && git add -f dist/",
"test": "jest" "test": "jest"
}, },
"repository": { "repository": {
@ -34,36 +34,28 @@
"author": "shivammathur", "author": "shivammathur",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@actions/exec": "^2.0.0", "@actions/core": "^1.9.0",
"compare-versions": "^6.1.1" "@actions/exec": "^1.1.1",
"@actions/io": "^1.1.2"
}, },
"devDependencies": { "devDependencies": {
"@eslint/compat": "^2.0.2", "@types/jest": "^28.1.6",
"@eslint/js": "^9.39.1", "@types/node": "^18.0.6",
"@types/jest": "^30.0.0", "@typescript-eslint/eslint-plugin": "^5.30.7",
"@types/node": "^25.2.2", "@typescript-eslint/parser": "^5.30.7",
"@typescript-eslint/eslint-plugin": "^8.54.0", "@vercel/ncc": "^0.34.0",
"@typescript-eslint/parser": "^8.54.0", "eslint": "^8.20.0",
"@vercel/ncc": "^0.38.4", "eslint-config-prettier": "^8.5.0",
"eslint": "^9.39.1", "eslint-plugin-import": "^2.26.0",
"eslint-config-prettier": "^10.1.8", "eslint-plugin-jest": "^26.6.0",
"eslint-import-resolver-typescript": "^4.4.4", "eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-import": "^2.32.0", "jest": "^28.1.3",
"eslint-plugin-jest": "^29.12.2", "jest-circus": "^28.1.3",
"eslint-plugin-prettier": "^5.5.5", "nock": "^13.2.8",
"globals": "^17.3.0", "prettier": "^2.7.1",
"jest": "^30.2.0", "simple-git-hooks": "^2.8.0",
"jest-circus": "^30.2.0", "ts-jest": "^28.0.7",
"nock": "^14.0.10", "typescript": "^4.7.4"
"prettier": "^3.8.1",
"simple-git-hooks": "^2.13.1",
"ts-jest": "^29.4.6",
"typescript": "^5.9.3"
},
"overrides": {
"test-exclude": "^7.0.1",
"glob": "^11.1.0",
"minimatch": "^10.2.1"
}, },
"bugs": { "bugs": {
"url": "https://github.com/shivammathur/setup-php/issues" "url": "https://github.com/shivammathur/setup-php/issues"

View File

@ -1,65 +1,35 @@
amqp=amqp amqp=amqp
apcu=apcu apcu=apcu
ast=ast
brotli=brotli
couchbase=couchbase couchbase=couchbase
ds=ds
event=event event=event
excimer=excimer
expect=expect expect=expect
gearman=gearman
gmagick=gmagick
gnupg=gnupg gnupg=gnupg
grpc=grpc grpc=grpc
igbinary=igbinary igbinary=igbinary
imagick=imagick imagick=imagick
imap=imap imap=imap
interbase=interbase
lua=lua
mailparse=mailparse mailparse=mailparse
maxminddb=maxminddb
mcrypt=mcrypt mcrypt=mcrypt
memcache=memcache memcache=memcache
memcached=memcached memcached=memcached
mongodb=mongodb mongodb=mongodb
mongodb1=mongodb1
msgpack=msgpack msgpack=msgpack
newrelic=newrelic
oauth=oauth
opentelemetry=opentelemetry
pcov=pcov pcov=pcov
pdo_firebird=pdo_firebird
pdo_sqlsrv=pdo_sqlsrv
pecl_http=http pecl_http=http
phalcon3=phalcon phalcon3=phalcon
phalcon4=phalcon phalcon4=phalcon
phalcon5=phalcon phalcon5=phalcon
pinba=pinba
propro=propro propro=propro
protobuf=protobuf protobuf=protobuf
psr=psr psr=psr
raphf=raphf raphf=raphf
rdkafka=rdkafka rdkafka=rdkafka
phpredis=redis
redis=redis redis=redis
seaslog=seaslog
scalar_objects=scalar_objects
snmp=snmp
sqlsrv=sqlsrv
spx=spx
ssh2=ssh2 ssh2=ssh2
swoole=swoole swoole=swoole
swow=swow
uopz=uopz
uploadprogress=uploadprogress
uuid=uuid
v8js=v8js
vips=vips vips=vips
vld=vld
xdebug=xdebug xdebug=xdebug
xdebug2=xdebug xdebug2=xdebug
xhprof=xhprof
xlswriter=xlswriter xlswriter=xlswriter
yaml=yaml yaml=yaml
zmq=zmq zmq=zmq
zstd=zstd

View File

@ -1,3 +1,2 @@
COMPOSER_PROCESS_TIMEOUT=0 COMPOSER_PROCESS_TIMEOUT=0
COMPOSER_NO_INTERACTION=1 COMPOSER_NO_INTERACTION=1
COMPOSER_NO_AUDIT=1

View File

@ -1,22 +0,0 @@
amqp=rabbitmq-c
decimal=mpdecimal
ev=libev
event=libevent
geoip=geoip
gmagick=graphicsmagick
gnupg=gpgme
grpc=grpc protobuf
imagick=imagemagick
memcached=libmemcached libevent
protobuf=protobuf
rdkafka=librdkafka
snappy=snappy
sodium=libsodium
ssh2=libssh2
uv=libuv
uuid=util-linux
vips=vips
yaz=yaz
yaml=libyaml
zstd=zstd
zmq=zeromq

View File

@ -1,3 +0,0 @@
opcache.enable=1
opcache.jit_buffer_size=128M
opcache.jit=1235

View File

@ -1,22 +0,0 @@
amqp=librabbitmq-dev
decimal=libmpdec-dev
ev=libev-dev
event=libevent-dev
geoip=libgeoip-dev
gmagick=graphicsmagick-libmagick-dev-compat
gnupg=libgpgme-dev
grpc=libgrpc-dev libprotobuf-dev protobuf-compiler
imagick=libmagickwand-dev libmagickcore-dev
memcached=libmemcached-dev libevent-dev
protobuf=libprotobuf-dev protobuf-compiler
rdkafka=librdkafka-dev
snappy=libsnappy-dev
sodium=libsodium-dev
ssh2=libssh2-1-dev
uv=libuv1-dev
uuid=uuid-dev
vips=libvips-dev
yaz=libyaz-dev
yaml=libyaml-dev
zstd=libzstd-dev
zmq=libzmq3-dev

View File

@ -1,31 +0,0 @@
apc=25
apcu_bc=25
apcu-bc=25
blackfire=30
couchbase=30
decimal=30
ds=30
event=30
ev=30
grpc=30
http=25
pecl_http=25
pecl-http=25
inotify=30
libvirt-php=40
mailparse=25
maxminddb=30
memcached=25
mysqlnd=10
mysqlnd_ms=30
opcache=10
openswoole=25
pdo=10
phalcon=35
protobuf=30
psr=15
rdkafka=30
swoole=25
vips=30
xml=15
zstd=30

View File

@ -17,8 +17,3 @@
21.04,hirsute 21.04,hirsute
21.10,impish 21.10,impish
22.04,jammy 22.04,jammy
23.04,lunar
23.10,mantic
24.04,noble
24.10,oracular
25.10,plucky

1 8 jessie
17 21.04 hirsute
18 21.10 impish
19 22.04 jammy
23.04 lunar
23.10 mantic
24.04 noble
24.10 oracular
25.10 plucky

View File

@ -1,10 +1,7 @@
{ {
"lowest": "8.1", "latest": "8.1",
"highest": "8.5", "nightly": "8.2",
"latest": "8.5",
"nightly": "8.6",
"master": "8.6",
"5.x": "5.6", "5.x": "5.6",
"7.x": "7.4", "7.x": "7.4",
"8.x": "8.5" "8.x": "8.1"
} }

View File

@ -1,11 +0,0 @@
cgi
cli
curl
fpm
intl
mbstring
mysql
opcache
pgsql
xml
zip

View File

@ -1,18 +1,4 @@
{ {
"backward-compatibility-check": {
"type": "composer",
"repository": "roave/backward-compatibility-check",
"scope": "scoped"
},
"box": {
"type": "phar",
"repository": "box-project/box",
"packagist": "humbug/box",
"extension": ".phar",
"domain": "https://github.com",
"version_prefix": "",
"version_parameter": "--version"
},
"churn": { "churn": {
"type": "phar", "type": "phar",
"repository": "bmitch/churn-php", "repository": "bmitch/churn-php",
@ -21,26 +7,13 @@
"version_prefix": "", "version_prefix": "",
"version_parameter": "-V" "version_parameter": "-V"
}, },
"composer-dependency-analyser": {
"type": "composer",
"repository": "shipmonk/composer-dependency-analyser",
"scope": "scoped"
},
"composer-unused": {
"type": "phar",
"repository": "composer-unused/composer-unused",
"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",
"extension": ".phar", "extension": ".phar",
"domain": "https://github.com", "domain": "https://github.com",
"version_prefix": "", "version_prefix": "",
"version_parameter": "diagnose" "version_parameter": "-V"
}, },
"cs2pr": { "cs2pr": {
"type": "phar", "type": "phar",
@ -50,12 +23,6 @@
"version_prefix": "", "version_prefix": "",
"version_parameter": "-V" "version_parameter": "-V"
}, },
"easy-coding-standard": {
"type": "composer",
"alias": "ecs",
"repository": "symplify/easy-coding-standard",
"scope": "scoped"
},
"infection": { "infection": {
"type": "phar", "type": "phar",
"repository": "infection/infection", "repository": "infection/infection",
@ -64,11 +31,6 @@
"version_prefix": "", "version_prefix": "",
"version_parameter": "-V" "version_parameter": "-V"
}, },
"name-collision-detector": {
"type": "composer",
"repository": "shipmonk/name-collision-detector",
"scope": "scoped"
},
"phan": { "phan": {
"type": "phar", "type": "phar",
"repository": "phan/phan", "repository": "phan/phan",
@ -87,25 +49,16 @@
}, },
"php-cs-fixer": { "php-cs-fixer": {
"type": "phar", "type": "phar",
"repository": "PHP-CS-Fixer/PHP-CS-Fixer", "repository": "FriendsOfPHP/PHP-CS-Fixer",
"extension": ".phar", "extension": ".phar",
"domain": "https://github.com", "domain": "https://github.com",
"fetch_latest": "true", "fetch_latest": "true",
"version_prefix": "v", "version_prefix": "v",
"version_parameter": "-V" "version_parameter": "-V"
}, },
"php-scoper": {
"type": "phar",
"repository": "humbug/php-scoper",
"packagist": "humbug/php-scoper",
"extension": ".phar",
"domain": "https://github.com",
"version_prefix": "",
"version_parameter": "--version"
},
"phpcbf": { "phpcbf": {
"type": "phar", "type": "phar",
"repository": "PHPCSStandards/PHP_CodeSniffer", "repository": "squizlabs/PHP_CodeSniffer",
"extension": ".phar", "extension": ".phar",
"domain": "https://github.com", "domain": "https://github.com",
"version_prefix": "", "version_prefix": "",
@ -113,7 +66,7 @@
}, },
"phpcs": { "phpcs": {
"type": "phar", "type": "phar",
"repository": "PHPCSStandards/PHP_CodeSniffer", "repository": "squizlabs/PHP_CodeSniffer",
"extension": ".phar", "extension": ".phar",
"domain": "https://github.com", "domain": "https://github.com",
"version_prefix": "", "version_prefix": "",
@ -152,20 +105,12 @@
"version_prefix": "", "version_prefix": "",
"version_parameter": "-V" "version_parameter": "-V"
}, },
"pie": {
"type": "phar",
"repository": "php/pie",
"extension": ".phar",
"domain": "https://github.com",
"version_prefix": "",
"version_parameter": "-V"
},
"pint": { "pint": {
"type": "phar", "type": "phar",
"repository": "laravel/pint", "repository": "laravel/pint",
"extension": ".phar", "extension": ".phar",
"domain": "https://github.com", "domain": "https://github.com",
"version_prefix": "v", "version_prefix": "Pint ",
"version_parameter": "-V" "version_parameter": "-V"
}, },
"psalm": { "psalm": {
@ -197,6 +142,11 @@
"repository": "maglnet/composer-require-checker", "repository": "maglnet/composer-require-checker",
"scope": "scoped" "scope": "scoped"
}, },
"composer-unused": {
"type": "composer",
"repository": "icanhazstring/composer-unused",
"scope": "scoped"
},
"flex": { "flex": {
"type": "composer", "type": "composer",
"repository": "symfony/flex", "repository": "symfony/flex",
@ -234,11 +184,6 @@
"repository": "laravel/vapor-cli", "repository": "laravel/vapor-cli",
"scope": "scoped" "scope": "scoped"
}, },
"rector": {
"type": "composer",
"repository": "rector/rector",
"scope": "scoped"
},
"blackfire": { "blackfire": {
"type": "custom-package", "type": "custom-package",
"alias": "blackfire-agent" "alias": "blackfire-agent"
@ -249,12 +194,6 @@
"domain": "https://github.com", "domain": "https://github.com",
"version_prefix": "v" "version_prefix": "v"
}, },
"mago": {
"type": "custom-package",
"repository": "carthage-software/mago",
"domain": "https://github.com",
"version_prefix": ""
},
"protoc": { "protoc": {
"type": "custom-package", "type": "custom-package",
"repository": "protocolbuffers/protobuf", "repository": "protocolbuffers/protobuf",
@ -266,8 +205,7 @@
"type": "custom-package", "type": "custom-package",
"repository": "symfony-cli/symfony-cli", "repository": "symfony-cli/symfony-cli",
"domain": "https://github.com", "domain": "https://github.com",
"version_prefix": "v", "version_prefix": "-V"
"version_parameter": "-V"
}, },
"blackfire-player": { "blackfire-player": {
"type": "custom-function", "type": "custom-function",
@ -276,14 +214,6 @@
"version_prefix": "v", "version_prefix": "v",
"version_parameter": "-V" "version_parameter": "-V"
}, },
"castor": {
"type": "custom-function",
"domain": "https://github.com",
"repository": "jolicode/castor",
"function": "castor",
"version_prefix": "v",
"version_parameter": "-V"
},
"composer": { "composer": {
"type": "custom-function", "type": "custom-function",
"domain": "https://getcomposer.org", "domain": "https://getcomposer.org",
@ -330,7 +260,6 @@
"phpunit": { "phpunit": {
"type": "custom-function", "type": "custom-function",
"repository": "sebastianbergmann/phpunit", "repository": "sebastianbergmann/phpunit",
"packagist": "phpunit/phpunit",
"domain": "https://phar.phpunit.de", "domain": "https://phar.phpunit.de",
"function": "phpunit", "function": "phpunit",
"version_prefix": "", "version_prefix": "",
@ -355,4 +284,4 @@
"version_parameter": "--version", "version_parameter": "--version",
"version_prefix": "v" "version_prefix": "v"
} }
} }

View File

@ -13,7 +13,6 @@
"fetch_latest": "true", "fetch_latest": "true",
"function": "function_name", "function": "function_name",
"repository": "user/tool", "repository": "user/tool",
"packagist": "user/tool",
"scope": "global, scoped", "scope": "global, scoped",
"type": "phar, composer, custom-package or custom-function", "type": "phar, composer, custom-package or custom-function",
"version_parameter": "--version", "version_parameter": "--version",
@ -78,15 +77,6 @@
"user/tool" "user/tool"
] ]
}, },
"packagist": {
"$id": "#/items/properties/packagist",
"type": "string",
"title": "The repository schema",
"description": "Packagist repository of the tool in case different from repository.",
"examples": [
"user/tool"
]
},
"scope": { "scope": {
"$id": "#/items/properties/scope", "$id": "#/items/properties/scope",
"type": "string", "type": "string",

View File

@ -1,2 +0,0 @@
xdebug
pcov

View File

@ -1,112 +0,0 @@
import {EOL} from 'os';
/**
* Commands
*
* Command Format:
* ::name key=value,key=value::message
*
* @see https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions
*/
interface CommandProperties {
[key: string]: string;
}
/**
* Sanitizes the message for use in a workflow command.
* @param message
*/
function toCommandValue(message: string | Error): string {
if (message instanceof Error) {
return message.toString();
}
return message;
}
/**
* Escapes data for safe use in workflow command messages.
* @param s
*/
function escapeData(s: string | Error): string {
return toCommandValue(s)
.replace(/%/g, '%25')
.replace(/\r/g, '%0D')
.replace(/\n/g, '%0A');
}
/**
* Escapes property values for safe use in workflow command properties.
* @param s
*/
function escapeProperty(s: string): string {
return s
.replace(/%/g, '%25')
.replace(/\r/g, '%0D')
.replace(/\n/g, '%0A')
.replace(/:/g, '%3A')
.replace(/,/g, '%2C');
}
/**
* Issues a command to the GitHub Actions runner.
*
* @param command - The command name to issue
* @param properties - Additional properties for the command (key-value pairs)
* @param message - The message to include with the command
*/
export function issueCommand(
command: string,
properties: CommandProperties,
message: string | Error
): void {
let cmdStr = `::${command}`;
if (properties && Object.keys(properties).length > 0) {
cmdStr += ' ';
const props = Object.entries(properties)
.filter(([, val]) => val)
.map(([key, val]) => `${key}=${escapeProperty(val)}`)
.join(',');
cmdStr += props;
}
cmdStr += `::${escapeData(message)}`;
process.stdout.write(cmdStr + EOL);
}
/**
* Adds an error issue.
* @param message - error issue message
*/
export function error(message: string | Error): void {
issueCommand('error', {}, message);
}
/**
* Sets the action status to failed.
* When the action exits it will be with an exit code of 1.
* @param message - add error issue message
*/
export function setFailed(message: string | Error): void {
process.exitCode = 1;
error(message);
}
/**
* Gets the value of an input.
* The value is trimmed.
* Returns an empty string if the value is not defined.
*
* @param name - name of the input to get
* @param required - whether the input is required
* @returns string
*/
export function getInput(name: string, required = false): string {
const val: string =
process.env[`INPUT_${name.replace(/ /g, '_').toUpperCase()}`] || '';
if (required && !val) {
throw new Error(`Input required and not supplied: ${name}`);
}
return val.trim();
}

View File

@ -16,7 +16,7 @@ export async function checkXdebugError(
} }
/** /**
* Function to set up Xdebug * Function to setup Xdebug
* *
* @param extension * @param extension
* @param version * @param version
@ -30,8 +30,9 @@ export async function addCoverageXdebug(
pipe: string pipe: string
): Promise<string> { ): Promise<string> {
let script = '\n'; let script = '\n';
const error: string = await checkXdebugError(extension, version); let message: string = await checkXdebugError(extension, version);
if (!error) { let status = '$cross';
if (!message) {
script += script +=
(await extensions.addExtension(':pcov:false', version, os, true)) + pipe; (await extensions.addExtension(':pcov:false', version, os, true)) + pipe;
extension = extension == 'xdebug3' ? 'xdebug' : extension; extension = extension == 'xdebug3' ? 'xdebug' : extension;
@ -42,17 +43,15 @@ export async function addCoverageXdebug(
'php -r "echo phpversion(\'xdebug\');"', 'php -r "echo phpversion(\'xdebug\');"',
os os
); );
script += message = 'Xdebug $xdebug_version enabled as coverage driver';
(await utils.getCommand(os, 'extension_log')) + status = '$tick';
'xdebug "Xdebug $xdebug_version enabled as coverage driver"';
} else {
script += await utils.addLog('$cross', extension, error, os);
} }
script += await utils.addLog(status, extension, message, os);
return script; return script;
} }
/** /**
* Function to set up PCOV * Function to setup PCOV
* *
* @param version * @param version
* @param os * @param os
@ -77,9 +76,14 @@ export async function addCoveragePCOV(
'php -r "echo phpversion(\'pcov\');"', 'php -r "echo phpversion(\'pcov\');"',
os os
); );
script += // success
(await utils.getCommand(os, 'extension_log')) + script += await utils.addLog(
'pcov "PCOV $pcov_version enabled as coverage driver"'; '$tick',
'coverage: pcov',
'PCOV $pcov_version enabled as coverage driver',
os
);
// version is not supported
break; break;
case /5\.[3-6]|7\.0/.test(version): case /5\.[3-6]|7\.0/.test(version):

View File

@ -31,30 +31,22 @@ export async function addExtensionDarwin(
case /.+-.+\/.+@.+/.test(extension): case /.+-.+\/.+@.+/.test(extension):
add_script += await utils.parseExtensionSource(extension, ext_prefix); add_script += await utils.parseExtensionSource(extension, ext_prefix);
return; return;
// match 7.4relay...8.5relay // match 5.3blackfire...8.1blackfire
// match 5.3blackfire...8.5blackfire // match 5.3blackfire-(semver)...8.1blackfire-(semver)
// match 5.3blackfire-(semver)...8.5blackfire-(semver) // match couchbase, event, geos, pdo_oci, oci8, http, pecl_http
// match couchbase, event, geos, ibm_db2, pdo_ibm, pdo_oci, oci8, http, pecl_http // match 5.3ioncube...7.4ioncube
// match 5.3ioncube...8.4ioncube // match 7.0phalcon3...7.3phalcon3, 7.2phalcon4...7.4phalcon4, and 7.4phalcon5...8.2phalcon5
// match 7.0phalcon3...7.3phalcon3, 7.2phalcon4...7.4phalcon4, and 7.4phalcon5...8.4phalcon5 case /^(5\.[3-6]|7\.[0-4]|8\.[0-1])blackfire(-\d+\.\d+\.\d+)?$/.test(
// match 7.0zephir_parser...8.4zephir_parser
case /^(7\.4|8\.[0-5])relay(-v?\d+\.\d+\.\d+|-nightly)?$/.test(
version_extension version_extension
): ):
case /^(5\.[3-6]|7\.[0-4]|8\.[0-5])blackfire(-\d+\.\d+\.\d+)?$/.test( case /^couchbase|^event|^geos$|^pdo_oci$|^oci8$|^(pecl_)?http|^pdo_firebird$/.test(
version_extension
):
case /^couchbase|^event|^gearman$|^geos$|^ibm_db2$|^pdo_ibm$|^pdo_oci$|^oci8$|^(pecl_)?http|^pdo_firebird$/.test(
extension extension
): ):
case /^(5\.[3-6]|7\.[0-4]|8\.[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|(7\.4|8\.[0-4])phalcon5?/.test( case /(5\.6|7\.[0-3])phalcon3|7\.[2-4]phalcon4|(7\.4|8\.[0-2])phalcon5/.test(
version_extension version_extension
): ):
case /(?<!5\.[3-6])(pdo_)?sqlsrv$/.test(version_extension): case /(?<!5\.[3-6])(pdo_)?sqlsrv$/.test(version_extension):
case /^(7\.[0-4]|8\.[0-4])zephir_parser(-v?\d+\.\d+\.\d+)?$/.test(
version_extension
):
add_script += await utils.customPackage( add_script += await utils.customPackage(
ext_name, ext_name,
'extensions', 'extensions',
@ -72,7 +64,7 @@ export async function addExtensionDarwin(
); );
return; return;
// match semver // match semver
case /.+-\d+(\.\d+\.\d+.*)?/.test(extension): case /.+-\d+\.\d+\.\d+.*/.test(extension):
add_script += await utils.joins( add_script += await utils.joins(
'\nadd_pecl_extension', '\nadd_pecl_extension',
ext_name, ext_name,
@ -84,15 +76,16 @@ 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 brew extensions // 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
case /(?<!5\.[3-5])(amqp|apcu|brotli|excimer|expect|gmagick|gnupg|grpc|igbinary|imagick|imap|interbase|mailparse|maxminddb|mcrypt|memcache|memcached|mongodb|mongodb1|msgpack|newrelic|oauth|opentelemetry|pdo_firebird|pinba|protobuf|psr|raphf|rdkafka|redis|scalar_objects|seaslog|snmp|spx|ssh2|swoole|uopz|uploadprogress|uuid|vld|xdebug|xdebug2|xhprof|yaml|zmq|zstd)/.test( // match 7.1 and newer - pcov
// match 5.6 to 7.4 - propro
// match 7.0 and newer - vips, xlswriter
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\.[3-6])(ds|v8js)/.test(version_extension): case /(5\.6|7\.[0-4])propro/.test(version_extension):
case /(5\.6|7\.[0-4])(propro|lua)/.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])(ast|vips|xlswriter)/.test(version_extension): case /(?<!5\.[3-6])(vips|xlswriter)/.test(version_extension):
case /^(8\.[0-5])swow$/.test(version_extension):
add_script += await utils.joins( add_script += await utils.joins(
'\nadd_brew_extension', '\nadd_brew_extension',
ext_name, ext_name,
@ -137,28 +130,21 @@ 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.5blackfire // match 5.3blackfire...8.1blackfire
// match 5.3blackfire-(semver)...8.5blackfire-(semver) // match 5.3blackfire-(semver)...8.1blackfire-(semver)
// match ibm_db2, pdo_ibm, pdo_oci and oci8 // match pdo_oci and oci8
// match 5.3ioncube...8.4ioncube // match 5.3ioncube...7.4ioncube
// match 7.0phalcon3...7.3phalcon3, 7.2phalcon4...7.4phalcon4, and 7.4phalcon5...8.4phalcon5 // match 7.0phalcon3...7.3phalcon3, 7.2phalcon4...7.4phalcon4, and 7.4phalcon5...8.2phalcon5
// match 7.1pecl_http...8.1pecl_http and 7.1http...8.1http // match 7.1pecl_http...8.1pecl_http and 7.1http...8.1http
// match 7.0zephir_parser...8.4zephir_parser case /^(5\.[3-6]|7\.[0-4]|8\.1)blackfire(-\d+\.\d+\.\d+)?$/.test(
case /^(5\.[3-6]|7\.[0-4]|8\.[0-5])blackfire(-\d+\.\d+\.\d+)?$/.test(
version_extension version_extension
): ):
case /^ibm_db2$|^pdo_ibm$|^pdo_oci$|^oci8$|^pdo_firebird$/.test( case /^pdo_oci$|^oci8$|^pdo_firebird$/.test(extension):
extension case /^(5\.[3-6]|7\.[0-4])ioncube$/.test(version_extension):
): case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$|^(7\.4|8\.[0-2])phalcon5$/.test(
case /^(5\.[3-6]|7\.[0-4]|8\.[0-4])ioncube$/.test(version_extension):
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$|^(7\.4|8\.[0-4])phalcon5?$/.test(
version_extension version_extension
): ):
case /^(7\.[1-4]|8\.1)(pecl_)?http/.test(version_extension): case /^(7\.[1-4]|8\.1)(pecl_)?http/.test(version_extension):
case /(?<!5\.[3-6])(pdo_)?sqlsrv$/.test(version_extension):
case /^(7\.[0-4]|8\.[0-4])zephir_parser(-v?\d+\.\d+\.\d+)?$/.test(
version_extension
):
add_script += await utils.customPackage( add_script += await utils.customPackage(
ext_name, ext_name,
'extensions', 'extensions',
@ -182,6 +168,15 @@ export async function addExtensionWindows(
'win32' 'win32'
); );
break; break;
// match semver without state
case /.+-\d+\.\d+\.\d+$/.test(extension):
add_script += await utils.joins(
'\nAdd-Extension',
ext_name,
'stable',
ext_version
);
break;
// match semver with state // match semver with state
case /.+-\d+\.\d+\.\d+[a-zA-Z]+\d*/.test(extension): case /.+-\d+\.\d+\.\d+[a-zA-Z]+\d*/.test(extension):
matches = /.+-(\d+\.\d+\.\d+)([a-zA-Z]+)\d*/.exec( matches = /.+-(\d+\.\d+\.\d+)([a-zA-Z]+)\d*/.exec(
@ -194,15 +189,6 @@ export async function addExtensionWindows(
matches[1] matches[1]
); );
break; break;
// match semver without state
case /.+-\d+(\.\d+\.\d+.*)?/.test(extension):
add_script += await utils.joins(
'\nAdd-Extension',
ext_name,
'stable',
ext_version
);
break;
// match 7.2xdebug2 to 7.4xdebug2 // match 7.2xdebug2 to 7.4xdebug2
case /7\.[2-4]xdebug2/.test(version_extension): case /7\.[2-4]xdebug2/.test(version_extension):
add_script += '\nAdd-Extension xdebug stable 2.9.8'; add_script += '\nAdd-Extension xdebug stable 2.9.8';
@ -268,35 +254,27 @@ export async function addExtensionLinux(
case /.+-.+\/.+@.+/.test(extension): case /.+-.+\/.+@.+/.test(extension):
add_script += await utils.parseExtensionSource(extension, ext_prefix); add_script += await utils.parseExtensionSource(extension, ext_prefix);
return; return;
// match 7.4relay...8.5relay // match 5.3blackfire...8.1blackfire
// match 5.3blackfire...8.5blackfire // match 5.3blackfire-(semver)...8.1blackfire-(semver)
// match 5.3blackfire-(semver)...8.5blackfire-(semver)
// match 5.3pdo_cubrid...7.2php_cubrid, 5.3cubrid...7.4cubrid // match 5.3pdo_cubrid...7.2php_cubrid, 5.3cubrid...7.4cubrid
// match couchbase, geos, ibm_db2, pdo_ibm, pdo_oci, oci8, http, pecl_http // match couchbase, geos, pdo_oci, oci8, http, pecl_http
// match 5.3ioncube...8.4ioncube // match 5.3ioncube...7.4ioncube
// match 7.0phalcon3...7.3phalcon3, 7.2phalcon4...7.4phalcon4, 7.4phalcon5...8.4phalcon5 // match 7.0phalcon3...7.3phalcon3, 7.2phalcon4...7.4phalcon4, 7.4phalcon5...8.2phalcon5
// match 7.0zephir_parser...8.4zephir_parser case /^(5\.[3-6]|7\.[0-4]|8\.[0-1])blackfire(-\d+\.\d+\.\d+)?$/.test(
case /^(7\.4|8\.[0-5])relay(-v?\d+\.\d+\.\d+|-nightly)?$/.test(
version_extension
):
case /^(5\.[3-6]|7\.[0-4]|8\.[0-5])blackfire(-\d+\.\d+\.\d+)?$/.test(
version_extension version_extension
): ):
case /^((5\.[3-6])|(7\.[0-2]))pdo_cubrid$|^((5\.[3-6])|(7\.[0-4]))cubrid$/.test( case /^((5\.[3-6])|(7\.[0-2]))pdo_cubrid$|^((5\.[3-6])|(7\.[0-4]))cubrid$/.test(
version_extension version_extension
): ):
case /^couchbase|^event|^gearman$|^geos$|^ibm_db2$|^pdo_ibm$|^pdo_oci$|^oci8$|^(pecl_)?http|^pdo_firebird$/.test( case /^couchbase|^event|^gearman$|^geos$|^pdo_oci$|^oci8$|^(pecl_)?http|^pdo_firebird$/.test(
extension extension
): ):
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]|8\.[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$|^(7\.4|8\.[0-4])phalcon5?$/.test( case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$|^(7\.4|8\.[0-2])phalcon5$/.test(
version_extension version_extension
): ):
case /(?<!5\.[3-6])(pdo_)?sqlsrv$/.test(version_extension): case /(?<!5\.[3-6])(pdo_)?sqlsrv$/.test(version_extension):
case /^(7\.[0-4]|8\.[0-4])zephir_parser(-v?\d+\.\d+\.\d+)?$/.test(
version_extension
):
add_script += await utils.customPackage( add_script += await utils.customPackage(
ext_name, ext_name,
'extensions', 'extensions',
@ -314,7 +292,7 @@ export async function addExtensionLinux(
); );
return; return;
// match semver versions // match semver versions
case /.+-\d+(\.\d+\.\d+.*)?/.test(extension): case /.+-\d+\.\d+\.\d+.*/.test(extension):
add_script += await utils.joins( add_script += await utils.joins(
'\nadd_pecl_extension', '\nadd_pecl_extension',
ext_name, ext_name,

View File

@ -1,10 +1,9 @@
/** import {IncomingMessage, OutgoingHttpHeaders} from 'http';
* Redirect status codes set for O(1) lookup import * as https from 'https';
*/ import * as url from 'url';
const REDIRECT_CODES = new Set([301, 302, 303, 307, 308]);
/** /**
* Function to fetch a URL using native fetch API (Node 24+) * Function to fetch a URL
* *
* @param input_url * @param input_url
* @param auth_token * @param auth_token
@ -15,28 +14,42 @@ export async function fetch(
auth_token?: string, auth_token?: string,
redirect_count = 5 redirect_count = 5
): Promise<Record<string, string>> { ): Promise<Record<string, string>> {
const headers: Record<string, string> = { const fetch_promise: Promise<Record<string, string>> = new Promise(
'User-Agent': `Mozilla/5.0 (${process.platform} ${process.arch}) setup-php` resolve => {
}; const url_object: url.UrlObject = new url.URL(input_url);
if (auth_token) { const headers: OutgoingHttpHeaders = {
headers['Authorization'] = 'Bearer ' + auth_token; 'User-Agent': `Mozilla/5.0 (${process.platform} ${process.arch}) setup-php`
} };
if (auth_token) {
try { headers.authorization = 'Bearer ' + auth_token;
const response = await globalThis.fetch(input_url, { }
headers, const options: https.RequestOptions = {
redirect: redirect_count > 0 ? 'follow' : 'manual' hostname: url_object.hostname,
}); path: url_object.pathname,
headers: headers
if (response.ok) { };
const data = await response.text(); const req = https.get(options, (res: IncomingMessage) => {
return {data}; if (res.statusCode === 200) {
} else if (REDIRECT_CODES.has(response.status) && redirect_count <= 0) { let body = '';
return {error: `${response.status}: Redirect error`}; res.setEncoding('utf8');
} else { res.on('data', chunk => (body += chunk));
return {error: `${response.status}: ${response.statusText}`}; 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();
} }
} catch (error) { );
return {error: `Fetch error: ${(error as Error).message}`}; return await fetch_promise;
}
} }

View File

@ -1,8 +1,8 @@
import path from 'path'; import path from 'path';
import fs from 'fs'; import fs from 'fs';
import {exec} from '@actions/exec'; import {exec} from '@actions/exec';
import * as core from '@actions/core';
import * as config from './config'; import * as config from './config';
import * as core from './core';
import * as coverage from './coverage'; import * as coverage from './coverage';
import * as extensions from './extensions'; import * as extensions from './extensions';
import * as tools from './tools'; import * as tools from './tools';
@ -14,16 +14,17 @@ import * as utils from './utils';
* @param os * @param os
*/ */
export async function getScript(os: string): Promise<string> { export async function getScript(os: string): Promise<string> {
const url = 'https://setup-php.com/sponsor'; const url = 'https://setup-php.com/support-ukraine';
const filename = os + (await utils.scriptExtension(os)); const filename = os + (await utils.scriptExtension(os));
const script_path = path.join(__dirname, '../src/scripts', filename); const script_path = path.join(__dirname, '../src/scripts', filename);
const run_path = script_path.replace(os, 'run'); const run_path = script_path.replace(os, 'run');
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( const version: string = await utils.parseVersion(
await utils.readPHPVersion() await utils.getInput('php-version', true)
); );
const ini_file: string = await utils.parseIniFile( const ini_file: string = await utils.parseIniFile(
await utils.getInput('ini-file', false) await utils.getInput('ini-file', false)
@ -39,27 +40,18 @@ export async function getScript(os: string): Promise<string> {
if (ini_values_csv) { if (ini_values_csv) {
script += await config.addINIValues(ini_values_csv, os); script += await config.addINIValues(ini_values_csv, os);
} }
script += '\n' + (await utils.stepLog(`Sponsor setup-php`, os)); script += '\n' + (await utils.stepLog(`#StandWithUkraine`, os));
script += '\n' + (await utils.addLog('$tick', 'setup-php', url, os)); script += '\n' + (await utils.addLog('$tick', 'read-more', url, os));
fs.writeFileSync(run_path, script, {mode: 0o755}); fs.writeFileSync(run_path, script, {mode: 0o755});
return run_path; return run_path;
} }
/**
* Function to set environment variables based on inputs.
*/
export async function setEnv(): Promise<void> {
process.env['fail_fast'] = await utils.getInput('fail-fast', false);
process.env['GITHUB_TOKEN'] ??= await utils.getInput('github-token', false);
}
/** /**
* Run the script * Run the script
*/ */
export async function run(): Promise<void> { export async function run(): Promise<void> {
await setEnv();
const os: string = process.platform; const os: string = process.platform;
const tool = await utils.scriptTool(os); const tool = await utils.scriptTool(os);
const run_path = await getScript(os); const run_path = await getScript(os);

View File

@ -1,37 +0,0 @@
import * as cv from 'compare-versions';
import * as fetch from './fetch';
type RS = Record<string, string>;
type RSRS = Record<string, RS>;
export async function search(
package_name: string,
php_version: string
): Promise<string | null> {
const response = await fetch.fetch(
`https://repo.packagist.org/p2/${package_name}.json`
);
if (response.error || response.data === '[]') {
return null;
}
const data = JSON.parse(response['data']);
if (data && data.packages) {
const versions = data.packages[package_name];
versions.sort((a: RS, b: RS) => cv.compareVersions(b.version, a.version));
const result = versions.find((versionData: RSRS) => {
if (versionData?.require?.php) {
return versionData?.require?.php
.split('|')
.some(
require => require && cv.satisfies(php_version + '.0', require)
);
}
return false;
});
return result ? result.version : null;
}
return null;
}

View File

@ -1,25 +1,22 @@
# Handle dependency extensions # Function to setup environment for self-hosted runners.
handle_dependency_extensions() { self_hosted_helper() {
local formula=$1 if ! command -v brew >/dev/null; then
local extension=$2 step_log "Setup Brew"
formula_file="${tap_dir:?}/$ext_tap/Formula/$extension@${version:?}.rb" get -q -e "/tmp/install.sh" "https://raw.githubusercontent.com/Homebrew/install/master/install.sh" && /tmp/install.sh >/dev/null 2>&1
[ -e "$formula_file" ] || formula_file="$tap_dir/$ext_tap/Formula/$formula@$version.rb" add_log "${tick:?}" "Brew" "Installed Homebrew"
fi
}
# Disable dependency extensions
disable_dependency_extensions() {
local extension=$1
formula_file="$tap_dir/$ext_tap/Formula/$extension@${version:?}.rb"
if [ -e "$formula_file" ]; then if [ -e "$formula_file" ]; then
IFS=" " read -r -a dependency_extensions <<< "$(grep -Eo "shivammathur.*@" "$formula_file" | xargs -I {} -n 1 basename '{}' | cut -d '@' -f 1 | tr '\n' ' ')" IFS=" " read -r -a dependency_extensions <<< "$(grep -Eo "shivammathur.*@" "$formula_file" | xargs -I {} -n 1 basename '{}' | cut -d '@' -f 1 | tr '\n' ' ')"
for dependency_extension in "${dependency_extensions[@]}"; do for dependency_extension in "${dependency_extensions[@]}"; do
sudo sed -Ei '' "/=(.*\/)?\"?$dependency_extension(.so)?$/d" "${ini_file:?}" sudo sed -Ei '' "/=(.*\/)?\"?$dependency_extension(.so)?$/d" "${ini_file:?}"
done done
fi fi
suffix="$(get_php_formula_suffix)"
if [[ -n "$suffix" ]]; then
brew_opts=(-sf)
patch_abstract_file >/dev/null 2>&1
for dependency_extension in "${dependency_extensions[@]}"; do
safe_brew install --skip-link "${brew_opts[@]}" "$ext_tap/$dependency_extension@$version" >/dev/null 2>&1 &&
brew link --overwrite --force "$dependency_extension@$version" >/dev/null 2>&1 &&
copy_brew_extensions "$dependency_extension"
done
fi
} }
# Helper function to disable an extension. # Helper function to disable an extension.
@ -36,26 +33,42 @@ disable_extension_helper() {
echo '' | sudo tee /tmp/extdisabled/"$version"/"$extension" >/dev/null 2>&1 echo '' | sudo tee /tmp/extdisabled/"$version"/"$extension" >/dev/null 2>&1
} }
# Function to fetch a brew tap.
fetch_brew_tap() {
tap=$1
tap_user=$(dirname "$tap")
tap_name=$(basename "$tap")
mkdir -p "$tap_dir/$tap_user"
get -s -n "" "https://github.com/$tap/archive/master.tar.gz" | sudo tar -xzf - -C "$tap_dir/$tap_user"
if [ -d "$tap_dir/$tap_user/$tap_name-master" ]; then
sudo mv "$tap_dir/$tap_user/$tap_name-master" "$tap_dir/$tap_user/$tap_name"
fi
}
# Function to add a brew tap.
add_brew_tap() {
tap=$1
if ! [ -d "$tap_dir/$tap" ]; then
if [ "${runner:?}" = "self-hosted" ]; then
brew tap "$tap" >/dev/null 2>&1
else
fetch_brew_tap "$tap" >/dev/null 2>&1
if ! [ -d "$tap_dir/$tap" ]; then
brew tap "$tap" >/dev/null 2>&1
fi
fi
fi
}
# Function to get extension name from brew formula. # Function to get extension name from brew formula.
get_extension_from_formula() { get_extension_from_formula() {
local formula=$1 local formula=$1
local extension local extension
extension=$(grep -E "^$formula=" "$src"/configs/brew_extensions | cut -d '=' -f 2) extension=$(grep "$formula=" "$src"/configs/brew_extensions | cut -d '=' -f 2)
[[ -z "$extension" ]] && extension="$(echo "$formula" | sed -E "s/pecl_|php|[0-9]//g")" [[ -z "$extension" ]] && extension="$(echo "$formula" | sed -E "s/pecl_|[0-9]//g")"
echo "$extension" echo "$extension"
} }
# Function to get renamed formula.
get_renamed_formula() {
local formula=$1
formula_renames_json="$tap_dir/$ext_tap/formula_renames.json"
if [ -e "$formula_renames_json" ] && grep -q "$formula@$version\":" "$formula_renames_json"; then
grep "$formula@$version\":" "$formula_renames_json" | cut -d ':' -f 2 | tr -d ' ",' | cut -d '@' -f 1
else
echo "$formula"
fi
}
# Function to copy extension binaries to the extension directory. # Function to copy extension binaries to the extension directory.
copy_brew_extensions() { copy_brew_extensions() {
local formula=$1 local formula=$1
@ -63,12 +76,10 @@ copy_brew_extensions() {
deps="$(grep -Eo 'depends_on "shivammathur[^"]+' "$formula_file" | cut -d '/' -f 3 | tr '\n' ' ')" deps="$(grep -Eo 'depends_on "shivammathur[^"]+' "$formula_file" | cut -d '/' -f 3 | tr '\n' ' ')"
IFS=' ' read -r -a deps <<< "$formula@$version $deps" IFS=' ' read -r -a deps <<< "$formula@$version $deps"
for dependency in "${deps[@]}"; do for dependency in "${deps[@]}"; do
extension_file="${brew_prefix:?}/opt/$dependency/$(get_extension_from_formula "${dependency%@*}").so" extension_file="$brew_prefix/opt/$dependency/$(get_extension_from_formula "${dependency%@*}").so"
[ -e "$extension_file" ] && sudo cp "$extension_file" "$ext_dir" [ -e "$extension_file" ] && sudo cp "$extension_file" "$ext_dir"
done done
if [ -d "$brew_prefix"/Cellar/"$formula"@"$version" ]; then sudo find -- "$brew_prefix"/Cellar/"$formula"@"$version" -name "*.dylib" -exec cp {} "$ext_dir" \;
sudo find -- "$brew_prefix"/Cellar/"$formula"@"$version" -name "*.dylib" -exec cp {} "$ext_dir" \;
fi
} }
# Function to install a php extension from shivammathur/extensions tap. # Function to install a php extension from shivammathur/extensions tap.
@ -82,27 +93,15 @@ add_brew_extension() {
else else
add_brew_tap "$php_tap" add_brew_tap "$php_tap"
add_brew_tap "$ext_tap" add_brew_tap "$ext_tap"
formula="$(get_renamed_formula "$formula")" sudo mv "$tap_dir"/"$ext_tap"/.github/deps/"$formula"/* "$core_repo/Formula/" 2>/dev/null || true
update_dependencies >/dev/null 2>&1 update_dependencies >/dev/null 2>&1
handle_dependency_extensions "$formula" "$extension" >/dev/null 2>&1 disable_dependency_extensions "$extension" >/dev/null 2>&1
( brew install -f "$ext_tap/$formula@$version" >/dev/null 2>&1
safe_brew install --skip-link "${brew_opts[@]}" "$ext_tap/$formula@$version" >/dev/null 2>&1 && copy_brew_extensions "$formula"
brew link --overwrite --force "$formula@$version" >/dev/null 2>&1 &&
copy_brew_extensions "$formula"
) || pecl_install "$extension" >/dev/null 2>&1
add_extension_log "$extension" "Installed and enabled" add_extension_log "$extension" "Installed and enabled"
fi fi
} }
# Function to patch the abstract file in the extensions tap.
patch_abstract_file() {
abstract_path="$tap_dir"/"$ext_tap"/Abstract/abstract-php-extension.rb
if [[ -e "$abstract_path" && ! -e /tmp/abstract_patch ]]; then
echo '' | sudo tee /tmp/abstract_patch >/dev/null 2>&1
sudo sed -i '' -e "s|php@#{\(.*\)}|php@#{\1}$suffix|g" -e "s|php_version /|\"#{php_version}$suffix\" /|g" "$abstract_path"
fi
}
# Helper function to add an extension. # Helper function to add an extension.
add_extension_helper() { add_extension_helper() {
local extension=$1 local extension=$1
@ -130,45 +129,66 @@ add_pecl() {
add_log "${tick:?}" "PECL" "Found PECL $pear_version" add_log "${tick:?}" "PECL" "Found PECL $pear_version"
} }
# Link opcache extension to extensions directory. # Function to link all libraries of a formula.
link_opcache() { link_libraries() {
opcache_ini="$brew_prefix"/etc/php/"$version"/conf.d/ext-opcache.ini formula=$1
if [ -e "$opcache_ini" ]; then formula_prefix="$(brew --prefix "$formula")"
opcache_ext=$(grep -Eo "zend_extension.*opcache.*\.so" "$opcache_ini" | cut -d '"' -f 2) sudo mkdir -p "$formula_prefix"/lib
sudo ln -sf "$opcache_ext" "$ext_dir" for lib in "$formula_prefix"/lib/*.dylib; do
fi lib_name=$(basename "$lib")
sudo cp -a "$lib" "$brew_prefix/lib/$lib_name" 2>/dev/null || true
done
} }
# 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 -Ei '' "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 -Ei '' 's/$code.*/$code, overwrite: overwrite?\)/' $formula_installer" exit trap "sudo sed -Ei '' 's/$code.*/$code, overwrite: overwrite?\)/' $formula_installer" exit
} }
# Helper function to update the dependencies.
update_dependencies_helper() {
dependency=$1
get -q -n "$core_repo/Formula/$dependency.rb" "https://raw.githubusercontent.com/Homebrew/homebrew-core/master/Formula/$dependency.rb"
link_libraries "$dependency"
}
# Function to update dependencies. # Function to update dependencies.
update_dependencies() { update_dependencies() {
patch_brew patch_brew
if ! [ -e /tmp/update_dependencies ]; then if ! [ -e /tmp/update_dependencies ]; then
for repo in "$brew_repo" "${core_repo:?}"; do if [ "${runner:?}" != "self-hosted" ] && [ "${ImageOS:-}" != "" ] && [ "${ImageVersion:-}" != "" ]; then
if [ -e "$repo" ]; then while read -r dependency; do
git_retry -C "$repo" fetch origin main && git -C "$repo" reset --hard origin/main update_dependencies_helper "$dependency" &
fi to_wait+=($!)
done done <"$tap_dir/$php_tap/.github/deps/${ImageOS:?}_${ImageVersion:?}"
wait "${to_wait[@]}"
else
git -C "$core_repo" fetch origin master && git -C "$core_repo" reset --hard origin/master
fi
echo '' | sudo tee /tmp/update_dependencies >/dev/null 2>&1 echo '' | sudo tee /tmp/update_dependencies >/dev/null 2>&1
fi fi
} }
# Function to fix dependencies on install PHP version.
fix_dependencies() {
broken_deps_paths=$(php -v 2>&1 | grep -Eo '/opt/[a-zA-Z0-9@\.]+')
if [ "x$broken_deps_paths" != "x" ]; then
update_dependencies
IFS=" " read -r -a formulae <<< "$(echo "$broken_deps_paths" | tr '\n' ' ' | sed 's|/opt/||g' 2>&1)$php_formula"
brew reinstall "${formulae[@]}"
brew link --force --overwrite "$php_formula" || true
fi
}
# Function to get PHP version if it is already installed using Homebrew. # Function to get PHP version if it is already installed using Homebrew.
get_brewed_php() { get_brewed_php() {
cellar="$brew_prefix"/Cellar php_cellar="$brew_prefix"/Cellar/php
php_cellar="$cellar"/php if [ -d "$php_cellar" ] && ! [[ "$(find "$php_cellar" -maxdepth 1 -name "$version*" | wc -l 2>/dev/null)" -eq 0 ]]; then
if [ -d "$cellar" ] && ! [[ "$(find "$cellar" -maxdepth 1 -name "php@$version*" | wc -l 2>/dev/null)" -eq 0 ]]; then php_semver | cut -c 1-3
php_semver
elif [ -d "$php_cellar" ] && ! [[ "$(find "$php_cellar" -maxdepth 1 -name "$version*" | wc -l 2>/dev/null)" -eq 0 ]]; then
php_semver
else else
echo 'false'; echo 'false';
fi fi
@ -178,33 +198,14 @@ get_brewed_php() {
add_php() { add_php() {
action=$1 action=$1
existing_version=$2 existing_version=$2
suffix="$(get_php_formula_suffix)" add_brew_tap "$php_tap"
php_keg="php@$version$suffix" update_dependencies
php_formula="shivammathur/php/$php_keg" if [ "$existing_version" != "false" ]; then
if [[ "$existing_version" = "false" || -n "$suffix" || "$action" = "upgrade" ]]; then ([ "$action" = "upgrade" ] && brew upgrade -f "$php_formula") || brew unlink "$php_formula"
update_dependencies
add_brew_tap "$php_tap"
fi
if [[ "$existing_version" != "false" && -z "$suffix" ]]; then
if [ "$action" = "upgrade" ]; then
safe_brew install --only-dependencies "$php_formula"
safe_brew upgrade -f --overwrite "$php_formula"
else
brew unlink "$php_keg"
fi
else else
safe_brew install --only-dependencies "$php_formula" brew install -f "$php_formula"
safe_brew install --skip-link -f --overwrite "$php_formula" 2>/dev/null || safe_brew upgrade -f --overwrite "$php_formula"
fi fi
brew link --force --overwrite "$php_keg" || (sudo chown -R "$(id -un)":"$(id -gn)" "$brew_prefix" && brew link --force --overwrite "$php_keg") brew link --force --overwrite "$php_formula"
}
# Function to get formula suffix
get_php_formula_suffix() {
local suffix
[ "${debug:?}" = "debug" ] && suffix="-debug"
[ "${ts:?}" = "zts" ] && suffix="$suffix-zts"
echo "$suffix"
} }
# Function to get extra version. # Function to get extra version.
@ -236,34 +237,26 @@ get_scan_dir() {
fi fi
} }
# Function to handle self-hosted runner setup.
self_hosted_helper() {
sudo mkdir -p /opt/hostedtoolcache >/dev/null 2>&1 || true
}
# 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)" php_config="$(command -v php-config 2>/dev/null)"
update=true
check_pre_installed
existing_version=$(get_brewed_php) existing_version=$(get_brewed_php)
status="Found"
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
status="Installed" status="Installed"
elif [ "${existing_version:0:3}" != "$version" ]; then elif [ "$existing_version" != "$version" ]; then
add_php "install" "$existing_version" >/dev/null 2>&1 add_php "install" "$existing_version" >/dev/null 2>&1
status="Installed" status="Installed"
elif [[ "${existing_version:0:3}" = "$version" && "${update:?}" = "true" ]]; then elif [ "$existing_version" = "$version" ] && [ "${update:?}" = "true" ]; then
brew_php_version="$(brew info --json "php@$version" 2>/dev/null | jq -r '.[].versions.stable')" add_php "upgrade" "$existing_version" >/dev/null 2>&1
if [ "$brew_php_version" != "$existing_version" ]; then status="Updated to"
add_php "upgrade" "$existing_version" >/dev/null 2>&1 else
status="Upgraded" status="Found"
fi fix_dependencies >/dev/null 2>&1
fi fi
php_config="$(command -v php-config)" php_config="$(command -v php-config)"
ext_dir="$(sed -n "s/.*extension_dir=['\"]\(.*\)['\"].*/\1/p" "$php_config")" ext_dir="$(grep 'extension_dir=' "$php_config" | cut -d "'" -f 2)"
ini_dir="$(php_ini_path)" ini_dir="$(php_ini_path)"
scan_dir="$(get_scan_dir)" scan_dir="$(get_scan_dir)"
ini_file="$ini_dir"/php.ini ini_file="$ini_dir"/php.ini
@ -272,7 +265,6 @@ setup_php() {
semver="$(php_semver)" semver="$(php_semver)"
extra_version="$(php_extra_version)" extra_version="$(php_extra_version)"
configure_php configure_php
link_opcache
set_output "php-version" "$semver" 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"
@ -284,28 +276,31 @@ setup_php() {
} }
# Variables # Variables
version=${1:-'8.5'} version=${1:-'8.1'}
ini=${2:-'production'} ini=${2:-'production'}
src=${0%/*}/.. src=${0%/*}/..
php_formula=shivammathur/php/php@"$version" php_formula=shivammathur/php/php@"$version"
brew_path="$(command -v brew)"
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
core_repo="$tap_dir"/homebrew/homebrew-core
scripts="$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_NO_AUTO_UPDATE=1 export HOMEBREW_NO_AUTO_UPDATE=1
export HOMEBREW_NO_ENV_HINTS=1 export HOMEBREW_NO_ENV_HINTS=1
export HOMEBREW_NO_INSTALL_CLEANUP=1 export HOMEBREW_NO_INSTALL_CLEANUP=1
export HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1 export HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1
export HOMEBREW_NO_INSTALL_FROM_API=1
# shellcheck source=. # shellcheck source=.
. "${scripts:?}"/unix.sh . "${scripts:?}"/unix.sh
. "${scripts:?}"/tools/brew.sh
. "${scripts:?}"/tools/retry.sh
. "${scripts:?}"/tools/add_tools.sh . "${scripts:?}"/tools/add_tools.sh
. "${scripts:?}"/extensions/source.sh . "${scripts:?}"/extensions/source.sh
. "${scripts:?}"/extensions/add_extensions.sh . "${scripts:?}"/extensions/add_extensions.sh
configure_brew
read_env read_env
self_hosted_setup self_hosted_setup
setup_php setup_php

View File

@ -1,32 +1,3 @@
# Function to check if extension is enabled.
Function Test-Extension() {
Param (
[Parameter(Position = 0, Mandatory = $true)]
[ValidateNotNull()]
[string]
$extension
)
$extension_info = Get-PhpExtension -Path $php_dir | Where-Object { $_.Name -eq $extension -or $_.Handle -eq $extension }
return $null -ne $extension_info
}
# Function to add extension log.
Function Add-ExtensionLog() {
Param (
[Parameter(Position = 0, Mandatory = $true)]
[ValidateNotNull()]
$extension,
[Parameter(Position = 1, Mandatory = $true)]
[ValidateNotNull()]
$message
)
if (Test-Extension $extension) {
Add-Log $tick $extension $message
} else {
Add-Log $cross $extension "Could not install $extension on PHP $( $installed.FullVersion )"
}
}
# Function to link dependencies to PHP directory. # Function to link dependencies to PHP directory.
Function Set-ExtensionPrerequisites Function Set-ExtensionPrerequisites
{ {
@ -35,9 +6,8 @@ Function Set-ExtensionPrerequisites
[ValidateNotNull()] [ValidateNotNull()]
[ValidateLength(1, [int]::MaxValue)] [ValidateLength(1, [int]::MaxValue)]
[string] [string]
$extension $deps_dir
) )
$deps_dir = "$ext_dir\$extension-vc$($installed.VCVersion)-$arch"
$deps = Get-ChildItem -Recurse -Path $deps_dir $deps = Get-ChildItem -Recurse -Path $deps_dir
if ($deps.Count -ne 0) { if ($deps.Count -ne 0) {
# Symlink dependencies instead of adding the directory to PATH ... # Symlink dependencies instead of adding the directory to PATH ...
@ -50,41 +20,6 @@ Function Set-ExtensionPrerequisites
} }
} }
# Function to enable extension.
Function Enable-Extension() {
Param (
[Parameter(Position = 0, Mandatory = $true)]
[ValidateNotNull()]
[ValidateLength(1, [int]::MaxValue)]
[string]
$extension
)
Enable-ExtensionDependencies $extension
Enable-PhpExtension -Extension $extension -Path $php_dir
Set-ExtensionPrerequisites $extension
Add-Log $tick $extension "Enabled"
}
# Function to add custom built PHP extension for nightly builds.
Function Add-ExtensionFromGithub {
Param (
[Parameter(Position = 0, Mandatory = $true)]
[ValidateNotNull()]
[ValidateLength(1, [int]::MaxValue)]
[string]
$extension
)
if($ts) { $ts_part = 'ts' } else { $ts_part = 'nts' }
$repo = "$github/shivammathur/php-extensions-windows"
$url = "$repo/releases/download/builds/php$version`_$ts_part`_$arch`_$extension.dll"
Get-File -Url $url -OutFile "$ext_dir\php_$extension.dll"
if(Test-Path "$ext_dir\php_$extension.dll") {
Enable-Extension $extension > $null
} else {
throw "Failed to download the $extension"
}
}
# Function to add PHP extensions. # Function to add PHP extensions.
Function Add-Extension { Function Add-Extension {
Param ( Param (
@ -100,7 +35,7 @@ Function Add-Extension {
$stability = 'stable', $stability = 'stable',
[Parameter(Position = 2, Mandatory = $false)] [Parameter(Position = 2, Mandatory = $false)]
[ValidateNotNull()] [ValidateNotNull()]
[ValidatePattern('^\d+(\.\d+){0,3}$')] [ValidatePattern('^\d+(\.\d+){0,2}$')]
[string] [string]
$extension_version = '' $extension_version = ''
) )
@ -117,36 +52,31 @@ Function Add-Extension {
Add-Log $tick $extension "Enabled" Add-Log $tick $extension "Enabled"
} }
default { default {
Enable-Extension $extension_info.Handle Enable-ExtensionDependencies $extension
Enable-PhpExtension -Extension $extension_info.Handle -Path $php_dir
Set-ExtensionPrerequisites $deps_dir
Add-Log $tick $extension "Enabled"
} }
} }
} }
else { else {
if(($version -match $nightly_versions) -and (Select-String -Path $src\configs\windows_extensions -Pattern $extension -SimpleMatch -Quiet)) { # Patch till PHP 8.1 DLLs are released as stable.
Add-ExtensionFromGithub $extension $minimumStability = $stability
} else { if($version -eq '8.1' -and $stability -eq 'stable') {
# Patch till DLLs for PHP 8.1 and above are released as stable. $minimumStability = 'snapshot'
$minimumStability = $stability
if ($version -match '8.[1-4]' -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
}
# If extension for a different version exists
if(Test-Path $ext_dir\php_$extension.dll) {
Move-Item $ext_dir\php_$extension.dll $ext_dir\php_$extension.bak.dll -Force
}
Install-PhpExtension @params
Set-ExtensionPrerequisites $extension
} }
$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" Add-Log $tick $extension "Installed and enabled"
} }
} catch { }
Add-Log $cross $extension "Could not install $extension on PHP $( $installed.FullVersion )" catch {
Add-Log $cross $extension "Could not install $extension on PHP $($installed.FullVersion)"
} }
} }
@ -261,4 +191,4 @@ Function Disable-AllShared() {
# Function to handle request to add PECL. # Function to handle request to add PECL.
Function Add-Pecl() { Function Add-Pecl() {
Add-Log $tick "PECL" "Use extensions input to setup PECL extensions on windows" Add-Log $tick "PECL" "Use extensions input to setup PECL extensions on windows"
} }

View File

@ -1,10 +1,8 @@
# Function to log result of installing extension. # Function to log result of installing extension.
add_extension_log() { add_extension_log() {
if check_extension ${1%%-*}; then (
add_log "${tick:?}" "$1" "$2" check_extension "$(echo "$1" | cut -d '-' -f 1)" && add_log "${tick:?}" "$1" "$2"
else ) || add_log "${cross:?}" "$1" "Could not install $1 on PHP ${semver:?}"
add_log "${cross:?}" "$1" "${3:-Could not install $1 on PHP ${semver:?}}"
fi
} }
# Function to test if extension is loaded. # Function to test if extension is loaded.
@ -50,19 +48,7 @@ enable_extension() {
[ -d "$modules_dir" ] && sudo find "$modules_dir" -path "*disabled*$1" -delete [ -d "$modules_dir" ] && sudo find "$modules_dir" -path "*disabled*$1" -delete
enable_extension_dependencies "$1" "$2" enable_extension_dependencies "$1" "$2"
enable_cache_extension_dependencies "$1" "$2" enable_cache_extension_dependencies "$1" "$2"
if ! [[ "${version:?}" =~ ${old_versions:?} ]] && command -v phpenmod >/dev/null 2>&1; then echo "$2=${ext_dir:?}/$1.so" | sudo tee -a "${pecl_file:-${ini_file[@]}}" >/dev/null
sudo sed -Ei "/=(.*\/)?\"?$extension(.so)?\"?$/d" "$pecl_file"
mod="${ini_dir:?}"/../mods-available/"$1".ini
if ! [ -e "$mod" ]; then
priority="${3:-20}";
mod_priority_line="$(grep -E "^$1=" "${src:?}/configs/mod_priority")";
[ -n "$mod_priority_line" ] && priority=$(echo "$mod_priority_line" | cut -d'=' -f 2)
(echo "; priority=$priority"; echo "$2=${ext_dir:?}/$1.so") | sudo tee "$mod" >/dev/null
fi
sudo phpenmod -v "$version" "$1" >/dev/null 2>&1
else
echo "$2=${ext_dir:?}/$1.so" | sudo tee -a "${pecl_file:-${ini_file[@]}}" >/dev/null
fi
fi fi
} }
@ -128,15 +114,15 @@ disable_all_shared() {
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 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" mkdir -p /tmp/extdisabled/"$version"
sudo rm -f /tmp/php"$version"_extensions sudo rm -f /tmp/php"$version"_extensions
sudo find "$ext_dir" -name '*.so' -print0 | xargs -0 -n 1 basename -s .so | xargs -I{} touch /tmp/extdisabled/"$version"/{} 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" add_log "${tick:?}" "none" "Disabled all shared extensions"
} }
# Function to configure PECL. # Function to configure PECL.
configure_pecl() { configure_pecl() {
[ -z "${pecl_file:-${ini_file[@]}}" ] && return
if ! [ -e /tmp/pecl_config ]; then if ! [ -e /tmp/pecl_config ]; then
for script in pear pecl; do for script in pear pecl; do
sudo "$script" config-set php_ini "${pecl_file:-${ini_file[@]}}"
sudo "$script" channel-update "$script".php.net sudo "$script" channel-update "$script".php.net
done done
echo '' | sudo tee /tmp/pecl_config >/dev/null 2>&1 echo '' | sudo tee /tmp/pecl_config >/dev/null 2>&1
@ -158,49 +144,30 @@ add_extension() {
# Function to get the PECL version of an extension. # Function to get the PECL version of an extension.
get_pecl_version() { get_pecl_version() {
local extension=$1 local extension=$1
states=("stable" "rc" "preview" "beta" "alpha" "snapshot") stability="$(echo "$2" | grep -m 1 -Eio "(stable|alpha|beta|rc|snapshot|preview)")"
stability="$(echo "$2" | grep -m 1 -Eio "($(IFS='|' ; echo "${states[*]}"))")"
IFS=' ' read -r -a states <<< "$(echo "${states[@]}" | grep -Eo "$stability.*")"
major_version=${3:-'[0-9]+'} major_version=${3:-'[0-9]+'}
pecl_rest='https://pecl.php.net/rest/r/' pecl_rest='https://pecl.php.net/rest/r/'
response=$(get -s -n "" "$pecl_rest$extension"/allreleases.xml) response=$(get -s -n "" "$pecl_rest$extension"/allreleases.xml)
for state in "${states[@]}"; do pecl_version=$(echo "$response" | grep -m 1 -Eio "($major_version\.[0-9]+\.[0-9]+${stability}[0-9]+<)" | cut -d '<' -f 1)
pecl_version=$(echo "$response" | grep -m 1 -Eio "($major_version\.[0-9]+\.[0-9]+${state}[0-9]+<)" | cut -d '<' -f 1) if [ ! "$pecl_version" ]; then
[ -z "$pecl_version" ] && pecl_version=$(echo "$response" | grep -m 1 -Eio "v>(.*)<\/v>.*$state<" | grep -m 1 -Eo "($major_version\.[0-9]+\.[0-9]+.*)<" | cut -d '<' -f 1) pecl_version=$(echo "$response" | grep -m 1 -Eo "($major_version\.[0-9]+\.[0-9]+)<" | cut -d '<' -f 1)
[ -n "$pecl_version" ] && break; fi
done
[ -z "$pecl_version" ] && pecl_version=$(echo "$response" | grep -m 1 -Eo "($major_version\.[0-9]+\.[0-9]+)<" | cut -d '<' -f 1)
echo "$pecl_version" echo "$pecl_version"
} }
# Function to install PECL extensions and accept default options # Function to install PECL extensions and accept default options
pecl_install() { pecl_install() {
local extension=$1 local extension=$1
local prefix=${2:-extension}
add_pecl >/dev/null 2>&1 add_pecl >/dev/null 2>&1
disable_extension_helper "${extension%-*}" >/dev/null 2>&1 cpu_count="$(nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || echo '1')"
# Compare version with 8.3 so it runs only on 8.4 and above prefix_opts="$(parse_args "$extension" CONFIGURE_PREFIX_OPTS) MAKEFLAGS='-j $cpu_count'"
# Install using the source interface as it allows for patching. suffix_opts="$(parse_args "$extension" CONFIGURE_OPTS) $(parse_args "$extension" CONFIGURE_SUFFIX_OPTS)"
if [[ $(printf "%s\n%s" "${version:?}" "8.3" | sort -V | head -n1) != "$version" ]]; then IFS=' ' read -r -a libraries <<<"$(parse_args "$extension" LIBS) $(parse_args "$extension" "$(uname -s)"_LIBS)"
extension_version=${extension##*-}; (( ${#libraries[@]} )) && add_libs "${libraries[@]}" >/dev/null 2>&1
[ "$extension_version" = "${extension%-*}" ] && extension_version=$(get_pecl_version "$extension" "stable") if [ "$version" = "5.3" ]; then
add_extension_from_source "${extension%-*}" https://pecl.php.net "${extension%-*}" "${extension%-*}" "$extension_version" "$prefix" pecl yes '' 2>/dev/null | sudo "$prefix_opts" pecl install -f "$extension" >/dev/null 2>&1
check_extension "${extension%-*}" && return 0 || return 1;
else else
cpu_count="$(nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || echo '1')" yes '' 2>/dev/null | sudo "$prefix_opts" pecl install -f -D "$(parse_pecl_configure_options "$suffix_opts")" "$extension" >/dev/null 2>&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
if [ "$version" = "5.3" ]; then
yes '' 2>/dev/null | sudo "$prefix_opts" pecl install -f "$extension" >/dev/null 2>&1
else
yes '' 2>/dev/null | sudo "$prefix_opts" pecl install -f -D "$(parse_pecl_configure_options "$suffix_opts")" "$extension" >/dev/null 2>&1
fi
local exit_code=$?
sudo pecl info "$extension" | grep -iq 'zend extension' && prefix=zend_extension
enable_extension "${extension%-*}" "$prefix"
return "$exit_code"
fi fi
} }
@ -214,14 +181,12 @@ add_pecl_extension() {
pecl_version=$(get_pecl_version "$extension" "$pecl_version") pecl_version=$(get_pecl_version "$extension" "$pecl_version")
fi fi
ext_version=$(php -r "echo phpversion('$extension');") ext_version=$(php -r "echo phpversion('$extension');")
if check_extension "$extension" && [[ -z "$pecl_version" || (-n "$pecl_version" && "${ext_version/-/}" == "$pecl_version") ]]; then if [ "${ext_version/-/}" = "$pecl_version" ]; then
add_log "${tick:?}" "$extension" "Enabled" add_log "${tick:?}" "$extension" "Enabled"
else else
[ -n "$pecl_version" ] && pecl_version="-$pecl_version" disable_extension_helper "$extension" >/dev/null 2>&1
pecl_install "$extension$pecl_version" || ( [ "${fail_fast:?}" = "false" ] && add_extension "$extension" "$(get_extension_prefix "$extension")" >/dev/null 2>&1) pecl_install "$extension-$pecl_version"
extension_version="$(php -r "echo phpversion('$extension');")" add_extension_log "$extension-$pecl_version" "Installed and enabled"
[ -n "$extension_version" ] && extension_version="-$extension_version"
add_extension_log "$extension$extension_version" "Installed and enabled"
fi fi
} }
@ -233,8 +198,3 @@ add_unstable_extension() {
pecl_version=$(get_pecl_version "$extension" "$stability") pecl_version=$(get_pecl_version "$extension" "$stability")
add_pecl_extension "$extension" "$pecl_version" "$prefix" add_pecl_extension "$extension" "$pecl_version" "$prefix"
} }
# Function to get extension prefix
get_extension_prefix() {
echo "$1" | grep -Eq "xdebug([2-3])?$|opcache|ioncube|eaccelerator" && echo zend_extension || echo extension
}

View File

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

View File

@ -8,10 +8,6 @@ add_blackfire() {
status='Enabled' status='Enabled'
if ! shared_extension blackfire; then if ! shared_extension blackfire; then
status='Installed and enabled' status='Installed and enabled'
arch="$(uname -m)"
arch_name="amd64"
[[ "$arch" = "aarch64" || "$arch" = "arm64" ]] && arch_name="arm64"
[ "${ts:?}" = 'zts' ] && no_dot_version="${no_dot_version}-zts"
if [ "$extension_version" = "blackfire" ]; then if [ "$extension_version" = "blackfire" ]; then
if [[ ${version:?} =~ 5.[3-6] ]]; then if [[ ${version:?} =~ 5.[3-6] ]]; then
extension_version='1.50.0' extension_version='1.50.0'
@ -19,14 +15,8 @@ add_blackfire() {
extension_version=$(get -s -n "" https://blackfire.io/api/v1/releases | grep -Eo 'php":"([0-9]+.[0-9]+.[0-9]+)' | cut -d '"' -f 3) extension_version=$(get -s -n "" https://blackfire.io/api/v1/releases | grep -Eo 'php":"([0-9]+.[0-9]+.[0-9]+)' | cut -d '"' -f 3)
fi fi
fi fi
get -q -n "${ext_dir:?}/blackfire.so" https://packages.blackfire.io/binaries/blackfire-php/"$extension_version"/blackfire-php-"$platform"_"$arch_name"-php-"$no_dot_version".so >/dev/null 2>&1 get -q -n "${ext_dir:?}/blackfire.so" https://packages.blackfire.io/binaries/blackfire-php/"$extension_version"/blackfire-php-"$platform"_amd64-php-"$no_dot_version".so >/dev/null 2>&1
fi
if [ -e "${ext_dir:?}/blackfire.so" ]; then
disable_extension xdebug >/dev/null 2>&1
disable_extension pcov >/dev/null 2>&1
enable_extension blackfire extension
add_extension_log blackfire "$status"
else
add_extension_log blackfire "Could not install blackfire on PHP ${semver:?}"
fi fi
enable_extension blackfire extension
add_extension_log blackfire "$status"
} }

View File

@ -5,30 +5,24 @@ add_couchbase_clibs() {
if [[ "$ext" =~ couchbase-2.+ ]]; then if [[ "$ext" =~ couchbase-2.+ ]]; then
release="2.10.9" release="2.10.9"
else else
release=$(get -s -n "" "$trunk"/latest | grep -Eo -m 1 "[0-9]+\.[0-9]+\.[0-9]+" | head -n 1) release="$(curl -sL $trunk/latest | grep -Eo "libcouchbase-[0-9]+\.[0-9]+\.[0-9]+" | head -n 1 | cut -d'-' -f 2)"
fi fi
[ "$VERSION_ID" = "24.04" ] && vid=22.04 || vid="$VERSION_ID" [ "$VERSION_ID" = "22.04" ] && vid=20.04 || vid="$VERSION_ID"
[ "$VERSION_CODENAME" = "noble" ] && vcn=jammy || vcn="$VERSION_CODENAME" [ "$VERSION_CODENAME" = "jammy" ] && vcn=focal || vcn="$VERSION_CODENAME"
deb_url="$trunk/download/$release/libcouchbase-${release}_ubuntu${vid/./}_${vcn}_amd64.tar" deb_url="$trunk/download/$release/libcouchbase-${release}_ubuntu${vid/./}_${vcn}_amd64.tar"
get -q -n /tmp/libcouchbase.tar "$deb_url" get -q -n /tmp/libcouchbase.tar "$deb_url"
if ! [ -e /tmp/libcouchbase.tar ] || ! file /tmp/libcouchbase.tar | grep -q 'tar archive'; then
deb_url="$trunk/download/$release/libcouchbase-${release}_ubuntu2004_focal_amd64.tar"
get -q -n /tmp/libcouchbase.tar "$deb_url"
add_old_libssl
fi
sudo tar -xf /tmp/libcouchbase.tar -C /tmp sudo tar -xf /tmp/libcouchbase.tar -C /tmp
install_packages libev4 libevent-dev install_packages libev4 libevent-dev
sudo dpkg -i /tmp/libcouchbase-*/*.deb sudo dpkg -i /tmp/libcouchbase-*/*.deb
} }
add_old_libssl() {
if [[ "$VERSION_ID" = "24.04" ]]; then
get -q -n /tmp/libssl.deb http://archive.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.1f-1ubuntu2_amd64.deb
[ -e /tmp/libssl.deb ] && sudo dpkg -i /tmp/libssl.deb || add_extension_log "couchbase" "Could not install libssl1.1"
fi
}
add_couchbase_cxxlibs() { add_couchbase_cxxlibs() {
if [ "$VERSION_ID" = "18.04" ]; then
if ! command -v gcc-8 >/dev/null || ! command -v g++-8 >/dev/null; then
install_packages gcc-8 g++-8 -y
fi
printf "gcc g++" | xargs -d ' ' -I {} sudo update-alternatives --install /usr/bin/{} {} /usr/bin/{}-8 8
fi
if [ "${runner:?}" = "self-hosted" ]; then if [ "${runner:?}" = "self-hosted" ]; then
add_list cmake https://apt.kitware.com/ubuntu/ https://apt.kitware.com/keys/kitware-archive-latest.asc "$VERSION_CODENAME" main add_list cmake https://apt.kitware.com/ubuntu/ https://apt.kitware.com/keys/kitware-archive-latest.asc "$VERSION_CODENAME" main
fi fi
@ -44,8 +38,6 @@ get_couchbase_version() {
echo couchbase-3.0.4 echo couchbase-3.0.4
elif [ "${version:?}" = '7.3' ]; then elif [ "${version:?}" = '7.3' ]; then
echo couchbase-3.2.2 echo couchbase-3.2.2
elif [ "${version:?}" = '7.4' ]; then
echo couchbase-4.1.1
else else
echo couchbase echo couchbase
fi fi
@ -69,9 +61,6 @@ add_couchbase() {
else else
if [ "$ext" = "couchbase" ]; then if [ "$ext" = "couchbase" ]; then
ext="couchbase-$(get_pecl_version "couchbase" "stable")" ext="couchbase-$(get_pecl_version "couchbase" "stable")"
n_proc="$(nproc)"
export COUCHBASE_SUFFIX_OPTS="CMAKE_BUILD_TYPE=Release"
export CMAKE_BUILD_PARALLEL_LEVEL="$n_proc"
add_extension_from_source couchbase https://pecl.php.net couchbase couchbase "${ext##*-}" extension pecl >/dev/null 2>&1 add_extension_from_source couchbase https://pecl.php.net couchbase couchbase "${ext##*-}" extension pecl >/dev/null 2>&1
else else
pecl_install "${ext}" >/dev/null 2>&1 pecl_install "${ext}" >/dev/null 2>&1
@ -80,7 +69,7 @@ add_couchbase() {
fi fi
else else
if [ -e "${ext_dir:?}"/libcouchbase_php_core.dylib ]; then if [ -e "${ext_dir:?}"/libcouchbase_php_core.dylib ]; then
sudo cp "${ext_dir:?}"/libcouchbase_php_core.dylib "${brew_prefix:?}"/lib sudo cp "${ext_dir:?}"/libcouchbase_php_core.dylib ${brew_prefix:?}/lib
fi fi
add_brew_extension couchbase extension add_brew_extension couchbase extension
fi fi

View File

@ -7,6 +7,15 @@ add_license_log() {
echo "$END_GROUP" echo "$END_GROUP"
} }
# Function to setup gcc-7 and g++-7
setup_compiler() {
if ! command -v gcc-7 >/dev/null || ! command -v g++-7 >/dev/null; then
add_ppa ubuntu-toolchain-r/test
add_packages gcc-7 g++-7 -y
fi
printf "gcc g++" | xargs -d ' ' -I {} sudo update-alternatives --install /usr/bin/{} {} /usr/bin/{}-7 7
}
# Function to set cubrid repo for the extension. # Function to set cubrid repo for the extension.
set_cubrid_repo() { set_cubrid_repo() {
case "${ext:?}" in case "${ext:?}" in

View File

@ -13,7 +13,7 @@ get_event_configure_opts() {
) )
else else
event_opts+=( event_opts+=(
--with-openssl-dir="$(brew --prefix openssl@3)" --with-openssl-dir="$(brew --prefix openssl@1.1)"
--with-event-libevent-dir="$(brew --prefix libevent)" --with-event-libevent-dir="$(brew --prefix libevent)"
) )
fi fi

View File

@ -4,7 +4,7 @@ Function Add-Choco() {
# Source: https://docs.chocolatey.org/en-us/choco/setup # Source: https://docs.chocolatey.org/en-us/choco/setup
Set-ExecutionPolicy Bypass -Scope Process -Force Set-ExecutionPolicy Bypass -Scope Process -Force
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072 [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072
Invoke-Expression ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1')) Invoke-Expression ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
} }
} catch { } } catch { }
} }

View File

@ -1,7 +1,16 @@
add_firebird_client_darwin() {
firebird_tag='R3_0_7'
pkg_name=$(get -s -n "" https://github.com/FirebirdSQL/firebird/releases/tag/"$firebird_tag" | grep -Eo "Firebird-.*.pkg" | head -n 1)
get -q -e "/tmp/firebird.pkg" https://github.com/FirebirdSQL/firebird/releases/download/"$firebird_tag"/"$pkg_name"
sudo installer -pkg /tmp/firebird.pkg -target /
sudo mkdir -p /opt/firebird/include /opt/firebird/lib
sudo find /Library/Frameworks/Firebird.framework -name '*.h' -exec cp "{}" /opt/firebird/include \;
sudo find /Library/Frameworks/Firebird.framework -name '*.dylib' -exec cp "{}" /opt/firebird/lib \;
}
add_firebird_helper() { add_firebird_helper() {
firebird_dir=$1 firebird_dir=$1
tag="$(php_src_tag)" tag="$(php_src_tag)"
export PDO_FIREBIRD_CONFIGURE_PREFIX_OPTS="CFLAGS=-Wno-incompatible-function-pointer-types EXTRA_CFLAGS=-Wno-int-conversion"
export PDO_FIREBIRD_CONFIGURE_OPTS="--with-pdo-firebird=$firebird_dir" export PDO_FIREBIRD_CONFIGURE_OPTS="--with-pdo-firebird=$firebird_dir"
export PDO_FIREBIRD_LINUX_LIBS="firebird-dev" export PDO_FIREBIRD_LINUX_LIBS="firebird-dev"
export PDO_FIREBIRD_PATH="ext/pdo_firebird" export PDO_FIREBIRD_PATH="ext/pdo_firebird"
@ -9,19 +18,22 @@ add_firebird_helper() {
} }
add_firebird() { add_firebird() {
if [ "$(uname -s )" = "Darwin" ]; then
add_firebird_client_darwin >/dev/null 2>&1
fi
enable_extension pdo_firebird extension enable_extension pdo_firebird extension
if check_extension pdo_firebird; then status="Enabled"
add_log "${tick:?}" pdo_firebird Enabled if ! check_extension pdo_firebird; then
else status="Installed and enabled"
if [ "$(uname -s)" = "Linux" ]; then if [ "$(uname -s)" = "Linux" ]; then
if [[ "${version:?}" =~ 5.3|${php_builder_versions:?} ]]; then if [[ "${version:?}" =~ 5.3|${nightly_versions:?} ]]; then
add_firebird_helper /usr >/dev/null 2>&1 add_firebird_helper /usr >/dev/null 2>&1
else else
add_pdo_extension firebird >/dev/null 2>&1 add_pdo_extension firebird >/dev/null 2>&1
fi fi
else else
add_brew_extension pdo_firebird extension >/dev/null 2>&1 add_firebird_helper /opt/firebird >/dev/null 2>&1
fi fi
add_extension_log pdo_firebird "Installed and enabled"
fi fi
add_extension_log pdo_firebird "$status"
} }

View File

@ -1,13 +1,12 @@
# Helper function to add gearman extension. # Helper function to add gearman extension.
add_gearman_helper() { add_gearman_helper() {
add_ppa ondrej/pkg-gearman
install_packages libgearman-dev install_packages libgearman-dev
enable_extension gearman extension enable_extension gearman extension
if ! check_extension gearman; then if ! check_extension gearman; then
status="Installed and enabled" status="Installed and enabled"
if [[ "${version:?}" =~ 5.[3-6] ]]; then if [[ "${version:?}" =~ 5.[3-5] ]]; then
pecl_install gearman-1.1.2 pecl_install gearman-1.1.2
elif [[ "${version:?}" =~ 7.0 ]]; then
pecl_install gearman-2.1.3
else else
install_packages php"${version:?}"-gearman || pecl_install gearman install_packages php"${version:?}"-gearman || pecl_install gearman
fi fi
@ -18,10 +17,6 @@ add_gearman_helper() {
# Function to add gearman extension. # Function to add gearman extension.
add_gearman() { add_gearman() {
status="Enabled" status="Enabled"
if [ "$(uname -s)" = 'Linux' ]; then add_gearman_helper >/dev/null 2>&1
add_gearman_helper >/dev/null 2>&1 add_extension_log "gearman" "$status"
add_extension_log "gearman" "$status"
else
add_brew_extension gearman extension
fi
} }

View File

@ -13,7 +13,7 @@ Function Get-ICUUrl() {
$trunk = "https://windows.php.net" $trunk = "https://windows.php.net"
$urls=@("${trunk}/downloads/php-sdk/deps/${vs_version}/${arch}", "${trunk}/downloads/php-sdk/deps/archives/${vs_version}/${arch}") $urls=@("${trunk}/downloads/php-sdk/deps/${vs_version}/${arch}", "${trunk}/downloads/php-sdk/deps/archives/${vs_version}/${arch}")
foreach ($url in $urls) { foreach ($url in $urls) {
$web_content = Get-File -Url $url $web_content = Invoke-WebRequest -Uri $url
foreach ($link in $web_content.Links) { foreach ($link in $web_content.Links) {
if ($link -match "/.*ICU-${icu_version}.*/") { if ($link -match "/.*ICU-${icu_version}.*/") {
return $trunk + $link.HREF return $trunk + $link.HREF
@ -32,7 +32,7 @@ Function Repair-ICU() {
$zip_url = Get-ICUUrl $icu.Groups[1].Value $installed.Architecture $vs $zip_url = Get-ICUUrl $icu.Groups[1].Value $installed.Architecture $vs
if ($zip_url -ne '') { if ($zip_url -ne '') {
New-Item -Path "$php_dir" -Name "icu" -ItemType "directory" -Force > $null 2>&1 New-Item -Path "$php_dir" -Name "icu" -ItemType "directory" -Force > $null 2>&1
Get-File -Url $zip_url -OutFile "$php_dir\icu\icu.zip" Invoke-WebRequest -Uri $zip_url -OutFile "$php_dir\icu\icu.zip"
Expand-Archive -Path $php_dir\icu\icu.zip -DestinationPath $php_dir\icu -Force Expand-Archive -Path $php_dir\icu\icu.zip -DestinationPath $php_dir\icu -Force
Get-ChildItem $php_dir\icu\bin -Filter *.dll | Copy-Item -Destination $php_dir -Force Get-ChildItem $php_dir\icu\bin -Filter *.dll | Copy-Item -Destination $php_dir -Force
} }
@ -47,5 +47,10 @@ Function Add-Http() {
} }
Add-Extension pecl_http >$null 2>&1 Add-Extension pecl_http >$null 2>&1
Repair-ICU Repair-ICU
Add-ExtensionLog http "Installed and enabled" try {
php --ri "http" 2> $null | Out-Null
Add-Log $tick "http" "Installed and enabled"
} catch {
Add-Log $cross "http" "Could not install http on PHP $( $installed.FullVersion )"
}
} }

View File

@ -61,7 +61,7 @@ add_http_helper() {
export HTTP_CONFIGURE_OPTS="$http_configure_opts" export HTTP_CONFIGURE_OPTS="$http_configure_opts"
export HTTP_LINUX_LIBS="zlib1g libbrotli-dev libcurl4-openssl-dev libevent-dev libicu-dev libidn2-dev" export HTTP_LINUX_LIBS="zlib1g libbrotli-dev libcurl4-openssl-dev libevent-dev libicu-dev libidn2-dev"
export HTTP_DARWIN_LIBS="brotli curl icu4c libevent libidn2" export HTTP_DARWIN_LIBS="brotli curl icu4c libevent libidn2"
if ! [[ ${version:?} =~ 5.[3-6]|7.[0-4] ]]; then if [[ "${version:?}" =~ ${nightly_versions:?} ]]; then
add_extension_from_source http https://github.com m6w6 ext-http master extension add_extension_from_source http https://github.com m6w6 ext-http master extension
else else
add_extension_from_source pecl_http https://pecl.php.net http http "${ext##*-}" extension pecl add_extension_from_source pecl_http https://pecl.php.net http http "${ext##*-}" extension pecl

View File

@ -1,56 +0,0 @@
# Function to log license information for ibm extensions.
Function Add-LicenseLog() {
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 "IBM Db2 ODBC and CLI Driver is required for %s extension.\n" $extension
printf "It is provided under the IBM International Program License Agreement.\n"
printf "Refer to: \033[35;1m%s \033[0m\n" "https://www.ibm.com/support/pages/db2-odbc-cli-driver-download-and-installation-information"
$licensePath = "$php_dir\clidriver\license\odbc_notices.rtf"
if (Test-Path $licensePath) {
Add-Type -AssemblyName System.Windows.Forms
$rtBox = New-Object System.Windows.Forms.RichTextBox
$rtBox.Rtf = [System.IO.File]::ReadAllText($licensePath);
Write-Host $rtBox.Text;
}
Write-Output "$env:END_GROUP"
}
# Function to install IBM Db2 CLI driver.
Function Add-IbmCli() {
$cliPath = "$php_dir\clidriver"
if (-not (Test-Path "$cliPath\bin")) {
$suffix = if ($arch -eq 'x86') { 'nt32' } else { 'ntx64' }
$archive = "$suffix`_odbc_cli.zip"
$destination = "$ENV:RUNNER_TOOL_CACHE\ibm_cli.zip"
Get-File -Url "https://public.dhe.ibm.com/ibmdl/export/pub/software/data/db2/drivers/odbc_cli/$archive" -OutFile $destination > $null 2>&1
Expand-Archive -Path $destination -DestinationPath $php_dir -Force > $null 2>&1
}
$env:IBM_DB_HOME = $cliPath
$env:LD_LIBRARY_PATH = "$cliPath\bin;$cliPath\lib;$env:LD_LIBRARY_PATH"
Add-Path "$cliPath\bin"
$env:PATH = "$cliPath\bin;$env:PATH"
}
# Function to install ibm_db2 and pdo_ibm.
Function Add-Ibm() {
Param (
[Parameter(Position = 0, Mandatory = $true)]
[ValidateNotNull()]
[ValidateSet('ibm_db2', 'pdo_ibm')]
[string]
$extension
)
try {
$status = 'Enabled'
Add-IbmCli
if (Test-Path "$ext_dir\php_$extension.dll") {
Enable-PhpExtension -Extension $extension -Path $php_dir
} else {
Add-Extension $extension
$status = 'Installed and enabled'
}
Add-ExtensionLog $extension $status
Add-LicenseLog
} catch {
Add-Log $cross $extension "Could not install $extension on PHP $( $installed.FullVersion )"
}
}

View File

@ -1,106 +0,0 @@
# Function to log license details for ibm extensions.
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 "IBM Db2 ODBC and CLI Driver is required for %s extension.\n" "$ext"
printf "Refer to: \033[35;1m%s \033[0m\n" "https://www.ibm.com/support/pages/db2-odbc-cli-driver-download-and-installation-information"
local license_file="$ibm_cli/license/odbc_notices.txt"
if [ -f "$license_file" ]; then
cat "$license_file"
fi
echo "$END_GROUP"
}
# Function to determine the driver archive for the current platform.
get_cli_archive() {
local os=$1
local arch=$2
case $os in
Linux)
case $arch in
x86_64|amd64) echo "linuxx64_odbc_cli.tar.gz";;
i?86) echo "linuxia32_odbc_cli.tar.gz";;
*) return 1;;
esac
;;
Darwin)
case $arch in
x86_64) echo "macos64_odbc_cli.tar.gz";;
arm64|aarch64) echo "macarm64_odbc_cli.tar.gz";;
*) return 1;;
esac
;;
*)
return 1
;;
esac
}
# Function to install IBM Db2 CLI driver.
add_cli_driver() {
local os arch archive url tmp libs
if [ -d "$ibm_cli" ]; then
return 0
fi
os=$(uname -s)
arch=$(uname -m)
archive=$(get_cli_archive "$os" "$arch") || return 1
url="https://public.dhe.ibm.com/ibmdl/export/pub/software/data/db2/drivers/odbc_cli/$archive"
tmp=/tmp/$archive
get -q -n "$tmp" "$url"
sudo mkdir -p "$ibm_home"
sudo tar -xzf "$tmp" -C "$ibm_home"
sudo rm -f "$tmp"
if [ ! -d "$ibm_cli" ]; then
local extracted
extracted=$(find "$ibm_home" -maxdepth 1 -type d -name 'clidriver*' | head -n 1)
[ -n "$extracted" ] && sudo mv "$extracted" "$ibm_cli"
fi
if [ "$os" = "Linux" ]; then
echo "$ibm_cli/lib" | sudo tee /etc/ld.so.conf.d/ibm_db2.conf >/dev/null
sudo ldconfig
else
libs='/usr/local/lib'
sudo mkdir -p "$libs"
sudo ln -sf "$ibm_cli"/lib/*.dylib "$libs" >/dev/null 2>&1 || true
fi
}
# Function to install ibm_db2 and pdo_ibm.
add_ibm_helper() {
if ! shared_extension "$ext"; then
status='Installed and enabled'
export IBM_DB_HOME="$ibm_cli"
export LD_LIBRARY_PATH="$IBM_DB_HOME/lib"
add_env DYLD_LIBRARY_PATH "$IBM_DB_HOME/lib"
local configure_flag
if [ "$ext" = 'ibm_db2' ]; then
configure_flag="--with-IBM_DB2=$IBM_DB_HOME"
else
configure_flag="--with-pdo-ibm=$IBM_DB_HOME"
fi
read -r "${ext}_CONFIGURE_OPTS" <<< "--with-php-config=$(command -v php-config) $configure_flag"
patch_phpize
add_extension_from_source "$ext" https://github.com php "pecl-database-$ext" master extension get
restore_phpize
else
enable_extension "$ext" extension
fi
}
# Function to add ibm_db2 and pdo_ibm.
add_ibm() {
ext=$1
status='Enabled'
ibm_home='/opt/ibm'
ibm_cli=$ibm_home/clidriver
if ! add_cli_driver >/dev/null 2>&1; then
add_log "${cross:?}" "$ext" "IBM Db2 CLI driver is not available on $(uname -s)/$(uname -m)"
return 1
fi
add_ibm_helper >/dev/null 2>&1
add_extension_log "$ext" "$status"
check_extension "$ext" && add_license_log
}
# shellcheck source=.
. "${scripts:?}"/extensions/patches/phpize.sh

View File

@ -2,27 +2,22 @@
install_icu() { install_icu() {
icu=$1 icu=$1
if [ "$(php -i | grep "ICU version =>" | sed -e "s|.*=> s*||")" != "$icu" ]; then if [ "$(php -i | grep "ICU version =>" | sed -e "s|.*=> s*||")" != "$icu" ]; then
get -q -n /tmp/icu.tar.zst "https://github.com/shivammathur/icu-intl/releases/download/icu4c/icu4c-$icu$arch_suffix.tar.zst" get -q -n /tmp/icu.tar.zst "https://github.com/shivammathur/icu-intl/releases/download/icu4c/icu4c-$icu.tar.zst"
sudo tar -I zstd -xf /tmp/icu.tar.zst -C /usr/local sudo tar -I zstd -xf /tmp/icu.tar.zst -C /usr/local
sudo cp -r /usr/local/icu/lib/* /usr/lib/"$(uname -m)"-linux-gnu/ sudo cp -r /usr/local/icu/lib/* /usr/lib/x86_64-linux-gnu/
fi fi
} }
# Function to add ext-intl with the given version of ICU # Function to add ext-intl with the given version of ICU
add_intl() { add_intl() {
icu=$(echo "$1" | cut -d'-' -f 2) icu=$(echo "$1" | cut -d'-' -f 2)
supported_version=$(get -s -n "" https://api.github.com/repos/shivammathur/icu-intl/releases/tags/intl-"$icu" | grep -Po "php${version?}-intl-$icu" | head -n 1) supported_version=$(get -s -n "" https://api.github.com/repos/shivammathur/icu-intl/releases | grep -Po "${icu//./\\.}" | head -n 1)
[ -z "$supported_version" ] && supported_version=$(get -s -n "" https://github.com/shivammathur/icu-intl/releases/expanded_assets/intl-"$icu" | grep -Po "php$version-intl-$icu" | head -n 1) if [ "$icu" != "$supported_version" ]; then
if [ "php$version-intl-$icu" != "$supported_version" ]; then add_log "${cross:?}" "intl" "ICU $icu is not supported"
add_log "${cross:?}" "intl" "ICU $icu is not supported for PHP $version"
else else
[ "${ts:?}" = 'zts' ] && suffix='-zts'
install_icu "$icu" >/dev/null 2>&1 install_icu "$icu" >/dev/null 2>&1
get -q -n "${ext_dir:?}/intl.so" "https://github.com/shivammathur/icu-intl/releases/download/intl-$icu/php${version:?}-intl-$icu$suffix$arch_suffix.so" get -q -n "${ext_dir:?}/intl.so" "https://github.com/shivammathur/icu-intl/releases/download/intl/php${version:?}-intl-$icu.so"
enable_extension intl extension enable_extension intl extension
add_extension_log intl "Installed and enabled with ICU $icu" add_extension_log intl "Installed and enabled with ICU $icu"
fi fi
} }
arch="$(uname -m)"
[[ "$arch" = 'arm64' || "$arch" = 'aarch64' ]] && arch_suffix='-arm64' || arch_suffix=''

View File

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

View File

@ -10,25 +10,12 @@ add_ioncube() {
status='Enabled' status='Enabled'
if ! shared_extension ioncube; then if ! shared_extension ioncube; then
status='Installed and enabled' status='Installed and enabled'
arch="$(uname -m)" os_name='lin' && [ "$(uname -s)" = "Darwin" ] && os_name='mac'
if [ "$(uname -s)" = "Darwin" ]; then get -s -n "" https://downloads.ioncube.com/loader_downloads/ioncube_loaders_"$os_name"_x86-64.tar.gz | tar -xzf - -C /tmp
[ "$arch" = "arm64" ] && os_suffix="dar_arm64" || os_suffix="mac_x86-64" sudo mv /tmp/ioncube/ioncube_loader_"$os_name"_"${version:?}".so "${ext_dir:?}/ioncube.so"
else sudo cp /tmp/ioncube/LICENSE.txt "$ext_dir"/IONCUBE_LICENSE.txt
[[ "$arch" = "i386" || "$arch" = "i686" ]] && arch=x86
[[ "$arch" = "x86_64" ]] && arch=x86-64
os_suffix="lin_$arch"
fi
ts_part="" && [ "${ts:?}" = "zts" ] && ts_part="_ts"
get -s -n "" https://downloads.ioncube.com/loader_downloads/ioncube_loaders_"$os_suffix".tar.gz | tar -xzf - -C /tmp
loader_file=/tmp/ioncube/ioncube_loader_"${os_suffix%%_*}_${version:?}$ts_part".so
if [ -e "$loader_file" ]; then
sudo mv /tmp/ioncube/ioncube_loader_"${os_suffix%%_*}_${version:?}$ts_part".so "${ext_dir:?}/ioncube.so"
sudo cp /tmp/ioncube/LICENSE.txt "$ext_dir"/IONCUBE_LICENSE.txt
echo "zend_extension=$ext_dir/ioncube.so" | sudo tee "${scan_dir:?}/00-ioncube.ini" >/dev/null 2>&1
fi
else
echo "zend_extension=$ext_dir/ioncube.so" | sudo tee "${scan_dir:?}/00-ioncube.ini" >/dev/null 2>&1
fi fi
echo "zend_extension=$ext_dir/ioncube.so" | sudo tee "${scan_dir:?}/00-ioncube.ini" >/dev/null 2>&1
add_extension_log "ioncube" "$status" add_extension_log "ioncube" "$status"
check_extension "ioncube" && add_license_log check_extension "ioncube" && add_license_log
} }

View File

@ -14,7 +14,7 @@ Function Add-InstantClient() {
if ($arch -eq 'x86') { if ($arch -eq 'x86') {
$suffix = 'nt' $suffix = 'nt'
} }
Get-File -Url https://download.oracle.com/otn_software/nt/instantclient/instantclient-basiclite-$suffix.zip -OutFile $php_dir\instantclient.zip Invoke-WebRequest -Uri https://download.oracle.com/otn_software/nt/instantclient/instantclient-basiclite-$suffix.zip -OutFile $php_dir\instantclient.zip
Expand-Archive -Path $php_dir\instantclient.zip -DestinationPath $php_dir -Force Expand-Archive -Path $php_dir\instantclient.zip -DestinationPath $php_dir -Force
Copy-Item $php_dir\instantclient*\* $php_dir Copy-Item $php_dir\instantclient*\* $php_dir
} }
@ -48,7 +48,6 @@ Function Get-Oci8DLL() {
return $_ return $_
} }
} }
return $null
} }
# Function to install oci8 and pdo_oci. # Function to install oci8 and pdo_oci.
@ -63,17 +62,22 @@ Function Add-Oci() {
try { try {
$status = 'Enabled' $status = 'Enabled'
Add-InstantClient Add-InstantClient
if($version -lt '8.4') { if ($extension -eq "pdo_oci") {
if($version -lt '5.6' -and $extension -eq 'oci8') { Enable-PhpExtension pdo_oci -Path $php_dir
Add-Content -Value "`r`nextension=php_oci8.dll" -Path $php_dir\php.ini
} else {
Enable-PhpExtension $extension -Path $php_dir
}
} else { } else {
$status = 'Installed and enabled' if(-not(Test-Path $ext_dir\php_oci8.dll)) {
Add-Extension $extension >$null 2>&1 $oci8DLL = Get-Oci8DLL
if($oci8DLL) {
Copy-Item -Path $oci8DLL -Destination $ext_dir\php_oci8.dll
} else {
$status = 'Installed and enabled'
Invoke-WebRequest -Uri (Get-Oci8Url) -OutFile $php_dir\oci8.zip
Expand-Archive -Path $php_dir\oci8.zip -DestinationPath $ext_dir -Force
}
}
Add-Content -Value "`r`nextension=php_oci8.dll" -Path $php_dir\php.ini
} }
Add-ExtensionLog $extension $status Add-Log $tick $extension $status
Add-LicenseLog Add-LicenseLog
} catch { } catch {
Add-Log $cross $extension "Could not install $extension on PHP $( $installed.FullVersion )" Add-Log $cross $extension "Could not install $extension on PHP $( $installed.FullVersion )"

View File

@ -11,37 +11,25 @@ add_license_log() {
add_client() { add_client() {
if [ ! -e "$oracle_client" ]; then if [ ! -e "$oracle_client" ]; then
sudo mkdir -p -m 777 "$oracle_home" "$oracle_client" sudo mkdir -p -m 777 "$oracle_home" "$oracle_client"
arch="$(uname -m)"
for package in basiclite sdk; do for package in basiclite sdk; do
if [ "$os" = 'Linux' ]; then if [ "$os" = 'Linux' ]; then
libs='/usr/lib/' libs='/usr/lib/'
os_name='linux' os_name='linux'
[[ "$arch" = 'arm64' || "$arch" = 'aarch64' ]] && arch_suffix='linux-arm64' || arch_suffix='linuxx64' arch='linuxx64'
lib_ext='so' lib_ext='so'
elif [ "$os" = 'Darwin' ]; then elif [ "$os" = 'Darwin' ]; then
libs='/usr/local/lib/' libs='/usr/local/lib/'
os_name='mac' os_name='mac'
arch_suffix='macos' arch='macos'
lib_ext='dylib' lib_ext='dylib'
fi fi
if [[ "$os" = 'Darwin' && ("$arch" = 'arm64' || "$arch" = 'aarch64') ]]; then get -q -n "/opt/oracle/$package.zip" "https://download.oracle.com/otn_software/$os_name/instantclient/instantclient-$package-$arch.zip"
get -q -n "/opt/oracle/$package.dmg" "https://download.oracle.com/otn_software/$os_name/instantclient/instantclient-$package-macos-arm64.dmg" unzip -o "/opt/oracle/$package.zip" -d "$oracle_home"
sudo hdiutil attach "/opt/oracle/$package.dmg"
(cd /Volumes/instantclient-"$package"-macos.arm64-* && bash install_ic.sh)
sudo cp -a ~/Downloads/instantclient_* /opt/oracle/
else
get -q -n "/opt/oracle/$package.zip" "https://download.oracle.com/otn_software/$os_name/instantclient/instantclient-$package-$arch_suffix.zip"
unzip -o "/opt/oracle/$package.zip" -d "$oracle_home"
fi
done done
for icdir in /opt/oracle/instantclient_*; do for icdir in /opt/oracle/instantclient_*; do
sudo mv "$icdir"/* "$oracle_client"/ sudo mv "$icdir"/* "$oracle_client"/
done done
sudo mkdir -p "$libs" sudo ln -sf /opt/oracle/instantclient/*.$lib_ext* $libs
sudo ln -sf /opt/oracle/instantclient/*."$lib_ext"* "$libs"
if [ "$os" = "Linux" ]; then
[ -e "$libs/$arch"-linux-gnu/libaio.so.1 ] || sudo ln -sf "$libs/$arch"-linux-gnu/libaio.so.1t64 "$libs/$arch"-linux-gnu/libaio.so.1
fi
fi fi
} }
@ -49,16 +37,11 @@ add_client() {
add_oci_helper() { add_oci_helper() {
if ! shared_extension "$ext"; then if ! shared_extension "$ext"; then
status='Installed and enabled' status='Installed and enabled'
read -r "${ext}_CONFIGURE_PREFIX_OPTS" <<< "CFLAGS=-Wno-incompatible-function-pointer-types"
read -r "${ext}_LINUX_LIBS" <<< "libaio-dev" read -r "${ext}_LINUX_LIBS" <<< "libaio-dev"
read -r "${ext}_CONFIGURE_OPTS" <<< "--with-php-config=$(command -v php-config) --with-${ext/_/-}=instantclient,$oracle_client" read -r "${ext}_CONFIGURE_OPTS" <<< "--with-php-config=$(command -v php-config) --with-${ext/_/-}=instantclient,$oracle_client"
read -r "${ext}_PATH" <<< "ext/$ext"
patch_phpize patch_phpize
if [[ $(printf "%s\n%s" "${version:?}" "8.3" | sort -V | head -n1) != "$version" ]]; then add_extension_from_source "$ext" https://github.com php php-src "$(php_src_tag)" extension get
add_extension_from_source "$ext" https://github.com php pecl-database-"$ext" main extension get
else
read -r "${ext}_PATH" <<< "ext/$ext"
add_extension_from_source "$ext" https://github.com php php-src "$(php_src_tag)" extension get
fi
restore_phpize restore_phpize
else else
enable_extension "$ext" extension enable_extension "$ext" extension

View File

@ -1,5 +0,0 @@
patch_amqp() {
if [[ $(printf '%s\n%s\n' "${version:?}" "8.5" | sort -V | head -n1) == "8.5" ]]; then
get -q -n amqp_connection_resource.c https://raw.githubusercontent.com/remicollet/php-amqp/977449987412a3d5c59a036dbab8b6d67764bb3e/amqp_connection_resource.c
fi
}

View File

@ -1,35 +0,0 @@
patch_84() {
sed -i.bak \
-e '0,/#include.*\(php_lcg.h\|php_mt_rand.h\|php_rand.h\|standard\/php_random\.h\).*/s//#include <ext\/random\/php_random.h>/' \
-e '/#include.*\(php_lcg.h\|php_mt_rand.h\|php_rand.h\|standard\/php_random\.h\)/d' \
"$1" && rm -rf *.bak
}
patch_85() {
sed -i.bak \
-e 's#ext/standard/php_smart_string.h#Zend/zend_smart_string.h#g' \
-e 's#ext/standard/php_smart_string_public.h#Zend/zend_smart_string.h#g' \
-e 's#zend_exception_get_default(TSRMLS_C)#zend_ce_exception#g' \
-e 's#zend_exception_get_default()#zend_ce_exception#g' \
"$1" && rm -rf *.bak
}
version_ge() {
ver=$1
min=$2
[[ $(printf '%s\n%s\n' "$ver" "$min" | sort -V | head -n1) == "$min" ]]
}
if version_ge "${version:?}" "8.4"; then
while IFS= read -r file; do
patch_84 "$file"
done < <(grep -rlE 'php_lcg\.h|php_mt_rand\.h|php_rand\.h|standard/php_random\.h' \
--include='*.c' --include='*.h' . || true)
fi
if version_ge "${version:?}" "8.5"; then
while IFS= read -r file; do
patch_85 "$file"
done < <(grep -rlE 'ext/standard/php_smart_string(_public)?\.h|zend_exception_get_default' \
--include='*.c' --include='*.h' . || true)
fi

View File

@ -1,9 +1,7 @@
patch_geos() { patch_geos() {
if [[ $(printf '%s\n%s\n' "${version:?}" "7.0" | sort -V | head -n1) == "7.0" ]]; then if [ "$(php -r "echo PHP_VERSION_ID;")" -ge 70000 ]; then
sed -i~ -e "s/, ce->name/, ZSTR_VAL(ce->name)/; s/ulong /zend_ulong /" geos.c sed -i~ -e "s/, ce->name/, ZSTR_VAL(ce->name)/; s/ulong /zend_ulong /" geos.c
fi fi
get -q -n /tmp/php8.patch https://git.remirepo.net/cgit/rpms/php/php-geos.git/plain/0003-add-all-arginfo-and-fix-build-with-PHP-8.patch get -q -n /tmp/php8.patch https://git.remirepo.net/cgit/rpms/php/php-geos.git/plain/0003-add-all-arginfo-and-fix-build-with-PHP-8.patch
get -q -n /tmp/toString.patch https://git.remirepo.net/cgit/rpms/php/php-geos.git/plain/0006-fix-__toString-with-8.2.patch
patch -p1 < /tmp/php8.patch 2>/dev/null || true patch -p1 < /tmp/php8.patch 2>/dev/null || true
patch -p1 < /tmp/toString.patch 2>/dev/null || true
} }

View File

@ -1,8 +1,5 @@
patch_pdo_oci() { patch_pdo_oci() {
get -q -n config.m4 https://raw.githubusercontent.com/php/php-src/PHP-8.0/ext/pdo_oci/config.m4 get -q -n config.m4 https://raw.githubusercontent.com/php/php-src/PHP-8.0/ext/pdo_oci/config.m4
if [[ $(printf '%s\n%s\n' "${version:?}" "8.5" | sort -V | head -n1) == "8.5" ]]; then
get -q -n pdo_oci.c https://raw.githubusercontent.com/shivammathur/pecl-database-pdo_oci/a9cf2c53b6de46f9e5f523bcd11fd344e3beeb85/pdo_oci.c
fi
if [[ ${version:?} =~ 5.[3-6] ]]; then if [[ ${version:?} =~ 5.[3-6] ]]; then
sudo sed -i '' "/PHP_CHECK_PDO_INCLUDES/d" config.m4 2>/dev/null || sudo sed -i "/PHP_CHECK_PDO_INCLUDES/d" config.m4 sudo sed -i '' "/PHP_CHECK_PDO_INCLUDES/d" config.m4 2>/dev/null || sudo sed -i "/PHP_CHECK_PDO_INCLUDES/d" config.m4
fi fi

View File

@ -1,5 +0,0 @@
if [[ $(printf '%s\n%s\n' "${version:?}" "8.5" | sort -V | head -n1) == "8.5" ]]; then
sed -i.bak -e 's/zval_ptr_dtor( &dbh->query_stmt_zval );/OBJ_RELEASE(dbh->query_stmt_obj);dbh->query_stmt_obj = NULL;/' php_pdo_sqlsrv_int.h
sed -i.bak -e 's/pdo_error_mode prev_err_mode/uint8_t prev_err_mode/g' pdo_dbh.cpp
rm -rf *.bak
fi

View File

@ -3,8 +3,7 @@ get_phpize() {
if [[ "${version:?}" =~ 5.[3-5] ]]; then if [[ "${version:?}" =~ 5.[3-5] ]]; then
echo '/opt/local/bin/phpize' echo '/opt/local/bin/phpize'
else else
[ -n "$brew_prefix" ] && phpize_dir="$brew_prefix" || phpize_dir="/usr/local/bin" echo "/usr/local/bin/$(readlink /usr/local/bin/phpize)"
echo "${phpize_dir}/bin/$(readlink ${phpize_dir}/bin/phpize)"
fi fi
} }

View File

@ -1,51 +1,3 @@
# Function to get the url of the phalcon release asset.
Function Get-PhalconReleaseAssetUrl() {
Param (
[Parameter(Position = 0, Mandatory = $true)]
[ValidateNotNull()]
[string]
$Semver
)
$domain = 'https://api.github.com/repos'
$releases = 'phalcon/cphalcon/releases'
$match = $null
if($extension_version -match '[3-4]') {
$nts = if (!$installed.ThreadSafe) { "_nts" } else { "" }
try {
$match = (Invoke-RestMethod -Uri "$domain/$releases/tags/v$Semver").assets | Select-String -Pattern "browser_download_url=.*(phalcon_${arch}_.*_php${version}_${extension_version}.*[0-9]${nts}.zip)"
} catch { }
if($null -eq $match) {
try {
$match = (Get-File -Url "$github/$releases/expanded_assets/v$Semver").Links.href | Select-String -Pattern "(phalcon_${arch}_.*_php${version}_${extension_version}.*[0-9]${nts}.zip)"
} catch { }
}
} else {
$nts = if (!$installed.ThreadSafe) { "-nts" } else { "-ts" }
try {
$match = (Invoke-RestMethod -Uri "$domain/$releases/tags/v$Semver").assets | Select-String -Pattern "browser_download_url=.*(php_phalcon-php${version}${nts}-windows.*-x64.zip)"
} catch { }
if($null -eq $match) {
try {
$match = (Get-File -Url "$github/$releases/expanded_assets/v$Semver").Links.href | Select-String -Pattern "(php_phalcon-php${version}${nts}-windows.*-x64.zip)"
} catch { }
}
if($null -eq $match) {
try {
$match = (Invoke-RestMethod -Uri "$domain/$releases/tags/v$Semver").assets | Select-String -Pattern "browser_download_url=.*(phalcon-php${version}${nts}-windows.*-x64.zip)"
} catch { }
}
if($null -eq $match) {
try {
$match = (Get-File -Url "$github/$releases/expanded_assets/v$Semver").Links.href | Select-String -Pattern "(phalcon-php${version}${nts}-windows.*-x64.zip)"
} catch { }
}
}
if($NULL -ne $match) {
return "$github/$releases/download/v$Semver/$($match.Matches[0].Groups[1].Value)"
}
return false;
}
# Function to add phalcon using GitHub releases. # Function to add phalcon using GitHub releases.
Function Add-PhalconFromGitHub() { Function Add-PhalconFromGitHub() {
Param ( Param (
@ -54,9 +6,16 @@ Function Add-PhalconFromGitHub() {
[string] [string]
$Semver $Semver
) )
$zip_url = Get-PhalconReleaseAssetUrl $Semver $domain = 'https://github.com'
if($zip_url) { $nts = if (!$installed.ThreadSafe) { "_nts" } else { "" }
Get-File -Url $zip_url -OutFile $ENV:RUNNER_TOOL_CACHE\phalcon.zip > $null 2>&1 $match = Invoke-WebRequest -Uri "$domain/phalcon/cphalcon/releases/v$Semver" | Select-String -Pattern "href=`"(.*phalcon_x64_.*_php${version}_${extension_version}.*[0-9]${nts}.zip)`""
if($NULL -eq $match) {
$nts = if (!$installed.ThreadSafe) { "-nts" } else { "-ts" }
$match = Invoke-WebRequest -Uri "$domain/phalcon/cphalcon/releases/v$Semver" | Select-String -Pattern "href=`"(.*phalcon-php${version}${nts}-windows.*-x64.zip)`""
}
if($NULL -ne $match) {
$zip_file = $match.Matches[0].Groups[1].Value
Invoke-WebRequest -Uri $domain/$zip_file -OutFile $ENV:RUNNER_TOOL_CACHE\phalcon.zip > $null 2>&1
Expand-Archive -Path $ENV:RUNNER_TOOL_CACHE\phalcon.zip -DestinationPath $ENV:RUNNER_TOOL_CACHE\phalcon -Force > $null 2>&1 Expand-Archive -Path $ENV:RUNNER_TOOL_CACHE\phalcon.zip -DestinationPath $ENV:RUNNER_TOOL_CACHE\phalcon -Force > $null 2>&1
Copy-Item -Path "$ENV:RUNNER_TOOL_CACHE\phalcon\php_phalcon.dll" -Destination "$ext_dir\php_phalcon.dll" Copy-Item -Path "$ENV:RUNNER_TOOL_CACHE\phalcon\php_phalcon.dll" -Destination "$ext_dir\php_phalcon.dll"
Enable-PhpExtension -Extension phalcon -Path $php_dir Enable-PhpExtension -Extension phalcon -Path $php_dir
@ -64,30 +23,17 @@ Function Add-PhalconFromGitHub() {
throw "Unable to get Phalcon release from the GitHub release" throw "Unable to get Phalcon release from the GitHub release"
} }
} }
# Function to get phalcon semver.
Function Get-PhalconSemver() {
if($extension_version -eq '3') {
return '3.4.5'
} elseif (($extension_version -eq '4') -and ($version -eq '7.2')) {
return '4.1.0'
} elseif (($extension_version -eq '5') -and ($version -eq '7.4')) {
return '5.4.0'
}
return Get-PeclPackageVersion phalcon $extension_version stable stable | Select-Object -First 1
}
# Function to install phalcon # Function to install phalcon
Function Add-PhalconHelper() { Function Add-PhalconHelper() {
$semver = Get-PhalconSemver if ($extension_version -eq '5') {
if ($extension_version -eq '3') { Add-PhalconFromGitHub -Semver (Get-PeclPackageVersion phalcon 5 snapshot stable | Select-Object -First 1)
Add-PhalconFromGitHub $semver } elseif ($extension_version -eq '4') {
} else { Install-Phpextension -Extension phalcon -MinimumStability stable -Path $php_dir
Add-Extension -Extension phalcon -Stability stable -Extension_version $semver } elseif ($extension_version -eq '3') {
Add-PhalconFromGitHub -Semver 3.4.5
} }
} }
# Function to add phalcon
Function Add-Phalcon() { Function Add-Phalcon() {
Param ( Param (
[Parameter(Position = 0, Mandatory = $true)] [Parameter(Position = 0, Mandatory = $true)]

View File

@ -1,13 +1,10 @@
# Helper function to get phalcon version # Helper function to get phalcon version
get_phalcon_version() { get_phalcon_version() {
if [ "$extension" = "phalcon5" ]; then if [ "$extension" = "phalcon5" ]; then
if [ "${version:?}" = "7.4" ]; then semver="$(get_pecl_version phalcon stable 5)"
echo '5.4.0' ([ -n "$semver" ] && echo "$semver") || get_pecl_version phalcon rc 5
else
get_pecl_version phalcon stable 5
fi
elif [ "$extension" = "phalcon4" ]; then elif [ "$extension" = "phalcon4" ]; then
echo '4.1.2' echo '4.1.3'
elif [ "$extension" = "phalcon3" ]; then elif [ "$extension" = "phalcon3" ]; then
echo '3.4.5' echo '3.4.5'
fi fi
@ -35,8 +32,8 @@ add_phalcon_helper() {
else else
package="php${version:?}-$extension" package="php${version:?}-$extension"
add_ppa ondrej/php >/dev/null 2>&1 || update_ppa ondrej/php add_ppa ondrej/php >/dev/null 2>&1 || update_ppa ondrej/php
[[ "$extension" =~ phalcon[4|5] ]] && (install_packages "php${version:?}-psr" || pecl_install psr || pecl_install psr-1.1.0) [ "$extension" = "phalcon4" ] && (install_packages "php${version:?}-psr" || pecl_install psr || pecl_install psr-1.1.0)
(check_package "$package" && install_packages "$package") || pecl_install phalcon-"$(get_phalcon_version)" || add_phalcon_from_repo (check_package "$package" && install_packages "$package") || add_phalcon_from_repo
fi fi
} }
@ -73,7 +70,7 @@ add_phalcon4() {
fi fi
} }
# Function to add phalcon5. # Function to add phalcon3.
add_phalcon5() { add_phalcon5() {
if shared_extension phalcon; then if shared_extension phalcon; then
phalcon_version=$(php -d="extension=phalcon.so" -r "echo phpversion('phalcon');" | cut -d'.' -f 1) phalcon_version=$(php -d="extension=phalcon.so" -r "echo phpversion('phalcon');" | cut -d'.' -f 1)
@ -89,9 +86,8 @@ add_phalcon5() {
# Function to add phalcon. # Function to add phalcon.
add_phalcon() { add_phalcon() {
local extension=$1 extension=$1
status='Enabled' status='Enabled'
[ "$extension" = "phalcon" ] && extension=phalcon5
extension_major_version=${extension: -1} extension_major_version=${extension: -1}
if [[ "$extension_major_version" =~ [3-5] ]]; then if [[ "$extension_major_version" =~ [3-5] ]]; then
add_phalcon"$extension_major_version" >/dev/null 2>&1 add_phalcon"$extension_major_version" >/dev/null 2>&1

View File

@ -1,158 +0,0 @@
# Get relay version
get_relay_version() {
local ext=$1
if [[ "$ext" =~ ^relay$ ]]; then
get -s -n "" "${relay_release:?}"
elif [[ $ext =~ ^relay-nightly$ ]]; then
echo "dev"
else
relay_version="${ext##*-}"
echo "v${relay_version/v//}"
fi
}
# Get OS suffix in relay artifact URL.
get_os_suffix() {
if [ "$os" = "Linux" ]; then
if [[ "$ID" =~ ubuntu|debian ]]; then
echo debian
elif [ "$ID" = "centos" ]; then
echo centos"$VERSION_ID"
else
echo "$ID"
fi
else
echo darwin
fi
}
# Get openssl suffix in relay artifact URL.
get_openssl_suffix() {
openssl_3=$(php -r "echo strpos(OPENSSL_VERSION_TEXT, 'SSL 3') !== false;")
[ "$openssl_3" = "1" ] && echo '+libssl3' || echo ''
}
# Change library paths in relay binary.
change_library_paths() {
if [ "$os" = "Darwin" ]; then
otool -L "${ext_dir:?}"/relay.so | grep -q 'ssl.1' && openssl_version='1.1' || openssl_version='3'
[ -e "${brew_prefix:?}"/opt/openssl@"$openssl_version" ] || {
safe_brew install --skip-link openssl@"$openssl_version" &&
brew link --overwrite --force openssl@"$openssl_version"
}
dylibs="$(otool -L "${ext_dir:?}"/relay.so | grep -Eo '.*\.dylib' | cut -f1 -d ' ')"
install_name_tool -change "$(echo "${dylibs}" | grep -E "libzstd.*dylib" | xargs)" "$brew_prefix"/opt/zstd/lib/libzstd.dylib "$ext_dir"/relay.so
install_name_tool -change "$(echo "${dylibs}" | grep -E "liblz4.*dylib" | xargs)" "$brew_prefix"/opt/lz4/lib/liblz4.dylib "$ext_dir"/relay.so
install_name_tool -change "$(echo "${dylibs}" | grep -E "libssl.*dylib" | xargs)" "$brew_prefix"/opt/openssl@"$openssl_version"/lib/libssl.dylib "$ext_dir"/relay.so
install_name_tool -change "$(echo "${dylibs}" | grep -E "libcrypto.*dylib" | xargs)" "$brew_prefix"/opt/openssl@"$openssl_version"/lib/libcrypto.dylib "$ext_dir"/relay.so
install_name_tool -change "$(echo "${dylibs}" | grep -E "libck.*dylib" | xargs)" "$brew_prefix"/opt/concurrencykit/lib/libck.dylib "$ext_dir"/relay.so
fi
}
# Add relay dependencies
add_relay_dependencies() {
add_extension json
add_extension msgpack
add_extension igbinary
if [ "$os" = "Darwin" ]; then
. "${0%/*}"/tools/brew.sh
configure_brew
safe_brew install lz4 hiredis zstd concurrencykit
fi
}
# Initialize relay extension ini configuration
init_relay_ini() {
relay_ini=$1
if [ -e "$relay_ini" ]; then
if [[ -n "$RELAY_KEY" ]]; then
sudo sed -i.bak "s/^; relay.key =.*/relay.key = $RELAY_KEY/" "$relay_ini"
fi
if [[ -n "$RELAY_ENVIRONMENT" ]]; then
sudo sed -i.bak "s/^; relay.environment =.*/relay.environment = $RELAY_ENVIRONMENT/" "$relay_ini"
fi
if [[ -n "$RELAY_EVICTION_POLICY" ]]; then
sudo sed -i.bak "s/^; relay.eviction_policy =.*/relay.eviction_policy = $RELAY_EVICTION_POLICY/" "$relay_ini"
fi
if [[ -n "$RELAY_MAX_MEMORY" ]]; then
sudo sed -i.bak "s/^; relay.maxmemory =.*/relay.maxmemory = $RELAY_MAX_MEMORY/" "$relay_ini"
fi
sudo rm -rf "$relay_ini".bak
fi
}
# Enable relay extension
enable_relay() {
relay_ini=$1
if [ -e "$relay_ini" ]; then
init_relay_ini "$relay_ini"
if [ "$os" = "Linux" ]; then
sudo cp "$relay_ini" "${ini_dir:?}"/../mods-available/relay.ini
sudo phpenmod -v "${version:?}" relay
else
sudo cp "${relay_ini}" "${scan_dir:?}"/60-relay.ini
fi
fi
}
# Patch binary id in relay extension
init_relay_binary_id() {
if [ -e "${ext_dir:?}"/relay.so ]; then
sudo LC_ALL=C sed -i.bak "s/00000000-0000-0000-0000-000000000000/$(uuidgen)/" "$ext_dir"/relay.so || true
fi
}
# Configure relay extension
configure_relay() {
change_library_paths
init_relay_binary_id
enable_relay "${ext_dir}"/relay.ini
}
# Helper function to add relay extension
add_relay_helper() {
local arch=$1
os_suffix="$(get_os_suffix)"
openssl_suffix="$(get_openssl_suffix)"
artifact_file_name="relay-$relay_version-php${version:?}-$os_suffix-$arch$openssl_suffix.tar.gz"
url="$relay_trunk"/"$relay_version"/"$artifact_file_name"
get -q -n /tmp/relay.tar.gz "$url"
if (! [ -e /tmp/relay.tar.gz ] || ! file /tmp/relay.tar.gz | grep -q 'gzip'); then
if [ "$openssl_suffix" = '+libssl3' ]; then
get -q -n /tmp/relay.tar.gz "${url/+libssl3/}"
else
get -q -n /tmp/relay.tar.gz "${url/.tar/+libssl3.tar}"
fi
fi
if [ -e /tmp/relay.tar.gz ] && file /tmp/relay.tar.gz | grep -q 'gzip'; then
sudo tar --strip-components=1 -xzf /tmp/relay.tar.gz -C "${ext_dir:?}"
sudo mv "${ext_dir:?}"/relay-pkg.so "${ext_dir:?}"/relay.so
fi
}
# Add relay extension
add_relay() {
local ext=$1
local arch
local url
local message
local error
os=$(uname -s)
arch="$(uname -m | sed 's/_/-/')"
relay_release=https://builds.r2.relay.so/meta/latest
relay_trunk=https://builds.r2.relay.so
if [[ "$arch" = "x86-64" && "$os" = "Darwin" ]]; then
error="Relay extension is not available for macOS x86_64 architecture"
else
relay_version=$(get_relay_version "$ext")
add_relay_dependencies >/dev/null 2>&1
if shared_extension relay; then
message="Enabled"
else
add_relay_helper "$arch" >/dev/null 2>&1
message="Installed and enabled ${relay_version}"
fi
configure_relay >/dev/null 2>&1
fi
add_extension_log relay "$message" "$error"
}

View File

@ -1,7 +1,3 @@
os="$(uname -s)"
os_lower=$(echo "$os" | tr '[:upper:]' '[:lower:]')
os_capital=$(echo "$os" | tr '[:lower:]' '[:upper:]')
# Function to parse extension environment variables # Function to parse extension environment variables
parse_args() { parse_args() {
local extension=${1%-*} local extension=${1%-*}
@ -17,7 +13,7 @@ parse_args() {
# Function to parse configure options for pecl # Function to parse configure options for pecl
# Make sure we have all options in name="value" form i.e XML properties. # Make sure we have all options in name="value" form i.e XML properties.
parse_pecl_configure_options() { parse_pecl_configure_options() {
configure_opts=$(echo "$1" | sed -E -e "s#['\"]|--##g") configure_opts=$(echo "$1" | sed -r -e "s#['\"]|--##g")
IFS=' ' read -r -a opts_array <<< "$configure_opts" IFS=' ' read -r -a opts_array <<< "$configure_opts"
output_opts=() output_opts=()
for opt in "${opts_array[@]}"; do for opt in "${opts_array[@]}"; do
@ -40,7 +36,7 @@ add_lib_log() {
# Function to check if a library is installed # Function to check if a library is installed
check_lib() { check_lib() {
local lib=$1 local lib=$1
if [ "$os" = "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
[ "x$(find "${brew_prefix:?}"/Cellar -maxdepth 1 -name "$lib")" != "x" ] [ "x$(find "${brew_prefix:?}"/Cellar -maxdepth 1 -name "$lib")" != "x" ]
@ -60,11 +56,9 @@ add_linux_libs() {
add_darwin_libs() { add_darwin_libs() {
local lib=$1 local lib=$1
if ! check_lib "$lib"; then if ! check_lib "$lib"; then
brew install "$lib" >/dev/null 2>&1 || true
if [[ "$lib" = *@* ]]; then if [[ "$lib" = *@* ]]; then
safe_brew install --skip-link "$lib" >/dev/null 2>&1 || true
brew link --overwrite --force "$lib" >/dev/null 2>&1 || true brew link --overwrite --force "$lib" >/dev/null 2>&1 || true
else
safe_brew install "$lib" >/dev/null 2>&1 || true
fi fi
fi fi
add_lib_log "$lib" add_lib_log "$lib"
@ -74,7 +68,7 @@ add_darwin_libs() {
add_libs() { add_libs() {
local all_libs=("$@") local all_libs=("$@")
for lib in "${all_libs[@]}"; do for lib in "${all_libs[@]}"; do
if [ "$os" = "Linux" ]; then if [ "$(uname -s)" = "Linux" ]; then
add_linux_libs "$lib" add_linux_libs "$lib"
else else
add_darwin_libs "$lib" add_darwin_libs "$lib"
@ -82,19 +76,6 @@ add_libs() {
done done
} }
# Function to get required libraries for an extension
get_libraries() {
local extension=$1
{
parse_args "$extension" LIBS
parse_args "$extension" "$os_capital"_LIBS
[ -r "${src:?}/configs/${os_lower}_libs" ] && \
grep -E "^[[:space:]]*${extension}[[:space:]]*=" "${src:?}/configs/${os_lower}_libs" | \
head -n1 | \
sed -E "s/^[[:space:]]*${extension}[[:space:]]*=[[:space:]]*//"
} | xargs -n 1 2>/dev/null | sort -u | xargs 2>/dev/null
}
# Function to run command in a group # Function to run command in a group
run_group() { run_group() {
local command=$1 local command=$1
@ -102,16 +83,12 @@ run_group() {
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
local status=$?
rm ./run_group.sh rm ./run_group.sh
echo "$END_GROUP" echo "$END_GROUP"
return $status
} }
patch_extension() { patch_extension() {
local extension=$1 local extension=$1
# shellcheck source=.
. "${scripts:?}"/extensions/patches/common.sh
if [ -e "${scripts:?}"/extensions/patches/"$extension".sh ]; then if [ -e "${scripts:?}"/extensions/patches/"$extension".sh ]; then
# shellcheck source=. # shellcheck source=.
. "${scripts:?}"/extensions/patches/"$extension".sh . "${scripts:?}"/extensions/patches/"$extension".sh
@ -138,10 +115,9 @@ fetch_extension() {
elif [ "$fetch" = "pecl" ]; then elif [ "$fetch" = "pecl" ]; then
source="pecl" source="pecl"
pecl_name=${extension/http/pecl_http} pecl_name=${extension/http/pecl_http}
capital_pecl_name=$(echo "$pecl_name" | tr '[:lower:]' '[:upper:]') get -q -n /tmp/"$pecl_name".tgz https://pecl.php.net/get/"$pecl_name"-"$release".tgz
get -q -n /tmp/"$pecl_name".tgz https://pecl.php.net/get/"$pecl_name"-"$release".tgz https://pecl.php.net/get/"$capital_pecl_name"-"$release".tgz
tar -xzf /tmp/"$pecl_name".tgz -C /tmp tar -xzf /tmp/"$pecl_name".tgz -C /tmp
cd /tmp/"$pecl_name"-"$release" 2>/dev/null || cd /tmp/"$capital_pecl_name"-"$release" 2>/dev/null || exit cd /tmp/"$pecl_name"-"$release" || exit
fi fi
} }
@ -156,7 +132,7 @@ add_extension_from_source() {
local fetch=${7:-clone} local fetch=${7:-clone}
slug="$extension-$release" slug="$extension-$release"
source="$url/$org/$repo" source="$url/$org/$repo"
libraries="$(get_libraries "$extension")" libraries="$(parse_args "$extension" LIBS) $(parse_args "$extension" "$(uname -s)"_LIBS)"
opts="$(parse_args "$extension" CONFIGURE_OPTS)" opts="$(parse_args "$extension" CONFIGURE_OPTS)"
prefix_opts="$(parse_args "$extension" CONFIGURE_PREFIX_OPTS)" prefix_opts="$(parse_args "$extension" CONFIGURE_PREFIX_OPTS)"
suffix_opts="$(parse_args "$extension" CONFIGURE_SUFFIX_OPTS)" suffix_opts="$(parse_args "$extension" CONFIGURE_SUFFIX_OPTS)"
@ -170,12 +146,11 @@ add_extension_from_source() {
add_log "${cross:?}" "$source" "$source does not have a PHP extension" add_log "${cross:?}" "$source" "$source does not have a PHP extension"
else else
[[ -n "${libraries// }" ]] && run_group "add_libs $libraries" "add libraries" [[ -n "${libraries// }" ]] && run_group "add_libs $libraries" "add libraries"
[ "${debug:?}" = "debug" ] && suffix_opts="$suffix_opts --enable-debug"
patch_extension "$extension" >/dev/null 2>&1 patch_extension "$extension" >/dev/null 2>&1
run_group "phpize" "phpize" && \ run_group "phpize" "phpize"
run_group "sudo $prefix_opts ./configure $suffix_opts $opts" "configure" && \ run_group "sudo $prefix_opts ./configure $suffix_opts $opts" "configure"
run_group "sudo $prefix_opts make -j$(nproc 2>/dev/null || sysctl -n hw.ncpu)" "make" && \ run_group "sudo make -j$(nproc 2>/dev/null || sysctl -n hw.ncpu)" "make"
run_group "sudo make install" "make install" && \ run_group "sudo make install" "make install"
enable_extension "$extension" "$prefix" enable_extension "$extension" "$prefix"
fi fi
) )

View File

@ -1,80 +0,0 @@
# Function to get sqlsrv extension version.
Function Get-SqlsrvReleaseVersion() {
if ($version -le '7.2') {
# Use the releases from PECL for these versions
return null;
} elseif($version -eq '7.3') {
return '5.9.0'
} elseif ($version -eq '7.4') {
return '5.10.1'
} elseif ($version -eq '8.0') {
return '5.11.1'
} elseif ($version -match '8.[1-2]') {
return '5.12.0'
} else {
return 'latest'
}
}
# Function to get sqlsrv extension release URL.
Function Get-SqlsrvReleaseUrl()
{
$extensionVersion = Get-SqlsrvReleaseVersion
if($extensionVersion) {
$repo = "$github/microsoft/msphpsql"
if($extensionVersion -eq 'latest') {
return "$repo/releases/latest/download/Windows-$version.zip"
} else {
return "$repo/releases/download/v$extensionVersion/Windows-$version.zip"
}
}
}
# Function to add sqlsrv extension from GitHub.
Function Add-SqlsrvFromMSGithub()
{
Param (
[Parameter(Position = 0, Mandatory = $true)]
[ValidateNotNull()]
[string]
$extension
)
try {
$zipUrl = SqlsrvReleaseUrl
if($zipUrl) {
$nts = if (!$installed.ThreadSafe) { "nts" } else { "ts" }
$noDotVersion = $version.replace('.', '')
$extensionFilePath = "Windows-$version\$arch\php_${extension}_${noDotVersion}_${nts}.dll"
Get-File -Url $zipUrl -OutFile $ENV:RUNNER_TOOL_CACHE\sqlsrv.zip > $null 2>&1
Expand-Archive -Path $ENV:RUNNER_TOOL_CACHE\sqlsrv.zip -DestinationPath $ENV:RUNNER_TOOL_CACHE\sqlsrv -Force > $null 2>&1
Copy-Item -Path "$ENV:RUNNER_TOOL_CACHE\sqlsrv\$extensionFilePath" -Destination "$ext_dir\php_$extension.dll"
Enable-PhpExtension -Extension $extension -Path $php_dir
}
} catch { }
}
# Function to add sqlsrv extension.
Function Add-Sqlsrv() {
Param (
[Parameter(Position = 0, Mandatory = $true)]
[ValidateNotNull()]
[string]
$extension
)
$status = 'Enabled'
if (Test-Path $ext_dir\php_$extension.dll) {
Enable-PhpExtension -Extension $extension -Path $php_dir
} else {
try {
Add-ExtensionFromGithub $extension > $null 2>&1
} catch {}
if (-not(Test-Extension $extension)) {
Add-SqlsrvFromMSGithub $extension >$null 2>&1
}
if (-not(Test-Extension $extension)) {
Add-Extension $extension >$null 2>&1
}
$status = 'Installed and enabled'
}
Add-ExtensionLog $extension $status
}

View File

@ -2,15 +2,16 @@
get_sqlsrv_version() { get_sqlsrv_version() {
if [[ "${version:?}" =~ 7.[0-3] ]]; then if [[ "${version:?}" =~ 7.[0-3] ]]; then
echo '5.9.0' echo '5.9.0'
elif [[ "${version:?}" =~ 7.4 ]]; then
echo '5.10.1'
elif [[ "${version:?}" =~ 8.0 ]]; then
echo '5.11.1'
elif [[ "${version:?}" =~ 8.[1-2] ]]; then
echo '5.12.0'
else else
# Return an empty string so that pecl will install the latest version. echo '5.10.0'
echo '' fi
}
add_unixodbc() {
if [ "$(uname -s)" = 'Linux' ]; then
install_packages unixodbc-dev
else
brew install unixodbc
fi fi
} }
@ -18,10 +19,6 @@ get_sqlsrv_version() {
add_sqlsrv() { add_sqlsrv() {
ext=$1 ext=$1
ext_version=$(get_sqlsrv_version) ext_version=$(get_sqlsrv_version)
if [ "$(uname -s)" = 'Linux' ]; then add_unixodbc >/dev/null 2>&1
install_packages unixodbc-dev add_pecl_extension "$ext" "$ext_version" extension
add_pecl_extension "$ext" "$ext_version" extension
else
add_brew_extension "$ext" extension
fi
} }

Some files were not shown because too many files have changed in this diff Show More