Skip to content

Commit 92402f5

Browse files
authored
chore: run ci on windows (#213)
1 parent 9cbedd2 commit 92402f5

File tree

6 files changed

+36
-31
lines changed

6 files changed

+36
-31
lines changed

.github/actions/setup-go/action.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ runs:
2121

2222
- name: Clean Go module cache dir
2323
shell: bash
24+
if: runner.os == 'linux'
2425
run: sudo rm -rf ~/go/pkg/mod/golang.org/toolchain*
2526

2627
- name: Go cache

.github/workflows/ci.yml

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@ env:
1919
jobs:
2020
test-go:
2121
name: Test Go
22-
runs-on: rspack-ubuntu-22.04-large
22+
runs-on: ${{ matrix.runner }}
2323
strategy:
2424
matrix:
25+
runner: [rspack-ubuntu-22.04-large, windows-latest]
2526
go-version: ['1.24.1']
2627
steps:
2728
- name: Checkout code
@@ -39,23 +40,27 @@ jobs:
3940
go-version: ${{ matrix.go-version }}
4041
cache-name: test-go
4142
- name: golangci-lint
43+
if: runner.os == 'Linux'
4244
uses: golangci/golangci-lint-action@v8
4345
with:
4446
version: v2.3.0
4547
args: --timeout=5m ./cmd/... ./internal/...
4648
- name: go vet
49+
if: runner.os == 'Linux'
4750
run: npm run lint:go
4851
- name: go fmt
52+
if: runner.os == 'Linux'
4953
run: npm run format:go
5054
- name: Unit Test
5155
run: |
5256
go test -parallel 4 ./internal/...
5357
5458
test-node:
5559
name: Test npm packages
56-
runs-on: rspack-ubuntu-22.04-large
60+
runs-on: ${{ matrix.os }}
5761
strategy:
5862
matrix:
63+
os: [rspack-ubuntu-22.04-large, windows-latest]
5964
go-version: ['1.24.1']
6065
steps:
6166
- name: Checkout code
@@ -73,16 +78,18 @@ jobs:
7378
uses: ./.github/actions/setup-node
7479

7580
- name: Format
81+
if: runner.os == 'Linux'
7682
run: pnpm format:check
7783

7884
- name: Build
7985
run: pnpm build
8086

8187
- name: TypeCheck
88+
if: runner.os == 'Linux'
8289
run: pnpm typecheck
8390

84-
- name: Install xvfb and dependencies
85-
if: ${{ runner.os == 'Linux' && runner.environment == 'self-hosted' }}
91+
- name: Install xvfb and dependencies (Linux only)
92+
if: runner.os == 'Linux'
8693
run: |
8794
sudo apt update
8895
sudo apt install -y libasound2 libgbm1 libgtk-3-0 libnss3 xvfb
@@ -91,9 +98,9 @@ jobs:
9198
uses: lynx-infra/cache@5c6160a6a4c7fca80a2f3057bb9dfc9513fcb732
9299
with:
93100
path: packages/vscode-extension/.vscode-test
94-
key: 'vscode-test'
101+
key: vscode-test-${{ matrix.os }}
95102
restore-keys: |
96-
- 'vscode-test-'
103+
vscode-test-${{ matrix.os }}-
97104
98105
- name: Test on Linux
99106
if: runner.os == 'Linux'
@@ -104,17 +111,19 @@ jobs:
104111
run: pnpm -r test
105112

106113
- name: Check Spell
114+
if: runner.os == 'Linux'
107115
run: pnpm check-spell
108116

109117
- name: Lint
118+
if: runner.os == 'Linux'
110119
run: pnpm run lint
111120

112121
done:
113122
needs:
114123
- test-go
115124
- test-node
116125
if: always()
117-
runs-on: rspack-ubuntu-22.04-large
126+
runs-on: ubuntu-latest
118127
name: CI Done
119128
steps:
120129
- run: exit 1

cmd/rslint/api.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,14 @@ func (h *IPCHandler) HandleLint(req api.LintRequest) (*api.LintResponse, error)
4848
allowedFiles := []string{}
4949
// Apply file contents if provided
5050
if len(req.FileContents) > 0 {
51-
fs = utils.NewOverlayVFS(fs, req.FileContents)
52-
for file := range req.FileContents {
53-
54-
allowedFiles = append(allowedFiles, file) // Collect allowed files from request
51+
fileContents := make(map[string]string, len(req.FileContents))
52+
for k, v := range req.FileContents {
53+
normalizePath := tspath.NormalizePath(k)
54+
fileContents[normalizePath] = v
55+
allowedFiles = append(allowedFiles, normalizePath)
5556
}
57+
fs = utils.NewOverlayVFS(fs, fileContents)
58+
5659
}
5760

5861
// Initialize rule registry with all available rules

cmd/rslint/lsp.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"io"
99
"log"
1010
"os"
11+
"path/filepath"
1112
"strings"
1213
"sync"
1314

@@ -394,7 +395,7 @@ func findRslintConfig(fs vfs.FS, workingDir string) (string, bool) {
394395

395396
// Strategy 1: Try in the working directory
396397
for _, configName := range defaultConfigs {
397-
configPath := workingDir + "/" + configName
398+
configPath := filepath.Join(workingDir, configName)
398399
if fs.FileExists(configPath) {
399400
return configPath, true
400401
}

internal/config/config.go

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ package config
22

33
import (
44
"os"
5-
"path/filepath"
65
"strings"
76

87
"github.com/bmatcuk/doublestar/v4"
8+
"github.com/microsoft/typescript-go/shim/tspath"
99
importPlugin "github.com/web-infra-dev/rslint/internal/plugins/import"
1010
"github.com/web-infra-dev/rslint/internal/rule"
1111
"github.com/web-infra-dev/rslint/internal/rules/adjacent_overload_signatures"
@@ -362,21 +362,21 @@ func isFileIgnored(filePath string, ignorePatterns []string) bool {
362362

363363
for _, pattern := range ignorePatterns {
364364
// Try matching against normalized path
365-
if matched, err := doublestar.PathMatch(pattern, normalizedPath); err == nil && matched {
365+
if matched, err := doublestar.Match(pattern, normalizedPath); err == nil && matched {
366366
return true
367367
}
368368

369369
// Also try matching against original path for absolute patterns
370370
if normalizedPath != filePath {
371-
if matched, err := doublestar.PathMatch(pattern, filePath); err == nil && matched {
371+
if matched, err := doublestar.Match(pattern, filePath); err == nil && matched {
372372
return true
373373
}
374374
}
375375

376376
// Try Unix-style path for cross-platform compatibility
377377
unixPath := strings.ReplaceAll(normalizedPath, "\\", "/")
378378
if unixPath != normalizedPath {
379-
if matched, err := doublestar.PathMatch(pattern, unixPath); err == nil && matched {
379+
if matched, err := doublestar.Match(pattern, unixPath); err == nil && matched {
380380
return true
381381
}
382382
}
@@ -386,25 +386,16 @@ func isFileIgnored(filePath string, ignorePatterns []string) bool {
386386

387387
// normalizePath converts file path to be relative to cwd for consistent matching
388388
func normalizePath(filePath, cwd string) string {
389-
cleanPath := filepath.Clean(filePath)
390-
391-
// If absolute path, try to make it relative to working directory
392-
if filepath.IsAbs(cleanPath) {
393-
if relPath, err := filepath.Rel(cwd, cleanPath); err == nil {
394-
// Only use relative path if it doesn't go outside the working directory
395-
if !strings.HasPrefix(relPath, "..") {
396-
return relPath
397-
}
398-
}
399-
}
400-
401-
return cleanPath
389+
return tspath.NormalizePath(tspath.ConvertToRelativePath(filePath, tspath.ComparePathsOptions{
390+
UseCaseSensitiveFileNames: true,
391+
CurrentDirectory: cwd,
392+
}))
402393
}
403394

404395
// isFileIgnoredSimple provides fallback matching when cwd is unavailable
405396
func isFileIgnoredSimple(filePath string, ignorePatterns []string) bool {
406397
for _, pattern := range ignorePatterns {
407-
if matched, err := doublestar.PathMatch(pattern, filePath); err == nil && matched {
398+
if matched, err := doublestar.Match(pattern, filePath); err == nil && matched {
408399
return true
409400
}
410401
}

internal/config/cwd_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ func TestDoublestarBehavior(t *testing.T) {
143143

144144
for _, tt := range tests {
145145
t.Run(tt.name, func(t *testing.T) {
146-
matched, err := doublestar.PathMatch(tt.pattern, tt.path)
146+
matched, err := doublestar.Match(tt.pattern, tt.path)
147147
if err != nil {
148148
t.Errorf("doublestar.PathMatch error: %v", err)
149149
return

0 commit comments

Comments
 (0)