Skip to content

Split shell init and activation of test environment to remove spurious warning - #475

Merged
goanpeca merged 1 commit into
conda-incubator:mainfrom
goanpeca:fix/incorrect-warning
Apr 2, 2026
Merged

goanpeca merged 1 commit into
conda-incubator:mainfrom
goanpeca:fix/incorrect-warning

Conversation

@goanpeca

Copy link
Copy Markdown
Member

Fixes #474

@goanpeca
goanpeca requested a review from a team as a code owner March 24, 2026 00:03
Copilot AI review requested due to automatic review settings March 24, 2026 00:03
@goanpeca goanpeca self-assigned this Mar 24, 2026
@goanpeca
goanpeca force-pushed the fix/incorrect-warning branch from 3fe43a0 to a4c4ae2 Compare March 24, 2026 00:08

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses issue #474 by changing when conda activation commands are appended to shell profile/hook files, aiming to avoid Windows warnings caused by attempting to activate an environment before it exists.

Changes:

  • Split conda initialization into (1) shell integration/init and (2) profile/hook activation appends, and call the activation step after environment creation.
  • Add condaInitActivation() and update setup flow to invoke it later.
  • Minor repo hygiene updates (RELEASE formatting, ignore coverage/ in ESLint).

Reviewed changes

Copilot reviewed 4 out of 6 changed files in this pull request and generated 2 comments.

File Description
src/setup.ts Moves activation-profile writing to after ensureEnvironment() via new condaInitActivation() call.
src/conda.ts Splits activation append logic out of condaInit() into new condaInitActivation() function.
RELEASE.md Removes an extraneous whitespace-only line in release instructions.
.eslintignore Adds coverage/ to ignored paths.
Comments suppressed due to low confidence (2)

src/conda.ts:458

  • New behavior is introduced by condaInitActivation (and the setup flow change that calls it after env creation), but there are existing Vitest unit tests for src/conda.ts (e.g., applyCondaConfiguration in src/__tests__/conda.test.ts). Please add tests covering the activation-profile writing logic, especially the activate-environment: "" case (should not write conda activate "") and the Windows hook-file behavior that motivated #474, to prevent regressions.
/**
 * Append activation commands to all shell profile files so that
 * subsequent workflow steps start with the correct environment active.
 *
 * This must be called AFTER the target environment has been created,
 * otherwise `.bat` wrappers (which source `conda_hook.bat`) would try
 * to activate a non-existent environment during setup and emit false
 * warnings (see #474).
 *
 * @param inputs - The parsed action inputs.
 * @param options - The current dynamic options.
 */
export async function condaInitActivation(
  inputs: types.IActionInputs,
  options: types.IDynamicOptions,
): Promise<void> {
  const isValidActivate = !(await isDefaultEnvironment(
    inputs.activateEnvironment,
    inputs,
    options,
  ));
  const autoActivateDefault: boolean =
    options.condaConfig.auto_activate === "true";
  const installationDirectory = condaBasePath(inputs, options);

  // PowerShell profiles
  // NOTE: Using array.join() to prevent auto-formatters from adding indentation
  const powerLines: string[] = [
    "",

src/conda.ts:465

  • isValidActivate becomes true when inputs.activateEnvironment is an empty string because isDefaultEnvironment("") returns false; this leads to appending commands like conda activate "" / @CALL "%CONDA_BAT%" activate "" into profile/hook files. Since activate-environment: "" is a supported way to request no activation, add an explicit non-empty check (or early-return) so empty input never produces activation commands.
  const isValidActivate = !(await isDefaultEnvironment(
    inputs.activateEnvironment,
    inputs,
    options,
  ));
  const autoActivateDefault: boolean =
    options.condaConfig.auto_activate === "true";
  const installationDirectory = condaBasePath(inputs, options);

  // PowerShell profiles
  // NOTE: Using array.join() to prevent auto-formatters from adding indentation
  const powerLines: string[] = [
    "",
    "# ----------------------------------------------------------------------------",
  ];
  if (isValidActivate) {
    powerLines.push(
      "# Conda Setup Action: Custom activation",
      `conda activate "${inputs.activateEnvironment}"`,
    );

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/setup.ts Resolved
Comment thread src/setup.ts Resolved
@goanpeca
goanpeca force-pushed the fix/incorrect-warning branch 2 times, most recently from 7c5eabb to ee7e96a Compare March 24, 2026 00:34
@goanpeca
goanpeca requested review from dbast, jaimergp and jezdez March 24, 2026 17:18
@goanpeca
goanpeca force-pushed the fix/incorrect-warning branch from ee7e96a to 56c41de Compare April 2, 2026 02:33
@goanpeca
goanpeca force-pushed the fix/incorrect-warning branch from 56c41de to 9c73b9a Compare April 2, 2026 02:49
@goanpeca
goanpeca merged commit 9b650ee into conda-incubator:main Apr 2, 2026
108 checks passed
@goanpeca
goanpeca deleted the fix/incorrect-warning branch April 2, 2026 03:04
jezdez added a commit to conda/conda that referenced this pull request Apr 16, 2026
Follow-up to #15741. The original experimental branch in
conda-incubator/setup-miniconda#453 has been closed and split into
several non-breaking PRs that have now been merged to
conda-incubator/setup-miniconda@main. This pins the action to the
current main tip (a89f5d4) to measure the combined CI impact, including:

- conda-incubator/setup-miniconda#465 fix double channel config apply
- conda-incubator/setup-miniconda#467 bulk-move extracted pkgs on cleanup
- conda-incubator/setup-miniconda#475 split shell init and activation
- conda-incubator/setup-miniconda#482 channel parsing / URL validation
- conda-incubator/setup-miniconda#486 remove HTML index scraping
- conda-incubator/setup-miniconda#487 parallelize Windows takeown calls
@jezdez jezdez mentioned this pull request Apr 16, 2026
3 tasks done
kenodegard pushed a commit to conda/conda that referenced this pull request Apr 23, 2026
conda-incubator/setup-miniconda@v4.0.0 ships a number of performance
improvements:

- conda-incubator/setup-miniconda#465 fix double channel config apply
- conda-incubator/setup-miniconda#467 bulk-move extracted pkgs on cleanup
- conda-incubator/setup-miniconda#475 split shell init and activation
- conda-incubator/setup-miniconda#482 channel parsing / URL validation
- conda-incubator/setup-miniconda#486 remove HTML index scraping
- conda-incubator/setup-miniconda#487 parallelize Windows takeown calls
- conda-incubator/setup-miniconda#488 replace isDefaultEnvironment subprocess with local YAML reads
- conda-incubator/setup-miniconda#489 replace conda config subprocesses with direct .condarc YAML
  writes

v4.0.0 also upgrades the action runtime to Node.js 24.x and switches
the build to ESM, which is the breaking change motivating the major
bump.
@goanpeca goanpeca added the type:bug Something isn't working label May 31, 2026
@goanpeca goanpeca added this to the v4.0.0 milestone May 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type:bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

False positive warnings for "test" environment

3 participants