From 3bfb1d99e0f002a68433f041c79f0db7fbfdae93 Mon Sep 17 00:00:00 2001 From: Pavel Zwerschke Date: Tue, 5 Dec 2023 14:15:05 +0100 Subject: [PATCH] . --- .github/workflows/test-cache.yml | 294 +++++++------- .github/workflows/test-post-cleanup.yml | 1 - .github/workflows/test.yml | 520 ++++++++++++------------ action.yml | 3 +- src/options.ts | 6 +- 5 files changed, 410 insertions(+), 414 deletions(-) diff --git a/.github/workflows/test-cache.yml b/.github/workflows/test-cache.yml index 5df5f1e..70c810b 100644 --- a/.github/workflows/test-cache.yml +++ b/.github/workflows/test-cache.yml @@ -12,159 +12,159 @@ defaults: shell: bash -el {0} jobs: - # test-download1: - # name: Test download cache 1/2 - # timeout-minutes: 10 - # runs-on: ${{ matrix.os }} - # strategy: - # fail-fast: false - # matrix: - # os: [windows-latest, ubuntu-latest, macos-latest] - # steps: - # - uses: actions/checkout@v4 - # - uses: ./ - # with: - # environment-file: test/environment.yml - # cache-downloads-key: download-key-${{ github.sha }}-${{ github.run_attempt }} - # - name: test environment name - # run: | - # python -c "import os; env = os.path.basename(os.environ['CONDA_PREFIX']); assert env == 'env-name'" + test-download1: + name: Test download cache 1/2 + timeout-minutes: 10 + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [windows-latest, ubuntu-latest, macos-latest] + steps: + - uses: actions/checkout@v4 + - uses: ./ + with: + environment-file: test/environment.yml + cache-downloads-key: download-key-${{ github.sha }}-${{ github.run_attempt }} + - name: test environment name + run: | + python -c "import os; env = os.path.basename(os.environ['CONDA_PREFIX']); assert env == 'env-name'" - # test-download2: - # name: Test download cache 2/2 - # timeout-minutes: 10 - # needs: test-download1 - # runs-on: ${{ matrix.os }} - # strategy: - # fail-fast: false - # matrix: - # os: [windows-latest, ubuntu-latest, macos-latest] - # steps: - # - uses: actions/checkout@v4 - # - uses: ./ - # with: - # environment-file: test/environment.yml - # cache-downloads-key: download-key-${{ github.sha }}-${{ github.run_attempt }} - # - name: test environment name - # run: | - # python -c "import os; env = os.path.basename(os.environ['CONDA_PREFIX']); assert env == 'env-name'" + test-download2: + name: Test download cache 2/2 + timeout-minutes: 10 + needs: test-download1 + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [windows-latest, ubuntu-latest, macos-latest] + steps: + - uses: actions/checkout@v4 + - uses: ./ + with: + environment-file: test/environment.yml + cache-downloads-key: download-key-${{ github.sha }}-${{ github.run_attempt }} + - name: test environment name + run: | + python -c "import os; env = os.path.basename(os.environ['CONDA_PREFIX']); assert env == 'env-name'" - # test-env1: - # name: Test env cache 1/2 - # timeout-minutes: 10 - # runs-on: ${{ matrix.os }} - # strategy: - # fail-fast: false - # matrix: - # os: [windows-latest, ubuntu-latest, macos-latest] - # steps: - # - uses: actions/checkout@v4 - # - uses: ./ - # with: - # environment-file: test/environment.yml - # cache-environment-key: env-key-${{ github.sha }}-${{ github.run_attempt }} - # - name: test environment name - # run: | - # python -c "import os; env = os.path.basename(os.environ['CONDA_PREFIX']); assert env == 'env-name'" + test-env1: + name: Test env cache 1/2 + timeout-minutes: 10 + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [windows-latest, ubuntu-latest, macos-latest] + steps: + - uses: actions/checkout@v4 + - uses: ./ + with: + environment-file: test/environment.yml + cache-environment-key: env-key-${{ github.sha }}-${{ github.run_attempt }} + - name: test environment name + run: | + python -c "import os; env = os.path.basename(os.environ['CONDA_PREFIX']); assert env == 'env-name'" - # test-env2: - # name: Test env cache 2/2 - # timeout-minutes: 10 - # needs: test-env1 - # runs-on: ${{ matrix.os }} - # strategy: - # fail-fast: false - # matrix: - # os: [windows-latest, ubuntu-latest, macos-latest] - # steps: - # - uses: actions/checkout@v4 - # - uses: ./ - # with: - # environment-file: test/environment.yml - # cache-environment-key: env-key-${{ github.sha }}-${{ github.run_attempt }} - # - name: test environment name - # run: | - # python -c "import os; env = os.path.basename(os.environ['CONDA_PREFIX']); assert env == 'env-name'" + test-env2: + name: Test env cache 2/2 + timeout-minutes: 10 + needs: test-env1 + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [windows-latest, ubuntu-latest, macos-latest] + steps: + - uses: actions/checkout@v4 + - uses: ./ + with: + environment-file: test/environment.yml + cache-environment-key: env-key-${{ github.sha }}-${{ github.run_attempt }} + - name: test environment name + run: | + python -c "import os; env = os.path.basename(os.environ['CONDA_PREFIX']); assert env == 'env-name'" - # test-env-changing-root-path1: - # name: Test env cache with changing root path 1/2 - # timeout-minutes: 10 - # runs-on: ${{ matrix.os }} - # strategy: - # fail-fast: false - # matrix: - # os: [windows-latest, ubuntu-latest, macos-latest] - # steps: - # - uses: actions/checkout@v4 - # - uses: ./ - # with: - # environment-file: test/environment.yml - # cache-environment-key: env-root-path-key-${{ github.sha }}-${{ github.run_attempt }} - # micromamba-root-path: ~/micromamba - # - name: test environment name - # run: | - # python -c "import os; env = os.path.basename(os.environ['CONDA_PREFIX']); assert env == 'env-name'" + test-env-changing-root-path1: + name: Test env cache with changing root path 1/2 + timeout-minutes: 10 + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [windows-latest, ubuntu-latest, macos-latest] + steps: + - uses: actions/checkout@v4 + - uses: ./ + with: + environment-file: test/environment.yml + cache-environment-key: env-root-path-key-${{ github.sha }}-${{ github.run_attempt }} + micromamba-root-path: ~/micromamba + - name: test environment name + run: | + python -c "import os; env = os.path.basename(os.environ['CONDA_PREFIX']); assert env == 'env-name'" - # test-env-changing-root-path2: - # name: Test env cache with changing root path 2/2 - # timeout-minutes: 10 - # needs: test-env-changing-root-path1 - # runs-on: ${{ matrix.os }} - # strategy: - # fail-fast: false - # matrix: - # os: [windows-latest, ubuntu-latest, macos-latest] - # steps: - # - uses: actions/checkout@v4 - # - uses: ./ - # with: - # environment-file: test/environment.yml - # cache-environment-key: env-root-path-key-${{ github.sha }}-${{ github.run_attempt }} - # micromamba-root-path: ~/micromamba2 - # - name: test environment name - # run: | - # python -c "import os; env = os.path.basename(os.environ['CONDA_PREFIX']); assert env == 'env-name'" + test-env-changing-root-path2: + name: Test env cache with changing root path 2/2 + timeout-minutes: 10 + needs: test-env-changing-root-path1 + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [windows-latest, ubuntu-latest, macos-latest] + steps: + - uses: actions/checkout@v4 + - uses: ./ + with: + environment-file: test/environment.yml + cache-environment-key: env-root-path-key-${{ github.sha }}-${{ github.run_attempt }} + micromamba-root-path: ~/micromamba2 + - name: test environment name + run: | + python -c "import os; env = os.path.basename(os.environ['CONDA_PREFIX']); assert env == 'env-name'" - # test-env-then-download1: - # name: Test env then download 1/2 - # timeout-minutes: 10 - # runs-on: ${{ matrix.os }} - # strategy: - # fail-fast: false - # matrix: - # os: [windows-latest, ubuntu-latest, macos-latest] - # steps: - # - uses: actions/checkout@v4 - # - uses: ./ - # with: - # environment-file: test/environment.yml - # cache-environment-key: env-then-download-env-${{ github.sha }}-${{ github.run_attempt }} - # - name: test environment name - # run: | - # python -c "import os; env = os.path.basename(os.environ['CONDA_PREFIX']); assert env == 'env-name'" + test-env-then-download1: + name: Test env then download 1/2 + timeout-minutes: 10 + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [windows-latest, ubuntu-latest, macos-latest] + steps: + - uses: actions/checkout@v4 + - uses: ./ + with: + environment-file: test/environment.yml + cache-environment-key: env-then-download-env-${{ github.sha }}-${{ github.run_attempt }} + - name: test environment name + run: | + python -c "import os; env = os.path.basename(os.environ['CONDA_PREFIX']); assert env == 'env-name'" - # test-env-then-download2: - # name: Test env then download 2/2 - # timeout-minutes: 10 - # needs: test-env-then-download1 - # runs-on: ${{ matrix.os }} - # strategy: - # fail-fast: false - # matrix: - # os: [windows-latest, ubuntu-latest, macos-latest] - # steps: - # - uses: actions/checkout@v4 - # - uses: ./ - # with: - # # Since the environment is cached, there will be no downloaded packages in $MAMBA_ROOT_PREFIX/pkgs. - # # The caching should not fail because of this. - # environment-file: test/environment.yml - # cache-environment-key: env-then-download-env-${{ github.sha }}-${{ github.run_attempt }} - # cache-downloads-key: env-then-download-download-${{ github.sha }}-${{ github.run_attempt }} - # - name: test environment name - # run: | - # python -c "import os; env = os.path.basename(os.environ['CONDA_PREFIX']); assert env == 'env-name'" - # test -d $MAMBA_ROOT_PREFIX - # ! test -d $MAMBA_ROOT_PREFIX/pkgs + test-env-then-download2: + name: Test env then download 2/2 + timeout-minutes: 10 + needs: test-env-then-download1 + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [windows-latest, ubuntu-latest, macos-latest] + steps: + - uses: actions/checkout@v4 + - uses: ./ + with: + # Since the environment is cached, there will be no downloaded packages in $MAMBA_ROOT_PREFIX/pkgs. + # The caching should not fail because of this. + environment-file: test/environment.yml + cache-environment-key: env-then-download-env-${{ github.sha }}-${{ github.run_attempt }} + cache-downloads-key: env-then-download-download-${{ github.sha }}-${{ github.run_attempt }} + - name: test environment name + run: | + python -c "import os; env = os.path.basename(os.environ['CONDA_PREFIX']); assert env == 'env-name'" + test -d $MAMBA_ROOT_PREFIX + ! test -d $MAMBA_ROOT_PREFIX/pkgs diff --git a/.github/workflows/test-post-cleanup.yml b/.github/workflows/test-post-cleanup.yml index 634833e..5071696 100644 --- a/.github/workflows/test-post-cleanup.yml +++ b/.github/workflows/test-post-cleanup.yml @@ -9,7 +9,6 @@ on: jobs: test-post-cleanup: - if: false name: ${{ matrix.post-cleanup }} strategy: matrix: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3bd1fc8..c3b797c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -8,284 +8,284 @@ on: merge_group: jobs: - # no-environment-file: - # runs-on: ubuntu-latest - # steps: - # - uses: actions/checkout@v4 - # - uses: ./ - # with: - # environment-name: test - # create-args: >- - # python - # cython - # - run: | - # micromamba info | grep -q "environment : test" - # shell: bash -el {0} + no-environment-file: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: ./ + with: + environment-name: test + create-args: >- + python + cython + - run: | + micromamba info | grep -q "environment : test" + shell: bash -el {0} - # environment-file: - # runs-on: ubuntu-latest - # steps: - # - uses: actions/checkout@v4 - # - uses: ./ - # with: - # environment-file: 'test/environment.yml' - # - run: | - # micromamba info | grep -q "environment : env-name" - # shell: bash -el {0} + environment-file: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: ./ + with: + environment-file: 'test/environment.yml' + - run: | + micromamba info | grep -q "environment : env-name" + shell: bash -el {0} - # no-environment: - # runs-on: ubuntu-latest - # steps: - # - uses: actions/checkout@v4 - # - uses: ./ - # - run: | - # micromamba info | grep -q "environment : None (not found)" - # shell: bash -el {0} + no-environment: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: ./ + - run: | + micromamba info | grep -q "environment : None (not found)" + shell: bash -el {0} - # micromamba-old-version-1: - # runs-on: ubuntu-latest - # steps: - # - uses: actions/checkout@v4 - # - uses: ./ - # with: - # micromamba-version: 1.4.5-0 - # environment-file: 'test/environment.yml' - # - run: test "$(micromamba --version)" = 1.4.5 - # shell: bash -el {0} + micromamba-old-version-1: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: ./ + with: + micromamba-version: 1.4.5-0 + environment-file: 'test/environment.yml' + - run: test "$(micromamba --version)" = 1.4.5 + shell: bash -el {0} - # micromamba-old-version-2: - # runs-on: ubuntu-latest - # steps: - # - uses: actions/checkout@v4 - # - uses: ./ - # with: - # micromamba-version: 1.2.0-1 # this will throw a warning - # environment-file: 'test/environment.yml' - # - run: test "$(micromamba --version)" = 1.2.0 - # shell: bash -el {0} + micromamba-old-version-2: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: ./ + with: + micromamba-version: 1.2.0-1 # this will throw a warning + environment-file: 'test/environment.yml' + - run: test "$(micromamba --version)" = 1.2.0 + shell: bash -el {0} - # micromamba-shell: - # strategy: - # matrix: - # os: [ubuntu-latest, macos-latest] - # runs-on: ${{ matrix.os }} - # steps: - # - uses: actions/checkout@v4 - # - uses: ./ - # with: - # init-shell: '' - # environment-file: '' - # create-args: pytest - # environment-name: test - # - run: | - # pytest --version - # python --version - # shell: micromamba-shell {0} + micromamba-shell: + strategy: + matrix: + os: [ubuntu-latest, macos-latest] + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v4 + - uses: ./ + with: + init-shell: '' + environment-file: '' + create-args: pytest + environment-name: test + - run: | + pytest --version + python --version + shell: micromamba-shell {0} - # bash: - # strategy: - # matrix: - # os: [ubuntu-latest, macos-latest, windows-latest] - # runs-on: ${{ matrix.os }} - # steps: - # - uses: actions/checkout@v4 - # - uses: ./ - # with: - # init-shell: bash - # environment-file: 'test/environment.yml' - # - run: | - # micromamba info | grep -q "environment : env-name" - # shell: bash -el {0} + bash: + strategy: + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v4 + - uses: ./ + with: + init-shell: bash + environment-file: 'test/environment.yml' + - run: | + micromamba info | grep -q "environment : env-name" + shell: bash -el {0} - # multiple-shell-init: - # runs-on: ubuntu-latest - # steps: - # - uses: actions/checkout@v4 - # - uses: ./ - # with: - # init-shell: >- - # bash - # powershell - # environment-file: 'test/environment.yml' - # - run: | - # micromamba info | grep -q "environment : env-name" - # shell: bash -el {0} - # - name: micromamba info (pwsh) - # run: micromamba info - # shell: pwsh - # # TODO: powershell equivalent of `micromamba info | grep -q "environment : env-name"` + multiple-shell-init: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: ./ + with: + init-shell: >- + bash + powershell + environment-file: 'test/environment.yml' + - run: | + micromamba info | grep -q "environment : env-name" + shell: bash -el {0} + - name: micromamba info (pwsh) + run: micromamba info + shell: pwsh + # TODO: powershell equivalent of `micromamba info | grep -q "environment : env-name"` - # cmd: - # runs-on: windows-latest - # steps: - # - uses: actions/checkout@v4 - # - uses: ./ - # with: - # init-shell: cmd.exe - # environment-file: 'test/environment.yml' - # - name: micromamba info (cmd.exe) - # run: micromamba info - # shell: cmd /C CALL {0} - # # TODO: cmd equivalent of `micromamba info | grep -q "environment : env-name"` + cmd: + runs-on: windows-latest + steps: + - uses: actions/checkout@v4 + - uses: ./ + with: + init-shell: cmd.exe + environment-file: 'test/environment.yml' + - name: micromamba info (cmd.exe) + run: micromamba info + shell: cmd /C CALL {0} + # TODO: cmd equivalent of `micromamba info | grep -q "environment : env-name"` - # powershell: - # strategy: - # matrix: - # os: [ubuntu-latest, macos-latest, windows-latest] - # runs-on: ${{ matrix.os }} - # steps: - # - uses: actions/checkout@v4 - # - uses: ./ - # with: - # init-shell: powershell - # environment-file: 'test/environment.yml' - # - name: micromamba info (pwsh) - # run: micromamba info - # shell: pwsh - # - name: micromamba info (powershell) - # if: matrix.os == 'windows-latest' - # run: micromamba info - # shell: powershell - # # TODO: powershell equivalent of `micromamba info | grep -q "environment : env-name"` + powershell: + strategy: + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v4 + - uses: ./ + with: + init-shell: powershell + environment-file: 'test/environment.yml' + - name: micromamba info (pwsh) + run: micromamba info + shell: pwsh + - name: micromamba info (powershell) + if: matrix.os == 'windows-latest' + run: micromamba info + shell: powershell + # TODO: powershell equivalent of `micromamba info | grep -q "environment : env-name"` - # env-variable: - # runs-on: ubuntu-latest - # steps: - # - uses: actions/checkout@v4 - # - uses: ./ - # with: - # environment-file: 'test/environment.yml' - # - run: | # this should work even without `bash -l {0}` - # [ -n "$MAMBA_ROOT_PREFIX" ] - # [ -n "$MAMBA_EXE" ] - # [ -n "$CONDARC" ] + env-variable: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: ./ + with: + environment-file: 'test/environment.yml' + - run: | # this should work even without `bash -l {0}` + [ -n "$MAMBA_ROOT_PREFIX" ] + [ -n "$MAMBA_EXE" ] + [ -n "$CONDARC" ] - # custom-condarc: - # runs-on: ubuntu-latest - # steps: - # - uses: actions/checkout@v4 - # - uses: ./ - # with: - # environment-file: 'test/environment.yml' - # condarc-file: 'test/.condarc' - # - run: | # this should only work when the pytorch channel is loaded, i.e., the custom condarc is used - # micromamba search pytorch=2.0.0 - # micromamba search pytorch=2.0.0 | grep -q "pytorch 2.0.0 py3.10_cpu_0" - # shell: bash -el {0} + custom-condarc: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: ./ + with: + environment-file: 'test/environment.yml' + condarc-file: 'test/.condarc' + - run: | # this should only work when the pytorch channel is loaded, i.e., the custom condarc is used + micromamba search pytorch=2.0.0 + micromamba search pytorch=2.0.0 | grep -q "pytorch 2.0.0 py3.10_cpu_0" + shell: bash -el {0} - # conda-lock: - # runs-on: ubuntu-latest - # steps: - # - uses: actions/checkout@v4 - # - uses: ./ - # with: - # environment-file: 'test/conda-lock.yml' - # environment-name: locked-env - # - run: | - # micromamba list | grep -q "python 3.11.3 h2755cc3_0_cpython conda-forge" - # shell: bash -el {0} + conda-lock: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: ./ + with: + environment-file: 'test/conda-lock.yml' + environment-name: locked-env + - run: | + micromamba list | grep -q "python 3.11.3 h2755cc3_0_cpython conda-forge" + shell: bash -el {0} - # comment-in-environment-file: - # runs-on: ubuntu-latest - # steps: - # - uses: actions/checkout@v4 - # - uses: ./ - # with: - # environment-file: 'test/environment2.yml' - # - run: | - # micromamba info | grep -q "environment : env-name2" - # shell: bash -el {0} - # - run: | - # python --version | grep -q "Python 3.10.1" - # # micromamba-shell uses the environment-name inferred by setup-micromamba - # shell: micromamba-shell {0} + comment-in-environment-file: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: ./ + with: + environment-file: 'test/environment2.yml' + - run: | + micromamba info | grep -q "environment : env-name2" + shell: bash -el {0} + - run: | + python --version | grep -q "Python 3.10.1" + # micromamba-shell uses the environment-name inferred by setup-micromamba + shell: micromamba-shell {0} - # create-args-multiple-spaces-1: - # runs-on: ubuntu-latest - # steps: - # - uses: actions/checkout@v4 - # - uses: ./ - # with: - # environment-name: test - # create-args: python pytest - # - run: | - # micromamba list | grep -q python - # micromamba list | grep -q pytest - # shell: bash -el {0} + create-args-multiple-spaces-1: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: ./ + with: + environment-name: test + create-args: python pytest + - run: | + micromamba list | grep -q python + micromamba list | grep -q pytest + shell: bash -el {0} - # create-args-multiple-spaces-2: - # runs-on: ubuntu-latest - # steps: - # - uses: actions/checkout@v4 - # - uses: ./ - # with: - # environment-file: test/environment2.yml - # create-args: -c bioconda pytest - # - run: | - # micromamba list | grep -q python - # micromamba list | grep -q pytest - # shell: bash -el {0} + create-args-multiple-spaces-2: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: ./ + with: + environment-file: test/environment2.yml + create-args: -c bioconda pytest + - run: | + micromamba list | grep -q python + micromamba list | grep -q pytest + shell: bash -el {0} - # output-environment-path-env-file: - # runs-on: ubuntu-latest - # steps: - # - uses: actions/checkout@v4 - # - uses: ./ - # id: setup-micromamba - # with: - # environment-file: 'test/environment.yml' - # - run: | - # test ${{ steps.setup-micromamba.outputs.environment-path }} = "$HOME/micromamba/envs/env-name" - # ls ${{ steps.setup-micromamba.outputs.environment-path }} + output-environment-path-env-file: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: ./ + id: setup-micromamba + with: + environment-file: 'test/environment.yml' + - run: | + test ${{ steps.setup-micromamba.outputs.environment-path }} = "$HOME/micromamba/envs/env-name" + ls ${{ steps.setup-micromamba.outputs.environment-path }} - # output-environment-path-env-name-overwrite: - # runs-on: ubuntu-latest - # steps: - # - uses: actions/checkout@v4 - # - uses: ./ - # id: setup-micromamba - # with: - # environment-file: 'test/environment.yml' - # environment-name: test - # - run: | - # test "${{ steps.setup-micromamba.outputs.environment-path }}" = /home/runner/micromamba/envs/test - # ls "${{ steps.setup-micromamba.outputs.environment-path }}" + output-environment-path-env-name-overwrite: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: ./ + id: setup-micromamba + with: + environment-file: 'test/environment.yml' + environment-name: test + - run: | + test "${{ steps.setup-micromamba.outputs.environment-path }}" = /home/runner/micromamba/envs/test + ls "${{ steps.setup-micromamba.outputs.environment-path }}" - # output-environment-path-custom-root-prefix: - # runs-on: ubuntu-latest - # steps: - # - uses: actions/checkout@v4 - # - uses: ./ - # id: setup-micromamba - # with: - # environment-name: test - # micromamba-root-path: /home/runner/custom-micromamba-root-prefix - # - run: | - # test "${{ steps.setup-micromamba.outputs.environment-path }}" = /home/runner/custom-micromamba-root-prefix/envs/test - # ls "${{ steps.setup-micromamba.outputs.environment-path }}" + output-environment-path-custom-root-prefix: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: ./ + id: setup-micromamba + with: + environment-name: test + micromamba-root-path: /home/runner/custom-micromamba-root-prefix + - run: | + test "${{ steps.setup-micromamba.outputs.environment-path }}" = /home/runner/custom-micromamba-root-prefix/envs/test + ls "${{ steps.setup-micromamba.outputs.environment-path }}" - # output-no-environment-path: - # runs-on: ubuntu-latest - # steps: - # - uses: actions/checkout@v4 - # - uses: ./ - # id: setup-micromamba - # - run: | - # test "${{ steps.setup-micromamba.outputs.environment-path }}" = "" + output-no-environment-path: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: ./ + id: setup-micromamba + - run: | + test "${{ steps.setup-micromamba.outputs.environment-path }}" = "" - # check-micromamba-on-path: - # runs-on: ubuntu-latest - # steps: - # - uses: actions/checkout@v4 - # - uses: ./ - # with: - # init-shell: none - # environment-file: test/environment.yml - # - run: | - # which micromamba | grep /home/runner/micromamba-bin/micromamba - # type micromamba | grep "micromamba is /home/runner/micromamba-bin/micromamba" - # which micromamba-shell | grep /home/runner/micromamba-bin/micromamba-shell - # shell: bash -el {0} + check-micromamba-on-path: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: ./ + with: + init-shell: none + environment-file: test/environment.yml + - run: | + which micromamba | grep /home/runner/micromamba-bin/micromamba + type micromamba | grep "micromamba is /home/runner/micromamba-bin/micromamba" + which micromamba-shell | grep /home/runner/micromamba-bin/micromamba-shell + shell: bash -el {0} use-micromamba-from-path: runs-on: ubuntu-latest @@ -301,7 +301,6 @@ jobs: environment-file: test/environment.yml download-micromamba: false - run: | - set -x micromamba info | grep -q "environment : env-name" shell: bash -elo pipefail {0} @@ -320,9 +319,6 @@ jobs: download-micromamba: false micromamba-binary-path: ~/not-on-path/bin/micromamba - run: | - micromamba info - which micromamba - set -x micromamba info | grep -q "environment : env-name" which micromamba | grep not-on-path/bin shell: bash -elo pipefail {0} diff --git a/action.yml b/action.yml index 55ce322..753a38c 100644 --- a/action.yml +++ b/action.yml @@ -43,8 +43,7 @@ inputs: URL to download micromamba from. download-micromamba: description: | - If you already have a `micromamba` on PATH, you can set this to `true` to use it and skip the download step. - You can also specify a path to the micromamba binary to use with `micromamba-binary-path`. + If you already have micromamba installed, you can set this to `false`. init-shell: description: | Which shells to initialize micromamba in. diff --git a/src/options.ts b/src/options.ts index 13c5267..4a017ad 100644 --- a/src/options.ts +++ b/src/options.ts @@ -6,8 +6,8 @@ import * as z from 'zod' import { left, right } from 'fp-ts/lib/Either' import type { Either } from 'fp-ts/lib/Either' import untildify from 'untildify' -import { coreMocked } from './mocking' import which from 'which' +import { coreMocked } from './mocking' const core = process.env.MOCKING ? coreMocked : coreDefault @@ -132,7 +132,9 @@ const inferOptions = (inputs: Inputs): Options => { const downloadMicromamba = inputs.downloadMicromamba !== undefined ? inputs.downloadMicromamba : true const micromambaBinPath = inputs.micromambaBinPath ? path.resolve(untildify(inputs.micromambaBinPath)) - : inputs.downloadMicromamba === false ? which.sync('micromamba') : PATHS.micromambaBin + : inputs.downloadMicromamba === false + ? which.sync('micromamba') + : PATHS.micromambaBin return { ...inputs,