Skip to content

Commit 53b0fd5

Browse files
Copilotlengau
andauthored
Add armhf cross-compilation support via candidate-armhf branch (#119)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: lengau <4305943+lengau@users.noreply.github.com>
1 parent b4ed1e5 commit 53b0fd5

File tree

4 files changed

+121
-20
lines changed

4 files changed

+121
-20
lines changed

.github/workflows/pull-request.yaml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,7 @@ concurrency:
1111
jobs:
1212
build:
1313
name: 🧪 Build snap
14-
strategy:
15-
matrix:
16-
os: [ubuntu-latest, ubuntu-24.04-arm]
17-
runs-on: ${{ matrix.os }}
14+
runs-on: ubuntu-24.04-arm
1815
steps:
1916
- name: 🧪 Build snap
2017
uses: snapcrafters/ci/test-snap-build@main
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Release (armhf)
2+
3+
on:
4+
# Run the workflow each time new commits are pushed to the candidate-armhf branch.
5+
push:
6+
branches: [ "candidate-armhf" ]
7+
workflow_dispatch:
8+
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.ref }}
11+
cancel-in-progress: true
12+
13+
permissions:
14+
contents: read
15+
issues: write
16+
17+
jobs:
18+
release:
19+
name: 🚢 Release armhf to latest/candidate
20+
runs-on: ubuntu-latest
21+
environment: "Candidate Branch"
22+
steps:
23+
- name: 🚢 Release to latest/candidate
24+
uses: snapcrafters/ci/release-to-candidate@main
25+
with:
26+
architecture: armhf
27+
launchpad-token: ${{ secrets.LP_BUILD_SECRET }}
28+
repo-token: ${{ secrets.SNAPCRAFTERS_BOT_COMMIT }}
29+
store-token: ${{ secrets.SNAP_STORE_CANDIDATE }}
30+
31+
call-for-testing:
32+
name: 📣 Create call for testing
33+
needs: release
34+
environment: "Candidate Branch"
35+
runs-on: ubuntu-latest
36+
outputs:
37+
issue-number: ${{ steps.issue.outputs.issue-number }}
38+
steps:
39+
- name: 📣 Create call for testing
40+
id: issue
41+
uses: snapcrafters/ci/call-for-testing@main
42+
with:
43+
architectures: armhf
44+
github-token: ${{ secrets.GITHUB_TOKEN }}
45+
46+
test:
47+
name: 🗒️ Test snap on armhf
48+
needs: call-for-testing
49+
runs-on: ubuntu-24.04-arm
50+
steps:
51+
- name: 🗒️ Run tests
52+
uses: snapcrafters/ci/run-tests@main
53+
with:
54+
issue-number: ${{ needs.call-for-testing.outputs.issue-number }}
55+
github-token: ${{ secrets.GITHUB_TOKEN }}
56+
test-script: ./test.sh
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Sync to armhf branch
2+
3+
on:
4+
push:
5+
branches:
6+
- candidate
7+
workflow_dispatch:
8+
workflow_call:
9+
10+
permissions:
11+
issues: write
12+
contents: write
13+
14+
jobs:
15+
sync-armhf:
16+
name: 🔄 Sync candidate branch to candidate-armhf
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Checkout the source
20+
uses: actions/checkout@v4
21+
with:
22+
token: ${{ secrets.SNAPCRAFTERS_BOT_COMMIT }}
23+
fetch-depth: 0
24+
ref: candidate-armhf
25+
- name: Merge from candidate
26+
run: |
27+
git pull
28+
git config --global user.name "Snapcrafters Bot"
29+
git config --global user.email "bot@snapcrafters.org"
30+
31+
git merge origin/candidate -m 'chore: merge candidate to candidate-armhf'
32+
git push

snap/snapcraft.yaml

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,19 @@ issues:
3030
source-code: https://github.com/astral-sh/ruff
3131
website: https://github.com/astral-sh/ruff
3232

33+
package-repositories:
34+
- type: apt
35+
architectures: [$CRAFT_ARCH_BUILD_FOR]
36+
formats: [deb, deb-src]
37+
components: [main]
38+
suites: [noble, noble-updates, noble-backports]
39+
key-id: F6ECB3762474EDA9D21B7022871920D1991BC93C
40+
url: http://ports.ubuntu.com/ubuntu-ports
41+
3342
platforms:
34-
amd64:
35-
arm64:
36-
# Disabled until we can fix https://github.com/snapcrafters/ruff/issues/117
37-
# armhf:
38-
ppc64el:
39-
riscv64:
40-
s390x:
43+
armhf:
44+
build-on: [arm64, amd64]
45+
build-for: [armhf]
4146

4247
parts:
4348
ruff:
@@ -49,15 +54,26 @@ parts:
4954
source-tag: $SNAPCRAFT_PROJECT_VERSION
5055
source-depth: 1
5156
build-environment:
52-
# See: https://github.com/lengau/uv-snap/issues/10
53-
- to arm64:
54-
- JEMALLOC_SYS_WITH_LG_PAGE: 16
55-
- to ppc64el:
56-
- JEMALLOC_SYS_WITH_LG_PAGE: 16
57-
stage:
58-
- bin/ruff
59-
organize:
60-
ruff: bin/ruff
57+
# Build a static binary. Needed for armhf because of https://github.com/canonical/snapcraft/issues/5836
58+
- CARGO_BUILD_TARGET: armv7-unknown-linux-musleabihf
59+
- CARGO_TARGET_ARMV7_UNKNOWN_LINUX_MUSLEABIHF_LINKER: rust-lld
60+
- CARGO_CFG_TARGET_FEATURE: crt-static
61+
- CC: clang-20
62+
- CARGO_PROFILE_RELEASE_LTO: "off"
63+
build-packages:
64+
- libclang-20-dev
65+
- cmake
66+
- gcc-arm-linux-gnueabihf
67+
- libc6-dev-armhf-cross
68+
# Use clang for the armhf build so we can build for musl.
69+
- clang-20
70+
- musl-dev
71+
- musl-tools
72+
override-build: |
73+
rustup target add ${CARGO_BUILD_TARGET}
74+
craftctl default
75+
# manually install the ruff binary as its target dir differs
76+
install -Dvm755 ./target/${CARGO_BUILD_TARGET}/release/ruff "${CRAFT_PART_INSTALL}/bin/ruff"
6177
6278
apps:
6379
ruff:

0 commit comments

Comments
 (0)