Skip to content

ci: run push builds only on main and skip internal/cmd tests on macOS - #332

Merged
bpauli merged 1 commit into
mainfrom
ci/trim-runs
Nov 4, 2026
Merged

bpauli merged 1 commit into
mainfrom
ci/trim-runs

Conversation

@bpauli

@bpauli bpauli commented Nov 4, 2026 •

Copy link
Copy Markdown
Owner

Summary

PR CI takes about 20 minutes. The last run of #329 is an example. The macOS job waited about 10 minutes for a runner and then spent about 9 minutes in make test. This PR changes two things in .github/workflows/ci.yml:

  • Push builds run only for main. Before, each push to a PR branch started two full CI runs, one for push and one for pull_request. Each run used its own macOS runner. A PR now gets one run, from pull_request. A push to main still gets a run.
  • The macOS job skips the internal/cmd tests. It now runs make test-other-packages and the cgo Keychain build. internal/cmd has no darwin-specific code, and the Linux test job still runs it with -race. The darwin-specific code is in internal/garminauth/sso.go and internal/config, and test-other-packages covers it. The job name darwin-cgo-build does not change, so the merge rule in AGENTS.md still applies.

A branch without a PR no longer gets CI on push.

The slow internal/cmd tests themselves are a separate change: each test run builds the whole Kong parser again (77 ms under -race, about 6000 times).

Verification

Each push to a PR branch started two full CI runs, one for push and one
for pull_request, so every PR push used two macOS runners. Push builds
now run only for main. PRs get their run from pull_request.

The macOS job ran the full make test for about 9 minutes, and most of
that time was the internal/cmd tests. internal/cmd has no
darwin-specific code, and the Linux test job runs it with -race. The
macOS job now runs make test-other-packages, which covers the
darwin-specific code in internal/garminauth and internal/config, and it
still builds with cgo for the Keychain.
@bpauli

bpauli commented Nov 4, 2026

Copy link
Copy Markdown
Owner Author

Independent verification: PASS+NOTES

Head 4f802c8f3989bac3f071e9c3fca50942cd4ed53f, base 8a832a9b51644e5618cee2d414dd76df1aa84f9c, checked against main 2bcd38d0be93119065434b0b15a6696b373fb2be (local merge of head into main, own worktree).

What I ran

  • Merge of head into main 2bcd38d: no conflict. The merge differs from main only in .github/workflows/ci.yml (+4/-2). git diff 8a832a9 2bcd38d -- Makefile .github is empty, so feat: set FTP and power zones #329 and perf(cmd): build the command parser once per process #333 did not touch the Makefile or the workflows. make test-other-packages still exists: go test -race -timeout 20m $(go list ./... | grep -v '/internal/cmd$'). It excludes only internal/cmd and keeps internal/config, internal/garminauth, internal/secrets and conformance.
  • make test-other-packages on the merge, with HOME and XDG_CONFIG_HOME in a temp dir: all 15 packages ok, 24 s.
  • go test -count=1 -run Workflow ./conformance/: TestE2EWorkflowKeepsTheRecordedSetOnTheRunner passes. No other Go test reads ci.yml.
  • actionlint 1.7.12 on the merged ci.yml and on all workflows: clean.
  • Search for OS-specific code: no build tags, _darwin.go files or runtime.GOOS in internal/cmd. The only runtime.GOOS switch is in internal/garminauth/sso.go. The unix/!unix files are in internal/config and internal/secrets. All of these stay in the macOS job.
  • Trigger semantics: the GitHub workflow syntax docs say that when only branches is set, the workflow "won't run for events affecting the undefined Git ref". So push now runs for main only and not for tags. pull_request has no filter, so a PR against any base still gets a run. gh run list --branch ci/trim-runs --workflow ci.yml shows one run, 41799508338, event pull_request, and no push run.
  • Branch protection: gh api repos/bpauli/gccli/branches/main/protection returns 404 (not protected), and rulesets is []. No required check depends on the push event. e2e.yml has its own push: branches: [main] filter and release.yml runs on tags. Neither depends on ci.yml.
  • PR Verification claims, rerun from gh run view --json jobs. Run 41799508338: darwin-cgo-build 1m13s, test 10m40s, conformance 1m42s. The darwin log shows make test-other-packages and no internal/cmd. In the feat: set FTP and power zones #329 runs, darwin-cgo-build took 9m21s (pull_request 41727259684, started 10 min after the run was created) and 10m46s (push 41727252071). The claims are confirmed.

Notes

  1. internal/cmd has no darwin-specific source code, but some of its tests do exercise OS behavior on darwin. lockTokens in internal/cmd/client.go takes the flock token lock in config.ConfigDir() (on darwin, ~/Library/Application Support/gccli), and on darwin it maps the errors to fs.ErrPermission/EROFS. TestRefreshLockWaitMessage, TestResolveClient_LockFails and TestResolveClient_ReadOnlyConfigDirRefreshesUnlocked now run on Linux only. config.LockFile itself stays covered on darwin through the internal/config Update tests. I think this loss is acceptable.
  2. The darwin job is the only place where an internal/cmd test has failed alone. In the last 60 failed CI runs, TestRefreshLockWaitMessage failed only on darwin: run 41799663798 (main push at e51f9e2, so main was red there) and run 40772274263. Both failed with stderr = "". My guess is that this is a timing flake, not a darwin bug. The test starts the 1.5 s unlock timer before execute. When a slow runner takes more than 0.5 s to reach the lock, the wait stays under the 1 s threshold and the message is not printed. After this PR the flake can still occur on Linux, but no runner shows it often. It should get its own issue.
  3. Tag pushes no longer start ci.yml. v3.0.0 and v3.1.0 each had a tag-push run. The tagged commit is on main and gets its main push run, and release.yml does not depend on ci.yml, so this costs little. The PR description does not name it.
  4. The push-to-main run under the new filter can only be seen after merge. Check that the merge commit gets exactly one push run of ci.yml.
  5. Not run: make fmt-check, make lint, go vet -tags e2e ./..., make test and the binary-vs-mock comparison. No Go file or Makefile changed, and CI run 41811269931 on main 2bcd38d passed all three jobs. Not done: live Garmin calls, auth login.

@bpauli
bpauli merged commit 9ac1cf6 into main Nov 4, 2026
3 checks passed
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.

1 participant