Skip to content

Commit

Permalink
(Linter Enhancements): use specific version and check with github act…
Browse files Browse the repository at this point in the history
…ions
  • Loading branch information
camilamacedo86 committed Sep 23, 2023
1 parent fe1bcc4 commit 6715d9e
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 3 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Lint
on:
push:
pull_request:

jobs:
lint:
name: golangci-lint
runs-on: ubuntu-latest
steps:
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: '~1.21'
- name: Clone the code
uses: actions/checkout@v4
- name: Run linter
uses: golangci/golangci-lint-action@v3
with:
version: v1.54
3 changes: 3 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
run:
deadline: 5m
allow-parallel-runners: true
19 changes: 16 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ COMMIT?=$(shell git describe HEAD)$(shell git diff --quiet || echo '+dirty')
# Use linker flags to provide commit info
LDFLAGS=-ldflags "-X=github.com/foundriesio/fioctl/subcommands/version.Commit=$(COMMIT)"

linter:=$(shell which golangci-lint 2>/dev/null || echo $(HOME)/go/bin/golangci-lint)

build: fioctl-linux-amd64 fioctl-linux-arm64 fioctl-windows-amd64 fioctl-darwin-amd64 fioctl-darwin-arm64
@true

Expand All @@ -24,12 +22,27 @@ fioctl-%:
go build $(LDFLAGS) -o bin/$@ main.go
@if [ "$@" = "fioctl-windows-amd64" ]; then mv bin/$@ bin/$@.exe; fi

GOLANGCI_LINT = $(shell pwd)/bin/golangci-lint
golangci-lint:
@[ -f $(GOLANGCI_LINT) ] || { \
set -e ;\
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(shell dirname $(GOLANGCI_LINT)) v1.54.2 ;\
}

.PHONY: lint
lint: golangci-lint ## Run linter
$(GOLANGCI_LINT) run --timeout=5m

.PHONY: lint-fix
lint-fix: golangci-lint ## Run golangci-lint linter and perform fixes
$(GOLANGCI_LINT) run --fix

format:
@gofmt -l -w ./
check:
@test -z $(shell gofmt -l ./ | tee /dev/stderr) || echo "[WARN] Fix formatting issues with 'make format'"
@test -x $(linter) || (echo "Please install linter from https://github.com/golangci/golangci-lint/releases/tag/v1.51.2 to $(HOME)/go/bin")
$(linter) run
make lint

# Use the image for Dockerfile.build to build and install the tool.
container-init:
Expand Down
3 changes: 3 additions & 0 deletions subcommands/keys/ca_show.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,9 @@ func prettyPrint(cert string) {
case *ecdsa.PublicKey:
fmt.Println("\t\tNIST CURVE:", pub.Curve.Params().Name)
fmt.Print("\t\t\t")

//FIXME: Fix deprecation and remove the nolint
//nolint: staticcheck: SA1019: elliptic.Marshal has been deprecated since Go 1.21: for ECDH, use the crypto/ecdh package. This function returns an encoding equivalent to that of PublicKey.Bytes in crypto/ecdh. (staticcheck)
for idx, b := range elliptic.Marshal(pub.Curve, pub.X, pub.Y) {
fmt.Printf("%02x:", b)
if (idx+1)%15 == 0 {
Expand Down

0 comments on commit 6715d9e

Please sign in to comment.