Skip to content

Commit

Permalink
Update CI
Browse files Browse the repository at this point in the history
Signed-off-by: futuretea <[email protected]>
  • Loading branch information
futuretea committed Sep 19, 2023
1 parent 852276f commit 72f2d17
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 71 deletions.
26 changes: 14 additions & 12 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ on:
push:
branches:
- master
- harvester
paths-ignore:
- '*.md'
pull_request:
branches:
- master
- harvester
paths-ignore:
- '*.md'
permissions:
Expand All @@ -20,15 +22,15 @@ env:
jobs:
lint:
name: Run linter
runs-on: ubuntu-18.04
runs-on: ubuntu-latest
steps:
- name: Setup Go
uses: actions/setup-go@v2
uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}
- name: Checkout code
uses: actions/checkout@v2
- uses: actions/cache@v2
uses: actions/checkout@v3
- uses: actions/cache@v3
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
Expand All @@ -38,15 +40,15 @@ jobs:
run: make lint
test:
name: Run tests
runs-on: ubuntu-18.04
runs-on: ubuntu-latest
steps:
- name: Setup Go
uses: actions/setup-go@v2
uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}
- name: Checkout code
uses: actions/checkout@v2
- uses: actions/cache@v2
uses: actions/checkout@v3
- uses: actions/cache@v3
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
Expand All @@ -59,15 +61,15 @@ jobs:
needs:
- lint
- test
runs-on: ubuntu-18.04
runs-on: ubuntu-latest
steps:
- name: Setup Go
uses: actions/setup-go@v2
uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}
- name: Checkout code
uses: actions/checkout@v2
- uses: actions/cache@v2
uses: actions/checkout@v3
- uses: actions/cache@v3
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
Expand Down
24 changes: 12 additions & 12 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ env:
jobs:
lint:
name: Run linter
runs-on: ubuntu-18.04
runs-on: ubuntu-latest
steps:
- name: Setup Go
uses: actions/setup-go@v2
uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}
- name: Checkout code
uses: actions/checkout@v2
- uses: actions/cache@v2
uses: actions/checkout@v3
- uses: actions/cache@v3
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
Expand All @@ -29,15 +29,15 @@ jobs:
run: make lint
test:
name: Run tests
runs-on: ubuntu-18.04
runs-on: ubuntu-latest
steps:
- name: Setup Go
uses: actions/setup-go@v2
uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}
- name: Checkout code
uses: actions/checkout@v2
- uses: actions/cache@v2
uses: actions/checkout@v3
- uses: actions/cache@v3
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
Expand All @@ -47,17 +47,17 @@ jobs:
run: make test
release:
name: Release
runs-on: ubuntu-18.04
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Setup Go
uses: actions/setup-go@v2
uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}
- name: Checkout code
uses: actions/checkout@v2
- uses: actions/cache@v2
uses: actions/checkout@v3
- uses: actions/cache@v3
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
Expand Down
61 changes: 22 additions & 39 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -1,44 +1,27 @@
run:
deadline: 5m
skip-dirs:
- go/pkg/mod
linters:
enable-all: true
disable:
- golint # deprecated
- interfacer # deprecated
- maligned # deprecated
- scopelint # deprecated
- cyclop # duplicate of gocyclo
- rowserrcheck # exclude 'sql' preset
- sqlclosecheck # exclude 'sql' preset
- exhaustivestruct
- gochecknoglobals
- goconst
- godox
- goerr113
- gomnd
- gomoddirectives
- lll
- nlreturn
- prealloc
- wrapcheck
- wsl
enable:
- vet
- staticcheck
- errcheck
- gofmt
- goimports
- whitespace
- unused
- ineffassign
- stylecheck
- gosimple
- misspell
# - depguard
# - goconst
# - prealloc
# - gosec
enable-all: false
disable-all: true
fast: false
linters-settings:
depguard:
list-type: blacklist
include-go-root: true
packages:
- errors
- io/ioutil
- sync/atomic
- github.com/pkg/errors
- github.com/stretchr/testify/assert
- gotest.tools/v3
packages-with-error-message:
- errors: "Use github.com/cockroachdb/errors instead."
- io/ioutil: "The 'io/ioutil' package is deprecated. Use corresponding 'os' or 'io' functions instead."
- sync/atomic: "Use go.uber.org/atomic instead."
- github.com/pkg/errors: "Use github.com/cockroachdb/errors instead."
- github.com/stretchr/testify/assert: "Use github.com/stretchr/testify/require instead."
- gotest.tools/v3: "Use github.com/stretchr/testify instead."
gci:
goimports:
local-prefixes: github.com/tohjustin/kube-lineage
18 changes: 11 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
SHELL:=/bin/bash

GO_VERSION = "1.17"
GOLANGCI_LINT_VERSION = "1.42.1"
GORELEASER_VERSION = "1.0.0"
GO_VERSION = "1.18"
GOLANGCI_LINT_VERSION = "1.54.2"
GORELEASER_VERSION = "1.20.0"

export BUILD_DATE = $(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
export GIT_COMMIT = $(shell git rev-parse HEAD)
export GIT_TREE_STATE = $(shell if [ -z "`git status --porcelain`" ]; then echo "clean" ; else echo "dirty"; fi)
export GIT_VERSION = $(shell git describe --tags --always | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+(-.*)?')
export GIT_VERSION_MAJOR = $(shell if [[ "${GIT_VERSION}" ]]; then echo ${GIT_VERSION} | cut -d 'v' -f 2 | cut -d "." -f 1 ; fi)
export GIT_VERSION_MINOR = $(shell if [[ "${GIT_VERSION}" ]]; then echo ${GIT_VERSION} | cut -d 'v' -f 2 | cut -d "." -f 2 ; fi)
export CGO_ENABLED = 1
export CGO_ENABLED = 0

REPO = $(shell go list -m)
GO_BUILD_ARGS = \
Expand All @@ -34,17 +34,21 @@ all: install
clean:
rm -rf bin dist

.PHONY: mod
mod:
go mod tidy -v && go mod vendor -v

.PHONY: lint
lint:
lint: mod
source ./scripts/fetch.sh; fetch golangci-lint $(GOLANGCI_LINT_VERSION) && ./bin/golangci-lint run

.PHONY: test
test:
go test ./...

.PHONY: build
build:
go build $(GO_BUILD_ARGS) -o bin/kube-lineage ./cmd/kube-lineage
build: mod
go build $(GO_BUILD_ARGS) -mod=vendor -o bin/kube-lineage ./cmd/kube-lineage

.PHONY: install
install: build
Expand Down
2 changes: 1 addition & 1 deletion scripts/goreleaser_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ hash_sha256_verify() {
return 1
fi
BASENAME=${TARGET##*/}
want=$(grep "${BASENAME}" "${checksums}" 2>/dev/null | tr '\t' ' ' | cut -d ' ' -f 1)
want=$(grep "${BASENAME}$" "${checksums}" 2>/dev/null | tr '\t' ' ' | cut -d ' ' -f 1)
if [ -z "$want" ]; then
log_err "hash_sha256_verify unable to find checksum for '${TARGET}' in '${checksums}'"
return 1
Expand Down

0 comments on commit 72f2d17

Please sign in to comment.