Skip to content

Commit 94c64d2

Browse files
authored
e2e: fix new folder flow conda test (#8789)
### Summary This PR resolves a flake in the new folder flow test related to Conda environment creation. The test would occasionally fail because the `create-conda.py` script fell back to the defaults channel, despite CI being configured to use `conda-forge` via Miniforge. We could use either Miniforge or Miniconda, but for now we prefer Miniforge due to recent changes to Miniconda that require Terms of Service acceptance when using the defaults channel and this also aligns with the container work done by @testlabauto. ### QA Notes @:new-folder-flow @:web
1 parent d56dbf3 commit 94c64d2

File tree

7 files changed

+39
-39
lines changed

7 files changed

+39
-39
lines changed

.github/actions/install-python/action.yml

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -91,31 +91,17 @@ runs:
9191
echo "Setting up Conda environment with Python 3.12..."
9292
9393
# Ensure Conda is available
94-
source "${CONDA}/etc/profile.d/conda.sh"
94+
source "$CONDA/etc/profile.d/conda.sh"
9595
9696
# Define environment path
9797
CONDA_ENV_DIR="$HOME/scratch/python-env"
9898
99-
# Create a new Conda environment with Python 3.12
100-
conda create -y -p "$CONDA_ENV_DIR" python=3.12.10 pip setuptools
99+
# NOTE: When using Minforge conda-forge is the default and override is no longer strictly necessary,
100+
# but we keep it to prevent any unintentional fallback if configs change.
101+
conda create -y --override-channels -c conda-forge -p "$CONDA_ENV_DIR" python=3.12.10 pip setuptools
101102
102-
# Verify Python installation
103-
PYTHON_BIN="$CONDA_ENV_DIR/bin/python"
103+
echo "Verifying Python in Conda environment..."
104+
"$CONDA_ENV_DIR/bin/python" --version
105+
"$CONDA_ENV_DIR/bin/python" -c "import sys; print(f'Python {sys.version} is working!')"
104106
105-
if [[ -x "$PYTHON_BIN" ]]; then
106-
echo "Python successfully installed in Conda environment at $PYTHON_BIN"
107-
$PYTHON_BIN --version
108-
else
109-
echo "Error: Python binary not found in Conda environment!"
110-
exit 1
111-
fi
112-
113-
# Verify Python modules are working
114-
echo "Checking if Python modules work..."
115-
$PYTHON_BIN -c "import venv, sys; print(f'Python {sys.version} modules are working!')"
116-
117-
# Final verification
118-
echo "Final Python check..."
119-
$PYTHON_BIN -c "import sys; print(f'Python {sys.version} is working!')"
120-
121-
echo "Miniconda-based Python 3.12 setup complete!"
107+
echo "Miniforge-based Python 3.12 setup complete!"

.github/actions/setup-test-env/action.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,15 @@ runs:
3636
with:
3737
tinytex: true
3838

39+
# Miniforge avoids Anaconda ToS and defaults to conda-forge
3940
- name: Setup Conda (Miniforge3)
4041
uses: conda-incubator/setup-miniconda@v3
4142
with:
42-
miniforge-variant: Miniforge3
4343
miniforge-version: latest
4444
auto-activate-base: false
45+
channels: conda-forge,defaults # Defaults included only to suppress warnings; all packages are still resolved from conda-forge
46+
conda-remove-defaults: "true"
47+
channel-priority: strict
4548

4649
- name: Setup Python
4750
uses: ./.github/actions/install-python

extensions/positron-python/python_files/create_conda.py

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -104,19 +104,30 @@ def main(argv: Optional[Sequence[str]] = None) -> None:
104104
env_path = get_conda_env_path(args.name)
105105
print(f"EXISTING_CONDA_ENV:{env_path}")
106106
else:
107+
# --- Start Positron ---
108+
# Special case for Playwright CI: force conda-forge to avoid ToS prompt from defaults
109+
is_playwright_test = os.environ.get("PW_TEST") == "1"
110+
111+
cmd = [
112+
sys.executable,
113+
"-m",
114+
"conda",
115+
"create",
116+
"--yes",
117+
"--prefix",
118+
args.name,
119+
f"python={args.python}",
120+
]
121+
122+
if is_playwright_test:
123+
print("PW_TEST env var detected: Configuring conda to use conda-forge channel only")
124+
cmd.extend(["--override-channels", "-c", "conda-forge"])
125+
107126
run_process(
108-
[
109-
sys.executable,
110-
"-m",
111-
"conda",
112-
"create",
113-
"--yes",
114-
"--prefix",
115-
args.name,
116-
f"python={args.python}",
117-
],
127+
cmd,
118128
"CREATE_CONDA.ENV_FAILED_CREATION",
119129
)
130+
# --- End Positron ---
120131
env_path = get_conda_env_path(args.name)
121132
print(f"CREATED_CONDA_ENV:{env_path}")
122133
if args.git_ignore:

extensions/positron-python/src/client/pythonEnvironments/creation/provider/condaCreationProvider.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,9 @@ async function createCondaEnv(
9898
cwd: workspace.uri.fsPath,
9999
env: {
100100
PATH: pathEnv,
101+
// --- Start Positron ---
102+
PW_TEST: process.env.PW_TEST,
103+
// --- End Positron ---
101104
},
102105
});
103106

test/e2e/pages/hotKeys.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ export class HotKeys {
156156

157157
public async closeWorkspace() {
158158
await this.pressHotKeys('Cmd+J W');
159-
await expect(this.code.driver.page.locator('.explorer-folders-view')).toBeVisible();
159+
await expect(this.code.driver.page.locator('.explorer-folders-view')).not.toBeVisible();
160160
}
161161

162162
public async importSettings() {

test/e2e/tests/new-folder-flow/new-folder-flow-python.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ test.describe('New Folder Flow: Python Project', { tag: [tags.MODAL, tags.NEW_FO
5959
await verifyPyprojectTomlCreated(app);
6060
});
6161

62-
test.skip('New env: Conda environment', async function ({ app }) {
62+
test('New env: Conda environment', async function ({ app }) {
6363
const folderName = addRandomNumSuffix('conda-installed');
6464
await createNewFolder(app, {
6565
folderTemplate,

test/e2e/tests/welcome/welcome.test.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,8 @@ test.describe('Welcome Page', { tag: [tags.WELCOME, tags.WEB] }, () => {
9494
});
9595

9696
test.describe('No Workspace', () => {
97-
test.beforeAll(async function ({ hotKeys }) {
98-
await hotKeys.closeWorkspace();
99-
});
100-
10197
test.beforeEach(async function ({ hotKeys, sessions }) {
98+
await hotKeys.closeWorkspace();
10299
await sessions.expectSessionPickerToBe('Start Session');
103100
await sessions.expectNoStartUpMessaging();
104101
await hotKeys.openWelcomeWalkthrough();

0 commit comments

Comments
 (0)