Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add MacOS m1 Runner & move target aarch64 to this runner #2001

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions guide/src/distribution.md
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ Options:
- linux: Linux
- windows: Windows
- macos: macOS
- macosarm64: macOS(Arm64)
- emscripten: Emscripten

--pytest
Expand Down
146 changes: 131 additions & 15 deletions src/ci.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,18 @@ pub enum Platform {
Macos,
/// Emscripten
Emscripten,
/// macOS(Arm64)
MacosArm64,
}

impl Platform {
fn defaults() -> Vec<Self> {
vec![Platform::Linux, Platform::Windows, Platform::Macos]
vec![
Platform::Linux,
Platform::Windows,
Platform::Macos,
Platform::MacosArm64,
]
}

fn all() -> Vec<Self> {
Expand All @@ -45,6 +52,7 @@ impl Platform {
Platform::Windows,
Platform::Macos,
Platform::Emscripten,
Platform::MacosArm64,
]
}
}
Expand All @@ -57,6 +65,7 @@ impl fmt::Display for Platform {
Platform::Windows => write!(f, "windows"),
Platform::Macos => write!(f, "macos"),
Platform::Emscripten => write!(f, "emscripten"),
Platform::MacosArm64 => write!(f, "macosarm64"),
}
}
}
Expand All @@ -79,7 +88,7 @@ pub struct GenerateCI {
long,
action = ArgAction::Append,
num_args = 1..,
default_values_t = vec![Platform::Linux, Platform::Windows, Platform::Macos],
default_values_t = vec![Platform::Linux, Platform::Windows, Platform::Macos, Platform::MacosArm64],
)]
pub platforms: Vec<Platform>,
/// Enable pytest
Expand All @@ -96,7 +105,12 @@ impl Default for GenerateCI {
ci: Provider::GitHub,
manifest_path: None,
output: PathBuf::from("-"),
platforms: vec![Platform::Linux, Platform::Windows, Platform::Macos],
platforms: vec![
Platform::Linux,
Platform::Windows,
Platform::Macos,
Platform::MacosArm64,
],
pytest: false,
zig: false,
}
Expand Down Expand Up @@ -210,21 +224,30 @@ jobs:\n",
if bridge_model.is_bin() && matches!(platform, Platform::Emscripten) {
continue;
}
let plat_name = platform.to_string();
let plat_name = match platform {
Platform::MacosArm64 => "macos_arm64".to_string(),
_ => platform.to_string(),
};
let tag_name = match platform {
Platform::MacosArm64 => "14".to_string(),
_ => "latest".to_string(),
};
let os_name = match platform {
Platform::Linux | Platform::Emscripten => "ubuntu",
Platform::Macos | Platform::MacosArm64 => "macos",
_ => &plat_name,
};
needs.push(platform.to_string());
needs.push(plat_name.clone());
conf.push_str(&format!(
" {plat_name}:
runs-on: {os_name}-latest\n"
runs-on: {os_name}-{tag_name}\n"
));
// target matrix
let targets = match platform {
Platform::Linux => vec!["x86_64", "x86", "aarch64", "armv7", "s390x", "ppc64le"],
Platform::Windows => vec!["x64", "x86"],
Platform::Macos => vec!["x86_64", "aarch64"],
Platform::Macos => vec!["x86_64"],
Platform::MacosArm64 => vec!["aarch64"],
_ => Vec::new(),
};
if !targets.is_empty() {
Expand Down Expand Up @@ -590,7 +613,7 @@ mod tests {
runs-on: macos-latest
strategy:
matrix:
target: [x86_64, aarch64]
target: [x86_64]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
Expand All @@ -608,6 +631,28 @@ mod tests {
name: wheels-macos-${{ matrix.target }}
path: dist

macos_arm64:
runs-on: macos-14
strategy:
matrix:
target: [aarch64]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.target }}
args: --release --out dist --find-interpreter
sccache: 'true'
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-macosarm64-${{ matrix.target }}
path: dist

sdist:
runs-on: ubuntu-latest
steps:
Expand All @@ -627,7 +672,7 @@ mod tests {
name: Release
runs-on: ubuntu-latest
if: "startsWith(github.ref, 'refs/tags/')"
needs: [linux, windows, macos, sdist]
needs: [linux, windows, macos, macos_arm64, sdist]
steps:
- uses: actions/download-artifact@v4
- name: Publish to PyPI
Expand Down Expand Up @@ -716,7 +761,7 @@ mod tests {
runs-on: macos-latest
strategy:
matrix:
target: [x86_64, aarch64]
target: [x86_64]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
Expand All @@ -734,11 +779,33 @@ mod tests {
name: wheels-macos-${{ matrix.target }}
path: dist

macos_arm64:
runs-on: macos-14
strategy:
matrix:
target: [aarch64]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.target }}
args: --release --out dist
sccache: 'true'
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-macosarm64-${{ matrix.target }}
path: dist

release:
name: Release
runs-on: ubuntu-latest
if: "startsWith(github.ref, 'refs/tags/')"
needs: [linux, windows, macos]
needs: [linux, windows, macos, macos_arm64]
steps:
- uses: actions/download-artifact@v4
- name: Publish to PyPI
Expand Down Expand Up @@ -867,7 +934,7 @@ mod tests {
runs-on: macos-latest
strategy:
matrix:
target: [x86_64, aarch64]
target: [x86_64]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
Expand All @@ -893,6 +960,36 @@ mod tests {
pip install pytest
pytest

macos_arm64:
runs-on: macos-14
strategy:
matrix:
target: [aarch64]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.target }}
args: --release --out dist --find-interpreter
sccache: 'true'
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-macosarm64-${{ matrix.target }}
path: dist
- name: pytest
if: ${{ !startsWith(matrix.target, 'aarch64') }}
shell: bash
run: |
set -e
pip install example --find-links dist --force-reinstall
pip install pytest
pytest

sdist:
runs-on: ubuntu-latest
steps:
Expand All @@ -912,7 +1009,7 @@ mod tests {
name: Release
runs-on: ubuntu-latest
if: "startsWith(github.ref, 'refs/tags/')"
needs: [linux, windows, macos, sdist]
needs: [linux, windows, macos, macos_arm64, sdist]
steps:
- uses: actions/download-artifact@v4
- name: Publish to PyPI
Expand Down Expand Up @@ -994,7 +1091,7 @@ mod tests {
runs-on: macos-latest
strategy:
matrix:
target: [x86_64, aarch64]
target: [x86_64]
steps:
- uses: actions/checkout@v4
- name: Build wheels
Expand All @@ -1009,6 +1106,25 @@ mod tests {
name: wheels-macos-${{ matrix.target }}
path: dist

macos_arm64:
runs-on: macos-14
strategy:
matrix:
target: [aarch64]
steps:
- uses: actions/checkout@v4
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.target }}
args: --release --out dist
sccache: 'true'
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-macosarm64-${{ matrix.target }}
path: dist

sdist:
runs-on: ubuntu-latest
steps:
Expand All @@ -1028,7 +1144,7 @@ mod tests {
name: Release
runs-on: ubuntu-latest
if: "startsWith(github.ref, 'refs/tags/')"
needs: [linux, windows, macos, sdist]
needs: [linux, windows, macos, macos_arm64, sdist]
steps:
- uses: actions/download-artifact@v4
- name: Publish to PyPI
Expand Down
3 changes: 2 additions & 1 deletion tests/cmd/generate-ci.stdout
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,15 @@ Options:
--platform <platform>...
Platform support

[default: linux windows macos]
[default: linux windows macos macosarm64]

Possible values:
- all: All
- linux: Linux
- windows: Windows
- macos: macOS
- emscripten: Emscripten
- macosarm64: macOS(Arm64)

--pytest
Enable pytest
Expand Down