feat: add core no-redeclare rule #5926
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 | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| types: [opened, synchronize] | |
| workflow_dispatch: | |
| permissions: | |
| # Required: allow read access to the content for analysis. | |
| contents: read | |
| # Optional: allow read access to pull requests. Use with `only-new-issues` option. | |
| pull-requests: read | |
| # Required: allow writing check results and annotations | |
| checks: write | |
| # Required: allow updating commit statuses | |
| statuses: write | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }} | |
| cancel-in-progress: ${{ github.ref_name != 'main' }} | |
| jobs: | |
| test-go: | |
| name: Test Go | |
| runs-on: ${{ matrix.runner }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| runner: | |
| - rspack-ubuntu-22.04-large | |
| - rspack-darwin-14-medium | |
| - rspack-windows-2022-large | |
| go-version: ['1.26.0'] | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 | |
| with: | |
| submodules: true | |
| fetch-depth: 1 | |
| - name: Setup Node | |
| uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6 | |
| with: | |
| node-version: '24' | |
| - name: Setup Go | |
| uses: ./.github/actions/setup-go | |
| with: | |
| go-version: ${{ matrix.go-version }} | |
| cache-name: ci-test-go | |
| - name: Unit Test | |
| if: matrix.runner != 'rspack-windows-2022-large' | |
| run: go test -count=1 ./cmd/... ./internal/... | |
| - name: Unit Test (Windows) | |
| if: matrix.runner == 'rspack-windows-2022-large' | |
| shell: pwsh | |
| run: | | |
| # Pre-build shared dependencies to warm the build cache | |
| go build ./cmd/... ./internal/... | |
| $packages = go list ./cmd/... ./internal/... | Where-Object { $_ -ne "" } | |
| $batchSize = 64 | |
| $batch = @() | |
| foreach ($pkg in $packages) { | |
| $batch += $pkg | |
| if ($batch.Count -ge $batchSize) { | |
| Write-Host "Running batch of $($batch.Count) packages..." | |
| go test -p 64 -count=1 $batch | |
| if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } | |
| $batch = @() | |
| } | |
| } | |
| # Run remaining packages | |
| if ($batch.Count -gt 0) { | |
| Write-Host "Running final batch of $($batch.Count) packages..." | |
| go test -p 64 -count=1 $batch | |
| if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } | |
| } | |
| lint: | |
| name: Lint&Check | |
| runs-on: rspack-ubuntu-22.04-large | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 | |
| with: | |
| submodules: true | |
| - name: Setup Node.js | |
| uses: ./.github/actions/setup-node | |
| - name: Setup Go | |
| uses: ./.github/actions/setup-go | |
| with: | |
| go-version: 1.26.0 | |
| cache-name: ci-go-lint | |
| - name: golangci-lint | |
| uses: golangci/golangci-lint-action@4afd733a84b1f43292c63897423277bb7f4313a9 # v8 | |
| with: | |
| version: v2.12.2 | |
| args: --timeout=10m ./cmd/... ./internal/... | |
| - name: go vet | |
| run: npm run lint:go | |
| - name: go fmt | |
| run: npm run format:go | |
| - name: Check Spell | |
| run: pnpm check-spell | |
| test-node: | |
| name: Test npm packages | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [rspack-ubuntu-22.04-large] | |
| go-version: ['1.26.0'] | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 | |
| with: | |
| submodules: true | |
| - name: Setup Go | |
| uses: ./.github/actions/setup-go | |
| with: | |
| go-version: ${{ matrix.go-version }} | |
| cache-name: ci-test-node | |
| - name: Setup Node.js | |
| uses: ./.github/actions/setup-node | |
| # napi build drops the host .node into its @rslint/native-{tuple} package; | |
| # the worker loads it at test runtime. | |
| - name: Setup Rust | |
| uses: ./.github/actions/setup-rust | |
| - name: Build napi parser (native) | |
| run: pnpm --filter @rslint/native run build | |
| - name: Format | |
| run: pnpm format:check | |
| - name: Build | |
| run: pnpm run build | |
| - name: Dogfooding | |
| run: pnpm run lint --format github | |
| - name: TypeCheck | |
| run: pnpm typecheck | |
| - name: Install xvfb and dependencies | |
| run: | | |
| sudo apt update | |
| sudo apt install -y libasound2 libgbm1 libgtk-3-0 libnss3 xvfb | |
| - name: VSCode Test Cache | |
| uses: lynx-infra/cache@5c6160a6a4c7fca80a2f3057bb9dfc9513fcb732 | |
| with: | |
| path: packages/vscode-extension/.vscode-test | |
| key: vscode-test-${{ matrix.os }} | |
| restore-keys: | | |
| vscode-test-${{ matrix.os }}- | |
| - name: Test | |
| run: xvfb-run -a pnpm run test | |
| test-node-windows: | |
| name: Test npm packages (rspack-windows-2022-large) | |
| runs-on: rspack-windows-2022-large | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 | |
| with: | |
| submodules: true | |
| fetch-depth: 1 | |
| - name: Setup Go | |
| uses: ./.github/actions/setup-go | |
| with: | |
| go-version: 1.26.0 | |
| cache-name: ci-test-node-windows | |
| - name: Setup Node.js | |
| uses: ./.github/actions/setup-node | |
| # napi build drops the host (win32) .node into its @rslint/native-{tuple} | |
| # package; the worker loads it at test runtime. | |
| - name: Setup Rust | |
| uses: ./.github/actions/setup-rust | |
| - name: Build napi parser (native) | |
| run: pnpm --filter @rslint/native run build | |
| - name: Build rslint.exe | |
| shell: pwsh | |
| run: go build -o npm/rslint/win32-x64-msvc/rslint.exe ./cmd/rslint | |
| # vscode-extension (package "rslint") is excluded here - it's tested on | |
| # windows-latest instead, since the vscode-extension test does not run | |
| # reliably on this self-hosted runner. | |
| - name: Build | |
| run: pnpm -r --filter=@rslint/test-tools... build | |
| - name: Test | |
| run: pnpm -r --filter=@rslint/test-tools... test | |
| - name: Upload rslint.exe | |
| uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 | |
| with: | |
| name: ci-test-rslint-windows-amd64 | |
| path: npm/rslint/win32-x64-msvc/rslint.exe | |
| retention-days: 1 | |
| if-no-files-found: error | |
| test-vscode-windows: | |
| name: Test vscode-extension (windows-latest) | |
| runs-on: windows-latest | |
| needs: test-node-windows | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 | |
| with: | |
| submodules: true | |
| - name: Setup Node.js | |
| uses: ./.github/actions/setup-node | |
| # napi build drops the host (win32) .node into its @rslint/native-{tuple} | |
| # package; the worker loads it at test runtime. | |
| - name: Setup Rust | |
| uses: ./.github/actions/setup-rust | |
| - name: Build napi parser (native) | |
| run: pnpm --filter @rslint/native run build | |
| - name: Download rslint.exe | |
| uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0 | |
| with: | |
| name: ci-test-rslint-windows-amd64 | |
| path: npm/rslint/win32-x64-msvc | |
| # build:js only - skip @rslint/core's build:bin, which invokes `go | |
| # build` directly. The host rslint.exe was already built on the | |
| # self-hosted Windows runner and downloaded above; this job has no Go | |
| # toolchain set up and shouldn't need one. | |
| - name: Build | |
| shell: bash | |
| run: | | |
| pnpm --filter @rslint/api build | |
| pnpm --filter @rslint/core run build:js | |
| pnpm --filter rslint build | |
| - name: VSCode Test Cache | |
| uses: lynx-infra/cache@5c6160a6a4c7fca80a2f3057bb9dfc9513fcb732 | |
| with: | |
| path: packages/vscode-extension/.vscode-test | |
| key: vscode-test-windows | |
| restore-keys: | | |
| vscode-test-windows- | |
| - name: Test | |
| run: pnpm --filter rslint test | |
| test-wasm: | |
| name: Test WASM | |
| runs-on: rspack-ubuntu-22.04-large | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 | |
| with: | |
| submodules: true | |
| - name: Setup Go | |
| uses: ./.github/actions/setup-go | |
| with: | |
| go-version: 1.26.0 | |
| cache-name: ci-test-wasm | |
| - name: Setup Node.js | |
| uses: ./.github/actions/setup-node | |
| # build:js is one rslib build (library surface + eslint-plugin worker). | |
| # The worker's native loader is bundled from core sources and resolves the | |
| # platform .node at runtime, so no napi build / Rust is needed to compile. | |
| - name: Build | |
| run: | | |
| pnpm --filter '@rslint/core' build:js | |
| pnpm --filter '@rslint/wasm' build | |
| test-rust: | |
| name: Test Rust | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [macos-latest] | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 | |
| with: | |
| submodules: true | |
| - name: Setup Rust | |
| uses: ./.github/actions/setup-rust | |
| with: | |
| components: rustfmt, clippy | |
| cache-workspaces: '.' | |
| # Workaround for Swatinem/rust-cache#341: on the new macos runner image | |
| # caching ~/.cargo/bin restores a broken `cargo` shim that resolves to | |
| # rustup-init, causing `cargo fmt`/`clippy` to fail with | |
| # "unexpected argument 'fmt' found / Usage: rustup-init[EXE] [OPTIONS]". | |
| cache-bin: 'false' | |
| - name: Check formatting | |
| run: cargo fmt --all -- --check | |
| - name: Run clippy | |
| run: cargo clippy --all-targets --all-features -- -D warnings | |
| - name: Setup Node.js | |
| uses: ./.github/actions/setup-node | |
| - name: Setup Go | |
| uses: ./.github/actions/setup-go | |
| with: | |
| go-version: 1.26.0 | |
| cache-name: ci-test-wasm | |
| - name: Build | |
| run: | | |
| pnpm --filter '@rslint/tsgo' build | |
| - name: Run tests | |
| run: cargo test --verbose | |
| benchmark-go: | |
| if: ${{ startsWith(github.ref_name, 'chore/release-') || startsWith(github.head_ref, 'chore/release-') }} | |
| permissions: | |
| contents: read | |
| id-token: write | |
| uses: ./.github/workflows/benchmark-go.yml | |
| benchmark-cli: | |
| if: ${{ startsWith(github.ref_name, 'chore/release-') || startsWith(github.head_ref, 'chore/release-') }} | |
| permissions: | |
| contents: read | |
| id-token: write | |
| uses: ./.github/workflows/benchmark-cli.yml | |
| done: | |
| needs: | |
| - test-go | |
| - test-node | |
| - test-node-windows | |
| - test-vscode-windows | |
| - lint | |
| - test-wasm | |
| - test-rust | |
| if: always() | |
| runs-on: ubuntu-latest | |
| name: CI Done | |
| steps: | |
| - run: exit 1 | |
| if: ${{ always() && (contains(needs.*.result, 'failure') || contains(needs.*.result, 'skipped') || contains(needs.*.result, 'cancelled')) }} |