diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ca112c4e..4b630442 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,69 +11,13 @@ permissions: contents: read jobs: - build: - name: Build - runs-on: ubuntu-latest - steps: - - name: Check out code - uses: actions/checkout@v7 - - - name: Set up Go - uses: actions/setup-go@v7 - with: - go-version-file: go.mod - cache: true - - - name: Download dependencies - run: go mod download - - - name: Build binary - run: make build - - - name: Check documentation examples and CLI contract - run: python3 scripts/check-docs.py --binary build/l8k - - - name: Build all platforms - run: make build-all - - test: - name: Test - runs-on: ubuntu-latest - steps: - - name: Check out code - uses: actions/checkout@v7 - - - name: Set up Go - uses: actions/setup-go@v7 - with: - go-version-file: go.mod - cache: true - - - name: Download dependencies - run: go mod download - - - name: Run tests - run: go test -v -race -count=1 ./... - - - name: Run tests with coverage - run: | - go test -coverprofile=coverage.out ./... - go tool cover -func=coverage.out - - lint: - name: Lint - runs-on: ubuntu-latest - steps: - - name: Check out code - uses: actions/checkout@v7 - - - name: Set up Go - uses: actions/setup-go@v7 - with: - go-version-file: go.mod - cache: true - - - name: Run golangci-lint - uses: golangci/golangci-lint-action@v9 - with: - version: v2.11 + ci: + uses: Mellanox/cloud-orchestration-reusable-workflows/.github/workflows/go-ci-reusable.yml@main + with: + build-command: | + make build + python3 scripts/check-docs.py --binary build/l8k + make build-all + test-command: | + go test -v -race -count=1 -coverprofile=coverage.out ./... + go tool cover -func=coverage.out diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b21ba725..80132b7c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -12,6 +12,14 @@ Read [AGENTS.md](AGENTS.md) for repository navigation, behavior contracts, build and test guidance, and the development workflow. These shared rules also apply to agent-assisted contributions; `CLAUDE.md` points to the same guide. +### Continuous integration + +Build, test, and lint jobs use `Mellanox/cloud-orchestration-reusable-workflows`. +Go and golangci-lint versions are selected centrally. CI retains documentation +contract checks and cross-platform builds, and combines race detection and +coverage in one test run. `make lint` installs a versioned local binary; +`GOLANGCILINT_VERSION` can select the same version used by CI. + ### Extension Contracts Use the [contract index](openspec/README.md) to identify the integration boundaries diff --git a/Makefile b/Makefile index 4858acec..c36863c1 100644 --- a/Makefile +++ b/Makefile @@ -84,16 +84,23 @@ deps: $(GOMOD) download $(GOMOD) tidy -## Run linter (requires golangci-lint) -lint: - golangci-lint run ./... +# CI supplies this environment variable from the reusable workflow. +GOLANGCILINT_VERSION ?= v2.14.0 +GOLANGCI_LINT = $(CURDIR)/bin/golangci-lint-$(GOLANGCILINT_VERSION) -## Install golangci-lint if not present -install-lint: - @which golangci-lint > /dev/null || (echo "Installing golangci-lint..." && go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest) +## Run linter +lint: install-lint + $(GOLANGCI_LINT) run ./... + +## Install the selected golangci-lint version locally +install-lint: $(GOLANGCI_LINT) +$(GOLANGCI_LINT): + mkdir -p $(CURDIR)/bin + GOBIN=$(CURDIR)/bin go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@$(GOLANGCILINT_VERSION) + mv $(CURDIR)/bin/golangci-lint $(GOLANGCI_LINT) ## Run linter with installation check -lint-check: install-lint lint +lint-check: lint ## Build Docker image docker-build: