Compare commits

..

6 Commits

Author SHA1 Message Date
dependabot[bot] c10774ce0f Bump json5 from 1.0.1 to 1.0.2 (#170)
Bumps [json5](https://github.com/json5/json5) from 1.0.1 to 1.0.2.
- [Release notes](https://github.com/json5/json5/releases)
- [Changelog](https://github.com/json5/json5/blob/main/CHANGELOG.md)
- [Commits](https://github.com/json5/json5/compare/v1.0.1...v1.0.2)

---
updated-dependencies:
- dependency-name: json5
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-01-04 07:35:12 +00:00
Paulo F. Oliveira 37ac1c5116 Try to prevent 403 when accessing the GitHub API (#168)
* Repeat request on error (while logging it)

* Test one change at a time

* Conditionally authorize requests

This seems to affect Windows builds, so might not be the best solution,
but we're trying to isolate the issue to move forward

* Act on CI results

* Ease consumption via a JSON.parse wrapper

We still throw the error, but in a more controlled manner

* Act on CI results
2023-01-04 07:27:57 +00:00
Paulo F. Oliveira 2d314bc413 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
2022-12-14 09:25:50 -06:00
Paulo F. Oliveira aee3f52e58 Update versions as to not have CI fail (while fixing "non-failing" CI) (#164)
* Make README links usable

* Update versions under test

Otherwise it silently fails with "Error: Requested Erlang/OTP version
(23.2) not found in version list (should you be using option
'version-type': 'strict'?)", which is not too important since this
happens when setup-beam.js is included (which happens in the test
environment only)

* Fix failing Gleam test

I think `gleam check` requires OTP (execution complains about missing
`escript`) where `gleam format` does not
2022-12-11 18:33:12 -06:00
github-actions[bot] 96fce952fd Update 3rd party licenses (#162)
Co-authored-by: GitHub Actions <actions@user.noreply.github.com>
2022-12-08 07:51:51 -06:00
Paulo F. Oliveira 35850967ef Have rebar3.cmd work on a Windows CMD shell (#151)
* Provide a working rebar.cmd for system that need it

(Windows on non-PowerShell)

* Add tests for recent changes

If the "run" were to fail the job would too

* Check if Rust can find it
2022-12-01 19:16:40 +00:00
21 changed files with 227 additions and 92 deletions
+4 -1
View File
@@ -9,6 +9,9 @@ on:
branches: branches:
- main - main
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
jobs: jobs:
check_integrity: check_integrity:
name: Expected local npm actions name: Expected local npm actions
@@ -28,7 +31,7 @@ jobs:
- run: npm run yamllint - run: npm run yamllint
- run: npm run jslint - run: npm run jslint
- name: Check if build left artifacts - name: Check if build left artifacts
run: git diff --exit-code run: git diff --exit-code --ignore-space-at-eol
unit_tests_ubuntu: unit_tests_ubuntu:
name: Unit tests (Ubuntu) name: Unit tests (Ubuntu)
+5 -2
View File
@@ -9,6 +9,9 @@ on:
branches: branches:
- main - main
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
jobs: jobs:
integration_test: integration_test:
name: > name: >
@@ -179,10 +182,10 @@ jobs:
cd test-projects/erlang_rebar3 cd test-projects/erlang_rebar3
rebar3 ct rebar3 ct
if: ${{matrix.combo.rebar3-version}} if: ${{matrix.combo.rebar3-version}}
- name: Type check Gleam project (without installing Erlang/OTP) - name: Format Gleam project (without installing Erlang/OTP)
run: | run: |
cd test-projects/gleam_gleam cd test-projects/gleam_gleam
gleam check gleam format
if: ${{ matrix.combo.gleam-version && !matrix.combo.otp-version }} if: ${{ matrix.combo.gleam-version && !matrix.combo.otp-version }}
- name: Run Gleam project tests (without `rebar3`) - name: Run Gleam project tests (without `rebar3`)
run: | run: |
+17 -1
View File
@@ -9,6 +9,9 @@ on:
branches: branches:
- main - main
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
jobs: jobs:
integration_test: integration_test:
name: > name: >
@@ -41,9 +44,11 @@ jobs:
otp-version: '24' otp-version: '24'
rebar3-version: '3.15' rebar3-version: '3.15'
os: 'windows-latest' os: 'windows-latest'
- gleam-version: '0.19.0-rc3'
otp-version: '24'
os: 'windows-latest'
- gleam-version: '0.23.0-rc1' - gleam-version: '0.23.0-rc1'
otp-version: '24' otp-version: '24'
rebar3-version: '3.16'
os: 'windows-latest' os: 'windows-latest'
- elixir-version: 'v1.13' - elixir-version: 'v1.13'
otp-version: '24' otp-version: '24'
@@ -70,6 +75,17 @@ jobs:
if: ${{matrix.combo.gleam-version}} if: ${{matrix.combo.gleam-version}}
- name: rebar3 version (action) - name: rebar3 version (action)
run: echo "rebar3 ${{steps.setup-beam.outputs.rebar3-version}}" run: echo "rebar3 ${{steps.setup-beam.outputs.rebar3-version}}"
- name: Run rebar3 and rebar3.cmd
run: |
# Should not fail
rebar3 version
rebar3.cmd version
if: ${{matrix.combo.rebar3-version}}
- name: rebar3 from Rust
run: |
cd test-projects/rust_rebar3_cmd
cargo test -- --nocapture
if: ${{matrix.combo.rebar3-version}}
- name: mix version and help (CLI) - name: mix version and help (CLI)
run: | run: |
mix -v mix -v
+1 -1
View File
@@ -2009,7 +2009,7 @@ THE SOFTWARE.
----- -----
The following software may be included in this product: es-shim-unscopables, safe-regex-test. A copy of the source code may be downloaded from git+https://github.com/ljharb/es-shim-unscopables.git (es-shim-unscopables), git+https://github.com/ljharb/safe-regex-test.git (safe-regex-test). This software contains the following license and notice below: The following software may be included in this product: es-shim-unscopables, gopd, safe-regex-test. A copy of the source code may be downloaded from git+https://github.com/ljharb/es-shim-unscopables.git (es-shim-unscopables), git+https://github.com/ljharb/gopd.git (gopd), git+https://github.com/ljharb/safe-regex-test.git (safe-regex-test). This software contains the following license and notice below:
MIT License MIT License
+6 -6
View File
@@ -1,12 +1,12 @@
<!-- markdownlint-disable MD013 --> <!-- markdownlint-disable MD013 -->
# setup-beam [![GitHub Actions][action-img]][action] [![GitHub Actions][ubuntu-img]][ubuntu] [![GitHub Actions][windows-img]][windows] # setup-beam [![GitHub Actions][action-img]][action] [![GitHub Actions][ubuntu-img]][ubuntu] [![GitHub Actions][windows-img]][windows]
[action]: https://github.com/erlef/setup-beam [action]: https://github.com/erlef/setup-beam/actions/workflows/action.yml
[action-img]: https://github.com/erlef/setup-beam/workflows/action/badge.svg [action-img]: https://github.com/erlef/setup-beam/actions/workflows/action.yml/badge.svg
[ubuntu]: https://github.com/erlef/setup-beam [ubuntu]: https://github.com/erlef/setup-beam/actions/workflows/ubuntu.yml
[ubuntu-img]: https://github.com/erlef/setup-beam/workflows/ubuntu/badge.svg [ubuntu-img]: https://github.com/erlef/setup-beam/actions/workflows/ubuntu.yml/badge.svg
[windows]: https://github.com/erlef/setup-beam [windows]: https://github.com/erlef/setup-beam/actions/workflows/windows.yml
[windows-img]: https://github.com/erlef/setup-beam/workflows/windows/badge.svg [windows-img]: https://github.com/erlef/setup-beam/actions/workflows/windows.yml/badge.svg
This action sets up an Erlang/OTP environment for use in a GitHub Actions This action sets up an Erlang/OTP environment for use in a GitHub Actions
workflow by: workflow by:
+3 -3
View File
@@ -1,6 +1,6 @@
simulateInput('otp-version', '23.2') simulateInput('otp-version', '25.1.2')
simulateInput('elixir-version', '1.11') simulateInput('elixir-version', '1.14.2')
simulateInput('rebar3-version', '3.14') simulateInput('rebar3-version', '3.20')
simulateInput('install-rebar', 'true') simulateInput('install-rebar', 'true')
simulateInput('install-hex', 'true') simulateInput('install-hex', 'true')
+21 -11
View File
@@ -7440,7 +7440,7 @@ async function getOTPVersions(osVersion) {
}) })
} else if (process.platform === 'win32') { } else if (process.platform === 'win32') {
otpVersionsListings.forEach((otpVersionsListing) => { otpVersionsListings.forEach((otpVersionsListing) => {
JSON.parse(otpVersionsListing) jsonParse(otpVersionsListing)
.map((x) => x.assets) .map((x) => x.assets)
.flat() .flat()
.filter((x) => x.name.match(/^otp_win64_.*.exe$/)) .filter((x) => x.name.match(/^otp_win64_.*.exe$/))
@@ -7487,7 +7487,7 @@ async function getGleamVersions() {
) )
const gleamVersionsListing = [] const gleamVersionsListing = []
resultJSONs.forEach((resultJSON) => { resultJSONs.forEach((resultJSON) => {
JSON.parse(resultJSON) jsonParse(resultJSON)
.map((x) => x.tag_name) .map((x) => x.tag_name)
.sort() .sort()
.forEach((v) => gleamVersionsListing.push(v)) .forEach((v) => gleamVersionsListing.push(v))
@@ -7502,7 +7502,7 @@ async function getRebar3Versions() {
) )
const rebar3VersionsListing = [] const rebar3VersionsListing = []
resultJSONs.forEach((resultJSON) => { resultJSONs.forEach((resultJSON) => {
JSON.parse(resultJSON) jsonParse(resultJSON)
.map((x) => x.tag_name) .map((x) => x.tag_name)
.sort() .sort()
.forEach((v) => rebar3VersionsListing.push(v)) .forEach((v) => rebar3VersionsListing.push(v))
@@ -7609,16 +7609,17 @@ async function get(url0, pageIdxs) {
function getPage(pageIdx) { function getPage(pageIdx) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const url = new URL(url0) const url = new URL(url0)
const headers = {
'user-agent': 'setup-beam',
}
if (process.env.GITHUB_TOKEN) {
headers.authorization = `Bearer ${process.env.GITHUB_TOKEN}`
}
if (pageIdx !== null) { if (pageIdx !== null) {
url.searchParams.append('page', pageIdx) url.searchParams.append('page', pageIdx)
} }
https https
.get( .get(url, { headers }, (res) => {
url,
{
headers: { 'user-agent': 'setup-beam' },
},
(res) => {
let data = '' let data = ''
res.on('data', (chunk) => { res.on('data', (chunk) => {
data += chunk data += chunk
@@ -7634,8 +7635,7 @@ async function get(url0, pageIdxs) {
resolve(data) resolve(data)
} }
}) })
}, })
)
.on('error', (err) => { .on('error', (err) => {
reject(err) reject(err)
}) })
@@ -7716,6 +7716,16 @@ function parseVersionFile(versionFilePath0) {
return appVersions return appVersions
} }
function jsonParse(maybeJson) {
try {
return JSON.parse(maybeJson)
} catch (exc) {
throw new Error(
`Got an exception when trying to parse non-JSON ${maybeJson}: ${exc}`,
)
}
}
module.exports = { module.exports = {
getOTPVersion, getOTPVersion,
getElixirVersion, getElixirVersion,
+17 -1
View File
@@ -4,10 +4,26 @@ $ErrorActionPreference="Stop"
Set-Location ${Env:RUNNER_TEMP} Set-Location ${Env:RUNNER_TEMP}
$FILE_INPUT="gleam-${VSN}-x86_64-pc-windows-msvc.zip"
$FILE_OUTPUT="gleam.zip" $FILE_OUTPUT="gleam.zip"
$DIR_FOR_BIN=".setup-beam/gleam" $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" $ProgressPreference="SilentlyContinue"
Invoke-WebRequest "https://github.com/gleam-lang/gleam/releases/download/${VSN}/${FILE_INPUT}" -OutFile "${FILE_OUTPUT}" Invoke-WebRequest "https://github.com/gleam-lang/gleam/releases/download/${VSN}/${FILE_INPUT}" -OutFile "${FILE_OUTPUT}"
$ProgressPreference="Continue" $ProgressPreference="Continue"
+4 -3
View File
@@ -9,12 +9,13 @@ FILE_OUTPUT=gleam.tar.gz
DIR_FOR_BIN=.setup-beam/gleam DIR_FOR_BIN=.setup-beam/gleam
version_gt() { 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() { uses_llvm_triplets() {
local version="$1" local VERSION="$1"
test "$version" = "nightly" || version_gt "$version" "v0.22.1" test "${VERSION}" = "nightly" || version_gt "${VERSION}" "v0.22.1"
} }
if uses_llvm_triplets "$VSN" if uses_llvm_triplets "$VSN"
+8 -5
View File
@@ -4,14 +4,17 @@ $ErrorActionPreference="Stop"
Set-Location ${Env:RUNNER_TEMP} Set-Location ${Env:RUNNER_TEMP}
$FILE_INPUT="otp_win64_${VSN}.exe"
$FILE_OUTPUT="otp.exe" $FILE_OUTPUT="otp.exe"
$ERL_ROOT = "${Env:RUNNER_TEMP}\.setup-beam\otp" $DIR_FOR_BIN="${Env:RUNNER_TEMP}\.setup-beam\otp"
$ProgressPreference="SilentlyContinue" $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" $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" 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
+3 -1
View File
@@ -7,6 +7,7 @@ Set-Location ${Env:RUNNER_TEMP}
$FILE_INPUT="rebar3" $FILE_INPUT="rebar3"
$FILE_OUTPUT="rebar3" $FILE_OUTPUT="rebar3"
$FILE_OUTPUT_PS1="rebar3.ps1" $FILE_OUTPUT_PS1="rebar3.ps1"
$FILE_OUTPUT_CMD="rebar3.cmd"
$DIR_FOR_BIN=".setup-beam/rebar3" $DIR_FOR_BIN=".setup-beam/rebar3"
$ProgressPreference="SilentlyContinue" $ProgressPreference="SilentlyContinue"
@@ -22,8 +23,9 @@ $ProgressPreference="Continue"
New-Item "${DIR_FOR_BIN}/bin" -ItemType Directory | Out-Null New-Item "${DIR_FOR_BIN}/bin" -ItemType Directory | Out-Null
Move-Item "${FILE_OUTPUT}" "${DIR_FOR_BIN}/bin" Move-Item "${FILE_OUTPUT}" "${DIR_FOR_BIN}/bin"
Write-Output "& escript.exe ${PWD}/${DIR_FOR_BIN}/bin/${FILE_OUTPUT} `${args}" | Out-File -FilePath "${FILE_OUTPUT_PS1}" -Encoding utf8 -Append Write-Output "& escript.exe ${PWD}/${DIR_FOR_BIN}/bin/${FILE_OUTPUT} `${args}" | Out-File -FilePath "${FILE_OUTPUT_PS1}" -Encoding utf8 -Append
type ${FILE_OUTPUT_PS1} Write-Output "@echo off`r`nescript.exe ${PWD}/${DIR_FOR_BIN}/bin/${FILE_OUTPUT} %*" | Out-File -FilePath "${FILE_OUTPUT_CMD}" -Encoding utf8 -Append
Move-Item "${FILE_OUTPUT_PS1}" "${DIR_FOR_BIN}/bin" Move-Item "${FILE_OUTPUT_PS1}" "${DIR_FOR_BIN}/bin"
Move-Item "${FILE_OUTPUT_CMD}" "${DIR_FOR_BIN}/bin"
Write-Output "Installed rebar3 version${REBAR3_NIGHTLY} follows" Write-Output "Installed rebar3 version${REBAR3_NIGHTLY} follows"
& "${DIR_FOR_BIN}/bin/rebar3" "version" | Write-Output & "${DIR_FOR_BIN}/bin/rebar3" "version" | Write-Output
+6 -6
View File
@@ -1857,9 +1857,9 @@
"dev": true "dev": true
}, },
"node_modules/json5": { "node_modules/json5": {
"version": "1.0.1", "version": "1.0.2",
"resolved": "https://registry.npmjs.org/json5/-/json5-1.0.1.tgz", "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.2.tgz",
"integrity": "sha512-aKS4WQjPenRxiQsC93MNfjx+nbF4PAdYzmd/1JIj8HYzqfbu86beTuNgXDzPknWk0n0uARlyewZo4s++ES36Ow==", "integrity": "sha512-g1MWMLBiz8FKi1e4w0UyVL3w+iJceWAFBAaBnnGKOpNa5f8TLktkbre1+s6oICydWAm+HRUGTmI+//xv2hvXYA==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"minimist": "^1.2.0" "minimist": "^1.2.0"
@@ -4363,9 +4363,9 @@
"dev": true "dev": true
}, },
"json5": { "json5": {
"version": "1.0.1", "version": "1.0.2",
"resolved": "https://registry.npmjs.org/json5/-/json5-1.0.1.tgz", "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.2.tgz",
"integrity": "sha512-aKS4WQjPenRxiQsC93MNfjx+nbF4PAdYzmd/1JIj8HYzqfbu86beTuNgXDzPknWk0n0uARlyewZo4s++ES36Ow==", "integrity": "sha512-g1MWMLBiz8FKi1e4w0UyVL3w+iJceWAFBAaBnnGKOpNa5f8TLktkbre1+s6oICydWAm+HRUGTmI+//xv2hvXYA==",
"dev": true, "dev": true,
"requires": { "requires": {
"minimist": "^1.2.0" "minimist": "^1.2.0"
+17 -1
View File
@@ -4,10 +4,26 @@ $ErrorActionPreference="Stop"
Set-Location ${Env:RUNNER_TEMP} Set-Location ${Env:RUNNER_TEMP}
$FILE_INPUT="gleam-${VSN}-x86_64-pc-windows-msvc.zip"
$FILE_OUTPUT="gleam.zip" $FILE_OUTPUT="gleam.zip"
$DIR_FOR_BIN=".setup-beam/gleam" $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" $ProgressPreference="SilentlyContinue"
Invoke-WebRequest "https://github.com/gleam-lang/gleam/releases/download/${VSN}/${FILE_INPUT}" -OutFile "${FILE_OUTPUT}" Invoke-WebRequest "https://github.com/gleam-lang/gleam/releases/download/${VSN}/${FILE_INPUT}" -OutFile "${FILE_OUTPUT}"
$ProgressPreference="Continue" $ProgressPreference="Continue"
+4 -3
View File
@@ -9,12 +9,13 @@ FILE_OUTPUT=gleam.tar.gz
DIR_FOR_BIN=.setup-beam/gleam DIR_FOR_BIN=.setup-beam/gleam
version_gt() { 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() { uses_llvm_triplets() {
local version="$1" local VERSION="$1"
test "$version" = "nightly" || version_gt "$version" "v0.22.1" test "${VERSION}" = "nightly" || version_gt "${VERSION}" "v0.22.1"
} }
if uses_llvm_triplets "$VSN" if uses_llvm_triplets "$VSN"
+8 -5
View File
@@ -4,14 +4,17 @@ $ErrorActionPreference="Stop"
Set-Location ${Env:RUNNER_TEMP} Set-Location ${Env:RUNNER_TEMP}
$FILE_INPUT="otp_win64_${VSN}.exe"
$FILE_OUTPUT="otp.exe" $FILE_OUTPUT="otp.exe"
$ERL_ROOT = "${Env:RUNNER_TEMP}\.setup-beam\otp" $DIR_FOR_BIN="${Env:RUNNER_TEMP}\.setup-beam\otp"
$ProgressPreference="SilentlyContinue" $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" $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" 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
+3 -1
View File
@@ -7,6 +7,7 @@ Set-Location ${Env:RUNNER_TEMP}
$FILE_INPUT="rebar3" $FILE_INPUT="rebar3"
$FILE_OUTPUT="rebar3" $FILE_OUTPUT="rebar3"
$FILE_OUTPUT_PS1="rebar3.ps1" $FILE_OUTPUT_PS1="rebar3.ps1"
$FILE_OUTPUT_CMD="rebar3.cmd"
$DIR_FOR_BIN=".setup-beam/rebar3" $DIR_FOR_BIN=".setup-beam/rebar3"
$ProgressPreference="SilentlyContinue" $ProgressPreference="SilentlyContinue"
@@ -22,8 +23,9 @@ $ProgressPreference="Continue"
New-Item "${DIR_FOR_BIN}/bin" -ItemType Directory | Out-Null New-Item "${DIR_FOR_BIN}/bin" -ItemType Directory | Out-Null
Move-Item "${FILE_OUTPUT}" "${DIR_FOR_BIN}/bin" Move-Item "${FILE_OUTPUT}" "${DIR_FOR_BIN}/bin"
Write-Output "& escript.exe ${PWD}/${DIR_FOR_BIN}/bin/${FILE_OUTPUT} `${args}" | Out-File -FilePath "${FILE_OUTPUT_PS1}" -Encoding utf8 -Append Write-Output "& escript.exe ${PWD}/${DIR_FOR_BIN}/bin/${FILE_OUTPUT} `${args}" | Out-File -FilePath "${FILE_OUTPUT_PS1}" -Encoding utf8 -Append
type ${FILE_OUTPUT_PS1} Write-Output "@echo off`r`nescript.exe ${PWD}/${DIR_FOR_BIN}/bin/${FILE_OUTPUT} %*" | Out-File -FilePath "${FILE_OUTPUT_CMD}" -Encoding utf8 -Append
Move-Item "${FILE_OUTPUT_PS1}" "${DIR_FOR_BIN}/bin" Move-Item "${FILE_OUTPUT_PS1}" "${DIR_FOR_BIN}/bin"
Move-Item "${FILE_OUTPUT_CMD}" "${DIR_FOR_BIN}/bin"
Write-Output "Installed rebar3 version${REBAR3_NIGHTLY} follows" Write-Output "Installed rebar3 version${REBAR3_NIGHTLY} follows"
& "${DIR_FOR_BIN}/bin/rebar3" "version" | Write-Output & "${DIR_FOR_BIN}/bin/rebar3" "version" | Write-Output
+21 -11
View File
@@ -247,7 +247,7 @@ async function getOTPVersions(osVersion) {
}) })
} else if (process.platform === 'win32') { } else if (process.platform === 'win32') {
otpVersionsListings.forEach((otpVersionsListing) => { otpVersionsListings.forEach((otpVersionsListing) => {
JSON.parse(otpVersionsListing) jsonParse(otpVersionsListing)
.map((x) => x.assets) .map((x) => x.assets)
.flat() .flat()
.filter((x) => x.name.match(/^otp_win64_.*.exe$/)) .filter((x) => x.name.match(/^otp_win64_.*.exe$/))
@@ -294,7 +294,7 @@ async function getGleamVersions() {
) )
const gleamVersionsListing = [] const gleamVersionsListing = []
resultJSONs.forEach((resultJSON) => { resultJSONs.forEach((resultJSON) => {
JSON.parse(resultJSON) jsonParse(resultJSON)
.map((x) => x.tag_name) .map((x) => x.tag_name)
.sort() .sort()
.forEach((v) => gleamVersionsListing.push(v)) .forEach((v) => gleamVersionsListing.push(v))
@@ -309,7 +309,7 @@ async function getRebar3Versions() {
) )
const rebar3VersionsListing = [] const rebar3VersionsListing = []
resultJSONs.forEach((resultJSON) => { resultJSONs.forEach((resultJSON) => {
JSON.parse(resultJSON) jsonParse(resultJSON)
.map((x) => x.tag_name) .map((x) => x.tag_name)
.sort() .sort()
.forEach((v) => rebar3VersionsListing.push(v)) .forEach((v) => rebar3VersionsListing.push(v))
@@ -416,16 +416,17 @@ async function get(url0, pageIdxs) {
function getPage(pageIdx) { function getPage(pageIdx) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const url = new URL(url0) const url = new URL(url0)
const headers = {
'user-agent': 'setup-beam',
}
if (process.env.GITHUB_TOKEN) {
headers.authorization = `Bearer ${process.env.GITHUB_TOKEN}`
}
if (pageIdx !== null) { if (pageIdx !== null) {
url.searchParams.append('page', pageIdx) url.searchParams.append('page', pageIdx)
} }
https https
.get( .get(url, { headers }, (res) => {
url,
{
headers: { 'user-agent': 'setup-beam' },
},
(res) => {
let data = '' let data = ''
res.on('data', (chunk) => { res.on('data', (chunk) => {
data += chunk data += chunk
@@ -441,8 +442,7 @@ async function get(url0, pageIdxs) {
resolve(data) resolve(data)
} }
}) })
}, })
)
.on('error', (err) => { .on('error', (err) => {
reject(err) reject(err)
}) })
@@ -523,6 +523,16 @@ function parseVersionFile(versionFilePath0) {
return appVersions return appVersions
} }
function jsonParse(maybeJson) {
try {
return JSON.parse(maybeJson)
} catch (exc) {
throw new Error(
`Got an exception when trying to parse non-JSON ${maybeJson}: ${exc}`,
)
}
}
module.exports = { module.exports = {
getOTPVersion, getOTPVersion,
getElixirVersion, getElixirVersion,
+2
View File
@@ -0,0 +1,2 @@
/target/
main
+7
View File
@@ -0,0 +1,7 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "rust_rebar3_cmd"
version = "0.1.0"
+8
View File
@@ -0,0 +1,8 @@
[package]
name = "rust_rebar3_cmd"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
+32
View File
@@ -0,0 +1,32 @@
use std::env;
use std::process;
use std::string;
// an example function...
fn main() {
let key = "PATH";
match env::var(key) {
Ok(val) => println!("{key}: {val:?}"),
Err(e) => println!("couldn't interpret {key}: {e}"),
}
}
#[allow(dead_code)]
fn rebar3_cmd_version() -> Result<String, string::FromUtf8Error> {
println!("going for rebar3.cmd");
let output = process::Command::new("rebar3.cmd")
.arg("version")
.output()
.expect("error");
return String::from_utf8(output.stdout);
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn it_works() {
rebar3_cmd_version().unwrap();
}
}