mirror of
https://github.com/shivammathur/setup-php.git
synced 2024-11-22 20:01:06 +07:00
commit
4a38014043
2
.github/workflows/experimental-workflow.yml
vendored
2
.github/workflows/experimental-workflow.yml
vendored
@ -28,7 +28,7 @@ jobs:
|
||||
operating-system: [ubuntu-latest, windows-latest, macos-latest]
|
||||
php-versions: ['8.0']
|
||||
env:
|
||||
extensions: xml, opcache, xdebug, pcov
|
||||
extensions: xml, opcache, pcov
|
||||
key: cache-v2
|
||||
steps:
|
||||
- name: Checkout
|
||||
|
14
README.md
14
README.md
@ -36,6 +36,7 @@ Setup PHP with required extensions, php.ini configuration, code-coverage support
|
||||
- [Cache Extensions](#cache-extensions)
|
||||
- [Cache Composer Dependencies](#cache-composer-dependencies)
|
||||
- [Cache Node.js Dependencies](#cache-nodejs-dependencies)
|
||||
- [Composer GitHub OAuth](#composer-github-oauth)
|
||||
- [Problem Matchers](#problem-matchers)
|
||||
- [Examples](#examples)
|
||||
- [License](#scroll-license)
|
||||
@ -430,6 +431,19 @@ If your project has node.js dependencies, you can persist npm's or yarn's cache
|
||||
|
||||
**Note:** Please do not cache `node_modules` directory as that will have side-effects.
|
||||
|
||||
### Composer GitHub OAuth
|
||||
|
||||
If you have a number of workflows which setup multiple tools or have many composer dependencies, you might hit the GitHub's rate limit for composer. To avoid that you can add a `OAuth` token to the composer's config by setting `COMPOSER_TOKEN` environment variable. You can use [`GITHUB_TOKEN`](https://help.github.com/en/actions/configuring-and-managing-workflows/authenticating-with-the-github_token "GITHUB_TOKEN documentation") secret for this purpose.
|
||||
|
||||
```yaml
|
||||
- name: Setup PHP
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: '7.4'
|
||||
env:
|
||||
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
```
|
||||
|
||||
### Problem Matchers
|
||||
|
||||
#### PHP
|
||||
|
@ -49,15 +49,17 @@ describe('Extension tests', () => {
|
||||
|
||||
it('checking addExtensionOnLinux', async () => {
|
||||
let linux: string = await extensions.addExtension(
|
||||
'Xdebug, pcov, sqlite, ast-beta, pdo_mysql, pdo-odbc, xdebug-alpha, grpc-1.2.3',
|
||||
'Xdebug, pcov, sqlite, ast, uopz, ast-beta, pdo_mysql, pdo-odbc, xdebug-alpha, grpc-1.2.3',
|
||||
'7.4',
|
||||
'linux'
|
||||
);
|
||||
expect(linux).toContain('update_extension xdebug 2.9.2');
|
||||
expect(linux).toContain('update_extension xdebug 2.9.3');
|
||||
expect(linux).toContain('sudo $debconf_fix apt-get install -y php7.4-pcov');
|
||||
expect(linux).toContain(
|
||||
'sudo $debconf_fix apt-get install -y php7.4-sqlite3'
|
||||
);
|
||||
expect(linux).toContain('sudo $debconf_fix apt-get install -y php-ast');
|
||||
expect(linux).toContain('sudo $debconf_fix apt-get install -y php-uopz');
|
||||
expect(linux).toContain('add_unstable_extension ast beta extension');
|
||||
expect(linux).toContain('add_pdo_extension mysql');
|
||||
expect(linux).toContain('add_pdo_extension odbc');
|
||||
|
10
dist/index.js
vendored
10
dist/index.js
vendored
@ -2788,10 +2788,10 @@ async function addExtensionLinux(extension_csv, version, pipe) {
|
||||
' ' +
|
||||
version;
|
||||
return;
|
||||
// match 7.0xdebug..7.4xdebug
|
||||
case /^7\.[0-4]xdebug$/.test(version_extension):
|
||||
// match 7.1xdebug..7.4xdebug
|
||||
case /^7\.[1-4]xdebug$/.test(version_extension):
|
||||
script +=
|
||||
'\nupdate_extension xdebug 2.9.2' +
|
||||
'\nupdate_extension xdebug 2.9.3' +
|
||||
pipe +
|
||||
'\n' +
|
||||
(await utils.addLog('$tick', 'xdebug', 'Enabled', 'linux'));
|
||||
@ -2801,6 +2801,10 @@ async function addExtensionLinux(extension_csv, version, pipe) {
|
||||
extension = extension.replace('pdo_', '').replace('pdo-', '');
|
||||
script += '\nadd_pdo_extension ' + extension;
|
||||
return;
|
||||
// match ast and uopz
|
||||
case /^(ast|uopz)$/.test(extension):
|
||||
command = command_prefix + '-' + extension + pipe;
|
||||
break;
|
||||
// match sqlite
|
||||
case /^sqlite$/.test(extension):
|
||||
extension = 'sqlite3';
|
||||
|
1316
package-lock.json
generated
1316
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
22
package.json
22
package.json
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "setup-php",
|
||||
"version": "2.1.3",
|
||||
"version": "2.1.4",
|
||||
"private": false,
|
||||
"description": "Setup PHP for use with GitHub Actions",
|
||||
"main": "dist/index.js",
|
||||
@ -30,21 +30,21 @@
|
||||
"fs": "0.0.1-security"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/jest": "^25.1.4",
|
||||
"@types/node": "^13.9.1",
|
||||
"@typescript-eslint/eslint-plugin": "^2.24.0",
|
||||
"@typescript-eslint/parser": "^2.24.0",
|
||||
"@zeit/ncc": "^0.21.1",
|
||||
"@types/jest": "^25.2.1",
|
||||
"@types/node": "^13.11.1",
|
||||
"@typescript-eslint/eslint-plugin": "^2.27.0",
|
||||
"@typescript-eslint/parser": "^2.27.0",
|
||||
"@zeit/ncc": "^0.22.1",
|
||||
"eslint": "^6.8.0",
|
||||
"eslint-config-prettier": "^6.10.0",
|
||||
"eslint-plugin-import": "^2.20.1",
|
||||
"eslint-config-prettier": "^6.10.1",
|
||||
"eslint-plugin-import": "^2.20.2",
|
||||
"eslint-plugin-jest": "^23.8.2",
|
||||
"eslint-plugin-prettier": "^3.1.2",
|
||||
"husky": "^4.2.3",
|
||||
"jest": "^25.1.0",
|
||||
"jest-circus": "^25.1.0",
|
||||
"jest": "^25.3.0",
|
||||
"jest-circus": "^25.3.0",
|
||||
"prettier": "^1.19.1",
|
||||
"ts-jest": "^25.2.1",
|
||||
"ts-jest": "^25.3.1",
|
||||
"typescript": "^3.8.3"
|
||||
},
|
||||
"husky": {
|
||||
|
Binary file not shown.
Binary file not shown.
@ -268,10 +268,10 @@ export async function addExtensionLinux(
|
||||
' ' +
|
||||
version;
|
||||
return;
|
||||
// match 7.0xdebug..7.4xdebug
|
||||
case /^7\.[0-4]xdebug$/.test(version_extension):
|
||||
// match 7.1xdebug..7.4xdebug
|
||||
case /^7\.[1-4]xdebug$/.test(version_extension):
|
||||
script +=
|
||||
'\nupdate_extension xdebug 2.9.2' +
|
||||
'\nupdate_extension xdebug 2.9.3' +
|
||||
pipe +
|
||||
'\n' +
|
||||
(await utils.addLog('$tick', 'xdebug', 'Enabled', 'linux'));
|
||||
@ -281,6 +281,10 @@ export async function addExtensionLinux(
|
||||
extension = extension.replace('pdo_', '').replace('pdo-', '');
|
||||
script += '\nadd_pdo_extension ' + extension;
|
||||
return;
|
||||
// match ast and uopz
|
||||
case /^(ast|uopz)$/.test(extension):
|
||||
command = command_prefix + '-' + extension + pipe;
|
||||
break;
|
||||
// match sqlite
|
||||
case /^sqlite$/.test(extension):
|
||||
extension = 'sqlite3';
|
||||
|
@ -108,6 +108,9 @@ add_tool() {
|
||||
sudo chmod a+x "$tool_path"
|
||||
if [ "$tool" = "composer" ]; then
|
||||
composer -q global config process-timeout 0
|
||||
if [ -n "$COMPOSER_TOKEN" ]; then
|
||||
composer -q global config github-oauth.github.com "$COMPOSER_TOKEN"
|
||||
fi
|
||||
elif [ "$tool" = "phive" ]; then
|
||||
add_extension curl "sudo pecl install -f curl" extension >/dev/null 2>&1
|
||||
add_extension mbstring "sudo pecl install -f mbstring" extension >/dev/null 2>&1
|
||||
|
@ -20,12 +20,6 @@ add_log() {
|
||||
update_ppa() {
|
||||
if [ "$ppa_updated" = "false" ]; then
|
||||
sudo "$debconf_fix" apt-get update >/dev/null 2>&1
|
||||
# if [[ "$version" =~ $old_versions ]]; then
|
||||
# ppa="dotdeb-ubuntu-php*.list"
|
||||
# else
|
||||
# ppa="ondrej-ubuntu-php*.list"
|
||||
# fi
|
||||
# find /etc/apt/sources.list.d -type f -name "$ppa" -exec sudo "$debconf_fix" apt-fast update -o Dir::Etc::sourcelist="{}" ';' >/dev/null 2>&1
|
||||
ppa_updated="true"
|
||||
fi
|
||||
}
|
||||
@ -187,6 +181,9 @@ add_tool() {
|
||||
sudo chmod a+x "$tool_path"
|
||||
if [ "$tool" = "composer" ]; then
|
||||
composer -q global config process-timeout 0
|
||||
if [ -n "$COMPOSER_TOKEN" ]; then
|
||||
composer -q global config github-oauth.github.com "$COMPOSER_TOKEN"
|
||||
fi
|
||||
elif [ "$tool" = "cs2pr" ]; then
|
||||
sudo sed -i 's/\r$//; s/exit(9)/exit(0)/' "$tool_path"
|
||||
elif [ "$tool" = "phive" ]; then
|
||||
@ -242,27 +239,23 @@ add_blackfire() {
|
||||
setup_master() {
|
||||
tar_file=php_"$version"%2Bubuntu"$(lsb_release -r -s)".tar.xz
|
||||
install_dir=~/php/"$version"
|
||||
bintray_url=https://dl.bintray.com/shivammathur/php/"$tar_file"
|
||||
sudo mkdir -m 777 -p ~/php
|
||||
update_ppa && $apt_install libicu-dev >/dev/null 2>&1
|
||||
curl -SLO https://dl.bintray.com/shivammathur/php/"$tar_file" >/dev/null 2>&1
|
||||
sudo tar xf "$tar_file" -C ~/php >/dev/null 2>&1
|
||||
rm -rf "$tar_file"
|
||||
curl -o /tmp/"$tar_file" -sSL "$bintray_url"
|
||||
sudo tar xf /tmp/"$tar_file" -C ~/php
|
||||
sudo ln -sf -S "$version" "$install_dir"/bin/* /usr/bin/
|
||||
sudo ln -sf "$install_dir"/etc/php.ini /etc/php.ini
|
||||
}
|
||||
|
||||
# Function to setup PHP 5.3, PHP 5.4 and PHP 5.5
|
||||
setup_old_versions() {
|
||||
(
|
||||
cd /tmp || exit
|
||||
curl -SLO https://dl.bintray.com/shivammathur/php/php-"$version".tar.xz >/dev/null 2>&1
|
||||
sudo tar xf php-"$version".tar.xz >/dev/null 2>&1
|
||||
cd php-"$version" || exit
|
||||
sudo chmod a+x ./*.sh
|
||||
./install.sh >/dev/null 2>&1
|
||||
./post-install.sh >/dev/null 2>&1
|
||||
)
|
||||
sudo rm -rf /tmp/php-"$version"
|
||||
dir=php-"$version"
|
||||
tar_file="$dir".tar.xz
|
||||
bintray_url=https://dl.bintray.com/shivammathur/php/"$tar_file"
|
||||
curl -o /tmp/"$tar_file" -sSL "$bintray_url"
|
||||
sudo tar xf /tmp/"$tar_file" -C /tmp
|
||||
sudo chmod a+x /tmp/"$dir"/*.sh
|
||||
(cd /tmp/"$dir" && ./install.sh && ./post-install.sh)
|
||||
configure_pecl
|
||||
release_version=$(php -v | head -n 1 | cut -d' ' -f 2)
|
||||
}
|
||||
@ -328,9 +321,9 @@ sudo mkdir -p /var/run /run/php
|
||||
if [ "$existing_version" != "$version" ]; then
|
||||
if [ ! -e "/usr/bin/php$version" ]; then
|
||||
if [ "$version" = "8.0" ]; then
|
||||
setup_master
|
||||
setup_master >/dev/null 2>&1
|
||||
elif [[ "$version" =~ $old_versions ]] || [ "$version" = "5.3" ]; then
|
||||
setup_old_versions
|
||||
setup_old_versions >/dev/null 2>&1
|
||||
else
|
||||
update_ppa
|
||||
$apt_install php"$version" php"$version"-curl php"$version"-mbstring php"$version"-xml >/dev/null 2>&1
|
||||
|
@ -136,6 +136,9 @@ Function Add-Tool() {
|
||||
(Get-Content $php_dir/cs2pr).replace('exit(9)', 'exit(0)') | Set-Content $php_dir/cs2pr
|
||||
} elseif($tool -eq "composer") {
|
||||
composer -q global config process-timeout 0
|
||||
if (Test-Path env:COMPOSER_TOKEN) {
|
||||
composer -q global config github-oauth.github.com $env:COMPOSER_TOKEN
|
||||
}
|
||||
} elseif($tool -eq "wp-cli") {
|
||||
Copy-Item $php_dir\wp-cli.bat -Destination $php_dir\wp.bat
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user