From 1a9a475c2aef170abfd9e1e4d8eeb4d955384fa0 Mon Sep 17 00:00:00 2001 From: LongYinan Date: Thu, 22 Jul 2021 17:37:53 +0800 Subject: [PATCH] fix: linux aarch64 musl build --- .cargo/config.toml | 4 +- .github/workflows/CI.yaml | 118 +++++++++++++++++++++----------------- 2 files changed, 66 insertions(+), 56 deletions(-) diff --git a/.cargo/config.toml b/.cargo/config.toml index 4987562..eb0d042 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -11,5 +11,5 @@ rustflags = [ ] [target.aarch64-unknown-linux-musl] -linker = "aarch64-linux-gnu-gcc" -rustflags = ["-C", "target-feature=-crt-static", "-C", "link-arg=-lgcc"] +linker = "aarch64-linux-musl-gcc" +rustflags = ["-C", "target-feature=-crt-static"] diff --git a/.github/workflows/CI.yaml b/.github/workflows/CI.yaml index e5660bb..476c9f1 100644 --- a/.github/workflows/CI.yaml +++ b/.github/workflows/CI.yaml @@ -72,10 +72,12 @@ jobs: yarn build --target aarch64-linux-android - host: ubuntu-latest target: 'aarch64-unknown-linux-musl' - setup: | - sudo apt-get update - sudo apt-get install gcc-aarch64-linux-gnu -y - build: yarn build --target aarch64-unknown-linux-musl + downloadTarget: 'aarch64-unknown-linux-musl' + docker: | + docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD $DOCKER_REGISTRY_URL + docker pull ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine + docker tag ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine builder + build: docker run --rm -v ~/.cargo/git:/root/.cargo/git -v ~/.cargo/registry:/root/.cargo/registry -v $(pwd):/snappy -w /snappy builder sh -c "yarn build -- --target=aarch64-unknown-linux-musl" - host: windows-latest target: 'aarch64-pc-windows-msvc' build: yarn build --target aarch64-pc-windows-msvc @@ -189,7 +191,6 @@ jobs: yarn test rm -rf node_modules rm -rf target - - name: Upload artifact uses: actions/upload-artifact@v2 with: @@ -349,32 +350,52 @@ jobs: run: ls -R . shell: bash - - uses: uraimo/run-on-arch-action@v2.1.0 - name: Setup and run tests - id: runcmd + - name: Setup and run tests + uses: docker://multiarch/ubuntu-core:arm64-focal with: - arch: aarch64 - distro: ubuntu20.04 - - dockerRunArgs: | - --volume "${PWD}:/snappy" - -w /snappy - - # Not required, but speeds up builds by storing container images in - # a GitHub package registry. - githubToken: ${{ github.token }} - - install: | - apt-get update && \ - apt-get install -y ca-certificates gnupg2 curl apt-transport-https && \ - curl -sL https://deb.nodesource.com/setup_${{ matrix.node }}.x | bash - && \ - apt-get install -y nodejs && \ - npm install -g yarn - run: | - yarn install --ignore-scripts --registry https://registry.npmjs.org --network-timeout 300000 - yarn test - ls -la + args: > + sh -c " + apt-get update && \ + apt-get install -y ca-certificates gnupg2 curl apt-transport-https && \ + curl -sL https://deb.nodesource.com/setup_${{ matrix.node }}.x | bash - && \ + apt-get install -y nodejs && \ + npm install -g yarn && \ + yarn install --ignore-scripts --registry https://registry.npmjs.org --network-timeout 300000 && \ + yarn test && \ + ls -la + " + test-linux-aarch64-musl-binding: + name: Test bindings on aarch64-unknown-linux-musl - node@${{ matrix.node }} + needs: + - build + + runs-on: ubuntu-20.04 + + steps: + - run: docker run --rm --privileged multiarch/qemu-user-static:register --reset + + - uses: actions/checkout@v2 + + - name: Download artifacts + uses: actions/download-artifact@v2 + with: + name: bindings-aarch64-unknown-linux-musl + path: . + + - name: List packages + run: ls -R . + shell: bash + - name: Setup and run tests + uses: docker://multiarch/alpine:aarch64-latest-stable + with: + args: > + sh -c " + apk add nodejs npm && \ + npm install -g yarn && \ + yarn install --ignore-scripts --registry https://registry.npmjs.org --network-timeout 300000 && \ + npm test + " test-linux-arm-gnueabihf-binding: name: Test bindings on armv7-unknown-linux-gnueabihf - node@${{ matrix.node }} needs: @@ -400,32 +421,20 @@ jobs: run: ls -R . shell: bash - - uses: uraimo/run-on-arch-action@v2.1.0 - name: Setup and run tests - id: runcmd + - name: Setup and run tests + uses: docker://multiarch/ubuntu-core:armhf-focal with: - arch: armv7 - distro: ubuntu20.04 - - dockerRunArgs: | - --volume "${PWD}:/snappy" - -w /snappy - - # Not required, but speeds up builds by storing container images in - # a GitHub package registry. - githubToken: ${{ github.token }} - - install: | - apt-get update && \ - apt-get install -y ca-certificates gnupg2 curl apt-transport-https && \ - curl -sL https://deb.nodesource.com/setup_${{ matrix.node }}.x | bash - && \ - apt-get install -y nodejs && \ - npm install -g yarn - run: | - yarn install --ignore-scripts --registry https://registry.npmjs.org --network-timeout 300000 - yarn test - ls -la - + args: > + sh -c " + apt-get update && \ + apt-get install -y ca-certificates gnupg2 curl apt-transport-https && \ + curl -sL https://deb.nodesource.com/setup_${{ matrix.node }}.x | bash - && \ + apt-get install -y nodejs && \ + npm install -g yarn && \ + yarn install --ignore-scripts --registry https://registry.npmjs.org --network-timeout 300000 && \ + yarn test && \ + ls -la + " publish: name: Publish runs-on: ubuntu-20.04 @@ -435,6 +444,7 @@ jobs: - test-linux-aarch64-gnu-binding - test-linux-arm-gnueabihf-binding - test-macOS-windows-binding + - test-linux-aarch64-musl-binding - build-freebsd steps: