diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 3ded2b1a8..0de50ac2b 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -15,3 +15,9 @@ updates: schedule: interval: "daily" target-branch: "develop/v1" + - package-echosystem: "github-acitons" + directory: "/" + schedule: + interval: "daily" + target-branch: "develop/v2" + diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ac28e5f25..4fde71c6f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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: @@ -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 diff --git a/.github/workflows/smoke.yml b/.github/workflows/smoke.yml index 2ae686c7f..0598734ef 100644 --- a/.github/workflows/smoke.yml +++ b/.github/workflows/smoke.yml @@ -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: @@ -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 diff --git a/Makefile b/Makefile index 4b548b7ea..f3247b25e 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/tools/test.sh b/tools/test.sh new file mode 100755 index 000000000..b8236fab9 --- /dev/null +++ b/tools/test.sh @@ -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