Skip to content

Commit

Permalink
Merge pull request #24 from lainio/bench-tests
Browse files Browse the repository at this point in the history
Super Fast
  • Loading branch information
lainio authored Oct 11, 2024
2 parents 95c6e7a + 208c157 commit aa59314
Show file tree
Hide file tree
Showing 33 changed files with 2,068 additions and 820 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v3
uses: actions/setup-go@v5
with:
go-version: 1.19

Expand Down
16 changes: 8 additions & 8 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,39 +5,39 @@ jobs:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: golangci-lint
uses: golangci/golangci-lint-action@v2
uses: golangci/golangci-lint-action@v5
with:
version: latest
args: --timeout=5m
test:
strategy:
matrix:
go-version: [1.18.x, 1.19.x, 1.20.x, 1.21.x]
go-version: [1.18.x, 1.19.x, 1.20.x, 1.21.x, 1.22.x]
os: [windows-latest, ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- name: setup go
uses: actions/setup-go@v2
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
- name: checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: test
run: make test
test-cov:
runs-on: ubuntu-latest
steps:
- name: setup
uses: actions/setup-go@v2
uses: actions/setup-go@v5
with:
go-version: 1.19.x
- name: checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: test
run: make test_cov_out
- name: upload
uses: codecov/codecov-action@v2
uses: codecov/codecov-action@v4
with:
files: ./coverage.txt
5 changes: 0 additions & 5 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,7 @@ linters-settings:
# Default: 5
min-complexity: 8
gomnd:
settings:
mnd:
# don't include the "operation" and "assign"
checks: argument,case,condition,return
govet:
check-shadowing: true
lll:
line-length: 140
maligned:
Expand Down
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@

### Version history

##### 1.0.0
- **Finally! We are very happy, and thanks to all who have helped!**
- Lots of documentation updates and cleanups for version 1.0.0
- `Catch/Handle` take unlimited amount error handler functions
- allows building e.g. error handling middlewares
- this is major feature because it allows building helpers/add-ons
- automatic outputs aren't overwritten by given args, only with `assert.Plain`
- Minor API fixes to still simplify it:
- remove exported vars, obsolete types and funcs from `assert` pkg
- `Result2.Def2()` sets only `Val2`
- technical refactorings: variadic function calls only in API level

##### 0.9.52
- `err2.Stderr` helpers for `Catch/Handle` to direct auto-logging + snippets
- `assert` package `Shorter` `Longer` helpers for automatic messages
Expand Down
50 changes: 46 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ PKGS := $(PKG_ERR2) $(PKG_ASSERT) $(PKG_TRY) $(PKG_DEBUG) $(PKG_HANDLER) $(PKG_S

SRCDIRS := $(shell go list -f '{{.Dir}}' $(PKGS))

MAX_LINE ?= 80
GO ?= go
TEST_ARGS ?= -benchmem
# -"gcflags '-N -l'" both optimization & inlining disabled
Expand Down Expand Up @@ -61,9 +62,33 @@ inline_handler:
tinline_handler:
$(GO) test -c -gcflags=-m=2 $(PKG_HANDLER) 2>&1 | ag 'inlin'

inline_assert:
$(GO) test -c -gcflags=-m=2 $(PKG_ASSERT) 2>&1 | ag 'inlin'

bench:
$(GO) test $(TEST_ARGS) -bench=. $(PKGS)

bench_T:
$(GO) test $(TEST_ARGS) -bench='BenchmarkT_.*' $(PKG_ERR2)

bench_S:
$(GO) test $(TEST_ARGS) -bench='BenchmarkS.*' $(PKG_ASSERT)

bench_M:
$(GO) test $(TEST_ARGS) -bench='BenchmarkM.*' $(PKG_ASSERT)

bench_C:
$(GO) test $(TEST_ARGS) -bench='BenchmarkC.*' $(PKG_ASSERT)

bench_nil:
$(GO) test $(TEST_ARGS) -bench='Benchmark.*Nil' $(PKG_ASSERT)

bench_empty:
$(GO) test $(TEST_ARGS) -bench='Benchmark.*Empty' $(PKG_ASSERT)

bench_zero:
$(GO) test $(TEST_ARGS) -bench='BenchmarkZero.*' $(PKG_ASSERT)

bench_goid:
$(GO) test $(TEST_ARGS) -bench='BenchmarkGoid' $(PKG_ASSERT)

Expand All @@ -77,7 +102,7 @@ bench_go:
$(GO) test $(TEST_ARGS) -bench='BenchmarkTry_StringGenerics' $(PKG_ERR2)

bench_that:
$(GO) test $(TEST_ARGS) -bench='BenchmarkThat.*' $(PKG_ASSERT)
$(GO) test $(TEST_ARGS) -bench='Benchmark.*That.*' $(PKG_ASSERT)

bench_copy:
$(GO) test $(TEST_ARGS) -bench='Benchmark_CopyBuffer' $(PKG_TRY)
Expand Down Expand Up @@ -106,6 +131,14 @@ bench_x:
vet: | test
$(GO) vet $(PKGS)

fmt:
@echo "Pretty formatting with golines"
@golines -t 5 -w -m $(MAX_LINE) --ignore-generated .

dry-fmt:
@echo "--dry-run: Pretty formatting with golines"
@golines -t 5 --dry-run -m $(MAX_LINE) --ignore-generated .

gofmt:
@echo Checking code is gofmted
@test -z "$(shell gofmt -s -l -d -e $(SRCDIRS) | tee /dev/stderr)"
Expand All @@ -124,8 +157,17 @@ test_cov: test_cov_out
go tool cover -html=coverage.txt -o=coverage.html
firefox ./coverage.html 1>&- 2>&- &

lint:
@golangci-lint run
test_cov_pc_assert:
go tool cover -func=coverage.txt | ag assert

.PHONY: check
test_cov_zero: test_cov_out
go tool cover -func=coverage.txt | ag '\:\s*[A-Z]+.*\s+0\.0%'

test_cov_assert_zero: test_cov_out
go tool cover -func=coverage.txt | ag 'assert\/.*\:\s*[A-Z]+.*\s+0\.0%'

test_cov_pc:
go tool cover -func=coverage.txt

lint:
@golangci-lint run
Loading

0 comments on commit aa59314

Please sign in to comment.