Skip to content

ci: add build, unit test, vet and lint workflows - #123

Open
bhatnitish wants to merge 2 commits into
ROCm:mainfrom
bhatnitish:ci/github-actions
Open

ci: add build, unit test, vet and lint workflows#123
bhatnitish wants to merge 2 commits into
ROCm:mainfrom
bhatnitish:ci/github-actions

Conversation

@bhatnitish

Copy link
Copy Markdown

Stacked on #122 (golangci-lint v2 bump + lint fixes). The diff against main includes it — merge #122 first, or the Lint job here fails.

Why

This repo has no build or test CI. Its only workflow, linting.yml, lints documentation via ROCm/rocm-docs-core. A PR can currently break the build or the unit tests with no automated signal.

Jobs

Each maps to an existing Makefile target, so CI runs exactly what you run locally:

Job Command Artifact
Build make manager manager binary
Unit Tests make unit-test cover.out
Vet make vet
Lint make lint

Four independent jobs, no needs: between them, so a failure is attributable without reading another job's log. Go comes from actions/setup-go with go-version-file: go.mod, so the toolchain tracks the module rather than being pinned separately in CI.

Vet is deliberately its own job even though unit-test: vet already runs it. The duplicate run costs seconds and makes a vet failure visible directly rather than buried in unit-test output. Say the word if you'd rather drop it.

Triggers

PRs to main and release-*, pushes to main (so a broken main announces itself immediately rather than at the next PR), plus manual dispatch. Concurrency group cancels superseded runs.

All checks are advisory

No required status checks are configured — nothing here blocks merge. Deliberate: it lands CI without any chance of disrupting in-flight work, and produces the run history needed to judge which jobs are stable enough to enforce. Enforcement is a follow-up and needs repo admin.

Fork safety

permissions: contents: read, no secrets, no pull_request_target. Note that who may trigger a run is a repository setting (Settings → Actions → General → Fork pull request workflows from outside collaborators), not workflow config.

Submodules

Checkout deliberately does not fetch submodules. external/common-infra-operator is declared, but the dependency is vendored and no Makefile target or Dockerfile references external/ — fetching it would only add a failure mode. (It would work if needed: the repo is public and actions/checkout rewrites the SSH URL.)

Verification

actionlint clean. All four targets run on this branch:

Command Result
make manager pass
make unit-test pass
make vet pass
make lint pass (with #122)

I also confirmed the two uploaded paths — manager and cover.out — are produced at the repo root where the workflow expects them, and that both are already gitignored.

I can't run the workflow itself against this repo, so its first real execution will be on this PR.

`make lint` does not currently work in this repo. It fails before reporting
anything:

    can't load config: the Go language version (go1.23) used to build
    golangci-lint is lower than the targeted Go version (1.25.8)

[email protected] has a toolchain directive forcing it to be built with
go1.23.6, while go.mod targets Go 1.25.8, and golangci-lint refuses that
combination. Staying on v1 is not an option: every v1 release up to and
including the final v1.64.8 is built with Go <= 1.24.

Bump to v2.13.1 (built with go1.26.7). Note the module path gains a /v2 suffix.
There is no .golangci.yml in this repo, so there is no config to migrate - only
the default linter set changes slightly (gosimple folds into staticcheck).

Fix the 34 issues this surfaces. Note that golangci-lint caps duplicate
messages at 3 by default, which reports only 21 of them; the full set was found
with --max-same-issues=0.

  errcheck     7   unchecked Close() / os.Setenv / os.Unsetenv returns
  staticcheck 13   ST1005  capitalized error strings
  staticcheck  5   QF1004  strings.Replace(..., -1) -> strings.ReplaceAll
  staticcheck  4   QF1008  redundant embedded-field selectors
  staticcheck  2   QF1003  if/else-if chain -> tagged switch
  staticcheck  2   SA1019  deprecated NodeSystemInfo.KubeProxyVersion
  staticcheck  1   ST1001  dot import

Notes on the two judgement calls:

- SA1019: KubeProxyVersion appears only as test fixture data and is never read
  by non-test code, so the field is dropped rather than suppressed.

- ST1001: the dot import is gocheck's documented idiom and there are 66 call
  sites across the e2e suite that would need qualifying. Suppressed with a
  nolint carrying that rationale rather than churning the suite.

All changes are behaviour preserving. Verified: make manager, make vet, make
unit-test and make lint all pass, and lint reports 0 issues uncapped.
This repo has no build or test CI. Its only workflow, linting.yml, lints
documentation via ROCm/rocm-docs-core. A pull request can currently break the
build or the unit tests with no automated signal.

Add four jobs, each mapping to an existing Makefile target so CI runs exactly
what a developer runs locally:

  Build       make manager    + uploads the binary
  Unit Tests  make unit-test  + uploads cover.out
  Vet         make vet
  Lint        make lint

The jobs are independent, so a failure is attributable without reading another
job's log. Go comes from actions/setup-go reading go.mod, so the toolchain
tracks the module rather than being pinned separately in CI.

Vet is deliberately its own job even though `unit-test` depends on `vet` and
therefore runs it too. The duplicate run costs seconds and means a vet failure
is visible directly instead of being buried in the unit test output.

Triggers on pull requests to main and release-*, pushes to main so a broken main
announces itself immediately rather than at the next PR, and manual dispatch.
The concurrency group cancels superseded runs.

No required status checks are configured, so nothing here blocks merge. That is
deliberate: it lands CI without disrupting in-flight work and builds the run
history needed to decide what is stable enough to enforce later.

The workflow declares `permissions: contents: read`, references no secrets and
does not use pull_request_target, so fork pull requests are safe to run. Who may
trigger a run is a repository setting (Actions > Fork pull request workflows
from outside collaborators), not workflow configuration.

Checkout does not fetch submodules. external/common-infra-operator is declared
but vendored, and no Makefile target or Dockerfile references external/, so
fetching it would only add a failure mode.

Verified: actionlint reports no issues, all four targets pass, and the two
uploaded paths - manager and cover.out - are produced where the workflow expects
them.
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