Skip to content

Commit

Permalink
Add download-micromamba
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelzw committed Dec 5, 2023
1 parent 98d6b2d commit 6801cd6
Show file tree
Hide file tree
Showing 11 changed files with 683 additions and 37 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,42 @@ jobs:
which micromamba-shell | grep /home/runner/micromamba-bin/micromamba-shell
shell: bash -el {0}
use-micromamba-from-path:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download micromamba
run: |
curl -Ls https://github.com/mamba-org/micromamba-releases/releases/latest/download/micromamba-linux-64 -o /usr/local/bin/micromamba
chmod +x /usr/local/bin/micromamba
which micromamba
- uses: ./
with:
environment-file: test/environment.yml
download-micromamba: false
- run: |
micromamba info | grep -q "environment : env-name"
shell: bash -elo pipefail {0}
no-download-with-custom-path:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download micromamba
run: |
mkdir -p "$HOME/not-on-path/bin"
curl -Ls https://github.com/mamba-org/micromamba-releases/releases/latest/download/micromamba-linux-64 -o "$HOME/not-on-path/bin/micromamba"
chmod +x "$HOME/not-on-path/bin/micromamba"
- uses: ./
with:
environment-file: test/environment.yml
download-micromamba: false
micromamba-binary-path: ~/not-on-path/bin/micromamba
- run: |
micromamba info | grep -q "environment : env-name"
which micromamba | grep not-on-path/bin
shell: bash -elo pipefail {0}
# not properly testable
# https://github.com/actions/runner/issues/2347
# https://github.com/orgs/community/discussions/15452
Expand Down
34 changes: 31 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -257,13 +257,17 @@ This can be specified by setting the `log-level` input.

If nothing is specified, `setup-micromamba` will default to `warning` or `debug` depending on if [debug logging is enabled for the action](#debug-logging-of-the-action).

### Post action cleanup
### Self-hosted runners

On self hosted runners, it may happen that some files are persisted between jobs.
On self-hosted runners, it may happen that some files are persisted between jobs.
This can lead to problems when the next job is run.
To avoid this, you can use the `post-cleanup` input to specify the post cleanup behavior of the action (i.e., what happens _after_ all your commands have been executed).

#### Post-action cleanup

To avoid persistence between jobs, you can use the `post-cleanup` input to specify the post cleanup behavior of the action (i.e., what happens _after_ all your commands have been executed).

There is a total of 4 options:

- `none`: No cleanup is performed.
- `shell-init`: The shell initialization files are removed by executing `micromamba shell deinit -s <shell>`.
- `environment`: Shell initialization files and the installed environment are removed.
Expand All @@ -278,6 +282,30 @@ If nothing is specified, `setup-micromamba` will default to `shell-init`.
post-cleanup: environment
```

#### Specify the path of the micromamba binary

You also might want to alter the default micromamba installation location to a temporary location. You can use `micromamba-binary-path: ${{ runner.temp }}/bin/micromamba` to do this.

```yml
- uses: mamba-org/setup-micromamba@v1
with:
environment-file: environment.yml
# ${{ runner.temp }}\Scripts\micromamba.exe on Windows
micromamba-binary-path: ${{ runner.temp }}/bin/micromamba
```

You can also use a pre-installed micromamba binary by setting `micromamba-binary-path` to the path of the binary and specifying `download-micromamba: false`.

```yml
- uses: mamba-org/setup-micromamba@v1
with:
environment-file: environment.yml
download-micromamba: false
# you don't need to specify this if micromamba is already on PATH
micromamba-binary-path: /usr/local/bin/micromamba
generate-run-shell: false # this would generate a file next to the micromamba binary
```

## More examples

If you want to see more examples, you can take a look at the [GitHub Workflows of this repository](.github/workflows/).
Expand Down
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ inputs:
micromamba-url:
description: |
URL to download micromamba from.
download-micromamba:
description: |
If you already have micromamba installed, you can set this to `false`.
init-shell:
description: |
Which shells to initialize micromamba in.
Expand Down
Loading

0 comments on commit 6801cd6

Please sign in to comment.