Background
I've been working on a feature to pick up user-level config from ~/.config/dprint/dprint.jsonc (related to issue 118). Before submitting that feature, I wanted to ensure proper test coverage across platforms since reading from the user's home directory may have platform-specific implications.
While setting up CI, I encountered and fixed several issues with the build system and test infrastructure. These fixes are useful independent of my feature work, so I'm offering them as a standalone contribution.
I'd like to contribute improvements in three focused areas:
- Build system updates - dependency updates and TypeScript fixes
- Test infrastructure - reliable test execution with process isolation
- GitHub Actions CI - cross-platform automated testing
I've prepared three PRs on my fork, each addressing a single concern. (I previously opened PR #120 for TypeScript fixes but closed it to create cleaner, more focused commits.)
PR 1: Build System Updates
Problem: Project has compilation errors from dependency version mismatches and outdated TypeScript configuration.
Changes (2 commits):
-
build: update dependencies for VSCode 1.75+ compatibility
- Update
engines.vscode from ^1.45.0 to ^1.75.0
- Update
@types/vscode from ^1.45.0 to ^1.75.0
- Update
@vscode/test-electron from ^2.1.5 to ^2.5.2
- Update
@vscode/vsce from ^3.3.2 to ^3.7.1
- Run
npm audit fix for security vulnerabilities
-
fix: resolve TypeScript compilation errors
- Add
esModuleInterop and skipLibCheck to tsconfig.json
- Add explicit return type to
tryResolveInNodeModules in npm.ts
- Fix type guard in ActivatedDisposables.ts
Verification: npm run compile passes with 0 errors
PR 2: Test Infrastructure
Problem: Tests fail due to:
- Hardcoded paths (
process.cwd()) that don't work across environments
pkill dprint killing the VSCode process itself (VSCode's extension host path contains "dprint")
- Race conditions during test cleanup (VSCode's local history feature)
Changes (3 commits):
-
test: fix test infrastructure for reliable execution
Tests can be run two ways, each with different workspace handling:
Via npm run test (CI and command line):
runTest.ts creates an isolated workspace in os.tmpdir()
- Workspace is cleaned up automatically between runs
Via VSCode "Extension Tests" task (Run and Debug panel):
launch.json opens test-workspace/ folder as the workspace
- Added
test-workspace/.gitkeep to repo (with contents gitignored)
- Allows debugging tests directly in VSCode
Common changes:
- Get workspace root from
vscode.workspace.workspaceFolders (works for both modes)
- Create
dprint.json in workspace root for extension discovery
- Create test files in
test/ subdirectory within workspace
- Disable VSCode's local history to prevent ENOENT race conditions during cleanup
-
feat(test): implement PID-based process management
- Add
getEditorServicePid() API through extension architecture
- Replace system-wide
pkill dprint with targeted process killing
- Add integration test verifying process isolation
- Architecture: EditorProcess → EditorService → FolderService → WorkspaceService → ExtensionBackend → Extension API
-
fix(test): clear inherited VSCode env vars before spawning test instance
- Clear
ELECTRON_* and VSCODE_* env vars in runTest.ts
- Prevents issues when tests are run from within a VSCode extension host
Verification: All 4 tests pass via npm test
PR 3: GitHub Actions CI
Changes (1 commit):
ci: add GitHub Actions workflow with CI-specific timeouts
- Cross-platform testing (Ubuntu, macOS, Windows)
- Automatic dprint binary installation
xvfb-run for headless display on Linux
- CI-specific timeouts (30s suite / 2s init wait) for plugin downloads and cold starts
Verification: All tests pass on all 3 platforms
Summary
| PR |
Branch |
Commits |
Purpose |
| 1 |
update_build |
2 |
Build system and TypeScript fixes |
| 2 |
fix_tests |
3 |
Test infrastructure, process isolation, env var fix |
| 3 |
add_ci |
1 |
GitHub Actions CI workflow |
Total: 6 clean commits, each focused on a single change.
Note: Potential Windows Issue in Upstream
During review of our PR, a potential Windows compatibility issue was identified in upstream commit c4a3ea8 ("fix: improve how dprint executable is launched"):
The change from shell: true to shell: false in spawn() and from exec to execFile may break Windows installations where dprint is provided as a .cmd/.bat shim (e.g., npm install -g dprint). These shim files cannot be executed without a shell on Windows.
This is pre-existing in upstream/main, not introduced by our changes. Mentioning it here in case it's relevant for the maintainer's awareness.
Questions
- Are these contributions welcome?
- Should I submit PRs sequentially (1 → 2 → 3) or all at once?
- Any preferences on commit message style or PR format?
Fork PR for Review
Combined PR with all changes: simonheimlicher#8
Happy to adjust based on your preferences before submitting to upstream.
Background
I've been working on a feature to pick up user-level config from
~/.config/dprint/dprint.jsonc(related to issue 118). Before submitting that feature, I wanted to ensure proper test coverage across platforms since reading from the user's home directory may have platform-specific implications.While setting up CI, I encountered and fixed several issues with the build system and test infrastructure. These fixes are useful independent of my feature work, so I'm offering them as a standalone contribution.
I'd like to contribute improvements in three focused areas:
I've prepared three PRs on my fork, each addressing a single concern. (I previously opened PR #120 for TypeScript fixes but closed it to create cleaner, more focused commits.)
PR 1: Build System Updates
Problem: Project has compilation errors from dependency version mismatches and outdated TypeScript configuration.
Changes (2 commits):
build: update dependencies for VSCode 1.75+ compatibilityengines.vscodefrom ^1.45.0 to ^1.75.0@types/vscodefrom ^1.45.0 to ^1.75.0@vscode/test-electronfrom ^2.1.5 to ^2.5.2@vscode/vscefrom ^3.3.2 to ^3.7.1npm audit fixfor security vulnerabilitiesfix: resolve TypeScript compilation errorsesModuleInteropandskipLibCheckto tsconfig.jsontryResolveInNodeModulesin npm.tsVerification:
npm run compilepasses with 0 errorsPR 2: Test Infrastructure
Problem: Tests fail due to:
process.cwd()) that don't work across environmentspkill dprintkilling the VSCode process itself (VSCode's extension host path contains "dprint")Changes (3 commits):
test: fix test infrastructure for reliable executionTests can be run two ways, each with different workspace handling:
Via
npm run test(CI and command line):runTest.tscreates an isolated workspace inos.tmpdir()Via VSCode "Extension Tests" task (Run and Debug panel):
launch.jsonopenstest-workspace/folder as the workspacetest-workspace/.gitkeepto repo (with contents gitignored)Common changes:
vscode.workspace.workspaceFolders(works for both modes)dprint.jsonin workspace root for extension discoverytest/subdirectory within workspacefeat(test): implement PID-based process managementgetEditorServicePid()API through extension architecturepkill dprintwith targeted process killingfix(test): clear inherited VSCode env vars before spawning test instanceELECTRON_*andVSCODE_*env vars in runTest.tsVerification: All 4 tests pass via
npm testPR 3: GitHub Actions CI
Changes (1 commit):
ci: add GitHub Actions workflow with CI-specific timeoutsxvfb-runfor headless display on LinuxVerification: All tests pass on all 3 platforms
Summary
update_buildfix_testsadd_ciTotal: 6 clean commits, each focused on a single change.
Note: Potential Windows Issue in Upstream
During review of our PR, a potential Windows compatibility issue was identified in upstream commit c4a3ea8 ("fix: improve how dprint executable is launched"):
The change from
shell: truetoshell: falseinspawn()and fromexectoexecFilemay break Windows installations where dprint is provided as a.cmd/.batshim (e.g.,npm install -g dprint). These shim files cannot be executed without a shell on Windows.This is pre-existing in upstream/main, not introduced by our changes. Mentioning it here in case it's relevant for the maintainer's awareness.
Questions
Fork PR for Review
Combined PR with all changes: simonheimlicher#8
Happy to adjust based on your preferences before submitting to upstream.