mirror of
https://github.com/shivammathur/setup-php.git
synced 2025-07-19 05:13:28 +07:00
Compare commits
26 Commits
Author | SHA1 | Date | |
---|---|---|---|
0f7f1d08e3 | |||
433bdeeaf0 | |||
1c5378302c | |||
c251c791ff | |||
36fada6981 | |||
27853eb8b4 | |||
18b776ee45 | |||
2ec652d38d | |||
8d8f975af3 | |||
12b910a04d | |||
962fc445e2 | |||
6ba658ae8d | |||
c954e9c756 | |||
b595b415e2 | |||
9c22be2b20 | |||
ac0e29410e | |||
2cae8ac286 | |||
df8d123345 | |||
d371420c90 | |||
287979ae16 | |||
dd942787eb | |||
d000f49d9a | |||
dc7e73e115 | |||
755f6046e1 | |||
ec0360b904 | |||
373563aabe |
14
README.md
14
README.md
@ -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.
|
||||
|
||||
[`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`], [`pint`], [`prestissimo`], [`protoc`], [`psalm`], [`rector`], [`symfony`] or [`symfony-cli`], [`vapor`] or [`vapor-cli`], [`wp`] or [`wp-cli`]
|
||||
[`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`]
|
||||
|
||||
```yaml
|
||||
- name: Setup PHP with tools
|
||||
@ -309,6 +309,17 @@ These tools can be set up globally using the `tools` input. It accepts a string
|
||||
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.
|
||||
|
||||
```yaml
|
||||
- name: Setup PHP with fail-fast
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: '8.4'
|
||||
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.
|
||||
@ -1086,6 +1097,7 @@ These companies generously provide setup-php their products and services to aid
|
||||
[`phpunit`]: https://phpunit.de/
|
||||
[`phpunit-bridge`]: https://symfony.com/doc/current/components/phpunit_bridge.html
|
||||
[`phpunit-polyfills`]: https://github.com/Yoast/PHPUnit-Polyfills
|
||||
[`pie`]: https://github.com/php/pie
|
||||
[`pint`]: https://github.com/laravel/pint
|
||||
[`prestissimo`]: https://github.com/hirak/prestissimo
|
||||
[`protoc`]: https://developers.google.com/protocol-buffers/
|
||||
|
@ -258,8 +258,9 @@ describe('Tools tests', () => {
|
||||
|
||||
it.each`
|
||||
version | php_version | os | script
|
||||
${'latest'} | ${'7.4'} | ${'linux'} | ${'add_tool https://github.com/phar-io/phive/releases/download/3.2.1/phive-3.2.1.phar phive'}
|
||||
${'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'}
|
||||
${'latest'} | ${'8.0'} | ${'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'} | ${'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.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'}
|
||||
@ -392,7 +393,7 @@ describe('Tools tests', () => {
|
||||
|
||||
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',
|
||||
'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',
|
||||
[
|
||||
'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',
|
||||
@ -413,7 +414,7 @@ describe('Tools tests', () => {
|
||||
'add_tool https://www.phing.info/get/phing-latest.phar phing "-v"',
|
||||
'add_composer_tool phinx phinx robmorgan/ scoped',
|
||||
'add_composer_tool phinx phinx:1.2.3 robmorgan/ scoped',
|
||||
'add_tool https://github.com/phar-io/phive/releases/download/3.2.1/phive-3.2.1.phar phive "status"',
|
||||
'add_tool https://github.com/phar-io/phive/releases/download/0.15.3/phive-0.15.3.phar phive "status"',
|
||||
'add_composer_tool phpunit-bridge phpunit-bridge symfony/ global',
|
||||
'add_composer_tool phpunit-polyfills phpunit-polyfills yoast/ global',
|
||||
'add_tool https://github.com/laravel/pint/releases/latest/download/pint.phar pint "-V"',
|
||||
@ -422,7 +423,8 @@ describe('Tools tests', () => {
|
||||
'add_protoc latest',
|
||||
'add_symfony latest',
|
||||
'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"',
|
||||
'add_tool https://github.com/php/pie/releases/latest/download/pie.phar pie "-V"'
|
||||
]
|
||||
]
|
||||
])('checking addTools on linux', async (tools_csv, scripts) => {
|
||||
@ -434,7 +436,7 @@ describe('Tools tests', () => {
|
||||
|
||||
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',
|
||||
'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',
|
||||
[
|
||||
'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',
|
||||
@ -453,7 +455,7 @@ describe('Tools tests', () => {
|
||||
'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_composer_tool phinx phinx robmorgan/ scoped',
|
||||
'add_tool https://github.com/phar-io/phive/releases/download/1.2.3/phive-1.2.3.phar phive',
|
||||
'add_tool https://github.com/phar-io/phive/releases/download/0.15.3/phive-0.15.3.phar phive',
|
||||
'add_devtools php-config',
|
||||
'add_tool https://github.com/PHPCSStandards/PHP_CodeSniffer/releases/latest/download/phpcbf.phar phpcbf "--version"',
|
||||
'add_tool https://phar.phpunit.de/phpcpd.phar phpcpd "--version"',
|
||||
@ -470,7 +472,8 @@ describe('Tools tests', () => {
|
||||
'add_symfony latest',
|
||||
'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_composer_tool easy-coding-standard easy-coding-standard symplify/ scoped'
|
||||
'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) => {
|
||||
@ -482,7 +485,7 @@ describe('Tools tests', () => {
|
||||
|
||||
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',
|
||||
'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',
|
||||
[
|
||||
'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',
|
||||
@ -493,13 +496,14 @@ describe('Tools tests', () => {
|
||||
'Tool does_not_exist is not supported',
|
||||
'Add-ComposerTool flex flex symfony/ global',
|
||||
'Add-ComposerTool phinx phinx robmorgan/ scoped',
|
||||
'Add-Tool https://github.com/phar-io/phive/releases/download/0.13.2/phive-0.13.2.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',
|
||||
'phpize is not a windows tool',
|
||||
'Add-Tool https://github.com/phpmd/phpmd/releases/latest/download/phpmd.phar phpmd "--version"',
|
||||
'Add-ComposerTool phpunit-bridge phpunit-bridge symfony/ global',
|
||||
'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) => {
|
||||
|
@ -1,6 +1,7 @@
|
||||
import fs from 'fs';
|
||||
import * as path from 'path';
|
||||
import * as utils from '../src/utils';
|
||||
import * as fetchModule from '../src/fetch';
|
||||
|
||||
/**
|
||||
* Mock @actions/core
|
||||
@ -12,15 +13,6 @@ jest.mock('@actions/core', () => ({
|
||||
info: jest.fn()
|
||||
}));
|
||||
|
||||
/**
|
||||
* Mock fetch.ts
|
||||
*/
|
||||
jest.mock('../src/fetch', () => ({
|
||||
fetch: jest.fn().mockImplementation(() => {
|
||||
return {data: '{ "latest": "8.1", "5.x": "5.6" }'};
|
||||
})
|
||||
}));
|
||||
|
||||
describe('Utils tests', () => {
|
||||
it('checking readEnv', async () => {
|
||||
process.env['test'] = 'setup-php';
|
||||
@ -43,15 +35,27 @@ describe('Utils tests', () => {
|
||||
});
|
||||
|
||||
it('checking getManifestURL', async () => {
|
||||
expect(await utils.getManifestURL()).toContain('php-versions.json');
|
||||
for (const url of await utils.getManifestURLS()) {
|
||||
expect(url).toContain('php-versions.json');
|
||||
}
|
||||
});
|
||||
|
||||
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('7')).toBe('7.0');
|
||||
expect(await utils.parseVersion('7.4')).toBe('7.4');
|
||||
expect(await utils.parseVersion('5.x')).toBe('5.6');
|
||||
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 () => {
|
||||
|
4
dist/index.js
vendored
4
dist/index.js
vendored
File diff suppressed because one or more lines are too long
5866
package-lock.json
generated
5866
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
32
package.json
32
package.json
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "setup-php",
|
||||
"version": "2.33.0",
|
||||
"version": "2.34.1",
|
||||
"private": false,
|
||||
"description": "Setup PHP for use with GitHub Actions",
|
||||
"main": "lib/install.js",
|
||||
@ -40,25 +40,25 @@
|
||||
"compare-versions": "^6.1.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@eslint/compat": "^1.2.8",
|
||||
"@eslint/js": "9.24.0",
|
||||
"@eslint/compat": "^1.3.0",
|
||||
"@eslint/js": "9.28.0",
|
||||
"@types/jest": "^29.5.14",
|
||||
"@types/node": "^22.14.1",
|
||||
"@typescript-eslint/eslint-plugin": "^8.29.1",
|
||||
"@typescript-eslint/parser": "^8.29.1",
|
||||
"@types/node": "^24.0.1",
|
||||
"@typescript-eslint/eslint-plugin": "^8.34.0",
|
||||
"@typescript-eslint/parser": "^8.34.0",
|
||||
"@vercel/ncc": "^0.38.3",
|
||||
"eslint": "9.24.0",
|
||||
"eslint-config-prettier": "^10.1.2",
|
||||
"eslint": "9.28.0",
|
||||
"eslint-config-prettier": "^10.1.5",
|
||||
"eslint-plugin-import": "^2.31.0",
|
||||
"eslint-plugin-jest": "^28.11.0",
|
||||
"eslint-plugin-prettier": "^5.2.6",
|
||||
"globals": "^16.0.0",
|
||||
"jest": "^29.7.0",
|
||||
"jest-circus": "^29.7.0",
|
||||
"nock": "^14.0.3",
|
||||
"eslint-plugin-jest": "^28.13.3",
|
||||
"eslint-plugin-prettier": "^5.4.1",
|
||||
"globals": "^16.2.0",
|
||||
"jest": "^30.0.0",
|
||||
"jest-circus": "^30.0.0",
|
||||
"nock": "^14.0.5",
|
||||
"prettier": "^3.5.3",
|
||||
"simple-git-hooks": "^2.12.1",
|
||||
"ts-jest": "^29.3.1",
|
||||
"simple-git-hooks": "^2.13.0",
|
||||
"ts-jest": "^29.4.0",
|
||||
"typescript": "^5.8.3"
|
||||
},
|
||||
"bugs": {
|
||||
|
@ -20,3 +20,5 @@
|
||||
23.04,lunar
|
||||
23.10,mantic
|
||||
24.04,noble
|
||||
24.10,oracular
|
||||
25.10,plucky
|
||||
|
|
@ -136,6 +136,14 @@
|
||||
"version_prefix": "",
|
||||
"version_parameter": "-V"
|
||||
},
|
||||
"pie": {
|
||||
"type": "phar",
|
||||
"repository": "php/pie",
|
||||
"extension": ".phar",
|
||||
"domain": "https://github.com",
|
||||
"version_prefix": "",
|
||||
"version_parameter": "-V"
|
||||
},
|
||||
"pint": {
|
||||
"type": "phar",
|
||||
"repository": "laravel/pint",
|
||||
|
@ -69,7 +69,6 @@ add_brew_extension() {
|
||||
else
|
||||
add_brew_tap "$php_tap"
|
||||
add_brew_tap "$ext_tap"
|
||||
sudo mv "$tap_dir"/"$ext_tap"/.github/deps/"$formula"/* "${core_repo:?}/Formula/" 2>/dev/null || true
|
||||
update_dependencies >/dev/null 2>&1
|
||||
handle_dependency_extensions "$formula" "$extension" >/dev/null 2>&1
|
||||
(brew install "${brew_opts[@]}" "$ext_tap/$formula@$version" >/dev/null 2>&1 && copy_brew_extensions "$formula") || pecl_install "$extension" >/dev/null 2>&1
|
||||
@ -136,7 +135,9 @@ update_dependencies() {
|
||||
patch_brew
|
||||
if ! [ -e /tmp/update_dependencies ]; then
|
||||
for repo in "$brew_repo" "$core_repo"; do
|
||||
git_retry -C "$repo" fetch origin master && git -C "$repo" reset --hard origin/master
|
||||
if [ -e "$repo" ]; then
|
||||
git_retry -C "$repo" fetch origin master && git -C "$repo" reset --hard origin/master
|
||||
fi
|
||||
done
|
||||
echo '' | sudo tee /tmp/update_dependencies >/dev/null 2>&1
|
||||
fi
|
||||
@ -209,6 +210,11 @@ get_scan_dir() {
|
||||
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.
|
||||
setup_php() {
|
||||
step_log "Setup PHP"
|
||||
|
@ -48,12 +48,17 @@ change_library_paths() {
|
||||
fi
|
||||
}
|
||||
|
||||
# Link hiredis library
|
||||
link_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
|
||||
# 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
|
||||
@ -64,8 +69,8 @@ add_relay_dependencies() {
|
||||
if [ "$os" = "Darwin" ]; then
|
||||
. "${0%/*}"/tools/brew.sh
|
||||
configure_brew
|
||||
brew install hiredis lz4 zstd concurrencykit
|
||||
link_hiredis
|
||||
brew install lz4 zstd concurrencykit
|
||||
add_hiredis
|
||||
fi
|
||||
}
|
||||
|
||||
|
@ -83,8 +83,10 @@ run_group() {
|
||||
echo "$command" | sudo tee ./run_group.sh >/dev/null 2>&1
|
||||
echo "$GROUP$log"
|
||||
. ./run_group.sh
|
||||
local status=$?
|
||||
rm ./run_group.sh
|
||||
echo "$END_GROUP"
|
||||
return $status
|
||||
}
|
||||
|
||||
patch_extension() {
|
||||
@ -150,10 +152,10 @@ add_extension_from_source() {
|
||||
[[ -n "${libraries// }" ]] && run_group "add_libs $libraries" "add libraries"
|
||||
[ "${debug:?}" = "debug" ] && suffix_opts="$suffix_opts --enable-debug"
|
||||
patch_extension "$extension" >/dev/null 2>&1
|
||||
run_group "phpize" "phpize"
|
||||
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 install" "make install"
|
||||
run_group "phpize" "phpize" && \
|
||||
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 install" "make install" && \
|
||||
enable_extension "$extension" "$prefix"
|
||||
fi
|
||||
)
|
||||
|
@ -20,6 +20,7 @@ self_hosted_helper() {
|
||||
sudo ln -sf /usr/bin/apt-get /usr/bin/apt-fast
|
||||
trap "sudo rm -f /usr/bin/apt-fast 2>/dev/null" exit
|
||||
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
|
||||
}
|
||||
|
||||
|
@ -58,6 +58,11 @@ Function Set-ComposerEnv() {
|
||||
(Get-Content $src\configs\composer.env -Raw) -replace '(?m)^COMPOSER_PROCESS_TIMEOUT=.*$', "COMPOSER_PROCESS_TIMEOUT=$env:COMPOSER_PROCESS_TIMEOUT" | Set-Content $src\configs\composer.env
|
||||
}
|
||||
Add-EnvPATH $src\configs\composer.env
|
||||
if($env:COMPOSER_ALLOW_PLUGINS) {
|
||||
$env:COMPOSER_ALLOW_PLUGINS -split '\s*,\s*' | Where-Object { $_ } | ForEach-Object {
|
||||
& composer global config --no-plugins "allow-plugins.$_" true > $null 2>&1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Function to extract tool version.
|
||||
|
@ -75,6 +75,11 @@ set_composer_env() {
|
||||
sed -i "$sed_arg" "$composer_env" 2>/dev/null || sed -i '' "$sed_arg" "$composer_env"
|
||||
fi
|
||||
add_env_path "$composer_env"
|
||||
if [ -n "$COMPOSER_ALLOW_PLUGINS" ]; then
|
||||
echo "$COMPOSER_ALLOW_PLUGINS" | tr ',' '\n' | sed 's/^[[:space:]]*//;s/[[:space:]]*$//' | grep -v '^$' | while IFS= read -r plugin; do
|
||||
composer global config --no-plugins "allow-plugins.$plugin" true >/dev/null 2>&1
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
# Helper function to configure tools.
|
||||
|
@ -129,7 +129,8 @@ add_list() {
|
||||
arch=$(dpkg --print-architecture)
|
||||
[ -e "$key_source" ] && key_file=$key_source || key_file="$key_dir"/"${ppa/\//-}"-keyring.gpg
|
||||
add_key "$ppa" "$ppa_url" "$package_dist" "$key_source" "$key_file"
|
||||
echo "deb [arch=$arch signed-by=$key_file] $ppa_url $package_dist $branches" | sudo tee -a "$list_dir"/"${ppa/\//-}".list >/dev/null 2>&1
|
||||
sudo rm -rf "$list_dir"/"${ppa/\//-}".list || true
|
||||
echo "deb [arch=$arch signed-by=$key_file] $ppa_url $package_dist $branches" | sudo tee -a "$list_dir"/"${ppa%%/*}"-"$ID"-"${ppa#*/}"-"$package_dist".list >/dev/null 2>&1
|
||||
update_lists "$ppa" "$ppa_search"
|
||||
. /etc/os-release
|
||||
fi
|
||||
@ -181,6 +182,7 @@ add_ppa() {
|
||||
ppa=${1:-ondrej/php}
|
||||
if [[ "$ID" = "ubuntu" || "$ID_LIKE" =~ ubuntu ]] && [[ "$ppa" =~ "ondrej/" ]]; then
|
||||
if is_ubuntu_ppa_up "$ppa" ; then
|
||||
[ "${runner:?}" = "self-hosted" ] && find "$list_dir" -type f -name 'sp*' -exec grep -qF "$sp" {} \; -delete
|
||||
[ "${debug:?}" = "debug" ] && add_list "$ppa" "$lpc_ppa/$ppa/ubuntu" "$lpc_ppa/$ppa/ubuntu" "$VERSION_CODENAME" "main/debug"
|
||||
add_list "$ppa"
|
||||
else
|
||||
|
@ -53,9 +53,11 @@ read_env() {
|
||||
[ "${debug:-${DEBUG:-false}}" = "true" ] && debug=debug && update=true || debug=release
|
||||
[[ "${phpts:-${PHPTS:-nts}}" = "ts" || "${phpts:-${PHPTS:-nts}}" = "zts" ]] && ts=zts && update=true || ts=nts
|
||||
fail_fast="${fail_fast:-${FAIL_FAST:-false}}"
|
||||
[[ -z "${ImageOS}" && -z "${ImageVersion}" || -n ${ACT} ]] && _runner=self-hosted || _runner=github
|
||||
[[ ( -z "$ImageOS" && -z "$ImageVersion" ) ||
|
||||
( -n "$RUNNER_ENVIRONMENT" && "$RUNNER_ENVIRONMENT" = "self-hosted" ) ||
|
||||
-n "$ACT" || -n "$CONTAINER" ]] && _runner=self-hosted || _runner=github
|
||||
runner="${runner:-${RUNNER:-$_runner}}"
|
||||
tool_path_dir="${tools_dir:-${TOOLS_DIR:-/usr/local/bin}}"
|
||||
tool_path_dir="${setup_php_tools_dir:-${SETUP_PHP_TOOLS_DIR:-/usr/local/bin}}"
|
||||
|
||||
if [[ "$runner" = "github" && $_runner = "self-hosted" ]]; then
|
||||
fail_fast=true
|
||||
@ -76,7 +78,7 @@ read_env() {
|
||||
export runner
|
||||
export update
|
||||
export ts
|
||||
export tools_dir_path
|
||||
export tool_path_dir
|
||||
}
|
||||
|
||||
# Function to create a lock.
|
||||
@ -105,6 +107,18 @@ release_lock() {
|
||||
sudo rm -rf "$lock_path"
|
||||
}
|
||||
|
||||
# Function to get the SHA256 hash of a string.
|
||||
get_sha256() {
|
||||
local input=$1
|
||||
if command -v sha256sum >/dev/null; then
|
||||
printf '%s' "$input" | sha256sum | cut -d' ' -f1
|
||||
elif command -v shasum >/dev/null; then
|
||||
printf '%s' "$input" | shasum -a 256 | cut -d' ' -f1
|
||||
elif command -v openssl >/dev/null; then
|
||||
printf '%s' "$input" | openssl dgst -sha256 | cut -d' ' -f2
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to download a file using cURL.
|
||||
# mode: -s pipe to stdout, -v save file and return status code
|
||||
# execute: -e save file as executable
|
||||
@ -118,7 +132,7 @@ get() {
|
||||
sudo curl "${curl_opts[@]}" "${links[0]}"
|
||||
else
|
||||
if [ "$runner" = "self-hosted" ]; then
|
||||
lock_path="$file_path.lock"
|
||||
lock_path="/tmp/sp-lck-$(get_sha256 "$file_path")"
|
||||
acquire_lock "$lock_path"
|
||||
if [ "$execute" = "-e" ]; then
|
||||
until [ -z "$(fuser "$file_path" 2>/dev/null)" ]; do
|
||||
@ -207,7 +221,7 @@ self_hosted_setup() {
|
||||
exit 1
|
||||
else
|
||||
self_hosted_helper >/dev/null 2>&1
|
||||
add_env RUNNER_TOOL_CACHE /tmp
|
||||
add_env RUNNER_TOOL_CACHE /opt/hostedtoolcache
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
@ -401,6 +401,9 @@ export async function addPhive(data: RS): Promise<string> {
|
||||
case /7\.2/.test(data['php_version']):
|
||||
data['version'] = '0.14.5';
|
||||
break;
|
||||
case /7\.3|7\.4/.test(data['php_version']):
|
||||
data['version'] = '0.15.3';
|
||||
break;
|
||||
case /^latest$/.test(data['version']):
|
||||
data['version'] = await getLatestVersion(data);
|
||||
break;
|
||||
@ -416,6 +419,7 @@ export async function addPhive(data: RS): Promise<string> {
|
||||
* @param data
|
||||
*/
|
||||
export async function addPHPUnitTools(data: RS): Promise<string> {
|
||||
/* istanbul ignore next */
|
||||
if (data['version'] === 'latest') {
|
||||
data['version'] =
|
||||
(await packagist.search(data['packagist'], data['php_version'])) ??
|
||||
|
19
src/utils.ts
19
src/utils.ts
@ -48,8 +48,11 @@ export async function getInput(
|
||||
/**
|
||||
* Function to get manifest URL
|
||||
*/
|
||||
export async function getManifestURL(): Promise<string> {
|
||||
return 'https://raw.githubusercontent.com/shivammathur/setup-php/develop/src/configs/php-versions.json';
|
||||
export async function getManifestURLS(): Promise<string[]> {
|
||||
return [
|
||||
'https://raw.githubusercontent.com/shivammathur/setup-php/develop/src/configs/php-versions.json',
|
||||
'https://setup-php.com/php-versions.json'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -60,9 +63,13 @@ export async function getManifestURL(): Promise<string> {
|
||||
export async function parseVersion(version: string): Promise<string> {
|
||||
switch (true) {
|
||||
case /^(latest|lowest|highest|nightly|\d+\.x)$/.test(version):
|
||||
return JSON.parse((await fetch.fetch(await getManifestURL()))['data'])[
|
||||
version
|
||||
];
|
||||
for (const manifestURL of await getManifestURLS()) {
|
||||
const fetchResult = await fetch.fetch(manifestURL);
|
||||
if (fetchResult['data'] ?? false) {
|
||||
return JSON.parse(fetchResult['data'])[version];
|
||||
}
|
||||
}
|
||||
throw new Error(`Could not fetch the PHP version manifest.`);
|
||||
default:
|
||||
switch (true) {
|
||||
case version.length > 1:
|
||||
@ -449,6 +456,7 @@ export async function readPHPVersion(): Promise<string> {
|
||||
const composerLock = path.join(composerProjectDir, 'composer.lock');
|
||||
if (fs.existsSync(composerLock)) {
|
||||
const lockFileContents = JSON.parse(fs.readFileSync(composerLock, 'utf8'));
|
||||
/* istanbul ignore next */
|
||||
if (
|
||||
lockFileContents['platform-overrides'] &&
|
||||
lockFileContents['platform-overrides']['php']
|
||||
@ -462,6 +470,7 @@ export async function readPHPVersion(): Promise<string> {
|
||||
const composerFileContents = JSON.parse(
|
||||
fs.readFileSync(composerJson, 'utf8')
|
||||
);
|
||||
/* istanbul ignore next */
|
||||
if (
|
||||
composerFileContents['config'] &&
|
||||
composerFileContents['config']['platform'] &&
|
||||
|
Reference in New Issue
Block a user