Skip to content
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
157 changes: 157 additions & 0 deletions .github/workflows/example-16.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
name: "Example 16: Default environment activation"

on:
pull_request:
push:
branches:
- main
schedule:
# Note that cronjobs run on master/main by default
- cron: "0 0 * * *"

jobs:
example-16-build:
# prevent cronjobs from running on forks
if:
(github.event_name == 'schedule' && github.repository ==
'conda-incubator/setup-miniconda') || (github.event_name != 'schedule')
name:
Build Ex16 (os=${{matrix.os}}, default env=${{ matrix.add-activation-env
== 'true' && 'default' || 'base' }})
runs-on: ${{ matrix.os }}-latest
strategy:
fail-fast: false
matrix:
add-activation-env: ["false", "true"]
os: ["ubuntu", "windows"]
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
persist-credentials: false

- name: Set up Miniconda for installer builds
uses: ./
with:
activate-environment: ""
auto-activate: false

- name: Create installer
uses: conda-incubator/installer@2d2df0b03c6795f70e128c56403c7d084cca4fb8 # v0.1.0
id: create-installer
with:
conda-root: ${{ env.CONDA }}
environment-yaml-string: |
channels:
- conda-forge
dependencies:
- constructor
variables:
ADD_ACTIVATION_ENV: '${{ matrix.add-activation-env }}'
EXT: ${{ matrix.os == 'windows' && 'exe' || 'sh' }}
input-directory: etc/example-installers/default-environment/

- name: Upload installer to Github artifact
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
path: ${{ steps.create-installer.outputs.artifacts-directory }}/*
name:
ex16-${{ matrix.os }}-${{ matrix.add-activation-env == 'false' &&
'no-' }}-activation-env

example-16-test:
needs: [example-16-build]
name:
Test Ex16 (os=${{matrix.os}}, default env=${{ matrix.add-activation-env ==
'true' && 'default' || 'base' }}, auto-activate-base=${{
matrix.auto-activate-base }})
runs-on: ${{ matrix.os }}-latest
strategy:
fail-fast: false
matrix:
auto-activate-base: ["false", "true"]
add-activation-env: ["false", "true"]
os: ["ubuntu", "windows"]
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
persist-credentials: false

- name: Obtain artifact
uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
with:
name:
ex16-${{ matrix.os }}-${{ matrix.add-activation-env == 'false' &&
'no-' }}-activation-env
path: ${{ runner.temp }}/_installer

- name: Determine installer file name
id: installer-file
env:
ARTIFACTS_DIRECTORY: ${{ runner.temp }}/_installer
EXT: ${{ matrix.os == 'windows' && 'exe' || 'sh' }}
run: |
INSTALLER_FILE=$(find "${ARTIFACTS_DIRECTORY}" -name "*.${EXT}" | head -n 1)
echo "installer-file=${INSTALLER_FILE}" >> ${GITHUB_OUTPUT}
shell: bash

- name: Run installation
uses: ./
with:
activate-environment: ""
auto-activate-base:
${{ matrix.auto-activate-base == 'true' && 'true' ||
'legacy-placeholder' }}
auto-activate:
${{ matrix.auto-activate-base == 'true' && '' || 'true' }}
installation-dir: ${{ runner.temp }}/installer_test
installer-url:
file://${{ steps.installer-file.outputs.installer-file }}

- name: Output conda info (bash)
env:
DEFAULT_ENV: ${{ matrix.add-activation-env && 'default' || 'base' }}
TEST_DIR: ${{ runner.temp }}/installer_output
run: |
mkdir -p ${TEST_DIR}
conda info --json > "${TEST_DIR}/bash.json"
shell: bash -el {0}

- name: Output conda info (cmd.exe)
if: matrix.os == 'windows'
env:
TEST_DIR: ${{ runner.temp }}\installer_output
run: |
conda info --json > "%TEST_DIR%\cmd.exe.json"
shell: cmd /C CALL {0}

- name: Output conda info (PowerShell)
if: matrix.os == 'windows'
env:
TEST_DIR: ${{ runner.temp }}\installer_output
run: conda info --json > "${env:TEST_DIR}\pwsh.json"
shell: pwsh

- name: Test default environments
env:
DEFAULT_ENV:
${{ matrix.add-activation-env == 'true' && matrix.auto-activate-base
== 'false' && 'default' || 'base' }}
TEST_DIR: ${{ runner.temp }}/installer_output
run: |
import json
import os
from pathlib import Path

json_dir = Path(os.environ["TEST_DIR"])
default_env_expected = os.environ["DEFAULT_ENV"]
incorrect_environments = {}
for file in json_dir.iterdir():
conda_info = json.loads(file.read_text())
default_env = conda_info.get("active_prefix_name")
if default_env != default_env_expected:
incorrect_environments[str(file.name).removesuffix(".json")] = default_env
if incorrect_environments:
raise AssertionError(
f"Found incorrect default environments: {incorrect_environments}"
)
shell: python
4 changes: 2 additions & 2 deletions .github/workflows/example-3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
environment-file: etc/example-environment.yml
python-version: 3.8
condarc-file: etc/example-condarc.yml
auto-activate-base: false
auto-activate: false
auto-update-conda: true
- run: |
conda info
Expand All @@ -60,7 +60,7 @@ jobs:
environment-file: etc/example-environment-no-name.yml
python-version: 3.8
condarc-file: etc/example-condarc.yml
auto-activate-base: false
auto-activate: false
auto-update-conda: true
- run: |
conda info
Expand Down
15 changes: 10 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ possibility of automatically activating the `test` environment on all shells.
| [Apple Silicon](#example-13-apple-silicon) | [![Apple Silicon][ex13-badge]][ex13] |
| [Remove defaults](#example-14-remove-defaults-channel) | [![Remove defaults][ex14-badge]][ex14] |
| [Linux ARM](#example-15-linux-arm) | [![Linux ARM][ex15-badge]][ex15] |
| Default environments | [![Default environments][ex16-badge]][ex16] |

[ex1]:
https://github.com/conda-incubator/setup-miniconda/actions/workflows/example-1.yml
Expand Down Expand Up @@ -122,6 +123,10 @@ possibility of automatically activating the `test` environment on all shells.
https://github.com/conda-incubator/setup-miniconda/actions/workflows/example-15.yml
[ex15-badge]:
https://github.com/conda-incubator/setup-miniconda/actions/workflows/example-15.yml/badge.svg?branch=main
[ex16]:
https://github.com/conda-incubator/setup-miniconda/actions/workflows/example-16.yml
[ex16-badge]:
https://github.com/conda-incubator/setup-miniconda/actions/workflows/example-16.yml/badge.svg?branch=main

## Other Workflows

Expand Down Expand Up @@ -180,16 +185,16 @@ Miniconda installation.

### Activate `base` environment

If your specific workflow still needs to activate and use `base` you will need
to do **both** of:
If your specific workflow still needs to activate and use the default
environment, you will need to do **both**:

- set `activate-environment` to an empty string
- set `auto-activate-base` to `true`
- set `auto-activate` to `true`

```yaml
- uses: conda-incubator/setup-miniconda@v3
with:
auto-activate-base: true
auto-activate: true
activate-environment: ""
```

Expand Down Expand Up @@ -330,7 +335,7 @@ jobs:
environment-file: etc/example-environment.yml
python-version: 3.5
condarc-file: etc/example-condarc.yml
auto-activate-base: false
auto-activate: false
- run: |
conda info
conda list
Expand Down
21 changes: 16 additions & 5 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -134,16 +134,27 @@ inputs:
for more information.'
required: false
default: ""
auto-activate-base:
auto-activate:
description:
'Conda configuration. If you’d prefer that conda’s base environment not be
activated on startup, set the to "false". Default is "true". This setting
always overrides if set to "true" or "false". If you want to use the
"condarc-file" setting pass and empty string. See
'Conda configuration. If you’d prefer that conda’s default environment not
be activated on startup, set the to "false". Default is "true". This
setting always overrides if set to "true" or "false". If you want to use
the "condarc-file" setting pass an empty string. See
https://docs.conda.io/projects/conda/en/latest/user-guide/configuration/
for more information.'
required: false
default: "true"
auto-activate-base:
description:
(deprecated in favor of `auto-activate`) 'Conda configuration. If you’d
prefer that conda’s base environment not be activated on startup, set the
to "false". Default is "true". This setting always overrides if set to
"true" or "false". If you want to use the "condarc-file" setting pass an
empty string. See
https://docs.conda.io/projects/conda/en/latest/user-guide/configuration/
for more information.'
required: false
default: "legacy-placeholder"
auto-update-conda:
description:
'Conda configuration. When "true", conda updates itself any time a user
Expand Down
17 changes: 14 additions & 3 deletions dist/delete/index.js

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

Loading
Loading