Compare commits

..

49 Commits

Author SHA1 Message Date
89b2566bb0 Check github-token on enterprise
On GitHub enterprise we may get a Personal Access token or a default token generated by GitHub that maybe not have the permissions required to access public GitHub, so we check and add it only if it can authenticate with the public GitHub API
2025-08-02 12:12:58 +05:30
dcec1cf0b4 Override GITHUB_TOKEN if COMPOSER_TOKEN is set 2025-07-30 22:30:05 +05:30
ccf2c627fe Bump version to 2.35.2 2025-07-29 19:08:58 +05:30
2a597f617d Fix race condition 2025-07-29 02:08:56 +05:30
2282b6a082 Bump version to 2.35.1 2025-07-28 20:33:43 +05:30
11373c6dce Fix shellcheck in add_tools.sh [skip ci] 2025-07-28 20:13:02 +05:30
50ad25710d Use auth.json for composer authentication 2025-07-28 20:11:02 +05:30
c1c6c51867 Update geos patch [skip ci] 2025-07-28 17:22:40 +05:30
34a5396826 Bump node.js dependencies 2025-07-28 14:49:02 +05:30
a0d5abedf1 Revert hiredis patch 2025-07-28 14:49:02 +05:30
102ffdc294 Add patch for gearman [skip ci] 2025-07-28 14:47:16 +05:30
97cf0581e3 Filter shared extensions to enable on Windows 2025-07-28 13:30:51 +05:30
bac87fed32 Cleanup in cubrid.sh 2025-07-20 02:01:02 +05:30
b9341130b4 Fix mirror setup in ppa.sh 2025-07-20 02:00:10 +05:30
e1dc734412 Remove ondrej/pkg-gearman ppa [skip ci] 2025-07-20 01:48:35 +05:30
20169f80b7 Add -Force to Move-Item in mago.ps1 to handle workflow reruns
Co-authored-by: shivammathur <1571086+shivammathur@users.noreply.github.com>
2025-07-17 11:52:44 +00:00
ec1e2c6601 Fix mago extraction paths for binary location in subdirectories
Co-authored-by: shivammathur <1571086+shivammathur@users.noreply.github.com>
2025-07-17 11:44:09 +00:00
5581e61575 Update test and README for mago tool - remove 'latest' from test and add to README
Co-authored-by: shivammathur <1571086+shivammathur@users.noreply.github.com>
2025-07-17 11:27:31 +00:00
de4f59c442 Address PR review feedback - simplify validation and remove license display
Co-authored-by: shivammathur <1571086+shivammathur@users.noreply.github.com>
2025-07-17 11:16:20 +00:00
26dc9b4fed Add mago tool support as custom package
Co-authored-by: shivammathur <1571086+shivammathur@users.noreply.github.com>
2025-07-17 10:57:30 +00:00
8d11cf02d2 Initial plan 2025-07-17 10:44:21 +00:00
8aee7c58b7 Sort tools.json [skip ci] 2025-07-17 15:05:00 +05:30
725b40730f Merge pull request #974 from shivammathur/copilot/fix-d6851e4e-e860-4989-8c53-4391e7116ea7
Add support for roave/backward-compatibility-check tool
2025-07-17 14:59:25 +05:30
b8f4bf011c Merge branch 'develop' into copilot/fix-d6851e4e-e860-4989-8c53-4391e7116ea7 2025-07-17 14:58:44 +05:30
f9fbb516a6 Address review feedback: revert src/tools.ts, remove run.sh, rename tool to backward-compatibility-check
Co-authored-by: shivammathur <1571086+shivammathur@users.noreply.github.com>
2025-07-17 08:54:16 +00:00
987ba5bfe9 Add support for roave/backward-compatibility-check tool
Co-authored-by: shivammathur <1571086+shivammathur@users.noreply.github.com>
2025-07-17 08:37:06 +00:00
9dffd40113 Add roave/backward-compatibility-check tool support
Co-authored-by: shivammathur <1571086+shivammathur@users.noreply.github.com>
2025-07-17 08:34:50 +00:00
2dfe351907 Initial plan 2025-07-17 08:22:49 +00:00
1897d72bb4 Merge pull request #973 from shivammathur/copilot/fix-74435ef3-8c22-4393-8d87-090d0d41f7fa
Add support for shipmonk/name-collision-detector tool
2025-07-17 13:42:50 +05:30
879090af77 Add link for name-collision-detector tool in README
Co-authored-by: shivammathur <1571086+shivammathur@users.noreply.github.com>
2025-07-17 08:07:21 +00:00
a3845d84ae Add name-collision-detector to README tools section
Co-authored-by: shivammathur <1571086+shivammathur@users.noreply.github.com>
2025-07-17 08:01:28 +00:00
24d382d1f8 Add support for shipmonk/name-collision-detector tool
Co-authored-by: shivammathur <1571086+shivammathur@users.noreply.github.com>
2025-07-17 07:25:13 +00:00
7a5da9d8dc Initial plan 2025-07-17 07:15:57 +00:00
011ab6e363 Update sponsors section 2025-07-17 07:32:30 +05:30
545bc26d45 Minor fix in README 2025-07-17 07:32:30 +05:30
55463ffe4f Add support for github-token input 2025-07-17 07:32:24 +05:30
2a3befd7ab Do not fallback extension to default version on fail-fast 2025-07-17 05:07:54 +05:30
7cc4441283 Use ppa.setup-php.com [skip ci] 2025-07-17 04:49:47 +05:30
4a4c5a48bb Update dependencies 2025-07-09 05:18:20 +05:30
3514a658eb Update branch references to main 2025-07-09 04:36:51 +05:30
7aefaa0b54 Merge pull request #967 from jrfnl/feature/readme-fix-broken-link
README: fix broken link
2025-06-25 05:04:51 +05:30
048eb79ef3 README: fix broken link 2025-06-25 01:31:29 +02:00
29247235f0 Merge pull request #966 from OskarStark/patch-1
⚙ Improvement: Update docs
2025-06-24 20:41:11 +05:30
e84efebd6e Update docs
As version 2 is the standard right now, make it clear by setting the v1 manually.
2025-06-24 17:39:04 +03:00
0f7f1d08e3 Upgrade to Jest 30 2025-06-13 02:06:31 +05:30
433bdeeaf0 Bump version to 2.34.1 2025-06-12 03:52:26 +05:30
1c5378302c Update node.js dependencies 2025-06-11 15:17:10 +05:30
c251c791ff Fix pipe in get_sha256 2025-06-11 15:00:38 +05:30
36fada6981 Fix tool-cache directory on self-hosted runners 2025-06-11 14:57:09 +05:30
28 changed files with 2699 additions and 1472 deletions

View File

@ -2,7 +2,7 @@ name: Node workflow
on: on:
pull_request: pull_request:
branches: branches:
- master - main
- develop - develop
- verbose - verbose
paths-ignore: paths-ignore:
@ -10,7 +10,7 @@ on:
- 'examples/**' - 'examples/**'
push: push:
branches: branches:
- master - main
- develop - develop
- verbose - verbose
paths-ignore: paths-ignore:

View File

@ -3,7 +3,7 @@ on:
workflow_dispatch: workflow_dispatch:
pull_request: pull_request:
branches: branches:
- master - main
- develop - develop
- verbose - verbose
paths-ignore: paths-ignore:
@ -11,7 +11,7 @@ on:
- 'examples/**' - 'examples/**'
push: push:
branches: branches:
- master - main
- develop - develop
- verbose - verbose
paths-ignore: paths-ignore:

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/master/Node.gitignore # Rest of the file pulled from https://github.com/github/gitignore/blob/main/Node.gitignore
# Logs # Logs
logs logs
*.log *.log

View File

@ -229,7 +229,7 @@ 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.
[`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`], [`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`] [`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`]
```yaml ```yaml
- name: Setup PHP with tools - name: Setup PHP with tools
@ -258,19 +258,6 @@ These tools can be set up globally using the `tools` input. It accepts a string
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.
With the exception of major versions of `composer`, if you specify only the `major` version or the version in `major.minor` format for a 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.
```yaml
- name: Setup PHP with tools
uses: shivammathur/setup-php@v2
with:
php-version: '8.4'
tools: php-cs-fixer:3.64, phpunit:11.4
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. - 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
@ -278,7 +265,7 @@ These tools can be set up globally using the `tools` input. It accepts a string
uses: shivammathur/setup-php@v2 uses: shivammathur/setup-php@v2
with: with:
php-version: '8.4' php-version: '8.4'
tools: composer:v2 tools: composer:v1
``` ```
- 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.
@ -430,7 +417,7 @@ Disable coverage for these reasons:
- The `php-version-file` input if it exists - The `php-version-file` input if it exists
- A `composer.lock` file and the `platform-overrides.php` value - A `composer.lock` file and the `platform-overrides.php` value
- A `composer.json` file and the `config.platform.php` value - A `composer.json` file and the `config.platform.php` value
- If the `composer.lock` or `composer.json` file is in a sub-directory in your repository, please specify the subdirectory path in `COMPOSER_PROJECT_DIR` env. - 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) #### `php-version-file` (optional)
@ -438,7 +425,7 @@ Disable coverage for these reasons:
- Accepts a `string`. For example `'.phpenv-version'`. - Accepts a `string`. For example `'.phpenv-version'`.
- See [PHP support](#tada-php-support) for the supported PHP versions. - See [PHP support](#tada-php-support) for the supported PHP versions.
- By default, `.php-version` file is used. - By default, `.php-version` file is used.
- The file either have the PHP version as its content, or follow the asdf `.tool-versions` format. - 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. - If not specified and the default `.php-version` file is not found, the latest stable PHP version is set up.
#### `extensions` (optional) #### `extensions` (optional)
@ -473,6 +460,13 @@ 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`
@ -561,8 +555,6 @@ jobs:
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:${{ matrix.phpunit-versions }} tools: php-cs-fixer, phpunit:${{ matrix.phpunit-versions }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
``` ```
### Nightly Build Setup ### Nightly Build Setup
@ -804,19 +796,20 @@ restore-keys: ${{ runner.os }}-composer-${{ matrix.prefer }}-
### GitHub Composer Authentication ### GitHub Composer Authentication
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. 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.
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.4' php-version: '8.4'
env: github-token: ${{ secrets.YOUR_PAT_TOKEN }}
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.
@ -1015,19 +1008,26 @@ Many users and organisations support setup-php via [GitHub Sponsors](https://git
These companies generously provide setup-php their products and services to aid in the development of this project. These companies generously provide setup-php their products and services to aid in the development of this project.
<p> <p>
<a href="https://www.jetbrains.com/?from=setup-php"> <a target="_blank" href="https://www.jetbrains.com/?from=setup-php">
<img src="https://setup-php.com/sponsors/jetbrains.svg" alt="JetBrains" width="212" height="120"> <img src="https://setup-php.com/sponsors/jetbrains.svg" alt="JetBrains" width="140" height="80">
</a> </a>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<a href="https://www.macstadium.com/opensource/members#gh-light-mode-only"> <a target="_blank" href="https://www.cloudflare.com/lp/project-alexandria/#gh-light-mode-only">
<img src="https://setup-php.com/sponsors/macstadium.png" alt="Mac Stadium" width="296" height="120"> <img src="https://setup-php.com/sponsors/cloudflare.svg" alt="Cloudflare" width="240" height="80">
</a> </a>
<a href="https://www.macstadium.com/opensource/members#gh-dark-mode-only"> <a target="_blank" href="https://www.cloudflare.com/lp/project-alexandria/#gh-dark-mode-only">
<img src="https://setup-php.com/sponsors/macstadium-white.png" alt="Mac Stadium" width="296" height="120"> <img src="https://setup-php.com/sponsors/cloudflare-white.svg" alt="Cloudflare" width="240" height="80">
</a> </a>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<a href="https://tidelift.com/subscription/pkg/npm-setup-php"> <a target="_blank" href="https://www.macstadium.com/company/opensource#gh-light-mode-only">
<img src="https://setup-php.com/sponsors/tidelift.png" alt="Tidelift" width="140" height="120"> <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="#">
<img src="https://setup-php.com/sponsors/tidelift.png" alt="Tidelift" width="94" height="80">
</a> </a>
</p> </p>
@ -1056,6 +1056,7 @@ These companies generously provide setup-php their products and services to aid
<!-- 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
@ -1075,6 +1076,8 @@ These companies generously provide setup-php their products and services to aid
[`flex`]: https://flex.symfony.com/ [`flex`]: https://flex.symfony.com/
[`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

View File

@ -393,7 +393,7 @@ describe('Tools tests', () => {
it.each([ it.each([
[ [
'blackfire, blackfire-player, box, churn, cs2pr, flex, grpc_php_plugin, 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, 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',
[ [
'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_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',
@ -403,6 +403,8 @@ describe('Tools tests', () => {
'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_composer_tool 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/PHP-CS-Fixer/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/humbug/php-scoper/releases/latest/download/php-scoper.phar php-scoper "--version"',
@ -436,7 +438,7 @@ describe('Tools tests', () => {
it.each([ it.each([
[ [
'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, 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', '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',
[ [
'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_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_composer_tool behat behat behat/ scoped',
@ -451,6 +453,8 @@ describe('Tools tests', () => {
'add_composer_tool flex flex symfony/ global', 'add_composer_tool 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"',
@ -469,6 +473,7 @@ describe('Tools tests', () => {
'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 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_composer_tool 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"',
@ -485,7 +490,7 @@ describe('Tools tests', () => {
it.each([ it.each([
[ [
'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, pie', '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',
[ [
'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-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',
@ -495,6 +500,8 @@ describe('Tools tests', () => {
'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 name-collision-detector name-collision-detector shipmonk/ scoped',
'Add-ComposerTool 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 "status"', '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',

View File

@ -27,6 +27,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'

2
dist/index.js vendored

File diff suppressed because one or more lines are too long

3765
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.34.0", "version": "2.35.2",
"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",
@ -40,27 +40,30 @@
"compare-versions": "^6.1.1" "compare-versions": "^6.1.1"
}, },
"devDependencies": { "devDependencies": {
"@eslint/compat": "^1.2.9", "@eslint/compat": "^1.3.1",
"@eslint/js": "9.28.0", "@eslint/js": "9.32.0",
"@types/jest": "^29.5.14", "@types/jest": "^30.0.0",
"@types/node": "^22.15.30", "@types/node": "^24.1.0",
"@typescript-eslint/eslint-plugin": "^8.33.1", "@typescript-eslint/eslint-plugin": "^8.38.0",
"@typescript-eslint/parser": "^8.33.1", "@typescript-eslint/parser": "^8.38.0",
"@vercel/ncc": "^0.38.3", "@vercel/ncc": "^0.38.3",
"eslint": "9.28.0", "eslint": "9.32.0",
"eslint-config-prettier": "^10.1.5", "eslint-config-prettier": "^10.1.8",
"eslint-plugin-import": "^2.31.0", "eslint-plugin-import": "^2.32.0",
"eslint-plugin-jest": "^28.13.0", "eslint-plugin-jest": "^29.0.1",
"eslint-plugin-prettier": "^5.4.1", "eslint-plugin-prettier": "^5.5.3",
"globals": "^16.2.0", "globals": "^16.3.0",
"jest": "^29.7.0", "jest": "^30.0.5",
"jest-circus": "^29.7.0", "jest-circus": "^30.0.5",
"nock": "^14.0.5", "nock": "^14.0.7",
"prettier": "^3.5.3", "prettier": "^3.6.2",
"simple-git-hooks": "^2.13.0", "simple-git-hooks": "^2.13.0",
"ts-jest": "^29.3.4", "ts-jest": "^29.4.0",
"typescript": "^5.8.3" "typescript": "^5.8.3"
}, },
"overrides": {
"test-exclude": "^7.0.1"
},
"bugs": { "bugs": {
"url": "https://github.com/shivammathur/setup-php/issues" "url": "https://github.com/shivammathur/setup-php/issues"
}, },

View File

@ -1,4 +1,9 @@
{ {
"backward-compatibility-check": {
"type": "composer",
"repository": "roave/backward-compatibility-check",
"scope": "scoped"
},
"box": { "box": {
"type": "phar", "type": "phar",
"repository": "box-project/box", "repository": "box-project/box",
@ -45,6 +50,12 @@
"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",
@ -53,6 +64,11 @@
"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",
@ -233,6 +249,12 @@
"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",
@ -331,11 +353,5 @@
"extension": ".phar", "extension": ".phar",
"version_parameter": "--version", "version_parameter": "--version",
"version_prefix": "v" "version_prefix": "v"
},
"easy-coding-standard": {
"type": "composer",
"alias": "ecs",
"repository": "symplify/easy-coding-standard",
"scope": "scoped"
} }
} }

View File

@ -18,7 +18,6 @@ export async function getScript(os: string): Promise<string> {
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);
@ -48,6 +47,14 @@ export async function getScript(os: string): Promise<string> {
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
*/ */
@ -55,6 +62,7 @@ export async function run(): Promise<void> {
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);
await setEnv();
await exec(tool + run_path); await exec(tool + run_path);
} }

View File

@ -212,7 +212,7 @@ get_scan_dir() {
# Function to handle self-hosted runner setup. # Function to handle self-hosted runner setup.
self_hosted_helper() { self_hosted_helper() {
: sudo mkdir -p /opt/hostedtoolcache >/dev/null 2>&1 || true
} }
# Function to Setup PHP. # Function to Setup PHP.

View File

@ -216,7 +216,7 @@ add_pecl_extension() {
add_log "${tick:?}" "$extension" "Enabled" add_log "${tick:?}" "$extension" "Enabled"
else else
[ -n "$pecl_version" ] && pecl_version="-$pecl_version" [ -n "$pecl_version" ] && pecl_version="-$pecl_version"
pecl_install "$extension$pecl_version" || add_extension "$extension" "$(get_extension_prefix "$extension")" >/dev/null 2>&1 pecl_install "$extension$pecl_version" || ( [ "${fail_fast:?}" = "false" ] && add_extension "$extension" "$(get_extension_prefix "$extension")" >/dev/null 2>&1)
extension_version="$(php -r "echo phpversion('$extension');")" extension_version="$(php -r "echo phpversion('$extension');")"
[ -n "$extension_version" ] && extension_version="-$extension_version" [ -n "$extension_version" ] && extension_version="-$extension_version"
add_extension_log "$extension$extension_version" "Installed and enabled" add_extension_log "$extension$extension_version" "Installed and enabled"

View File

@ -7,15 +7,6 @@ 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

@ -1,6 +1,5 @@
# 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

View File

@ -0,0 +1,5 @@
patch_gearman() {
if [[ "${version:?}" =~ ${nightly_versions:?} ]]; then
sed -i~ -e "s/zend_exception_get_default()/zend_ce_exception/" php_gearman.c
fi
}

View File

@ -1,7 +1,11 @@
patch_geos() { patch_geos() {
if [ "$(php -r "echo PHP_VERSION_ID;")" -ge 70000 ]; then php_version_id="$(php -r "echo PHP_VERSION_ID;")"
if [ "$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
if [ "$php_version_id" -ge 80500 ]; then
sed -i~ -e "s/zend_exception_get_default(TSRMLS_C)/zend_ce_exception/" geos.c
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 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

View File

@ -48,19 +48,6 @@ change_library_paths() {
fi fi
} }
# Add hiredis library
add_hiredis() {
hiredis_url=https://github.com/redis/hiredis/archive/v1.1.0.tar.gz
hiredis_sha=fe6d21741ec7f3fc9df409d921f47dfc73a4d8ff64f4ac6f1d95f951bf7f53d6
sed -Ei.bak -e "s#^ url.*# url \"$hiredis_url\"#" -e "s#^ sha256.*# sha256 \"$hiredis_sha\"#" ${core_repo:?}/Formula/h/hiredis.rb
brew install -s hiredis
lib_dir="${brew_prefix:?}"/opt/hiredis/lib
if [ -e "$lib_dir"/libhiredis_ssl.1.1.0.dylib ]; then
sudo ln -sf "$lib_dir"/libhiredis_ssl.1.1.0.dylib "$lib_dir"/libhiredis_ssl.dylib.1.1.0
fi
mv ${core_repo:?}/Formula/h/hiredis.rb.bak ${core_repo:?}/Formula/h/hiredis.rb
}
# Add relay dependencies # Add relay dependencies
add_relay_dependencies() { add_relay_dependencies() {
add_extension json add_extension json
@ -69,8 +56,7 @@ add_relay_dependencies() {
if [ "$os" = "Darwin" ]; then if [ "$os" = "Darwin" ]; then
. "${0%/*}"/tools/brew.sh . "${0%/*}"/tools/brew.sh
configure_brew configure_brew
brew install lz4 zstd concurrencykit brew install lz4 hiredis zstd concurrencykit
add_hiredis
fi fi
} }

View File

@ -20,6 +20,7 @@ self_hosted_helper() {
sudo ln -sf /usr/bin/apt-get /usr/bin/apt-fast sudo ln -sf /usr/bin/apt-get /usr/bin/apt-fast
trap "sudo rm -f /usr/bin/apt-fast 2>/dev/null" exit trap "sudo rm -f /usr/bin/apt-fast 2>/dev/null" exit
fi fi
sudo mkdir -p /opt/hostedtoolcache >/dev/null 2>&1 || true
install_packages apt-transport-https ca-certificates curl file make jq unzip autoconf automake gcc g++ gnupg install_packages apt-transport-https ca-certificates curl file make jq unzip autoconf automake gcc g++ gnupg
} }

View File

@ -28,6 +28,52 @@ Function Edit-ComposerConfig() {
Set-ComposerAuth Set-ComposerAuth
} }
# Function to update auth.json.
Function Update-AuthJson {
[CmdletBinding()]
param(
[Parameter(Mandatory)][string[]] $ComposerAuth
)
if (Test-Path $composer_home\auth.json) {
try {
$existing = Get-Content $composer_home\auth.json -Raw | ConvertFrom-Json
} catch {
$existing = [PSCustomObject]@{}
}
} else {
$existing = [PSCustomObject]@{}
}
foreach ($fragment in $ComposerAuth) {
$piece = ('{' + $fragment + '}') | ConvertFrom-Json
foreach ($prop in $piece.PSObject.Properties) {
if ($prop.Name -eq 'http-basic') {
if (-not $existing.'http-basic') {
$existing | Add-Member -MemberType NoteProperty -Name 'http-basic' -Value ([PSCustomObject]@{}) -Force
}
foreach ($domainProp in $prop.Value.PSObject.Properties) {
$existing.'http-basic' | Add-Member -MemberType NoteProperty -Name $domainProp.Name -Value $domainProp.Value -Force
}
} else {
$existing | Add-Member -MemberType NoteProperty -Name $prop.Name -Value $prop.Value -Force
}
}
}
Set-Content -Path $composer_home\auth.json -Value ($existing | ConvertTo-Json -Depth 5)
}
function Test-GitHubPublicAccess {
param(
[Parameter(Mandatory=$true)]
[string]$Token
)
try {
Invoke-RestMethod -Uri 'https://api.github.com/' -Headers @{ Authorization = "token $Token" } -ErrorAction Stop | Out-Null
return $true
} catch {
return $false
}
}
# Function to setup authentication in composer. # Function to setup authentication in composer.
Function Set-ComposerAuth() { Function Set-ComposerAuth() {
if(Test-Path env:COMPOSER_AUTH_JSON) { if(Test-Path env:COMPOSER_AUTH_JSON) {
@ -41,14 +87,18 @@ Function Set-ComposerAuth() {
if(Test-Path env:PACKAGIST_TOKEN) { if(Test-Path env:PACKAGIST_TOKEN) {
$composer_auth += '"http-basic": {"repo.packagist.com": { "username": "token", "password": "' + $env:PACKAGIST_TOKEN + '"}}' $composer_auth += '"http-basic": {"repo.packagist.com": { "username": "token", "password": "' + $env:PACKAGIST_TOKEN + '"}}'
} }
if(-not(Test-Path env:GITHUB_TOKEN) -and (Test-Path env:COMPOSER_TOKEN)) { $write_token = $true
$env:GITHUB_TOKEN = $env:COMPOSER_TOKEN $token = if ($env:COMPOSER_TOKEN) { $env:COMPOSER_TOKEN } else { $env:GITHUB_TOKEN }
} if ($token) {
if (Test-Path env:GITHUB_TOKEN) { if ($env:GITHUB_SERVER_URL -ne "https://github.com" -and -not(Test-GitHubPublicAccess $token)) {
$composer_auth += '"github-oauth": {"github.com": "' + $env:GITHUB_TOKEN + '"}' $write_token = $false
}
if($write_token) {
$composer_auth += '"github-oauth": {"github.com": "' + $token + '"}'
}
} }
if($composer_auth.length) { if($composer_auth.length) {
Add-Env COMPOSER_AUTH ('{' + ($composer_auth -join ',') + '}') Update-AuthJson $composer_auth
} }
} }

View File

@ -11,7 +11,7 @@ get_tool_version() {
alp="[a-zA-Z0-9\.]" alp="[a-zA-Z0-9\.]"
version_regex="[0-9]+((\.{1}$alp+)+)(\.{0})(-$alp+){0,1}" version_regex="[0-9]+((\.{1}$alp+)+)(\.{0})(-$alp+){0,1}"
if [ "$tool" = "composer" ]; then if [ "$tool" = "composer" ]; then
composer_alias_version="$(grep -Ea "const\sBRANCH_ALIAS_VERSION" "$tool_path_dir/composer" | grep -Eo "$version_regex")" composer_alias_version="$(grep -Ea "const\sBRANCH_ALIAS_VERSION" "${tool_path_dir:?}/composer" | grep -Eo "$version_regex")"
if [[ -n "$composer_alias_version" ]]; then if [[ -n "$composer_alias_version" ]]; then
composer_version="$composer_alias_version+$(grep -Ea "const\sVERSION" "$tool_path_dir/composer" | grep -Eo "$alp+" | tail -n 1)" composer_version="$composer_alias_version+$(grep -Ea "const\sVERSION" "$tool_path_dir/composer" | grep -Eo "$alp+" | tail -n 1)"
else else
@ -46,6 +46,30 @@ configure_composer() {
set_composer_auth set_composer_auth
} }
# Function to merge auth.json fragments.
update_auth_json() {
local auth_file="$composer_home/auth.json"
local merged
[[ -f "$auth_file" ]] && merged=$(<"$auth_file") || merged='{}'
for frag in "$@"; do
local obj="{$frag}"
merged=$(jq -n --argjson b "$merged" --argjson n "$obj" '
if $n|has("http-basic") then
(($b["http-basic"]//{}) + $n["http-basic"]) as $hb
| ($b + $n) | .["http-basic"] = $hb
else
$b + $n
end
')
done
printf '%s' "$merged" > "$composer_home/auth.json"
}
# Function to check if public GitHub token authentication is possible.
can_access_public_github() {
curl --fail -s -H "Authorization: token $1" 'https://api.github.com/' >/dev/null 2>&1
}
# Function to setup authentication in composer. # Function to setup authentication in composer.
set_composer_auth() { set_composer_auth() {
if [ -n "$COMPOSER_AUTH_JSON" ]; then if [ -n "$COMPOSER_AUTH_JSON" ]; then
@ -59,11 +83,18 @@ set_composer_auth() {
if [ -n "$PACKAGIST_TOKEN" ]; then if [ -n "$PACKAGIST_TOKEN" ]; then
composer_auth+=( '"http-basic": {"repo.packagist.com": { "username": "token", "password": "'"$PACKAGIST_TOKEN"'"}}' ) composer_auth+=( '"http-basic": {"repo.packagist.com": { "username": "token", "password": "'"$PACKAGIST_TOKEN"'"}}' )
fi fi
if [ -n "${GITHUB_TOKEN:-$COMPOSER_TOKEN}" ]; then token="${COMPOSER_TOKEN:-$GITHUB_TOKEN}"
composer_auth+=( '"github-oauth": {"github.com": "'"${GITHUB_TOKEN:-$COMPOSER_TOKEN}"'"}' ) if [ -n "$token" ]; then
write_token=true
if [ "$GITHUB_SERVER_URL" != "https://github.com" ]; then
can_access_public_github "$token" || write_token=false
fi
if [ "$write_token" = 'true' ]; then
composer_auth+=( '"github-oauth": {"github.com": "'"$token"'"}' )
fi
fi fi
if ((${#composer_auth[@]})); then if ((${#composer_auth[@]})); then
add_env COMPOSER_AUTH "{$(IFS=$','; echo "${composer_auth[*]}")}" update_auth_json "${composer_auth[@]}"
fi fi
} }

View File

@ -0,0 +1,36 @@
Function Get-MagoTag() {
$releases = 'https://github.com/carthage-software/mago/releases'
if("$mago_tag" -eq "latest") {
$mago_tag = (Get-File -Url $releases/latest).BaseResponse.RequestMessage.RequestUri.Segments[-1]
} else {
try {
[net.httpWebRequest] $request = [net.webRequest]::create("$releases/tag/$mago_tag")
$request.Method = "HEAD"
[net.httpWebResponse] $response = $request.getResponse()
$response.Close()
$mago_tag = "$mago_tag"
} catch {
$mago_tag = (Get-File -Url $releases/latest).BaseResponse.RequestMessage.RequestUri.Segments[-1]
}
}
return $mago_tag
}
Function Add-Mago() {
param(
[Parameter(Mandatory = $true, Position = 0, HelpMessage = 'The mago version to be installed')]
[ValidatePattern('^latest$|^\d+\.\d+\.\d+$')]
[string] $mago_tag
)
$mago_tag = Get-MagoTag
$arch_name = 'x86_64'
if(-not([Environment]::Is64BitOperatingSystem)) {
$arch_name = 'i686'
}
$url = "https://github.com/carthage-software/mago/releases/download/$mago_tag/mago-$mago_tag-$arch_name-pc-windows-msvc.zip"
Get-File -Url $url -OutFile $bin_dir\mago.zip >$null 2>&1
Expand-Archive -Path $bin_dir\mago.zip -DestinationPath $bin_dir\mago -Force >$null 2>&1
Move-Item -Path $bin_dir\mago\mago-$mago_tag-$arch_name-pc-windows-msvc\mago.exe -Destination $bin_dir\mago.exe -Force
Add-ToProfile $current_profile 'mago' "New-Alias mago $bin_dir\mago.exe"
Add-Log $tick "mago" "Added mago $mago_tag"
}

29
src/scripts/tools/mago.sh Normal file
View File

@ -0,0 +1,29 @@
get_mago_tag() {
if [ "$mago_tag" = "latest" ]; then
mago_tag=$(get -s -n "" https://github.com/carthage-software/mago/releases/latest 2<&1 | grep -m 1 -Eo "tag/([0-9]+(\.[0-9]+)?(\.[0-9]+)?)" | head -n 1 | cut -d '/' -f 2)
else
status_code=$(get -v -n /tmp/mago.tmp "https://github.com/carthage-software/mago/releases/tag/$mago_tag")
if [ "$status_code" = "200" ]; then
mago_tag="$mago_tag"
else
mago_tag=$(get -s -n "" https://github.com/carthage-software/mago/releases/latest 2<&1 | grep -m 1 -Eo "tag/([0-9]+(\.[0-9]+)?(\.[0-9]+)?)" | head -n 1 | cut -d '/' -f 2)
fi
fi
}
add_mago() {
mago_tag=$1
get_mago_tag
(
platform='unknown-linux-gnu'
[ "$(uname -s)" = "Darwin" ] && platform='apple-darwin'
arch="$(uname -m)"
[[ "$arch" = 'arm64' || "$arch" = 'aarch64' ]] && arch='aarch64'
[[ "$arch" = 'x86_64' || "$arch" = 'amd64' ]] && arch='x86_64'
get -q -n /tmp/mago.tar.gz "https://github.com/carthage-software/mago/releases/download/$mago_tag/mago-$mago_tag-$arch-$platform.tar.gz"
sudo tar -xzf /tmp/mago.tar.gz -C /tmp/
sudo mv /tmp/mago-$mago_tag-$arch-$platform/mago /usr/local/bin/mago
sudo chmod +x /usr/local/bin/mago
) >/dev/null 2>&1
add_log "${tick:?}" "mago" "Added mago $mago_tag"
}

View File

@ -164,7 +164,7 @@ remove_list() {
# Function to check if ubuntu ppa is up # Function to check if ubuntu ppa is up
is_ubuntu_ppa_up() { is_ubuntu_ppa_up() {
ppa=${1:-ondrej/php} ppa=${1:-ondrej/php}
curl -s --connect-timeout 5 --max-time 5 --head --fail "$lpc_ppa/$ppa/ubuntu/dists/$VERSION_CODENAME/Release" > /dev/null curl -s --connect-timeout 10 --max-time 10 --head --fail "$lpc_ppa/$ppa/ubuntu/dists/$VERSION_CODENAME/Release" > /dev/null
} }
# Function to add the PPA mirror. # Function to add the PPA mirror.
@ -172,8 +172,8 @@ add_ppa_sp_mirror() {
ppa=$1 ppa=$1
ppa_name="$(basename "$ppa")" ppa_name="$(basename "$ppa")"
remove_list "$ppa" || true remove_list "$ppa" || true
[ "${debug:?}" = "debug" ] && add_list sp/"$ppa_name" "$sp/$ppa/ubuntu" "$sp/$ppa/ubuntu/key.gpg" "$VERSION_CODENAME" "main/debug" [ "${debug:?}" = "debug" ] && add_list sp/"$ppa_name" "$ppa_sp/$ppa/ubuntu" "$ppa_sp/$ppa/ubuntu/key.gpg" "$VERSION_CODENAME" "main/debug"
add_list sp/"$ppa_name" "$sp/$ppa/ubuntu" "$sp/$ppa/ubuntu/key.gpg" add_list sp/"$ppa_name" "$ppa_sp/$ppa/ubuntu" "$ppa_sp/$ppa/ubuntu/key.gpg"
} }
# Function to add a PPA. # Function to add a PPA.
@ -182,11 +182,13 @@ add_ppa() {
ppa=${1:-ondrej/php} ppa=${1:-ondrej/php}
if [[ "$ID" = "ubuntu" || "$ID_LIKE" =~ ubuntu ]] && [[ "$ppa" =~ "ondrej/" ]]; then if [[ "$ID" = "ubuntu" || "$ID_LIKE" =~ ubuntu ]] && [[ "$ppa" =~ "ondrej/" ]]; then
if is_ubuntu_ppa_up "$ppa" ; then if is_ubuntu_ppa_up "$ppa" ; then
[ "${runner:?}" = "self-hosted" ] && find "$list_dir" -type f -name 'sp*' -exec grep -qF "$sp" {} \; -delete [ "${runner:?}" = "self-hosted" ] && find "$list_dir" -type f -name 'sp*' -exec grep -qF "${sp/https:\/\/}" {} \; -delete
[ "${debug:?}" = "debug" ] && add_list "$ppa" "$lpc_ppa/$ppa/ubuntu" "$lpc_ppa/$ppa/ubuntu" "$VERSION_CODENAME" "main/debug" [ "${debug:?}" = "debug" ] && add_list "$ppa" "$lpc_ppa/$ppa/ubuntu" "$lpc_ppa/$ppa/ubuntu" "$VERSION_CODENAME" "main/debug"
add_list "$ppa" add_list "$ppa"
else elif [ "$ppa" = "ondrej/php" ]; then
add_ppa_sp_mirror "$ppa" add_ppa_sp_mirror "$ppa"
else
add_log "${cross:?}" "$ppa" "PPA $ppa is not available"
fi fi
elif [[ "$ID" = "debian" || "$ID_LIKE" =~ debian ]] && [[ "$ppa" =~ "ondrej/" ]]; then elif [[ "$ID" = "debian" || "$ID_LIKE" =~ debian ]] && [[ "$ppa" =~ "ondrej/" ]]; then
[ "${debug:?}" = "debug" ] && add_list "$ppa" "$sury"/"${ppa##*/}"/ "$sury"/"${ppa##*/}"/apt.gpg "$VERSION_CODENAME" "main/debug" [ "${debug:?}" = "debug" ] && add_list "$ppa" "$sury"/"${ppa##*/}"/ "$sury"/"${ppa##*/}"/apt.gpg "$VERSION_CODENAME" "main/debug"
@ -225,6 +227,7 @@ lpc_ppa='https://ppa.launchpadcontent.net'
key_dir='/usr/share/keyrings' key_dir='/usr/share/keyrings'
dist_info_dir='/usr/share/distro-info' dist_info_dir='/usr/share/distro-info'
sury='https://packages.sury.org' sury='https://packages.sury.org'
ppa_sp='https://ppa.setup-php.com'
sp='https://setup-php.com' sp='https://setup-php.com'
sks=( sks=(
'https://keyserver.ubuntu.com' 'https://keyserver.ubuntu.com'

View File

@ -110,11 +110,11 @@ release_lock() {
# Function to get the SHA256 hash of a string. # Function to get the SHA256 hash of a string.
get_sha256() { get_sha256() {
local input=$1 local input=$1
if command -v sha256sum >/dev/null 2>&1; then if command -v sha256sum >/dev/null; then
printf '%s' "$input" | sha256sum | cut -d' ' -f1 printf '%s' "$input" | sha256sum | cut -d' ' -f1
elif command -v shasum >/dev/null 2>&1; then elif command -v shasum >/dev/null; then
printf '%s' "$input" | shasum -a 256 | cut -d' ' -f1 printf '%s' "$input" | shasum -a 256 | cut -d' ' -f1
elif command -v openssl >/dev/null 2>&1; then elif command -v openssl >/dev/null; then
printf '%s' "$input" | openssl dgst -sha256 | cut -d' ' -f2 printf '%s' "$input" | openssl dgst -sha256 | cut -d' ' -f2
fi fi
} }
@ -221,7 +221,7 @@ self_hosted_setup() {
exit 1 exit 1
else else
self_hosted_helper >/dev/null 2>&1 self_hosted_helper >/dev/null 2>&1
add_env RUNNER_TOOL_CACHE /tmp add_env RUNNER_TOOL_CACHE /opt/hostedtoolcache
fi fi
fi fi
} }

View File

@ -447,7 +447,7 @@ if($version -lt "5.5") {
} else { } else {
$enable_extensions += ('opcache') $enable_extensions += ('opcache')
} }
Enable-PhpExtension -Extension $enable_extensions -Path $php_dir Enable-PhpExtension -Extension ($enable_extensions | Where-Object { Test-Path $ext_dir\php_$_.dll }) -Path $php_dir
Add-PhpCAInfo Add-PhpCAInfo
Add-OpenSSLConf Add-OpenSSLConf
Copy-Item -Path $src\configs\pm\*.json -Destination $env:RUNNER_TOOL_CACHE Copy-Item -Path $src\configs\pm\*.json -Destination $env:RUNNER_TOOL_CACHE

View File

@ -419,6 +419,7 @@ export async function addPhive(data: RS): Promise<string> {
* @param data * @param data
*/ */
export async function addPHPUnitTools(data: RS): Promise<string> { export async function addPHPUnitTools(data: RS): Promise<string> {
/* istanbul ignore next */
if (data['version'] === 'latest') { if (data['version'] === 'latest') {
data['version'] = data['version'] =
(await packagist.search(data['packagist'], data['php_version'])) ?? (await packagist.search(data['packagist'], data['php_version'])) ??

View File

@ -456,6 +456,7 @@ export async function readPHPVersion(): Promise<string> {
const composerLock = path.join(composerProjectDir, 'composer.lock'); const composerLock = path.join(composerProjectDir, 'composer.lock');
if (fs.existsSync(composerLock)) { if (fs.existsSync(composerLock)) {
const lockFileContents = JSON.parse(fs.readFileSync(composerLock, 'utf8')); const lockFileContents = JSON.parse(fs.readFileSync(composerLock, 'utf8'));
/* istanbul ignore next */
if ( if (
lockFileContents['platform-overrides'] && lockFileContents['platform-overrides'] &&
lockFileContents['platform-overrides']['php'] lockFileContents['platform-overrides']['php']
@ -469,6 +470,7 @@ export async function readPHPVersion(): Promise<string> {
const composerFileContents = JSON.parse( const composerFileContents = JSON.parse(
fs.readFileSync(composerJson, 'utf8') fs.readFileSync(composerJson, 'utf8')
); );
/* istanbul ignore next */
if ( if (
composerFileContents['config'] && composerFileContents['config'] &&
composerFileContents['config']['platform'] && composerFileContents['config']['platform'] &&