Merge pull request #193 from jaapio/feature/ext-blackfire

🎉 Add blackfire extenstion
This commit is contained in:
Shivam Mathur
2020-02-27 15:50:29 +05:30
committed by GitHub
10 changed files with 230 additions and 0 deletions

View File

@ -0,0 +1,27 @@
Param (
[Parameter(Position = 0, Mandatory = $true)]
[ValidateNotNull()]
[string]
$phpversion,
[Parameter(Position = 1, Mandatory = $true)]
[ValidateNotNull()]
[ValidateLength(1, [int]::MaxValue)]
[string]
$version = '1.31.0'
)
Function Install-Blackfire() {
$installed = Get-Php -Path $php_dir
$nts = if (!$installed.ThreadSafe) { "_nts" } else { "" }
Invoke-WebRequest -UseBasicParsing -Uri "https://packages.blackfire.io/binaries/blackfire-php/${version}/blackfire-php-windows_x64-php-${phpversion}${nts}.dll" -OutFile $ENV:RUNNER_TOOL_CACHE\blackfire.dll > $null 2>&1
Copy-Item -Path "$ENV:RUNNER_TOOL_CACHE\blackfire.dll" -Destination "$ext_dir\blackfire.dll"
Enable-PhpExtension -Extension blackfire -Path $php_dir
printf "\033[%s;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" "32" $tick "Blackfire" "Installed and enabled"
}
$tick = ([char]8730)
$php_dir = 'C:\tools\php'
$ext_dir = $php_dir + '\ext'
Install-Blackfire

View File

@ -0,0 +1,23 @@
add_log() {
mark=$1
subject=$2
message=$3
if [ "$mark" = "$tick" ]; then
printf "\033[32;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s\033[0m\n" "$mark" "$subject" "$message"
else
printf "\033[31;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s\033[0m\n" "$mark" "$subject" "$message"
fi
}
phpversion=$2
blackfireVersion=${3:-1.31.0}
ini_file="/etc/php/$1/cli/conf.d/50-blackfire.ini"
tick="✓"
cross="✗"
(curl -A "Github action" -o /tmp/blackfire.so -L -s https://packages.blackfire.io/binaries/blackfire-php/$blackfireVersion/blackfire-php-linux_amd64-php-$phpversion.so >/dev/null 2>&1 && \
sudo mv /tmp/blackfire.so $(php -r "echo ini_get ('extension_dir');")/blackfire.so >/dev/null 2>&1 && \
echo "extension=blackfire.so" | sudo tee -a "$ini_file" >/dev/null 2>&1 && \
add_log "$tick" "blackfire" "Installed and enabled") || \
add_log "$cross" "blackfire" "Could not install blackfire"

View File

@ -0,0 +1,23 @@
# Function to log result of a operation
add_log() {
mark=$1
subject=$2
message=$3
if [ "$mark" = "$tick" ]; then
printf "\033[32;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s\033[0m\n" "$mark" "$subject" "$message"
else
printf "\033[31;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s\033[0m\n" "$mark" "$subject" "$message"
fi
}
tick="✓"
cross="✗"
phpversion=$2
blackfireVersion=${3:-1.31.0}
ini_file=$(php -d "date.timezone=UTC" --ini | grep "Loaded Configuration" | sed -e "s|.*:s*||" | sed "s/ //g")
(curl -A "Github action" -o /tmp/blackfire.so -L -s https://packages.blackfire.io/binaries/blackfire-php/$blackfireVersion/blackfire-php-darwin_amd64-php-$phpversion.so && \
sudo mv /tmp/blackfire.so $(php -r "echo ini_get ('extension_dir');")/blackfire.so && \
echo "extension=blackfire.so" >>"$ini_file" && \
add_log "$tick" "blackfire" "Installed and enabled") || \
add_log "$cross" "blackfire" "Could not install blackfire"