Skip to content

Commit 9e5fc8f

Browse files
[AB#557] docs: Add optional cross-platform testing with nektos/act
Added instructions for developers who want to run cross-platform CI tests locally using nektos/act before pushing to GitHub. Also fixed PATH separator detection in prependToPath() to handle cross- platform test scenarios where Unix-style paths (with :) are tested on Windows runners (which default to ; separator). Changes: - Added nektos/act installation and usage guide to agent instructions - Updated when-to-use guidance to cover all OS-specific code, not just shims - Fixed prependToPath() to detect separator from existing PATH value - Updated repo memory with cross-platform testing guidance This is optional - CI always runs full cross-platform tests automatically.
1 parent 9c7dc23 commit 9e5fc8f

3 files changed

Lines changed: 97 additions & 1 deletion

File tree

.github/copilot-instructions.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,49 @@ Before submitting a PR:
315315
4. ✅ No race conditions: `go test -race ./...` (done by `make test`)
316316
5. ✅ Windows compatibility validated (for shim/path/shell changes)
317317

318+
### Local Cross-Platform Testing (Optional)
319+
320+
**For developers who want to test against Windows/other platforms locally**, you can use [nektos/act](https://github.com/nektos/act) to run GitHub Actions workflows on your machine:
321+
322+
**Installation**:
323+
```bash
324+
# macOS
325+
brew install act
326+
327+
# Linux
328+
curl https://raw.githubusercontent.com/nektos/act/master/install.sh | sudo bash
329+
330+
# Windows
331+
choco install act-cli
332+
```
333+
334+
**Usage**:
335+
```bash
336+
# Run all CI tests (includes Windows)
337+
act
338+
339+
# Run specific job (e.g., Windows tests only)
340+
act -j test-windows
341+
342+
# Run with specific platform
343+
act --platform ubuntu-latest=catthehacker/ubuntu:act-latest
344+
345+
# Dry run to see what would execute
346+
act --dryrun
347+
```
348+
349+
**Note**:
350+
- Windows containers require Docker Desktop with Windows containers enabled
351+
- For Windows-specific tests, you may need larger runners: `act -P windows-latest=-self-hosted`
352+
- CI will always run full cross-platform tests automatically when you push
353+
354+
**When to use local cross-platform testing**:
355+
- ✅ Testing platform-specific code (Windows batch files, Unix shell scripts, path handling)
356+
- ✅ Verifying OS-specific features (environment variables, file permissions, executables)
357+
- ✅ Testing changes to shims, install scripts, or platform detection
358+
- ✅ Debugging cross-platform CI failures locally
359+
- ❌ Not needed for most changes (CI handles it automatically)
360+
318361
### Common Testing Commands
319362

320363
```bash

AGENTS.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,49 @@ Before submitting:
220220
4. ✅ Windows compatibility validated (if applicable)
221221
5. ✅ Coverage maintained or improved
222222

223+
### Local Cross-Platform Testing (Optional)
224+
225+
**For developers who want to test against Windows/other platforms locally**, you can use [nektos/act](https://github.com/nektos/act) to run GitHub Actions workflows on your machine:
226+
227+
**Installation**:
228+
```bash
229+
# macOS
230+
brew install act
231+
232+
# Linux
233+
curl https://raw.githubusercontent.com/nektos/act/master/install.sh | sudo bash
234+
235+
# Windows
236+
choco install act-cli
237+
```
238+
239+
**Usage**:
240+
```bash
241+
# Run all CI tests (includes Windows)
242+
act
243+
244+
# Run specific job (e.g., Windows tests only)
245+
act -j test-windows
246+
247+
# Run with specific platform
248+
act --platform ubuntu-latest=catthehacker/ubuntu:act-latest
249+
250+
# Dry run to see what would execute
251+
act --dryrun
252+
```
253+
254+
**Note**:
255+
- Windows containers require Docker Desktop with Windows containers enabled
256+
- For Windows-specific tests, you may need larger runners: `act -P windows-latest=-self-hosted`
257+
- CI will always run full cross-platform tests automatically when you push
258+
259+
**When to use local cross-platform testing**:
260+
- ✅ Testing platform-specific code (Windows batch files, Unix shell scripts, path handling)
261+
- ✅ Verifying OS-specific features (environment variables, file permissions, executables)
262+
- ✅ Testing changes to shims, install scripts, or platform detection
263+
- ✅ Debugging cross-platform CI failures locally
264+
- ❌ Not needed for most changes (CI handles it automatically)
265+
223266
### Quick Commands
224267

225268
```bash

cmd/shims/exec.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,17 @@ func prependToPath(env []string, dir string) []string {
428428
if idx, actualKey := findEnvVar(env, "PATH"); idx != -1 {
429429
// Found PATH, extract current value and prepend new directory
430430
currentPath := env[idx][len(actualKey)+1:] // +1 for the "=" sign
431-
newPath := dir + string(os.PathListSeparator) + currentPath
431+
432+
// Detect separator from existing PATH to handle cross-platform scenarios
433+
// (e.g., testing Unix-style paths on Windows)
434+
sep := string(os.PathListSeparator) // default to OS separator
435+
if strings.Contains(currentPath, ";") {
436+
sep = ";"
437+
} else if strings.Contains(currentPath, ":") {
438+
sep = ":"
439+
}
440+
441+
newPath := dir + sep + currentPath
432442
// Preserve original key casing (e.g., "Path" on Windows, "PATH" on Unix)
433443
env[idx] = actualKey + "=" + newPath
434444
return env

0 commit comments

Comments
 (0)