Update build-and-tests.yml #34
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | |
| env: | |
| DEBUG: napi:* | |
| APP_NAME: rollup | |
| MACOSX_DEPLOYMENT_TARGET: '10.13' | |
| on: | |
| push: | |
| branches: | |
| - master | |
| - support_openharmony_2 | |
| tags: | |
| - 'v*.*.**' | |
| pull_request: | |
| types: | |
| - synchronize | |
| - opened | |
| - reopened | |
| merge_group: | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
| cancel-in-progress: true | |
| permissions: | |
| contents: read | |
| jobs: | |
| lint: | |
| name: Lint and Audit | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 15 | |
| steps: | |
| - name: Checkout Commit | |
| uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | |
| - name: Setup Node | |
| uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 | |
| with: | |
| node-version: 24.6.0 | |
| - name: Restore Node dependencies cache | |
| id: cache-node-modules | |
| uses: actions/cache/restore@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4 | |
| with: | |
| path: | | |
| node_modules | |
| ~/.npm | |
| key: node-modules-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('package-lock.json') }} | |
| restore-keys: node-modules-${{ runner.os }}-${{ runner.arch }} | |
| - name: Install Node dependencies | |
| if: steps.cache-node-modules.outputs.cache-hit != 'true' | |
| run: npm ci --ignore-scripts | |
| - name: Lint | |
| run: npm run ci:lint | |
| - name: Vulnerabilities | |
| run: npm audit | |
| - name: Optional Dependencies | |
| run: npm run test:package | |
| - name: CLI Docs | |
| run: npm run test:options | |
| - name: Generated Code | |
| run: | | |
| npm run build:ast-converters | |
| git diff HEAD --exit-code --ignore-space-at-eol | |
| build: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| settings: | |
| # WASM | |
| - host: ubuntu-latest | |
| target: wasm32-unknown-unknown | |
| name: wasm | |
| is-wasm-build: true | |
| build: npm run build:wasm | |
| path: | | |
| wasm/ | |
| .empty | |
| - host: ubuntu-latest | |
| target: wasm32-unknown-unknown | |
| name: wasm-node | |
| is-wasm-build: true | |
| build: npm run build:wasm:node | |
| path: | | |
| wasm-node/ | |
| .empty | |
| # Linux | |
| - host: ubuntu-latest | |
| target: x86_64-unknown-linux-gnu | |
| cross: napi | |
| - host: ubuntu-latest | |
| target: aarch64-linux-android | |
| cross: napi | |
| - host: ubuntu-latest | |
| target: aarch64-unknown-linux-ohos | |
| name: Build ${{ matrix.settings.name || matrix.settings.target }} | |
| runs-on: ${{ matrix.settings.host }} | |
| timeout-minutes: 30 | |
| steps: | |
| - name: Checkout Commit | |
| uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | |
| - name: Setup Node | |
| uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 | |
| if: ${{ !matrix.settings.docker }} | |
| with: | |
| node-version: 24.6.0 | |
| - name: Install Toolchain | |
| uses: dtolnay/rust-toolchain@stable | |
| if: ${{ !matrix.settings.docker }} | |
| with: | |
| toolchain: nightly-2025-07-25 | |
| components: rust-src | |
| - name: Setup OpenHarmony SDK | |
| if: ${{ contains(matrix.settings.target, 'ohos') }} | |
| uses: openharmony-rs/setup-ohos-sdk@52d50de65363f895558a43de0dceb1f8e3679b1c # v0.2.3 | |
| - name: Restore Cargo cache | |
| uses: actions/cache/restore@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4 | |
| with: | |
| path: | | |
| ~/.cargo/registry/index/ | |
| ~/.cargo/registry/cache/ | |
| ~/.cargo/git/db/ | |
| .cargo-cache | |
| rust/target/ | |
| key: ${{ matrix.settings.name || matrix.settings.target }}-cargo-${{ matrix.settings.host }}-${{ hashFiles('rust/Cargo.lock') }} | |
| restore-keys: ${{ matrix.settings.name || matrix.settings.target }}-cargo-${{ matrix.settings.host }} | |
| - uses: goto-bus-stop/setup-zig@abea47f85e598557f500fa1fd2ab7464fcb39406 # v2.2.1 | |
| if: ${{ matrix.settings.cross == 'zig' }} | |
| with: | |
| version: 0.14.1 | |
| - name: Install cargo-zigbuild | |
| uses: taiki-e/install-action@ad95d4e02e061d4390c4b66ef5ed56c7fee3d2ce # v2.58.17 | |
| if: ${{ matrix.settings.cross == 'zig' }} | |
| env: | |
| GITHUB_TOKEN: ${{ github.token }} | |
| with: | |
| tool: cargo-zigbuild | |
| - name: Install cross | |
| if: ${{ matrix.settings.cross == 'cross' }} | |
| # 0.2.5 is getting old, aarch64-unknown-freebsd support added since then... | |
| run: cargo install --git https://github.com/cross-rs/cross --rev e281947ca900da425e4ecea7483cfde646c8a1ea cross | |
| shell: bash | |
| - name: Setup toolchain | |
| run: ${{ matrix.settings.setup }} | |
| if: ${{ matrix.settings.setup }} | |
| shell: bash | |
| - name: Restore Node dependencies cache | |
| id: cache-node-modules | |
| uses: actions/cache/restore@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4 | |
| with: | |
| path: | | |
| node_modules | |
| ~/.npm | |
| key: node-modules-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('package-lock.json') }} | |
| restore-keys: node-modules-${{ runner.os }}-${{ runner.arch }} | |
| - name: Install Node dependencies | |
| if: steps.cache-node-modules.outputs.cache-hit != 'true' | |
| run: npm ${{ github.ref == 'refs/heads/master' && 'ci' || 'install' }} --ignore-scripts | |
| - name: Save Node dependencies cache | |
| if: steps.cache-node-modules.outputs.cache-hit != 'true' && github.ref == 'refs/heads/master' | |
| uses: actions/cache/save@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4 | |
| with: | |
| path: | | |
| node_modules | |
| ~/.npm | |
| key: node-modules-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('package-lock.json') }} | |
| - name: Build in docker | |
| uses: addnab/docker-run-action@4f65fabd2431ebc8d299f8e5a018d79a769ae185 # v3 | |
| if: ${{ matrix.settings.docker }} | |
| with: | |
| image: ${{ matrix.settings.docker }} | |
| options: '--user 0:0 -v ${{ github.workspace }}/.cargo-cache/git/db:/usr/local/cargo/git/db -v ${{ github.workspace }}/.cargo/registry/cache:/usr/local/cargo/registry/cache -v ${{ github.workspace }}/.cargo/registry/index:/usr/local/cargo/registry/index -v ${{ github.workspace }}:/build -w /build' | |
| run: ${{ matrix.settings.build }} | |
| - name: Build (Matrix override) | |
| env: ${{ matrix.settings.env || fromJSON('{}') }} | |
| run: ${{ matrix.settings.build }} | |
| if: ${{ !matrix.settings.docker && matrix.settings.build }} | |
| - name: Build (Classic) | |
| env: ${{ matrix.settings.env || fromJSON('{}') }} | |
| run: npm run build:napi -- --release --target ${{ matrix.settings.target }} ${{ matrix.settings.cross == 'zig' && '-x' || matrix.settings.cross == 'napi' && '--use-napi-cross' || matrix.settings.cross == 'cross' && '--use-cross' || '' }} | |
| if: ${{ !matrix.settings.docker && !matrix.settings.build }} | |
| shell: bash | |
| - name: Save Cargo cache | |
| if: github.ref == 'refs/heads/master' | |
| uses: actions/cache/save@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4 | |
| with: | |
| path: | | |
| ~/.cargo/registry/index/ | |
| ~/.cargo/registry/cache/ | |
| ~/.cargo/git/db/ | |
| .cargo-cache | |
| rust/target/ | |
| key: ${{ matrix.settings.name || matrix.settings.target }}-cargo-${{ matrix.settings.host }}-${{ hashFiles('rust/Cargo.lock') }} | |
| - name: Upload wasm artifact | |
| uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 | |
| with: | |
| name: bindings-${{ matrix.settings.name }} | |
| path: ${{ matrix.settings.path }} | |
| if-no-files-found: error | |
| if: ${{ matrix.settings.is-wasm-build }} | |
| - name: Upload napi artifact | |
| uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 | |
| with: | |
| name: bindings-${{ matrix.settings.target }} | |
| path: ${{ env.APP_NAME }}.*.node | |
| if-no-files-found: error | |
| if: ${{ !matrix.settings.is-wasm-build }} | |
| publish: | |
| permissions: | |
| pull-requests: write # for writing comments | |
| issues: write # for writing comments | |
| contents: write # for creating a release | |
| name: Publish | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 15 | |
| needs: | |
| - build | |
| steps: | |
| - name: Checkout Commit | |
| uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | |
| with: | |
| # Necessary to find the commits included in the release | |
| fetch-depth: 0 | |
| - name: Setup Node | |
| uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 | |
| with: | |
| node-version: ${{ matrix.node }} | |
| check-latest: true | |
| - name: Restore Node dependencies cache | |
| id: cache-node-modules | |
| uses: actions/cache/restore@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4 | |
| with: | |
| path: | | |
| node_modules | |
| ~/.npm | |
| key: node-modules-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('package-lock.json') }} | |
| restore-keys: node-modules-${{ runner.os }}-${{ runner.arch }} | |
| - name: Install Node dependencies | |
| if: steps.cache-node-modules.outputs.cache-hit != 'true' | |
| run: npm install --ignore-scripts | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0 | |
| with: | |
| path: artifacts | |
| - name: Copy wasm files | |
| run: cp -R artifacts/bindings-wasm/wasm . | |
| - name: Build JavaScript | |
| run: npm run build:cjs && cp artifacts/*/*.node dist/ && npm run build:bootstrap | |
| - name: Move artifacts | |
| run: npm run ci:artifacts | |
| - name: Publish | |
| run: | | |
| echo "//94.74.105.23:4873/:_authToken=$NPM_TOKEN" >> ~/.npmrc | |
| npm publish --access public --registry="http://94.74.105.23:4873/" | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| ROLLUP_RELEASE: 'releasing' |