diff --git a/.github/workflows/asan.yml b/.github/workflows/asan.yml index 8ec41173..a29a588a 100644 --- a/.github/workflows/asan.yml +++ b/.github/workflows/asan.yml @@ -14,8 +14,8 @@ on: pull_request: jobs: - build_and_test: - name: nightly - ubuntu - node@16 + test: + name: Address sanitizer runs-on: ubuntu-20.04 steps: diff --git a/.github/workflows/check-all-features.yml b/.github/workflows/check-all-features.yml deleted file mode 100644 index d1fdc556..00000000 --- a/.github/workflows/check-all-features.yml +++ /dev/null @@ -1,35 +0,0 @@ -name: Check NAPI-RS features - -on: - push: - branches: - - main - pull_request: - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -jobs: - build_and_test: - strategy: - fail-fast: false - matrix: - settings: - - features: 'napi1,napi2,napi3,napi4,napi5,napi6,napi7,napi8,experimental,async,chrono_date,latin1,full' - package: 'napi' - - features: 'compat-mode,strict,type-def,noop,full,default' - package: 'napi-derive' - name: stable - ubuntu-latest - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - - name: Install - uses: dtolnay/rust-toolchain@stable - with: - toolchain: stable - - - name: Check build - run: cargo check -p ${{ matrix.settings.package }} -F ${{ matrix.settings.features }} diff --git a/.github/workflows/cli-binary.yml b/.github/workflows/cli-binary.yml deleted file mode 100644 index c95a2ef9..00000000 --- a/.github/workflows/cli-binary.yml +++ /dev/null @@ -1,52 +0,0 @@ -name: Cli Build Binary - -env: - DEBUG: 'napi:*' - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -on: - push: - branches: - - main - pull_request: - -jobs: - build_binary_crate: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - - name: Setup node - uses: actions/setup-node@v3 - with: - node-version: 18 - cache: 'yarn' - - - name: Install - uses: dtolnay/rust-toolchain@stable - with: - toolchain: stable - - - name: Cache cargo - uses: actions/cache@v3 - with: - path: | - ~/.cargo/registry - ~/.cargo/git - target - key: stable-cargo-cache-build-binary - - - name: 'Install dependencies' - run: yarn install --mode=skip-build --immutable - - - name: Build and run binary - run: | - yarn workspace binary build - ./examples/binary/napi-examples-binary - yarn workspace binary build --profile napi-rs-custom - env: - RUST_BACKTRACE: 1 diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml deleted file mode 100644 index db0f279e..00000000 --- a/.github/workflows/lint.yaml +++ /dev/null @@ -1,56 +0,0 @@ -name: Lint - -on: - push: - branches: - - main - pull_request: - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -jobs: - lint: - name: Lint SourceCode - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - - name: Setup node - uses: actions/setup-node@v3 - with: - node-version: 18 - cache: 'yarn' - - - name: Install - uses: dtolnay/rust-toolchain@stable - with: - toolchain: stable - components: rustfmt, clippy - - - name: Cache cargo - uses: actions/cache@v3 - with: - path: | - ~/.cargo/registry - ~/.cargo/git - key: lint-cargo-cache - - - name: 'Install dependencies' - run: yarn install --immutable --mode=skip-build - - - name: 'Lint JS/TS' - run: yarn lint - - - name: Cargo fmt - run: cargo fmt -- --check - - - name: Clippy - run: cargo clippy - - - name: Clear the cargo caches - run: | - cargo install cargo-cache --no-default-features --features ci-autoclean - cargo-cache diff --git a/.github/workflows/linux-armv7.yaml b/.github/workflows/linux-armv7.yaml deleted file mode 100644 index 07043c6c..00000000 --- a/.github/workflows/linux-armv7.yaml +++ /dev/null @@ -1,66 +0,0 @@ -name: Linux-armv7 - -env: - DEBUG: 'napi:*' - RUST_BACKTRACE: 1 - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -on: - push: - branches: - - main - pull_request: - -jobs: - build: - name: stable - armv7-unknown-linux-gnu - node@18 - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - - name: Setup node - uses: actions/setup-node@v3 - with: - node-version: 18 - cache: 'yarn' - - - name: Install - uses: dtolnay/rust-toolchain@stable - with: - toolchain: stable - targets: armv7-unknown-linux-gnueabihf - - - name: Install ziglang - uses: goto-bus-stop/setup-zig@v2 - with: - version: 0.10.1 - - - name: Cache cargo - uses: actions/cache@v3 - with: - path: | - ~/.cargo/registry - ~/.cargo/git - target - key: stable-linux-armv7-gnu-node@18-cargo-cache - - - name: Install dependencies - run: | - yarn config set --json supportedArchitectures.cpu '["arm", "current"]' - yarn install --immutable --mode=skip-build - - - name: Cross build native tests - run: yarn build:test -- --target armv7-unknown-linux-gnueabihf --cross-compile - - - run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes - - - name: Setup and run tests - uses: addnab/docker-run-action@v3 - with: - image: node:lts-bullseye-slim - options: --platform linux/arm/v7 -v ${{ github.workspace }}:/build -w /build - run: yarn test diff --git a/.github/workflows/test.yaml b/.github/workflows/test-release.yaml similarity index 69% rename from .github/workflows/test.yaml rename to .github/workflows/test-release.yaml index e842637a..1f5b0bb0 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test-release.yaml @@ -1,4 +1,4 @@ -name: Test +name: Test & Release env: DEBUG: 'napi:*' @@ -9,6 +9,10 @@ concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true +permissions: + contents: write + id-token: write + on: push: branches: @@ -16,6 +20,45 @@ on: pull_request: jobs: + lint: + name: Lint SourceCode + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - name: Setup node + uses: actions/setup-node@v3 + with: + node-version: 18 + cache: 'yarn' + + - name: Install + uses: dtolnay/rust-toolchain@stable + with: + toolchain: stable + components: rustfmt, clippy + + - name: Cache cargo + uses: actions/cache@v3 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + key: lint-cargo-cache + + - name: 'Install dependencies' + run: yarn install --immutable --mode=skip-build + + - name: 'Lint JS/TS' + run: yarn lint + + - name: Cargo fmt + run: cargo fmt -- --check + + - name: Clippy + run: cargo clippy + build_and_test: strategy: fail-fast: false @@ -324,3 +367,131 @@ jobs: image: ${{ steps.image-name.outputs.docker-image }} options: ${{ matrix.settings.args }} -v ${{ github.workspace }}:/build -w /build run: yarn test + + build-and-test-linux-armv7: + name: stable - armv7-unknown-linux-gnu - node@18 + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - name: Setup node + uses: actions/setup-node@v3 + with: + node-version: 18 + cache: 'yarn' + + - name: Install + uses: dtolnay/rust-toolchain@stable + with: + toolchain: stable + targets: armv7-unknown-linux-gnueabihf + + - name: Install ziglang + uses: goto-bus-stop/setup-zig@v2 + with: + version: 0.10.1 + + - name: Cache cargo + uses: actions/cache@v3 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + target + key: stable-linux-armv7-gnu-node@18-cargo-cache + + - name: Install dependencies + run: | + yarn config set --json supportedArchitectures.cpu '["arm", "current"]' + yarn install --immutable --mode=skip-build + + - name: Cross build native tests + run: yarn build:test -- --target armv7-unknown-linux-gnueabihf --cross-compile + + - run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes + + - name: Setup and run tests + uses: addnab/docker-run-action@v3 + with: + image: node:lts-bullseye-slim + options: --platform linux/arm/v7 -v ${{ github.workspace }}:/build -w /build + run: yarn test + + build_binary_crate: + runs-on: ubuntu-latest + name: Test cli build binary + steps: + - uses: actions/checkout@v3 + + - name: Setup node + uses: actions/setup-node@v3 + with: + node-version: 18 + cache: 'yarn' + + - name: Install + uses: dtolnay/rust-toolchain@stable + with: + toolchain: stable + + - name: Cache cargo + uses: actions/cache@v3 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + target + key: stable-cargo-cache-build-binary + + - name: 'Install dependencies' + run: yarn install --mode=skip-build --immutable + + - name: Build and run binary + run: | + yarn workspace binary build + ./examples/binary/napi-examples-binary + yarn workspace binary build --profile napi-rs-custom + + check-all-features: + strategy: + fail-fast: false + matrix: + settings: + - features: 'napi1,napi2,napi3,napi4,napi5,napi6,napi7,napi8,experimental,async,chrono_date,latin1,full' + package: 'napi' + - features: 'compat-mode,strict,type-def,noop,full,default' + package: 'napi-derive' + name: stable - ubuntu-latest + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - name: Install + uses: dtolnay/rust-toolchain@stable + with: + toolchain: stable + + - name: Check build + run: cargo check -p ${{ matrix.settings.package }} -F ${{ matrix.settings.features }} + + release-npm: + runs-on: ubuntu-latest + if: "startsWith(github.event.head_commit.message, 'chore(release): publish')" + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: 18 + cache: 'yarn' + - name: Publish + run: | + yarn install --mode=skip-build + yarn build + npm config set provenance true + echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc + yarn lerna publish from-package --pre-dist-tag canary --yes + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.prettierignore b/.prettierignore index 2800ecb9..6d81dff6 100644 --- a/.prettierignore +++ b/.prettierignore @@ -3,4 +3,5 @@ node_modules scripts triples/index.js examples/napi/index.d.ts -.yarn \ No newline at end of file +.yarn +yarn.lock diff --git a/cli/package.json b/cli/package.json index d6b62238..8bb33a4f 100644 --- a/cli/package.json +++ b/cli/package.json @@ -1,6 +1,6 @@ { "name": "@napi-rs/cli", - "version": "3.0.0-alpha.3", + "version": "3.0.0-alpha.4", "description": "Cli tools for napi-rs", "author": "LongYinan ", "homepage": "https://github.com/napi-rs/napi-rs", diff --git a/lerna.json b/lerna.json index af750106..75d24ebc 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { "version": "independent", "npmClient": "yarn", - "message": "chore: publish" + "message": "chore(release): publish" } diff --git a/package.json b/package.json index cd829621..928f4315 100644 --- a/package.json +++ b/package.json @@ -60,11 +60,6 @@ "cargo fmt --" ] }, - "husky": { - "hooks": { - "pre-commit": "lint-staged && cargo fmt --all" - } - }, "devDependencies": { "@napi-rs/cli": "workspace:*", "@rollup/plugin-alias": "^5.0.0", diff --git a/triples/package.json b/triples/package.json index 38d697d5..530262ba 100644 --- a/triples/package.json +++ b/triples/package.json @@ -1,6 +1,6 @@ { "name": "@napi-rs/triples", - "version": "2.0.0-alpha.1", + "version": "2.0.0-alpha.2", "description": "Rust target triples objects", "keywords": [ "Rust",