Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use tparse #845

Merged
merged 2 commits into from
Nov 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,9 @@ updates:
schedule:
interval: "daily"
target-branch: "develop/v1"
- package-echosystem: "github-acitons"
directory: "/"
schedule:
interval: "daily"
target-branch: "develop/v2"

4 changes: 3 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
go_tags: [ 'stdlib', 'goccy', 'es256k', 'all']
go_tags: [ 'stdlib', 'goccy', 'es256k', 'alltags']
go: [ '1.19', '1.18', '1.17' ]
name: "Test [ Go ${{ matrix.go }} / Tags ${{ matrix.go_tags }} ]"
steps:
Expand Down Expand Up @@ -42,6 +42,8 @@ jobs:
echo "::add-path::$(go env GOPATH)/bin"
- name: Install stringer
run: go install golang.org/x/tools/cmd/stringer@latest
- name: Install tparse
run: go install github.com/mfridman/tparse@latest
- name: Install jose
run: sudo apt-get install -y --no-install-recommends jose
- run: make generate
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/smoke.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
go_tags: [ 'stdlib', 'goccy', 'es256k', 'all' ]
go_tags: [ 'stdlib', 'goccy', 'es256k', 'alltags' ]
go: [ '1.19', '1.18', '1.17' ]
name: "Smoke [ Go ${{ matrix.go }} / Tags ${{ matrix.go_tags }} ]"
steps:
Expand All @@ -38,6 +38,8 @@ jobs:
check-latest: true
- name: Install stringer
run: go install golang.org/x/tools/cmd/stringer@latest
- name: Install tparse
run: go install github.com/mfridman/tparse@latest
- name: Install jose
run: sudo apt-get install -y --no-install-recommends jose
- run: make generate
Expand Down
52 changes: 26 additions & 26 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,58 +11,58 @@ realclean:
rm coverage.out

test-cmd:
go test -v -race $(TESTOPTS)
env TESTOPTS="$(TESTOPTS)" ./tools/test.sh

test:
$(MAKE) TESTOPTS=./... test-cmd
$(MAKE) -f $(PWD)/Makefile -C examples test-cmd
$(MAKE) -f $(PWD)/Makefile -C bench/performance test-cmd
$(MAKE) test-stdlib TESTOPTS=

test-stdlib:
$(MAKE) test-cmd TESTOPTS=

test-goccy:
$(MAKE) test-cmd TESTOPTS="-tags jwx_goccy"

test-es256k:
$(MAKE) test-cmd TESTOPTS="-tags jwx_es256k"

test-alltags:
$(MAKE) test-cmd TESTOPTS="-tags jwx_goccy,jwx_es256k"

cover-cmd:
$(MAKE) test-cmd
$(MAKE) -f $(PWD)/Makefile -C examples TESTOPTS= test-cmd
$(MAKE) -f $(PWD)/Makefile -C bench/performance TESTOPTS= test-cmd
$(MAKE) -f $(PWD)/Makefile -C cmd/jwx TESTOPTS= test-cmd
@# This is NOT cheating. tools to generate code, and tools to
@# run tests don't need to be included in the final result.
@cat coverage.out.tmp | grep -v "internal/jose" | grep -v "internal/jwxtest" | grep -v "internal/cmd" > coverage.out
@rm coverage.out.tmp
env MODE=cover ./tools/test.sh

cover:
$(MAKE) cover-stdlib

cover-stdlib:
$(MAKE) cover-cmd TESTOPTS="-coverpkg=./... -coverprofile=coverage.out.tmp ./..."
$(MAKE) cover-cmd TESTOPTS=

cover-goccy:
$(MAKE) cover-cmd TESTOPTS="-tags jwx_goccy -coverpkg=./... -coverprofile=coverage.out.tmp ./..."
$(MAKE) cover-cmd TESTOPTS="-tags jwx_goccy"

cover-es256k:
$(MAKE) cover-cmd TESTOPTS="-tags jwx_es256k -coverpkg=./... -coverprofile=coverage.out.tmp ./..."
$(MAKE) cover-cmd TESTOPTS="-tags jwx_es256k"

cover-all:
$(MAKE) cover-cmd TESTOPTS="-tags jwx_goccy,jwx_es256k -coverpkg=./... -coverprofile=coverage.out.tmp ./..."
cover-alltags:
$(MAKE) cover-cmd TESTOPTS="-tags jwx_goccy,jwx_es256k"

smoke-cmd:
$(MAKE) test-cmd
$(MAKE) -f $(PWD)/Makefile -C examples test-cmd
$(MAKE) -f $(PWD)/Makefile -C bench/performance test-cmd
$(MAKE) -f $(PWD)/Makefile -C cmd/jwx test-cmd
env MODE=short ./tools/test.sh

smoke:
$(MAKE) smoke-stdlib

smoke-stdlib:
$(MAKE) smoke-cmd TESTOPTS="-short ./..."
$(MAKE) smoke-cmd TESTOPTS=

smoke-goccy:
$(MAKE) smoke-cmd TESTOPTS="-short -tags jwx_goccy ./..."
$(MAKE) smoke-cmd TESTOPTS="-tags jwx_goccy"

smoke-es256k:
$(MAKE) smoke-cmd TESTOPTS="-short -tags jwx_es256k ./..."
$(MAKE) smoke-cmd TESTOPTS="-tags jwx_es256k"

smoke-all:
$(MAKE) smoke-cmd TESTOPTS="-short -tags jwx_goccy,jwx_es256k ./..."
smoke-alltags:
$(MAKE) smoke-cmd TESTOPTS="-tags jwx_goccy,jwx_es256k"

viewcover:
go tool cover -html=coverage.out
Expand Down
31 changes: 31 additions & 0 deletions tools/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash

ROOT=$(cd $(dirname $0)/..; pwd -P)
DST="$ROOT/coverage.out"
if [[ -e "$DST" ]]; then
rm "$DST"
fi

testopts=($TESTOPTS)

tmpfile=coverage.out.tmp
case "$MODE" in
"cover")
testopts+=("-coverpkg=./...")
testopts+=("-coverprofile=$tmpfile")
;;
"short")
testopts+=("-short")
;;
esac

echo "mode: atomic" > "$DST"
for dir in . ./examples ./bench/performance ./cmd/jwx; do
pushd "$dir" > /dev/null
go test -race -json ${testopts[@]} ./... | tparse
if [[ -e "$tmpfile" ]]; then
cat "$tmpfile" | tail -n +2 | grep -v "internal/jose" | grep -v "internal/jwxtest" | grep -v "internal/cmd" >> "$DST"
rm "$tmpfile"
fi
popd > /dev/null
done