Repository navigation
ci: add test/vet/gofmt workflow on PRs and main - #12
Merged
Merged
Conversation
The repo had no CI gate — only a release workflow on tags — so tests never ran automatically on pull requests. Add a CI workflow that runs on every PR and push to main: - gofmt -l (fail if any file is not gofmt-clean) - go vet ./... - go test ./... It uses go-version-file: src/go.mod (the same single source of truth as release.yml) and reuses release.yml's pinned action SHAs. Two prerequisites so the new gates pass on a clean checkout: 1. TestCreate_WorktreeOpenDefault assumed the host had a launchable default app. A bare CI runner has none (no editor/terminal/clipboard), so DetectDefaultApp returned "no default app detected" and the launch-guard marker assertion failed. The test now seeds a fake code.desktop under a temp $HOME so VSCode resolves as the default on Linux deterministically, and skips the marker assertion on platforms where no default can be resolved — making it host-independent. 2. Format the module with gofmt so the gofmt gate is green. The changes are whitespace/alignment only, except one comment in apps.go that was reworded: gofmt's comment smart-quoting rewrote the shell-escape example into a Unicode right-quote, corrupting its meaning. The reword removes the quote pair that triggered it, keeping the file gofmt-clean under both Go 1.25 and 1.26 without losing the explanation.
There was a problem hiding this comment.
Pull request overview
Adds a new GitHub Actions CI workflow to continuously enforce Go formatting and run vet/tests on PRs and pushes to main, and updates the codebase/tests to be deterministic and gofmt-clean so the new gates pass reliably.
Changes:
- Add
.github/workflows/ci.ymlto rungofmt,go vet ./..., andgo test ./...usinggo-version-file: src/go.mod. - Make
TestCreate_WorktreeOpenDefaultdeterministic in headless environments by seeding a fake default app on Linux and skipping the launch-marker assertion when no default app can be resolved. - Apply gofmt-driven formatting/import ordering changes and reword a comment in
apps.goto avoid gofmt “smart quote” corruption.
Reviewed changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
.github/workflows/ci.yml |
New CI workflow running gofmt/vet/test on PRs and main pushes. |
src/cmd/wt/create_test.go |
Removes environment dependency from default-app test; adds deterministic Linux seeding + skip fallback. |
src/internal/worktree/apps.go |
Comment rewording for shell-quoting explanation (keeps gofmt output stable). |
src/internal/worktree/errors.go |
gofmt alignment changes only. |
src/cmd/wt/main.go |
gofmt import ordering. |
src/cmd/wt/list.go |
gofmt import ordering. |
src/cmd/wt/init.go |
gofmt import ordering. |
src/cmd/wt/create.go |
gofmt import ordering. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds a
CIworkflow (.github/workflows/ci.yml) that runs on every pull request and push tomain. Until now the repo only had a release workflow (tag-triggered), so tests never ran automatically on PRs — including the recently-merged #10 and the open #11.The workflow runs three gates:
gofmt-cleango vet ./...go test ./...It uses
go-version-file: src/go.mod(the same single source of truth asrelease.yml) and reusesrelease.yml's pinned action SHAs (checkoutv4,setup-gov5).Prerequisites included so the gates pass on a clean checkout
1. Fix
TestCreate_WorktreeOpenDefault's environment dependency.The test assumed the host had a launchable default app. A bare
ubuntu-latestrunner has none (no editor/terminal/clipboard), soDetectDefaultAppreturned "no default app detected" and the launch-guard marker assertion failed. The test now seeds a fakecode.desktopunder a temp$HOME, so VSCode resolves as the default on Linux deterministically (appAvailablechecks for.desktopfiles under$HOME/.local/share/applications). On platforms where no default can resolve it nowt.Skips the marker assertion rather than failing. Host-independent either way; theWT_TEST_NO_LAUNCHseam still prevents any real launch.2. Format the module so the gofmt gate is green.
Whitespace/alignment only, with one exception: a comment in
apps.gowas reworded. gofmt's comment smart-quoting was rewriting the shell-escape example'\''into a Unicode right-quote (’), corrupting the comment's meaning. The reword removes the quote pair that triggered it — the file is now gofmt-clean under both Go 1.25 and 1.26 without losing the explanation.Verification
go build,go vet, andgo test ./...all pass under Go 1.25 (thego.modversion) with no skips on a bare Linux environment. gofmt-lreports clean.Note
This is independent of #11 (the menu byte-theft fix). Once this merges, #11 (and future PRs) will get the test gate automatically — #11 may need a trivial rebase to pick up the workflow, or it can merge first; either order works.
🤖 Generated with Claude Code