Skip to content

Commit 1189489

Browse files
authored
Merge pull request kubernetes-sigs#10 from sttts/sttts-ci-matrix-aggregation
🌱 .github: add golangci-lint aggregation we can use in branch protection
2 parents d3f5ac8 + ce0eb72 commit 1189489

File tree

4 files changed

+37
-37
lines changed

4 files changed

+37
-37
lines changed

.github/workflows/golangci-lint.yml renamed to .github/workflows/ci.yml

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: golangci-lint
1+
name: CI
22
on:
33
pull_request:
44
types: [opened, edited, synchronize, reopened]
@@ -14,17 +14,18 @@ permissions:
1414
checks: write
1515

1616
jobs:
17-
golangci:
18-
name: lint
17+
golangci-lint-matrix:
1918
runs-on: ubuntu-latest
2019
strategy:
20+
fail-fast: false
2121
matrix:
2222
working-directory:
2323
- ""
2424
- examples/kind
2525
- providers/kind
2626
- examples/cluster-api
2727
- providers/cluster-api
28+
name: golangci-lint [${{ matrix.working-directory }}]
2829
steps:
2930
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag=v4.2.2
3031
- name: Calculate go version
@@ -37,6 +38,32 @@ jobs:
3738
- name: golangci-lint
3839
uses: golangci/golangci-lint-action@2226d7cb06a077cd73e56eedd38eecad18e5d837 # tag=v6.5.0
3940
with:
40-
version: v1.63.4
41+
version: v1.64.5
4142
args: --out-format=colored-line-number
4243
working-directory: ${{matrix.working-directory}}
44+
45+
golangci-lint: # aggregate the results of the matrix job. This we can depend on in the branch protection rule.
46+
name: golangci-lint
47+
runs-on: ubuntu-latest
48+
needs:
49+
- golangci-lint-matrix
50+
if: (failure() || success()) && !contains(needs.golangci-lint-matrix.result, 'skipped')
51+
steps:
52+
- name: noop
53+
run: exit 1
54+
if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')
55+
56+
test:
57+
name: make test
58+
runs-on: ubuntu-latest
59+
steps:
60+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag=v4.2.2
61+
- name: Calculate go version
62+
id: vars
63+
run: echo "go_version=$(make go-version)" >> $GITHUB_OUTPUT
64+
- name: Set up Go
65+
uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # tag=v5.3.0
66+
with:
67+
go-version: ${{ steps.vars.outputs.go_version }}
68+
- name: make test
69+
run: MAKEFLAGS="-s" make test

.github/workflows/test..yml

Lines changed: 0 additions & 30 deletions
This file was deleted.

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ $(CONTROLLER_GEN): # Build controller-gen from tools folder.
9898
GOBIN=$(TOOLS_BIN_DIR) $(GO_INSTALL) $(CONTROLLER_GEN_PKG) $(CONTROLLER_GEN_BIN) $(CONTROLLER_GEN_VER)
9999

100100
GOLANGCI_LINT_BIN := golangci-lint
101-
GOLANGCI_LINT_VER := $(shell cat .github/workflows/golangci-lint.yml | grep [[:space:]]version: | sed 's/.*version: //')
101+
GOLANGCI_LINT_VER := $(shell cat .github/workflows/ci.yml | grep [[:space:]]version: | sed 's/.*version: //')
102102
GOLANGCI_LINT := $(abspath $(TOOLS_BIN_DIR)/$(GOLANGCI_LINT_BIN)-$(GOLANGCI_LINT_VER))
103103
GOLANGCI_LINT_PKG := github.com/golangci/golangci-lint/cmd/golangci-lint
104104

hack/verify.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,8 @@ if [[ -n ${CI} ]]; then
3131
make verify-modules
3232
fi
3333

34-
header_text "running golangci-lint"
35-
make lint
34+
# Only run locally because CI has it run in dedicated jobs
35+
if [[ -z ${CI} ]]; then
36+
header_text "running golangci-lint"
37+
make lint
38+
fi

0 commit comments

Comments
 (0)