فهرست منبع

build: fix linux aarch64 musl

LongYinan 4 سال پیش
والد
کامیت
cf77a29a8e
2فایلهای تغییر یافته به همراه77 افزوده شده و 62 حذف شده
  1. 2 2
      .cargo/config.toml
  2. 75 60
      .github/workflows/CI.yaml

+ 2 - 2
.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"]

+ 75 - 60
.github/workflows/CI.yaml

@@ -37,7 +37,7 @@ jobs:
             setup: |
               choco install nodejs-lts --x86 -y --force
               echo "C:\\Program Files (x86)\\nodejs" >> $GITHUB_PATH
-          - host: ubuntu-20.04
+          - host: ubuntu-latest
             target: 'x86_64-unknown-linux-gnu'
             docker: |
               docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD $DOCKER_REGISTRY_URL
@@ -45,7 +45,7 @@ jobs:
               docker tag $DOCKER_REGISTRY_URL/napi-rs/napi-rs/nodejs-rust:lts-debian builder
             build: |
               docker run --rm -v ~/.cargo/git:/root/.cargo/git -v ~/.cargo/registry:/root/.cargo/registry -v $(pwd):/build -w /build builder yarn build
-          - host: ubuntu-20.04
+          - host: ubuntu-latest
             target: 'x86_64-unknown-linux-musl'
             docker: |
               docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD $DOCKER_REGISTRY_URL
@@ -55,27 +55,28 @@ jobs:
           - host: macos-latest
             target: 'aarch64-apple-darwin'
             build: yarn build --target=aarch64-apple-darwin
-          - host: ubuntu-20.04
+          - host: ubuntu-latest
             target: 'aarch64-unknown-linux-gnu'
             setup: |
               sudo apt-get install g++-aarch64-linux-gnu gcc-aarch64-linux-gnu -y
             build: yarn build --target=aarch64-unknown-linux-gnu
-          - host: ubuntu-20.04
+          - host: ubuntu-latest
             target: 'armv7-unknown-linux-gnueabihf'
             setup: |
               sudo apt-get install gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf -y
             build: yarn build --target=armv7-unknown-linux-gnueabihf
-          - host: ubuntu-20.04
+          - host: ubuntu-latest
             target: 'aarch64-linux-android'
             build: |
               export CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER="${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android24-clang"
               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
+            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):/package-template -w /package-template 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
@@ -250,7 +251,7 @@ jobs:
       fail-fast: false
       matrix:
         node: ['12', '14', '16']
-    runs-on: ubuntu-20.04
+    runs-on: ubuntu-latest
 
     steps:
       - uses: actions/checkout@v2
@@ -291,7 +292,7 @@ jobs:
       fail-fast: false
       matrix:
         node: ['12', '14', '16']
-    runs-on: ubuntu-20.04
+    runs-on: ubuntu-latest
 
     steps:
       - uses: actions/checkout@v2
@@ -332,7 +333,7 @@ jobs:
       fail-fast: false
       matrix:
         node: ['12', '14', '16']
-    runs-on: ubuntu-20.04
+    runs-on: ubuntu-latest
 
     steps:
       - run: docker run --rm --privileged multiarch/qemu-user-static:register --reset
@@ -349,31 +350,54 @@ jobs:
         run: ls -R .
         shell: bash
 
-      - uses: uraimo/run-on-arch-action@v2.0.9
-        name: Setup and run tests
+      - name: Setup and run tests
+        uses: docker://multiarch/ubuntu-core:arm64-focal
         id: runcmd
         with:
-          arch: aarch64
-          distro: ubuntu20.04
-
-          dockerRunArgs: |
-            --volume "${PWD}:/${{ env.APP_NAME }}"
-            -w /${{ env.APP_NAME }}
-
-          # 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@lts
+    needs:
+      - build
+
+    runs-on: ubuntu-latest
+
+    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 }}
@@ -383,7 +407,7 @@ jobs:
       fail-fast: false
       matrix:
         node: ['12', '14', '16']
-    runs-on: ubuntu-20.04
+    runs-on: ubuntu-latest
 
     steps:
       - run: docker run --rm --privileged multiarch/qemu-user-static:register --reset
@@ -400,41 +424,32 @@ jobs:
         run: ls -R .
         shell: bash
 
-      - uses: uraimo/run-on-arch-action@v2.0.9
-        name: Setup and run tests
+      - name: Setup and run tests
+        uses: docker://multiarch/ubuntu-core:armhf-focal
         id: runcmd
         with:
-          arch: armv7
-          distro: ubuntu20.04
-
-          dockerRunArgs: |
-            --volume "${PWD}:/${{ env.APP_NAME }}"
-            -w /${{ env.APP_NAME }}
-
-          # 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
+    runs-on: ubuntu-latest
     needs:
       - test-linux-x64-gnu-binding
       - test-linux-x64-musl-binding
       - test-linux-aarch64-gnu-binding
       - test-linux-arm-gnueabihf-binding
       - test-macOS-windows-binding
+      - test-linux-aarch64-musl-binding
       - build-freebsd
 
     steps: