Skip to content

Commit

Permalink
Add micromamba deinit in post.js (#89)
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelzw committed Aug 30, 2022
1 parent a319a81 commit b54d7bb
Show file tree
Hide file tree
Showing 11 changed files with 1,835 additions and 224 deletions.
108 changes: 108 additions & 0 deletions .github/workflows/test_deinit.yml
@@ -0,0 +1,108 @@
name: Test deinit

on:
push:
branches:
- main
pull_request: null

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
test_deinit:
name: Test deinit - ${{ matrix.os }} ${{ matrix.rcfile }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
# .bash_profile gets initialized in p-w-m ubuntu-latest instead of .bashrc like in micromamba
- { os: ubuntu-latest, rcfile: ~/.bash_profile }
- { os: ubuntu-latest, rcfile: ~/.zshrc }
# TODO zshrc not yet initialized in macos p-w-m
# https://github.com/mamba-org/mamba/issues/925
- { os: macos-latest, rcfile: ~/.bash_profile }
- { os: windows-latest, rcfile: ~/.bash_profile }
- { os: windows-latest, rcfile: ~/Documents/WindowsPowerShell/profile.ps1 }
steps:
- uses: actions/checkout@v3

# This is a fork of webiny/action-post-run. If webiny/action-post-run is updated, this should be updated as well.
- uses: lisanna-dettwyler/action-post-run@d053b9b43d788b87a409f6cdb3b6fc87c6c8a4fe
with:
# assert that mamba initialize is not in rcfile
# if the rcfile is not found, the test will still succeed
run: |
! grep -F "mamba initialize" ${{ matrix.rcfile }}
- uses: ./
with:
environment-file: false

- run: grep -F "mamba initialize" ${{ matrix.rcfile }}

test_deinit_false:
name: Test deinit false - ${{ matrix.os }} ${{ matrix.rcfile }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
# .bash_profile gets initialized in p-w-m ubuntu-latest instead of .bashrc like in micromamba
- { os: ubuntu-latest, rcfile: ~/.bash_profile }
- { os: ubuntu-latest, rcfile: ~/.zshrc }
# TODO zshrc not yet initialized in macos p-w-m
# https://github.com/mamba-org/mamba/issues/925
- { os: macos-latest, rcfile: ~/.bash_profile }
- { os: windows-latest, rcfile: ~/.bash_profile }
- { os: windows-latest, rcfile: ~/Documents/WindowsPowerShell/profile.ps1 }
steps:
- uses: actions/checkout@v3

# This is a fork of webiny/action-post-run. If webiny/action-post-run is updated, this should be updated as well.
- uses: lisanna-dettwyler/action-post-run@d053b9b43d788b87a409f6cdb3b6fc87c6c8a4fe
with:
# assert that mamba initialize is in rcfile
run: |
grep -F "mamba initialize" ${{ matrix.rcfile }}
- uses: ./
with:
environment-file: false
post-deinit: false

- run: grep -F "mamba initialize" ${{ matrix.rcfile }}

test_deinit_auto_old_micromamba:
name: Test deinit auto old micromamba - ${{ matrix.os }} ${{ matrix.rcfile }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
# .bash_profile gets initialized in p-w-m ubuntu-latest instead of .bashrc like in micromamba
- { os: ubuntu-latest, rcfile: ~/.bash_profile }
- { os: ubuntu-latest, rcfile: ~/.zshrc }
# TODO zshrc not yet initialized in macos p-w-m
# https://github.com/mamba-org/mamba/issues/925
- { os: macos-latest, rcfile: ~/.bash_profile }
- { os: windows-latest, rcfile: ~/.bash_profile }
- { os: windows-latest, rcfile: ~/Documents/WindowsPowerShell/profile.ps1 }
steps:
- uses: actions/checkout@v3

# This is a fork of webiny/action-post-run. If webiny/action-post-run is updated, this should be updated as well.
- uses: lisanna-dettwyler/action-post-run@d053b9b43d788b87a409f6cdb3b6fc87c6c8a4fe
with:
# assert that mamba initialize is in rcfile
run: |
grep -F "mamba initialize" ${{ matrix.rcfile }}
- uses: ./
with:
environment-file: false
micromamba-version: "0.23.0"

- run: grep -F "mamba initialize" ${{ matrix.rcfile }}
9 changes: 9 additions & 0 deletions README.md
Expand Up @@ -96,6 +96,15 @@ condarc-options: |
http: ...
```

### `post-deinit`

Attempt to undo any modifications done to `.bashrc` etc. in the post action of the workflow.
This is useful for self-hosted runners that keep the state of the system.
One of `"auto"`, `"true"` or `"false"`.
If set to `"auto"`, behaves like `"true"` if the micromamba version used supports `micromamba shell deinit` (i.e. `micromamba>=0.25.0`).

Default value: `auto`

<!-- end generated -->

## Example usage
Expand Down
8 changes: 8 additions & 0 deletions action.yml
Expand Up @@ -109,6 +109,14 @@ inputs:
proxy_servers:
http: ...
```
post-deinit:
description: |-
Attempt to undo any modifications done to `.bashrc` etc. in the post action of the workflow.
This is useful for self-hosted runners that keep the state of the system.
One of `"auto"`, `"true"` or `"false"`.
If set to `"auto"`, behaves like `"true"` if the micromamba version used supports `micromamba shell deinit` (i.e. `micromamba>=0.25.0`).
required: true
default: auto

# setup-miniconda options that are not (yet) supported:
#
Expand Down

0 comments on commit b54d7bb

Please sign in to comment.