Skip to content

Commit

Permalink
add pr-golangci-lint workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
nawazkh committed Sep 5, 2024
1 parent 3bf7e50 commit caf3075
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 3 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/pr-golangci-lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: PR golangci-lint

on:
pull_request:
types: [opened, edited, synchronize, reopened]

# Remove all permissions from GITHUB_TOKEN except metadata.
permissions: {}

jobs:
golangci:
name: lint
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
working-directory:
- ""
- test
- hack/tools
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # tag=v4.1.7
- name: Calculate go version
id: vars
run: echo "go_version=$(make go-version)" >> $GITHUB_OUTPUT
- name: Set up Go
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # tag=v5.0.2
with:
go-version: ${{ steps.vars.outputs.go_version }}
- name: golangci-lint
uses: golangci/golangci-lint-action@aaa42aa0628b4ae2578232a66b541047968fac86 # tag=v6.1.0
with:
version: v1.60.3
args: --out-format=colored-line-number
working-directory: ${{matrix.working-directory}}
21 changes: 18 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@
SHELL:=/usr/bin/env bash

.DEFAULT_GOAL:=help

#
# Go.
#
GO_VERSION ?= 1.22.5
GOPATH := $(shell go env GOPATH)
GOARCH := $(shell go env GOARCH)
GOOS := $(shell go env GOOS)
Expand Down Expand Up @@ -395,7 +398,7 @@ acr-login: ## Login to Azure Container Registry.
.PHONY: docker-pull-prerequisites
docker-pull-prerequisites: ## Pull prerequisites for building controller-manager.
docker pull docker/dockerfile:1.4
docker pull docker.io/library/golang:1.22
docker pull docker.io/library/golang:$(GO_VERSION)
docker pull gcr.io/distroless/static:latest

.PHONY: docker-build
Expand Down Expand Up @@ -649,7 +652,7 @@ release-binary: $(RELEASE_DIR) ## Compile and build release binaries.
-e GOARCH=$(GOARCH) \
-v "$$(pwd):/workspace" \
-w /workspace \
golang:1.22 \
golang:$(GO_VERSION) \
go build -a -ldflags '$(LDFLAGS) -extldflags "-static"' \
-o $(RELEASE_DIR)/$(notdir $(RELEASE_BINARY))-$(GOOS)-$(GOARCH) $(RELEASE_BINARY)

Expand Down Expand Up @@ -872,3 +875,15 @@ $(CODESPELL): ## Build codespell from tools folder.

include conformance.mk
include e2e.mk

## --------------------------------------
## Helpers
## --------------------------------------

##@ helpers:

go-version: ## Print the go version we use to compile our binaries and images
@echo $(GO_VERSION)

# Helper function to get dependency version from go.mod
get_go_version = $(shell go list -m $1 | awk '{print $$2}')

0 comments on commit caf3075

Please sign in to comment.