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

Staging #25

Merged
merged 3 commits into from
Dec 4, 2024
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
1 change: 1 addition & 0 deletions _conda_environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ channels:
dependencies:
- compilers=1.8.*
- curl=8.10.*
- jq=1.7.*
- make=4.*
- ruby=3.3.*
- shellcheck=0.10.*
Expand Down
18 changes: 18 additions & 0 deletions _posts/2050-12-03-conda-updated.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
layout: post
title: Conda updated?
---

Using a tip from
[Travis Hathaway](https://github.com/conda/conda/issues/14418#issuecomment-2513806325),
here is a shell one-liner to check if a conda environment is up to date:

```shell
conda update --all --dry-run --json | jq -e '.success and (.actions | length) == 0'
```

It exits (`-e`) with `0` if the environment is already updated and `1` if
updates are available.

I use this in CI so that I get an email if my `environment.yml` file is holding
any packages back.
6 changes: 2 additions & 4 deletions _scripts/check_conda_updated.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
# Check that all installed conda packages are up to date
function check_conda_updated () {
TEMP_FILE="$(mktemp)"
conda update --all --dry-run | tee "$TEMP_FILE"
# grep for the message that conda update prints if packages are up to date.
# grep exits with 0 if it is not found (meaning that updates are available).
grep -q "requested packages already installed" "$TEMP_FILE"
mamba update --all --dry-run --json | tee "$TEMP_FILE"
jq -e '.success and (.actions | length) == 0' "$TEMP_FILE"
}
3 changes: 1 addition & 2 deletions configure.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ function configure_conda_environment () {
mamba env create \
--prefix "$CONDA_PREFIX" \
--file "$CONDA_ENV_YML" \
--yes \
--no-default-packages
--yes
fi
}

Expand Down
Loading