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

fix: LLVM version for MacOS CI builds + Add Linux ARM64 builds to CI #623

Merged
merged 12 commits into from
Mar 31, 2025
50 changes: 41 additions & 9 deletions .github/actions/artifacts/build-pc-artifacts/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ inputs:
description: "Commit SHA to checkout"
required: true
os:
description: "Operating system for the build (linux, macos-x86_64, macos-arm64)"
description: "Operating system for the build (linux-x86_64, linux-arm64, macos-x86_64, macos-arm64)"
required: true

runs:
using: "composite"
steps:
Expand All @@ -21,19 +20,20 @@ runs:
- name: Set filename variables
shell: bash
run: |
if [[ "${{ inputs.os }}" == "linux" ]]; then
if [[ "${{ inputs.os }}" == "linux-x86_64" ]]; then
echo "PARTNER_CHAINS_NODE=partner-chains-node-${{ inputs.tag }}-x86_64-linux" >> $GITHUB_ENV
elif [[ "${{ inputs.os }}" == "linux-arm64" ]]; then
echo "PARTNER_CHAINS_NODE=partner-chains-node-${{ inputs.tag }}-aarch64-linux" >> $GITHUB_ENV
elif [[ "${{ inputs.os }}" == "macos-x86_64" ]]; then
echo "PARTNER_CHAINS_NODE=partner-chains-node-${{ inputs.tag }}-x86_64-apple-darwin" >> $GITHUB_ENV
elif [[ "${{ inputs.os }}" == "macos-arm64" ]]; then
echo "PARTNER_CHAINS_NODE=partner-chains-node-${{ inputs.tag }}-aarch64-apple-darwin" >> $GITHUB_ENV
fi

- name: Install protoc
shell: bash
run: |
cd $GITHUB_WORKSPACE
if [[ "${{ inputs.os }}" == "linux" ]]; then
if [[ "${{ inputs.os }}" == "linux-x86_64" || "${{ inputs.os }}" == "linux-arm64" ]]; then
sudo apt-get install -y protobuf-compiler
elif [[ "${{ inputs.os }}" == "macos-x86_64" ]]; then
curl -LO https://github.com/protocolbuffers/protobuf/releases/download/v21.3/protoc-21.3-osx-x86_64.zip
Expand All @@ -44,30 +44,62 @@ runs:
unzip protoc-21.3-osx-aarch_64.zip -d $HOME/protoc
sudo mv $HOME/protoc/bin/protoc /usr/local/bin/protoc
fi

- name: Install cross-compilation dependencies for Linux ARM64
shell: bash
run: |
if [[ "${{ inputs.os }}" == "linux-arm64" ]]; then
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
fi
- name: Install LLVM for macOS
if: startsWith(inputs.os, 'macos')
shell: bash
run: |
brew install llvm
echo "LLVM_PATH=$(brew --prefix llvm)" >> $GITHUB_ENV
echo "$(brew --prefix llvm)/bin" >> $GITHUB_PATH
echo 'export PATH="$(brew --prefix llvm)/bin:$PATH"' >> ~/.bash_profile
source ~/.bash_profile
echo "CC=$(brew --prefix llvm)/bin/clang" >> $GITHUB_ENV
echo "CXX=$(brew --prefix llvm)/bin/clang++" >> $GITHUB_ENV
echo "LLVM_CONFIG=$(brew --prefix llvm)/bin/llvm-config" >> $GITHUB_ENV
clang --version
- name: Build partner-chains-node
shell: bash
run: |
cd $GITHUB_WORKSPACE
if [[ "${{ inputs.os }}" == "linux" ]]; then
if [[ "${{ inputs.os }}" == "linux-x86_64" ]]; then
rustup target add x86_64-unknown-linux-gnu
cargo build -p partner-chains-node --locked --release --target x86_64-unknown-linux-gnu
cp target/x86_64-unknown-linux-gnu/release/partner-chains-node $PARTNER_CHAINS_NODE
chmod +x $PARTNER_CHAINS_NODE
elif [[ "${{ inputs.os }}" == "linux-arm64" ]]; then
rustup target add aarch64-unknown-linux-gnu

# Configure cross-compilation environment variables
export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc
export CC_aarch64_unknown_linux_gnu=aarch64-linux-gnu-gcc
export CXX_aarch64_unknown_linux_gnu=aarch64-linux-gnu-g++
export PKG_CONFIG_PATH=/usr/lib/aarch64-linux-gnu/pkgconfig

cargo build -p partner-chains-node --locked --release --target aarch64-unknown-linux-gnu
cp target/aarch64-unknown-linux-gnu/release/partner-chains-node $PARTNER_CHAINS_NODE
chmod +x $PARTNER_CHAINS_NODE
elif [[ "${{ inputs.os }}" == "macos-x86_64" ]]; then
rustup target add x86_64-apple-darwin
RUSTFLAGS="-C linker=${LLVM_PATH}/bin/clang" \
cargo build -p partner-chains-node --locked --release --target x86_64-apple-darwin
cp target/x86_64-apple-darwin/release/partner-chains-node $PARTNER_CHAINS_NODE
chmod +x $PARTNER_CHAINS_NODE
elif [[ "${{ inputs.os }}" == "macos-arm64" ]]; then
rustup target add aarch64-apple-darwin
RUSTFLAGS="-C linker=${LLVM_PATH}/bin/clang" \
cargo build -p partner-chains-node --locked --release --target aarch64-apple-darwin
cp target/aarch64-apple-darwin/release/partner-chains-node $PARTNER_CHAINS_NODE
chmod +x $PARTNER_CHAINS_NODE
fi

- name: Upload partner-chains-node artifact
uses: actions/upload-artifact@v4
with:
name: partner-chains-node-${{ inputs.os }}-artifact
path: ${{ env.PARTNER_CHAINS_NODE }}
path: ${{ env.PARTNER_CHAINS_NODE }}
106 changes: 78 additions & 28 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:

### Pre merge workflow ###############################################################################################################

build-linux-pre-merge:
build-linux-x86_64-pre-merge:
runs-on: ubuntu-latest
if: github.event_name == 'pull_request' && github.event.pull_request.merged == false
outputs:
Expand Down Expand Up @@ -87,7 +87,7 @@ jobs:

local-environment-tests:
if: github.event_name == 'pull_request' && github.event.pull_request.merged == false
needs: build-linux-pre-merge
needs: build-linux-x86_64-pre-merge
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -99,8 +99,8 @@ jobs:
uses: ./.github/actions/tests/local-environment-tests
with:
tag: CI
image: ${{ secrets.ECR_REGISTRY_SECRET }}/partner-chains-node:${{ needs.build-linux-pre-merge.outputs.sha }}
sha: ${{ needs.build-linux-pre-merge.outputs.sha }}
image: ${{ secrets.ECR_REGISTRY_SECRET }}/partner-chains-node:${{ needs.build-linux-x86_64-pre-merge.outputs.sha }}
sha: ${{ needs.build-linux-x86_64-pre-merge.outputs.sha }}
tests: premerge
env:
SUBSTRATE_REPO_SSH_KEY: ${{ secrets.SUBSTRATE_REPO_SSH_KEY }}
Expand Down Expand Up @@ -143,7 +143,7 @@ jobs:
shell: bash

devshell-tests:
needs: build-linux-pre-merge
needs: build-linux-x86_64-pre-merge
if: github.event_name == 'pull_request' && github.event.pull_request.merged == false
strategy:
matrix:
Expand Down Expand Up @@ -176,7 +176,7 @@ jobs:

upload-chain-specs-pre-merge:
if: github.event_name == 'pull_request' && github.event.pull_request.merged == false
needs: build-linux-pre-merge
needs: build-linux-x86_64-pre-merge
runs-on: eks
steps:
- name: Checkout
Expand All @@ -187,20 +187,20 @@ jobs:
- name: Upload chain spec artifacts to Kubernetes
uses: ./.github/actions/deploy/upload-chain-specs
with:
sha: ${{ needs.build-linux-pre-merge.outputs.sha }}
sha: ${{ needs.build-linux-x86_64-pre-merge.outputs.sha }}
env:
kubeconfig_base64: ${{ secrets.kubeconfig_base64 }}
K8S_SERVER: ${{ secrets.K8S_SERVER }}
K8S_SA_TOKEN: ${{ secrets.K8S_SA_TOKEN }}

pre-merge-checks-complete:
if: ${{ always() && github.event_name == 'pull_request' && github.event.pull_request.merged == false }}
needs: [build-linux-pre-merge, local-environment-tests, devshell-tests, upload-chain-specs-pre-merge]
needs: [build-linux-x86_64-pre-merge, local-environment-tests, devshell-tests, upload-chain-specs-pre-merge]
runs-on: ubuntu-latest
steps:
- name: Check if any needed job failed
run: |
if [[ "${{ needs.build-linux-pre-merge.result }}" != "success" ||
if [[ "${{ needs.build-linux-x86_64-pre-merge.result }}" != "success" ||
"${{ needs.local-environment-tests.result }}" != "success" ||
"${{ needs.devshell-tests.result }}" != "success" ||
"${{ needs.upload-chain-specs-pre-merge.result }}" != "success" ]]; then
Expand All @@ -212,7 +212,7 @@ jobs:

### Post merge workflow ###############################################################################################################

build-linux-post-merge:
build-linux-x86_64-post-merge:
runs-on: ubuntu-latest
if: github.event_name == 'pull_request' && github.event.pull_request.merged == true
outputs:
Expand Down Expand Up @@ -289,6 +289,30 @@ jobs:
./to-build/staging_preview_chain_spec.json
./to-build/staging_preprod_chain_spec.json

build-linux-arm64:
if: github.event_name == 'pull_request' && github.event.pull_request.merged == true
permissions:
id-token: write
contents: write
runs-on: ubuntu-latest
steps:
- name: Checkout master
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: master
- name: Get current commit SHA
id: get_sha
run: echo "sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Build and Upload for linux arm64
uses: ./.github/actions/artifacts/build-pc-artifacts
with:
sha: ${{ steps.get_sha.outputs.sha }}
tag: ${{ steps.get_sha.outputs.sha }}
os: linux-arm64

build-macos-x86_64:
if: github.event_name == 'pull_request' && github.event.pull_request.merged == true
permissions:
Expand Down Expand Up @@ -336,7 +360,8 @@ jobs:
upload-to-s3:
if: github.event_name == 'pull_request' && github.event.pull_request.merged == true
needs:
- build-linux-post-merge
- build-linux-x86_64-post-merge
- build-linux-arm64
- build-macos-x86_64
- build-macos-arm64
runs-on: ubuntu-latest
Expand All @@ -363,7 +388,7 @@ jobs:

upload-chain-specs:
if: github.event_name == 'pull_request' && github.event.pull_request.merged == true
needs: build-linux-post-merge
needs: build-linux-x86_64-post-merge
runs-on: eks
steps:
- name: Checkout
Expand All @@ -374,15 +399,15 @@ jobs:
- name: Upload chain spec artifacts to Kubernetes
uses: ./.github/actions/deploy/upload-chain-specs
with:
sha: ${{ needs.build-linux-post-merge.outputs.sha }}
sha: ${{ needs.build-linux-x86_64-post-merge.outputs.sha }}
env:
kubeconfig_base64: ${{ secrets.kubeconfig_base64 }}
K8S_SERVER: ${{ secrets.K8S_SERVER }}
K8S_SA_TOKEN: ${{ secrets.K8S_SA_TOKEN }}

deploy-rustdoc:
if: github.event_name == 'pull_request' && github.event.pull_request.merged == true
needs: build-linux-post-merge
needs: build-linux-x86_64-post-merge
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -400,7 +425,7 @@ jobs:

local-environment-tests-post-merge:
if: github.event_name == 'pull_request' && github.event.pull_request.merged == true
needs: build-linux-post-merge
needs: build-linux-x86_64-post-merge
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -412,8 +437,8 @@ jobs:
uses: ./.github/actions/tests/local-environment-tests
with:
tag: CI
image: ${{ secrets.ECR_REGISTRY_SECRET }}/partner-chains-node:${{ needs.build-linux-post-merge.outputs.sha }}
sha: ${{ needs.build-linux-post-merge.outputs.sha }}
image: ${{ secrets.ECR_REGISTRY_SECRET }}/partner-chains-node:${{ needs.build-linux-x86_64-post-merge.outputs.sha }}
sha: ${{ needs.build-linux-x86_64-post-merge.outputs.sha }}
tests: postmerge
env:
SUBSTRATE_REPO_SSH_KEY: ${{ secrets.SUBSTRATE_REPO_SSH_KEY }}
Expand Down Expand Up @@ -457,7 +482,7 @@ jobs:

deploy-ci-preview:
needs:
- build-linux-post-merge
- build-linux-x86_64-post-merge
- local-environment-tests-post-merge-alert
permissions:
id-token: write
Expand All @@ -471,8 +496,8 @@ jobs:
- name: Deploy ci-preview
uses: ./.github/actions/deploy/deploy-ci-preview
with:
image: ${{ secrets.ECR_REGISTRY_SECRET }}/partner-chains-node:${{ needs.build-linux-post-merge.outputs.sha }}
sha: ${{ needs.build-linux-post-merge.outputs.sha }}
image: ${{ secrets.ECR_REGISTRY_SECRET }}/partner-chains-node:${{ needs.build-linux-x86_64-post-merge.outputs.sha }}
sha: ${{ needs.build-linux-x86_64-post-merge.outputs.sha }}
no-wipe: true
env:
AWS_REGION: "eu-central-1"
Expand Down Expand Up @@ -512,22 +537,24 @@ jobs:
if: ${{ always() && (github.event_name == 'pull_request' && github.event.pull_request.merged == true) }}
needs:
[
build-linux-post-merge,
build-linux-x86_64-post-merge,
deploy-rustdoc,
upload-chain-specs,
local-environment-tests-post-merge,
ci-preview-tests-post-merge,
deploy-ci-preview,
upload-to-s3,
]
runs-on: ubuntu-latest
steps:
- name: Check if any needed job failed
run: |
if [[ "${{ needs.deploy-rustdoc.result }}" != "success" ||
"${{ needs.build-linux-post-merge.result }}" != "success" ||
"${{ needs.build-linux-x86_64-post-merge.result }}" != "success" ||
"${{ needs.upload-chain-specs.result }}" != "success" ||
"${{ needs.local-environment-tests-post-merge.result }}" != "success" ]]
"${{ needs.deploy-ci-preview.result }}" != "success" ]]; then
"${{ needs.deploy-ci-preview.result }}" != "success" ]]
"${{ needs.upload-to-s3.result }}" != "success" ]]; then
echo "One or more needed jobs failed."
exit 1
else
Expand All @@ -536,7 +563,7 @@ jobs:

### Workflow dispatch flow ###############################################################################################################

build-linux-workflow-dispatch:
build-linux-x86_64-workflow-dispatch:
runs-on: ubuntu-latest
if: github.event_name == 'workflow_dispatch'
steps:
Expand Down Expand Up @@ -595,6 +622,27 @@ jobs:
./to-build/staging_preview_chain_spec.json
./to-build/staging_preprod_chain_spec.json

build-linux-arm64-workflow-dispatch:
if: github.event_name == 'workflow_dispatch'
permissions:
id-token: write
contents: write
runs-on: ubuntu-latest
steps:
- name: Checkout specific SHA
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.sha }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Build and Upload for linux arm64
uses: ./.github/actions/artifacts/build-pc-artifacts
with:
sha: ${{ inputs.sha }}
tag: ${{ inputs.sha }}
os: linux-arm64

build-macos-x86_64-workflow-dispatch:
if: github.event_name == 'workflow_dispatch'
permissions:
Expand Down Expand Up @@ -636,7 +684,8 @@ jobs:
upload-to-s3-workflow-dispatch:
if: github.event_name == 'workflow_dispatch'
needs:
- build-linux-workflow-dispatch
- build-linux-x86_64-workflow-dispatch
- build-linux-arm64-workflow-dispatch
- build-macos-x86_64-workflow-dispatch
- build-macos-arm64-workflow-dispatch
runs-on: ubuntu-latest
Expand All @@ -660,7 +709,7 @@ jobs:

upload-chain-specs-workflow-dispatch:
if: github.event_name == 'workflow_dispatch'
needs: build-linux-workflow-dispatch
needs: build-linux-x86_64-workflow-dispatch
runs-on: eks
steps:
- name: Checkout specific SHA
Expand All @@ -679,12 +728,13 @@ jobs:

workflow-dispatch-flow-complete:
if: ${{ always() && github.event_name == 'workflow_dispatch' }}
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]
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]
runs-on: ubuntu-latest
steps:
- name: Check if any needed job failed
run: |
if [[ "${{ needs.build-linux-workflow-dispatch.result }}" != "success" ||
if [[ "${{ needs.build-linux-x86_64-workflow-dispatch.result }}" != "success" ||
"${{ needs.build-linux-arm64-workflow-dispatch.result }}" != "success" ||
"${{ needs.build-macos-x86_64-workflow-dispatch.result }}" != "success" ||
"${{ needs.build-macos-arm64-workflow-dispatch.result }}" != "success" ||
"${{ needs.upload-to-s3-workflow-dispatch.result }}" != "success" ||
Expand Down
Loading