diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml index 8e5cc1c4..e9058b7c 100644 --- a/.github/workflows/docker.yaml +++ b/.github/workflows/docker.yaml @@ -29,7 +29,7 @@ jobs: uses: docker/build-push-action@v2 with: file: alpine.Dockerfile - platforms: linux/amd64,linux/arm64 + platforms: linux/amd64 push: true tags: ghcr.io/${{ github.repository }}/nodejs-rust:lts-alpine diff --git a/.github/workflows/linux-aarch64-musl.yaml b/.github/workflows/linux-aarch64-musl.yaml new file mode 100644 index 00000000..c361e9f7 --- /dev/null +++ b/.github/workflows/linux-aarch64-musl.yaml @@ -0,0 +1,89 @@ +name: Linux-aarch64-musl + +env: + DEBUG: 'napi:*' + CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER: 'aarch64-linux-musl-gcc' + +on: + push: + branches: + - main + pull_request: + +jobs: + build: + name: stable - aarch64-unknown-linux-gnu - node@14 + 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: 14 + 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') }} + + - name: Install dependencies + run: yarn install --frozen-lockfile --ignore-platform --registry https://registry.npmjs.org --network-timeout 300000 + + - name: 'Build TypeScript' + run: yarn build + + - name: Pull docker image + run: | + docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD $DOCKER_REGISTRY_URL + docker pull $DOCKER_REGISTRY_URL/${{ github.repository }}/nodejs-rust:lts-alpine + docker tag $DOCKER_REGISTRY_URL/${{ github.repository }}/nodejs-rust:lts-alpine builder + env: + DOCKER_REGISTRY_URL: ghcr.io + DOCKER_USERNAME: ${{ github.actor }} + DOCKER_PASSWORD: ${{ secrets.GITHUB_TOKEN }} + + - name: Cross build native tests + run: | + docker run -v ~/.cargo/git:/root/.cargo/git -v ~/.cargo/registry:/root/.cargo/registry -v $(pwd):/napi-rs -w /napi-rs -e CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER=aarch64-linux-musl-gcc builder yarn --cwd ./test_module build --target aarch64-unknown-linux-musl + + - name: Setup and run tests + uses: docker://multiarch/alpine:aarch64-latest-stable + with: + args: > + sh -c " + apk add nodejs yarn && \ + yarn test + " diff --git a/.github/workflows/linux-aarch64.yaml b/.github/workflows/linux-aarch64.yaml index fef069c9..94af14dc 100644 --- a/.github/workflows/linux-aarch64.yaml +++ b/.github/workflows/linux-aarch64.yaml @@ -63,7 +63,7 @@ jobs: run: sudo apt-get install gcc-9-aarch64-linux-gnu g++-9-aarch64-linux-gnu -y - name: Install dependencies - run: yarn install --frozen-lockfile --registry https://registry.npmjs.org --network-timeout 300000 + run: yarn install --frozen-lockfile --ignore-platform --registry https://registry.npmjs.org --network-timeout 300000 - name: 'Build TypeScript' run: yarn build diff --git a/.github/workflows/linux-armv7.yaml b/.github/workflows/linux-armv7.yaml index 1a30a772..3f5098d9 100644 --- a/.github/workflows/linux-armv7.yaml +++ b/.github/workflows/linux-armv7.yaml @@ -63,7 +63,7 @@ jobs: run: sudo apt-get install gcc-9-arm-linux-gnueabihf -y - name: Install dependencies - run: yarn install --frozen-lockfile --registry https://registry.npmjs.org --network-timeout 300000 + run: yarn install --frozen-lockfile --ignore-platform --registry https://registry.npmjs.org --network-timeout 300000 - name: 'Build TypeScript' run: yarn build diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 422e049d..df309f39 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -60,7 +60,7 @@ jobs: key: npm-cache-${{ matrix.os }}-node@${{ matrix.node }}-${{ hashFiles('yarn.lock') }} - name: 'Install dependencies' - run: yarn install --frozen-lockfile --registry https://registry.npmjs.org --network-timeout 300000 + run: yarn install --frozen-lockfile --ignore-platform --registry https://registry.npmjs.org --network-timeout 300000 - name: 'Build TypeScript' run: yarn build diff --git a/alpine.Dockerfile b/alpine.Dockerfile index 0461b3df..885750db 100644 --- a/alpine.Dockerfile +++ b/alpine.Dockerfile @@ -1,11 +1,30 @@ FROM node:lts-alpine -ENV RUSTFLAGS="-C target-feature=-crt-static" \ - PATH="/usr/local/cargo/bin/rustup:/root/.cargo/bin:$PATH" \ +ENV PATH="/aarch64-linux-musl-cross/bin:/usr/local/cargo/bin/rustup:/root/.cargo/bin:$PATH" \ + RUSTFLAGS="-C target-feature=-crt-static" \ CC="clang" \ - CXX="clang++" + CXX="clang++" \ + GN_EXE=gn -RUN sed -i -e 's/v[[:digit:]]\..*\//edge\//g' /etc/apk/repositories && \ - apk update && \ - apk add rustup musl-dev build-base && \ - rustup-init -y +RUN apk add --update --no-cache musl-dev && \ + sed -i -e 's/v[[:digit:]]\..*\//edge\//g' /etc/apk/repositories && \ + apk add --update --no-cache --repository http://dl-cdn.alpinelinux.org/alpine/edge/testing \ + rustup \ + bash \ + python3 \ + python2 \ + git \ + build-base \ + wget \ + clang \ + llvm \ + gn \ + tar \ + ninja + +RUN rustup-init -y && \ + yarn global add pnpm && \ + rustup target add aarch64-unknown-linux-musl && \ + wget https://musl.cc/aarch64-linux-musl-cross.tgz && \ + tar -xvf aarch64-linux-musl-cross.tgz && \ + rm aarch64-linux-musl-cross.tgz diff --git a/test_module/tsconfig.json b/test_module/tsconfig.json index c5cf16e7..f9813ffb 100644 --- a/test_module/tsconfig.json +++ b/test_module/tsconfig.json @@ -3,7 +3,8 @@ "include": ["."], "compilerOptions": { "outDir": "./dist", - "rootDir": "__test__" + "rootDir": "__test__", + "target": "ES2015" }, "exclude": ["dist"] }