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
Camila Macedo committed Sep 27, 2023
1 parent 47a8873 commit 521c519
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 13 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
23 changes: 18 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,26 @@ fioctl-%:
go build $(LDFLAGS) -o bin/$@ main.go
@if [ "$@" = "fioctl-windows-amd64" ]; then mv bin/$@ bin/$@.exe; fi

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")
install-linter:
echo "[WARN] Installing golangci binary version v1.51.2 at $(HOME)/go/bin/golangci-lint"
@curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(shell dirname $(linter)) v1.51.2

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

linter-check: has-linter
$(linter) run

linter-fix: has-linter
echo "[WARN] Attempting to automatically fix some linter issues."
$(linter) run --fix

format-check:
@test -z $(shell gofmt -l ./ | tee /dev/stderr) || echo "[WARN] Fix formatting issues with 'make format-check'"

check: format-check linter-check
@true

# Use the image for Dockerfile.build to build and install the tool.
container-init:
docker build -t fioctl-build -f Dockerfile.build .
Expand Down

0 comments on commit 521c519

Please sign in to comment.