Skip to content

ci: add test/vet/gofmt workflow on PRs and main - #12

Merged
sahil-noon merged 1 commit into
mainfrom
add-ci-workflow
May 31, 2026
Merged

sahil-noon merged 1 commit into
mainfrom
add-ci-workflow

Conversation

@sahil87

@sahil87 sahil87 commented May 31, 2026

Copy link
Copy Markdown
Owner

What

Adds a CI workflow (.github/workflows/ci.yml) that runs on every pull request and push to main. 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 — fails if any file isn't gofmt-clean
  • go vet — go vet ./...
  • go test — 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 (checkout v4, setup-go v5).

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-latest 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 (appAvailable checks for .desktop files under $HOME/.local/share/applications). On platforms where no default can resolve it now t.Skips the marker assertion rather than failing. Host-independent either way; the WT_TEST_NO_LAUNCH seam 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.go was 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, and go test ./... all pass under Go 1.25 (the go.mod version) with no skips on a bare Linux environment. gofmt -l reports 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

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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.yml to run gofmt, go vet ./..., and go test ./... using go-version-file: src/go.mod.
  • Make TestCreate_WorktreeOpenDefault deterministic 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.go to 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.

@sahil-noon
sahil-noon merged commit b0ffab2 into main May 31, 2026
2 checks passed
@sahil-noon
sahil-noon deleted the add-ci-workflow branch May 31, 2026 02:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants