Skip to content

Commit

Permalink
Detect and support Linux ARM runners for both Miniconda and Miniforge (
Browse files Browse the repository at this point in the history
…#387)

Co-authored-by: Travis Hathaway <travis.j.hathaway@gmail.com>
Co-authored-by: Jannis Leidel <jannis@leidel.info>
  • Loading branch information
3 people authored Jan 20, 2025
1 parent 254deea commit 7611e53
Show file tree
Hide file tree
Showing 8 changed files with 135 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/example-13.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
miniconda-version: latest
- uses: ./
if: matrix.variant == 'no-variant'
id: setup-miniconda-no-variant
id: setup-miniforge-no-variant
continue-on-error: true
with:
miniforge-version: latest
Expand Down
78 changes: 78 additions & 0 deletions .github/workflows/example-15.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: "Example 15: Linux ARM"

on:
pull_request:
branches:
- "*"
push:
branches:
- "develop"
- "main"
- "master"
schedule:
# Note that cronjobs run on master/main by default
- cron: "0 0 * * *"

jobs:
example-15:
# prevent cronjobs from running on forks
if:
(github.event_name == 'schedule' && github.repository ==
'conda-incubator/setup-miniconda') || (github.event_name != 'schedule')
name: Ex15 (os=${{ matrix.os }} variant=${{ matrix.variant }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: ["ubuntu-24.04-arm"]
variant: ["Miniforge3", "Miniconda", "no-variant", "empty-with"]
steps:
- uses: actions/checkout@v4
- uses: ./
if: matrix.variant == 'Miniforge3'
id: setup-miniforge
continue-on-error: true
with:
auto-update-conda: true
miniforge-variant: ${{ matrix.variant }}
miniforge-version: latest
- uses: ./
if: matrix.variant == 'Miniconda'
id: setup-miniconda
continue-on-error: true
with:
auto-update-conda: true
miniconda-version: latest
- uses: ./
if: matrix.variant == 'no-variant'
id: setup-miniforge-no-variant
continue-on-error: true
with:
miniforge-version: latest
- uses: ./
if: matrix.variant == 'empty-with'
id: setup-miniconda-empty-with
continue-on-error: true
- name: Conda info
shell: bash -el {0}
run: conda info
- name: Conda list
shell: bash -el {0}
run: conda list
- name: Environment
shell: bash -el {0}
run: printenv | sort
- name: Create an environment
shell: bash -el {0}
run: conda create -n unused --dry-run zlib
- name: Run mamba
if: matrix.variant == 'Miniforge3'
shell: bash -el {0}
run: mamba --version
- name: Install Python
shell: bash -el {0}
run: conda install -y python
- name: Check architecture
shell: bash -el {0}
run: |
python -c "import platform; assert platform.machine() == 'aarch64', platform.machine()"
34 changes: 32 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ possibility of automatically activating the `test` environment on all shells.
| [Caching environments](#caching-environments) | [![Caching Env Example Status][caching-env-badge]][caching-env] |
| [Apple Silicon](#example-13-apple-silicon) | [![Apple Silicon][ex13-badge]][ex13] |
| [Remove defaults](#example-14-remove-defaults-channel) | [![Remove defaults][ex14-badge]][ex14] |
| [Linux ARM](#example-15-linux-arm) | [![Linux ARM][ex15-badge]][ex15] |

[ex1]:
https://github.com/conda-incubator/setup-miniconda/actions/workflows/example-1.yml
Expand Down Expand Up @@ -117,6 +118,10 @@ possibility of automatically activating the `test` environment on all shells.
https://github.com/conda-incubator/setup-miniconda/actions/workflows/example-14.yml
[ex14-badge]:
https://github.com/conda-incubator/setup-miniconda/actions/workflows/example-14.yml/badge.svg?branch=main
[ex15]:
https://github.com/conda-incubator/setup-miniconda/actions/workflows/example-15.yml
[ex15-badge]:
https://github.com/conda-incubator/setup-miniconda/actions/workflows/example-15.yml/badge.svg?branch=main

## Other Workflows

Expand Down Expand Up @@ -595,10 +600,10 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: ./
id: setup-miniconda
id: setup-miniforge
continue-on-error: true
with:
miniconda-version: latest
miniforge-version: latest
- name: Check arm64
shell: bash -el {0}
run: |
Expand Down Expand Up @@ -635,6 +640,31 @@ jobs:
conda config --show-sources
```

### Example 15: Linux ARM

```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@v4
- uses: ./
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()"
```

## Caching

### Caching packages
Expand Down
11 changes: 8 additions & 3 deletions dist/delete/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 8 additions & 7 deletions dist/setup/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ export const MINICONDA_ARCHITECTURES: types.IArchitectures = {
export const MINIFORGE_ARCHITECTURES: types.IArchitectures = {
x64: "x86_64",
x86_64: "x86_64",
aarch64: "aarch64", // To be supported by github runners
aarch64: "aarch64",
ppc64le: "ppc64le", // To be supported by github runners
arm64: "arm64", // To be supported by github runners
arm64: "arm64",
};

export const OS_NAMES: types.IOperatingSystems = {
Expand Down
7 changes: 6 additions & 1 deletion src/input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,14 @@ const RULES: IRule[] = [
* Parse, validate, and normalize string-ish inputs from a workflow action's `with`
*/
export async function parseInputs(): Promise<types.IActionInputs> {
let arch = core.getInput("architecture") || process.arch;
if (arch === "arm64" && constants.IS_LINUX) {
// https://github.com/conda-incubator/setup-miniconda/issues/385
arch = "aarch64";
}
const inputs: types.IActionInputs = Object.freeze({
activateEnvironment: core.getInput("activate-environment"),
architecture: core.getInput("architecture") || process.arch,
architecture: arch,
condaBuildVersion: core.getInput("conda-build-version"),
condaConfigFile: core.getInput("condarc-file"),
condaVersion: core.getInput("conda-version"),
Expand Down
4 changes: 0 additions & 4 deletions src/installer/download-miniconda.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,6 @@ export async function downloadMiniconda(
if (!arch) {
throw new Error(`Invalid arch "${inputs.architecture}"!`);
}
// Backwards compatibility: ARM64 used to map to aarch64
if (arch === "arm64" && constants.IS_LINUX) {
arch = constants.MINICONDA_ARCHITECTURES["aarch64"];
}

let extension: string = constants.IS_UNIX ? "sh" : "exe";
let osName: string = constants.OS_NAMES[process.platform];
Expand Down

0 comments on commit 7611e53

Please sign in to comment.