From 1921c58e3ed1c28b4274a6143f3bbc27142f0c14 Mon Sep 17 00:00:00 2001 From: Owen Leung Date: Thu, 21 Mar 2024 11:23:53 +0800 Subject: [PATCH 1/2] Update ci.rs --- src/ci.rs | 37 ++++++++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/src/ci.rs b/src/ci.rs index 0dd23e40c..cec33873a 100644 --- a/src/ci.rs +++ b/src/ci.rs @@ -32,11 +32,18 @@ pub enum Platform { Macos, /// Emscripten Emscripten, + /// macOSM1 + MacosM1, } impl Platform { fn defaults() -> Vec { - vec![Platform::Linux, Platform::Windows, Platform::Macos] + vec![ + Platform::Linux, + Platform::Windows, + Platform::Macos, + Platform::MacosM1, + ] } fn all() -> Vec { @@ -45,6 +52,7 @@ impl Platform { Platform::Windows, Platform::Macos, Platform::Emscripten, + Platform::MacosM1, ] } } @@ -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::MacosM1 => write!(f, "macos"), } } } @@ -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::MacosM1], )] pub platforms: Vec, /// Enable pytest @@ -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::MacosM1, + ], pytest: false, zig: false, } @@ -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::MacosM1 => "macos_m1".to_string(), + _ => platform.to_string(), + }; + let tag_name = match platform { + Platform::MacosM1 => "14".to_string(), + _ => "latest".to_string(), + }; let os_name = match platform { Platform::Linux | Platform::Emscripten => "ubuntu", + Platform::Macos | Platform::MacosM1 => "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::MacosM1 => vec!["aarch64"], _ => Vec::new(), }; if !targets.is_empty() { From 152437ea0535430c182533583a32d0ab0c305618 Mon Sep 17 00:00:00 2001 From: Owen Leung Date: Thu, 21 Mar 2024 15:21:27 +0800 Subject: [PATCH 2/2] fix failing CI, Rename MacosM1 to MacosArm64 --- guide/src/distribution.md | 1 + src/ci.rs | 131 ++++++++++++++++++++++++++++++----- tests/cmd/generate-ci.stdout | 3 +- 3 files changed, 115 insertions(+), 20 deletions(-) diff --git a/guide/src/distribution.md b/guide/src/distribution.md index e0c1b899e..8b93cf7ec 100644 --- a/guide/src/distribution.md +++ b/guide/src/distribution.md @@ -281,6 +281,7 @@ Options: - linux: Linux - windows: Windows - macos: macOS + - macosarm64: macOS(Arm64) - emscripten: Emscripten --pytest diff --git a/src/ci.rs b/src/ci.rs index cec33873a..82fb7a02b 100644 --- a/src/ci.rs +++ b/src/ci.rs @@ -32,8 +32,8 @@ pub enum Platform { Macos, /// Emscripten Emscripten, - /// macOSM1 - MacosM1, + /// macOS(Arm64) + MacosArm64, } impl Platform { @@ -42,7 +42,7 @@ impl Platform { Platform::Linux, Platform::Windows, Platform::Macos, - Platform::MacosM1, + Platform::MacosArm64, ] } @@ -52,7 +52,7 @@ impl Platform { Platform::Windows, Platform::Macos, Platform::Emscripten, - Platform::MacosM1, + Platform::MacosArm64, ] } } @@ -65,7 +65,7 @@ impl fmt::Display for Platform { Platform::Windows => write!(f, "windows"), Platform::Macos => write!(f, "macos"), Platform::Emscripten => write!(f, "emscripten"), - Platform::MacosM1 => write!(f, "macos"), + Platform::MacosArm64 => write!(f, "macosarm64"), } } } @@ -88,7 +88,7 @@ pub struct GenerateCI { long, action = ArgAction::Append, num_args = 1.., - default_values_t = vec![Platform::Linux, Platform::Windows, Platform::Macos, Platform::MacosM1], + default_values_t = vec![Platform::Linux, Platform::Windows, Platform::Macos, Platform::MacosArm64], )] pub platforms: Vec, /// Enable pytest @@ -109,7 +109,7 @@ impl Default for GenerateCI { Platform::Linux, Platform::Windows, Platform::Macos, - Platform::MacosM1, + Platform::MacosArm64, ], pytest: false, zig: false, @@ -225,16 +225,16 @@ jobs:\n", continue; } let plat_name = match platform { - Platform::MacosM1 => "macos_m1".to_string(), + Platform::MacosArm64 => "macos_arm64".to_string(), _ => platform.to_string(), }; let tag_name = match platform { - Platform::MacosM1 => "14".to_string(), + Platform::MacosArm64 => "14".to_string(), _ => "latest".to_string(), }; let os_name = match platform { Platform::Linux | Platform::Emscripten => "ubuntu", - Platform::Macos | Platform::MacosM1 => "macos", + Platform::Macos | Platform::MacosArm64 => "macos", _ => &plat_name, }; needs.push(plat_name.clone()); @@ -247,7 +247,7 @@ jobs:\n", Platform::Linux => vec!["x86_64", "x86", "aarch64", "armv7", "s390x", "ppc64le"], Platform::Windows => vec!["x64", "x86"], Platform::Macos => vec!["x86_64"], - Platform::MacosM1 => vec!["aarch64"], + Platform::MacosArm64 => vec!["aarch64"], _ => Vec::new(), }; if !targets.is_empty() { @@ -613,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 @@ -631,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: @@ -650,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 @@ -739,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 @@ -757,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 @@ -890,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 @@ -916,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: @@ -935,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 @@ -1017,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 @@ -1032,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: @@ -1051,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 diff --git a/tests/cmd/generate-ci.stdout b/tests/cmd/generate-ci.stdout index a4462009f..824a65e29 100644 --- a/tests/cmd/generate-ci.stdout +++ b/tests/cmd/generate-ci.stdout @@ -21,7 +21,7 @@ Options: --platform ... Platform support - [default: linux windows macos] + [default: linux windows macos macosarm64] Possible values: - all: All @@ -29,6 +29,7 @@ Options: - windows: Windows - macos: macOS - emscripten: Emscripten + - macosarm64: macOS(Arm64) --pytest Enable pytest