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 7477587
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 18 deletions.
25 changes: 16 additions & 9 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10563,7 +10563,7 @@ async function install(toolName, opts) {
const cmd = 'erl'
const args = ['-version']

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

return [cmd, args]
return [cmd, args, {}]
},
},
}
Expand Down Expand Up @@ -10609,7 +10609,7 @@ async function install(toolName, opts) {
const cmd = 'elixir'
const args = ['-v']

return [cmd, args]
return [cmd, args, {}]
},
},
}
Expand Down Expand Up @@ -10649,7 +10649,7 @@ async function install(toolName, opts) {
const cmd = 'gleam'
const args = ['--version']

return [cmd, args]
return [cmd, args, {}]
},
},
win32: {
Expand Down Expand Up @@ -10682,7 +10682,7 @@ async function install(toolName, opts) {
const cmd = 'gleam.exe'
const args = ['--version']

return [cmd, args]
return [cmd, args, {}]
},
},
}
Expand Down Expand Up @@ -10714,7 +10714,14 @@ async function install(toolName, opts) {
const cmd = 'rebar3'
const args = ['version']

return [cmd, args]
return [
cmd,
args,
{
REBAR_GLOBAL_CONFIG_DIR: '/fake-dir',
REBAR_CONFIG: 'fake.config',
},
]
},
},
win32: {
Expand Down Expand Up @@ -10750,7 +10757,7 @@ async function install(toolName, opts) {
const cmd = 'rebar3.cmd'
const args = ['version']

return [cmd, args]
return [cmd, args, {}]
},
},
}
Expand Down Expand Up @@ -10804,8 +10811,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: env })
}

function checkPlatform() {
Expand Down
25 changes: 16 additions & 9 deletions src/setup-beam.js
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,7 @@ async function install(toolName, opts) {
const cmd = 'erl'
const args = ['-version']

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

return [cmd, args]
return [cmd, args, {}]
},
},
}
Expand Down Expand Up @@ -778,7 +778,7 @@ async function install(toolName, opts) {
const cmd = 'elixir'
const args = ['-v']

return [cmd, args]
return [cmd, args, {}]
},
},
}
Expand Down Expand Up @@ -818,7 +818,7 @@ async function install(toolName, opts) {
const cmd = 'gleam'
const args = ['--version']

return [cmd, args]
return [cmd, args, {}]
},
},
win32: {
Expand Down Expand Up @@ -851,7 +851,7 @@ async function install(toolName, opts) {
const cmd = 'gleam.exe'
const args = ['--version']

return [cmd, args]
return [cmd, args, {}]
},
},
}
Expand Down Expand Up @@ -883,7 +883,14 @@ async function install(toolName, opts) {
const cmd = 'rebar3'
const args = ['version']

return [cmd, args]
return [
cmd,
args,
{
REBAR_GLOBAL_CONFIG_DIR: '/fake-dir',
REBAR_CONFIG: 'fake.config',
},
]
},
},
win32: {
Expand Down Expand Up @@ -919,7 +926,7 @@ async function install(toolName, opts) {
const cmd = 'rebar3.cmd'
const args = ['version']

return [cmd, args]
return [cmd, args, {}]
},
},
}
Expand Down Expand Up @@ -973,8 +980,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: env })
}

function checkPlatform() {
Expand Down

0 comments on commit 7477587

Please sign in to comment.