Skip to content

Commit

Permalink
feat(chore): code quality with lint, tests and CI
Browse files Browse the repository at this point in the history
  • Loading branch information
darkweak committed Jul 11, 2024
1 parent 173af49 commit 506526d
Show file tree
Hide file tree
Showing 19 changed files with 1,326 additions and 274 deletions.
55 changes: 55 additions & 0 deletions .github/workflows/static.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Run static tests

on:
pull_request:
workflow_dispatch:

env:
GO_VERSION: '1.22'

jobs:
static-validation:
services:
redis:
image: redis
ports:
- 6379:6379
etcd:
image: quay.io/coreos/etcd:v3.5.13
env:
ETCD_NAME: etcd0
ETCD_ADVERTISE_CLIENT_URLS: http://etcd:2379,http://etcd:4001
ETCD_LISTEN_CLIENT_URLS: http://0.0.0.0:2379,http://0.0.0.0:4001
ETCD_INITIAL_ADVERTISE_PEER_URLS: http://etcd:2380
ETCD_LISTEN_PEER_URLS: http://0.0.0.0:2380
ETCD_INITIAL_CLUSTER_TOKEN: etcd-cluster-1
ETCD_INITIAL_CLUSTER: etcd0=http://etcd:2380
ETCD_INITIAL_CLUSTER_STATE: new
ports:
- 2379:2379
- 2380:2380
- 4001:4001
strategy:
matrix:
submodules:
- badger
- core
- etcd
- nuts
- otter
- redis
name: Validate Go code linting
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
working-directory: ${{ matrix.submodules }}
- name: unit tests
run: go test -v -race ./${{ matrix.submodules }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
**/report.xml
35 changes: 35 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
run:
go: '1.22.2'

fix: true

output:
formats:
- format: json
path: stderr
- format: checkstyle
path: report.xml
- format: colored-line-number

linters:
enable-all: true
disable:
- bodyclose
- containedctx
- cyclop
- depguard
- err113
- exhaustruct
- forcetypeassert
- funlen
- gochecknoglobals
- gomoddirectives
- gomnd
- ireturn
- lll
- mnd
- nestif
- nonamedreturns
- stylecheck
- revive
- wrapcheck
18 changes: 15 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.PHONY: bump-version generate-release
.PHONY: bump-version generate-release golangci-lint unit-tests

STORAGES_LIST=badger etcd nuts olric otter redis
STORAGES_LIST=badger core etcd nuts olric otter redis
TESTS_LIST=badger core etcd nuts otter redis

bump-version:
test $(from)
Expand All @@ -20,4 +21,15 @@ bump-version:
done

generate-release:
cd .github/workflows && ./generate_release.sh
cd .github/workflows && ./generate_release.sh

golangci-lint:
for storage in $(STORAGES_LIST) ; do \
cd $$storage && golangci-lint run --fix ; cd - ; \
done

unit-tests:
go test -v -race ./core
for item in $(TESTS_LIST) ; do \
go test -v -race ./$$item ; \
done
Loading

0 comments on commit 506526d

Please sign in to comment.