neiam /action-setup-beam
action-setup-beam
public · Issues · Pulls · Labels · Forks · Compare · Actions queued
⭐
Log in to mark this repository.
Improve output when failing to get a version from "a place" (#334)
891e46b · Paulo F. Oliveira · 2025-05-28 22:42
Files changed
modified
dist/index.js
+45
−32
@@ -9268,20 +9268,30 @@ async function maybeInstallRebar3(rebar3Spec) {
| 9268 | 9268 | } |
| 9269 | 9269 | |
| 9270 | 9270 | async function getOTPVersion(otpSpec0, osVersion) { |
| 9271 | − const otpVersions = await getOTPVersions(osVersion) | |
| 9271 | + const [otpVersions, originListing, hexMirrors] = await getOTPVersions( | |
| 9272 | + osVersion, | |
| 9273 | + ) | |
| 9272 | 9274 | let spec = otpSpec0.replace(/^OTP-/, '') |
| 9273 | 9275 | const versions = otpVersions |
| 9274 | 9276 | const otpVersion = getVersionFromSpec(spec, versions) |
| 9277 | + | |
| 9275 | 9278 | if (otpVersion === null) { |
| 9276 | 9279 | throw new Error( |
| 9277 | − `Requested Erlang/OTP version (${otpSpec0}) not found in version list ` + | |
| 9278 | − "(should you be using option 'version-type': 'strict'?)", | |
| 9280 | + requestedVersionFor('Erlang/OTP', otpSpec0, originListing, hexMirrors), | |
| 9279 | 9281 | ) |
| 9280 | 9282 | } |
| 9281 | 9283 | |
| 9282 | 9284 | return otpVersion // from the reference, for download |
| 9283 | 9285 | } |
| 9284 | 9286 | |
| 9287 | +function requestedVersionFor(tool, version, originListing, mirrors) { | |
| 9288 | + return ( | |
| 9289 | + `Requested ${tool} version (${version}) not found in version list, ` + | |
| 9290 | + `at ${originListing}${mirrors ? `, with mirrors ${mirrors}` : ''}; ` + | |
| 9291 | + "should you be using option 'version-type': 'strict'?" | |
| 9292 | + ) | |
| 9293 | +} | |
| 9294 | + | |
| 9285 | 9295 | async function getElixirVersion(exSpec0, otpVersion0) { |
| 9286 | 9296 | const otpVersion = otpVersion0.match(/^([^-]+-)?(.+)$/)[2] |
| 9287 | 9297 | let otpVersionMajor = otpVersion.match(/^([^.]+).*$/)[1] |
@@ -9292,15 +9302,15 @@ async function getElixirVersion(exSpec0, otpVersion0) {
| 9292 | 9302 | otpVersionMajor = userSuppliedOtp |
| 9293 | 9303 | } |
| 9294 | 9304 | |
| 9295 | − const [otpVersionsForElixirMap, elixirVersions] = await getElixirVersions() | |
| 9305 | + const [otpVersionsForElixirMap, elixirVersions, originListing, hexMirrors] = | |
| 9306 | + await getElixirVersions() | |
| 9296 | 9307 | const spec = exSpec0.replace(/-otp-.*$/, '') |
| 9297 | 9308 | const versions = elixirVersions |
| 9298 | 9309 | const elixirVersionFromSpec = getVersionFromSpec(spec, versions) |
| 9299 | 9310 | |
| 9300 | 9311 | if (elixirVersionFromSpec === null) { |
| 9301 | 9312 | throw new Error( |
| 9302 | − `Requested Elixir version (${exSpec0}) not found in version list ` + | |
| 9303 | − "(should you be using option 'version-type': 'strict'?)", | |
| 9313 | + requestedVersionFor('Elixir', exSpec0, originListing, hexMirrors), | |
| 9304 | 9314 | ) |
| 9305 | 9315 | } |
| 9306 | 9316 |
@@ -9331,30 +9341,26 @@ async function getElixirVersion(exSpec0, otpVersion0) {
| 9331 | 9341 | } |
| 9332 | 9342 | |
| 9333 | 9343 | async function getGleamVersion(gleamSpec0) { |
| 9334 | − const gleamVersions = await getGleamVersions() | |
| 9344 | + const [gleamVersions, originListing] = await getGleamVersions() | |
| 9335 | 9345 | const spec = gleamSpec0 |
| 9336 | 9346 | const versions = gleamVersions |
| 9337 | 9347 | const gleamVersion = getVersionFromSpec(spec, versions) |
| 9348 | + | |
| 9338 | 9349 | if (gleamVersion === null) { |
| 9339 | − throw new Error( | |
| 9340 | − `Requested Gleam version (${gleamSpec0}) not found in version list ` + | |
| 9341 | − "(should you be using option 'version-type': 'strict'?)", | |
| 9342 | − ) | |
| 9350 | + throw new Error(requestedVersionFor('Gleam', gleamSpec0, originListing)) | |
| 9343 | 9351 | } |
| 9344 | 9352 | |
| 9345 | 9353 | return maybePrependWithV(gleamVersion) |
| 9346 | 9354 | } |
| 9347 | 9355 | |
| 9348 | 9356 | async function getRebar3Version(r3Spec) { |
| 9349 | − const rebar3Versions = await getRebar3Versions() | |
| 9357 | + const [rebar3Versions, originListing] = await getRebar3Versions() | |
| 9350 | 9358 | const spec = r3Spec |
| 9351 | 9359 | const versions = rebar3Versions |
| 9352 | 9360 | const rebar3Version = getVersionFromSpec(spec, versions) |
| 9361 | + | |
| 9353 | 9362 | if (rebar3Version === null) { |
| 9354 | − throw new Error( | |
| 9355 | − `Requested rebar3 version (${r3Spec}) not found in version list ` + | |
| 9356 | − "(should you be using option 'version-type': 'strict'?)", | |
| 9357 | − ) | |
| 9363 | + throw new Error(requestedVersionFor('rebar3', r3Spec, originListing)) | |
| 9358 | 9364 | } |
| 9359 | 9365 | |
| 9360 | 9366 | return rebar3Version |
@@ -9363,10 +9369,12 @@ async function getRebar3Version(r3Spec) {
| 9363 | 9369 | async function getOTPVersions(osVersion) { |
| 9364 | 9370 | let otpVersionsListings |
| 9365 | 9371 | let originListing |
| 9372 | + let hexMirrors = null | |
| 9366 | 9373 | if (process.platform === 'linux') { |
| 9367 | 9374 | originListing = `/builds/otp/${getRunnerOSArchitecture()}/${osVersion}/builds.txt` |
| 9375 | + hexMirrors = hexMirrorsInput() | |
| 9368 | 9376 | otpVersionsListings = await doWithMirrors({ |
| 9369 | − hexMirrors: hexMirrorsInput(), | |
| 9377 | + hexMirrors, | |
| 9370 | 9378 | actionTitle: `fetch ${originListing}`, |
| 9371 | 9379 | action: async (hexMirror) => { |
| 9372 | 9380 | return get(`${hexMirror}${originListing}`, []) |
@@ -9378,7 +9386,10 @@ async function getOTPVersions(osVersion) {
| 9378 | 9386 | otpVersionsListings = await get(originListing, [1, 2, 3]) |
| 9379 | 9387 | } |
| 9380 | 9388 | |
| 9381 | − debugLog(`OTP versions listings from ${originListing}`, otpVersionsListings) | |
| 9389 | + debugLog( | |
| 9390 | + `OTP versions listings from ${originListing}, mirrors ${hexMirrors}`, | |
| 9391 | + otpVersionsListings, | |
| 9392 | + ) | |
| 9382 | 9393 | |
| 9383 | 9394 | const otpVersions = {} |
| 9384 | 9395 | if (process.platform === 'linux') { |
@@ -9412,15 +9423,19 @@ async function getOTPVersions(osVersion) {
| 9412 | 9423 | }) |
| 9413 | 9424 | } |
| 9414 | 9425 | |
| 9415 | − debugLog(`OTP versions from ${originListing}`, JSON.stringify(otpVersions)) | |
| 9426 | + debugLog( | |
| 9427 | + `OTP versions from ${originListing}, mirrors ${hexMirrors}`, | |
| 9428 | + JSON.stringify(otpVersions), | |
| 9429 | + ) | |
| 9416 | 9430 | |
| 9417 | − return otpVersions | |
| 9431 | + return [otpVersions, originListing, hexMirrors] | |
| 9418 | 9432 | } |
| 9419 | 9433 | |
| 9420 | 9434 | async function getElixirVersions() { |
| 9421 | 9435 | const originListing = '/builds/elixir/builds.txt' |
| 9436 | + const hexMirrors = hexMirrorsInput() | |
| 9422 | 9437 | const elixirVersionsListings = await doWithMirrors({ |
| 9423 | − hexMirrors: hexMirrorsInput(), | |
| 9438 | + hexMirrors, | |
| 9424 | 9439 | actionTitle: `fetch ${originListing}`, |
| 9425 | 9440 | action: async (hexMirror) => { |
| 9426 | 9441 | return get(`${hexMirror}${originListing}`, []) |
@@ -9446,14 +9461,13 @@ async function getElixirVersions() {
| 9446 | 9461 | elixirVersions[elixirVersion] = elixirVersion |
| 9447 | 9462 | }) |
| 9448 | 9463 | |
| 9449 | − return [otpVersionsForElixirMap, elixirVersions] | |
| 9464 | + return [otpVersionsForElixirMap, elixirVersions, originListing, hexMirrors] | |
| 9450 | 9465 | } |
| 9451 | 9466 | |
| 9452 | 9467 | async function getGleamVersions() { |
| 9453 | − const resultJSONs = await get( | |
| 9454 | − 'https://api.github.com/repos/gleam-lang/gleam/releases?per_page=100', | |
| 9455 | − [1, 2, 3], | |
| 9456 | − ) | |
| 9468 | + const originListing = | |
| 9469 | + 'https://api.github.com/repos/gleam-lang/gleam/releases?per_page=100' | |
| 9470 | + const resultJSONs = await get(originListing, [1, 2, 3]) | |
| 9457 | 9471 | const gleamVersionsListing = {} |
| 9458 | 9472 | resultJSONs.forEach((resultJSON) => { |
| 9459 | 9473 | resultJSON |
@@ -9465,14 +9479,13 @@ async function getGleamVersions() {
| 9465 | 9479 | }) |
| 9466 | 9480 | }) |
| 9467 | 9481 | |
| 9468 | − return gleamVersionsListing | |
| 9482 | + return [gleamVersionsListing, originListing] | |
| 9469 | 9483 | } |
| 9470 | 9484 | |
| 9471 | 9485 | async function getRebar3Versions() { |
| 9472 | − const resultJSONs = await get( | |
| 9473 | − 'https://api.github.com/repos/erlang/rebar3/releases?per_page=100', | |
| 9474 | − [1, 2, 3], | |
| 9475 | − ) | |
| 9486 | + const originListing = | |
| 9487 | + 'https://api.github.com/repos/erlang/rebar3/releases?per_page=100' | |
| 9488 | + const resultJSONs = await get(originListing, [1, 2, 3]) | |
| 9476 | 9489 | const rebar3VersionsListing = {} |
| 9477 | 9490 | resultJSONs.forEach((resultJSON) => { |
| 9478 | 9491 | resultJSON |
@@ -9482,7 +9495,7 @@ async function getRebar3Versions() {
| 9482 | 9495 | }) |
| 9483 | 9496 | }) |
| 9484 | 9497 | |
| 9485 | − return rebar3VersionsListing | |
| 9498 | + return [rebar3VersionsListing, originListing] | |
| 9486 | 9499 | } |
| 9487 | 9500 | |
| 9488 | 9501 | function isStrictVersion() { |
modified
src/setup-beam.js
+45
−32
@@ -168,20 +168,30 @@ async function maybeInstallRebar3(rebar3Spec) {
| 168 | 168 | } |
| 169 | 169 | |
| 170 | 170 | async function getOTPVersion(otpSpec0, osVersion) { |
| 171 | − const otpVersions = await getOTPVersions(osVersion) | |
| 171 | + const [otpVersions, originListing, hexMirrors] = await getOTPVersions( | |
| 172 | + osVersion, | |
| 173 | + ) | |
| 172 | 174 | let spec = otpSpec0.replace(/^OTP-/, '') |
| 173 | 175 | const versions = otpVersions |
| 174 | 176 | const otpVersion = getVersionFromSpec(spec, versions) |
| 177 | + | |
| 175 | 178 | if (otpVersion === null) { |
| 176 | 179 | throw new Error( |
| 177 | − `Requested Erlang/OTP version (${otpSpec0}) not found in version list ` + | |
| 178 | − "(should you be using option 'version-type': 'strict'?)", | |
| 180 | + requestedVersionFor('Erlang/OTP', otpSpec0, originListing, hexMirrors), | |
| 179 | 181 | ) |
| 180 | 182 | } |
| 181 | 183 | |
| 182 | 184 | return otpVersion // from the reference, for download |
| 183 | 185 | } |
| 184 | 186 | |
| 187 | +function requestedVersionFor(tool, version, originListing, mirrors) { | |
| 188 | + return ( | |
| 189 | + `Requested ${tool} version (${version}) not found in version list, ` + | |
| 190 | + `at ${originListing}${mirrors ? `, with mirrors ${mirrors}` : ''}; ` + | |
| 191 | + "should you be using option 'version-type': 'strict'?" | |
| 192 | + ) | |
| 193 | +} | |
| 194 | + | |
| 185 | 195 | async function getElixirVersion(exSpec0, otpVersion0) { |
| 186 | 196 | const otpVersion = otpVersion0.match(/^([^-]+-)?(.+)$/)[2] |
| 187 | 197 | let otpVersionMajor = otpVersion.match(/^([^.]+).*$/)[1] |
@@ -192,15 +202,15 @@ async function getElixirVersion(exSpec0, otpVersion0) {
| 192 | 202 | otpVersionMajor = userSuppliedOtp |
| 193 | 203 | } |
| 194 | 204 | |
| 195 | − const [otpVersionsForElixirMap, elixirVersions] = await getElixirVersions() | |
| 205 | + const [otpVersionsForElixirMap, elixirVersions, originListing, hexMirrors] = | |
| 206 | + await getElixirVersions() | |
| 196 | 207 | const spec = exSpec0.replace(/-otp-.*$/, '') |
| 197 | 208 | const versions = elixirVersions |
| 198 | 209 | const elixirVersionFromSpec = getVersionFromSpec(spec, versions) |
| 199 | 210 | |
| 200 | 211 | if (elixirVersionFromSpec === null) { |
| 201 | 212 | throw new Error( |
| 202 | − `Requested Elixir version (${exSpec0}) not found in version list ` + | |
| 203 | − "(should you be using option 'version-type': 'strict'?)", | |
| 213 | + requestedVersionFor('Elixir', exSpec0, originListing, hexMirrors), | |
| 204 | 214 | ) |
| 205 | 215 | } |
| 206 | 216 |
@@ -231,30 +241,26 @@ async function getElixirVersion(exSpec0, otpVersion0) {
| 231 | 241 | } |
| 232 | 242 | |
| 233 | 243 | async function getGleamVersion(gleamSpec0) { |
| 234 | − const gleamVersions = await getGleamVersions() | |
| 244 | + const [gleamVersions, originListing] = await getGleamVersions() | |
| 235 | 245 | const spec = gleamSpec0 |
| 236 | 246 | const versions = gleamVersions |
| 237 | 247 | const gleamVersion = getVersionFromSpec(spec, versions) |
| 248 | + | |
| 238 | 249 | if (gleamVersion === null) { |
| 239 | − throw new Error( | |
| 240 | − `Requested Gleam version (${gleamSpec0}) not found in version list ` + | |
| 241 | − "(should you be using option 'version-type': 'strict'?)", | |
| 242 | − ) | |
| 250 | + throw new Error(requestedVersionFor('Gleam', gleamSpec0, originListing)) | |
| 243 | 251 | } |
| 244 | 252 | |
| 245 | 253 | return maybePrependWithV(gleamVersion) |
| 246 | 254 | } |
| 247 | 255 | |
| 248 | 256 | async function getRebar3Version(r3Spec) { |
| 249 | − const rebar3Versions = await getRebar3Versions() | |
| 257 | + const [rebar3Versions, originListing] = await getRebar3Versions() | |
| 250 | 258 | const spec = r3Spec |
| 251 | 259 | const versions = rebar3Versions |
| 252 | 260 | const rebar3Version = getVersionFromSpec(spec, versions) |
| 261 | + | |
| 253 | 262 | if (rebar3Version === null) { |
| 254 | − throw new Error( | |
| 255 | − `Requested rebar3 version (${r3Spec}) not found in version list ` + | |
| 256 | − "(should you be using option 'version-type': 'strict'?)", | |
| 257 | − ) | |
| 263 | + throw new Error(requestedVersionFor('rebar3', r3Spec, originListing)) | |
| 258 | 264 | } |
| 259 | 265 | |
| 260 | 266 | return rebar3Version |
@@ -263,10 +269,12 @@ async function getRebar3Version(r3Spec) {
| 263 | 269 | async function getOTPVersions(osVersion) { |
| 264 | 270 | let otpVersionsListings |
| 265 | 271 | let originListing |
| 272 | + let hexMirrors = null | |
| 266 | 273 | if (process.platform === 'linux') { |
| 267 | 274 | originListing = `/builds/otp/${getRunnerOSArchitecture()}/${osVersion}/builds.txt` |
| 275 | + hexMirrors = hexMirrorsInput() | |
| 268 | 276 | otpVersionsListings = await doWithMirrors({ |
| 269 | − hexMirrors: hexMirrorsInput(), | |
| 277 | + hexMirrors, | |
| 270 | 278 | actionTitle: `fetch ${originListing}`, |
| 271 | 279 | action: async (hexMirror) => { |
| 272 | 280 | return get(`${hexMirror}${originListing}`, []) |
@@ -278,7 +286,10 @@ async function getOTPVersions(osVersion) {
| 278 | 286 | otpVersionsListings = await get(originListing, [1, 2, 3]) |
| 279 | 287 | } |
| 280 | 288 | |
| 281 | − debugLog(`OTP versions listings from ${originListing}`, otpVersionsListings) | |
| 289 | + debugLog( | |
| 290 | + `OTP versions listings from ${originListing}, mirrors ${hexMirrors}`, | |
| 291 | + otpVersionsListings, | |
| 292 | + ) | |
| 282 | 293 | |
| 283 | 294 | const otpVersions = {} |
| 284 | 295 | if (process.platform === 'linux') { |
@@ -312,15 +323,19 @@ async function getOTPVersions(osVersion) {
| 312 | 323 | }) |
| 313 | 324 | } |
| 314 | 325 | |
| 315 | − debugLog(`OTP versions from ${originListing}`, JSON.stringify(otpVersions)) | |
| 326 | + debugLog( | |
| 327 | + `OTP versions from ${originListing}, mirrors ${hexMirrors}`, | |
| 328 | + JSON.stringify(otpVersions), | |
| 329 | + ) | |
| 316 | 330 | |
| 317 | − return otpVersions | |
| 331 | + return [otpVersions, originListing, hexMirrors] | |
| 318 | 332 | } |
| 319 | 333 | |
| 320 | 334 | async function getElixirVersions() { |
| 321 | 335 | const originListing = '/builds/elixir/builds.txt' |
| 336 | + const hexMirrors = hexMirrorsInput() | |
| 322 | 337 | const elixirVersionsListings = await doWithMirrors({ |
| 323 | − hexMirrors: hexMirrorsInput(), | |
| 338 | + hexMirrors, | |
| 324 | 339 | actionTitle: `fetch ${originListing}`, |
| 325 | 340 | action: async (hexMirror) => { |
| 326 | 341 | return get(`${hexMirror}${originListing}`, []) |
@@ -346,14 +361,13 @@ async function getElixirVersions() {
| 346 | 361 | elixirVersions[elixirVersion] = elixirVersion |
| 347 | 362 | }) |
| 348 | 363 | |
| 349 | − return [otpVersionsForElixirMap, elixirVersions] | |
| 364 | + return [otpVersionsForElixirMap, elixirVersions, originListing, hexMirrors] | |
| 350 | 365 | } |
| 351 | 366 | |
| 352 | 367 | async function getGleamVersions() { |
| 353 | − const resultJSONs = await get( | |
| 354 | − 'https://api.github.com/repos/gleam-lang/gleam/releases?per_page=100', | |
| 355 | − [1, 2, 3], | |
| 356 | − ) | |
| 368 | + const originListing = | |
| 369 | + 'https://api.github.com/repos/gleam-lang/gleam/releases?per_page=100' | |
| 370 | + const resultJSONs = await get(originListing, [1, 2, 3]) | |
| 357 | 371 | const gleamVersionsListing = {} |
| 358 | 372 | resultJSONs.forEach((resultJSON) => { |
| 359 | 373 | resultJSON |
@@ -365,14 +379,13 @@ async function getGleamVersions() {
| 365 | 379 | }) |
| 366 | 380 | }) |
| 367 | 381 | |
| 368 | − return gleamVersionsListing | |
| 382 | + return [gleamVersionsListing, originListing] | |
| 369 | 383 | } |
| 370 | 384 | |
| 371 | 385 | async function getRebar3Versions() { |
| 372 | − const resultJSONs = await get( | |
| 373 | − 'https://api.github.com/repos/erlang/rebar3/releases?per_page=100', | |
| 374 | − [1, 2, 3], | |
| 375 | − ) | |
| 386 | + const originListing = | |
| 387 | + 'https://api.github.com/repos/erlang/rebar3/releases?per_page=100' | |
| 388 | + const resultJSONs = await get(originListing, [1, 2, 3]) | |
| 376 | 389 | const rebar3VersionsListing = {} |
| 377 | 390 | resultJSONs.forEach((resultJSON) => { |
| 378 | 391 | resultJSON |
@@ -382,7 +395,7 @@ async function getRebar3Versions() {
| 382 | 395 | }) |
| 383 | 396 | }) |
| 384 | 397 | |
| 385 | − return rebar3VersionsListing | |
| 398 | + return [rebar3VersionsListing, originListing] | |
| 386 | 399 | } |
| 387 | 400 | |
| 388 | 401 | function isStrictVersion() { |
Parents: a770081