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 'conda-remove-defaults' setting and support 'nodefaults' as a keyword channel #367

Merged
merged 23 commits into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from 6 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
54 changes: 54 additions & 0 deletions .github/workflows/example-14.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: "Example 14: Remove implicitly added channels"
jaimergp marked this conversation as resolved.
Show resolved Hide resolved

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

concurrency:
group:
${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true

jobs:
example-14:
# prevent cronjobs from running on forks
if:
(github.event_name == 'schedule' && github.repository ==
'conda-incubator/setup-miniconda') || (github.event_name != 'schedule')
name: Ex14 (${{ matrix.os }}, ${{ matrix.no-implicit-channels }})
jaimergp marked this conversation as resolved.
Show resolved Hide resolved
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
no-implicit-channels: ["true", "false"]
jaimergp marked this conversation as resolved.
Show resolved Hide resolved
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- uses: ./
id: setup-miniconda
continue-on-error: true
with:
channels: conda-forge
python-version: "3.12"
no-implicit-channels: ${{ matrix.no-implicit-channels }}
jaimergp marked this conversation as resolved.
Show resolved Hide resolved
- shell: bash -el {0}
run: |
channels=$(conda config --show channels --json | jq -r '.channels | join(",")')
echo $channels
if [[ "${{ matrix.no-implicit-channels }}" == "true" ]]; then
jaimergp marked this conversation as resolved.
Show resolved Hide resolved
if [[ "$channels" != "conda-forge" ]]; then
exit 1
fi
elif [[ "$channels" != "conda-forge,defaults" ]]; then
exit 1
fi
34 changes: 34 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ possibility of automatically activating the `test` environment on all shells.
| [Caching packages](#caching-packages) | [![Caching Example Status][caching-badge]][caching] |
| [Caching environments](#caching-environments) | [![Caching Env Example Status][caching-env-badge]][caching-env] |
| [Apple Silicon](#example-13-apple-silicon) | [![Apple Silicon][ex13-badge]][ex13] |
| [No implicit channels](#example-14-no-implicit-channels) | [![No implicit channels][ex14-badge]][ex14] |
jaimergp marked this conversation as resolved.
Show resolved Hide resolved

[ex1]:
https://github.com/conda-incubator/setup-miniconda/actions/workflows/example-1.yml
Expand Down Expand Up @@ -112,6 +113,10 @@ possibility of automatically activating the `test` environment on all shells.
https://github.com/conda-incubator/setup-miniconda/actions/workflows/example-13.yml
[ex13-badge]:
https://github.com/conda-incubator/setup-miniconda/actions/workflows/example-13.yml/badge.svg?branch=main
[ex14]:
https://github.com/conda-incubator/setup-miniconda/actions/workflows/example-14.yml
[ex14-badge]:
https://github.com/conda-incubator/setup-miniconda/actions/workflows/example-14.yml/badge.svg?branch=main

## Other Workflows

Expand Down Expand Up @@ -598,6 +603,35 @@ jobs:
python -c "import platform; assert platform.machine() == 'arm64', platform.machine()"
```

### Example 14: No implicit channels
jaimergp marked this conversation as resolved.
Show resolved Hide resolved

Workaround for this bug:
[conda#12356](https://github.com/conda/conda/issues/12356).

```yaml
jobs:
example-13:
name: Ex14 (os=${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: ["ubuntu-latest"]
steps:
- uses: actions/checkout@v4
- uses: ./
id: setup-miniconda
continue-on-error: true
with:
miniforge-version: latest
channels: conda-forge
no-implicit-channels: "true"
jaimergp marked this conversation as resolved.
Show resolved Hide resolved
- name: Check config
shell: bash -el {0}
run: |
conda config --show-sources
```

## Caching

### Caching packages
Expand Down
6 changes: 6 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,12 @@ inputs:
for more information."
required: false
default: ""
no-implicit-channels:
jaimergp marked this conversation as resolved.
Show resolved Hide resolved
description:
"Postprocess channels list to remove channels that were not added
explicitly in the 'channels' setting. Will default to 'true' in 2025.03."
jaimergp marked this conversation as resolved.
Show resolved Hide resolved
required: false
default: ""
show-channel-urls:
description:
'Conda configuration. Show channel URLs when displaying what is going to
Expand Down
10 changes: 10 additions & 0 deletions dist/setup/index.js

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

14 changes: 14 additions & 0 deletions src/conda.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,20 @@ export async function applyCondaConfiguration(
await condaCommand(["config", "--add", "channels", channel], options);
}

if (inputs.noImplicitChannels === "true" && !channels.includes("defaults")) {
jaimergp marked this conversation as resolved.
Show resolved Hide resolved
core.info("Removing implicitly added 'defaults' channel");
try {
await condaCommand(
["config", "--remove", "channels", "defaults"],
options,
);
} catch (err) {
core.info(
"Removing defaults raised an error -- it was probably not present.",
);
}
}

// All other options are just passed as their string representations
for (const [key, value] of configEntries) {
if (value.trim().length === 0 || key === "channels") {
Expand Down
1 change: 1 addition & 0 deletions src/input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ export async function parseInputs(): Promise<types.IActionInputs> {
minicondaVersion: core.getInput("miniconda-version"),
miniforgeVariant: core.getInput("miniforge-variant"),
miniforgeVersion: core.getInput("miniforge-version"),
noImplicitChannels: core.getInput("no-implicit-channels"),
jaimergp marked this conversation as resolved.
Show resolved Hide resolved
pythonVersion: core.getInput("python-version"),
removeProfiles: core.getInput("remove-profiles"),
condaConfig: Object.freeze({
Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ export interface IActionInputs {
readonly minicondaVersion: string;
readonly miniforgeVariant: string;
readonly miniforgeVersion: string;
readonly noImplicitChannels: string;
jaimergp marked this conversation as resolved.
Show resolved Hide resolved
readonly pythonVersion: string;
readonly removeProfiles: string;
readonly useMamba: string;
Expand Down
Loading