{"id":13738716,"url":"https://github.com/conda-incubator/setup-miniconda","last_synced_at":"2025-04-10T00:04:35.286Z","repository":{"id":37084422,"uuid":"228279841","full_name":"conda-incubator/setup-miniconda","owner":"conda-incubator","description":"Set up your GitHub Actions workflow with conda via miniconda","archived":false,"fork":false,"pushed_at":"2025-02-04T13:28:46.000Z","size":3599,"stargazers_count":414,"open_issues_count":72,"forks_count":75,"subscribers_count":7,"default_branch":"main","last_synced_at":"2025-04-10T00:04:22.310Z","etag":null,"topics":["actions","anaconda","conda","dependencies","environment","github-actions","miniconda","package","package-manager","python","setup-miniconda","typescript","yml"],"latest_commit_sha":null,"homepage":"https://github.com/marketplace/actions/setup-miniconda","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/conda-incubator.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-12-16T01:37:17.000Z","updated_at":"2025-04-02T01:25:10.000Z","dependencies_parsed_at":"2023-02-18T19:00:38.652Z","dependency_job_id":"4cdf25a4-981d-4a9b-a8bf-ef44726f5181","html_url":"https://github.com/conda-incubator/setup-miniconda","commit_stats":{"total_commits":365,"total_committers":30,"mean_commits":"12.166666666666666","dds":0.7287671232876712,"last_synced_commit":"0e1496204d513e706ff93931b2ee73f2dafa25c7"},"previous_names":["goanpeca/action-setup-conda"],"tags_count":32,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/conda-incubator%2Fsetup-miniconda","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/conda-incubator%2Fsetup-miniconda/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/conda-incubator%2Fsetup-miniconda/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/conda-incubator%2Fsetup-miniconda/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/conda-incubator","download_url":"https://codeload.github.com/conda-incubator/setup-miniconda/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248131320,"owners_count":21052819,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["actions","anaconda","conda","dependencies","environment","github-actions","miniconda","package","package-manager","python","setup-miniconda","typescript","yml"],"created_at":"2024-08-03T03:02:34.526Z","updated_at":"2025-04-10T00:04:35.261Z","avatar_url":"https://github.com/conda-incubator.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"# `conda-incubator/setup-miniconda`\n\nThis action sets up a `base`\n[conda](https://docs.conda.io/projects/conda/en/latest/) environment by one of:\n\n- locating the `conda` installation [bundled] with the available runners and\n  available in `$CONDA`\n- installing a specific (or latest) version of\n  - [Miniconda3][miniconda-repo]\n  - [Miniforge][miniforge-releases]\n  - any [constructor]-based installer by or URL or filesystem path\n\nA `conda-build-version` or `mamba-version` may be provided to install specific\nversions of `conda` or `mamba` into `base`.\n\nThe base `condabin/` folder is added to `$PATH` and shell integration is\ninitialized across all platforms.\n\nBy default, this action will then create, and _activate_, an environment by one\nof:\n\n- creating a mostly-empty `test` environment, containing only the latest\n  `python-version` and its dependencies\n- creating a `test` environment described in a given `environment-file`\n  including:\n  - an `environment.yml`-like file (which can be patched with `python-version`).\n    Note: the patched environment will be cleaned up unless\n    `clean-patched-environment-file: false` is given\n  - a [lockfile](#example-7-lockfiles)\n\nThis action correctly handles activation of environments and offers the\npossibility of automatically activating the `test` environment on all shells.\n\n\u003e **Please** see the **[IMPORTANT](#important)** notes on additional information\n\u003e on environment activation.\n\n[bundled]:\n  https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-software\n[miniconda-repo]: https://repo.anaconda.com/miniconda\n[miniforge-releases]: https://github.com/conda-forge/miniforge/releases\n[constructor]: https://github.com/conda/constructor\n\n## Example Overview\n\n\u003e Each of the examples below is discussed in a dedicated section below.\n\n| Documentation                                                      | Workflow Status                                                 |\n| ------------------------------------------------------------------ | --------------------------------------------------------------- |\n| [Basic usage](#example-1-basic-usage)                              | [![Basic Usage Status][ex1-badge]][ex1]                         |\n| [Other shells](#example-2-other-shells)                            | [![Other Shells Status][ex2-badge]][ex2]                        |\n| [Other options](#example-3-other-options)                          | [![Other Options Status][ex3-badge]][ex3]                       |\n| [Channels](#example-4-conda-options)                               | [![Channels Status][ex4-badge]][ex4]                            |\n| [Custom installer](#example-5-custom-installer)                    | [![Custom Installer Status][ex5-badge]][ex5]                    |\n| [Mamba](#example-6-mamba)                                          | [![Mamba Status][ex6-badge]][ex6]                               |\n| [Lockfiles](#example-7-lockfiles)                                  | [![Lockfiles Status][ex7-badge]][ex7]                           |\n| [Miniforge](#example-10-miniforge)                                 | [![Miniforge Status][ex10-badge]][ex10]                         |\n| [Alternative Architectures](#example-11-alternative-architectures) | [![Alternative Architectures][ex11-badge]][ex11]                |\n| [Configure conda solver](#example-12-configure-conda-solver)       | [![Configure conda solver][ex12-badge]][ex12]                   |\n| [Caching packages](#caching-packages)                              | [![Caching Example Status][caching-badge]][caching]             |\n| [Caching environments](#caching-environments)                      | [![Caching Env Example Status][caching-env-badge]][caching-env] |\n| [Apple Silicon](#example-13-apple-silicon)                         | [![Apple Silicon][ex13-badge]][ex13]                            |\n| [Remove defaults](#example-14-remove-defaults-channel)             | [![Remove defaults][ex14-badge]][ex14]                          |\n| [Linux ARM](#example-15-linux-arm)                                 | [![Linux ARM][ex15-badge]][ex15]                                |\n\n[ex1]:\n  https://github.com/conda-incubator/setup-miniconda/actions/workflows/example-1.yml\n[ex1-badge]:\n  https://github.com/conda-incubator/setup-miniconda/actions/workflows/example-1.yml/badge.svg?branch=main\n[ex2]:\n  https://github.com/conda-incubator/setup-miniconda/actions/workflows/example-2.yml\n[ex2-badge]:\n  https://github.com/conda-incubator/setup-miniconda/actions/workflows/example-2.yml/badge.svg?branch=main\n[ex3]:\n  https://github.com/conda-incubator/setup-miniconda/actions/workflows/example-3.yml\n[ex3-badge]:\n  https://github.com/conda-incubator/setup-miniconda/actions/workflows/example-3.yml/badge.svg?branch=main\n[ex4]:\n  https://github.com/conda-incubator/setup-miniconda/actions/workflows/example-4.yml\n[ex4-badge]:\n  https://github.com/conda-incubator/setup-miniconda/actions/workflows/example-4.yml/badge.svg?branch=main\n[ex5]:\n  https://github.com/conda-incubator/setup-miniconda/actions/workflows/example-5.yml\n[ex5-badge]:\n  https://github.com/conda-incubator/setup-miniconda/actions/workflows/example-5.yml/badge.svg?branch=main\n[ex6]:\n  https://github.com/conda-incubator/setup-miniconda/actions/workflows/example-6.yml\n[ex6-badge]:\n  https://github.com/conda-incubator/setup-miniconda/actions/workflows/example-6.yml/badge.svg?branch=main\n[caching]:\n  https://github.com/conda-incubator/setup-miniconda/actions/workflows/caching-example.yml\n[caching-badge]:\n  https://github.com/conda-incubator/setup-miniconda/actions/workflows/caching-example.yml/badge.svg?branch=main\n[caching-env]:\n  https://github.com/conda-incubator/setup-miniconda/actions/workflows/caching-envs-example.yml\n[caching-env-badge]:\n  https://github.com/conda-incubator/setup-miniconda/actions/workflows/caching-envs-example.yml/badge.svg?branch=main\n[ex7]:\n  https://github.com/conda-incubator/setup-miniconda/actions/workflows/example-7.yml\n[ex7-badge]:\n  https://github.com/conda-incubator/setup-miniconda/actions/workflows/example-7.yml/badge.svg?branch=main\n[ex10]:\n  https://github.com/conda-incubator/setup-miniconda/actions/workflows/example-10.yml\n[ex10-badge]:\n  https://github.com/conda-incubator/setup-miniconda/actions/workflows/example-10.yml/badge.svg?branch=main\n[ex11]:\n  https://github.com/conda-incubator/setup-miniconda/actions/workflows/example-11.yml\n[ex11-badge]:\n  https://github.com/conda-incubator/setup-miniconda/actions/workflows/example-11.yml/badge.svg?branch=main\n[ex12]:\n  https://github.com/conda-incubator/setup-miniconda/actions/workflows/example-12.yml\n[ex12-badge]:\n  https://github.com/conda-incubator/setup-miniconda/actions/workflows/example-12.yml/badge.svg?branch=main\n[ex13]:\n  https://github.com/conda-incubator/setup-miniconda/actions/workflows/example-13.yml\n[ex13-badge]:\n  https://github.com/conda-incubator/setup-miniconda/actions/workflows/example-13.yml/badge.svg?branch=main\n[ex14]:\n  https://github.com/conda-incubator/setup-miniconda/actions/workflows/example-14.yml\n[ex14-badge]:\n  https://github.com/conda-incubator/setup-miniconda/actions/workflows/example-14.yml/badge.svg?branch=main\n[ex15]:\n  https://github.com/conda-incubator/setup-miniconda/actions/workflows/example-15.yml\n[ex15-badge]:\n  https://github.com/conda-incubator/setup-miniconda/actions/workflows/example-15.yml/badge.svg?branch=main\n\n## Other Workflows\n\n\u003e These are quality control and test workflows, and are not described in depth.\n\n| QA Workflow     | Linting                                     | Catch Invalid Enviroments                              | Handle Empty Channels                             |\n| --------------- | ------------------------------------------- | ------------------------------------------------------ | ------------------------------------------------- |\n| Workflow Status | [![Linting Status][linting-badge]][linting] | [![Catch Invalid Environments Status][ex8-badge]][ex8] | [![Handle Empty Channels Status][ex9-badge]][ex9] |\n\n[linting]:\n  https://github.com/conda-incubator/setup-miniconda/actions/workflows/lint.yml\n[linting-badge]:\n  https://github.com/conda-incubator/setup-miniconda/actions/workflows/lint.yml/badge.svg?branch=main\n[ex8]:\n  https://github.com/conda-incubator/setup-miniconda/actions/workflows/example-8.yml\n[ex8-badge]:\n  https://github.com/conda-incubator/setup-miniconda/actions/workflows/example-8.yml/badge.svg?branch=main\n[ex9]:\n  https://github.com/conda-incubator/setup-miniconda/actions/workflows/example-9.yml\n[ex9-badge]:\n  https://github.com/conda-incubator/setup-miniconda/actions/workflows/example-9.yml/badge.svg?branch=main\n\n## Environment activation\n\nThis action will, by default, activate an environment called `test` and _not_\nactivate the `base` environment. This encourages the recommended practice of not\ninstalling workflow packages into the `base` environment and leaving it with\nonly `conda` (and/or `mamba`).\n\n## Inputs and outputs\n\nFor a full list of available _inputs_ and _outputs_ for this action see\n[action.yml](action.yml).\n\n### Use a different environment name or path\n\nYou can change the default `test` environment to have a different name or path\nby setting the `activate-environment` input option.\n\n```yaml\n- uses: conda-incubator/setup-miniconda@v3\n  with:\n    activate-environment: whatever\n```\n\nThis will create a _named_ env in `$CONDA/envs/whatever`, where `$CONDA` is the\npath to the infrequently-updated, but **very fast** to start, \"bundled\"\nMiniconda installation.\n\n\u003e - If `activate-environment` contains either POSIX or Windows slashes, it will\n\u003e   be interpreted as a path, or `prefix` in `conda` terminology. Use this to\n\u003e   avoid \"path too long\"-style errors, especially on Windows.\n\u003e - Self-hosted runners can emulate the \"bundled\" Miniconda approach by\n\u003e   pre-installing a [constructor]-based installer and ensuring `$CONDA` is set\n\u003e   prior to starting `setup-miniconda`\n\n### Activate `base` environment\n\nIf your specific workflow still needs to activate and use `base` you will need\nto do **both** of:\n\n- set `activate-environment` to an empty string\n- set `auto-activate-base` to `true`\n\n```yaml\n- uses: conda-incubator/setup-miniconda@v3\n  with:\n    auto-activate-base: true\n    activate-environment: \"\"\n```\n\n## Usage examples\n\n### Example 1: Basic usage\n\nThis example shows how to set a basic python workflow with conda using the\ncross-platform available shells: `bash` and `pwsh`. In this example an\nenvironment named `test` will be created with the specific `python-version`\ninstalled for each operating system, resulting in 6 build workers.\n\n```yaml\njobs:\n  example-1:\n    name: Ex1 (${{ matrix.python-version }}, ${{ matrix.os }})\n    runs-on: ${{ matrix.os }}\n    strategy:\n      fail-fast: false\n      matrix:\n        os: [\"ubuntu-latest\", \"macos-latest\", \"windows-latest\"]\n        python-version: [\"3.7\", \"3.11\"]\n    steps:\n      - uses: conda-incubator/setup-miniconda@v3\n        with:\n          auto-update-conda: true\n          python-version: ${{ matrix.python-version }}\n      - name: Conda info\n        shell: bash -el {0}\n        run: conda info\n      - name: Conda list\n        shell: pwsh\n        run: conda list\n```\n\n### Example 2: Other shells\n\nThis example shows how to use all other available shells for specific operating\nsystems. In this example we download the latest anaconda version then create and\nactivate a default environment named `foo`.\n\n```yaml\njobs:\n  example-2-linux:\n    name: Ex2 Linux\n    runs-on: \"ubuntu-latest\"\n    steps:\n      - uses: conda-incubator/setup-miniconda@v3\n        with:\n          miniconda-version: \"latest\"\n          activate-environment: foo\n      - name: Bash\n        shell: bash -el {0}\n        run: |\n          conda info\n          conda list\n      - name: PowerShell Core\n        shell: pwsh\n        run: |\n          conda info\n          conda list\n\n  example-2-mac:\n    name: Ex2 Mac\n    runs-on: \"macos-latest\"\n    steps:\n      - uses: conda-incubator/setup-miniconda@v3\n        with:\n          miniconda-version: \"latest\"\n          activate-environment: foo\n      - name: Sh\n        shell: sh -l {0}\n        run: |\n          conda info\n          conda list\n      - name: Bash\n        shell: bash -el {0}\n        run: |\n          conda info\n          conda list\n      - name: PowerShell Core\n        shell: pwsh\n        run: |\n          conda info\n          conda list\n\n  example-2-win:\n    name: Ex2 Windows\n    runs-on: \"windows-latest\"\n    steps:\n      - uses: conda-incubator/setup-miniconda@v3\n        with:\n          miniconda-version: \"latest\"\n          activate-environment: foo\n      - name: Bash\n        shell: bash -el {0}\n        run: |\n          conda info\n          conda list\n      - name: PowerShell\n        shell: powershell\n        run: |\n          conda info\n          conda list\n      - name: PowerShell Core\n        shell: pwsh\n        run: |\n          conda info\n          conda list\n      - name: Cmd.exe\n        shell: cmd /C CALL {0}\n        run: \u003e-\n          conda info \u0026\u0026 conda list\n```\n\n### Example 3: Other options\n\nThis example shows how to use [environment.yml](etc/example-environment.yml) for\neasier creation of test/build environments and\n[.condarc](etc/example-condarc.yml) files for fine grained configuration\nmanagement. In this example we use a custom configuration file, install an\nenvironment from a yaml file, and disable autoactivating the base environment\nbefore activating the `anaconda-client-env`.\n\n```yaml\njobs:\n  example-3:\n    name: Ex3 Linux\n    runs-on: \"ubuntu-latest\"\n    defaults:\n      run:\n        shell: bash -el {0}\n    steps:\n      - uses: actions/checkout@v4\n      - uses: conda-incubator/setup-miniconda@v3\n        with:\n          activate-environment: anaconda-client-env\n          environment-file: etc/example-environment.yml\n          python-version: 3.5\n          condarc-file: etc/example-condarc.yml\n          auto-activate-base: false\n      - run: |\n          conda info\n          conda list\n```\n\n### Example 4: Conda options\n\nThis example shows how to use the `channels` option and other extra options. The\npriority will be set by the order of the channels. The following example will\nresult in these priorities (from highest to lowest):\n\n- conda-forge\n- spyder-ide\n- defaults\n\n```yaml\njobs:\n  example-4:\n    name: Ex4 Linux\n    runs-on: \"ubuntu-latest\"\n    defaults:\n      run:\n        shell: bash -el {0}\n    steps:\n      - uses: actions/checkout@v4\n      - uses: conda-incubator/setup-miniconda@v3\n        with:\n          activate-environment: foo\n          python-version: 3.6\n          channels: conda-forge,spyder-ide\n          allow-softlinks: true\n          channel-priority: flexible\n          show-channel-urls: true\n          use-only-tar-bz2: true\n      - run: |\n          conda info\n          conda list\n          conda config --show-sources\n          conda config --show\n```\n\n### Example 5: Custom installer\n\nAny installer created with the\n[constructor](https://github.com/conda/constructor) tool (which includes\n`conda`) can be used in place of Miniconda. For example,\n[conda-forge](https://conda-forge.org/) maintains additional builds of\n[miniforge](https://github.com/conda-forge/miniforge/releases) for platforms not\nyet supported by Miniconda. For more details, see\n[Example 10](#example-10-miniforge).\n\n\u003e Note:\n\u003e\n\u003e - Installer downloads are cached based on their full URL: adding some\n\u003e   non-functional salt to the URL will prevent this behavior, e.g.,\n\u003e   `#${{ github.run_number }}`\n\n```yaml\njobs:\n  example-5:\n    name: Ex5 Miniforge for PyPy\n    runs-on: \"ubuntu-latest\"\n    defaults:\n      run:\n        shell: bash -el {0}\n    steps:\n      - uses: actions/checkout@v4\n      - uses: conda-incubator/setup-miniconda@v3\n        with:\n          installer-url: https://github.com/conda-forge/miniforge/releases/download/4.8.3-2/Miniforge-pypy3-4.8.3-2-Linux-x86_64.sh\n          allow-softlinks: true\n          show-channel-urls: true\n          use-only-tar-bz2: true\n      - run: |\n          conda info\n          conda list\n          conda config --show-sources\n          conda config --show\n```\n\n### Example 6: Mamba\n\n\u003e Note: `conda` 23.10+ uses `conda-libmamba-solver` by default, which provides\n\u003e comparable performance to `mamba`. Most users won't need this setting with\n\u003e recent conda versions.\n\nExperimental! Use `mamba` to enable much faster conda installs. `mamba-version`\naccepts a version string `x.y` (including `\"*\"`). It requires you specify\n`conda-forge` as part of the channels, ideally with the highest priority.\n\n\u003e Notes:\n\u003e\n\u003e - If a [custom installer](#example-5-custom-installer) provides `mamba`, it\n\u003e   can be prioritized wherever possible (including installing `mamba-version`)\n\u003e   with `use-mamba: true`.\n\n```yaml\njobs:\n  example-6:\n    name: Ex6 Mamba\n    runs-on: \"ubuntu-latest\"\n    steps:\n      - uses: actions/checkout@v4\n      - uses: conda-incubator/setup-miniconda@v3\n        with:\n          python-version: 3.6\n          mamba-version: \"*\"\n          channels: conda-forge,defaults\n          channel-priority: true\n          activate-environment: anaconda-client-env\n          environment-file: etc/example-environment.yml\n      - shell: bash -el {0}\n        run: |\n          conda info\n          conda list\n          conda config --show-sources\n          conda config --show\n          printenv | sort\n      - shell: bash -el {0}\n        run: mamba install jupyterlab\n```\n\n### Example 7: Lockfiles\n\n`conda list --explicit` and [conda-lock][conda-lock] support generating\n[explicit environment specifications][explicit-spec], which skip the environment\nsolution step altogether, as they contain the _ordered_ list of exact URLs\nneeded to reproduce the environment.\n\nThis means explicitly-defined environments which:\n\n- are _much faster_ to install, as several expensive steps are skipped:\n  - channels are not queried for their repo data\n  - no solver is run\n- are not cross-platform, as the URLs almost always contain\n  platform/architecture information\n- can become broken if any file becomes unavailable\n\nThis approach can be useful as part of a larger system e.g., a separate workflow\nthat runs `conda-lock` for all the platforms needed in a separate job.\n\n[conda-lock]: https://github.com/conda/conda-lock\n[explicit-spec]:\n  https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html#building-identical-conda-environments\n\n```yaml\njobs:\n  example-7:\n    name: Ex7 Explicit\n    runs-on: \"ubuntu-latest\"\n    defaults:\n      run:\n        shell: bash -el {0}\n    steps:\n      - uses: actions/checkout@v4\n      - uses: conda-incubator/setup-miniconda@v3\n        with:\n          auto-update-conda: false\n          activate-environment: explicit-env\n          environment-file: etc/example-explicit.conda.lock\n      - run: |\n          conda info\n          conda list\n          conda config --show-sources\n          conda config --show\n          printenv | sort\n```\n\n### Example 10: Miniforge\n\n[Miniforge](https://github.com/conda-forge/miniforge) provides a number of\nalternatives to Miniconda, built from the ground up with `conda-forge` packages\nand with only `conda-forge` in its default channel(s).\n\nIf only `miniforge-version` is provided then `Miniforge3` will be used.\n\n```yaml\njobs:\n  example-10-miniforge:\n    name: Ex10 (${{ matrix.os }}, Miniforge)\n    runs-on: ${{ matrix.os }}-latest\n    strategy:\n      matrix:\n        os: [\"ubuntu\", \"macos\", \"windows\"]\n    steps:\n      - uses: actions/checkout@v4\n      - uses: conda-incubator/setup-miniconda@v3\n        with:\n          environment-file: etc/example-environment.yml\n          miniforge-version: latest\n```\n\nIn addition to `Miniforge3` with `conda`, `mamba` and `CPython`, you can also\ninstall `Miniforge-pypy3`, which replaces `CPython` with `PyPy.\n\n\u003e [!TIP] You can customize the installation directory via the `installation-dir`\n\u003e option.\n\n### Example 11: Alternative Architectures\n\nIn addition to the default 64-bit builds of Miniconda, 32-bit versions are\navailable for Windows. Note that although some x86 builds are available for\nLinux and MacOS, these are too old (\u003c4.6) to be supported by this action.\n\n```yaml\njobs:\n  example-11:\n    name:\n      Ex11 (os=${{ matrix.os }} architecture=${{ matrix.architecture }}\n      miniconda-version=${{ matrix.miniconda-version }})\n    runs-on: ${{ matrix.os }}\n    strategy:\n      fail-fast: false\n      matrix:\n        os: [\"windows-latest\"]\n        architecture: [\"x86\"]\n        miniconda-version: [\"latest\"]\n    steps:\n      - uses: actions/checkout@v4\n      - uses: conda-incubator/setup-miniconda@v3\n        with:\n          architecture: ${{ matrix.architecture }}\n          miniconda-version: $${{ matrix.miniconda-version }}\n          auto-update-conda: true\n          python-version: \"3.8\"\n```\n\n### Example 12: Configure conda solver\n\nSet the conda solver plugin to use. Only applies to the `conda` client, not\n`mamba`. Starting with Miniconda 23.5.2 and Miniforge 23.3.1, you can choose\nbetween `classic` and `libmamba`. Best when combined with\n`auto-update-conda: true`.\n\n```yaml\njobs:\n  example-12:\n    name: Ex12 (os=${{ matrix.os }} solver=${{ matrix.solver }})\n    runs-on: ${{ matrix.os }}\n    strategy:\n      fail-fast: false\n      matrix:\n        solver: [\"classic\", \"libmamba\"]\n        os: [\"ubuntu-latest\", \"windows-latest\"]\n    steps:\n      - uses: actions/checkout@v4\n      - uses: conda-incubator/setup-miniconda@v3\n        id: setup-miniconda\n        continue-on-error: true\n        with:\n          auto-update-conda: true\n          conda-solver: ${{ matrix.solver }}\n          python-version: \"3.9\"\n```\n\n### Example 13: Apple Silicon\n\n```yaml\njobs:\n  example-13:\n    name: Ex13 (os=${{ matrix.os }})\n    runs-on: ${{ matrix.os }}\n    strategy:\n      fail-fast: false\n      matrix:\n        os: [\"macos-14\"]\n    steps:\n      - uses: actions/checkout@v4\n      - uses: ./\n        id: setup-miniforge\n        continue-on-error: true\n        with:\n          miniforge-version: latest\n      - name: Check arm64\n        shell: bash -el {0}\n        run: |\n          conda install -y python\n          python -c \"import platform; assert platform.machine() == 'arm64', platform.machine()\"\n```\n\n### Example 14: Remove `defaults` channel\n\nWorkaround for this bug:\n[conda#12356](https://github.com/conda/conda/issues/12356).\n\n```yaml\njobs:\n  example-13:\n    name: Ex14 (os=${{ matrix.os }})\n    runs-on: ${{ matrix.os }}\n    strategy:\n      fail-fast: false\n      matrix:\n        os: [\"ubuntu-latest\"]\n    steps:\n      - uses: actions/checkout@v4\n      - uses: ./\n        id: setup-miniconda\n        continue-on-error: true\n        with:\n          miniforge-version: latest\n          channels: conda-forge\n          conda-remove-defaults: \"true\"\n      - name: Check config\n        shell: bash -el {0}\n        run: |\n          conda config --show-sources\n```\n\n### Example 15: Linux ARM\n\n```yaml\njobs:\n  example-15:\n    name: Ex15 (os=${{ matrix.os }})\n    runs-on: ${{ matrix.os }}\n    strategy:\n      fail-fast: false\n      matrix:\n        os: [\"ubuntu-24.04-arm\"]\n    steps:\n      - uses: actions/checkout@v4\n      - uses: ./\n        id: setup-miniconda\n        continue-on-error: true\n        with:\n          miniforge-version: latest\n      - name: Check ARM\n        shell: bash -el {0}\n        run: |\n          conda install -y python\n          python -c \"import platform; assert platform.machine() == 'aarch64', platform.machine()\"\n```\n\n## Caching\n\n### Caching packages\n\nIf you want to enable package caching for conda you can use the\n[cache action](https://github.com/actions/cache) using `~/conda_pkgs_dir` as\npath for conda packages.\n\nThe cache will use an explicit key for restoring and saving the cache.\n\nThis can be based in the contents of files like:\n\n- `setup.py`\n- `requirements.txt`\n- `environment.yml`\n\n```yaml\njobs:\n  caching-example:\n    name: Caching\n    runs-on: \"ubuntu-latest\"\n    steps:\n      - uses: actions/checkout@v4\n      - name: Cache conda\n        uses: actions/cache@v3\n        env:\n          # Increase this value to reset cache if etc/example-environment.yml has not changed\n          CACHE_NUMBER: 0\n        with:\n          path: ~/conda_pkgs_dir\n          key:\n            ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-${{\n            hashFiles('etc/example-environment.yml') }}\n      - uses: conda-incubator/setup-miniconda@v3\n        with:\n          activate-environment: anaconda-client-env\n          channel-priority: strict\n          environment-file: etc/example-environment.yml\n          use-only-tar-bz2: true # IMPORTANT: This needs to be set for caching to work properly!\n```\n\nYou may also set conda's package directories (`pkgs_dirs`) config value, if you\nwant to change setup-miniconda's default of `~/conda_pkgs_dir` with the\n`pkgs-dirs` config option. This is a comma-separated string like the channels\nconfig option:\n\n```yaml\njobs:\n  caching-example:\n    name: Caching\n    runs-on: \"windows-latest\"\n    steps:\n      - uses: actions/checkout@v4\n      - name: Cache conda\n        uses: actions/cache@v3\n        env:\n          # Increase this value to reset cache if etc/example-environment.yml has not changed\n          CACHE_NUMBER: 0\n        with:\n          # Use faster GNU tar\n          enableCrossOsArchive: true\n          path: D:\\conda_pkgs_dir\n          key:\n            ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-${{\n            hashFiles('etc/example-environment.yml') }}\n      - uses: conda-incubator/setup-miniconda@v3\n        with:\n          activate-environment: anaconda-client-env\n          channel-priority: strict\n          environment-file: etc/example-environment.yml\n          pkgs-dirs: D:\\conda_pkgs_dir\n```\n\n\u003e [!NOTE]\n\u003e\n\u003e - GitHub hosted Windows runners are currently faster during cache\n\u003e   decompression when configuring the package directories on the `D:` drive as\n\u003e   shown above. Make sure to use the `enableCrossOsArchive` cache config option\n\u003e   as well.\n\nIf you are using pip to resolve any dependencies in your conda environment then\nyou may want to\n[cache those dependencies separately](https://docs.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#caching-dependencies),\nas they are not included in the conda package cache.\n\n### Caching environments\n\nThe first installation step should setup a Miniconda variant without specifying\na environment file.\n\n```yaml\n- name: Setup Miniforge\n  uses: conda-incubator/setup-miniconda@v3\n  with:\n    miniforge-version: latest\n    activate-environment: anaconda-client-env\n```\n\nIt's a good idea to refresh the cache every 24 hours to avoid inconsistencies of\npackage versions between the CI pipeline and local installations. Here we ensure\nthat this happens by adding the current date to the cache key. You can remove\nthe \"Get Date\" step below if you use a resolved environment file product of\n`conda env export` or `conda list --explicit`.\n\n```yaml\n- name: Get Date\n  id: get-date\n  run: echo \"today=$(/bin/date -u '+%Y%m%d')\" \u003e\u003e $GITHUB_OUTPUT\n  shell: bash\n\n- name: Cache Conda env\n  uses: actions/cache@v3\n  with:\n    path: ${{ env.CONDA }}/envs\n    key:\n      conda-${{ runner.os }}--${{ runner.arch }}--${{\n      steps.get-date.outputs.today }}-${{\n      hashFiles('etc/example-environment-caching.yml') }}-${{ env.CACHE_NUMBER\n      }}\n  env:\n    # Increase this value to reset cache if etc/example-environment.yml has not changed\n    CACHE_NUMBER: 0\n  id: cache\n```\n\nKeep in mind that hashing `etc/example-environment-caching.yml` is not the same\nas hashing a resolved environment file. `conda` (and `mamba`) resolves the\ndependencies declared in the YAML file according to the packages available on\nthe channels at installation time. Since packages are updated all the time, you\nwill not see these changes reflected in the cache until the key gets updated by\ndate.\n\n**This means that the same environment file can make your tests pass locally but\nfail on CI, or the other way around. In that case, reset the cache manually to\nsee if that leads to consistent results, or use a resolved environment file.**\n\nFinally, update the environment based on the environment file if the cache does\nnot exist.\n\n```yaml\n- name: Update environment\n  run:\n    mamba env update -n anaconda-client-env -f\n    etc/example-environment-caching.yml\n  if: steps.cache.outputs.cache-hit != 'true'\n```\n\n### Use a default shell\n\nIf you use the same shell for every step in your workflow you don't have to add\na shell directive to every step (e.g., `shell: bash -el {0}` when using bash).\n\nYou can add a `defaults` section and specify the desired directive (e.g.,\n`bash -el {0}` or equivalent). All steps in the job will then default to using\nthat value.\n\nFor other shells, make sure to use the correct `shell` parameter as the default\nvalue. Check the [section below](#important) for some examples.\n\nFor more information see the\n[Github Actions help page](https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-syntax-for-github-actions#jobsjob_iddefaultsrun).\n\n```yaml\njobs:\n  default-shell:\n    name: Default shell\n    runs-on: \"ubuntu-latest\"\n    defaults:\n      run:\n        shell: bash -el {0}\n    steps:\n      - uses: actions/checkout@v4\n      - uses: conda-incubator/setup-miniconda@v3\n        with:\n          activate-environment: anaconda-client-env\n          environment-file: etc/example-environment-caching.yml\n      - run: conda info\n      - run: conda list\n      - run: conda config --show\n```\n\n## IMPORTANT\n\n- Conda activation does not correctly work on `sh`. Please use `bash`.\n- Bash shells do not use `~/.profile` or `~/.bashrc` so these shells need to be\n  explicitly declared as `shell: bash -el {0}` on steps that need to be properly\n  activated (or use a default shell). This is because bash shells are executed\n  with `bash --noprofile --norc -eo pipefail {0}` thus ignoring updated on bash\n  profile files made by `conda init bash`. See\n  [Github Actions Documentation](https://help.github.com/en/actions/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions#using-a-specific-shell)\n  and this\n  [community thread](https://github.community/t5/GitHub-Actions/How-to-share-shell-profile-between-steps-or-how-to-use-nvm-rvm/td-p/33185).\n- Sh shells do not use `~/.profile` or `~/.bashrc` so these shells need to be\n  explicitly declared as `shell: sh -l {0}` on steps that need to be properly\n  activated (or use a default shell). This is because sh shells are executed\n  with `sh -e {0}` thus ignoring updates on bash profile files made by\n  `conda init bash`. See\n  [Github Actions Documentation](https://help.github.com/en/actions/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions#using-a-specific-shell).\n- Cmd shells do not run `Autorun` commands so these shells need to be explicitly\n  declared as `shell: cmd /C call {0}` on steps that need to be properly\n  activated (or use a default shell). This is because cmd shells are executed\n  with `%ComSpec% /D /E:ON /V:OFF /S /C \"CALL \"{0}\"\"` and the `/D` flag disables\n  execution of `Command Processor/Autorun` Windows registry keys, which is what\n  `conda init cmd.exe` sets. See\n  [Github Actions Documentation](https://help.github.com/en/actions/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions#using-a-specific-shell).\n- For caching to work properly, you will need to set the `use-only-tar-bz2`\n  option to `true`.\n- Some options (e.g. `use-only-tar-bz2`) are not available on the default conda\n  installed on Windows VMs, be sure to use `auto-update-conda` or provide a\n  version of conda compatible with the option.\n- If you plan to use a `environment.yaml` file to set up the environment, the\n  action will read the `channels` listed in the key (if found). If you provide\n  the `channels` input in the action they must not conflict with what was\n  defined in `environment.yaml`, otherwise the conda solver might find conflicts\n  which cause very long install times or install failures.\n\n## Security / Reproducibility\n\nSecurity and reproducibility is important especially when workflows deal with\nsecrets. No matter how much individual Github action repositories are secured,\ngit branches and tags are always mutable. It is thus good practice to:\n\n1. pin the action to a specific sha1 with tag as comment, instead of e.g. using\n   v2 or v2.2.1 (which are mutable tags):\n   `uses: conda-incubator/setup-miniconda@9f54435e0e72c53962ee863144e47a4b094bfd35 # v2.3.0`\n   see\n   [example](https://github.com/conda-incubator/setup-miniconda/actions/workflows/caching-example.yml)\n2. keep the non-human-readable pinning updated to not run behind recent updates\n   and fixes via automation like\n   [renovate](https://docs.renovatebot.com/modules/manager/github-actions/) or\n   [dependabot](https://github.blog/changelog/2022-10-31-dependabot-now-updates-comments-in-github-actions-workflows-referencing-action-versions/)\n3. use conda-lock files, see\n   [conda-lock](https://github.com/conda/conda-lock#why)\n\n## Project History and Contributing\n\nSee the\n[CHANGELOG](https://github.com/conda-incubator/setup-miniconda/blob/main/CHANGELOG.md)\nfor project history, or\n[CONTRIBUTING](https://github.com/conda-incubator/setup-miniconda/blob/main/CONTRIBUTING.md)\nto get started adding features you need.\n\n## Similar Actions to work with conda packages\n\n- https://github.com/mamba-org/setup-micromamba\n- https://github.com/prefix-dev/setup-pixi\n\n## Contributors\n\nThanks to all the contributors that make this awesome project possible!\n\n[![Meet our contributors!](https://contrib.rocks/image?repo=conda-incubator/setup-miniconda)](https://github.com/conda-incubator/setup-miniconda/graphs/contributors)\n\n_Made with [contributors-img](https://contrib.rocks)._\n\n## License\n\nThe scripts and documentation in this project are released under the\n[MIT License](LICENSE.txt)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fconda-incubator%2Fsetup-miniconda","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fconda-incubator%2Fsetup-miniconda","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fconda-incubator%2Fsetup-miniconda/lists"}