Skip to content

chore: enforce stricter rslint rules and resolve violations #3619

chore: enforce stricter rslint rules and resolve violations

chore: enforce stricter rslint rules and resolve violations #3619

Workflow file for this run

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' }}
env:
GOMAXPROCS: 8
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]
go-version: ['1.26.0']
steps:
- name: Checkout code
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
submodules: true
fetch-depth: 1
- name: Setup Node
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
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
run: go test -parallel 8 ./internal/...
test-go-windows:
name: Test Go (rspack-windows-2022-large)
runs-on: rspack-windows-2022-large
strategy:
matrix:
go-version: ['1.26.0']
steps:
- name: Checkout code
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
submodules: true
fetch-depth: 1
- name: Setup Node
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
with:
node-version: '24'
- name: Setup Go
uses: ./.github/actions/setup-go
with:
go-version: ${{ matrix.go-version }}
cache-name: ci-go-windows
- name: Unit Test
shell: pwsh
run: |
# Pre-build shared dependencies to warm the build cache
go build ./internal/...
$packages = go list ./internal/... | Where-Object { $_ -ne "" }
$batchSize = 100
$batch = @()
$cacheDir = go env GOCACHE
foreach ($pkg in $packages) {
$batch += $pkg
if ($batch.Count -ge $batchSize) {
Write-Host "Running batch of $($batch.Count) packages..."
$marker = New-TemporaryFile
go test -parallel 4 $batch
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
# Remove only test-generated cache files, keeping build cache warm
Get-ChildItem -Path $cacheDir -Recurse -File |
Where-Object { $_.LastWriteTime -gt $marker.LastWriteTime } |
Remove-Item -Force -ErrorAction SilentlyContinue
Remove-Item $marker -Force
$batch = @()
}
}
# Run remaining packages
if ($batch.Count -gt 0) {
Write-Host "Running final batch of $($batch.Count) packages..."
go test -parallel 4 $batch
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
}
test-node-windows:
name: Test npm packages (windows-latest)
runs-on: windows-latest
steps:
- name: Checkout code
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
submodules: true
- name: Setup Go
uses: ./.github/actions/setup-go
with:
go-version: 1.26.0
cache-name: ci-go-windows-node
- name: Setup Node.js
uses: ./.github/actions/setup-node
- name: Build Go binary
run: go build -o packages/rslint/bin/rslint.exe ./cmd/rslint
- name: Build JS packages
shell: bash
run: |
pnpm --filter @rslint/api build
pnpm --filter @rslint/core run build:js
pnpm --filter @typescript-eslint/rule-tester build
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 run test
lint:
name: Lint&Check
runs-on: rspack-ubuntu-22.04-large
steps:
- name: Checkout code
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
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.11.3
args: --timeout=5m ./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@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
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
- name: Format
if: runner.os == 'Linux'
run: pnpm format:check
- name: Build
run: pnpm run build
- name: Dogfooding
if: runner.os == 'Linux'
run: pnpm run lint --format github
- name: TypeCheck
if: runner.os == 'Linux'
run: pnpm typecheck
- name: Install xvfb and dependencies (Linux only)
if: runner.os == 'Linux'
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 on Linux
if: runner.os == 'Linux'
run: xvfb-run -a pnpm run test
- name: Test on non-Linux
if: runner.os != 'Linux'
run: pnpm run test
test-wasm:
name: Test WASM
runs-on: rspack-ubuntu-22.04-large
steps:
- name: Checkout code
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
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
- 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@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
submodules: true
- name: Setup Rust
uses: dtolnay/rust-toolchain@29eef336d9b2848a0b548edc03f92a220660cdb8 # stable
with:
components: rustfmt, clippy
- name: Rust Cache
uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2
with:
workspaces: '.'
cache-on-failure: true
- 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
done:
needs:
- test-go
- test-go-windows
- test-node
- test-node-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')) }}