Forráskód Böngészése

ci: refactor ci jobs

LongYinan 4 éve
szülő
commit
c64c3020a8
10 módosított fájl, 870 hozzáadás és 923 törlés
  1. 0 6
      .cargo/config
  2. 11 0
      .cargo/config.toml
  3. 204 429
      .github/workflows/CI.yaml
  4. 16 0
      .github/workflows/auto-merge.yaml
  5. 1 0
      .husky/.gitignore
  6. 4 0
      .husky/pre-commit
  7. 1 1
      Cargo.toml
  8. 6 11
      package.json
  9. 7 1
      src/lib.rs
  10. 620 475
      yarn.lock

+ 0 - 6
.cargo/config

@@ -1,6 +0,0 @@
-[target.aarch64-unknown-linux-gnu]
-linker = "aarch64-linux-gnu-gcc"
-
-
-[target.armv7-unknown-linux-gnueabihf]
-linker = "arm-linux-gnueabihf-gcc"

+ 11 - 0
.cargo/config.toml

@@ -0,0 +1,11 @@
+[target.aarch64-unknown-linux-gnu]
+linker = "aarch64-linux-gnu-gcc-10"
+
+[target.armv7-unknown-linux-gnueabihf]
+linker = "arm-linux-gnueabihf-gcc-10"
+
+[target.x86_64-unknown-linux-musl]
+rustflags = [
+  "-C",
+  "target-feature=-crt-static",
+]

+ 204 - 429
.github/workflows/CI.yaml

@@ -3,6 +3,7 @@ name: CI
 env:
   DEBUG: 'napi:*'
   APP_NAME: 'package-template'
+  MACOSX_DEPLOYMENT_TARGET: '10.13'
 
 on:
   push:
@@ -19,10 +20,59 @@ jobs:
     strategy:
       fail-fast: false
       matrix:
-        os: [ubuntu-latest, macos-latest, windows-latest]
-
-    name: stable - ${{ matrix.os }} - node@14
-    runs-on: ${{ matrix.os }}
+        settings:
+          - host: macos-latest
+            target: 'x86_64-apple-darwin'
+            build: yarn build
+          - host: windows-latest
+            build: yarn build
+            target: 'x86_64-pc-windows-msvc'
+          - host: windows-latest
+            build: |
+              export CARGO_PROFILE_RELEASE_CODEGEN_UNITS=32;
+              export CARGO_PROFILE_RELEASE_LTO=false
+              yarn build --target i686-pc-windows-msvc
+              yarn test
+            target: 'i686-pc-windows-msvc'
+            setup: |
+              choco install nodejs-lts --x86 -y --force
+              echo "C:\\Program Files (x86)\\nodejs" >> $GITHUB_PATH
+          - host: ubuntu-20.04
+            target: 'x86_64-unknown-linux-gnu'
+            docker: |
+              docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD $DOCKER_REGISTRY_URL
+              docker pull $DOCKER_REGISTRY_URL/napi-rs/napi-rs/nodejs-rust:lts-debian
+              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
+            target: 'x86_64-unknown-linux-musl'
+            docker: |
+              docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD $DOCKER_REGISTRY_URL
+              docker pull $DOCKER_REGISTRY_URL/napi-rs/napi-rs/nodejs-rust:lts-alpine
+              docker tag $DOCKER_REGISTRY_URL/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):/build -w /build builder yarn build
+          - host: macos-latest
+            target: 'aarch64-apple-darwin'
+            build: yarn build --target=aarch64-apple-darwin
+          - host: ubuntu-20.04
+            target: 'aarch64-unknown-linux-gnu'
+            setup: |
+              sudo apt-get install g++-10-aarch64-linux-gnu gcc-10-aarch64-linux-gnu -y
+            build: yarn build --target=aarch64-unknown-linux-gnu
+          - host: ubuntu-20.04
+            target: 'armv7-unknown-linux-gnueabihf'
+            setup: |
+              sudo apt-get install gcc-10-arm-linux-gnueabihf g++-10-arm-linux-gnueabihf -y
+            build: yarn build --target=armv7-unknown-linux-gnueabihf
+          - host: ubuntu-20.04
+            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
+
+    name: stable - ${{ matrix.settings.target }} - node@14
+    runs-on: ${{ matrix.settings.host }}
 
     steps:
       - uses: actions/checkout@v2
@@ -36,9 +86,10 @@ jobs:
       - name: Install
         uses: actions-rs/toolchain@v1
         with:
-          toolchain: stable
           profile: minimal
           override: true
+          toolchain: stable
+          target: ${{ matrix.settings.target }}
 
       - name: Generate Cargo.lock
         uses: actions-rs/cargo@v1
@@ -49,298 +100,101 @@ jobs:
         uses: actions/cache@v1
         with:
           path: ~/.cargo/registry
-          key: stable-${{ matrix.os }}-node@14-cargo-registry-trimmed-${{ hashFiles('**/Cargo.lock') }}
+          key: ${{ matrix.settings.target }}-node@14-cargo-registry-trimmed-${{ hashFiles('**/Cargo.lock') }}
 
       - name: Cache cargo index
         uses: actions/cache@v1
         with:
           path: ~/.cargo/git
-          key: stable-${{ matrix.os }}-node@14-cargo-index-trimmed-${{ hashFiles('**/Cargo.lock') }}
-
-      - name: Cache NPM dependencies
-        uses: actions/cache@v1
-        with:
-          path: node_modules
-          key: npm-cache-${{ matrix.os }}-node@14-${{ hashFiles('yarn.lock') }}
-
-      - name: 'Install dependencies'
-        run: yarn install --frozen-lockfile --registry https://registry.npmjs.org --network-timeout 300000
-
-      - name: 'Build'
-        run: yarn build
-        env:
-          MACOSX_DEPLOYMENT_TARGET: '10.13'
-
-      - name: Upload artifact
-        uses: actions/upload-artifact@v2
-        with:
-          name: bindings-${{ matrix.os }}
-          path: ${{ env.APP_NAME }}.*.node
-
-      - name: Clear the cargo caches
-        run: |
-          cargo install cargo-cache --no-default-features --features ci-autoclean
-          cargo-cache
-
-  build-windows-i686:
-    if: "!contains(github.event.head_commit.message, 'skip ci')"
-    name: stable - windows-i686 - node@10
-    runs-on: windows-latest
-    env:
-      CARGO_PROFILE_RELEASE_CODEGEN_UNITS: 32
-      CARGO_PROFILE_RELEASE_LTO: 'false'
-    steps:
-      - uses: actions/checkout@v2
-
-      - name: Install node x86
-        run: |
-          choco install nodejs-lts --x86 -y --force
-          refreshenv
-      - name: Set 32bit NodeJS path
-        run: |
-          echo "C:\\Program Files (x86)\\nodejs" >> $GITHUB_PATH
-        shell: bash
-
-      - name: NodeJS arch
-        run: node -e "console.log(process.arch)"
+          key: ${{ matrix.settings.target }}-node@14-cargo-index-trimmed-${{ hashFiles('**/Cargo.lock') }}
 
       - name: Cache NPM dependencies
         uses: actions/cache@v1
         with:
           path: node_modules
-          key: npm-cache-windows-i686-node@lts-${{ hashFiles('yarn.lock') }}
-
-      - name: Install dependencies
-        run: yarn install --frozen-lockfile --registry https://registry.npmjs.org --network-timeout 300000
-
-      - name: Install
-        uses: actions-rs/toolchain@v1
-        with:
-          toolchain: stable
-          profile: minimal
-          override: true
-
-      - name: Install i686 toolchain
-        run: rustup target add i686-pc-windows-msvc
+          key: npm-cache-${{ matrix.settings.target }}-node@14-${{ hashFiles('yarn.lock') }}
 
-      - name: Generate Cargo.lock
-        uses: actions-rs/cargo@v1
-        with:
-          command: generate-lockfile
-
-      - name: Cache cargo registry
-        uses: actions/cache@v1
-        with:
-          path: ~/.cargo/registry
-          key: stable-windows-i686-node@lts-cargo-registry-trimmed-${{ hashFiles('**/Cargo.lock') }}
-
-      - name: Cache cargo index
-        uses: actions/cache@v1
-        with:
-          path: ~/.cargo/git
-          key: stable-windows-i686-node@lts-cargo-index-trimmed-${{ hashFiles('**/Cargo.lock') }}
-
-      - name: Cross build i686
-        run: yarn build --target i686-pc-windows-msvc
-
-      - name: Test binary
-        run: yarn test
-
-      - name: Upload artifact
-        uses: actions/upload-artifact@v2
-        with:
-          name: bindings-win32-i686
-          path: ${{ env.APP_NAME }}.*.node
-
-  build-linux-musl:
-    if: "!contains(github.event.head_commit.message, 'skip ci')"
-    name: stable - linux-musl - node@10
-    runs-on: ubuntu-latest
-
-    steps:
-      - uses: actions/checkout@v2
-
-      - name: Login to registry
-        run: |
-          docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD $DOCKER_REGISTRY_URL
+      - name: Pull latest image
+        run: ${{ matrix.settings.docker }}
         env:
-          DOCKER_REGISTRY_URL: docker.pkg.github.com
+          DOCKER_REGISTRY_URL: ghcr.io
           DOCKER_USERNAME: ${{ github.actor }}
           DOCKER_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
+        if: ${{ matrix.settings.docker }}
 
-      - name: Pull docker image
-        run: |
-          docker pull docker.pkg.github.com/napi-rs/napi-rs/rust-nodejs-alpine:lts
-          docker tag docker.pkg.github.com/napi-rs/napi-rs/rust-nodejs-alpine:lts builder
-
-      - name: Generate Cargo.lock
-        uses: actions-rs/cargo@v1
-        with:
-          command: generate-lockfile
-
-      - name: Cache cargo registry
-        uses: actions/cache@v1
-        with:
-          path: ~/.cargo/registry
-          key: stable-node-alpine-@10-cargo-registry-trimmed-${{ hashFiles('**/Cargo.lock') }}
-
-      - name: Cache cargo index
-        uses: actions/cache@v1
-        with:
-          path: ~/.cargo/git
-          key: stable-node-alpine-@10-cargo-index-trimmed-${{ hashFiles('**/Cargo.lock') }}
-
-      - name: Cache NPM dependencies
-        uses: actions/cache@v1
-        with:
-          path: node_modules
-          key: npm-cache-alpine-node@10-${{ hashFiles('yarn.lock') }}
+      - name: Setup toolchain
+        run: ${{ matrix.settings.setup }}
+        if: ${{ matrix.settings.setup }}
+        shell: bash
 
       - name: 'Install dependencies'
-        run: yarn install --frozen-lockfile --registry https://registry.npmjs.org --network-timeout 300000
+        run: yarn install --ignore-scripts --frozen-lockfile --registry https://registry.npmjs.org --network-timeout 300000
 
       - name: 'Build'
-        run: |
-          docker run --rm -v ~/.cargo/git:/root/.cargo/git -v ~/.cargo/registry:/root/.cargo/registry -v $(pwd):/${{ env.APP_NAME }} -e DEBUG="napi:*" -w /${{ env.APP_NAME }} builder sh -c "yarn build"
-
-      - name: Upload artifact
-        uses: actions/upload-artifact@v2
-        with:
-          name: bindings-linux-musl
-          path: ${{ env.APP_NAME }}.*.node
-
-  build-linux-arm7:
-    name: stable - arm7-unknown-linux-gnu - node@14
-    runs-on: ubuntu-latest
-
-    steps:
-      - run: docker run --rm --privileged multiarch/qemu-user-static:register --reset
-
-      - uses: actions/checkout@v2
-
-      - name: Setup node
-        uses: actions/setup-node@v1
-        with:
-          node-version: 14
-
-      - name: Install
-        uses: actions-rs/toolchain@v1
-        with:
-          toolchain: stable
-          profile: minimal
-          override: true
-
-      - name: Generate Cargo.lock
-        uses: actions-rs/cargo@v1
-        with:
-          command: generate-lockfile
-
-      - name: Cache cargo registry
-        uses: actions/cache@v1
-        with:
-          path: ~/.cargo/registry
-          key: stable-linux-arm7-gnu-node@14-cargo-registry-trimmed-${{ hashFiles('**/Cargo.lock') }}
-
-      - name: Cache cargo index
-        uses: actions/cache@v1
-        with:
-          path: ~/.cargo/git
-          key: stable-linux-arm7-gnu-node@14-cargo-index-trimmed-${{ hashFiles('**/Cargo.lock') }}
-
-      - name: Cache NPM dependencies
-        uses: actions/cache@v1
-        with:
-          path: node_modules
-          key: npm-cache-linux-arm7-gnu-node@14-${{ hashFiles('yarn.lock') }}
-
-      - name: Install aarch64 toolchain
-        run: rustup target add armv7-unknown-linux-gnueabihf
-
-      - name: Install cross compile toolchain
-        run: |
-          sudo apt-get update
-          sudo apt-get install gcc-arm-linux-gnueabihf -y
-
-      - name: Install dependencies
-        run: yarn install --frozen-lockfile --registry https://registry.npmjs.org --network-timeout 300000
-
-      - name: Cross build arm7
-        run: yarn build --target armv7-unknown-linux-gnueabihf
+        run: ${{ matrix.settings.build }}
+        shell: bash
 
       - name: Upload artifact
         uses: actions/upload-artifact@v2
         with:
-          name: bindings-linux-arm7
+          name: bindings-${{ matrix.settings.target }}
           path: ${{ env.APP_NAME }}.*.node
 
-  build-linux-aarch64:
-    name: stable - aarch64-unknown-linux-gnu - node@14
-    runs-on: ubuntu-latest
+  test-macOS-windows-binding:
+    name: Test bindings on ${{ matrix.settings.target }} - node@${{ matrix.node }}
+    needs:
+      - build
+    strategy:
+      fail-fast: false
+      matrix:
+        settings:
+          - host: macos-latest
+            target: 'x86_64-apple-darwin'
+          - host: windows-latest
+            target: 'x86_64-pc-windows-msvc'
+        node: ['10', '12', '14', '15']
+    runs-on: ${{ matrix.settings.host }}
 
     steps:
-      - run: docker run --rm --privileged multiarch/qemu-user-static:register --reset
-
       - uses: actions/checkout@v2
 
       - name: Setup node
         uses: actions/setup-node@v2
         with:
-          node-version: 14
+          node-version: ${{ matrix.node }}
           check-latest: true
 
-      - name: Install
-        uses: actions-rs/toolchain@v1
-        with:
-          toolchain: stable
-          profile: minimal
-          override: true
-
-      - name: Install aarch64 toolchain
-        run: rustup target add aarch64-unknown-linux-gnu
-
-      - name: Generate Cargo.lock
-        uses: actions-rs/cargo@v1
-        with:
-          command: generate-lockfile
-
-      - name: Cache cargo registry
-        uses: actions/cache@v1
-        with:
-          path: ~/.cargo/registry
-          key: stable-linux-aarch64-gnu-node@14-cargo-registry-trimmed-${{ hashFiles('**/Cargo.lock') }}
-
-      - name: Cache cargo index
-        uses: actions/cache@v1
-        with:
-          path: ~/.cargo/git
-          key: stable-linux-aarch64-gnu-node@14-cargo-index-trimmed-${{ hashFiles('**/Cargo.lock') }}
-
       - name: Cache NPM dependencies
         uses: actions/cache@v1
         with:
           path: node_modules
-          key: npm-cache-linux-aarch64-gnu-node@14-${{ hashFiles('yarn.lock') }}
+          key: npm-cache-test-${{ matrix.settings.target }}-${{ matrix.node }}-${{ hashFiles('yarn.lock') }}
 
-      - name: Install cross compile toolchain
-        run: |
-          sudo apt-get update
-          sudo apt-get install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu -y
+      - name: 'Install dependencies'
+        run: yarn install --ignore-scripts --frozen-lockfile --registry https://registry.npmjs.org --network-timeout 300000
 
-      - name: Install dependencies
-        run: yarn install --frozen-lockfile --registry https://registry.npmjs.org --network-timeout 300000
+      - name: Download artifacts
+        uses: actions/download-artifact@v2
+        with:
+          name: bindings-${{ matrix.settings.target }}
+          path: .
 
-      - name: Cross build aarch64
-        run: yarn build --target aarch64-unknown-linux-gnu
+      - name: List packages
+        run: ls -R .
+        shell: bash
 
-      - name: Upload artifact
-        uses: actions/upload-artifact@v2
-        with:
-          name: bindings-linux-aarch64
-          path: ${{ env.APP_NAME }}.*.node
+      - name: Test bindings
+        run: yarn test
 
-  build-apple-silicon:
-    name: stable - aarch64-apple-darwin - node@14
-    runs-on: macos-latest
+  test-linux-x64-gnu-binding:
+    name: Test bindings on Linux-x64-gnu - node@${{ matrix.node }}
+    needs:
+      - build
+    strategy:
+      fail-fast: false
+      matrix:
+        node: ['10', '12', '14', '15']
+    runs-on: ubuntu-20.04
 
     steps:
       - uses: actions/checkout@v2
@@ -348,116 +202,40 @@ jobs:
       - name: Setup node
         uses: actions/setup-node@v2
         with:
-          node-version: 14
+          node-version: ${{ matrix.node }}
           check-latest: true
 
-      - name: Install
-        uses: actions-rs/toolchain@v1
-        with:
-          toolchain: stable
-          profile: minimal
-          override: true
-
-      - name: Install aarch64 toolchain
-        run: rustup target add aarch64-apple-darwin
-
-      - name: Generate Cargo.lock
-        uses: actions-rs/cargo@v1
-        with:
-          command: generate-lockfile
-
-      - name: Cache cargo registry
-        uses: actions/cache@v1
-        with:
-          path: ~/.cargo/registry
-          key: stable-apple-aarch64-node@14-cargo-registry-trimmed-${{ hashFiles('**/Cargo.lock') }}
-
-      - name: Cache cargo index
-        uses: actions/cache@v1
-        with:
-          path: ~/.cargo/git
-          key: stable-apple-aarch64-node@14-cargo-index-trimmed-${{ hashFiles('**/Cargo.lock') }}
-
       - name: Cache NPM dependencies
         uses: actions/cache@v1
         with:
           path: node_modules
-          key: npm-cache-apple-aarch64-node@14-${{ hashFiles('yarn.lock') }}
-
-      - name: Install dependencies
-        run: yarn install --frozen-lockfile --registry https://registry.npmjs.org --network-timeout 300000
-
-      - name: Cross build aarch64
-        run: yarn build --target aarch64-apple-darwin
-
-      - name: Upload artifact
-        uses: actions/upload-artifact@v2
-        with:
-          name: bindings-apple-aarch64
-          path: ${{ env.APP_NAME }}.*.node
-
-  build-android-aarch64:
-    name: Build - Android - aarch64
-    runs-on: macos-latest
-    steps:
-      - uses: actions/checkout@v2
+          key: npm-cache-test-linux-x64-gnu-${{ matrix.node }}-${{ hashFiles('yarn.lock') }}
 
-      - name: Setup node
-        uses: actions/setup-node@v1
-        with:
-          node-version: 14
-
-      - name: Install aarch64 toolchain
-        run: rustup target add aarch64-linux-android
-
-      - name: Generate Cargo.lock
-        uses: actions-rs/cargo@v1
-        with:
-          command: generate-lockfile
-
-      - name: Cache cargo registry
-        uses: actions/cache@v1
-        with:
-          path: ~/.cargo/registry
-          key: stable-apple-aarch64-node@14-cargo-registry-trimmed-${{ hashFiles('**/Cargo.lock') }}
-
-      - name: Cache cargo index
-        uses: actions/cache@v1
-        with:
-          path: ~/.cargo/git
-          key: stable-apple-aarch64-node@14-cargo-index-trimmed-${{ hashFiles('**/Cargo.lock') }}
+      - name: 'Install dependencies'
+        run: yarn install --ignore-scripts --frozen-lockfile --registry https://registry.npmjs.org --network-timeout 300000
 
-      - name: Cache NPM dependencies
-        uses: actions/cache@v1
+      - name: Download artifacts
+        uses: actions/download-artifact@v2
         with:
-          path: node_modules
-          key: npm-cache-apple-aarch64-node@14-${{ hashFiles('yarn.lock') }}
-
-      - name: Install dependencies
-        run: yarn install --frozen-lockfile --registry https://registry.npmjs.org --network-timeout 300000
+          name: bindings-x86_64-unknown-linux-gnu
+          path: .
 
-      - name: Build
+      - name: List packages
+        run: ls -R .
         shell: bash
-        run: |
-          export CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER="${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/darwin-x86_64/bin/aarch64-linux-android24-clang"
-          yarn build --target aarch64-linux-android
 
-      - name: Upload artifact
-        uses: actions/upload-artifact@v2
-        with:
-          name: bindings-android-aarch64
-          path: ${{ env.APP_NAME }}.*.node
+      - name: Test bindings
+        run: docker run --rm -v $(pwd):/canvas -w /canvas node:${{ matrix.node }}-slim yarn test
 
-  test:
-    name: Test bindings on ${{ matrix.os }} - node@${{ matrix.node }}
+  test-linux-x64-musl-binding:
+    name: Test bindings on x86_64-unknown-linux-musl - node@${{ matrix.node }}
     needs:
       - build
     strategy:
       fail-fast: false
       matrix:
-        os: [ubuntu-latest, macos-latest, windows-latest]
         node: ['10', '12', '14', '15']
-    runs-on: ${{ matrix.os }}
+    runs-on: ubuntu-20.04
 
     steps:
       - uses: actions/checkout@v2
@@ -472,15 +250,15 @@ jobs:
         uses: actions/cache@v1
         with:
           path: node_modules
-          key: npm-cache-test-${{ matrix.os }}-node@${{ matrix.node }}-${{ hashFiles('yarn.lock') }}
+          key: npm-cache-test-x86_64-unknown-linux-musl-${{ matrix.node }}-${{ hashFiles('yarn.lock') }}
 
       - name: 'Install dependencies'
-        run: yarn install --frozen-lockfile --registry https://registry.npmjs.org --network-timeout 300000
+        run: yarn install --ignore-scripts --frozen-lockfile --registry https://registry.npmjs.org --network-timeout 300000
 
       - name: Download artifacts
         uses: actions/download-artifact@v2
         with:
-          name: bindings-${{ matrix.os }}
+          name: bindings-x86_64-unknown-linux-musl
           path: .
 
       - name: List packages
@@ -488,123 +266,119 @@ jobs:
         shell: bash
 
       - name: Test bindings
-        run: yarn test
+        run: docker run --rm -v $(pwd):/canvas -w /canvas node:${{ matrix.node }}-alpine yarn test
 
-  test-musl:
-    name: Test bindings on alpine - node@${{ matrix.node }}
+  test-linux-aarch64-gnu-binding:
+    name: Test bindings on aarch64-unknown-linux-gnu - node@${{ matrix.node }}
     needs:
-      - build-linux-musl
+      - build
     strategy:
       fail-fast: false
       matrix:
         node: ['10', '12', '14', '15']
-    runs-on: ubuntu-latest
+    runs-on: ubuntu-20.04
 
     steps:
-      - uses: actions/checkout@v2
-
-      - name: Cache NPM dependencies
-        uses: actions/cache@v1
-        with:
-          path: node_modules
-          key: npm-cache-alpine-node@${{ matrix.node }}-${{ hashFiles('yarn.lock') }}
+      - run: docker run --rm --privileged multiarch/qemu-user-static:register --reset
 
-      - name: 'Install dependencies'
-        run: yarn install --frozen-lockfile --ignore-scripts --registry https://registry.npmjs.org --network-timeout 300000
+      - uses: actions/checkout@v2
 
       - name: Download artifacts
         uses: actions/download-artifact@v2
         with:
-          name: bindings-linux-musl
+          name: bindings-aarch64-unknown-linux-gnu
           path: .
 
-      - name: List files
+      - name: List packages
         run: ls -R .
         shell: bash
 
-      - name: Run tests
-        run: docker run --rm -v $(pwd):/${{ env.APP_NAME }} -w /${{ env.APP_NAME }} node:${{ matrix.node }}-alpine sh -c "yarn test"
-
-  test-aarch64:
-    name: stable - aarch64-unknown-linux-gnu - node@${{ matrix.node }}
-    runs-on: ubuntu-latest
-
+      - uses: uraimo/run-on-arch-action@v2.0.9
+        name: Setup and run tests
+        id: runcmd
+        with:
+          arch: aarch64
+          distro: ubuntu20.04
+
+          dockerRunArgs: |
+            --volume "${PWD}:/canvas"
+            -w /canvas
+
+          # 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
+
+  test-linux-arm-gnueabihf-binding:
+    name: Test bindings on armv7-unknown-linux-gnueabihf - node@${{ matrix.node }}
     needs:
-      - build-linux-aarch64
+      - build
     strategy:
       fail-fast: false
       matrix:
         node: ['10', '12', '14', '15']
+    runs-on: ubuntu-20.04
 
     steps:
       - run: docker run --rm --privileged multiarch/qemu-user-static:register --reset
 
       - uses: actions/checkout@v2
 
-      - name: Setup node
-        uses: actions/setup-node@v2
-        with:
-          node-version: ${{ matrix.node }}
-          check-latest: true
-
-      - name: Cache NPM dependencies
-        uses: actions/cache@v1
-        with:
-          path: node_modules
-          key: npm-cache-test-linux-aarch64-gnu-node@${{ matrix.node }}-${{ hashFiles('yarn.lock') }}
-
-      - name: 'Install dependencies'
-        run: yarn install --frozen-lockfile --registry https://registry.npmjs.org --network-timeout 300000
-
       - name: Download artifacts
         uses: actions/download-artifact@v2
         with:
-          name: bindings-linux-aarch64
+          name: bindings-armv7-unknown-linux-gnueabihf
           path: .
 
-      - name: List
-        run: ls -a
+      - name: List packages
+        run: ls -R .
+        shell: bash
 
-      - name: Run tests
-        uses: docker://multiarch/ubuntu-core:arm64-focal
+      - uses: uraimo/run-on-arch-action@v2.0.9
+        name: Setup and run tests
+        id: runcmd
         with:
-          args: >
-            sh -c "
-              apt-get update && \
-              apt-get install -y ca-certificates gnupg2 curl && \
-              curl -sL https://deb.nodesource.com/setup_${{ matrix.node }}.x | bash - && \
-              apt-get install -y nodejs && \
-              node ./simple-test.js
-            "
-
-  dependabot:
-    needs:
-      - test
-      - test-musl
-      - test-aarch64
-      - build-windows-i686
-      - build-apple-silicon
-      - build-linux-arm7
-      - build-android-aarch64
-    runs-on: ubuntu-latest
-    steps:
-      - name: auto-merge
-        uses: ridedott/dependabot-auto-merge-action@master
-        with:
-          GITHUB_LOGIN: dependabot[bot]
-          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+          arch: armv7
+          distro: ubuntu20.04
+
+          dockerRunArgs: |
+            --volume "${PWD}:/canvas"
+            -w /canvas
+
+          # 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
 
   publish:
     name: Publish
-    runs-on: ubuntu-latest
+    runs-on: ubuntu-20.04
     needs:
-      - test
-      - test-musl
-      - test-aarch64
-      - build-windows-i686
-      - build-apple-silicon
-      - build-linux-arm7
-      - build-android-aarch64
+      - test-linux-x64-gnu-binding
+      - test-linux-x64-musl-binding
+      - test-linux-aarch64-gnu-binding
+      - test-linux-arm-gnueabihf-binding
+      - test-macOS-windows-binding
 
     steps:
       - uses: actions/checkout@v2
@@ -619,10 +393,11 @@ jobs:
         uses: actions/cache@v1
         with:
           path: node_modules
-          key: npm-cache-publish-ubuntu-latest-${{ hashFiles('yarn.lock') }}
-
+          key: npm-cache-ubuntu-latest-${{ hashFiles('yarn.lock') }}
+          restore-keys: |
+            npm-cache-
       - name: 'Install dependencies'
-        run: yarn install --frozen-lockfile --registry https://registry.npmjs.org --network-timeout 300000
+        run: yarn install --ignore-scripts --frozen-lockfile --registry https://registry.npmjs.org --network-timeout 300000
 
       - name: Download all artifacts
         uses: actions/download-artifact@v2
@@ -633,7 +408,7 @@ jobs:
         run: yarn artifacts
 
       - name: List packages
-        run: ls -R npm
+        run: ls -R .
         shell: bash
 
       - name: Publish

+ 16 - 0
.github/workflows/auto-merge.yaml

@@ -0,0 +1,16 @@
+name: Dependabot auto merge
+
+on:
+  check_suite:
+    types:
+      - completed
+
+jobs:
+  merge:
+    name: Merge
+    runs-on: ubuntu-latest
+    steps:
+      - name: Auto merge
+        uses: ridedott/merge-me-action@v2
+        with:
+          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

+ 1 - 0
.husky/.gitignore

@@ -0,0 +1 @@
+_

+ 4 - 0
.husky/pre-commit

@@ -0,0 +1,4 @@
+#!/bin/sh
+. "$(dirname "$0")/_/husky.sh"
+
+yarn lint-staged

+ 1 - 1
Cargo.toml

@@ -13,7 +13,7 @@ crate-type = ["cdylib"]
 napi = "1"
 napi-derive = "1"
 
-[target.'cfg(all(unix, not(target_env = "musl"), not(target_arch = "aarch64")))'.dependencies]
+[target.'cfg(all(unix, not(target_env = "musl"), not(target_arch = "aarch64"), not(target_arch = "arm")))'.dependencies]
 jemallocator = {version = "0.3", features = ["disable_initial_exec_tls"]}
 
 [target.'cfg(all(windows, target_arch = "x86_64"))'.dependencies]

+ 6 - 11
package.json

@@ -46,12 +46,13 @@
   },
   "devDependencies": {
     "@napi-rs/cli": "^1.0.3",
-    "@typescript-eslint/eslint-plugin": "^4.16.1",
-    "@typescript-eslint/parser": "^4.16.1",
+    "@swc-node/register": "^1.0.5",
+    "@typescript-eslint/eslint-plugin": "^4.21.0",
+    "@typescript-eslint/parser": "^4.21.0",
     "ava": "^3.15.0",
     "benny": "^3.6.15",
     "chalk": "^4.1.0",
-    "eslint": "^7.22.0",
+    "eslint": "^7.24.0",
     "eslint-config-prettier": "^8.1.0",
     "eslint-plugin-import": "^2.22.1",
     "eslint-plugin-prettier": "^3.3.1",
@@ -60,8 +61,7 @@
     "lint-staged": "^10.5.4",
     "npm-run-all": "^4.1.5",
     "prettier": "^2.2.1",
-    "ts-node": "^9.1.1",
-    "typescript": "^4.2.3"
+    "typescript": "^4.2.4"
   },
   "dependencies": {
     "@node-rs/helper": "^1.1.0"
@@ -73,7 +73,7 @@
     "*.json": ["prettier --parser json --write"]
   },
   "ava": {
-    "require": ["ts-node/register/transpile-only"],
+    "require": ["@swc-node/register"],
     "extensions": ["ts"],
     "environmentVariables": {
       "TS_NODE_PROJECT": "./tsconfig.json"
@@ -86,10 +86,5 @@
     "singleQuote": true,
     "arrowParens": "always",
     "parser": "typescript"
-  },
-  "husky": {
-    "hooks": {
-      "pre-commit": "lint-staged"
-    }
   }
 }

+ 7 - 1
src/lib.rs

@@ -7,7 +7,13 @@ use std::convert::TryInto;
 
 use napi::{CallContext, Env, JsNumber, JsObject, Result, Task};
 
-#[cfg(all(unix, not(target_env = "musl"), not(target_arch = "aarch64")))]
+#[cfg(all(
+  unix,
+  not(target_env = "musl"),
+  not(target_arch = "aarch64"),
+  not(target_arch = "arm"),
+  not(debug_assertions)
+))]
 #[global_allocator]
 static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc;
 

A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 620 - 475
yarn.lock