Skip to content

Commit b2731c3

Browse files
authored
Fix skip caller management (#2)
1 parent 16c5e05 commit b2731c3

File tree

10 files changed

+214
-154
lines changed

10 files changed

+214
-154
lines changed

.github/workflows/bench.yml

Lines changed: 40 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,25 @@
11
name: bench
22
on:
3-
push:
4-
tags:
5-
- v*
6-
branches:
7-
- master
8-
- main
93
pull_request:
4+
workflow_dispatch:
5+
inputs:
6+
old:
7+
description: 'Old Ref'
8+
required: false
9+
default: 'master'
10+
new:
11+
description: 'New Ref'
12+
required: true
13+
1014
env:
1115
GO111MODULE: "on"
16+
CACHE_BENCHMARK: "off" # Enables benchmark result reuse between runs, may skew latency results.
17+
RUN_BASE_BENCHMARK: "on" # Runs benchmark for PR base in case benchmark result is missing.
1218
jobs:
1319
bench:
1420
strategy:
1521
matrix:
16-
go-version: [ 1.15.x ]
22+
go-version: [ 1.16.x ]
1723
runs-on: ubuntu-latest
1824
steps:
1925
- name: Install Go
@@ -22,32 +28,52 @@ jobs:
2228
go-version: ${{ matrix.go-version }}
2329
- name: Checkout code
2430
uses: actions/checkout@v2
25-
- name: Restore vendor
31+
with:
32+
ref: ${{ (github.event.inputs.new != '') && github.event.inputs.new || github.event.ref }}
33+
- name: Go cache
2634
uses: actions/cache@v2
2735
with:
36+
# In order:
37+
# * Module download cache
38+
# * Build cache (Linux)
2839
path: |
29-
vendor
30-
key: ${{ runner.os }}-go${{ matrix.go-version }}-vendor-${{ hashFiles('**/go.mod') }}
31-
- name: Populate dependencies
32-
run: |
33-
(test -d vendor && echo vendor found) || (go mod vendor && du -sh vendor && du -sh ~/go/pkg/mod)
40+
~/go/pkg/mod
41+
~/.cache/go-build
42+
key: ${{ runner.os }}-go-cache-${{ hashFiles('**/go.sum') }}
43+
restore-keys: |
44+
${{ runner.os }}-go-cache
3445
- name: Restore benchstat
3546
uses: actions/cache@v2
3647
with:
3748
path: ~/go/bin/benchstat
3849
key: ${{ runner.os }}-benchstat
3950
- name: Restore base benchmark result
51+
if: env.CACHE_BENCHMARK == 'on'
52+
id: benchmark-base
4053
uses: actions/cache@v2
4154
with:
4255
path: |
4356
bench-master.txt
4457
bench-main.txt
4558
# Use base sha for PR or new commit hash for master/main push in benchmark result key.
4659
key: ${{ runner.os }}-bench-${{ (github.event.pull_request.base.sha != github.event.after) && github.event.pull_request.base.sha || github.event.after }}
60+
- name: Checkout base code
61+
if: env.RUN_BASE_BENCHMARK == 'on' && steps.benchmark-base.outputs.cache-hit != 'true' && (github.event.pull_request.base.sha != '' || github.event.inputs.old != '')
62+
uses: actions/checkout@v2
63+
with:
64+
ref: ${{ (github.event.pull_request.base.sha != '' ) && github.event.pull_request.base.sha || github.event.inputs.old }}
65+
path: __base
66+
- name: Run base benchmark
67+
if: env.RUN_BASE_BENCHMARK == 'on' && steps.benchmark-base.outputs.cache-hit != 'true' && (github.event.pull_request.base.sha != '' || github.event.inputs.old != '')
68+
run: |
69+
export REF_NAME=master
70+
cd __base
71+
BENCH_COUNT=5 make bench-run bench-stat
72+
cp bench-master.txt ../bench-master.txt
4773
- name: Benchmark
4874
id: bench
4975
run: |
50-
export REF_NAME=${GITHUB_REF##*/}
76+
export REF_NAME=new
5177
BENCH_COUNT=5 make bench-run bench-stat
5278
OUTPUT=$(make bench-stat)
5379
OUTPUT="${OUTPUT//'%'/'%25'}"

.github/workflows/golangci-lint.yml

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,25 @@ jobs:
1414
steps:
1515
- uses: actions/checkout@v2
1616
- name: golangci-lint
17-
uses: golangci/golangci-lint-action@v2.3.0
17+
uses: golangci/golangci-lint-action@v2.5.1
1818
with:
1919
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
20-
version: v1.35.2
20+
version: v1.38.0
21+
22+
# Optional: working directory, useful for monorepos
23+
# working-directory: somedir
2124

2225
# Optional: golangci-lint command line arguments.
23-
# args: ./the-only-dir-to-analyze/...
26+
# args: --issues-exit-code=0
27+
28+
# Optional: show only new issues if it's a pull request. The default value is `false`.
29+
# only-new-issues: true
30+
31+
# Optional: if set to true then the action will use pre-installed Go.
32+
# skip-go-installation: true
33+
34+
# Optional: if set to true then the action don't cache or restore ~/go/pkg.
35+
# skip-pkg-cache: true
2436

25-
# Required: the token is used for fetching a list of releases of golangci-lint.
26-
# The secret `GITHUB_TOKEN` is automatically created by GitHub,
27-
# no need to create it manually.
28-
# https://help.github.com/en/actions/configuring-and-managing-workflows/authenticating-with-the-github_token#about-the-github_token-secret
29-
github-token: ${{ secrets.GITHUB_TOKEN }}
37+
# Optional: if set to true then the action don't cache or restore ~/.cache/go-build.
38+
# skip-build-cache: true

.github/workflows/test-unit.yml

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@ on:
77
pull_request:
88
env:
99
GO111MODULE: "on"
10+
RUN_BASE_COVERAGE: "on" # Runs test for PR base in case base test coverage is missing.
1011
jobs:
1112
test:
1213
strategy:
1314
matrix:
14-
go-version: [ 1.13.x, 1.14.x, 1.15.x ]
15+
go-version: [ 1.13.x, 1.14.x, 1.15.x, 1.16.x ]
1516
runs-on: ubuntu-latest
1617
steps:
1718
- name: Install Go
@@ -20,22 +21,38 @@ jobs:
2021
go-version: ${{ matrix.go-version }}
2122
- name: Checkout code
2223
uses: actions/checkout@v2
24+
- name: Go cache
25+
uses: actions/cache@v2
26+
with:
27+
# In order:
28+
# * Module download cache
29+
# * Build cache (Linux)
30+
path: |
31+
~/go/pkg/mod
32+
~/.cache/go-build
33+
key: ${{ runner.os }}-go-cache-${{ hashFiles('**/go.sum') }}
34+
restore-keys: |
35+
${{ runner.os }}-go-cache
2336
- name: Restore base test coverage
37+
if: matrix.go-version == '1.16.x'
2438
uses: actions/cache@v2
2539
with:
2640
path: |
2741
unit-base.txt
2842
# Use base sha for PR or new commit hash for master/main push in test result key.
2943
key: ${{ runner.os }}-unit-test-coverage-${{ (github.event.pull_request.base.sha != github.event.after) && github.event.pull_request.base.sha || github.event.after }}
30-
- name: Restore vendor
31-
uses: actions/cache@v2
44+
- name: Checkout base code
45+
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 != ''
46+
uses: actions/checkout@v2
3247
with:
33-
path: |
34-
vendor
35-
key: ${{ runner.os }}-go${{ matrix.go-version }}-vendor-${{ hashFiles('**/go.mod') }}
36-
- name: Populate dependencies
48+
ref: ${{ github.event.pull_request.base.sha }}
49+
path: zapctxd
50+
- name: Run test for base code
51+
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 != ''
3752
run: |
38-
(test -d vendor && echo vendor found) || (go mod vendor && du -sh vendor && du -sh ~/go/pkg/mod)
53+
cd zapctxd
54+
make test-unit
55+
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
3956
- name: Test
4057
id: test
4158
run: |
@@ -52,7 +69,7 @@ jobs:
5269
if: ${{ github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' }}
5370
run: cp unit.txt unit-base.txt
5471
- name: Comment Test Coverage
55-
if: matrix.go-version == '1.15.x'
72+
if: matrix.go-version == '1.16.x'
5673
uses: marocchino/sticky-pull-request-comment@v2
5774
with:
5875
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -68,7 +85,7 @@ jobs:
6885
</details>
6986
7087
- name: Upload code coverage
71-
if: matrix.go-version == '1.15.x'
88+
if: matrix.go-version == '1.16.x'
7289
uses: codecov/codecov-action@v1
7390
with:
7491
file: ./unit.coverprofile

.golangci.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# See https://github.com/golangci/golangci-lint/blob/master/.golangci.example.yml
2+
run:
3+
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+
20+
linters:
21+
enable-all: true
22+
disable:
23+
- lll
24+
- maligned
25+
- gochecknoglobals
26+
- gomnd
27+
- wrapcheck
28+
- paralleltest
29+
- forbidigo
30+
- exhaustivestruct
31+
- interfacer
32+
- forcetypeassert
33+
- ifshort
34+
35+
issues:
36+
exclude-use-default: false
37+
exclude-rules:
38+
- linters:
39+
- gomnd
40+
- goconst
41+
- goerr113
42+
- noctx
43+
- funlen
44+
- dupl
45+
path: "_test.go"
46+

Makefile

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#GOLANGCI_LINT_VERSION := "v1.38.0" # Optional configuration to pinpoint golangci-lint version.
2+
13
# The head of Makefile determines location of dev-go to include standard targets.
24
GO ?= go
35
export GO111MODULE = on
@@ -26,12 +28,12 @@ ifeq ($(DEVGO_PATH),)
2628
endif
2729

2830
-include $(DEVGO_PATH)/makefiles/main.mk
29-
-include $(DEVGO_PATH)/makefiles/test-unit.mk
3031
-include $(DEVGO_PATH)/makefiles/lint.mk
32+
-include $(DEVGO_PATH)/makefiles/test-unit.mk
3133
-include $(DEVGO_PATH)/makefiles/bench.mk
32-
-include $(DEVGO_PATH)/makefiles/github-actions.mk
34+
-include $(DEVGO_PATH)/makefiles/reset-ci.mk
35+
36+
# Add your custom targets here.
3337

3438
## Run tests
3539
test: test-unit
36-
37-

dev_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
package zapctxd_test
22

3-
import _ "github.com/bool64/dev"
3+
import _ "github.com/bool64/dev" // Include CI/Dev scripts to project.

go.mod

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,8 @@ go 1.13
44

55
require (
66
github.com/bool64/ctxd v0.1.3
7-
github.com/bool64/dev v0.1.15
8-
github.com/fsnotify/fsnotify v1.4.9 // indirect
9-
github.com/golang/protobuf v1.4.3 // indirect
10-
github.com/google/go-cmp v0.5.2 // indirect
11-
github.com/kr/pretty v0.2.0 // indirect
12-
github.com/mattn/go-colorable v0.1.6 // indirect
13-
github.com/onsi/ginkgo v1.11.0 // indirect
14-
github.com/onsi/gomega v1.8.1 // indirect
15-
github.com/pkg/errors v0.9.1 // indirect
16-
github.com/stretchr/testify v1.6.1
17-
github.com/swaggest/assertjson v1.4.1
18-
go.uber.org/multierr v1.6.0 // indirect
7+
github.com/bool64/dev v0.1.25
8+
github.com/stretchr/testify v1.7.0
9+
github.com/swaggest/assertjson v1.6.4
1910
go.uber.org/zap v1.16.0
20-
golang.org/x/lint v0.0.0-20200302205851-738671d3881b // indirect
21-
golang.org/x/net v0.0.0-20201110031124-69a78807bb2b // indirect
22-
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68 // indirect
23-
golang.org/x/text v0.3.4 // indirect
24-
golang.org/x/tools v0.0.0-20201119191246-c0d5e8918928 // indirect
25-
google.golang.org/protobuf v1.25.0 // indirect
26-
honnef.co/go/tools v0.0.1-2020.1.4 // indirect
2711
)

0 commit comments

Comments
 (0)