Skip to content

Offer: Build fixes, test infrastructure, and CI implementation #123

@simonheimlicher

Description

@simonheimlicher

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:

  1. Build system updates - dependency updates and TypeScript fixes
  2. Test infrastructure - reliable test execution with process isolation
  3. 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):

  1. 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
  2. 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):

  1. 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
  2. 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
  3. 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):

  1. 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

  1. Are these contributions welcome?
  2. Should I submit PRs sequentially (1 → 2 → 3) or all at once?
  3. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions