Skip to content

Commit 72695f5

Browse files
fix: LLVM version for MacOS CI builds + Add Linux ARM64 builds to CI (#623)
1 parent a4c3367 commit 72695f5

File tree

2 files changed

+119
-37
lines changed

2 files changed

+119
-37
lines changed

.github/actions/artifacts/build-pc-artifacts/action.yml

+41-9
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,8 @@ inputs:
88
description: "Commit SHA to checkout"
99
required: true
1010
os:
11-
description: "Operating system for the build (linux, macos-x86_64, macos-arm64)"
11+
description: "Operating system for the build (linux-x86_64, linux-arm64, macos-x86_64, macos-arm64)"
1212
required: true
13-
1413
runs:
1514
using: "composite"
1615
steps:
@@ -21,19 +20,20 @@ runs:
2120
- name: Set filename variables
2221
shell: bash
2322
run: |
24-
if [[ "${{ inputs.os }}" == "linux" ]]; then
23+
if [[ "${{ inputs.os }}" == "linux-x86_64" ]]; then
2524
echo "PARTNER_CHAINS_NODE=partner-chains-node-${{ inputs.tag }}-x86_64-linux" >> $GITHUB_ENV
25+
elif [[ "${{ inputs.os }}" == "linux-arm64" ]]; then
26+
echo "PARTNER_CHAINS_NODE=partner-chains-node-${{ inputs.tag }}-aarch64-linux" >> $GITHUB_ENV
2627
elif [[ "${{ inputs.os }}" == "macos-x86_64" ]]; then
2728
echo "PARTNER_CHAINS_NODE=partner-chains-node-${{ inputs.tag }}-x86_64-apple-darwin" >> $GITHUB_ENV
2829
elif [[ "${{ inputs.os }}" == "macos-arm64" ]]; then
2930
echo "PARTNER_CHAINS_NODE=partner-chains-node-${{ inputs.tag }}-aarch64-apple-darwin" >> $GITHUB_ENV
3031
fi
31-
3232
- name: Install protoc
3333
shell: bash
3434
run: |
3535
cd $GITHUB_WORKSPACE
36-
if [[ "${{ inputs.os }}" == "linux" ]]; then
36+
if [[ "${{ inputs.os }}" == "linux-x86_64" || "${{ inputs.os }}" == "linux-arm64" ]]; then
3737
sudo apt-get install -y protobuf-compiler
3838
elif [[ "${{ inputs.os }}" == "macos-x86_64" ]]; then
3939
curl -LO https://github.com/protocolbuffers/protobuf/releases/download/v21.3/protoc-21.3-osx-x86_64.zip
@@ -44,30 +44,62 @@ runs:
4444
unzip protoc-21.3-osx-aarch_64.zip -d $HOME/protoc
4545
sudo mv $HOME/protoc/bin/protoc /usr/local/bin/protoc
4646
fi
47-
47+
- name: Install cross-compilation dependencies for Linux ARM64
48+
shell: bash
49+
run: |
50+
if [[ "${{ inputs.os }}" == "linux-arm64" ]]; then
51+
sudo apt-get update
52+
sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
53+
fi
54+
- name: Install LLVM for macOS
55+
if: startsWith(inputs.os, 'macos')
56+
shell: bash
57+
run: |
58+
brew install llvm
59+
echo "LLVM_PATH=$(brew --prefix llvm)" >> $GITHUB_ENV
60+
echo "$(brew --prefix llvm)/bin" >> $GITHUB_PATH
61+
echo 'export PATH="$(brew --prefix llvm)/bin:$PATH"' >> ~/.bash_profile
62+
source ~/.bash_profile
63+
echo "CC=$(brew --prefix llvm)/bin/clang" >> $GITHUB_ENV
64+
echo "CXX=$(brew --prefix llvm)/bin/clang++" >> $GITHUB_ENV
65+
echo "LLVM_CONFIG=$(brew --prefix llvm)/bin/llvm-config" >> $GITHUB_ENV
66+
clang --version
4867
- name: Build partner-chains-node
4968
shell: bash
5069
run: |
5170
cd $GITHUB_WORKSPACE
52-
if [[ "${{ inputs.os }}" == "linux" ]]; then
71+
if [[ "${{ inputs.os }}" == "linux-x86_64" ]]; then
5372
rustup target add x86_64-unknown-linux-gnu
5473
cargo build -p partner-chains-node --locked --release --target x86_64-unknown-linux-gnu
5574
cp target/x86_64-unknown-linux-gnu/release/partner-chains-node $PARTNER_CHAINS_NODE
5675
chmod +x $PARTNER_CHAINS_NODE
76+
elif [[ "${{ inputs.os }}" == "linux-arm64" ]]; then
77+
rustup target add aarch64-unknown-linux-gnu
78+
79+
# Configure cross-compilation environment variables
80+
export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc
81+
export CC_aarch64_unknown_linux_gnu=aarch64-linux-gnu-gcc
82+
export CXX_aarch64_unknown_linux_gnu=aarch64-linux-gnu-g++
83+
export PKG_CONFIG_PATH=/usr/lib/aarch64-linux-gnu/pkgconfig
84+
85+
cargo build -p partner-chains-node --locked --release --target aarch64-unknown-linux-gnu
86+
cp target/aarch64-unknown-linux-gnu/release/partner-chains-node $PARTNER_CHAINS_NODE
87+
chmod +x $PARTNER_CHAINS_NODE
5788
elif [[ "${{ inputs.os }}" == "macos-x86_64" ]]; then
5889
rustup target add x86_64-apple-darwin
90+
RUSTFLAGS="-C linker=${LLVM_PATH}/bin/clang" \
5991
cargo build -p partner-chains-node --locked --release --target x86_64-apple-darwin
6092
cp target/x86_64-apple-darwin/release/partner-chains-node $PARTNER_CHAINS_NODE
6193
chmod +x $PARTNER_CHAINS_NODE
6294
elif [[ "${{ inputs.os }}" == "macos-arm64" ]]; then
6395
rustup target add aarch64-apple-darwin
96+
RUSTFLAGS="-C linker=${LLVM_PATH}/bin/clang" \
6497
cargo build -p partner-chains-node --locked --release --target aarch64-apple-darwin
6598
cp target/aarch64-apple-darwin/release/partner-chains-node $PARTNER_CHAINS_NODE
6699
chmod +x $PARTNER_CHAINS_NODE
67100
fi
68-
69101
- name: Upload partner-chains-node artifact
70102
uses: actions/upload-artifact@v4
71103
with:
72104
name: partner-chains-node-${{ inputs.os }}-artifact
73-
path: ${{ env.PARTNER_CHAINS_NODE }}
105+
path: ${{ env.PARTNER_CHAINS_NODE }}

.github/workflows/ci.yml

+78-28
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424

2525
### Pre merge workflow ###############################################################################################################
2626

27-
build-linux-pre-merge:
27+
build-linux-x86_64-pre-merge:
2828
runs-on: ubuntu-latest
2929
if: github.event_name == 'pull_request' && github.event.pull_request.merged == false
3030
outputs:
@@ -87,7 +87,7 @@ jobs:
8787
8888
local-environment-tests:
8989
if: github.event_name == 'pull_request' && github.event.pull_request.merged == false
90-
needs: build-linux-pre-merge
90+
needs: build-linux-x86_64-pre-merge
9191
runs-on: ubuntu-latest
9292
steps:
9393
- name: Checkout
@@ -99,8 +99,8 @@ jobs:
9999
uses: ./.github/actions/tests/local-environment-tests
100100
with:
101101
tag: CI
102-
image: ${{ secrets.ECR_REGISTRY_SECRET }}/partner-chains-node:${{ needs.build-linux-pre-merge.outputs.sha }}
103-
sha: ${{ needs.build-linux-pre-merge.outputs.sha }}
102+
image: ${{ secrets.ECR_REGISTRY_SECRET }}/partner-chains-node:${{ needs.build-linux-x86_64-pre-merge.outputs.sha }}
103+
sha: ${{ needs.build-linux-x86_64-pre-merge.outputs.sha }}
104104
tests: premerge
105105
env:
106106
SUBSTRATE_REPO_SSH_KEY: ${{ secrets.SUBSTRATE_REPO_SSH_KEY }}
@@ -143,7 +143,7 @@ jobs:
143143
shell: bash
144144

145145
devshell-tests:
146-
needs: build-linux-pre-merge
146+
needs: build-linux-x86_64-pre-merge
147147
if: github.event_name == 'pull_request' && github.event.pull_request.merged == false
148148
strategy:
149149
matrix:
@@ -176,7 +176,7 @@ jobs:
176176
177177
upload-chain-specs-pre-merge:
178178
if: github.event_name == 'pull_request' && github.event.pull_request.merged == false
179-
needs: build-linux-pre-merge
179+
needs: build-linux-x86_64-pre-merge
180180
runs-on: eks
181181
steps:
182182
- name: Checkout
@@ -187,20 +187,20 @@ jobs:
187187
- name: Upload chain spec artifacts to Kubernetes
188188
uses: ./.github/actions/deploy/upload-chain-specs
189189
with:
190-
sha: ${{ needs.build-linux-pre-merge.outputs.sha }}
190+
sha: ${{ needs.build-linux-x86_64-pre-merge.outputs.sha }}
191191
env:
192192
kubeconfig_base64: ${{ secrets.kubeconfig_base64 }}
193193
K8S_SERVER: ${{ secrets.K8S_SERVER }}
194194
K8S_SA_TOKEN: ${{ secrets.K8S_SA_TOKEN }}
195195

196196
pre-merge-checks-complete:
197197
if: ${{ always() && github.event_name == 'pull_request' && github.event.pull_request.merged == false }}
198-
needs: [build-linux-pre-merge, local-environment-tests, devshell-tests, upload-chain-specs-pre-merge]
198+
needs: [build-linux-x86_64-pre-merge, local-environment-tests, devshell-tests, upload-chain-specs-pre-merge]
199199
runs-on: ubuntu-latest
200200
steps:
201201
- name: Check if any needed job failed
202202
run: |
203-
if [[ "${{ needs.build-linux-pre-merge.result }}" != "success" ||
203+
if [[ "${{ needs.build-linux-x86_64-pre-merge.result }}" != "success" ||
204204
"${{ needs.local-environment-tests.result }}" != "success" ||
205205
"${{ needs.devshell-tests.result }}" != "success" ||
206206
"${{ needs.upload-chain-specs-pre-merge.result }}" != "success" ]]; then
@@ -212,7 +212,7 @@ jobs:
212212
213213
### Post merge workflow ###############################################################################################################
214214

215-
build-linux-post-merge:
215+
build-linux-x86_64-post-merge:
216216
runs-on: ubuntu-latest
217217
if: github.event_name == 'pull_request' && github.event.pull_request.merged == true
218218
outputs:
@@ -289,6 +289,30 @@ jobs:
289289
./to-build/staging_preview_chain_spec.json
290290
./to-build/staging_preprod_chain_spec.json
291291
292+
build-linux-arm64:
293+
if: github.event_name == 'pull_request' && github.event.pull_request.merged == true
294+
permissions:
295+
id-token: write
296+
contents: write
297+
runs-on: ubuntu-latest
298+
steps:
299+
- name: Checkout master
300+
uses: actions/checkout@v4
301+
with:
302+
fetch-depth: 0
303+
ref: master
304+
- name: Get current commit SHA
305+
id: get_sha
306+
run: echo "sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
307+
- name: Set up QEMU
308+
uses: docker/setup-qemu-action@v3
309+
- name: Build and Upload for linux arm64
310+
uses: ./.github/actions/artifacts/build-pc-artifacts
311+
with:
312+
sha: ${{ steps.get_sha.outputs.sha }}
313+
tag: ${{ steps.get_sha.outputs.sha }}
314+
os: linux-arm64
315+
292316
build-macos-x86_64:
293317
if: github.event_name == 'pull_request' && github.event.pull_request.merged == true
294318
permissions:
@@ -336,7 +360,8 @@ jobs:
336360
upload-to-s3:
337361
if: github.event_name == 'pull_request' && github.event.pull_request.merged == true
338362
needs:
339-
- build-linux-post-merge
363+
- build-linux-x86_64-post-merge
364+
- build-linux-arm64
340365
- build-macos-x86_64
341366
- build-macos-arm64
342367
runs-on: ubuntu-latest
@@ -363,7 +388,7 @@ jobs:
363388

364389
upload-chain-specs:
365390
if: github.event_name == 'pull_request' && github.event.pull_request.merged == true
366-
needs: build-linux-post-merge
391+
needs: build-linux-x86_64-post-merge
367392
runs-on: eks
368393
steps:
369394
- name: Checkout
@@ -374,15 +399,15 @@ jobs:
374399
- name: Upload chain spec artifacts to Kubernetes
375400
uses: ./.github/actions/deploy/upload-chain-specs
376401
with:
377-
sha: ${{ needs.build-linux-post-merge.outputs.sha }}
402+
sha: ${{ needs.build-linux-x86_64-post-merge.outputs.sha }}
378403
env:
379404
kubeconfig_base64: ${{ secrets.kubeconfig_base64 }}
380405
K8S_SERVER: ${{ secrets.K8S_SERVER }}
381406
K8S_SA_TOKEN: ${{ secrets.K8S_SA_TOKEN }}
382407

383408
deploy-rustdoc:
384409
if: github.event_name == 'pull_request' && github.event.pull_request.merged == true
385-
needs: build-linux-post-merge
410+
needs: build-linux-x86_64-post-merge
386411
runs-on: ubuntu-latest
387412
steps:
388413
- name: Checkout
@@ -400,7 +425,7 @@ jobs:
400425

401426
local-environment-tests-post-merge:
402427
if: github.event_name == 'pull_request' && github.event.pull_request.merged == true
403-
needs: build-linux-post-merge
428+
needs: build-linux-x86_64-post-merge
404429
runs-on: ubuntu-latest
405430
steps:
406431
- name: Checkout
@@ -412,8 +437,8 @@ jobs:
412437
uses: ./.github/actions/tests/local-environment-tests
413438
with:
414439
tag: CI
415-
image: ${{ secrets.ECR_REGISTRY_SECRET }}/partner-chains-node:${{ needs.build-linux-post-merge.outputs.sha }}
416-
sha: ${{ needs.build-linux-post-merge.outputs.sha }}
440+
image: ${{ secrets.ECR_REGISTRY_SECRET }}/partner-chains-node:${{ needs.build-linux-x86_64-post-merge.outputs.sha }}
441+
sha: ${{ needs.build-linux-x86_64-post-merge.outputs.sha }}
417442
tests: postmerge
418443
env:
419444
SUBSTRATE_REPO_SSH_KEY: ${{ secrets.SUBSTRATE_REPO_SSH_KEY }}
@@ -457,7 +482,7 @@ jobs:
457482

458483
deploy-ci-preview:
459484
needs:
460-
- build-linux-post-merge
485+
- build-linux-x86_64-post-merge
461486
- local-environment-tests-post-merge-alert
462487
permissions:
463488
id-token: write
@@ -471,8 +496,8 @@ jobs:
471496
- name: Deploy ci-preview
472497
uses: ./.github/actions/deploy/deploy-ci-preview
473498
with:
474-
image: ${{ secrets.ECR_REGISTRY_SECRET }}/partner-chains-node:${{ needs.build-linux-post-merge.outputs.sha }}
475-
sha: ${{ needs.build-linux-post-merge.outputs.sha }}
499+
image: ${{ secrets.ECR_REGISTRY_SECRET }}/partner-chains-node:${{ needs.build-linux-x86_64-post-merge.outputs.sha }}
500+
sha: ${{ needs.build-linux-x86_64-post-merge.outputs.sha }}
476501
no-wipe: true
477502
env:
478503
AWS_REGION: "eu-central-1"
@@ -512,22 +537,24 @@ jobs:
512537
if: ${{ always() && (github.event_name == 'pull_request' && github.event.pull_request.merged == true) }}
513538
needs:
514539
[
515-
build-linux-post-merge,
540+
build-linux-x86_64-post-merge,
516541
deploy-rustdoc,
517542
upload-chain-specs,
518543
local-environment-tests-post-merge,
519544
ci-preview-tests-post-merge,
520545
deploy-ci-preview,
546+
upload-to-s3,
521547
]
522548
runs-on: ubuntu-latest
523549
steps:
524550
- name: Check if any needed job failed
525551
run: |
526552
if [[ "${{ needs.deploy-rustdoc.result }}" != "success" ||
527-
"${{ needs.build-linux-post-merge.result }}" != "success" ||
553+
"${{ needs.build-linux-x86_64-post-merge.result }}" != "success" ||
528554
"${{ needs.upload-chain-specs.result }}" != "success" ||
529555
"${{ needs.local-environment-tests-post-merge.result }}" != "success" ]]
530-
"${{ needs.deploy-ci-preview.result }}" != "success" ]]; then
556+
"${{ needs.deploy-ci-preview.result }}" != "success" ]]
557+
"${{ needs.upload-to-s3.result }}" != "success" ]]; then
531558
echo "One or more needed jobs failed."
532559
exit 1
533560
else
@@ -536,7 +563,7 @@ jobs:
536563
537564
### Workflow dispatch flow ###############################################################################################################
538565

539-
build-linux-workflow-dispatch:
566+
build-linux-x86_64-workflow-dispatch:
540567
runs-on: ubuntu-latest
541568
if: github.event_name == 'workflow_dispatch'
542569
steps:
@@ -595,6 +622,27 @@ jobs:
595622
./to-build/staging_preview_chain_spec.json
596623
./to-build/staging_preprod_chain_spec.json
597624
625+
build-linux-arm64-workflow-dispatch:
626+
if: github.event_name == 'workflow_dispatch'
627+
permissions:
628+
id-token: write
629+
contents: write
630+
runs-on: ubuntu-latest
631+
steps:
632+
- name: Checkout specific SHA
633+
uses: actions/checkout@v4
634+
with:
635+
fetch-depth: 0
636+
ref: ${{ github.sha }}
637+
- name: Set up QEMU
638+
uses: docker/setup-qemu-action@v3
639+
- name: Build and Upload for linux arm64
640+
uses: ./.github/actions/artifacts/build-pc-artifacts
641+
with:
642+
sha: ${{ inputs.sha }}
643+
tag: ${{ inputs.sha }}
644+
os: linux-arm64
645+
598646
build-macos-x86_64-workflow-dispatch:
599647
if: github.event_name == 'workflow_dispatch'
600648
permissions:
@@ -636,7 +684,8 @@ jobs:
636684
upload-to-s3-workflow-dispatch:
637685
if: github.event_name == 'workflow_dispatch'
638686
needs:
639-
- build-linux-workflow-dispatch
687+
- build-linux-x86_64-workflow-dispatch
688+
- build-linux-arm64-workflow-dispatch
640689
- build-macos-x86_64-workflow-dispatch
641690
- build-macos-arm64-workflow-dispatch
642691
runs-on: ubuntu-latest
@@ -660,7 +709,7 @@ jobs:
660709

661710
upload-chain-specs-workflow-dispatch:
662711
if: github.event_name == 'workflow_dispatch'
663-
needs: build-linux-workflow-dispatch
712+
needs: build-linux-x86_64-workflow-dispatch
664713
runs-on: eks
665714
steps:
666715
- name: Checkout specific SHA
@@ -679,12 +728,13 @@ jobs:
679728

680729
workflow-dispatch-flow-complete:
681730
if: ${{ always() && github.event_name == 'workflow_dispatch' }}
682-
needs: [build-linux-workflow-dispatch, build-macos-x86_64-workflow-dispatch, build-macos-arm64-workflow-dispatch, upload-to-s3-workflow-dispatch, upload-chain-specs-workflow-dispatch]
731+
needs: [build-linux-x86_64-workflow-dispatch, build-linux-arm64-workflow-dispatch, build-macos-x86_64-workflow-dispatch, build-macos-arm64-workflow-dispatch, upload-to-s3-workflow-dispatch, upload-chain-specs-workflow-dispatch]
683732
runs-on: ubuntu-latest
684733
steps:
685734
- name: Check if any needed job failed
686735
run: |
687-
if [[ "${{ needs.build-linux-workflow-dispatch.result }}" != "success" ||
736+
if [[ "${{ needs.build-linux-x86_64-workflow-dispatch.result }}" != "success" ||
737+
"${{ needs.build-linux-arm64-workflow-dispatch.result }}" != "success" ||
688738
"${{ needs.build-macos-x86_64-workflow-dispatch.result }}" != "success" ||
689739
"${{ needs.build-macos-arm64-workflow-dispatch.result }}" != "success" ||
690740
"${{ needs.upload-to-s3-workflow-dispatch.result }}" != "success" ||

0 commit comments

Comments
 (0)