From 2d314bc41389ed43737d2c8a1005faaea046520e Mon Sep 17 00:00:00 2001 From: "Paulo F. Oliveira" Date: Wed, 14 Dec 2022 15:25:50 +0000 Subject: [PATCH] Check behaviour on Windows pre- Gleam 0.23 (#166) * Check behaviour on Windows pre- Gleam 0.23 * Increase consistency with .sh counterpart * Support older versions (pre 0.22.1) on Windows * Increase inter-script consistency * Run `npm run build-dist` * React to CI results --- .github/workflows/windows.yml | 4 +++- dist/install-gleam.ps1 | 18 +++++++++++++++++- dist/install-gleam.sh | 7 ++++--- dist/install-otp.ps1 | 13 ++++++++----- src/install-gleam.ps1 | 18 +++++++++++++++++- src/install-gleam.sh | 7 ++++--- src/install-otp.ps1 | 13 ++++++++----- 7 files changed, 61 insertions(+), 19 deletions(-) diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 65475a9..5d8c466 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -41,9 +41,11 @@ jobs: otp-version: '24' rebar3-version: '3.15' os: 'windows-latest' + - gleam-version: '0.19.0-rc3' + otp-version: '24' + os: 'windows-latest' - gleam-version: '0.23.0-rc1' otp-version: '24' - rebar3-version: '3.16' os: 'windows-latest' - elixir-version: 'v1.13' otp-version: '24' diff --git a/dist/install-gleam.ps1 b/dist/install-gleam.ps1 index 8aa49e8..828d161 100644 --- a/dist/install-gleam.ps1 +++ b/dist/install-gleam.ps1 @@ -4,10 +4,26 @@ $ErrorActionPreference="Stop" Set-Location ${Env:RUNNER_TEMP} -$FILE_INPUT="gleam-${VSN}-x86_64-pc-windows-msvc.zip" $FILE_OUTPUT="gleam.zip" $DIR_FOR_BIN=".setup-beam/gleam" +function Version-Greater-Than([string]${THIS_ONE}, [string]${REFERENCE}) { + $THIS_ONE=$THIS_ONE.replace('v', '') + $THIS_ONE=$THIS_ONE.replace('rc', '') + $THIS_ONE=$THIS_ONE.replace('-', '') + return [version]${THIS_ONE} -gt [version]${REFERENCE} +} + +function Uses-LLVM-Triplets([string]${THIS_VSN}) { + return "${THIS_VSN}" -eq "nightly" -or (Version-Greater-Than "${THIS_VSN}" "0.22.1") +} + +if (Uses-LLVM-Triplets "$VSN") { + $FILE_INPUT="gleam-${VSN}-x86_64-pc-windows-msvc.zip" +} else { + $FILE_INPUT="gleam-${VSN}-windows-64bit.zip" +} + $ProgressPreference="SilentlyContinue" Invoke-WebRequest "https://github.com/gleam-lang/gleam/releases/download/${VSN}/${FILE_INPUT}" -OutFile "${FILE_OUTPUT}" $ProgressPreference="Continue" diff --git a/dist/install-gleam.sh b/dist/install-gleam.sh index d569426..6b060a9 100755 --- a/dist/install-gleam.sh +++ b/dist/install-gleam.sh @@ -9,12 +9,13 @@ FILE_OUTPUT=gleam.tar.gz DIR_FOR_BIN=.setup-beam/gleam version_gt() { - test "$(printf '%s\n' "$@" | sort -V | head -n 1)" != "$1" + REFERENCE=$1 + test "$(printf '%s\n' "$@" | sort -V | head -n 1)" != "$REFERENCE" } uses_llvm_triplets() { - local version="$1" - test "$version" = "nightly" || version_gt "$version" "v0.22.1" + local VERSION="$1" + test "${VERSION}" = "nightly" || version_gt "${VERSION}" "v0.22.1" } if uses_llvm_triplets "$VSN" diff --git a/dist/install-otp.ps1 b/dist/install-otp.ps1 index 24cf773..c290342 100644 --- a/dist/install-otp.ps1 +++ b/dist/install-otp.ps1 @@ -4,14 +4,17 @@ $ErrorActionPreference="Stop" Set-Location ${Env:RUNNER_TEMP} +$FILE_INPUT="otp_win64_${VSN}.exe" $FILE_OUTPUT="otp.exe" -$ERL_ROOT = "${Env:RUNNER_TEMP}\.setup-beam\otp" +$DIR_FOR_BIN="${Env:RUNNER_TEMP}\.setup-beam\otp" $ProgressPreference="SilentlyContinue" -Invoke-WebRequest "https://github.com/erlang/otp/releases/download/OTP-${VSN}/otp_win64_${VSN}.exe" -OutFile "${FILE_OUTPUT}" +Invoke-WebRequest "https://github.com/erlang/otp/releases/download/OTP-${VSN}/${FILE_INPUT}" -OutFile "${FILE_OUTPUT}" $ProgressPreference="Continue" -Start-Process "${FILE_OUTPUT}" "/S /D=${ERL_ROOT}" -Wait +New-Item "${DIR_FOR_BIN}" -ItemType Directory | Out-Null +$ProgressPreference="SilentlyContinue" +Start-Process "${FILE_OUTPUT}" "/S /D=${DIR_FOR_BIN}" -Wait Write-Output "Installed Erlang/OTP version follows" -& "${ERL_ROOT}/bin/erl.exe" "+V" | Write-Output +& "${DIR_FOR_BIN}/bin/erl.exe" "+V" | Write-Output -"INSTALL_DIR_FOR_OTP=${ERL_ROOT}" | Out-File -FilePath ${Env:GITHUB_ENV} -Encoding utf8 -Append +"INSTALL_DIR_FOR_OTP=${DIR_FOR_BIN}" | Out-File -FilePath ${Env:GITHUB_ENV} -Encoding utf8 -Append diff --git a/src/install-gleam.ps1 b/src/install-gleam.ps1 index 8aa49e8..828d161 100644 --- a/src/install-gleam.ps1 +++ b/src/install-gleam.ps1 @@ -4,10 +4,26 @@ $ErrorActionPreference="Stop" Set-Location ${Env:RUNNER_TEMP} -$FILE_INPUT="gleam-${VSN}-x86_64-pc-windows-msvc.zip" $FILE_OUTPUT="gleam.zip" $DIR_FOR_BIN=".setup-beam/gleam" +function Version-Greater-Than([string]${THIS_ONE}, [string]${REFERENCE}) { + $THIS_ONE=$THIS_ONE.replace('v', '') + $THIS_ONE=$THIS_ONE.replace('rc', '') + $THIS_ONE=$THIS_ONE.replace('-', '') + return [version]${THIS_ONE} -gt [version]${REFERENCE} +} + +function Uses-LLVM-Triplets([string]${THIS_VSN}) { + return "${THIS_VSN}" -eq "nightly" -or (Version-Greater-Than "${THIS_VSN}" "0.22.1") +} + +if (Uses-LLVM-Triplets "$VSN") { + $FILE_INPUT="gleam-${VSN}-x86_64-pc-windows-msvc.zip" +} else { + $FILE_INPUT="gleam-${VSN}-windows-64bit.zip" +} + $ProgressPreference="SilentlyContinue" Invoke-WebRequest "https://github.com/gleam-lang/gleam/releases/download/${VSN}/${FILE_INPUT}" -OutFile "${FILE_OUTPUT}" $ProgressPreference="Continue" diff --git a/src/install-gleam.sh b/src/install-gleam.sh index d569426..6b060a9 100755 --- a/src/install-gleam.sh +++ b/src/install-gleam.sh @@ -9,12 +9,13 @@ FILE_OUTPUT=gleam.tar.gz DIR_FOR_BIN=.setup-beam/gleam version_gt() { - test "$(printf '%s\n' "$@" | sort -V | head -n 1)" != "$1" + REFERENCE=$1 + test "$(printf '%s\n' "$@" | sort -V | head -n 1)" != "$REFERENCE" } uses_llvm_triplets() { - local version="$1" - test "$version" = "nightly" || version_gt "$version" "v0.22.1" + local VERSION="$1" + test "${VERSION}" = "nightly" || version_gt "${VERSION}" "v0.22.1" } if uses_llvm_triplets "$VSN" diff --git a/src/install-otp.ps1 b/src/install-otp.ps1 index 24cf773..c290342 100644 --- a/src/install-otp.ps1 +++ b/src/install-otp.ps1 @@ -4,14 +4,17 @@ $ErrorActionPreference="Stop" Set-Location ${Env:RUNNER_TEMP} +$FILE_INPUT="otp_win64_${VSN}.exe" $FILE_OUTPUT="otp.exe" -$ERL_ROOT = "${Env:RUNNER_TEMP}\.setup-beam\otp" +$DIR_FOR_BIN="${Env:RUNNER_TEMP}\.setup-beam\otp" $ProgressPreference="SilentlyContinue" -Invoke-WebRequest "https://github.com/erlang/otp/releases/download/OTP-${VSN}/otp_win64_${VSN}.exe" -OutFile "${FILE_OUTPUT}" +Invoke-WebRequest "https://github.com/erlang/otp/releases/download/OTP-${VSN}/${FILE_INPUT}" -OutFile "${FILE_OUTPUT}" $ProgressPreference="Continue" -Start-Process "${FILE_OUTPUT}" "/S /D=${ERL_ROOT}" -Wait +New-Item "${DIR_FOR_BIN}" -ItemType Directory | Out-Null +$ProgressPreference="SilentlyContinue" +Start-Process "${FILE_OUTPUT}" "/S /D=${DIR_FOR_BIN}" -Wait Write-Output "Installed Erlang/OTP version follows" -& "${ERL_ROOT}/bin/erl.exe" "+V" | Write-Output +& "${DIR_FOR_BIN}/bin/erl.exe" "+V" | Write-Output -"INSTALL_DIR_FOR_OTP=${ERL_ROOT}" | Out-File -FilePath ${Env:GITHUB_ENV} -Encoding utf8 -Append +"INSTALL_DIR_FOR_OTP=${DIR_FOR_BIN}" | Out-File -FilePath ${Env:GITHUB_ENV} -Encoding utf8 -Append