From 765cfecf86d645cb08ab9527f01f4ae14a7b64ce Mon Sep 17 00:00:00 2001 From: Xuejie Xiao Date: Thu, 2 Dec 2021 04:44:18 +0000 Subject: [PATCH] chore: add aarch64 build workflow to CI Now that aarch64 build has been tested for a while, I propose we include aarch64 build workflow as part of the CI process --- .cargo/config | 3 + .../workflows/ci_aarch64_build_ubuntu.yaml | 58 +++++++++++++++++++ devtools/ci/ci_main.sh | 19 ++++++ 3 files changed, 80 insertions(+) create mode 100644 .github/workflows/ci_aarch64_build_ubuntu.yaml diff --git a/.cargo/config b/.cargo/config index 708c54431b..39e142321a 100644 --- a/.cargo/config +++ b/.cargo/config @@ -2,3 +2,6 @@ name = "Nervos Core Dev" email = "dev@nervos.org" edition = "2018" + +[target.aarch64-unknown-linux-gnu] +linker = "aarch64-linux-gnu-gcc" diff --git a/.github/workflows/ci_aarch64_build_ubuntu.yaml b/.github/workflows/ci_aarch64_build_ubuntu.yaml new file mode 100644 index 0000000000..31aaa403dc --- /dev/null +++ b/.github/workflows/ci_aarch64_build_ubuntu.yaml @@ -0,0 +1,58 @@ +name: ci_aarch64_build_ubuntu +concurrency: + group: ci_aarch64_build_ubuntu-${{ github.ref }} + cancel-in-progress: true +on: + pull_request: + types: [ opened, synchronize, reopened ] + push: + branches: + - master + - develop + - trying + - staging + - 'rc/*' + + +env: + CARGO_TERM_COLOR: always + RUST_BACKTRACE: full + RUSTFLAGS: -D warnings +jobs: + prologue: + name: prologue + runs-on: ubuntu-20.04 + outputs: + os_skip: ${{ steps.prologue.outputs.os_skip }} + job_skip: ${{ steps.prologue.outputs.job_skip }} + linux_runner_label: ${{ steps.prologue.outputs.linux_runner_label }} + steps: + - uses: actions/checkout@v2 + - name: prologue + id: prologue + uses: ./.github/actions/ci_prologue + with: + GITHUB_EVENT_NAME: ${{ github.event_name }} + COMMIT_MESSAGE: "${{github.event.head_commit.message}}" + PR_COMMONS_BODY: "${{ github.event.pull_request.body }}" + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} + LABELS: "${{ toJson(github.event.pull_request.labels.*.name) }}" + GITHUB_REPOSITORY: ${{ github.repositoty }} + GITHUB_WORKFLOW: ${{ github.workflow }} + ci_aarch64_build_ubuntu: + name: ci_aarch64_build_ubuntu + needs: prologue + runs-on: ${{ needs.prologue.outputs.linux_runner_label }} + steps: + - uses: actions/checkout@v2 + - name: ci_aarch64_build_ubuntu + run: | + if [[ ${{ needs.prologue.outputs.os_skip }} == run ]] && [[ ${{ needs.prologue.outputs.job_skip }} == run ]];then + devtools/ci/ci_main.sh + else + echo "skip job" + exit 0 + fi + env: + RUNNER_LABEL: ${{ needs.prologue.outputs.runner_label }} + diff --git a/devtools/ci/ci_main.sh b/devtools/ci/ci_main.sh index e8330d6cae..d3adfa3be6 100755 --- a/devtools/ci/ci_main.sh +++ b/devtools/ci/ci_main.sh @@ -49,6 +49,25 @@ ci_integration_tests*) rustup target add wasm32-unknown-unknown make wasm-build-test ;; + ci_aarch64_build*) + echo "ci_aarch64_build" + sudo apt-get install -y gcc-multilib + sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu clang + rustup target add aarch64-unknown-linux-gnu + curl -LO https://www.openssl.org/source/openssl-1.1.1.tar.gz + tar -xvzf openssl-1.1.1.tar.gz + cd openssl-1.1.1 + CC=aarch64-linux-gnu-gcc ./Configure linux-aarch64 shared + CC=aarch64-linux-gnu-gcc make + cd .. + export TOP + export OPENSSL_LIB_DIR=$(pwd)/openssl-1.1.1 + export OPENSSL_INCLUDE_DIR=$(pwd)/openssl-1.1.1/include + export PKG_CONFIG_ALLOW_CROSS=1 + export CC=gcc + export CC_aarch64_unknown_linux_gnu=aarch64-linux-gnu-gcc + cargo build --target=aarch64-unknown-linux-gnu + ;; ci_cargo_deny*) echo "ci_security_audit_licenses" cargo deny --version || cargo +stable install cargo-deny --locked