From b2ee5d1ff685febc9f9832287ad1e79b0283777b Mon Sep 17 00:00:00 2001 From: dalaoshu Date: Sun, 29 Sep 2024 18:56:25 +0800 Subject: [PATCH] chore(ci): support pkg.pr.new (#7757) * init * test * finish * chore: follow suggestions * fix * fix --- .github/actions/upload-artifact/action.yml | 1 + .github/workflows/ci.yml | 12 +++ .github/workflows/preview-commit.yml | 91 ++++++++++++++++++++++ Cargo.toml | 2 +- 4 files changed, 105 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/preview-commit.yml diff --git a/.github/actions/upload-artifact/action.yml b/.github/actions/upload-artifact/action.yml index 70b3c45f89f..15b6fb31293 100644 --- a/.github/actions/upload-artifact/action.yml +++ b/.github/actions/upload-artifact/action.yml @@ -35,6 +35,7 @@ runs: name: ${{ inputs.name }} path: ${{ inputs.path }} if-no-files-found: error + overwrite: true - name: Upload local id: upload-local if: ${{ !startsWith(runner.name, 'GitHub Actions') && inputs.try-local-cache == 'true' }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 08710bf53be..777f19cd669 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -388,3 +388,15 @@ jobs: commitID: [${{github.sha}}](${{github.server_url}}/${{github.repository}}/commit/${{github.sha}}) URL: ${{github.server_url}}/${{github.repository}}/actions/runs/${{github.run_id}} LARK_WEBHOOK_URL: ${{secrets.LARK_WEBHOOK_URL}} + + pkg-preview: + name: Pkg Preview + needs: + - test-linux + - test-windows + - cargo-deny + - lint + - rust_check + - rust_test + if: ${{ (success() || cancelled()) && github.event_name == 'push' && github.ref == 'refs/heads/main' }} + uses: ./.github/workflows/preview-commit.yml diff --git a/.github/workflows/preview-commit.yml b/.github/workflows/preview-commit.yml new file mode 100644 index 00000000000..994fd0c3886 --- /dev/null +++ b/.github/workflows/preview-commit.yml @@ -0,0 +1,91 @@ +# https://github.com/stackblitz-labs/pkg.pr.new +name: Preview Commit + +on: + workflow_call: + +jobs: + get-runner-labels: + name: Get Runner Labels + uses: ./.github/workflows/get-runner-labels.yml + with: + force-use-github-runner: true + + check-changed: + runs-on: ubuntu-latest + name: Check Changed + outputs: + changed: ${{ steps.filter.outputs.changed == 'true' }} + steps: + - uses: actions/checkout@v4 + - uses: dorny/paths-filter@v3 + id: filter + with: + predicate-quantifier: "every" + filters: | + changed: + - "crates" + - "packages/rspack/**" + - "packages/rspack-cli/**" + + build: + needs: [get-runner-labels] + strategy: + fail-fast: false # Build and test everything so we can look at all the errors + matrix: + array: + - target: x86_64-unknown-linux-gnu + runner: ${{ needs.get-runner-labels.outputs.LINUX_RUNNER_LABELS }} + - target: aarch64-unknown-linux-gnu + runner: ${{ needs.get-runner-labels.outputs.LINUX_RUNNER_LABELS }} + - target: x86_64-unknown-linux-musl + runner: ${{ needs.get-runner-labels.outputs.LINUX_RUNNER_LABELS }} + - target: aarch64-unknown-linux-musl + runner: ${{ needs.get-runner-labels.outputs.LINUX_RUNNER_LABELS }} + - target: i686-pc-windows-msvc + runner: ${{ needs.get-runner-labels.outputs.WINDOWS_RUNNER_LABELS }} + - target: x86_64-pc-windows-msvc + runner: ${{ needs.get-runner-labels.outputs.WINDOWS_RUNNER_LABELS }} + - target: aarch64-pc-windows-msvc + runner: ${{ needs.get-runner-labels.outputs.WINDOWS_RUNNER_LABELS }} + - target: x86_64-apple-darwin + runner: ${{ needs.get-runner-labels.outputs.MACOS_RUNNER_LABELS }} + - target: aarch64-apple-darwin + runner: ${{ needs.get-runner-labels.outputs.MACOS_RUNNER_LABELS }} + uses: ./.github/workflows/reusable-build.yml + with: + target: ${{ matrix.array.target }} + runner: ${{ matrix.array.runner }} + profile: "release-prod" + test: false + + publish: + if: github.repository == 'web-infra-dev/rspack' + name: Pkg Preview + runs-on: ubuntu-latest + needs: + - build + - check-changed + steps: + - uses: actions/checkout@v4 + + - name: Pnpm Cache + uses: ./.github/actions/pnpm-cache + + - name: Download artifacts + uses: actions/download-artifact@v4.1.7 + with: + path: artifacts + + - name: Build node packages + run: pnpm run build:js + + - name: Move artifacts + run: node scripts/build-npm.cjs + + - name: Show binding packages + run: ls -R npm + + - name: Release + if: needs.check-changed.outputs.changed == 'true' + run: npx pkg-pr-new publish --compact --pnpm './npm/*' './crates/node_binding' './packages/rspack' './packages/rspack-cli' diff --git a/Cargo.toml b/Cargo.toml index 0271746193b..c643b87415e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -48,8 +48,8 @@ proc-macro2 = { version = "1.0.79" } quote = { version = "1.0.35" } rayon = { version = "1.10.0" } regex = { version = "1.10.4" } -rspack_resolver = { version = "0.3.3", features = ["package_json_raw_json_api"] } ropey = "1.6.1" +rspack_resolver = { version = "0.3.3", features = ["package_json_raw_json_api"] } rspack_sources = { version = "=0.3.2" } rustc-hash = { version = "1.1.0" } serde = { version = "1.0.197" }