Skip to content

Commit e82815e

Browse files
NickeZemilio
authored andcommitted
Refactor arm64 build to matrix strategy
Github is gradually moving ubuntu-latest to ubuntu-24.04 and the apt sources look slightly different. My fork and upstream ends up having different "ubuntu-latest", so I pin it to 24.
1 parent a5e1443 commit e82815e

1 file changed

Lines changed: 25 additions & 62 deletions

File tree

.github/workflows/cbindgen.yml

Lines changed: 25 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ on:
1414
jobs:
1515
rustfmt-clippy:
1616

17-
runs-on: ubuntu-latest
17+
runs-on: ubuntu-24.04
1818

1919
steps:
2020
- uses: actions/checkout@v3
@@ -41,81 +41,44 @@ jobs:
4141
cargo +${{steps.msrv.outputs.name}} test nonexistent-test --verbose
4242
4343
build:
44+
runs-on: ubuntu-24.04
4445

45-
runs-on: ubuntu-latest
46+
strategy:
47+
matrix:
48+
arch: [amd64, arm64]
49+
include:
50+
- arch: arm64
51+
env:
52+
CARGO_BUILD_TARGET: aarch64-unknown-linux-gnu
53+
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc-11
4654

4755
steps:
4856
- uses: actions/checkout@v3
4957

50-
- name: Install stable Rust
51-
uses: dtolnay/rust-toolchain@stable
52-
53-
- name: Install Python
54-
uses: actions/setup-python@v4
55-
with:
56-
python-version: '3.8'
57-
58-
- name: Install Cython
59-
run: |
60-
python -m pip install --upgrade pip wheel
61-
pip install Cython==3.0.2
62-
63-
- name: Build
64-
run: |
65-
cargo +stable build --verbose
66-
67-
- name: Build no-default-features
68-
run: |
69-
cargo +stable build --verbose --no-default-features
70-
71-
- name: Test package
72-
env:
73-
CBINDGEN_TEST_VERIFY: 1
74-
run: |
75-
cargo +stable package --verbose
76-
(cd target/package/cbindgen-$(cargo +stable run -- --version | cut -d ' ' -f 2) && cargo +stable test --verbose)
77-
78-
- name: Install nightly Rust
79-
uses: dtolnay/rust-toolchain@nightly
80-
81-
- name: Test
82-
env:
83-
CBINDGEN_TEST_VERIFY: 1
58+
- name: Setup environment variables for cross compiling
59+
if: matrix.arch != 'amd64'
8460
run: |
85-
cargo +nightly test --verbose
61+
echo CARGO_BUILD_TARGET=${{matrix.env.CARGO_BUILD_TARGET}} >> ${GITHUB_ENV}
62+
echo CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=${{matrix.env.CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER}} >> ${GITHUB_ENV}
8663
87-
- name: Test minimal-versions
64+
- name: Install cross linker and emulator
65+
if: matrix.arch == 'arm64'
8866
run: |
89-
cargo +nightly update -Zminimal-versions
90-
cargo +nightly test
91-
92-
build-arm64:
93-
94-
runs-on: ubuntu-latest
95-
env:
96-
CARGO_BUILD_TARGET: aarch64-unknown-linux-gnu
97-
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_RUNNER: qemu-aarch64-static
98-
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc-11
99-
100-
steps:
101-
- uses: actions/checkout@v3
102-
103-
- run: |
104-
sudo sed -i 's/^deb /deb [arch=amd64] /' /etc/apt/sources.list
105-
echo "deb [arch=arm64] http://ports.ubuntu.com/ jammy main multiverse universe" | sudo tee -a /etc/apt/sources.list
106-
echo "deb [arch=arm64] http://ports.ubuntu.com/ jammy-security main multiverse universe" | sudo tee -a /etc/apt/sources.list
107-
echo "deb [arch=arm64] http://ports.ubuntu.com/ jammy-backports main multiverse universe" | sudo tee -a /etc/apt/sources.list
108-
echo "deb [arch=arm64] http://ports.ubuntu.com/ jammy-updates main multiverse universe" | sudo tee -a /etc/apt/sources.list
67+
# Only works on noble (and later?)
68+
sudo sed -i '/^Components/a Architectures: amd64' /etc/apt/sources.list.d/ubuntu.sources
69+
echo "deb [arch=arm64] http://ports.ubuntu.com/ $(lsb_release -sc) main multiverse universe" | sudo tee -a /etc/apt/sources.list.d/ports.list
70+
echo "deb [arch=arm64] http://ports.ubuntu.com/ $(lsb_release -sc)-security main multiverse universe" | sudo tee -a /etc/apt/sources.list.d/ports.list
71+
echo "deb [arch=arm64] http://ports.ubuntu.com/ $(lsb_release -sc)-backports main multiverse universe" | sudo tee -a /etc/apt/sources.list.d/ports.list
72+
echo "deb [arch=arm64] http://ports.ubuntu.com/ $(lsb_release -sc)-updates main multiverse universe" | sudo tee -a /etc/apt/sources.list.d/ports.list
10973
11074
sudo dpkg --add-architecture arm64
11175
sudo apt-get update
112-
sudo apt-get install -y qemu-user-static gcc-11-aarch64-linux-gnu
113-
sudo apt-get install -y libc6:arm64
76+
sudo apt-get install -y qemu-user gcc-11-aarch64-linux-gnu libc6:arm64
11477
11578
- name: Install stable Rust
11679
uses: dtolnay/rust-toolchain@stable
11780
with:
118-
targets: ${{env.CARGO_BUILD_TARGET}}
81+
targets: ${{matrix.env.CARGO_BUILD_TARGET}}
11982

12083
- name: Install Python
12184
uses: actions/setup-python@v4
@@ -145,7 +108,7 @@ jobs:
145108
- name: Install nightly Rust
146109
uses: dtolnay/rust-toolchain@nightly
147110
with:
148-
targets: ${{env.CARGO_BUILD_TARGET}}
111+
targets: ${{matrix.env.CARGO_BUILD_TARGET}}
149112

150113
- name: Test
151114
env:

0 commit comments

Comments
 (0)