Skip to content

Commit

Permalink
Fix output on non GitHub Action environments
Browse files Browse the repository at this point in the history
  • Loading branch information
shivammathur committed Feb 2, 2022
1 parent 5acd006 commit 9d74a11
Show file tree
Hide file tree
Showing 14 changed files with 70 additions and 25 deletions.
2 changes: 1 addition & 1 deletion src/scripts/darwin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -235,13 +235,13 @@ setup_php() {
semver="$(php_semver)"
extra_version="$(php_extra_version)"
configure_php
set_output "php-version" "$semver"
if [ "${semver%.*}" != "$version" ]; then
add_log "${cross:?}" "PHP" "Could not setup PHP $version"
exit 1
fi

sudo cp "$src"/configs/pm/*.json "$RUNNER_TOOL_CACHE/"
echo "::set-output name=php-version::$semver"
add_log "$tick" "PHP" "$status PHP $semver$extra_version"
}

Expand Down
4 changes: 2 additions & 2 deletions src/scripts/extensions/cubrid.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Function to log license details.
add_license_log() {
printf "::group::\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" "$ext" "Click to read the $ext related license information"
printf "$GROUP\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" "$ext" "Click to read the $ext related license information"
printf "Cubrid CCI package is required for %s extension.\n" "$ext"
printf "The extension %s and Cubrid CCI are provided under the license linked below.\n" "$ext"
printf "Refer to: \033[35;1m%s \033[0m\n" "https://github.com/CUBRID/cubrid-cci/blob/develop/COPYING"
echo "::endgroup::"
echo "$END_GROUP"
}

# Function to setup gcc-7 and g++-7
Expand Down
4 changes: 2 additions & 2 deletions src/scripts/extensions/ioncube.ps1
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Function to log result of a operation.
Function Add-LicenseLog() {
printf "::group::\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" "ioncube" "Click to read the ioncube loader license information"
printf "$env:GROUP\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" "ioncube" "Click to read the ioncube loader license information"
Get-Content $ext_dir\ioncube\LICENSE.txt
Write-Output "::endgroup::"
Write-Output "$env:END_GROUP"
}

# Function to add ioncube extension.
Expand Down
4 changes: 2 additions & 2 deletions src/scripts/extensions/ioncube.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Function to log result of a operation.
add_license_log() {
printf "::group::\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" "ioncube" "Click to read the ioncube loader license information"
printf "$GROUP\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" "ioncube" "Click to read the ioncube loader license information"
cat "${ext_dir:?}"/IONCUBE_LICENSE.txt
echo "::endgroup::"
echo "$END_GROUP"
}

# Function to install ioncube.
Expand Down
4 changes: 2 additions & 2 deletions src/scripts/extensions/oci.ps1
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Function to log license information.
Function Add-LicenseLog() {
printf "::group::\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" $extension "Click to read the $extension related license information"
printf "$env:GROUP\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" $extension "Click to read the $extension related license information"
printf "Oracle Instant Client package is required for %s extension.\n" $extension
printf "It is provided under the Oracle Technology Network Development and Distribution License.\n"
printf "Refer to: \033[35;1m%s \033[0m\n" "https://www.oracle.com/downloads/licenses/instant-client-lic.html"
Write-Output "::endgroup::"
Write-Output "$env:END_GROUP"
}

# Function to get instantclinet.
Expand Down
4 changes: 2 additions & 2 deletions src/scripts/extensions/oci.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Function to log result of a operation.
add_license_log() {
printf "::group::\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" "$ext" "Click to read the $ext related license information"
printf "$GROUP\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" "$ext" "Click to read the $ext related license information"
printf "Oracle Instant Client package is required for %s extension.\n" "$ext"
printf "It is provided under the Oracle Technology Network Development and Distribution License.\n"
printf "Refer to: \033[35;1m%s \033[0m\n" "https://www.oracle.com/downloads/licenses/instant-client-lic.html"
echo "::endgroup::"
echo "$END_GROUP"
}

# Function to install instantclient and SDK.
Expand Down
4 changes: 2 additions & 2 deletions src/scripts/extensions/source.sh
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ run_group() {
command=$1
log=$2
echo "$command" | sudo tee ./run_group.sh >/dev/null 2>&1
echo "::group::$log"
echo "$GROUP$log"
. ./run_group.sh
rm ./run_group.sh
echo "::endgroup::"
echo "$END_GROUP"
}

patch_extension() {
Expand Down
2 changes: 1 addition & 1 deletion src/scripts/linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -239,10 +239,10 @@ setup_php() {
mapfile -t ini_file < <(sudo find "$ini_dir/.." -name "php.ini" -exec readlink -m {} +)
link_pecl_file
configure_php
set_output "php-version" "$semver"
sudo rm -rf /usr/local/bin/phpunit >/dev/null 2>&1
sudo chmod 777 "${ini_file[@]}" "$pecl_file" "${tool_path_dir:?}"
sudo cp "$src"/configs/pm/*.json "$RUNNER_TOOL_CACHE/"
echo "::set-output name=php-version::$semver"
add_log "${tick:?}" "PHP" "$status PHP $semver$extra_version"
}

Expand Down
6 changes: 3 additions & 3 deletions src/scripts/tools/grpc_php_plugin.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ Function Add-Grpc_php_plugin() {
$logs = . $msys_location\usr\bin\bash -l -c "pacman -S --noconfirm mingw-w64-x86_64-grpc" >$null 2>&1
$grpc_version = Get-ToolVersion 'Write-Output' "$logs"
Add-Path $msys_location\mingw64\bin
Write-Output "::set-output name=grpc_php_plugin_path::$msys_location\mingw64\bin\grpc_php_plugin.exe"
Set-Output grpc_php_plugin_path "$msys_location\mingw64\bin\grpc_php_plugin.exe"
Add-ToProfile $current_profile 'grpc_php_plugin' "New-Alias grpc_php_plugin $msys_location\mingw64\bin\grpc_php_plugin.exe"
Add-Log $tick "grpc_php_plugin" "Added grpc_php_plugin $grpc_version"
printf "::group::\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" "grpc_php_plugin" "Click to read the grpc_php_plugin related license information"
printf "$env:GROUP\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" "grpc_php_plugin" "Click to read the grpc_php_plugin related license information"
Write-Output (Invoke-WebRequest https://raw.githubusercontent.com/grpc/grpc/master/LICENSE).Content
Write-Output "::endgroup::"
Write-Output "$env:END_GROUP"
}
6 changes: 3 additions & 3 deletions src/scripts/tools/grpc_php_plugin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ add_grpc_php_plugin() {
else
add_grpc_php_plugin_compile >/dev/null 2>&1
fi
echo "::set-output name=grpc_php_plugin_path::$(command -v grpc_php_plugin)"
set_output grpc_php_plugin_path "$(command -v grpc_php_plugin)"
add_log "${tick:?}" "grpc_php_plugin" "Added grpc_php_plugin ${grpc_tag:1}"
printf "::group::\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" "grpc_php_plugin" "Click to read the grpc_php_plugin related license information"
printf "$GROUP\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" "grpc_php_plugin" "Click to read the grpc_php_plugin related license information"
cat "$license_path"
echo "::endgroup::"
echo "$END_GROUP"
}
4 changes: 2 additions & 2 deletions src/scripts/tools/protoc.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Function Add-Protoc() {
Move-Item -Path $bin_dir\protoc\bin\protoc.exe -Destination $bin_dir\protoc.exe
Add-ToProfile $current_profile 'protoc' "New-Alias protoc $bin_dir\protoc.exe"
Add-Log $tick "protoc" "Added protoc $($protobuf_tag -replace 'v', '')"
printf "::group::\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" "protoc" "Click to read the protoc related license information"
printf "$env:GROUP\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" "protoc" "Click to read the protoc related license information"
Write-Output (Invoke-WebRequest https://raw.githubusercontent.com/protocolbuffers/protobuf/master/LICENSE).Content
Write-Output "::endgroup::"
Write-Output "$env:END_GROUP"
}
4 changes: 2 additions & 2 deletions src/scripts/tools/protoc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ add_protoc() {
sudo chmod -R 777 /usr/local/bin/protoc /usr/local/include/google
) >/dev/null 2>&1
add_log "${tick:?}" "protoc" "Added protoc ${protobuf_tag:1}"
printf "::group::\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" "protoc" "Click to read the protoc related license information"
printf "$GROUP\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" "protoc" "Click to read the protoc related license information"
curl "${curl_opts[@]:?}" https://raw.githubusercontent.com/protocolbuffers/protobuf/master/LICENSE
echo "::endgroup::"
echo "$END_GROUP"
}
17 changes: 17 additions & 0 deletions src/scripts/unix.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ export github="https://github.com/shivammathur"
export jsdeliver="https://cdn.jsdelivr.net/gh/shivammathur"
export setup_php="https://setup-php.com"

if [ -n "${GITHUB_ACTIONS}" ]; then
export GROUP='::group::'
export END_GROUP='::endgroup::'
else
export GROUP=''
export END_GROUP=''
fi

# Function to log start of a operation.
step_log() {
message=$1
Expand All @@ -30,6 +38,15 @@ add_log() {
fi
}

# Function to set output on GitHub Actions.
set_output() {
name=$1
value=$2
if [ "${GITHUB_ACTIONS}" = "true" ]; then
echo "::set-output name=${name}::${value}"
fi
}

# Function to read env inputs.
read_env() {
update="${update:-${UPDATE:-false}}"
Expand Down
30 changes: 29 additions & 1 deletion src/scripts/win32.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,25 @@ Function Add-Log($mark, $subject, $message) {
}
}

# Function to set output on GitHub Actions.
Function Set-Output() {
param(
[Parameter(Position = 0, Mandatory = $true)]
[ValidateNotNull()]
[ValidateLength(1, [int]::MaxValue)]
[string]
$output,
[Parameter(Position = 1, Mandatory = $true)]
[ValidateNotNull()]
[ValidateLength(1, [int]::MaxValue)]
[string]
$value
)
if ($env:GITHUB_ACTIONS -eq 'true') {
Write-Output "::set-output name=$output::$value"
}
}

# Function to add a line to a powershell profile safely.
Function Add-ToProfile {
param(
Expand Down Expand Up @@ -231,6 +250,15 @@ if($env:PHPTS -ne 'ts') {
} else {
$env:PHPTS = ''
}

if ( $env:GITHUB_ACTIONS -eq 'true') {
$env:GROUP = '::group::'
$env:END_GROUP = '::endgroup::'
} else {
$env:GROUP = ''
$env:END_GROUP = ''
}

if($env:RUNNER -eq 'self-hosted' -or (-not($env:ImageOS) -and -not($env:ImageVersion))) {
$bin_dir = 'C:\tools\bin'
$php_dir = "$php_dir$version"
Expand Down Expand Up @@ -316,5 +344,5 @@ if($version -lt "5.5") {
Enable-PhpExtension -Extension $enable_extensions -Path $php_dir
Add-PhpCAInfo
Copy-Item -Path $src\configs\pm\*.json -Destination $env:RUNNER_TOOL_CACHE
Write-Output "::set-output name=php-version::$($installed.FullVersion)"
Set-Output php-version $($installed.FullVersion)
Add-Log $tick "PHP" "$status PHP $($installed.FullVersion)$extra_version"

0 comments on commit 9d74a11

Please sign in to comment.