Skip to content

Commit cfb9b8b

Browse files
authored
Add support for json.Number and uint64 (#5)
1 parent 7e7f50b commit cfb9b8b

File tree

10 files changed

+191
-111
lines changed

10 files changed

+191
-111
lines changed

.github/workflows/cloc.yml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,25 @@ jobs:
1313
runs-on: ubuntu-latest
1414
steps:
1515
- name: Checkout code
16-
uses: actions/checkout@v2
16+
uses: actions/checkout@v4
1717
with:
1818
path: pr
1919
- name: Checkout base code
20-
uses: actions/checkout@v2
20+
uses: actions/checkout@v4
2121
with:
2222
ref: ${{ github.event.pull_request.base.sha }}
2323
path: base
24-
- name: Count Lines Of Code
24+
- name: Count lines of code
2525
id: loc
2626
run: |
27-
curl -sLO https://github.com/vearutop/sccdiff/releases/download/v1.0.2/linux_amd64.tar.gz && tar xf linux_amd64.tar.gz && echo "b17e76bede22af0206b4918d3b3c4e7357f2a21b57f8de9e7c9dc0eb56b676c0 sccdiff" | shasum -c
27+
curl -sLO https://github.com/vearutop/sccdiff/releases/download/v1.0.3/linux_amd64.tar.gz && tar xf linux_amd64.tar.gz
28+
sccdiff_hash=$(git hash-object ./sccdiff)
29+
[ "$sccdiff_hash" == "ae8a07b687bd3dba60861584efe724351aa7ff63" ] || (echo "::error::unexpected hash for sccdiff, possible tampering: $sccdiff_hash" && exit 1)
2830
OUTPUT=$(cd pr && ../sccdiff -basedir ../base)
2931
echo "${OUTPUT}"
30-
OUTPUT="${OUTPUT//$'\n'/%0A}"
31-
echo "::set-output name=diff::$OUTPUT"
32+
echo "diff<<EOF" >> $GITHUB_OUTPUT && echo "$OUTPUT" >> $GITHUB_OUTPUT && echo "EOF" >> $GITHUB_OUTPUT
3233
33-
- name: Comment Code Lines
34+
- name: Comment lines of code
3435
continue-on-error: true
3536
uses: marocchino/sticky-pull-request-comment@v2
3637
with:

.github/workflows/golangci-lint.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@ jobs:
1919
name: golangci-lint
2020
runs-on: ubuntu-latest
2121
steps:
22-
- uses: actions/setup-go@v3
22+
- uses: actions/setup-go@v5
2323
with:
24-
go-version: 1.18.x
25-
- uses: actions/checkout@v2
24+
go-version: stable
25+
- uses: actions/checkout@v4
2626
- name: golangci-lint
27-
uses: golangci/golangci-lint-action@v3.1.0
27+
uses: golangci/golangci-lint-action@v8.0.0
2828
with:
2929
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
30-
version: v1.46.2
30+
version: v2.4.0
3131

3232
# Optional: working directory, useful for monorepos
3333
# working-directory: somedir

.github/workflows/gorelease.yml

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,29 +9,19 @@ concurrency:
99
cancel-in-progress: true
1010

1111
env:
12-
GO_VERSION: 1.18.x
12+
GO_VERSION: stable
1313
jobs:
1414
gorelease:
1515
runs-on: ubuntu-latest
1616
steps:
17-
- name: Install Go stable
18-
if: env.GO_VERSION != 'tip'
19-
uses: actions/setup-go@v3
17+
- name: Install Go
18+
uses: actions/setup-go@v5
2019
with:
2120
go-version: ${{ env.GO_VERSION }}
22-
- name: Install Go tip
23-
if: env.GO_VERSION == 'tip'
24-
run: |
25-
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
26-
ls -lah gotip.tar.gz
27-
mkdir -p ~/sdk/gotip
28-
tar -C ~/sdk/gotip -xzf gotip.tar.gz
29-
~/sdk/gotip/bin/go version
30-
echo "PATH=$HOME/go/bin:$HOME/sdk/gotip/bin/:$PATH" >> $GITHUB_ENV
3121
- name: Checkout code
32-
uses: actions/checkout@v2
22+
uses: actions/checkout@v4
3323
- name: Gorelease cache
34-
uses: actions/cache@v2
24+
uses: actions/cache@v4
3525
with:
3626
path: |
3727
~/go/bin/gorelease
@@ -42,9 +32,8 @@ jobs:
4232
test -e ~/go/bin/gorelease || go install golang.org/x/exp/cmd/gorelease@latest
4333
OUTPUT=$(gorelease 2>&1 || exit 0)
4434
echo "${OUTPUT}"
45-
OUTPUT="${OUTPUT//$'\n'/%0A}"
46-
echo "::set-output name=report::$OUTPUT"
47-
- name: Comment Report
35+
echo "report<<EOF" >> $GITHUB_OUTPUT && echo "$OUTPUT" >> $GITHUB_OUTPUT && echo "EOF" >> $GITHUB_OUTPUT
36+
- name: Comment report
4837
continue-on-error: true
4938
uses: marocchino/sticky-pull-request-comment@v2
5039
with:

.github/workflows/test-unit.yml

Lines changed: 21 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -15,36 +15,25 @@ concurrency:
1515
env:
1616
GO111MODULE: "on"
1717
RUN_BASE_COVERAGE: "on" # Runs test for PR base in case base test coverage is missing.
18-
COV_GO_VERSION: 1.18.x # Version of Go to collect coverage
18+
COV_GO_VERSION: stable # Version of Go to collect coverage
1919
TARGET_DELTA_COV: 90 # Target coverage of changed lines, in percents
2020
jobs:
2121
test:
2222
strategy:
2323
matrix:
24-
go-version: [ 1.16.x, 1.17.x, 1.18.x ]
24+
go-version: [ 1.16.x, stable, oldstable ]
2525
runs-on: ubuntu-latest
2626
steps:
27-
- name: Install Go stable
28-
if: matrix.go-version != 'tip'
29-
uses: actions/setup-go@v3
27+
- name: Install Go
28+
uses: actions/setup-go@v5
3029
with:
3130
go-version: ${{ matrix.go-version }}
3231

33-
- name: Install Go tip
34-
if: matrix.go-version == 'tip'
35-
run: |
36-
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
37-
ls -lah gotip.tar.gz
38-
mkdir -p ~/sdk/gotip
39-
tar -C ~/sdk/gotip -xzf gotip.tar.gz
40-
~/sdk/gotip/bin/go version
41-
echo "PATH=$HOME/go/bin:$HOME/sdk/gotip/bin/:$PATH" >> $GITHUB_ENV
42-
4332
- name: Checkout code
44-
uses: actions/checkout@v2
33+
uses: actions/checkout@v4
4534

4635
- name: Go cache
47-
uses: actions/cache@v2
36+
uses: actions/cache@v4
4837
with:
4938
# In order:
5039
# * Module download cache
@@ -59,7 +48,7 @@ jobs:
5948
- name: Restore base test coverage
6049
id: base-coverage
6150
if: matrix.go-version == env.COV_GO_VERSION && github.event.pull_request.base.sha != ''
62-
uses: actions/cache@v2
51+
uses: actions/cache@v4
6352
with:
6453
path: |
6554
unit-base.txt
@@ -82,26 +71,27 @@ jobs:
8271
go tool cover -func=./unit.coverprofile > unit.txt
8372
TOTAL=$(grep 'total:' unit.txt)
8473
echo "${TOTAL}"
85-
echo "::set-output name=total::$TOTAL"
74+
echo "total=$TOTAL" >> $GITHUB_OUTPUT
8675
8776
- name: Annotate missing test coverage
8877
id: annotate
8978
if: matrix.go-version == env.COV_GO_VERSION && github.event.pull_request.base.sha != ''
9079
run: |
91-
git fetch origin master ${{ github.event.pull_request.base.sha }}
92-
curl -sLO https://github.com/vearutop/gocovdiff/releases/download/v1.3.4/linux_amd64.tar.gz && tar xf linux_amd64.tar.gz && shasum -a 256 gocovdiff && echo "b351c67526eefeb0671c82e9271ae984875865eed19e911f40f78348cb98347c gocovdiff" | shasum -c
93-
REP=$(./gocovdiff -cov unit.coverprofile -gha-annotations gha-unit.txt -delta-cov-file delta-cov-unit.txt -target-delta-cov ${TARGET_DELTA_COV})
80+
curl -sLO https://github.com/vearutop/gocovdiff/releases/download/v1.4.2/linux_amd64.tar.gz && tar xf linux_amd64.tar.gz && rm linux_amd64.tar.gz
81+
gocovdiff_hash=$(git hash-object ./gocovdiff)
82+
[ "$gocovdiff_hash" == "c37862c73a677e5a9c069470287823ab5bbf0244" ] || (echo "::error::unexpected hash for gocovdiff, possible tampering: $gocovdiff_hash" && exit 1)
83+
# Fetch PR diff from GitHub API.
84+
curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -H "Accept: application/vnd.github.v3.diff" https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }} > pull_request.diff
85+
REP=$(./gocovdiff -diff pull_request.diff -mod github.com/$GITHUB_REPOSITORY -cov unit.coverprofile -gha-annotations gha-unit.txt -delta-cov-file delta-cov-unit.txt -target-delta-cov ${TARGET_DELTA_COV})
9486
echo "${REP}"
95-
REP="${REP//$'\n'/%0A}"
9687
cat gha-unit.txt
97-
DIFF=$(test -e unit-base.txt && ./gocovdiff -func-cov unit.txt -func-base-cov unit-base.txt || echo "Missing base coverage file")
98-
DIFF="${DIFF//$'\n'/%0A}"
88+
DIFF=$(test -e unit-base.txt && ./gocovdiff -mod github.com/$GITHUB_REPOSITORY -func-cov unit.txt -func-base-cov unit-base.txt || echo "Missing base coverage file")
9989
TOTAL=$(cat delta-cov-unit.txt)
100-
echo "::set-output name=rep::$REP"
101-
echo "::set-output name=diff::$DIFF"
102-
echo "::set-output name=total::$TOTAL"
90+
echo "rep<<EOF" >> $GITHUB_OUTPUT && echo "$REP" >> $GITHUB_OUTPUT && echo "EOF" >> $GITHUB_OUTPUT
91+
echo "diff<<EOF" >> $GITHUB_OUTPUT && echo "$DIFF" >> $GITHUB_OUTPUT && echo "EOF" >> $GITHUB_OUTPUT
92+
echo "total<<EOF" >> $GITHUB_OUTPUT && echo "$TOTAL" >> $GITHUB_OUTPUT && echo "EOF" >> $GITHUB_OUTPUT
10393
104-
- name: Comment Test Coverage
94+
- name: Comment test coverage
10595
continue-on-error: true
10696
if: matrix.go-version == env.COV_GO_VERSION && github.event.pull_request.base.sha != ''
10797
uses: marocchino/sticky-pull-request-comment@v2
@@ -130,7 +120,7 @@ jobs:
130120

131121
- name: Upload code coverage
132122
if: matrix.go-version == env.COV_GO_VERSION
133-
uses: codecov/codecov-action@v1
123+
uses: codecov/codecov-action@v5
134124
with:
135-
file: ./unit.coverprofile
125+
files: ./unit.coverprofile
136126
flags: unittests

.golangci.yml

Lines changed: 71 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,79 @@
1-
# See https://github.com/golangci/golangci-lint/blob/master/.golangci.example.yml
1+
# See https://golangci-lint.run/docs/linters/configuration/
2+
version: "2"
23
run:
34
tests: true
4-
5-
linters-settings:
6-
errcheck:
7-
check-type-assertions: true
8-
check-blank: true
9-
gocyclo:
10-
min-complexity: 20
11-
dupl:
12-
threshold: 100
13-
misspell:
14-
locale: US
15-
unused:
16-
check-exported: false
17-
unparam:
18-
check-exported: true
19-
205
linters:
21-
enable-all: true
6+
default: all
227
disable:
23-
- lll
24-
- maligned
25-
- gochecknoglobals
26-
- gomnd
27-
- wrapcheck
28-
- paralleltest
8+
- noinlineerr
9+
- wsl_v5
10+
- funcorder
11+
- copyloopvar
12+
- depguard
13+
- dupword
14+
- errname
15+
- exhaustruct
2916
- forbidigo
30-
- exhaustivestruct
31-
- interfacer # deprecated
3217
- forcetypeassert
33-
- scopelint # deprecated
34-
- ifshort # too many false positives
35-
- golint # deprecated
36-
- varnamelen
37-
- tagliatelle
38-
- errname
18+
- gochecknoglobals
19+
- intrange
3920
- ireturn
40-
- exhaustruct
21+
- lll
22+
- mnd
4123
- nonamedreturns
42-
43-
issues:
44-
exclude-use-default: false
45-
exclude-rules:
46-
- linters:
47-
- gomnd
48-
- goconst
49-
- goerr113
50-
- noctx
51-
- funlen
52-
- dupl
53-
path: "_test.go"
54-
24+
- paralleltest
25+
- recvcheck
26+
- tagalign
27+
- tagliatelle
28+
- testableexamples
29+
- testifylint
30+
- varnamelen
31+
- wrapcheck
32+
settings:
33+
dupl:
34+
threshold: 100
35+
errcheck:
36+
check-type-assertions: true
37+
check-blank: true
38+
gocyclo:
39+
min-complexity: 20
40+
misspell:
41+
locale: US
42+
unparam:
43+
check-exported: true
44+
exclusions:
45+
generated: lax
46+
rules:
47+
- linters:
48+
- gosec
49+
- dupl
50+
- funlen
51+
- goconst
52+
- mnd
53+
- noctx
54+
- unparam
55+
- unused
56+
path: _test.go
57+
- linters:
58+
- errcheck
59+
- gosec
60+
path: example_
61+
- linters:
62+
- revive
63+
text: 'unused-parameter: parameter'
64+
paths:
65+
- third_party$
66+
- builtin$
67+
- examples$
68+
formatters:
69+
enable:
70+
- gci
71+
- gofmt
72+
- gofumpt
73+
- goimports
74+
exclusions:
75+
generated: lax
76+
paths:
77+
- third_party$
78+
- builtin$
79+
- examples$

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#GOLANGCI_LINT_VERSION := "v1.46.2" # Optional configuration to pinpoint golangci-lint version.
1+
#GOLANGCI_LINT_VERSION := "v2.5.0" # Optional configuration to pinpoint golangci-lint version.
22

33
# The head of Makefile determines location of dev-go to include standard targets.
44
GO ?= go

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module github.com/bool64/shared
33
go 1.17
44

55
require (
6-
github.com/bool64/dev v0.2.17
6+
github.com/bool64/dev v0.2.43
77
github.com/stretchr/testify v1.4.0
88
)
99

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
github.com/bool64/dev v0.2.17 h1:jE+T92oazAIV8fvMDJrKjsF1bzfr5XezZ8bM5GS1Cl0=
2-
github.com/bool64/dev v0.2.17/go.mod h1:iJbh1y/HkunEPhgebWRNcs8wfGq7sjvJ6W5iabL8ACg=
1+
github.com/bool64/dev v0.2.43 h1:yQ7qiZVef6WtCl2vDYU0Y+qSq+0aBrQzY8KXkklk9cQ=
2+
github.com/bool64/dev v0.2.43/go.mod h1:iJbh1y/HkunEPhgebWRNcs8wfGq7sjvJ6W5iabL8ACg=
33
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
44
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
55
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=

0 commit comments

Comments
 (0)