mirror of
https://github.com/shivammathur/setup-php.git
synced 2025-09-14 00:34:17 +07:00
Fix side effects of this action
This commit is contained in:
@ -1,3 +1,4 @@
|
||||
import * as path from 'path';
|
||||
import * as utils from './utils';
|
||||
|
||||
/**
|
||||
@ -62,11 +63,15 @@ export async function addExtensionDarwin(
|
||||
switch (version + extension) {
|
||||
case '7.4xdebug':
|
||||
install_command =
|
||||
'sh ./xdebug_darwin.sh >/dev/null 2>&1 && echo "zend_extension=xdebug.so" >> $ini_file';
|
||||
'sh ' +
|
||||
path.join(__dirname, '../src/scripts/xdebug_darwin.sh') +
|
||||
' >/dev/null 2>&1 && echo "zend_extension=xdebug.so" >> $ini_file';
|
||||
break;
|
||||
case '7.4pcov':
|
||||
install_command =
|
||||
'sh ./pcov.sh >/dev/null 2>&1 && echo "extension=pcov.so" >> $ini_file';
|
||||
'sh ' +
|
||||
path.join(__dirname, '../src/scripts/pcov.sh') +
|
||||
' >/dev/null 2>&1 && echo "extension=pcov.so" >> $ini_file';
|
||||
break;
|
||||
case '5.6xdebug':
|
||||
install_command = 'sudo pecl install xdebug-2.5.5 >/dev/null 2>&1';
|
||||
@ -149,19 +154,34 @@ export async function addExtensionLinux(
|
||||
switch (version + extension) {
|
||||
case '7.4xdebug':
|
||||
install_command =
|
||||
'./xdebug.sh >/dev/null 2>&1 && echo "zend_extension=xdebug.so" >> $ini_file';
|
||||
'sh ' +
|
||||
path.join(__dirname, '../src/scripts/xdebug.sh') +
|
||||
' >/dev/null 2>&1 && echo "zend_extension=xdebug.so" >> $ini_file';
|
||||
break;
|
||||
case '7.4pcov':
|
||||
install_command =
|
||||
'./pcov.sh >/dev/null 2>&1 && echo "extension=pcov.so" >> $ini_file';
|
||||
'sh ' +
|
||||
path.join(__dirname, '../src/scripts/pcov.sh') +
|
||||
' >/dev/null 2>&1 && echo "extension=pcov.so" >> $ini_file';
|
||||
break;
|
||||
case '7.2phalcon3':
|
||||
case '7.3phalcon3':
|
||||
install_command = './phalcon.sh master ' + version + ' >/dev/null 2>&1';
|
||||
install_command =
|
||||
'sh ' +
|
||||
path.join(__dirname, '../src/scripts/phalcon.sh') +
|
||||
' master ' +
|
||||
version +
|
||||
' >/dev/null 2>&1';
|
||||
break;
|
||||
case '7.2phalcon4':
|
||||
case '7.3phalcon4':
|
||||
install_command = './phalcon.sh 4.0.x ' + version + ' >/dev/null 2>&1';
|
||||
case '7.4phalcon4':
|
||||
install_command =
|
||||
'sh ' +
|
||||
path.join(__dirname, '../src/scripts/phalcon.sh') +
|
||||
' 4.0.x ' +
|
||||
version +
|
||||
' >/dev/null 2>&1';
|
||||
break;
|
||||
default:
|
||||
install_command =
|
||||
|
@ -1,9 +1,10 @@
|
||||
import {exec} from '@actions/exec/lib/exec';
|
||||
import * as core from '@actions/core';
|
||||
import * as utils from './utils';
|
||||
import * as extensions from './extensions';
|
||||
import * as path from 'path';
|
||||
import * as config from './config';
|
||||
import * as coverage from './coverage';
|
||||
import * as extensions from './extensions';
|
||||
import * as utils from './utils';
|
||||
|
||||
/**
|
||||
* Build the script
|
||||
@ -12,7 +13,11 @@ import * as coverage from './coverage';
|
||||
* @param version
|
||||
* @param os_version
|
||||
*/
|
||||
async function build(filename: string, version: string, os_version: string) {
|
||||
async function build(
|
||||
filename: string,
|
||||
version: string,
|
||||
os_version: string
|
||||
): Promise<string> {
|
||||
// taking inputs
|
||||
let extension_csv: string = await utils.getInput('extension-csv', false);
|
||||
let ini_values_csv: string = await utils.getInput('ini-values-csv', false);
|
||||
@ -28,7 +33,8 @@ async function build(filename: string, version: string, os_version: string) {
|
||||
if (coverage_driver) {
|
||||
script += await coverage.addCoverage(coverage_driver, version, os_version);
|
||||
}
|
||||
await utils.writeScript(filename, version, script);
|
||||
|
||||
return await utils.writeScript(filename, script);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -40,14 +46,16 @@ async function run() {
|
||||
let version: string = await utils.getInput('php-version', true);
|
||||
// check the os version and run the respective script
|
||||
if (os_version == 'darwin') {
|
||||
await build('darwin.sh', version, os_version);
|
||||
await exec('sh ./' + version + 'darwin.sh ' + version);
|
||||
let script_path: string = await build('darwin.sh', version, os_version);
|
||||
await exec('sh ' + script_path + ' ' + version + ' ' + __dirname);
|
||||
} else if (os_version == 'win32') {
|
||||
await build('win32.ps1', version, os_version);
|
||||
await exec('pwsh .\\' + version + 'win32.ps1 -version ' + version);
|
||||
let script_path: string = await build('win32.ps1', version, os_version);
|
||||
await exec(
|
||||
'pwsh ' + script_path + ' -version ' + version + ' -dir ' + __dirname
|
||||
);
|
||||
} else if (os_version == 'linux') {
|
||||
await build('linux.sh', version, os_version);
|
||||
await exec('./' + version + 'linux.sh ' + version);
|
||||
let script_path: string = await build('linux.sh', version, os_version);
|
||||
await exec('sh ' + script_path + ' ' + version + ' ' + __dirname);
|
||||
}
|
||||
} catch (error) {
|
||||
core.setFailed(error.message);
|
||||
|
@ -58,7 +58,7 @@ echo 'export EXTRA_LIBS="/usr/local/opt/readline/lib/libhistory.dylib
|
||||
/usr/local/opt/icu4c/lib/libicutu.dylib
|
||||
/usr/local/opt/icu4c/lib/libicuuc.dylib"'
|
||||
} >> ~/.bash_profile
|
||||
config_file=$(pwd)/config.yaml
|
||||
config_file=$2/../src/configs/config.yaml
|
||||
|
||||
step_log "Setup PHPBrew"
|
||||
curl -L -O https://github.com/phpbrew/phpbrew/raw/master/phpbrew >/dev/null 2>&1
|
||||
|
@ -34,7 +34,7 @@ if [ "$existing_version" != "$1" ]; then
|
||||
|
||||
for tool in php phar phar.phar php-cgi php-config phpize; do
|
||||
if [ -e "/usr/bin/$tool$1" ]; then
|
||||
sudo update-alternatives --set $tool /usr/bin/"$tool$1" >/dev/null 2>&1 &
|
||||
sudo update-alternatives --set $tool /usr/bin/"$tool$1" >/dev/null 2>&1
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
@ -1,7 +1,5 @@
|
||||
git clone --depth=1 https://github.com/krakjoe/pcov.git
|
||||
(
|
||||
cd ~ && git clone --depth=1 https://github.com/krakjoe/pcov.git
|
||||
cd pcov && phpize
|
||||
./configure --enable-pcov
|
||||
make
|
||||
sudo make install
|
||||
)
|
||||
sudo make install
|
@ -1,19 +1,21 @@
|
||||
ini_file=$(php --ini | grep "Loaded Configuration" | sed -e "s|.*:s*||" | sed "s/ //g")
|
||||
sudo DEBIAN_FRONTEND=noninteractive apt install php"$2"-dev php-pear -y
|
||||
sudo DEBIAN_FRONTEND=noninteractive apt install php"$2"-dev -y
|
||||
for tool in php-config phpize; do
|
||||
if [ -e "/usr/bin/$tool$2" ]; then
|
||||
sudo update-alternatives --set $tool /usr/bin/"$tool$2" &
|
||||
sudo update-alternatives --set $tool /usr/bin/"$tool$2"
|
||||
fi
|
||||
done
|
||||
sudo pecl config-set php_ini "$ini_file"
|
||||
sudo pear config-set php_ini "$ini_file"
|
||||
sudo pecl install psr
|
||||
|
||||
cd ~ && git clone --depth=1 https://github.com/jbboehr/php-psr.git
|
||||
cd php-psr && sudo /usr/bin/phpize"$2"
|
||||
./configure --with-php-config=/usr/bin/php-config"$2"
|
||||
make -j2 && sudo make -j2 install
|
||||
echo "extension=psr.so" >> "$ini_file"
|
||||
|
||||
if [ "$1" = "master" ]; then
|
||||
sudo DEBIAN_FRONTEND=noninteractive apt install php"$2"-phalcon -y
|
||||
else
|
||||
git clone --depth=1 -v https://github.com/phalcon/cphalcon.git -b "$1"
|
||||
(
|
||||
cd cphalcon/build && sudo ./install --phpize /usr/bin/phpize"$2" --php-config /usr/bin/php-config"$2"
|
||||
echo "extension=phalcon.so" >> "$ini_file"
|
||||
)
|
||||
cd ~ && git clone --depth=1 -v https://github.com/phalcon/cphalcon.git -b "$1"
|
||||
cd cphalcon/build && sudo ./install --phpize /usr/bin/phpize"$2" --php-config /usr/bin/php-config"$2"
|
||||
echo "extension=phalcon.so" >> "$ini_file"
|
||||
fi
|
@ -1,5 +1,6 @@
|
||||
param (
|
||||
[Parameter(Mandatory=$true)][string]$version = "7.3"
|
||||
[Parameter(Mandatory=$true)][string]$version = "7.3",
|
||||
[Parameter(Mandatory=$true)][string]$dir
|
||||
)
|
||||
|
||||
$tick = ([char]8730)
|
||||
@ -41,7 +42,7 @@ if($version -lt '7.4') {
|
||||
Enable-PhpExtension curl
|
||||
} else {
|
||||
Add-Content C:\tools\php\php.ini "extension=php_openssl.dll`nextension=php_curl.dll"
|
||||
Copy-Item "php_pcov.dll" -Destination $ext_dir"\php_pcov.dll"
|
||||
Copy-Item $dir"\..\src\ext\php_pcov.dll" -Destination $ext_dir"\php_pcov.dll"
|
||||
}
|
||||
Add-Log $tick "PHP" $status
|
||||
|
||||
|
@ -1,5 +1,3 @@
|
||||
git clone --depth=1 https://github.com/xdebug/xdebug.git
|
||||
(
|
||||
cd xdebug || echo "cd failed"
|
||||
sudo ./rebuild.sh
|
||||
)
|
||||
cd ~ && git clone --depth=1 https://github.com/xdebug/xdebug.git
|
||||
cd xdebug || echo "Failed to clone Xdebug"
|
||||
sudo ./rebuild.sh
|
@ -1,8 +1,6 @@
|
||||
git clone --depth=1 https://github.com/xdebug/xdebug.git
|
||||
(
|
||||
cd xdebug || echo "cd failed"
|
||||
sudo phpize
|
||||
sudo ./configure
|
||||
sudo make
|
||||
sudo cp modules/xdebug.so "$(php -i | grep "extension_dir => /opt" | sed -e "s|.*=> s*||")"
|
||||
)
|
||||
cd ~ && git clone --depth=1 https://github.com/xdebug/xdebug.git
|
||||
cd xdebug || echo "Failed to clone Xdebug"
|
||||
sudo phpize
|
||||
sudo ./configure
|
||||
sudo make
|
||||
sudo cp modules/xdebug.so "$(php -i | grep "extension_dir => /opt" | sed -e "s|.*=> s*||")"
|
54
src/utils.ts
54
src/utils.ts
@ -38,19 +38,6 @@ export async function asyncForEach(
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy config
|
||||
*
|
||||
* @param files
|
||||
*/
|
||||
export async function moveFiles(files: Array<string>) {
|
||||
await asyncForEach(files, function(filename: string) {
|
||||
fs.createReadStream(path.join(__dirname, '../src/' + filename)).pipe(
|
||||
fs.createWriteStream(filename.split('/')[1], {mode: 0o755})
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the scripts
|
||||
*
|
||||
@ -67,33 +54,21 @@ export async function readScript(
|
||||
case 'darwin':
|
||||
switch (version) {
|
||||
case '7.4':
|
||||
await moveFiles([
|
||||
'configs/config.yaml',
|
||||
'scripts/xdebug_darwin.sh',
|
||||
'scripts/pcov.sh'
|
||||
]);
|
||||
return fs.readFileSync(
|
||||
path.join(__dirname, '../src/scripts/7.4.sh'),
|
||||
'utf8'
|
||||
);
|
||||
}
|
||||
break;
|
||||
return fs.readFileSync(
|
||||
path.join(__dirname, '../src/scripts/' + filename),
|
||||
'utf8'
|
||||
);
|
||||
case 'linux':
|
||||
let files: Array<string> = ['scripts/phalcon.sh'];
|
||||
switch (version) {
|
||||
case '7.4':
|
||||
files = files.concat(['scripts/xdebug.sh', 'scripts/pcov.sh']);
|
||||
break;
|
||||
}
|
||||
await moveFiles(files);
|
||||
break;
|
||||
case 'win32':
|
||||
switch (version) {
|
||||
case '7.4':
|
||||
await moveFiles(['ext/php_pcov.dll']);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
return fs.readFileSync(
|
||||
path.join(__dirname, '../src/scripts/' + filename),
|
||||
'utf8'
|
||||
);
|
||||
default:
|
||||
return await log(
|
||||
'Platform ' + os_version + ' is not supported',
|
||||
@ -101,11 +76,6 @@ export async function readScript(
|
||||
'error'
|
||||
);
|
||||
}
|
||||
|
||||
return fs.readFileSync(
|
||||
path.join(__dirname, '../src/scripts/' + filename),
|
||||
'utf8'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -117,10 +87,12 @@ export async function readScript(
|
||||
*/
|
||||
export async function writeScript(
|
||||
filename: string,
|
||||
version: string,
|
||||
script: string
|
||||
): Promise<any> {
|
||||
fs.writeFileSync(version + filename, script, {mode: 0o755});
|
||||
): Promise<string> {
|
||||
let runner_dir: string = await getInput('RUNNER_TOOL_CACHE', false);
|
||||
let script_path: string = path.join(runner_dir, filename);
|
||||
fs.writeFileSync(script_path, script, {mode: 0o755});
|
||||
return script_path;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user