Skip to content

Commit

Permalink
Support specification of micromamba run shell path
Browse files Browse the repository at this point in the history
And running passing argument other that a shell script.
  • Loading branch information
thewtex committed Dec 6, 2023
1 parent 0f951b3 commit 380f313
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 17 deletions.
11 changes: 6 additions & 5 deletions dist/cli.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 6 additions & 5 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions dist/post.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,16 +128,16 @@ export const generateMicromambaRunShell = () => {
}
core.info('Generating micromamba run shell.')
const micromambaRunShellContents = `#!/usr/bin/env sh
chmod +x $1
$MAMBA_EXE run -r $MAMBA_ROOT_PREFIX -n $MAMBA_DEFAULT_ENV $1
if test -f "$1"; then chmod +x $1; fi
$MAMBA_EXE run -r $MAMBA_ROOT_PREFIX -n $MAMBA_DEFAULT_ENV "$@"
`
return determineEnvironmentName(options.environmentName, options.environmentFile)
.then((environmentName) => {
const file = micromambaRunShellContents
.replace(/\$MAMBA_EXE/g, options.micromambaBinPath)
.replace(/\$MAMBA_ROOT_PREFIX/g, options.micromambaRootPath)
.replace(/\$MAMBA_DEFAULT_ENV/g, environmentName)
core.debug(`Writing micromamba run shell to ${options.micromambaRunShellPath}`)
core.debug(`Writing micromamba run shell to ${options.micromambaRunShellPatu}`)
core.debug(`File contents:\n"${file}"`)
return fs.writeFile(options.micromambaRunShellPath, file, { encoding: 'utf8', mode: 0o755 })
})
Expand Down
8 changes: 6 additions & 2 deletions src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ type Inputs = Readonly<{
postCleanup?: PostCleanupType
micromambaRootPath?: string
micromambaBinPath?: string
micromambaRunShellPath?: string
}>

export type Options = Readonly<{
Expand Down Expand Up @@ -154,7 +155,9 @@ const inferOptions = (inputs: Inputs): Options => {
? path.resolve(untildify(inputs.condarcFile))
: path.join(path.dirname(PATHS.micromambaBin), '.condarc'), // next to the micromamba binary -> easier cleanup
micromambaBinPath,
micromambaRunShellPath: path.join(path.dirname(micromambaBinPath), 'micromamba-shell'),
micromambaRunShellPath: inputs.micromambaRunShellPath
? path.resolve(untildify(inputs.micromambaRunShellPath))
: path.join(path.dirname(micromambaBinPath), 'micromamba-shell'),
micromambaRootPath: inputs.micromambaRootPath
? path.resolve(untildify(inputs.micromambaRootPath))
: PATHS.micromambaRoot
Expand Down Expand Up @@ -252,7 +255,8 @@ const getOptions = () => {
cacheEnvironmentKey: parseOrUndefined('cache-environment-key', z.string()),
postCleanup: parseOrUndefined('post-cleanup', postCleanupSchema),
micromambaRootPath: parseOrUndefined('micromamba-root-path', z.string()),
micromambaBinPath: parseOrUndefined('micromamba-binary-path', z.string())
micromambaBinPath: parseOrUndefined('micromamba-binary-path', z.string()),
micromambaRunShellPath: parseOrUndefined('micromamba-run-shell-path', z.string())
}
setLogLevel(inputs.logLevel)
core.debug(`Inputs: ${JSON.stringify(inputs)}`)
Expand Down

0 comments on commit 380f313

Please sign in to comment.