Skip to content

Commit

Permalink
(chore): Add linter improvements
Browse files Browse the repository at this point in the history
Signed-off-by: Camila Macedo <[email protected]>
  • Loading branch information
camilamacedo86 committed Sep 27, 2023
1 parent 47a8873 commit 6bbac30
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 12 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.19'
- name: Clone the code
uses: actions/checkout@v4
- name: Run linter
uses: golangci/golangci-lint-action@v3
with:
version: v1.51.2
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
8 changes: 0 additions & 8 deletions .jobserv.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
timeout: 30
triggers:
- name: pull-request
type: github_pr
runs:
- name: unit-test
container: golangci/golangci-lint:v1.51.2
host-tag: amd64
script: unit-test

- name: create-release
type: git_poller
params:
Expand Down
19 changes: 15 additions & 4 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,25 @@ 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
install-linter:
echo "[WARN] Installing golangci binary version v1.51.2 into the project's bin/ directory for this check"
@curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(shell dirname $(GOLANGCI_LINT)) v1.51.2

has-linter:
@test -x $(GOLANGCI_LINT) || (echo '[ERROR] Please install go linter using "make install-linter"' && exit 1)

lint-check: has-linter ## Run linter
$(GOLANGCI_LINT) run

lint-fix: has-linter ## 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-check

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

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 6bbac30

Please sign in to comment.