Skip to content

Commit

Permalink
Hack around rebar3 compiling for version
Browse files Browse the repository at this point in the history
What are we fixing?

If you're with'ing "version-file": ".tool-versions" after you
_use_ "actions/checkout", it's likely `rebar3` from `setup-beam`
is compiling your project just to output its
version

This commit prevents that as per
erlang/rebar3#2865 (comment)
  • Loading branch information
paulo-ferraz-oliveira committed Feb 22, 2024
1 parent a23b1fc commit f2415ce
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 18 deletions.
28 changes: 19 additions & 9 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10562,8 +10562,9 @@ async function install(toolName, opts) {
reportVersion: () => {
const cmd = 'erl'
const args = ['-version']
const env = {}

return [cmd, args]
return [cmd, args, env]
},
},
win32: {
Expand All @@ -10579,8 +10580,9 @@ async function install(toolName, opts) {
reportVersion: () => {
const cmd = 'erl.exe'
const args = ['+V']
const env = {}

return [cmd, args]
return [cmd, args, env]
},
},
}
Expand Down Expand Up @@ -10608,8 +10610,9 @@ async function install(toolName, opts) {
reportVersion: () => {
const cmd = 'elixir'
const args = ['-v']
const env = {}

return [cmd, args]
return [cmd, args, env]
},
},
}
Expand Down Expand Up @@ -10648,8 +10651,9 @@ async function install(toolName, opts) {
reportVersion: () => {
const cmd = 'gleam'
const args = ['--version']
const env = {}

return [cmd, args]
return [cmd, args, env]
},
},
win32: {
Expand Down Expand Up @@ -10681,8 +10685,9 @@ async function install(toolName, opts) {
reportVersion: () => {
const cmd = 'gleam.exe'
const args = ['--version']
const env = {}

return [cmd, args]
return [cmd, args, env]
},
},
}
Expand Down Expand Up @@ -10713,8 +10718,12 @@ async function install(toolName, opts) {
reportVersion: () => {
const cmd = 'rebar3'
const args = ['version']
const env = {
REBAR_GLOBAL_CONFIG_DIR: '/fake-dir',
REBAR_CONFIG: 'fake.config',
}

return [cmd, args]
return [cmd, args, env]
},
},
win32: {
Expand Down Expand Up @@ -10749,8 +10758,9 @@ async function install(toolName, opts) {
reportVersion: () => {
const cmd = 'rebar3.cmd'
const args = ['version']
const env = {}

return [cmd, args]
return [cmd, args, env]
},
},
}
Expand Down Expand Up @@ -10804,8 +10814,8 @@ async function installTool(opts) {
core.exportVariable(installDirForVarName, runnerToolPath)

core.info(`Installed ${installOpts.tool} version`)
const [cmd, args] = platformOpts.reportVersion()
await exec(cmd, args)
const [cmd, args, env] = platformOpts.reportVersion()
await exec(cmd, args, { env: { ...process.env, ...env } })
}

function checkPlatform() {
Expand Down
28 changes: 19 additions & 9 deletions src/setup-beam.js
Original file line number Diff line number Diff line change
Expand Up @@ -731,8 +731,9 @@ async function install(toolName, opts) {
reportVersion: () => {
const cmd = 'erl'
const args = ['-version']
const env = {}

return [cmd, args]
return [cmd, args, env]
},
},
win32: {
Expand All @@ -748,8 +749,9 @@ async function install(toolName, opts) {
reportVersion: () => {
const cmd = 'erl.exe'
const args = ['+V']
const env = {}

return [cmd, args]
return [cmd, args, env]
},
},
}
Expand Down Expand Up @@ -777,8 +779,9 @@ async function install(toolName, opts) {
reportVersion: () => {
const cmd = 'elixir'
const args = ['-v']
const env = {}

return [cmd, args]
return [cmd, args, env]
},
},
}
Expand Down Expand Up @@ -817,8 +820,9 @@ async function install(toolName, opts) {
reportVersion: () => {
const cmd = 'gleam'
const args = ['--version']
const env = {}

return [cmd, args]
return [cmd, args, env]
},
},
win32: {
Expand Down Expand Up @@ -850,8 +854,9 @@ async function install(toolName, opts) {
reportVersion: () => {
const cmd = 'gleam.exe'
const args = ['--version']
const env = {}

return [cmd, args]
return [cmd, args, env]
},
},
}
Expand Down Expand Up @@ -882,8 +887,12 @@ async function install(toolName, opts) {
reportVersion: () => {
const cmd = 'rebar3'
const args = ['version']
const env = {
REBAR_GLOBAL_CONFIG_DIR: '/fake-dir',
REBAR_CONFIG: 'fake.config',
}

return [cmd, args]
return [cmd, args, env]
},
},
win32: {
Expand Down Expand Up @@ -918,8 +927,9 @@ async function install(toolName, opts) {
reportVersion: () => {
const cmd = 'rebar3.cmd'
const args = ['version']
const env = {}

return [cmd, args]
return [cmd, args, env]
},
},
}
Expand Down Expand Up @@ -973,8 +983,8 @@ async function installTool(opts) {
core.exportVariable(installDirForVarName, runnerToolPath)

core.info(`Installed ${installOpts.tool} version`)
const [cmd, args] = platformOpts.reportVersion()
await exec(cmd, args)
const [cmd, args, env] = platformOpts.reportVersion()
await exec(cmd, args, { env: { ...process.env, ...env } })
}

function checkPlatform() {
Expand Down

0 comments on commit f2415ce

Please sign in to comment.