Skip to content

Commit

Permalink
Enable ARM64 on macOS for Miniforge and Mambaforge. (#331)
Browse files Browse the repository at this point in the history
  • Loading branch information
jezdez authored Feb 22, 2024
1 parent 2946f44 commit 392cf34
Show file tree
Hide file tree
Showing 7 changed files with 140 additions and 12 deletions.
75 changes: 75 additions & 0 deletions .github/workflows/example-13.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: "Example 13: Apple Silicon"

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

jobs:
example-13:
# prevent cronjobs from running on forks
if:
(github.event_name == 'schedule' && github.repository ==
'conda-incubator/setup-miniconda') || (github.event_name != 'schedule')
name: Ex13 (os=${{ matrix.os }} variant=${{ matrix.variant }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: ["macos-14"]
variant: ["Miniforge3", "Mambaforge", "Miniconda", "no-variant"]
steps:
- uses: actions/checkout@v4
- uses: ./
if: matrix.variant == 'Miniforge3' || matrix.variant == 'Mambaforge'
id: setup-miniforge
continue-on-error: true
with:
auto-update-conda: true
architecture: arm64
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-miniconda2
continue-on-error: true
with:
miniforge-version: latest
- 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 != 'Miniconda'
shell: bash -el {0}
run: mamba --version
- name: Install Python
shell: bash -el {0}
run: conda install -y python
- name: Check arm64
shell: bash -el {0}
run: |
python -c "import platform; assert platform.machine() == 'arm64', platform.machine()"
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
# CHANGELOG

## [v3.0.2] (2024-02-22)

### Fixes

- [#312] Enable ARM64 on macOS for Miniforge and Mambaforge including automatic
architecture detection.

### Tasks and Maintenance

- [#327] Bump conda-incubator/setup-miniconda from 3.0.0 to 3.0.1
- [#330] Bump actions/cache from 3 to 4
- [#334] Bump undici from 5.27.2 to 5.28.3

[v3.0.2]: https://github.com/conda-incubator/setup-miniconda/releases/tag/v3.0.2
[#312]: https://github.com/conda-incubator/setup-miniconda/pull/312
[#327]: https://github.com/conda-incubator/setup-miniconda/pull/327
[#330]: https://github.com/conda-incubator/setup-miniconda/pull/330
[#334]: https://github.com/conda-incubator/setup-miniconda/pull/334

## [v3.0.1] (2023-11-29)

### Fixes
Expand Down
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ possibility of automatically activating the `test` environment on all shells.
| [Configure conda solver](#example-12-configure-conda-solver) | [![Configure conda solver][ex12-badge]][ex12] |
| [Caching packages](#caching-packages) | [![Caching Example Status][caching-badge]][caching] |
| [Caching environments](#caching-environments) | [![Caching Env Example Status][caching-env-badge]][caching-env] |
| [Apple Silicon](#example-13-apple-silicon) | [![Apple Silicon][ex13-badge]][ex13] |

[ex1]:
https://github.com/conda-incubator/setup-miniconda/actions/workflows/example-1.yml
Expand Down Expand Up @@ -107,6 +108,10 @@ possibility of automatically activating the `test` environment on all shells.
https://github.com/conda-incubator/setup-miniconda/actions/workflows/example-12.yml
[ex12-badge]:
https://github.com/conda-incubator/setup-miniconda/actions/workflows/example-12.yml/badge.svg?branch=main
[ex13]:
https://github.com/conda-incubator/setup-miniconda/actions/workflows/example-13.yml
[ex13-badge]:
https://github.com/conda-incubator/setup-miniconda/actions/workflows/example-13.yml/badge.svg?branch=main

## Other Workflows

Expand Down Expand Up @@ -596,6 +601,31 @@ jobs:
python-version: "3.9"
```

### Example 13: Apple Silicon

```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@v4
- uses: ./
id: setup-miniconda
continue-on-error: true
with:
miniconda-version: latest
- name: Check arm64
shell: bash -el {0}
run: |
conda install -y python
python -c "import platform; assert platform.machine() == 'arm64', platform.machine()"
```

## Caching

### Caching packages
Expand Down
7 changes: 4 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -242,10 +242,11 @@ inputs:
default: "libmamba"
architecture:
description:
'Architecture of Miniconda that should be installed. Default is "x64". The
CPU architecture of the runner is not detected by the workflow.'
'Architecture of Miniconda that should be installed. This is automatically
detected by the runner. If you want to override it, you can use "x64",
"x86", "arm64", "aarch64", "s390x".'
required: false
default: "x64"
default: ""
clean-patched-environment-file:
description:
"Whether a patched environment-file (if created) should be cleaned"
Expand Down
9 changes: 5 additions & 4 deletions dist/setup/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -48605,8 +48605,6 @@ const RULES = [
(i) => !!(i.installerUrl &&
!constants.KNOWN_EXTENSIONS.includes(urlExt(i.installerUrl))) &&
`'installer-url' extension '${urlExt(i.installerUrl)}' must be one of: ${constants.KNOWN_EXTENSIONS}`,
(i) => !!(!i.minicondaVersion && i.architecture !== "x64") &&
`'architecture: ${i.architecture}' requires "miniconda-version"`,
(i) => !!(i.architecture === "x86" && !constants.IS_WINDOWS) &&
`'architecture: ${i.architecture}' is only available for recent versions on Windows`,
(i) => !!(!["latest", ""].includes(i.minicondaVersion) &&
Expand All @@ -48620,7 +48618,7 @@ function parseInputs() {
return __awaiter(this, void 0, void 0, function* () {
const inputs = Object.freeze({
activateEnvironment: core.getInput("activate-environment"),
architecture: core.getInput("architecture"),
architecture: core.getInput("architecture") || process.arch,
condaBuildVersion: core.getInput("conda-build-version"),
condaConfigFile: core.getInput("condarc-file"),
condaVersion: core.getInput("conda-version"),
Expand Down Expand Up @@ -48665,6 +48663,9 @@ function parseInputs() {
if (errors.length) {
throw Error(`${errors.length} errors found in action inputs`);
}
if (core.isDebug()) {
core.info(JSON.stringify(inputs));
}
return inputs;
});
}
Expand Down Expand Up @@ -49009,7 +49010,7 @@ function downloadMiniforge(inputs, options) {
return __awaiter(this, void 0, void 0, function* () {
const tool = inputs.miniforgeVariant.trim() || constants.MINIFORGE_DEFAULT_VARIANT;
const version = inputs.miniforgeVersion.trim() || constants.MINIFORGE_DEFAULT_VERSION;
const arch = constants.MINIFORGE_ARCHITECTURES[inputs.architecture];
const arch = constants.MINIFORGE_ARCHITECTURES[inputs.architecture.toLowerCase()];
// Check valid arch
if (!arch) {
throw new Error(`Invalid 'architecture: ${inputs.architecture}'`);
Expand Down
9 changes: 5 additions & 4 deletions src/input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,6 @@ const RULES: IRule[] = [
`'installer-url' extension '${urlExt(i.installerUrl)}' must be one of: ${
constants.KNOWN_EXTENSIONS
}`,
(i) =>
!!(!i.minicondaVersion && i.architecture !== "x64") &&
`'architecture: ${i.architecture}' requires "miniconda-version"`,
(
i, // Miniconda x86 is only published for Windows lately (last Linux was 2019, last MacOS 2015)
) =>
Expand All @@ -84,7 +81,7 @@ const RULES: IRule[] = [
export async function parseInputs(): Promise<types.IActionInputs> {
const inputs: types.IActionInputs = Object.freeze({
activateEnvironment: core.getInput("activate-environment"),
architecture: core.getInput("architecture"),
architecture: core.getInput("architecture") || process.arch,
condaBuildVersion: core.getInput("conda-build-version"),
condaConfigFile: core.getInput("condarc-file"),
condaVersion: core.getInput("conda-version"),
Expand Down Expand Up @@ -136,5 +133,9 @@ export async function parseInputs(): Promise<types.IActionInputs> {
throw Error(`${errors.length} errors found in action inputs`);
}

if (core.isDebug()) {
core.info(JSON.stringify(inputs));
}

return inputs;
}
3 changes: 2 additions & 1 deletion src/installer/download-miniforge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ export async function downloadMiniforge(
inputs.miniforgeVariant.trim() || constants.MINIFORGE_DEFAULT_VARIANT;
const version =
inputs.miniforgeVersion.trim() || constants.MINIFORGE_DEFAULT_VERSION;
const arch = constants.MINIFORGE_ARCHITECTURES[inputs.architecture];
const arch =
constants.MINIFORGE_ARCHITECTURES[inputs.architecture.toLowerCase()];

// Check valid arch
if (!arch) {
Expand Down

0 comments on commit 392cf34

Please sign in to comment.