Skip to content

Commit

Permalink
Test unavailable Elixir upon mix
Browse files Browse the repository at this point in the history
  • Loading branch information
paulo-ferraz-oliveira committed Mar 29, 2021
1 parent 7f2a3e9 commit a017948
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 4 deletions.
18 changes: 18 additions & 0 deletions __tests__/setup-beam.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,24 @@ async function test() {
},
`Installing rebar3 ${r3Version} is supposed to fail`)

await assert.rejects(
async () => {
await setupElixir.mixRebar()
},
(err) => {
assert.ok(err instanceof Error); return true
},
`Mixing rebar without Elixir is supposed to fail`)

await assert.rejects(
async () => {
await setupElixir.mixHex()
},
(err) => {
assert.ok(err instanceof Error); return true
},
`Mixing Hex without Elixir is supposed to fail`)

getOTPVersion({
spec: '19.3.x', osVersion: 'ubuntu-16.04',
expected: 'OTP-19.3.6',
Expand Down
16 changes: 14 additions & 2 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4014,13 +4014,23 @@ function maybeInstallElixir(otpVersion, elixirBuildsListing) {

async function mixRebar() {
if (core.getInput('install-rebar') !== false) {
await exec('mix local.rebar --force')
const cmd = 'mix local.rebar --force'
await exec(cmd)
.catch((err) => {
core.error(`${cmd} failed`)
throw new Error(err)
})
}
}

async function mixHex() {
if (core.getInput('install-hex') !== false) {
await exec('mix local.hex --force')
const cmd = 'mix local.hex --force'
await exec(cmd)
.catch((err) => {
core.error(`${cmd} failed`)
throw new Error(err)
})
}
}

Expand Down Expand Up @@ -4170,6 +4180,8 @@ module.exports = {
getOTPVersion: getOTPVersion,
getElixirVersion: getElixirVersion,
getRebar3Version: getRebar3Version,
mixRebar: mixRebar,
mixHex: mixHex,
}


Expand Down
16 changes: 14 additions & 2 deletions src/setup-beam.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,23 @@ function maybeInstallElixir(otpVersion, elixirBuildsListing) {

async function mixRebar() {
if (core.getInput('install-rebar') !== false) {
await exec('mix local.rebar --force')
const cmd = 'mix local.rebar --force'
await exec(cmd)
.catch((err) => {
core.error(`${cmd} failed`)
throw new Error(err)
})
}
}

async function mixHex() {
if (core.getInput('install-hex') !== false) {
await exec('mix local.hex --force')
const cmd = 'mix local.hex --force'
await exec(cmd)
.catch((err) => {
core.error(`${cmd} failed`)
throw new Error(err)
})
}
}

Expand Down Expand Up @@ -222,4 +232,6 @@ module.exports = {
getOTPVersion: getOTPVersion,
getElixirVersion: getElixirVersion,
getRebar3Version: getRebar3Version,
mixRebar: mixRebar,
mixHex: mixHex,
}

0 comments on commit a017948

Please sign in to comment.