Skip to content

Commit fa209aa

Browse files
committed
Add Makefile
1 parent 27a800e commit fa209aa

File tree

5 files changed

+125
-1106
lines changed

5 files changed

+125
-1106
lines changed

.github/workflows/go.yml

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,26 @@ jobs:
2626
cache: true
2727

2828
- name: Build
29-
run: go build -v ./...
29+
run: make build
30+
31+
- name: Format
32+
run: |
33+
make fmt
34+
if [[ -n $(git status --porcelain) ]]; then
35+
echo "Code is not formatted. Please run 'make fmt'"
36+
git diff
37+
exit 1
38+
fi
39+
40+
# Disabled for now
41+
# - name: Lint
42+
# uses: golangci/golangci-lint-action@v8
43+
# with:
44+
# version: v2.4.0
3045

3146
- name: Tests
3247
run: |
33-
go install github.com/jstemmer/go-junit-report/v2@latest
34-
go test -short -timeout 240s -race -count 1 -v ./... 2>&1 | go-junit-report -set-exit-code -iocopy -out "${{ github.workspace }}/report.xml"
48+
go test -short -timeout 240s -race -count 1 -v ./... 2>&1 | go tool go-junit-report -set-exit-code -iocopy -out "${{ github.workspace }}/report.xml"
3549
3650
- name: Test Summary
3751
uses: test-summary/action@v2
@@ -64,8 +78,7 @@ jobs:
6478

6579
- name: Tests
6680
run: |
67-
go install github.com/jstemmer/go-junit-report/v2@latest
68-
go test -timeout 240s -race -count 1 -v github.com/cschleiden/go-workflows/backend/redis 2>&1 | go-junit-report -set-exit-code -iocopy -out "${{ github.workspace }}/report.xml"
81+
go test -timeout 240s -race -count 1 -v github.com/cschleiden/go-workflows/backend/redis 2>&1 | go tool go-junit-report -set-exit-code -iocopy -out "${{ github.workspace }}/report.xml"
6982
7083
- name: Test Summary
7184
uses: test-summary/action@v2
@@ -88,17 +101,13 @@ jobs:
88101
check-latest: true
89102
cache: true
90103

91-
- name: Install dependencies
92-
run: |
93-
go install github.com/jstemmer/go-junit-report/v2@latest
94-
95104
- name: Tests (sqlite)
96105
run: |
97-
go test -timeout 240s -race -count 1 -v github.com/cschleiden/go-workflows/backend/sqlite 2>&1 | go-junit-report -set-exit-code -iocopy -out "${{ github.workspace }}/report.xml"
106+
go test -timeout 240s -race -count 1 -v github.com/cschleiden/go-workflows/backend/sqlite 2>&1 | go tool go-junit-report -set-exit-code -iocopy -out "${{ github.workspace }}/report.xml"
98107
99108
- name: Tests (monoprocess backend)
100109
run: |
101-
go test -timeout 240s -race -count 1 -v github.com/cschleiden/go-workflows/backend/monoprocess 2>&1 | go-junit-report -set-exit-code -iocopy -out "${{ github.workspace }}/report.xml"
110+
go test -timeout 240s -race -count 1 -v github.com/cschleiden/go-workflows/backend/monoprocess 2>&1 | go tool go-junit-report -set-exit-code -iocopy -out "${{ github.workspace }}/report.xml"
102111
103112
- name: Test Summary
104113
uses: test-summary/action@v2
@@ -126,8 +135,7 @@ jobs:
126135

127136
- name: Tests
128137
run: |
129-
go install github.com/jstemmer/go-junit-report/v2@latest
130-
go test -timeout 240s -race -count 1 -v github.com/cschleiden/go-workflows/backend/mysql 2>&1 | go-junit-report -set-exit-code -iocopy -out "${{ github.workspace }}/report.xml"
138+
go test -timeout 240s -race -count 1 -v github.com/cschleiden/go-workflows/backend/mysql 2>&1 | go tool go-junit-report -set-exit-code -iocopy -out "${{ github.workspace }}/report.xml"
131139
132140
- name: Test Summary
133141
uses: test-summary/action@v2

DEVELOPMENT.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,26 @@
22

33
1. `docker-compose up`
44

5+
## Build
6+
7+
```bash
8+
make build
9+
```
10+
11+
## Test
12+
13+
```bash
14+
make test
15+
```
16+
17+
## Lint
18+
19+
Install [golangci-lint](https://golangci-lint.run/usage/install/) and run
20+
21+
```bash
22+
make lint
23+
```
24+
525
### Use custom linter
626

727
1. Build analyzer `go build -tags analyzerplugin -buildmode=plugin analyzer/plugin/plugin.go`

Makefile

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# go-workflows Makefile
2+
3+
# Go parameters
4+
GOCMD=go
5+
GOBUILD=$(GOCMD) build
6+
GOCLEAN=$(GOCMD) clean
7+
GOTEST=$(GOCMD) test
8+
GOGET=$(GOCMD) get
9+
GOMOD=$(GOCMD) mod
10+
GOFMT=gofmt
11+
GOLINT=golangci-lint
12+
13+
# Test parameters
14+
TEST_TIMEOUT=240s
15+
TEST_FLAGS=-race -count=1 -v
16+
TEST_SHORT_FLAGS=-short $(TEST_FLAGS)
17+
18+
# Build targets
19+
.PHONY: all build clean test test-integration test-redis test-mysql test-sqlite test-backends lint fmt
20+
21+
# Default target
22+
all: build test lint
23+
24+
# Build the main project
25+
build:
26+
@echo "Building go-workflows..."
27+
$(GOBUILD) -v ./...
28+
29+
# Run tests with short flag (excludes long-running tests)
30+
test:
31+
@echo "Running tests..."
32+
$(GOTEST) $(TEST_SHORT_FLAGS) -timeout $(TEST_TIMEOUT) ./...
33+
34+
# Run all tests
35+
test-integration:
36+
@echo "Running all tests..."
37+
$(GOTEST) $(TEST_FLAGS) -timeout $(TEST_TIMEOUT) ./...
38+
39+
# Run Redis backend tests
40+
test-redis:
41+
@echo "Running Redis backend tests..."
42+
$(GOTEST) $(TEST_FLAGS) -timeout $(TEST_TIMEOUT) github.com/cschleiden/go-workflows/backend/redis
43+
44+
# Run MySQL backend tests
45+
test-mysql:
46+
@echo "Running MySQL backend tests..."
47+
$(GOTEST) $(TEST_FLAGS) -timeout $(TEST_TIMEOUT) github.com/cschleiden/go-workflows/backend/mysql
48+
49+
# Run SQLite backend tests
50+
test-sqlite:
51+
@echo "Running SQLite backend tests..."
52+
$(GOTEST) $(TEST_FLAGS) -timeout $(TEST_TIMEOUT) github.com/cschleiden/go-workflows/backend/sqlite
53+
54+
# Run monoprocess backend tests
55+
test-monoprocess:
56+
@echo "Running monoprocess backend tests..."
57+
$(GOTEST) $(TEST_FLAGS) -timeout $(TEST_TIMEOUT) github.com/cschleiden/go-workflows/backend/monoprocess
58+
59+
# Run all backend tests
60+
test-backends: test-redis test-mysql test-sqlite test-monoprocess
61+
62+
# Lint the code
63+
lint:
64+
@echo "Checking if golangci-lint is installed..."
65+
@which $(GOLINT) > /dev/null || (echo "golangci-lint is not installed. Please install it first." && exit 1)
66+
@echo "Running linter..."
67+
$(GOLINT) run
68+
69+
# Format the code
70+
fmt:
71+
@echo "Formatting code..."
72+
$(GOFMT) -s -w .
73+
74+
# Clean build artifacts
75+
clean:
76+
@echo "Cleaning..."
77+
$(GOCLEAN)
78+
rm -f coverage.out coverage.html
79+
rm -f *.sqlite
80+
rm -f report.xml
81+

go.mod

Lines changed: 3 additions & 164 deletions
Original file line numberDiff line numberDiff line change
@@ -18,51 +18,20 @@ require (
1818
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.31.0
1919
go.opentelemetry.io/otel/trace v1.31.0
2020
go.uber.org/goleak v1.3.0
21-
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d
2221
modernc.org/sqlite v1.27.0
2322
)
2423

2524
require (
26-
4d63.com/gocheckcompilerdirectives v1.2.1 // indirect
27-
github.com/4meepo/tagalign v1.3.2 // indirect
28-
github.com/Abirdcfly/dupword v0.0.12 // indirect
29-
github.com/GaijinEntertainment/go-exhaustruct/v3 v3.1.0 // indirect
30-
github.com/OpenPeeDeeP/depguard/v2 v2.1.0 // indirect
31-
github.com/alexkohler/nakedret/v2 v2.0.2 // indirect
32-
github.com/alingse/asasalint v0.0.11 // indirect
33-
github.com/breml/bidichk v0.2.4 // indirect
34-
github.com/butuzov/mirror v1.1.0 // indirect
35-
github.com/ccojocar/zxcvbn-go v1.0.1 // indirect
36-
github.com/curioswitch/go-reassign v0.2.0 // indirect
3725
github.com/dustin/go-humanize v1.0.1 // indirect
38-
github.com/firefart/nonamedreturns v1.0.4 // indirect
39-
github.com/golangci/golangci-lint v1.54.2 // indirect
4026
github.com/grpc-ecosystem/grpc-gateway/v2 v2.22.0 // indirect
4127
github.com/jstemmer/go-junit-report/v2 v2.0.0-beta1 // indirect
4228
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
43-
github.com/kkHAIKE/contextcheck v1.1.4 // indirect
44-
github.com/lufeee/execinquery v1.2.1 // indirect
45-
github.com/maratori/testableexamples v1.0.0 // indirect
46-
github.com/nunnatsa/ginkgolinter v0.13.5 // indirect
47-
github.com/pelletier/go-toml/v2 v2.0.5 // indirect
48-
github.com/quasilyte/stdinfo v0.0.0-20220114132959-f7386bf02567 // indirect
29+
github.com/lib/pq v1.10.9 // indirect
4930
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
50-
github.com/sashamelentyev/interfacebloat v1.1.0 // indirect
51-
github.com/sashamelentyev/usestdlibvars v1.24.0 // indirect
52-
github.com/sivchari/nosnakecase v1.7.0 // indirect
53-
github.com/stbenjam/no-sprintf-host-port v0.1.1 // indirect
54-
github.com/t-yuki/gocover-cobertura v0.0.0-20180217150009-aaee18c8195c // indirect
55-
github.com/timonwong/loggercheck v0.9.4 // indirect
56-
github.com/xen0n/gosmopolitan v1.2.1 // indirect
57-
github.com/ykadowak/zerologlint v0.1.3 // indirect
5831
go.opentelemetry.io/otel/metric v1.31.0 // indirect
5932
go.opentelemetry.io/proto/otlp v1.3.1 // indirect
60-
go.tmz.dev/musttag v0.7.2 // indirect
6133
go.uber.org/atomic v1.7.0 // indirect
62-
go.uber.org/multierr v1.6.0 // indirect
63-
go.uber.org/zap v1.24.0 // indirect
64-
golang.org/x/exp v0.0.0-20230510235704-dd950f8aeaea // indirect
65-
golang.org/x/exp/typeparams v0.0.0-20230307190834-24139beb5833 // indirect
34+
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
6635
google.golang.org/genproto v0.0.0-20230306155012-7f2fa6fef1f4 // indirect
6736
google.golang.org/grpc v1.67.1 // indirect
6837
lukechampine.com/uint128 v1.2.0 // indirect
@@ -77,148 +46,21 @@ require (
7746
)
7847

7948
require (
80-
4d63.com/gochecknoglobals v0.2.1 // indirect
81-
github.com/Antonboom/errname v0.1.12 // indirect
82-
github.com/Antonboom/nilnil v0.1.7 // indirect
83-
github.com/BurntSushi/toml v1.3.2 // indirect
84-
github.com/Djarvur/go-err113 v0.0.0-20210108212216-aea10b59be24 // indirect
85-
github.com/Masterminds/semver v1.5.0 // indirect
86-
github.com/alexkohler/prealloc v1.0.0 // indirect
87-
github.com/ashanbrown/forbidigo v1.6.0 // indirect
88-
github.com/ashanbrown/makezero v1.1.1 // indirect
89-
github.com/beorn7/perks v1.0.1 // indirect
90-
github.com/bkielbasa/cyclop v1.2.1 // indirect
91-
github.com/blizzy78/varnamelen v0.8.0 // indirect
92-
github.com/bombsimon/wsl/v3 v3.4.0 // indirect; indirec
93-
github.com/breml/errchkjson v0.3.1 // indirect
94-
github.com/butuzov/ireturn v0.2.0 // indirect
9549
github.com/cenkalti/backoff/v4 v4.3.0
9650
github.com/cespare/xxhash/v2 v2.3.0 // indirect
97-
github.com/charithe/durationcheck v0.0.10 // indirect
98-
github.com/chavacava/garif v0.0.0-20230227094218-b8c73b2037b8 // indirect
99-
github.com/daixiang0/gci v0.11.0 // indirect
100-
github.com/denis-tingaikin/go-header v0.4.3 // indirect
10151
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
102-
github.com/esimonov/ifshort v1.0.4 // indirect
103-
github.com/ettle/strcase v0.1.1 // indirect
104-
github.com/fatih/color v1.15.0 // indirect
105-
github.com/fatih/structtag v1.2.0 // indirect
106-
github.com/fsnotify/fsnotify v1.5.4 // indirect
107-
github.com/fzipp/gocyclo v0.6.0 // indirect
108-
github.com/go-critic/go-critic v0.9.0 // indirect
10952
github.com/go-logr/logr v1.4.2 // indirect
11053
github.com/go-logr/stdr v1.2.2 // indirect
111-
github.com/go-toolsmith/astcast v1.1.0 // indirect
112-
github.com/go-toolsmith/astcopy v1.1.0 // indirect
113-
github.com/go-toolsmith/astequal v1.1.0 // indirect
114-
github.com/go-toolsmith/astfmt v1.1.0 // indirect
115-
github.com/go-toolsmith/astp v1.1.0 // indirect
116-
github.com/go-toolsmith/strparse v1.1.0 // indirect
117-
github.com/go-toolsmith/typep v1.1.0 // indirect
118-
github.com/go-xmlfmt/xmlfmt v1.1.2 // indirect
119-
github.com/gobwas/glob v0.2.3 // indirect
120-
github.com/gofrs/flock v0.8.1 // indirect
121-
github.com/golang/protobuf v1.5.3 // indirect
122-
github.com/golangci/check v0.0.0-20180506172741-cfe4005ccda2 // indirect
123-
github.com/golangci/dupl v0.0.0-20180902072040-3e9179ac440a // indirect
124-
github.com/golangci/go-misc v0.0.0-20220329215616-d24fe342adfe // indirect
125-
github.com/golangci/gofmt v0.0.0-20220901101216-f2edd75033f2 // indirect
126-
github.com/golangci/lint-1 v0.0.0-20191013205115-297bf364a8e0 // indirect
127-
github.com/golangci/maligned v0.0.0-20180506175553-b1d89398deca // indirect
128-
github.com/golangci/misspell v0.4.1 // indirect
129-
github.com/golangci/revgrep v0.0.0-20220804021717-745bb2f7c2e6 // indirect
130-
github.com/golangci/unconvert v0.0.0-20180507085042-28b1c447d1f4 // indirect
131-
github.com/google/go-cmp v0.6.0 // indirect
132-
github.com/gordonklaus/ineffassign v0.0.0-20230610083614-0e73809eb601 // indirect
133-
github.com/gostaticanalysis/analysisutil v0.7.1 // indirect
134-
github.com/gostaticanalysis/comment v1.4.2 // indirect
135-
github.com/gostaticanalysis/forcetypeassert v0.1.0 // indirect
136-
github.com/gostaticanalysis/nilerr v0.1.1 // indirect
13754
github.com/hashicorp/errwrap v1.1.0 // indirect
13855
github.com/hashicorp/go-multierror v1.1.1 // indirect
139-
github.com/hashicorp/go-version v1.6.0 // indirect
140-
github.com/hashicorp/hcl v1.0.0 // indirect
141-
github.com/hexops/gotextdiff v1.0.3 // indirect
142-
github.com/inconshreveable/mousetrap v1.1.0 // indirect
143-
github.com/jgautheron/goconst v1.5.1 // indirect
144-
github.com/jingyugao/rowserrcheck v1.1.1 // indirect
145-
github.com/jirfag/go-printf-func-name v0.0.0-20200119135958-7558a9eaa5af // indirect
146-
github.com/julz/importas v0.1.0 // indirect
147-
github.com/kisielk/errcheck v1.6.3 // indirect
148-
github.com/kisielk/gotool v1.0.0 // indirect
149-
github.com/kulti/thelper v0.6.3 // indirect
150-
github.com/kunwardeep/paralleltest v1.0.8 // indirect
151-
github.com/kyoh86/exportloopref v0.1.11 // indirect
152-
github.com/ldez/gomoddirectives v0.2.3 // indirect
153-
github.com/ldez/tagliatelle v0.5.0 // indirect
154-
github.com/leonklingele/grouper v1.1.1 // indirect
155-
github.com/magiconair/properties v1.8.6 // indirect
156-
github.com/maratori/testpackage v1.1.1 // indirect
157-
github.com/matoous/godox v0.0.0-20230222163458-006bad1f9d26 // indirect
158-
github.com/mattn/go-colorable v0.1.13 // indirect
15956
github.com/mattn/go-isatty v0.0.17 // indirect
160-
github.com/mattn/go-runewidth v0.0.9 // indirect
161-
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
162-
github.com/mbilski/exhaustivestruct v1.2.0 // indirect
163-
github.com/mgechev/revive v1.3.2 // indirect
164-
github.com/mitchellh/go-homedir v1.1.0 // indirect
165-
github.com/mitchellh/mapstructure v1.5.0 // indirect
166-
github.com/moricho/tparallel v0.3.1 // indirect
167-
github.com/nakabonne/nestif v0.3.1 // indirect
168-
github.com/nishanths/exhaustive v0.11.0 // indirect
169-
github.com/nishanths/predeclared v0.2.2 // indirect
170-
github.com/olekukonko/tablewriter v0.0.5 // indirect
171-
github.com/pelletier/go-toml v1.9.5 // indirect
172-
github.com/polyfloyd/go-errorlint v1.4.4 // indirect
173-
github.com/prometheus/client_golang v1.12.1 // indirect
174-
github.com/prometheus/client_model v0.2.0 // indirect
175-
github.com/prometheus/common v0.32.1 // indirect
176-
github.com/prometheus/procfs v0.7.3 // indirect
177-
github.com/quasilyte/go-ruleguard v0.4.0 // indirect
178-
github.com/quasilyte/gogrep v0.5.0 // indirect
179-
github.com/quasilyte/regex/syntax v0.0.0-20210819130434-b3f0c404a727 // indirect
180-
github.com/ryancurrah/gomodguard v1.3.0 // indirect
181-
github.com/ryanrolds/sqlclosecheck v0.4.0 // indirect
182-
github.com/sanposhiho/wastedassign/v2 v2.0.7 // indirect
183-
github.com/securego/gosec/v2 v2.17.0 // indirect
184-
github.com/shazow/go-diff v0.0.0-20160112020656-b6b7b6733b8c // indirect
18557
github.com/sirupsen/logrus v1.9.3 // indirect
186-
github.com/sivchari/containedctx v1.0.3 // indirect
187-
github.com/sivchari/tenv v1.7.1 // indirect
188-
github.com/sonatard/noctx v0.0.2 // indirect
189-
github.com/sourcegraph/go-diff v0.7.0 // indirect
190-
github.com/spf13/afero v1.8.2 // indirect
191-
github.com/spf13/cast v1.5.0 // indirect
192-
github.com/spf13/cobra v1.7.0 // indirect
193-
github.com/spf13/jwalterweatherman v1.1.0 // indirect
194-
github.com/spf13/pflag v1.0.5 // indirect
195-
github.com/spf13/viper v1.13.0 // indirect
196-
github.com/ssgreg/nlreturn/v2 v2.2.1 // indirect
197-
github.com/subosito/gotenv v1.4.1 // indirect
198-
github.com/tdakkota/asciicheck v0.2.0 // indirect
199-
github.com/tetafro/godot v1.4.14 // indirect
200-
github.com/timakin/bodyclose v0.0.0-20230421092635-574207250966 // indirect
201-
github.com/tomarrell/wrapcheck/v2 v2.8.1 // indirect
202-
github.com/tommy-muehle/go-mnd/v2 v2.5.1 // indirect
203-
github.com/ultraware/funlen v0.1.0 // indirect
204-
github.com/ultraware/whitespace v0.0.5 // indirect
205-
github.com/uudashr/gocognit v1.0.7 // indirect
206-
github.com/yagipy/maintidx v1.0.0 // indirect
207-
github.com/yeya24/promlinter v0.2.0 // indirect
208-
gitlab.com/bosi/decorder v0.4.0 // indirect
20958
golang.org/x/mod v0.17.0 // indirect
21059
golang.org/x/net v0.30.0 // indirect
21160
golang.org/x/sync v0.8.0 // indirect
21261
golang.org/x/sys v0.26.0 // indirect
21362
golang.org/x/text v0.19.0 // indirect
21463
google.golang.org/protobuf v1.35.1 // indirect
215-
gopkg.in/ini.v1 v1.67.0 // indirect
216-
gopkg.in/yaml.v2 v2.4.0 // indirect
217-
honnef.co/go/tools v0.4.5 // indirect
218-
mvdan.cc/gofumpt v0.5.0 // indirect
219-
mvdan.cc/interfacer v0.0.0-20180901003855-c20040233aed // indirect
220-
mvdan.cc/lint v0.0.0-20170908181259-adc824a0674b // indirect
221-
mvdan.cc/unparam v0.0.0-20221223090309-7455f1af531d // indirect
22264
)
22365

22466
require (
@@ -230,7 +72,4 @@ require (
23072
gopkg.in/yaml.v3 v3.0.1 // indirect
23173
)
23274

233-
tool (
234-
github.com/golangci/golangci-lint/cmd/golangci-lint
235-
github.com/jstemmer/go-junit-report/v2
236-
)
75+
tool github.com/jstemmer/go-junit-report/v2

0 commit comments

Comments
 (0)