Skip to content

Commit f229905

Browse files
committed
feat: update workflows and add makefile
1 parent c1ffcf6 commit f229905

File tree

5 files changed

+128
-17
lines changed

5 files changed

+128
-17
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ env:
88
jobs:
99
lint-build-test:
1010
name: Lint, Build & Test
11-
uses: devnw/workflows/.github/workflows/build.yml@main
11+
uses: devnw/workflows/.github/workflows/make-build.yml@main
1212
secrets: inherit # pragma: allowlist secret

.github/workflows/release.yml

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,32 +7,43 @@ on:
77

88
jobs:
99
build:
10-
name: "Build & Unit Tests"
10+
name: Make Build
1111
strategy:
1212
matrix:
13-
go-version: [1.19.x]
1413
platform: [ubuntu-latest, macos-latest, windows-latest]
1514
fail-fast: true
16-
runs-on: ${{ matrix.platform }}
1715
steps:
1816
- name: Checkout code
19-
uses: actions/checkout@v3
17+
uses: actions/checkout@v4
18+
2019
- name: Install Go
2120
uses: actions/setup-go@v4
2221
with:
23-
go-version: ${{ matrix.go-version }}
22+
go-version: ${{ vars.GO_VERSION }}
2423
stable: false
24+
2525
- name: Build
26-
run: go build ./...
27-
- name: Test
28-
run: go test -race -failfast ./...
26+
run: make build-ci
27+
28+
- name: Upload Test Coverage
29+
uses: actions/upload-artifact@v3
30+
with:
31+
name: coverage
32+
path: coverage.txt
33+
34+
- name: Upload Fuzz Results
35+
uses: actions/upload-artifact@v3
36+
with:
37+
name: fuzz-results
38+
path: testdata/fuzz
39+
2940
release:
3041
needs: [build]
3142
name: "Tagged Release"
3243
runs-on: "ubuntu-latest"
3344
steps:
3445
- name: Checkout code
35-
uses: actions/checkout@v3
46+
uses: actions/checkout@v4
3647
- name: Create Github Release from Tag
3748
uses: "marvinpinto/action-automatic-releases@latest"
3849
with:

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Removing Vendor
22
vendor/
3+
.venv
34

45
.vscode/
56

@@ -23,4 +24,6 @@ coverage.html
2324
*.pem
2425

2526
# ignore mac files
26-
.DS_Store
27+
.DS_Store
28+
coverage.txt
29+

.pre-commit-config.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ exclude: '^package.json|package-lock.json|.*?\.tsv$'
22
fail_fast: true
33
repos:
44
- repo: https://github.com/commitizen-tools/commitizen
5-
rev: v2.42.1
5+
rev: v3.14.1
66
hooks:
77
- id: commitizen
88
stages: [commit-msg]
@@ -14,7 +14,7 @@ repos:
1414
exclude: package.lock.json
1515
stages: [commit]
1616
- repo: https://github.com/golangci/golangci-lint
17-
rev: v1.52.2
17+
rev: v1.55.2
1818
hooks:
1919
- id: golangci-lint
2020
stages: [commit]
@@ -24,7 +24,7 @@ repos:
2424
- id: go-unit-tests
2525
stages: [commit]
2626
- repo: https://github.com/pre-commit/pre-commit-hooks
27-
rev: v4.4.0
27+
rev: v4.5.0
2828
hooks:
2929
- id: check-json
3030
stages: [commit]
@@ -39,18 +39,18 @@ repos:
3939
- id: check-yaml
4040
stages: [commit]
4141
- repo: https://github.com/igorshubovych/markdownlint-cli
42-
rev: v0.33.0
42+
rev: v0.39.0
4343
hooks:
4444
- id: markdownlint-fix
4545
stages: [commit]
4646
args: ["--ignore", "README.md"] # This is a generated file
4747
- repo: https://github.com/shellcheck-py/shellcheck-py
48-
rev: v0.9.0.2
48+
rev: v0.9.0.6
4949
hooks:
5050
- id: shellcheck
5151
stages: [commit]
5252
- repo: https://github.com/pre-commit/mirrors-eslint
53-
rev: 'v8.36.0'
53+
rev: 'v9.0.0-alpha.2'
5454
hooks:
5555
- id: eslint
5656
stages: [commit]

Makefile

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
all: build tidy lint fmt test
2+
3+
#-------------------------------------------------------------------------
4+
# Variables
5+
# ------------------------------------------------------------------------
6+
env=CGO_ENABLED=0
7+
8+
pyenv=.venv/bin
9+
10+
#-------------------------------------------------------------------------
11+
# Targets
12+
#-------------------------------------------------------------------------
13+
deps:
14+
python3 -m venv .venv
15+
16+
$(pyenv)/pip install --upgrade pre-commit
17+
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
18+
go install github.com/goreleaser/goreleaser@latest
19+
20+
test: lint
21+
CGO_ENABLED=1 go test -cover -failfast -race ./...
22+
23+
fuzz:
24+
@fuzzTime=$${FUZZ_TIME:-10}; \
25+
files=$$(grep -r --include='**_test.go' --files-with-matches 'func Fuzz' .); \
26+
for file in $$files; do \
27+
funcs=$$(grep -o 'func Fuzz\w*' $$file | sed 's/func //'); \
28+
for func in $$funcs; do \
29+
echo "Fuzzing $$func in $$file"; \
30+
parentDir=$$(dirname $$file); \
31+
go test $$parentDir -run=$$func -fuzz=$$func -fuzztime=$${fuzzTime}s; \
32+
if [ $$? -ne 0 ]; then \
33+
echo "Fuzzing $$func in $$file failed"; \
34+
exit 1; \
35+
fi; \
36+
done; \
37+
done
38+
39+
40+
41+
lint: tidy
42+
golangci-lint run
43+
$(pyenv)/pre-commit run --all-files
44+
45+
build: update upgrade tidy lint test
46+
$(env) go build ./...
47+
48+
release-dev: build-ci
49+
goreleaser release --rm-dist --snapshot
50+
51+
upgrade:
52+
$(pyenv)/pre-commit autoupdate
53+
go get -u ./...
54+
55+
update:
56+
git submodule update --recursive
57+
58+
fmt:
59+
gofmt -s -w .
60+
61+
tidy: fmt
62+
go mod tidy
63+
64+
clean:
65+
rm -rf dist
66+
rm -rf coverage
67+
68+
#-------------------------------------------------------------------------
69+
# CI targets
70+
#-------------------------------------------------------------------------
71+
test-ci: deps tidy lint
72+
CGO_ENABLED=1 go test \
73+
-cover \
74+
-covermode=atomic \
75+
-coverprofile=coverage.txt \
76+
-failfast \
77+
-race ./...
78+
make fuzz FUZZ_TIME=10
79+
80+
build-ci: test-ci
81+
$(env) go build ./...
82+
83+
84+
release-ci: build-ci
85+
goreleaser release --rm-dist
86+
87+
#-------------------------------------------------------------------------
88+
# Force targets
89+
#-------------------------------------------------------------------------
90+
91+
FORCE:
92+
93+
#-------------------------------------------------------------------------
94+
# Phony targets
95+
#-------------------------------------------------------------------------
96+
97+
.PHONY: build test lint fuzz

0 commit comments

Comments
 (0)