Skip to content

Commit

Permalink
♻️ Add makefile and update ci config
Browse files Browse the repository at this point in the history
  • Loading branch information
ishantiw committed Jan 9, 2024
1 parent dfbd042 commit 6dac3ed
Show file tree
Hide file tree
Showing 7 changed files with 114 additions and 35 deletions.
33 changes: 0 additions & 33 deletions .github/workflows/go.yml

This file was deleted.

32 changes: 32 additions & 0 deletions .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# This workflow will build a golang project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go

name: 'PR CI'

on:
pull_request:

jobs:
check:
runs-on: self-hosted
steps:
- uses: actions/checkout@v3
- name: setup-go
uses: actions/setup-go@v4
with:
go-version: '1.21'
- name: build
run: go build -v ./...
- name: golangci-lint
run: make lint
- name: format
run: |
make format
if [ -z "$(git status --untracked-files=no --porcelain)" ]; then
echo "All files formatted"
else
echo "Running format is required"
exit 1
fi
- name: test
run: make test
59 changes: 59 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
run:
timeout: 5m
go: "1.19"
skip-files:
- "bindata.go"

linters:
disable-all: true
fast: false
enable:
- errcheck
- gosimple
- govet
- ineffassign
- goimports
- staticcheck
- typecheck
- unused
- whitespace
- errname
- godot
- exportloopref
- goconst
- gocritic
- gosec
- misspell
- nakedret
- nolintlint
- stylecheck
- unconvert
- usestdlibvars
- revive
- reassign
- predeclared
- errorlint
# - testpackage // Consider to adopt in the future

issues:
exclude-rules:
- source: "(noinspection|TODO)"
linters: [ godot ]
- path: "_test\\.go"
linters:
- goconst
- gosec
- errcheck
- text: "Use of weak random number generator"
linters:
- gosec
max-same-issues: 50

linters-settings:
revive:
enable-all-rules: false
rules:
- name: var-naming
disabled: true
stylecheck:
checks: ["*", "-ST1003"]
19 changes: 19 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# makefile

PKGS=$(shell go list ./... | grep -v "/vendor/")

.PHONY: test

test:
@echo "Test packages"
@go test -race -shuffle=on -coverprofile=coverage.out -cover $(PKGS)

lint:
@go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
golangci-lint run
format:
gofmt -s -w .
godocs:
@go install golang.org/x/tools/cmd/godoc@latest
@echo "open http://localhost:6060/pkg/github.com/LiskHQ/lisk-engine"
godoc -http=:6060
1 change: 0 additions & 1 deletion cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (

func main() {
logger, err := log.NewDefaultProductionLogger()

if err != nil {
panic(err)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/fault_detector/fault_detector.go
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// Package faultdetector implements Optimisim fault detector
// Package faultdetector implements Optimism fault detector
package faultdetector
3 changes: 3 additions & 0 deletions pkg/log/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,3 +142,6 @@ func (l *logger) With(kv ...interface{}) Logger {
zlog: l.zlog.With(kv...),
}
}

// Ensure logger conforms to the Logger interface.
var _ Logger = (*logger)(nil)

0 comments on commit 6dac3ed

Please sign in to comment.