Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add warning for older micromamba versions #108

Merged
merged 6 commits into from
Jul 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
micromamba info | grep -q "environment : None (not found)"
shell: bash -el {0}

micromamba-old-version:
micromamba-old-version-1:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand All @@ -53,6 +53,17 @@ jobs:
- run: test "$(micromamba --version)" = 1.4.5
shell: bash -el {0}

micromamba-old-version-2:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ./
with:
micromamba-version: 1.2.0-1 # this will throw a warning
environment-file: 'test/environment.yml'
- run: test "$(micromamba --version)" = 1.2.0
shell: bash -el {0}

micromamba-shell:
strategy:
matrix:
Expand Down
21 changes: 20 additions & 1 deletion dist/index.js

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

21 changes: 20 additions & 1 deletion dist/post.js

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

19 changes: 19 additions & 0 deletions src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,24 @@ const assertOptions = (options: Options) => {
assert(!options.createEnvironment || options.environmentFile !== undefined || options.environmentName !== undefined)
}

export const getRootPrefixFlagForInit = (options: Options) => {
// latest is always > 1.4.5-0
if (options.micromambaSource._tag === 'Left' && options.micromambaSource.left < '1.4.5-0') {
return '-p'
}
return '-r'
}

const checkForKnownIssues = (options: Options) => {
// micromamba 1.4.5 now uses -r for shell init instead of -p
// https://github.com/mamba-org/mamba/pull/2538
if (options.initShell && getRootPrefixFlagForInit(options) === '-p') {
core.warning(
'You are using a micromamba version < 1.4.5-0 and initialize the shell. This is behavior is deprecated. Please update the micromamba version. For further informations, see https://github.com/mamba-org/setup-micromamba/pull/107'
)
}
}

const getOptions = () => {
const inputs: Inputs = {
condarcFile: parseOrUndefined('condarc-file', z.string()),
Expand Down Expand Up @@ -209,6 +227,7 @@ const getOptions = () => {
validateInputs(inputs)
const options = inferOptions(inputs)
core.debug(`Inferred options: ${JSON.stringify(options)}`)
checkForKnownIssues(options)
assertOptions(options)
return options
}
Expand Down
16 changes: 13 additions & 3 deletions src/shell-init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import path from 'path'
import * as coreDefault from '@actions/core'
import { coreMocked } from './mocking'
import { execute, mambaRegexBlock, micromambaCmd } from './util'
import { PATHS, options } from './options'
import { PATHS, getRootPrefixFlagForInit, options } from './options'
import type { ShellType } from './options'

const core = process.env.MOCKING ? coreMocked : coreDefault
Expand Down Expand Up @@ -38,8 +38,13 @@ const removeMambaInitBlockFromBashProfile = () => {

export const shellInit = (shell: string) => {
core.startGroup(`Initialize micromamba for ${shell}.`)
const rootPrefixFlag = getRootPrefixFlagForInit(options)
const command = execute(
micromambaCmd(`shell init -s ${shell} -r ${options.micromambaRootPath}`, options.logLevel, options.condarcFile)
micromambaCmd(
`shell init -s ${shell} ${rootPrefixFlag} ${options.micromambaRootPath}`,
options.logLevel,
options.condarcFile
)
)
if (os.platform() === 'linux' && shell === 'bash') {
return command.then(copyMambaInitBlockToBashProfile).finally(core.endGroup)
Expand All @@ -49,8 +54,13 @@ export const shellInit = (shell: string) => {

export const shellDeinit = (shell: string) => {
core.startGroup(`Deinitialize micromamba for ${shell}`)
const rootPrefixFlag = getRootPrefixFlagForInit(options)
const command = execute(
micromambaCmd(`shell deinit -s ${shell} -r ${options.micromambaRootPath}`, options.logLevel, options.condarcFile)
micromambaCmd(
`shell deinit -s ${shell} ${rootPrefixFlag} ${options.micromambaRootPath}`,
options.logLevel,
options.condarcFile
)
)
if (os.platform() === 'linux' && shell === 'bash') {
return command.then(removeMambaInitBlockFromBashProfile).finally(core.endGroup)
Expand Down
Loading