Benchmark result
+
```
${{ steps.bench.outputs.result }}
```
diff --git a/.github/workflows/cloc.yml b/.github/workflows/cloc.yml
new file mode 100644
index 0000000..7002b22
--- /dev/null
+++ b/.github/workflows/cloc.yml
@@ -0,0 +1,36 @@
+# This script is provided by github.com/bool64/dev.
+name: cloc
+on:
+ pull_request:
+jobs:
+ cloc:
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout code
+ uses: actions/checkout@v2
+ with:
+ path: pr
+ - name: Checkout base code
+ uses: actions/checkout@v2
+ with:
+ ref: ${{ github.event.pull_request.base.sha }}
+ path: base
+ - name: Count Lines Of Code
+ id: loc
+ run: |
+ curl -sLO https://github.com/vearutop/sccdiff/releases/download/v1.0.1/linux_amd64.tar.gz && tar xf linux_amd64.tar.gz
+ OUTPUT=$(cd pr && ../sccdiff -basedir ../base)
+ echo "${OUTPUT}"
+ OUTPUT="${OUTPUT//$'\n'/%0A}"
+ echo "::set-output name=diff::$OUTPUT"
+
+ - name: Comment Code Lines
+ continue-on-error: true
+ uses: marocchino/sticky-pull-request-comment@v2
+ with:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ header: LOC
+ message: |
+ ### Lines Of Code
+
+ ${{ steps.loc.outputs.diff }}
diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml
index b51abbb..58c0ec6 100644
--- a/.github/workflows/golangci-lint.yml
+++ b/.github/workflows/golangci-lint.yml
@@ -1,3 +1,4 @@
+# This script is provided by github.com/bool64/dev.
name: lint
on:
push:
@@ -17,7 +18,7 @@ jobs:
uses: golangci/golangci-lint-action@v2.5.2
with:
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
- version: v1.39.0
+ version: v1.43.0
# Optional: working directory, useful for monorepos
# working-directory: somedir
diff --git a/.github/workflows/gorelease.yml b/.github/workflows/gorelease.yml
new file mode 100644
index 0000000..94c6966
--- /dev/null
+++ b/.github/workflows/gorelease.yml
@@ -0,0 +1,51 @@
+# This script is provided by github.com/bool64/dev.
+name: gorelease
+on:
+ pull_request:
+env:
+ GO_VERSION: 1.17.x
+jobs:
+ gorelease:
+ runs-on: ubuntu-latest
+ steps:
+ - name: Install Go stable
+ if: env.GO_VERSION != 'tip'
+ uses: actions/setup-go@v2
+ with:
+ go-version: ${{ env.GO_VERSION }}
+ - name: Install Go tip
+ if: env.GO_VERSION == 'tip'
+ run: |
+ curl -sL https://storage.googleapis.com/go-build-snap/go/linux-amd64/$(git ls-remote https://github.com/golang/go.git HEAD | awk '{print $1;}').tar.gz -o gotip.tar.gz
+ ls -lah gotip.tar.gz
+ mkdir -p ~/sdk/gotip
+ tar -C ~/sdk/gotip -xzf gotip.tar.gz
+ ~/sdk/gotip/bin/go version
+ echo "PATH=$HOME/go/bin:$HOME/sdk/gotip/bin/:$PATH" >> $GITHUB_ENV
+ - name: Checkout code
+ uses: actions/checkout@v2
+ - name: Gorelease cache
+ uses: actions/cache@v2
+ with:
+ path: |
+ ~/go/bin/gorelease
+ key: ${{ runner.os }}-gorelease
+ - name: Gorelease
+ id: gorelease
+ run: |
+ test -e ~/go/bin/gorelease || go install golang.org/x/exp/cmd/gorelease@latest
+ OUTPUT=$(gorelease || exit 0)
+ echo "${OUTPUT}"
+ OUTPUT="${OUTPUT//$'\n'/%0A}"
+ echo "::set-output name=report::$OUTPUT"
+ - name: Comment Report
+ continue-on-error: true
+ uses: marocchino/sticky-pull-request-comment@v2
+ with:
+ header: gorelease
+ message: |
+ ### Go API Changes
+
+
+ ${{ steps.gorelease.outputs.report }}
+
\ No newline at end of file
diff --git a/.github/workflows/test-unit.yml b/.github/workflows/test-unit.yml
index fa442d6..a90a1ae 100644
--- a/.github/workflows/test-unit.yml
+++ b/.github/workflows/test-unit.yml
@@ -1,3 +1,4 @@
+# This script is provided by github.com/bool64/dev.
name: test-unit
on:
push:
@@ -8,17 +9,28 @@ on:
env:
GO111MODULE: "on"
RUN_BASE_COVERAGE: "on" # Runs test for PR base in case base test coverage is missing.
+ COV_GO_VERSION: 1.17.x # Version of Go to collect coverage
jobs:
test:
strategy:
matrix:
- go-version: [ 1.13.x, 1.14.x, 1.15.x, 1.16.x ]
+ go-version: [ 1.13.x, 1.14.x, 1.15.x, 1.16.x, 1.17.x, tip ]
runs-on: ubuntu-latest
steps:
- - name: Install Go
+ - name: Install Go stable
+ if: matrix.go-version != 'tip'
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}
+ - name: Install Go tip
+ if: matrix.go-version == 'tip'
+ run: |
+ curl -sL https://storage.googleapis.com/go-build-snap/go/linux-amd64/$(git ls-remote https://github.com/golang/go.git HEAD | awk '{print $1;}').tar.gz -o gotip.tar.gz
+ ls -lah gotip.tar.gz
+ mkdir -p ~/sdk/gotip
+ tar -C ~/sdk/gotip -xzf gotip.tar.gz
+ ~/sdk/gotip/bin/go version
+ echo "PATH=$HOME/go/bin:$HOME/sdk/gotip/bin/:$PATH" >> $GITHUB_ENV
- name: Checkout code
uses: actions/checkout@v2
- name: Go cache
@@ -34,7 +46,8 @@ jobs:
restore-keys: |
${{ runner.os }}-go-cache
- name: Restore base test coverage
- if: matrix.go-version == '1.16.x'
+ id: base-coverage
+ if: matrix.go-version == env.COV_GO_VERSION
uses: actions/cache@v2
with:
path: |
@@ -42,13 +55,13 @@ jobs:
# Use base sha for PR or new commit hash for master/main push in test result key.
key: ${{ runner.os }}-unit-test-coverage-${{ (github.event.pull_request.base.sha != github.event.after) && github.event.pull_request.base.sha || github.event.after }}
- name: Checkout base code
- if: matrix.go-version == '1.16.x' && env.RUN_BASE_COVERAGE == 'on' && steps.benchmark-base.outputs.cache-hit != 'true' && github.event.pull_request.base.sha != ''
+ if: matrix.go-version == env.COV_GO_VERSION && env.RUN_BASE_COVERAGE == 'on' && steps.base-coverage.outputs.cache-hit != 'true' && github.event.pull_request.base.sha != ''
uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.base.sha }}
path: __base
- name: Run test for base code
- if: matrix.go-version == '1.16.x' && env.RUN_BASE_COVERAGE == 'on' && steps.benchmark-base.outputs.cache-hit != 'true' && github.event.pull_request.base.sha != ''
+ if: matrix.go-version == env.COV_GO_VERSION && env.RUN_BASE_COVERAGE == 'on' && steps.base-coverage.outputs.cache-hit != 'true' && github.event.pull_request.base.sha != ''
run: |
cd __base
make | grep test-unit && (make test-unit && go tool cover -func=./unit.coverprofile | sed -e 's/.go:[0-9]*:\t/.go\t/g' | sed -e 's/\t\t*/\t/g' > ../unit-base.txt) || echo "No test-unit in base"
@@ -58,17 +71,18 @@ jobs:
make test-unit
go tool cover -func=./unit.coverprofile | sed -e 's/.go:[0-9]*:\t/.go\t/g' | sed -e 's/\t\t*/\t/g' > unit.txt
OUTPUT=$(test -e unit-base.txt && (diff unit-base.txt unit.txt || exit 0) || cat unit.txt)
- OUTPUT="${OUTPUT//'%'/'%25'}"
- OUTPUT="${OUTPUT//$'\n'/'%0A'}"
- OUTPUT="${OUTPUT//$'\r'/'%0D'}"
+ echo "${OUTPUT}"
+ OUTPUT="${OUTPUT//$'\n'/%0A}"
TOTAL=$(grep 'total:' unit.txt)
+ echo "${TOTAL}"
echo "::set-output name=diff::$OUTPUT"
echo "::set-output name=total::$TOTAL"
- name: Store base coverage
if: ${{ github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' }}
run: cp unit.txt unit-base.txt
- name: Comment Test Coverage
- if: matrix.go-version == '1.16.x'
+ continue-on-error: true
+ if: matrix.go-version == env.COV_GO_VERSION
uses: marocchino/sticky-pull-request-comment@v2
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -84,7 +98,7 @@ jobs:
- name: Upload code coverage
- if: matrix.go-version == '1.16.x'
+ if: matrix.go-version == env.COV_GO_VERSION
uses: codecov/codecov-action@v1
with:
file: ./unit.coverprofile
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
deleted file mode 100644
index 735a690..0000000
--- a/.github/workflows/test.yml
+++ /dev/null
@@ -1,40 +0,0 @@
-name: test
-on:
- push:
- tags:
- - v*
- branches:
- - master
- - main
- pull_request:
-env:
- GO111MODULE: "on"
-jobs:
- test:
- strategy:
- matrix:
- go-version: [ 1.13.x, 1.14.x, 1.15.x ]
- runs-on: ubuntu-latest
- steps:
- - name: Install Go
- uses: actions/setup-go@v2
- with:
- go-version: ${{ matrix.go-version }}
- - name: Checkout code
- uses: actions/checkout@v2
- - name: Restore vendor
- uses: actions/cache@v2
- with:
- path: vendor
- key: ${{ runner.os }}-go-vendor-${{ hashFiles('**/go.mod') }}
- - name: Populate dependencies
- if: matrix.go-version == '1.15.x' # Use latest Go to populate vendor.
- run: '(test -d vendor && echo vendor found) || go mod vendor'
- - name: Test
- run: make test-unit
- - name: Upload code coverage
- if: matrix.go-version == '1.15.x'
- uses: codecov/codecov-action@v1
- with:
- file: ./unit.coverprofile
- flags: unittests
diff --git a/.golangci.yml b/.golangci.yml
index 3c4c317..97710e1 100644
--- a/.golangci.yml
+++ b/.golangci.yml
@@ -32,6 +32,11 @@ linters:
- forcetypeassert
- scopelint # deprecated
- ifshort # too many false positives
+ - golint # deprecated
+ - varnamelen
+ - tagliatelle
+ - errname
+ - ireturn
issues:
exclude-use-default: false
diff --git a/Makefile b/Makefile
index 44ea5c9..4b37b06 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-#GOLANGCI_LINT_VERSION := "v1.39.0" # Optional configuration to pinpoint golangci-lint version.
+#GOLANGCI_LINT_VERSION := "v1.43.0" # Optional configuration to pinpoint golangci-lint version.
# The head of Makefile determines location of dev-go to include standard targets.
GO ?= go
@@ -23,7 +23,7 @@ ifeq ($(DEVGO_PATH),)
DEVGO_PATH := $(shell GO111MODULE=on $(GO) list ${modVendor} -f '{{.Dir}}' -m github.com/bool64/dev)
ifeq ($(DEVGO_PATH),)
$(info Module github.com/bool64/dev not found, downloading.)
- DEVGO_PATH := $(shell export GO111MODULE=on && $(GO) mod tidy && $(GO) list -f '{{.Dir}}' -m github.com/bool64/dev)
+ DEVGO_PATH := $(shell export GO111MODULE=on && $(GO) get github.com/bool64/dev && $(GO) list -f '{{.Dir}}' -m github.com/bool64/dev)
endif
endif
diff --git a/go.mod b/go.mod
index 44375c5..1a21bd6 100644
--- a/go.mod
+++ b/go.mod
@@ -1,9 +1,15 @@
module github.com/bool64/ctxd
-go 1.13
+go 1.17
require (
- github.com/bool64/dev v0.1.28
- github.com/stretchr/testify v1.4.0
- github.com/swaggest/usecase v0.1.5
+ github.com/bool64/dev v0.2.5
+ github.com/stretchr/testify v1.7.0
+ github.com/swaggest/usecase v1.1.2
+)
+
+require (
+ github.com/davecgh/go-spew v1.1.0 // indirect
+ github.com/pmezard/go-difflib v1.0.0 // indirect
+ gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect
)
diff --git a/go.sum b/go.sum
index 272d181..3255b75 100644
--- a/go.sum
+++ b/go.sum
@@ -1,16 +1,17 @@
-github.com/bool64/dev v0.1.25/go.mod h1:cTHiTDNc8EewrQPy3p1obNilpMpdmlUesDkFTF2zRWU=
-github.com/bool64/dev v0.1.28 h1:bL7WI4kF5RzjzsQ+8wyWtqQkasw4m4q8l1Cz3CjShZE=
-github.com/bool64/dev v0.1.28/go.mod h1:cTHiTDNc8EewrQPy3p1obNilpMpdmlUesDkFTF2zRWU=
+github.com/bool64/dev v0.2.5 h1:H0bylghwcjDBBhEwSFTjArEO9Dr8cCaB54QSOF7esOA=
+github.com/bool64/dev v0.2.5/go.mod h1:cTHiTDNc8EewrQPy3p1obNilpMpdmlUesDkFTF2zRWU=
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
-github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
-github.com/swaggest/usecase v0.1.5 h1:xMDWXnYGysVaF2f3ZnmDsn2FlZ8fd3FJD+O+8wl4aNQ=
-github.com/swaggest/usecase v0.1.5/go.mod h1:uubX4ZbjQK1Bnl0xX9hOYpb/IUiSoVKk/yQImawbNMU=
+github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
+github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
+github.com/swaggest/usecase v1.1.2 h1:2LfuSyjYtPtpHnxqPwV87/eunbhGBC5HKdRp8/fINBk=
+github.com/swaggest/usecase v1.1.2/go.mod h1:abZWuMFYujaeLDODqRySJZpWD/ugsnE3Wj9K6jUeCjo=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
-gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
+gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
+gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=