### Linux ARM Setup Source: https://github.com/conda-incubator/setup-miniconda/blob/main/README.md This example demonstrates setting up Miniconda for Linux ARM architecture. It installs the latest Miniforge and verifies the machine architecture. ```yaml jobs: example-15: name: Ex15 (os=${{ matrix.os }}) runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: os: ["ubuntu-24.04-arm"] steps: - uses: actions/checkout@v6 - uses: conda-incubator/setup-miniconda@v4 id: setup-miniconda continue-on-error: true with: miniforge-version: latest - name: Check ARM shell: bash -el {0} run: | conda install -y python python -c "import platform; assert platform.machine() == 'aarch64', platform.machine()" ``` -------------------------------- ### Setup for Apple Silicon Source: https://github.com/conda-incubator/setup-miniconda/blob/main/README.md This example demonstrates setting up Miniconda for Apple Silicon (M1/M2 Macs). It installs the latest Miniforge and verifies the architecture. ```yaml jobs: example-13: name: Ex13 (os=${{ matrix.os }}) runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: os: ["macos-14"] steps: - uses: actions/checkout@v6 - uses: conda-incubator/setup-miniconda@v4 id: setup-miniforge continue-on-error: true with: miniforge-version: latest - name: Check arm64 shell: bash -el {0} run: | conda install -y python python -c "import platform; assert platform.machine() == 'arm64', platform.machine()" ``` -------------------------------- ### Mamba Post-Install Log Example Source: https://github.com/conda-incubator/setup-miniconda/blob/main/_autodocs/07-base-tools-module.md Illustrates the log output during a Mamba post-install action, showing detection and update steps. This output indicates Mamba's successful integration after installation. ```log Do we need to update mamba? ... we will update mamba. ... we will perform post-install steps after we update mamba. [...installation...] Mamba was found in the `base` env ``` -------------------------------- ### Setup Miniconda with Custom Installer URL Source: https://github.com/conda-incubator/setup-miniconda/blob/main/README.md Uses a custom installer URL to set up Miniconda, specifically demonstrating the use of Miniforge for PyPy on Linux. Includes options for softlinks, channel URLs, and tarball usage. ```yaml jobs: example-5: name: Ex5 Miniforge for PyPy runs-on: "ubuntu-latest" defaults: run: shell: bash -el {0} steps: - uses: actions/checkout@v6 - uses: conda-incubator/setup-miniconda@v4 with: installer-url: https://github.com/conda-forge/miniforge/releases/download/4.8.3-2/Miniforge-pypy3-4.8.3-2-Linux-x86_64.sh allow-softlinks: true show-channel-urls: true use-only-tar-bz2: true - run: | conda info conda list conda config --show-sources conda config --show ``` -------------------------------- ### Top-Level Entry Point for Setup Source: https://github.com/conda-incubator/setup-miniconda/blob/main/_autodocs/01-setup-and-entry-points.md The main entry point for the setup action. It parses inputs, calls the setup function, and handles errors by marking the action as failed. ```typescript void run(); ``` -------------------------------- ### Use Custom Installer URL Source: https://github.com/conda-incubator/setup-miniconda/blob/main/_autodocs/05-installer-module.md Provide a URL to a custom installer script. Ensure the installer has a `.sh` (Unix) or `.exe` (Windows) extension. You can also specify a custom `installation-dir`. ```yaml # Use custom installer URL - uses: conda-incubator/setup-miniconda@v3 with: installer-url: https://example.com/my-installer.sh installation-dir: /opt/custom ``` -------------------------------- ### Basic Python Workflow Setup Source: https://github.com/conda-incubator/setup-miniconda/blob/main/README.md Sets up Miniconda for a workflow, automatically updating Conda and installing a specified Python version. Includes steps to display Conda info and list packages using bash and PowerShell. ```yaml jobs: example-1: name: Ex1 (${{ matrix.python-version }}, ${{ matrix.os }}) runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: os: ["ubuntu-latest", "macos-latest", "windows-latest"] python-version: ["3.7", "3.11"] steps: - uses: conda-incubator/setup-miniconda@v4 with: auto-update-conda: true python-version: ${{ matrix.python-version }} - name: Conda info shell: bash -el {0} run: conda info - name: Conda list shell: pwsh run: conda list ``` -------------------------------- ### Remove Defaults Channel Source: https://github.com/conda-incubator/setup-miniconda/blob/main/README.md This example shows how to remove the `defaults` channel during setup, which can be a workaround for certain conda bugs. It verifies the configuration after setup. ```yaml jobs: example-13: name: Ex14 (os=${{ matrix.os }}) runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: os: ["ubuntu-latest"] steps: - uses: actions/checkout@v6 - uses: conda-incubator/setup-miniconda@v4 id: setup-miniconda continue-on-error: true with: miniforge-version: latest channels: conda-forge conda-remove-defaults: "true" - name: Check config shell: bash -el {0} run: | conda config --show-sources ``` -------------------------------- ### Setup Miniconda with Miniforge Source: https://github.com/conda-incubator/setup-miniconda/blob/main/README.md Installs a Miniconda variant using Miniforge with the latest version. This setup is useful for caching entire conda environments. ```yaml - name: Setup Miniforge uses: conda-incubator/setup-miniconda@v4 with: miniforge-version: latest activate-environment: anaconda-client-env ``` -------------------------------- ### Get Local Installer Path Source: https://github.com/conda-incubator/setup-miniconda/blob/main/_autodocs/05-installer-module.md Iterates through installer providers to find and return the path of the first matching installer. Use this to determine the correct installer based on inputs and options. ```typescript const installerInfo = await getLocalInstallerPath(inputs, options); console.log(`Installer: ${installerInfo.localInstallerPath}`); console.log(`Using bundled: ${installerInfo.options.useBundled}`); ``` -------------------------------- ### Run Installer Command (Windows) Source: https://github.com/conda-incubator/setup-miniconda/blob/main/_autodocs/05-installer-module.md Builds and executes the command array for running a Windows installer (.exe) silently. The installation destination must be the last argument. ```shell ["{path}\\installer.exe /InstallationType=JustMe /RegisterPython=0 /S /D={outputPath}"] ``` -------------------------------- ### Complete Workflow Example Source: https://github.com/conda-incubator/setup-miniconda/blob/main/_autodocs/09-outputs-module.md An example GitHub Actions workflow demonstrating the use of setup-miniconda, including accessing outputs and running tests within the activated conda environment. ```yaml name: Test with conda on: [push, pull_request] jobs: test: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - id: conda-setup uses: conda-incubator/setup-miniconda@v3 with: environment-file: environment.yml python-version: "3.11" # Access outputs - run: | echo "Conda path: $CONDA" echo "Environment file: ${{ steps.conda-setup.outputs.environment-file }}" echo "Was patched: ${{ steps.conda-setup.outputs.environment-file-was-patched }}" # Run tests (conda environment is activated) - run: pytest tests/ # Post cleanup runs automatically # Removes packages from cache if run-post: true ``` -------------------------------- ### Run Installer Command (Unix) Source: https://github.com/conda-incubator/setup-miniconda/blob/main/_autodocs/05-installer-module.md Builds and executes the command array for running a Unix installer (.sh) in batch mode. The installation path is specified using the -p flag. ```shell ["bash", "{path}/installer.sh", "-f", "-b", "-p", "{outputPath}"] ``` -------------------------------- ### Path Output Example (Windows) Source: https://github.com/conda-incubator/setup-miniconda/blob/main/_autodocs/09-outputs-module.md Example of the normalized absolute path output for an environment file on a Windows system. ```text C:\Users\runner\work\my-repo\my-repo\environment.yml ``` -------------------------------- ### Minimal Workflow Example Source: https://github.com/conda-incubator/setup-miniconda/blob/main/_autodocs/00-README.md Demonstrates the most basic usage of the setup-miniconda action, relying on default configurations. ```yaml - uses: conda-incubator/setup-miniconda@v3 ``` -------------------------------- ### Use Miniforge Distribution Source: https://github.com/conda-incubator/setup-miniconda/blob/main/README.md Configure the action to use Miniforge, a distribution built with conda-forge packages and channels. This example installs the latest Miniforge3. You can also specify Miniforge-pypy3 for PyPy environments. ```yaml jobs: example-10-miniforge: name: Ex10 (${{ matrix.os }}, Miniforge) runs-on: ${{ matrix.os }}-latest strategy: matrix: os: ["ubuntu", "macos", "windows"] steps: - uses: actions/checkout@v6 - uses: conda-incubator/setup-miniconda@v4 with: environment-file: etc/example-environment.yml miniforge-version: latest ``` -------------------------------- ### Path Output Example (Linux) Source: https://github.com/conda-incubator/setup-miniconda/blob/main/_autodocs/09-outputs-module.md Example of the normalized absolute path output for an environment file on a Linux system. ```text /home/runner/work/my-repo/my-repo/environment.yml ``` -------------------------------- ### Environment YAML Example Source: https://github.com/conda-incubator/setup-miniconda/blob/main/_autodocs/06-environment-module.md An example environment.yml file specifying environment name, channels, and dependencies including pip packages. ```yaml name: myenv channels: - conda-forge dependencies: - python=3.11 - numpy - scipy - pip - pip: - requests ``` -------------------------------- ### Install NodeJS Dependencies Source: https://github.com/conda-incubator/setup-miniconda/blob/main/CONTRIBUTING.md Run this command in your project's root directory to install all necessary NodeJS dependencies. ```bash npm install ``` -------------------------------- ### Explicit Lockfile Environment Example Source: https://github.com/conda-incubator/setup-miniconda/blob/main/_autodocs/06-environment-module.md Example of an explicit lockfile content. This format guarantees exact reproducibility by specifying full URLs for each package. ```text @EXPLICIT # platform: linux-64 https://conda.anaconda.org/conda-forge/linux-64/python-3.11.8-hd12c33a_0_cpython.tar.bz2 https://conda.anaconda.org/conda-forge/linux-64/numpy-1.24.3-py311h1234567_0.tar.bz2 ``` -------------------------------- ### Installer File Extensions Source: https://github.com/conda-incubator/setup-miniconda/blob/main/_autodocs/11-constants.md Specifies the supported file extensions for constructor-based installers. Custom installer URLs must use one of these extensions for validation. ```typescript export const KNOWN_EXTENSIONS = [".exe", ".sh"]; ``` -------------------------------- ### Get Conda Installation Path Source: https://github.com/conda-incubator/setup-miniconda/blob/main/_autodocs/11-constants.md Retrieves the path to a pre-installed conda environment from the CONDA environment variable. Defaults to an empty string if not set. ```typescript export const MINICONDA_DIR_PATH: string = process.env["CONDA"] || ""; ``` -------------------------------- ### runInstaller Source: https://github.com/conda-incubator/setup-miniconda/blob/main/_autodocs/05-installer-module.md Executes a generated installer (e.g., .exe or .sh) silently and in batch mode, then detects if mamba is installed. It constructs the appropriate command based on the installer type and updates options with mamba detection results. ```APIDOC ## Function: runInstaller ### Description Execute a constructor-generated installer and detect mamba provisioning. The function determines the installer type, builds the command array for silent/batch execution, and updates options based on mamba detection. ### Parameters #### Path Parameters - **installerPath** (string) - Required - Path to the installer (`.exe` or `.sh`) - **outputPath** (string) - Required - Target installation directory - **inputs** (`IActionInputs`) - Required - Parsed action inputs - **options** (`IDynamicOptions`) - Required - Current dynamic options ### Returns `Promise` — Updated options with mamba detection results ### Throws `Error` if installer has unknown extension ### Example ```typescript const options = await runInstaller( "/tmp/Miniforge3-Linux-x86_64.sh", "/opt/miniconda3", inputs, options ); if (options.useMamba) { console.log("Mamba is available and will be used"); } ``` ``` -------------------------------- ### Install or Update Mamba Source: https://github.com/conda-incubator/setup-miniconda/blob/main/_autodocs/07-base-tools-module.md Use this snippet to install the latest mamba or a specific version. It handles updating existing mamba installations or installing mamba if it's not present. ```yaml with: mamba-version: "*" ``` ```yaml with: mamba-version: "1.5.0" ``` -------------------------------- ### Usage: Custom Installer URL Source: https://github.com/conda-incubator/setup-miniconda/blob/main/_autodocs/10-configuration.md Use a custom installer URL to install a specific conda build. Ensure the installation directory is also specified. ```yaml with: installer-url: "https://example.com/my-conda-installer.sh" installation-dir: "/opt/custom-conda" ``` -------------------------------- ### Complex Workflow Example Source: https://github.com/conda-incubator/setup-miniconda/blob/main/_autodocs/00-README.md Illustrates an advanced configuration of the setup-miniconda action, specifying versions, environment files, and enabling mamba. ```yaml - uses: conda-incubator/setup-miniconda@v3 with: miniforge-version: latest # Use Miniforge environment-file: environment.yml # YAML env spec python-version: "3.11" # Override Python mamba-version: "*" # Install mamba use-mamba: true # Use mamba immediately conda-build-version: "3.28" # Install conda-build channels: "conda-forge, defaults" # Configure channels ``` -------------------------------- ### IInstallerResult Interface Source: https://github.com/conda-incubator/setup-miniconda/blob/main/_autodocs/03-types-and-interfaces.md Represents the output of an installer selection process, containing updated options and the local installer path. ```APIDOC ## Interface: `IInstallerResult` ### Description Represents the output of an installer selection process, containing updated options and the local installer path. ### Fields #### `options` - **Type**: `IDynamicOptions` - **Description**: Updated options (e.g., mamba detected) #### `localInstallerPath` - **Type**: `string` - **Description**: Local file path to the installer ``` -------------------------------- ### Miniforge Installer Filename Pattern Source: https://github.com/conda-incubator/setup-miniconda/blob/main/_autodocs/05-installer-module.md Defines the standard naming convention for Miniforge installer files, including variant, version, OS, and architecture. ```text {Variant}-{version}-{OS}-{ARCH}.{ext} ``` -------------------------------- ### Install Explicit Environments with Lockfiles Source: https://github.com/conda-incubator/setup-miniconda/blob/main/README.md Set up an environment using an explicit lockfile (e.g., from `conda list --explicit` or `conda-lock`). This method skips the solver step for faster installations but results in non-cross-platform environments that can break if files become unavailable. ```yaml jobs: example-7: name: Ex7 Explicit runs-on: "ubuntu-latest" defaults: run: shell: bash -el {0} steps: - uses: actions/checkout@v6 - uses: conda-incubator/setup-miniconda@v4 with: auto-update-conda: false activate-environment: explicit-env environment-file: etc/example-explicit.conda.lock - run: | conda info conda list conda config --show-sources conda config --show printenv | sort ``` -------------------------------- ### Batch Install Multiple Tools with Conda Source: https://github.com/conda-incubator/setup-miniconda/blob/main/_autodocs/07-base-tools-module.md Installs multiple tools like Python, Mamba, and conda-build in a single dependency resolution step. This is recommended for faster and more consistent installations. ```bash conda install --name base python=3.11 conda=23.11.2 mamba=1.5.0 conda-build=3.28 ``` -------------------------------- ### Local Installer Options Interface Source: https://github.com/conda-incubator/setup-miniconda/blob/main/_autodocs/05-installer-module.md TypeScript interface defining the structure for local installer options, used for building cache keys and tracking metadata. ```typescript interface ILocalInstallerOpts { url: string; // Download URL tool?: string; // Tool name (miniconda, miniforge) version?: string; // Version for cache key arch?: string; // Architecture for cache key } ``` -------------------------------- ### Activate Environment: Create and Use 'test' Source: https://github.com/conda-incubator/setup-miniconda/blob/main/_autodocs/10-configuration.md Specifies the name of the environment to create and activate. This example creates an environment named 'test'. ```yaml with: activate-environment: "test" # Creates ~/miniconda3/envs/test ``` -------------------------------- ### Install Mamba and Conda-Build Source: https://github.com/conda-incubator/setup-miniconda/blob/main/_autodocs/07-base-tools-module.md Install Mamba and Conda-Build to specific versions. Use '*' for the latest available version of Mamba. ```yaml - uses: conda-incubator/setup-miniconda@v3 with: mamba-version: "*" conda-build-version: "3.28" ``` -------------------------------- ### Install or Update Mamba Version Source: https://github.com/conda-incubator/setup-miniconda/blob/main/_autodocs/10-configuration.md Use `mamba-version` to install or update Mamba. The `"*"` value installs the latest available version. This can be combined with `use-mamba: true` to use Mamba immediately. ```yaml with: mamba-version: "*" use-mamba: true ``` ```yaml with: mamba-version: "1.5.0" ``` -------------------------------- ### getLocalInstallerPath Source: https://github.com/conda-incubator/setup-miniconda/blob/main/_autodocs/05-installer-module.md Iterates through installer providers to find and return the path of the first matching installer, along with updated options. It tries bundled, URL, Miniforge, and Miniconda providers in a specific order. ```APIDOC ## Function: getLocalInstallerPath ### Description Iterate through installer providers and return result from the first one that matches the given inputs and options. ### Parameters #### Path Parameters - **inputs** (`IActionInputs`) - Required - Parsed action inputs - **options** (`IDynamicOptions`) - Required - Current dynamic options ### Returns `Promise` — Installer path and updated options ### Throws `Error` with message "No installer could be found for the given inputs" ### Example ```typescript const installerInfo = await getLocalInstallerPath(inputs, options); console.log(`Installer: ${installerInfo.localInstallerPath}`); console.log(`Using bundled: ${installerInfo.options.useBundled}`); ``` ``` -------------------------------- ### Build Conda Install Specification Source: https://github.com/conda-incubator/setup-miniconda/blob/main/_autodocs/08-utilities-module.md Constructs a list of package specifications for Conda installation, including specific versions and latest versions. This is a prerequisite for executing Conda install commands. ```typescript const specs = [ makeSpec("python", inputs.pythonVersion), makeSpec("numpy", ">=1.20"), "pandas" // Latest version ]; await execute(["conda", "install", ...specs]); ``` -------------------------------- ### Setup Miniconda with Environment File Source: https://github.com/conda-incubator/setup-miniconda/blob/main/_autodocs/06-environment-module.md Use this snippet to set up a Miniconda environment based on a lock file. ```yaml - uses: conda-incubator/setup-miniconda@v3 with: environment-file: conda-lock.txt ``` -------------------------------- ### Define Installer Provider Interface Source: https://github.com/conda-incubator/setup-miniconda/blob/main/_autodocs/03-types-and-interfaces.md Defines the interface for strategies that ensure a locally-runnable conda installer. It includes methods to check applicability and retrieve the installer path. ```typescript export interface IInstallerProvider { label: string; provides: ( inputs: IActionInputs, options: IDynamicOptions, ) => Promise; installerPath: ( inputs: IActionInputs, options: IDynamicOptions, ) => Promise; } ``` -------------------------------- ### Use Environment File: Explicit Lockfile Example Source: https://github.com/conda-incubator/setup-miniconda/blob/main/_autodocs/10-configuration.md Specifies an explicit lockfile for environment configuration. This example uses 'conda-lock.txt' which lists exact package URLs. ```yaml @EXPLICIT # platform: linux-64 https://conda.anaconda.org/conda-forge/linux-64/python-3.11.8-hd12c33a_0_cpython.tar.bz2 ``` ```yaml with: environment-file: conda-lock.txt ``` -------------------------------- ### Miniconda Installer Filename Pattern Source: https://github.com/conda-incubator/setup-miniconda/blob/main/_autodocs/05-installer-module.md Defines the standard naming convention for Miniconda installer files, including version, OS, and architecture. ```text Miniconda3-{version}-{OS}-{ARCH}.{ext} ``` -------------------------------- ### Build Installer Filename Source: https://github.com/conda-incubator/setup-miniconda/blob/main/_autodocs/11-constants.md Constructs the Miniconda installer filename using platform-specific constants for OS, architecture, and file extension. ```typescript const os = OS_NAMES[process.platform]; const arch = MINICONDA_ARCHITECTURES[arch]; const filename = `Miniconda3-${version}-${os}-${arch}.${IS_UNIX ? 'sh' : 'exe'}`; ``` -------------------------------- ### Activate Environment: Use Custom Path Source: https://github.com/conda-incubator/setup-miniconda/blob/main/_autodocs/10-configuration.md Specifies a custom path for the environment to be created and activated. This example uses an absolute path. ```yaml with: activate-environment: "/opt/envs/prod" # Custom path ``` -------------------------------- ### Define Operating System Mappings Source: https://github.com/conda-incubator/setup-miniconda/blob/main/_autodocs/03-types-and-interfaces.md Maps Node.js platform names to installer OS name suffixes. Ensures correct OS identification for installers. ```typescript export interface IOperatingSystems { [key: string]: string; } ``` -------------------------------- ### Install Base Tools Source: https://github.com/conda-incubator/setup-miniconda/blob/main/_autodocs/07-base-tools-module.md Installs core conda tools into the base environment using a single solve. Check the `useMamba` option after execution to determine if Mamba is available. ```typescript const updatedOptions = await installBaseTools(inputs, options); if (updatedOptions.useMamba) { console.log("Mamba is now available for conda operations"); } ``` -------------------------------- ### makeSpec Function Examples Source: https://github.com/conda-incubator/setup-miniconda/blob/main/_autodocs/07-base-tools-module.md Illustrates the usage of the `makeSpec` function with different package names and specification strings. ```typescript makeSpec("python", "3.11") // "python=3.11" makeSpec("conda", ">=23.1") // "conda>=23.1" makeSpec("mamba", "1.5|1.6") // "mamba1.5|1.6" ``` -------------------------------- ### URL Downloader Provider Result Source: https://github.com/conda-incubator/setup-miniconda/blob/main/_autodocs/05-installer-module.md Use this provider to download an installer from a custom URL. The system will attempt to cache the downloaded installer. ```typescript { localInstallerPath: "/path/to/downloaded/installer.sh", options: unchanged } ``` -------------------------------- ### Use Bundled Miniconda Source: https://github.com/conda-incubator/setup-miniconda/blob/main/_autodocs/05-installer-module.md Use the default bundled Miniconda for the fastest installation. No additional configuration is required. ```yaml # Use bundled miniconda (fastest) - uses: conda-incubator/setup-miniconda@v3 ``` -------------------------------- ### installBaseTools Source: https://github.com/conda-incubator/setup-miniconda/blob/main/_autodocs/07-base-tools-module.md Installs all requested tools (conda, mamba, Python, conda-build) into the 'base' environment in a single conda solve operation, followed by post-installation actions. ```APIDOC ## Function: installBaseTools ### Description Installs all requested tools into the `base` environment in a single solve, then runs post-install actions. This function orchestrates the collection of tool specifications from various providers, performs a batched installation using `conda install`, and executes any necessary post-installation setup. ### Parameters #### Inputs - **inputs** (`IActionInputs`) - Required - Parsed action inputs that specify which tools to install. - **options** (`IDynamicOptions`) - Required - Current dynamic options that influence the installation process. ### Returns - `Promise` — An updated options object reflecting the state after the tools have been installed. ### Process 1. **Collect tools**: Iterates through `TOOL_PROVIDERS` to determine which tools are needed based on the `inputs` and `options`. 2. **Batch install**: Executes a single `conda install` command with all collected tool specifications to ensure consistency and reduce installation time. 3. **Run post-install actions**: Calls the `postInstall` method on relevant providers for version validation and additional setup. ### Example ```typescript const updatedOptions = await installBaseTools(inputs, options); if (updatedOptions.useMamba) { console.log("Mamba is now available for conda operations"); } ``` ``` -------------------------------- ### Conda Command Generation Examples Source: https://github.com/conda-incubator/setup-miniconda/blob/main/_autodocs/06-environment-module.md Provides examples of TypeScript arrays representing Conda commands for creating or updating environments using explicit lockfiles, environment YAML files, or simple Python package specifications. ```typescript ["env", "create", "--name", "test", "--file", "/path/to/explicit.txt"] ``` ```typescript ["env", "update", "--name", "test", "--file", "environment.yml"] ``` ```typescript ["create", "--name", "test", "python=3.11"] ``` -------------------------------- ### IInstallerProvider Interface Source: https://github.com/conda-incubator/setup-miniconda/blob/main/_autodocs/03-types-and-interfaces.md Defines the strategy for ensuring a locally-runnable conda installer, including methods to check applicability and retrieve the installer path. ```APIDOC ## Interface: `IInstallerProvider` ### Description Defines the strategy for ensuring a locally-runnable conda installer. ### Methods #### `label` - **Description**: Human-readable name shown in logs #### `provides(inputs: IActionInputs, options: IDynamicOptions)` - **Description**: Returns true if this installer applies to given inputs/options - **Returns**: `Promise` #### `installerPath(inputs: IActionInputs, options: IDynamicOptions)` - **Description**: Returns local file path and updated options - **Returns**: `Promise` ``` -------------------------------- ### Setup Miniconda with Parsed Inputs Source: https://github.com/conda-incubator/setup-miniconda/blob/main/_autodocs/01-setup-and-entry-points.md Orchestrates the complete conda setup workflow using parsed inputs. Ensure inputs are parsed before calling this function. ```typescript import { setupMiniconda } from './setup'; import * as input from './input'; // Parse inputs from workflow const inputs = await input.parseInputs(); // Run the complete setup await setupMiniconda(inputs); ``` -------------------------------- ### Usage: Specify Architecture (arm64 on macOS) Source: https://github.com/conda-incubator/setup-miniconda/blob/main/_autodocs/10-configuration.md Manually specify the processor architecture for the installer, such as arm64 for ARM64 on macOS. ```yaml with: architecture: "arm64" # On macOS ``` -------------------------------- ### Usage: Specify Architecture (aarch64) Source: https://github.com/conda-incubator/setup-miniconda/blob/main/_autodocs/10-configuration.md Manually specify the processor architecture for the installer, such as aarch64 for 64-bit ARM. ```yaml with: architecture: "aarch64" ``` -------------------------------- ### Setup Miniconda with Specific Python Version Source: https://github.com/conda-incubator/setup-miniconda/blob/main/_autodocs/06-environment-module.md Create a Miniconda environment with a specified Python version without an external environment file. ```yaml - uses: conda-incubator/setup-miniconda@v3 with: python-version: 3.11 ``` -------------------------------- ### Map Node.js Platform Names to Conda OS Suffixes Source: https://github.com/conda-incubator/setup-miniconda/blob/main/_autodocs/11-constants.md Maps `process.platform` values to the corresponding OS suffixes used in conda installer filenames. Useful for dynamically constructing installer paths. ```typescript export const OS_NAMES: types.IOperatingSystems = { win32: "Windows", darwin: "MacOSX", linux: "Linux", }; ``` -------------------------------- ### Setup-Miniconda Architecture Overview Source: https://github.com/conda-incubator/setup-miniconda/blob/main/_autodocs/00-README.md Illustrates the layered module structure of the setup-miniconda action, from input parsing to environment creation and post-action cleanup. ```text Input Parsing (input.ts) ↓ Installer Selection (installer/*) → Choose installer ↓ Conda Configuration (conda.ts) → Configure conda ↓ Environment Creation (env/*) → Create/update environment ↓ Base Tools (base-tools/*) → Install tools ↓ Outputs (outputs.ts) → Set GitHub Actions outputs ↓ Post Cleanup (delete.ts) → Clean package cache ``` -------------------------------- ### Specify Python Version for Environment Source: https://github.com/conda-incubator/setup-miniconda/blob/main/_autodocs/10-configuration.md Sets the Python version for the environment being created. Requires 'activate-environment' to be set. This example specifies Python 3.11. ```yaml with: python-version: "3.11" activate-environment: "test" ``` -------------------------------- ### Usage: Miniforge-pypy3 with Specific Version Source: https://github.com/conda-incubator/setup-miniconda/blob/main/_autodocs/10-configuration.md Install a specific version of the Miniforge-pypy3 variant. ```yaml with: miniforge-variant: "Miniforge-pypy3" miniforge-version: "22.11.1" ``` -------------------------------- ### Add Pip as Python Dependency Source: https://github.com/conda-incubator/setup-miniconda/blob/main/_autodocs/10-configuration.md Set this input to 'true' to ensure that pip, wheel, and setuptools are treated as dependencies of the Python package being installed. ```yaml with: add-pip-as-python-dependency: "true" ``` -------------------------------- ### Determine Conda Base Path Source: https://github.com/conda-incubator/setup-miniconda/blob/main/_autodocs/04-conda-module.md Gets the base path of the conda installation. Use this to locate the conda executable or environment directories. ```typescript const basePath = condaBasePath(inputs, options); // Possible outputs: // "/opt/miniconda3" (bundled on Linux) // "C:\\Users\\runner\\miniconda3" (default on Windows) // "/custom/conda/path" (custom installation directory) ``` -------------------------------- ### Normalize Python Version String Source: https://github.com/conda-incubator/setup-miniconda/blob/main/_autodocs/02-input-parsing-validation.md Removes the Python version prefix (e.g., 'py311_') from installer filenames to get the core version string. This is useful for consistent version handling. ```typescript version.replace(/^py\d+_/, "") ``` -------------------------------- ### Setup Miniconda with Different Shells Source: https://github.com/conda-incubator/setup-miniconda/blob/main/README.md Demonstrates setting up Miniconda and activating an environment in various shells (Bash, PowerShell Core, Sh, Cmd.exe) across different operating systems. ```yaml jobs: example-2-linux: name: Ex2 Linux runs-on: "ubuntu-latest" steps: - uses: conda-incubator/setup-miniconda@v4 with: miniconda-version: "latest" activate-environment: foo - name: Bash shell: bash -el {0} run: | conda info conda list - name: PowerShell Core shell: pwsh run: | conda info conda list example-2-mac: name: Ex2 Mac runs-on: "macos-latest" steps: - uses: conda-incubator/setup-miniconda@v4 with: miniconda-version: "latest" activate-environment: foo - name: Sh shell: sh -l {0} run: | conda info conda list - name: Bash shell: bash -el {0} run: | conda info conda list - name: PowerShell Core shell: pwsh run: | conda info conda list example-2-win: name: Ex2 Windows runs-on: "windows-latest" steps: - uses: conda-incubator/setup-miniconda@v4 with: miniconda-version: "latest" activate-environment: foo - name: Bash shell: bash -el {0} run: | conda info conda list - name: PowerShell shell: powershell run: | conda info conda list - name: PowerShell Core shell: pwsh run: | conda info conda list - name: Cmd.exe shell: cmd /C CALL {0} run: >- conda info && conda list ``` -------------------------------- ### Accessing Setup-Miniconda Outputs Source: https://github.com/conda-incubator/setup-miniconda/blob/main/_autodocs/09-outputs-module.md Demonstrates how to access outputs like environment file path, patch status, and content from the setup-miniconda action using step ID syntax in a GitHub Actions workflow. ```yaml - id: setup uses: conda-incubator/setup-miniconda@v3 with: environment-file: environment.yml - run: | echo "Environment file: ${{ steps.setup.outputs.environment-file }}" echo "Was patched: ${{ steps.setup.outputs.environment-file-was-patched }}" echo "Content:" echo "${{ steps.setup.outputs.environment-file-content }}" ``` -------------------------------- ### Execute Installer and Detect Mamba Source: https://github.com/conda-incubator/setup-miniconda/blob/main/_autodocs/05-installer-module.md Executes a conda installer and updates options based on Mamba detection. Use this after obtaining the installer path to perform the installation and check for Mamba availability. ```typescript const options = await runInstaller( "/tmp/Miniforge3-Linux-x86_64.sh", "/opt/miniconda3", inputs, options ); if (options.useMamba) { console.log("Mamba is available and will be used"); } ``` -------------------------------- ### Usage: Custom Installation Directory Source: https://github.com/conda-incubator/setup-miniconda/blob/main/_autodocs/10-configuration.md Specify a custom directory for the conda installation when using a custom installer URL. ```yaml with: installer-url: "https://example.com/installer.sh" installation-dir: "/opt/miniconda3" ``` -------------------------------- ### Install Conda-build Version Source: https://github.com/conda-incubator/setup-miniconda/blob/main/_autodocs/10-configuration.md Specify the version of `conda-build` to install in the base environment. This is only used if explicitly set and is installed after Conda or Mamba updates. ```yaml with: conda-build-version: "3.28" ``` -------------------------------- ### Define Installer Result Interface Source: https://github.com/conda-incubator/setup-miniconda/blob/main/_autodocs/03-types-and-interfaces.md Defines the structure for the result of an installer selection process, containing the local installer path and updated options. ```typescript export interface IInstallerResult { options: IDynamicOptions; localInstallerPath: string; } ``` -------------------------------- ### Accessing Environment Outputs in Subsequent Steps Source: https://github.com/conda-incubator/setup-miniconda/blob/main/_autodocs/06-environment-module.md Demonstrates how to access the outputs set by the setup-miniconda action, such as the environment file path, in subsequent steps of a GitHub Actions workflow. This allows for dynamic configuration and verification of the created environment. ```yaml - id: setup uses: conda-incubator/setup-miniconda@v3 with: environment-file: environment.yml - run: echo "Used ${{ steps.setup.outputs.environment-file }}" ``` -------------------------------- ### Simple Python Environment Creation Source: https://github.com/conda-incubator/setup-miniconda/blob/main/_autodocs/06-environment-module.md Example of creating a minimal environment with only a specified Python version. This is useful for setting up a base environment that can have other dependencies added later. ```typescript // With python-version: 3.11 and no environment-file await ensureEnvironment(inputs, options); // Runs: conda create --name test python=3.11 ``` -------------------------------- ### Environment File Patching Example Source: https://github.com/conda-incubator/setup-miniconda/blob/main/_autodocs/09-outputs-module.md Demonstrates the transformation of an environment file when a Python version is specified. The original file is shown, followed by the patched version with the Python version added. This illustrates the action's capability to modify environment files. ```yaml dependencies: - numpy ``` ```yaml dependencies: - python=3.10 # Added by action - numpy ``` -------------------------------- ### Setup Miniconda with Custom Channels and Options Source: https://github.com/conda-incubator/setup-miniconda/blob/main/README.md Sets up Miniconda with specified channels (conda-forge, spyder-ide, defaults) and configures various conda options like channel priority, softlinks, and tarball usage. ```yaml jobs: example-4: name: Ex4 Linux runs-on: "ubuntu-latest" defaults: run: shell: bash -el {0} steps: - uses: actions/checkout@v6 - uses: conda-incubator/setup-miniconda@v4 with: activate-environment: foo python-version: 3.6 channels: conda-forge,spyder-ide allow-softlinks: true channel-priority: flexible show-channel-urls: true use-only-tar-bz2: true - run: | conda info conda list conda config --show-sources conda config --show ``` -------------------------------- ### Migrate from auto-activate-base to auto-activate Source: https://github.com/conda-incubator/setup-miniconda/blob/main/_autodocs/10-configuration.md Demonstrates how to migrate from the deprecated `auto-activate-base` input to the new `auto-activate` input for controlling default environment activation. ```yaml # Old: with: auto-activate-base: "false" # New: with: auto-activate: "false" ``` -------------------------------- ### Check if Mamba is Installed Source: https://github.com/conda-incubator/setup-miniconda/blob/main/_autodocs/04-conda-module.md Determines if a mamba executable exists within the current conda installation. This is useful for conditionally using mamba for package management. ```typescript const isMambaInstalled = isMambaInstalled(inputs, options); ``` -------------------------------- ### Activate Environment: Use Empty String for 'base' Source: https://github.com/conda-incubator/setup-miniconda/blob/main/_autodocs/10-configuration.md Uses an empty string to specify the 'base' environment, which is equivalent to using the value 'base'. No additional environment is created. ```yaml with: activate-environment: "" # Same as base ``` -------------------------------- ### Parse and Use Package Directories Source: https://github.com/conda-incubator/setup-miniconda/blob/main/_autodocs/08-utilities-module.md This example demonstrates how to parse package directories from Conda configuration and iterate through them. It's useful for inspecting or managing package cache locations. ```typescript const pkgsDirs = parsePkgsDirs(inputs.condaConfig.pkgs_dirs); for (const dir of pkgsDirs) { console.log(`Package cache: ${dir}`); } ``` -------------------------------- ### condaBasePath Source: https://github.com/conda-incubator/setup-miniconda/blob/main/_autodocs/04-conda-module.md Determines the base path of the conda installation based on provided inputs and options. It can return the path to a bundled installation, a custom directory, or the default miniconda3 path. ```APIDOC ## Function: condaBasePath ### Description Determines the base path of the conda installation. It checks for a bundled installation, a custom directory specified in inputs, or defaults to `~/miniconda3`. ### Parameters - **inputs** (`IActionInputs`) - Required - Parsed action inputs. - **options** (`IDynamicOptions`) - Required - Current dynamic options. ### Returns - `string` - Absolute path to conda base directory. ### Example ```typescript const basePath = condaBasePath(inputs, options); // Possible outputs: // "/opt/miniconda3" (bundled on Linux) // "C:\\Users\\runner\\miniconda3" (default on Windows) // "/custom/conda/path" (custom installation directory) ``` ``` -------------------------------- ### Define Dynamic Options Interface Source: https://github.com/conda-incubator/setup-miniconda/blob/main/_autodocs/03-types-and-interfaces.md Defines options that can change during the discovery, installation, and configuration phases. Includes flags for using Mamba and bundled installations, and environment specifications. ```typescript export interface IDynamicOptions { useBundled: boolean; useMamba: boolean; mambaInInstaller: boolean; envSpec?: IEnvSpec; condaConfig: TCondaConfig; } ``` -------------------------------- ### Setup Miniconda with YAML Environment File and Python Override Source: https://github.com/conda-incubator/setup-miniconda/blob/main/_autodocs/06-environment-module.md Configure a Miniconda environment using a YAML file and explicitly set the Python version. ```yaml - uses: conda-incubator/setup-miniconda@v3 with: environment-file: environment.yml python-version: 3.10 ``` -------------------------------- ### Enable Mamba Usage Source: https://github.com/conda-incubator/setup-miniconda/blob/main/_autodocs/10-configuration.md Set `use-mamba: true` to utilize Mamba as a Conda replacement for supported subcommands. Mamba must be available, either from the installer or installed via `mamba-version`. ```yaml with: miniforge-version: latest # Includes mamba use-mamba: true ``` ```yaml with: mamba-version: "*" use-mamba: true ``` -------------------------------- ### Use Mamba for Faster Installs Source: https://github.com/conda-incubator/setup-miniconda/blob/main/README.md Configure the action to use Mamba for significantly faster package installations. Requires specifying 'conda-forge' as a channel with high priority. Note that recent conda versions (23.10+) include a mamba-like solver by default. ```yaml jobs: example-6: name: Ex6 Mamba runs-on: "ubuntu-latest" steps: - uses: actions/checkout@v6 - uses: conda-incubator/setup-miniconda@v4 with: python-version: 3.6 mamba-version: "*" channels: conda-forge,defaults channel-priority: true activate-environment: anaconda-client-env environment-file: etc/example-environment.yml - shell: bash -el {0} run: | conda info conda list conda config --show-sources conda config --show printenv | sort - shell: bash -el {0} run: mamba install jupyterlab ``` -------------------------------- ### Ensure Environment Creation or Update Source: https://github.com/conda-incubator/setup-miniconda/blob/main/_autodocs/06-environment-module.md Creates or updates the target environment using the first matching provider from a list including explicit lockfiles, simple Python versions, and YAML files. Throws an error if no provider matches. ```typescript try { await ensureEnvironment(inputs, options); console.log(`Environment '${inputs.activateEnvironment}' ready`); } catch (error) { console.error(`Failed to create environment: ${error.message}`); } ``` -------------------------------- ### isMambaInstalled Source: https://github.com/conda-incubator/setup-miniconda/blob/main/_autodocs/04-conda-module.md Checks whether the mamba executable exists in the current installation. ```APIDOC ## Function: `isMambaInstalled(inputs: IActionInputs, options: IDynamicOptions): boolean` ### Description Check whether mamba executable exists in the current installation. ### Parameters #### Path Parameters - **inputs** (`IActionInputs`) - Required - Parsed action inputs - **options** (`IDynamicOptions`) - Required - Current dynamic options ### Returns `boolean` — True if mamba found at any candidate location ``` -------------------------------- ### Usage: Latest Miniconda Version Source: https://github.com/conda-incubator/setup-miniconda/blob/main/_autodocs/10-configuration.md Download and install the latest available version of Miniconda3. ```yaml with: miniconda-version: "latest" ``` -------------------------------- ### Usage: Miniforge-pypy3 Variant Source: https://github.com/conda-incubator/setup-miniconda/blob/main/_autodocs/10-configuration.md Install the Miniforge-pypy3 variant, which uses a PyPy interpreter with conda-forge packages. ```yaml with: miniforge-variant: "Miniforge-pypy3" ``` -------------------------------- ### Install Miniconda for Alternative Architectures (Windows x86) Source: https://github.com/conda-incubator/setup-miniconda/blob/main/README.md Set up Miniconda for alternative architectures, specifically targeting 32-bit (x86) builds on Windows. Note that older x86 builds for Linux and macOS are not supported by this action. ```yaml jobs: example-11: name: Ex11 (os=${{ matrix.os }} architecture=${{ matrix.architecture }} miniconda-version=${{ matrix.miniconda-version }}) runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: os: ["windows-latest"] architecture: ["x86"] miniconda-version: ["latest"] steps: - uses: actions/checkout@v6 - uses: conda-incubator/setup-miniconda@v4 with: architecture: ${{ matrix.architecture }} miniconda-version: $${{ matrix.miniconda-version }} auto-update-conda: true python-version: "3.8" ``` -------------------------------- ### Setup Miniconda with Environment File and Condarc Source: https://github.com/conda-incubator/setup-miniconda/blob/main/README.md Configures Miniconda using an environment file for environment creation and a condarc file for fine-grained configuration. Disables auto-activation of the base environment. ```yaml jobs: example-3: name: Ex3 Linux runs-on: "ubuntu-latest" defaults: run: shell: bash -el {0} steps: - uses: actions/checkout@v6 - uses: conda-incubator/setup-miniconda@v4 with: activate-environment: anaconda-client-env environment-file: etc/example-environment.yml python-version: 3.5 condarc-file: etc/example-condarc.yml auto-activate: false - run: | conda info conda list ```