-
Notifications
You must be signed in to change notification settings - Fork 400
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #902 from vincepri/update-githubactions-cilint
🌱 Update golangci-lint, Makefile, Actions
- Loading branch information
Showing
19 changed files
with
233 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
name: golangci-lint | ||
on: | ||
pull_request: | ||
types: [opened, edited, synchronize, reopened] | ||
branches: | ||
- main | ||
|
||
permissions: | ||
# Required: allow read access to the content for analysis. | ||
contents: read | ||
# Optional: allow read access to pull request. Use with `only-new-issues` option. | ||
pull-requests: read | ||
# Optional: Allow write access to checks to allow the action to annotate code in the PR. | ||
checks: write | ||
|
||
jobs: | ||
golangci: | ||
name: lint | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
working-directory: | ||
- "" | ||
- tools/setup-envtest | ||
steps: | ||
- name: Set up Go | ||
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # tag=v5.0.0 | ||
with: | ||
go-version: "1.22" | ||
cache: false | ||
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # tag=v4.1.2 | ||
- name: golangci-lint | ||
uses: golangci/golangci-lint-action@3cfe3a4abbb849e10058ce4af15d205b6da42804 # tag=v4.0.0 | ||
with: | ||
version: v1.57.2 | ||
args: --out-format=colored-line-number | ||
working-directory: ${{matrix.working-directory}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
name: PR dependabot go modules fix | ||
|
||
# This action runs on PRs opened by dependabot and updates modules. | ||
on: | ||
pull_request: | ||
branches: | ||
- dependabot/** | ||
push: | ||
branches: | ||
- dependabot/** | ||
workflow_dispatch: | ||
|
||
permissions: | ||
contents: write # Allow to update the PR. | ||
|
||
jobs: | ||
build: | ||
name: Build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out code | ||
uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # tag=v4.1.2 | ||
- name: Set up Go | ||
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # tag=v5.0.0 | ||
with: | ||
go-version: '1.22' | ||
- name: Update all modules | ||
run: make modules | ||
- uses: EndBug/add-and-commit@a94899bca583c204427a224a7af87c02f9b325d5 # tag=v9.1.4 | ||
name: Commit changes | ||
with: | ||
author_name: dependabot[bot] | ||
author_email: 49699333+dependabot[bot]@users.noreply.github.com | ||
default_author: github_actor | ||
message: 'Update generated code' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,3 +16,9 @@ | |
*.swp | ||
*.swo | ||
*~ | ||
|
||
# Tools binaries. | ||
hack/tools/bin | ||
|
||
junit-report.xml | ||
/artifacts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,94 @@ | ||
test-all: | ||
#!/usr/bin/env bash | ||
|
||
# Copyright 2024 The Kubernetes Authors. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
# If you update this file, please follow | ||
# https://suva.sh/posts/well-documented-makefiles | ||
|
||
## -------------------------------------- | ||
## General | ||
## -------------------------------------- | ||
|
||
SHELL:=/usr/bin/env bash | ||
.DEFAULT_GOAL:=help | ||
|
||
# Use GOPROXY environment variable if set | ||
GOPROXY := $(shell go env GOPROXY) | ||
ifeq ($(GOPROXY),) | ||
GOPROXY := https://proxy.golang.org | ||
endif | ||
export GOPROXY | ||
|
||
# Active module mode, as we use go modules to manage dependencies | ||
export GO111MODULE=on | ||
|
||
# Tools. | ||
TOOLS_DIR := hack/tools | ||
TOOLS_BIN_DIR := $(abspath $(TOOLS_DIR)/bin) | ||
GOLANGCI_LINT := $(abspath $(TOOLS_BIN_DIR)/golangci-lint) | ||
GO_INSTALL := ./hack/go-install.sh | ||
|
||
## -------------------------------------- | ||
## Binaries | ||
## -------------------------------------- | ||
|
||
GOLANGCI_LINT_BIN := golangci-lint | ||
GOLANGCI_LINT_VER := $(shell cat .github/workflows/golangci-lint.yml | grep [[:space:]]version: | sed 's/.*version: //') | ||
GOLANGCI_LINT := $(abspath $(TOOLS_BIN_DIR)/$(GOLANGCI_LINT_BIN)-$(GOLANGCI_LINT_VER)) | ||
GOLANGCI_LINT_PKG := github.com/golangci/golangci-lint/cmd/golangci-lint | ||
|
||
$(GOLANGCI_LINT): # Build golangci-lint from tools folder. | ||
GOBIN=$(TOOLS_BIN_DIR) $(GO_INSTALL) $(GOLANGCI_LINT_PKG) $(GOLANGCI_LINT_BIN) $(GOLANGCI_LINT_VER) | ||
|
||
## -------------------------------------- | ||
## Linting | ||
## -------------------------------------- | ||
|
||
.PHONY: lint | ||
lint: $(GOLANGCI_LINT) ## Lint codebase | ||
$(GOLANGCI_LINT) run -v $(GOLANGCI_LINT_EXTRA_ARGS) | ||
cd tools/setup-envtest; $(GOLANGCI_LINT) run -v $(GOLANGCI_LINT_EXTRA_ARGS) | ||
|
||
.PHONY: lint-fix | ||
lint-fix: $(GOLANGCI_LINT) ## Lint the codebase and run auto-fixers if supported by the linter. | ||
GOLANGCI_LINT_EXTRA_ARGS=--fix $(MAKE) lint | ||
|
||
## -------------------------------------- | ||
## Testing | ||
## -------------------------------------- | ||
|
||
.PHONY: test | ||
test: ## Run the test.sh script which will check all. | ||
TRACE=1 ./test.sh | ||
|
||
generate-modules: | ||
test-all: | ||
$(MAKE) test | ||
|
||
.PHONY: modules | ||
modules: ## Runs go mod to ensure modules are up to date. | ||
go mod tidy | ||
|
||
## -------------------------------------- | ||
## Cleanup / Verification | ||
## -------------------------------------- | ||
|
||
.PHONY: clean | ||
clean: ## Cleanup. | ||
$(GOLANGCI_LINT) cache clean | ||
$(MAKE) clean-bin | ||
|
||
.PHONY: clean-bin | ||
clean-bin: ## Remove all generated binaries. | ||
rm -rf hack/tools/bin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#!/usr/bin/env bash | ||
# Copyright 2021 The Kubernetes Authors. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
set -o errexit | ||
set -o nounset | ||
set -o pipefail | ||
|
||
if [ -z "${1}" ]; then | ||
echo "must provide module as first parameter" | ||
exit 1 | ||
fi | ||
|
||
if [ -z "${2}" ]; then | ||
echo "must provide binary name as second parameter" | ||
exit 1 | ||
fi | ||
|
||
if [ -z "${3}" ]; then | ||
echo "must provide version as third parameter" | ||
exit 1 | ||
fi | ||
|
||
if [ -z "${GOBIN}" ]; then | ||
echo "GOBIN is not set. Must set GOBIN to install the bin in a specified directory." | ||
exit 1 | ||
fi | ||
|
||
rm -f "${GOBIN}/${2}"* || true | ||
|
||
# install the golang module specified as the first argument | ||
go install "${1}@${3}" | ||
mv "${GOBIN}/${2}" "${GOBIN}/${2}-${3}" | ||
ln -sf "${GOBIN}/${2}-${3}" "${GOBIN}/${2}" |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.