Skip to content

ci(go): run unit tests on main and release branches - #177

Merged
BraveY merged 1 commit into
dragonflyoss:mainfrom
system-thoughts:fix/ci-run-go-unit-tests
Oct 23, 2026
Merged

BraveY merged 1 commit into
dragonflyoss:mainfrom
system-thoughts:fix/ci-run-go-unit-tests

Conversation

@system-thoughts

Copy link
Copy Markdown
Contributor

Description

The existing workflows lint and analyze Go code but never execute the repository's tests. Add a Tests workflow and expose the command as Makefile targets so CI and local runs share one definition.

 .github/workflows/
 ├── check-size.yml
 ├── codeql-analysis.yml
 ├── lint.yaml
+└── test.yaml            # Go unit tests on push/PR to main and release-*
 Makefile
+├── test                 # go test -mod=readonly -count=1 ./...
+└── test-race            # go test -race -mod=readonly -count=1 ./...

The job pins the Go version from go.mod, runs with read-only module resolution and no test-result caching, and uses the race detector.

Related Issue

None. This is CI infrastructure; happy to open an issue first if the project prefers that.

Motivation and Context

pkg/** gained 13 test files (30 test functions, 58 cases including subtests) in #166, #167 and #169, but no workflow ran them, so a regression could land while every check stayed green.

Evidence

  • Before: no test job in .github/workflows; tests only ran manually.
    After: make test-race passes and the workflow runs it on every push/PR.
$ make test-race
ok  github.com/dragonflyoss/perf-tests/pkg/dfgetbench   1.018s
ok  github.com/dragonflyoss/perf-tests/pkg/filebench    1.017s
ok  github.com/dragonflyoss/perf-tests/pkg/imagebench   1.023s
ok  github.com/dragonflyoss/perf-tests/pkg/util         1.028s

real 0m3.171s   # race detector, no race reports

All 30 test functions run; the other 7 packages report [no test files].

Merge Danger

Door: two-way — the workflow and Makefile targets are additive and can be reverted without touching production code.

Blast Radius: CI-only

Once the Go unit tests check is marked required in branch protection, a failing test blocks merges on main and release-*. No runtime behavior changes.

The existing workflows lint and analyze Go code but do not execute the
repository's unit tests. Add a dedicated job for main and release-*
pushes and pull requests targeting those branches, using the Go version
declared in go.mod.

Run the suite with the race detector so tests that exercise the
concurrent benchmark code also check for data races. Use read-only
module resolution and disable test-result caching so every job executes
the assertions and fails on a failing test.

Expose the command as make test and make test-race so local runs and CI
share one definition.

Signed-off-by: Lv Ying <lvying.system.thoughts@gmail.com>

@BraveY BraveY 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.

LGTM, Thanks

@BraveY
BraveY merged commit ffba78e into dragonflyoss:main Oct 23, 2026
7 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.

2 participants