Skip to content

Commit 7bcae0b

Browse files
committed
Add ctx caller name
1 parent 5f9d0ab commit 7bcae0b

19 files changed

+309
-102
lines changed

.github/workflows/bench.yml

Lines changed: 66 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -12,27 +12,43 @@ on:
1212
description: 'New Ref'
1313
required: true
1414

15+
# Cancel the workflow in progress in newer build is about to start.
16+
concurrency:
17+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
18+
cancel-in-progress: true
19+
1520
env:
1621
GO111MODULE: "on"
1722
CACHE_BENCHMARK: "off" # Enables benchmark result reuse between runs, may skew latency results.
1823
RUN_BASE_BENCHMARK: "on" # Runs benchmark for PR base in case benchmark result is missing.
24+
GO_VERSION: 1.23.x
1925
jobs:
2026
bench:
21-
strategy:
22-
matrix:
23-
go-version: [ 1.16.x ]
2427
runs-on: ubuntu-latest
2528
steps:
26-
- name: Install Go
27-
uses: actions/setup-go@v2
29+
- name: Install Go stable
30+
if: env.GO_VERSION != 'tip'
31+
uses: actions/setup-go@v4
2832
with:
29-
go-version: ${{ matrix.go-version }}
33+
go-version: ${{ env.GO_VERSION }}
34+
35+
- name: Install Go tip
36+
if: env.GO_VERSION == 'tip'
37+
run: |
38+
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
39+
ls -lah gotip.tar.gz
40+
mkdir -p ~/sdk/gotip
41+
tar -C ~/sdk/gotip -xzf gotip.tar.gz
42+
~/sdk/gotip/bin/go version
43+
echo "PATH=$HOME/go/bin:$HOME/sdk/gotip/bin/:$PATH" >> $GITHUB_ENV
44+
3045
- name: Checkout code
31-
uses: actions/checkout@v2
46+
uses: actions/checkout@v3
3247
with:
3348
ref: ${{ (github.event.inputs.new != '') && github.event.inputs.new || github.event.ref }}
49+
3450
- name: Go cache
35-
uses: actions/cache@v2
51+
uses: actions/cache@v3
3652
with:
3753
# In order:
3854
# * Module download cache
@@ -43,44 +59,58 @@ jobs:
4359
key: ${{ runner.os }}-go-cache-${{ hashFiles('**/go.sum') }}
4460
restore-keys: |
4561
${{ runner.os }}-go-cache
62+
4663
- name: Restore benchstat
47-
uses: actions/cache@v2
64+
uses: actions/cache@v3
4865
with:
4966
path: ~/go/bin/benchstat
50-
key: ${{ runner.os }}-benchstat
67+
key: ${{ runner.os }}-benchstat-legacy
68+
5169
- name: Restore base benchmark result
70+
id: base-benchmark
5271
if: env.CACHE_BENCHMARK == 'on'
53-
id: benchmark-base
54-
uses: actions/cache@v2
72+
uses: actions/cache@v3
5573
with:
5674
path: |
5775
bench-master.txt
5876
bench-main.txt
5977
# Use base sha for PR or new commit hash for master/main push in benchmark result key.
6078
key: ${{ runner.os }}-bench-${{ (github.event.pull_request.base.sha != github.event.after) && github.event.pull_request.base.sha || github.event.after }}
61-
- name: Checkout base code
62-
if: env.RUN_BASE_BENCHMARK == 'on' && steps.benchmark-base.outputs.cache-hit != 'true' && (github.event.pull_request.base.sha != '' || github.event.inputs.old != '')
63-
uses: actions/checkout@v2
64-
with:
65-
ref: ${{ (github.event.pull_request.base.sha != '' ) && github.event.pull_request.base.sha || github.event.inputs.old }}
66-
path: __base
67-
- name: Run base benchmark
68-
if: env.RUN_BASE_BENCHMARK == 'on' && steps.benchmark-base.outputs.cache-hit != 'true' && (github.event.pull_request.base.sha != '' || github.event.inputs.old != '')
79+
80+
- name: Run benchmark
81+
run: |
82+
export REF_NAME=new
83+
make bench
84+
OUTPUT=$(make bench-stat-diff)
85+
echo "${OUTPUT}"
86+
echo "diff<<EOF" >> $GITHUB_OUTPUT && echo "$OUTPUT" >> $GITHUB_OUTPUT && echo "EOF" >> $GITHUB_OUTPUT
87+
OUTPUT=$(make bench-stat)
88+
echo "${OUTPUT}"
89+
echo "result<<EOF" >> $GITHUB_OUTPUT && echo "$OUTPUT" >> $GITHUB_OUTPUT && echo "EOF" >> $GITHUB_OUTPUT
90+
91+
- name: Run benchmark for base code
92+
if: env.RUN_BASE_BENCHMARK == 'on' && steps.base-benchmark.outputs.cache-hit != 'true' && (github.event.pull_request.base.sha != '' || github.event.inputs.old != '')
6993
run: |
94+
git fetch origin master ${{ github.event.pull_request.base.sha }}
95+
HEAD=$(git rev-parse HEAD)
96+
git reset --hard ${{ github.event.pull_request.base.sha }}
7097
export REF_NAME=master
71-
cd __base
72-
make | grep bench-run && (BENCH_COUNT=5 make bench-run bench-stat && cp bench-master.txt ../bench-master.txt) || echo "No benchmarks in base"
73-
- name: Benchmark
98+
make bench-run bench-stat
99+
git reset --hard $HEAD
100+
101+
- name: Benchmark stats
74102
id: bench
75103
run: |
76104
export REF_NAME=new
77-
BENCH_COUNT=5 make bench-run bench-stat
105+
OUTPUT=$(make bench-stat-diff)
106+
echo "${OUTPUT}"
107+
echo "diff<<EOF" >> $GITHUB_OUTPUT && echo "$OUTPUT" >> $GITHUB_OUTPUT && echo "EOF" >> $GITHUB_OUTPUT
78108
OUTPUT=$(make bench-stat)
79-
OUTPUT="${OUTPUT//'%'/'%25'}"
80-
OUTPUT="${OUTPUT//$'\n'/'%0A'}"
81-
OUTPUT="${OUTPUT//$'\r'/'%0D'}"
82-
echo "::set-output name=result::$OUTPUT"
83-
- name: Comment Benchmark Result
109+
echo "${OUTPUT}"
110+
echo "result<<EOF" >> $GITHUB_OUTPUT && echo "$OUTPUT" >> $GITHUB_OUTPUT && echo "EOF" >> $GITHUB_OUTPUT
111+
112+
- name: Comment benchmark result
113+
continue-on-error: true
84114
uses: marocchino/sticky-pull-request-comment@v2
85115
with:
86116
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -89,6 +119,13 @@ jobs:
89119
### Benchmark Result
90120
<details><summary>Benchmark diff with base branch</summary>
91121
122+
```
123+
${{ steps.bench.outputs.diff }}
124+
```
125+
</details>
126+
127+
<details><summary>Benchmark result</summary>
128+
92129
```
93130
${{ steps.bench.outputs.result }}
94131
```

.github/workflows/cloc.yml

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,37 @@
22
name: cloc
33
on:
44
pull_request:
5+
6+
# Cancel the workflow in progress in newer build is about to start.
7+
concurrency:
8+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
9+
cancel-in-progress: true
10+
511
jobs:
612
cloc:
713
runs-on: ubuntu-latest
814
steps:
915
- name: Checkout code
10-
uses: actions/checkout@v2
16+
uses: actions/checkout@v3
1117
with:
1218
path: pr
1319
- name: Checkout base code
14-
uses: actions/checkout@v2
20+
uses: actions/checkout@v3
1521
with:
1622
ref: ${{ github.event.pull_request.base.sha }}
1723
path: base
18-
- name: Count Lines Of Code
24+
- name: Count lines of code
1925
id: loc
2026
run: |
21-
curl -OL https://github.com/vearutop/sccdiff/releases/download/v1.0.1/linux_amd64.tar.gz && tar xf linux_amd64.tar.gz
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)
2230
OUTPUT=$(cd pr && ../sccdiff -basedir ../base)
23-
OUTPUT="${OUTPUT//'%'/'%25'}"
24-
OUTPUT="${OUTPUT//$'\n'/'%0A'}"
25-
OUTPUT="${OUTPUT//$'\r'/'%0D'}"
26-
echo "::set-output name=diff::$OUTPUT"
31+
echo "${OUTPUT}"
32+
echo "diff<<EOF" >> $GITHUB_OUTPUT && echo "$OUTPUT" >> $GITHUB_OUTPUT && echo "EOF" >> $GITHUB_OUTPUT
2733
28-
- name: Comment Code Lines
34+
- name: Comment lines of code
35+
continue-on-error: true
2936
uses: marocchino/sticky-pull-request-comment@v2
3037
with:
3138
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/golangci-lint.yml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,26 @@ on:
88
- master
99
- main
1010
pull_request:
11+
12+
# Cancel the workflow in progress in newer build is about to start.
13+
concurrency:
14+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
15+
cancel-in-progress: true
16+
1117
jobs:
1218
golangci:
1319
name: golangci-lint
1420
runs-on: ubuntu-latest
1521
steps:
22+
- uses: actions/setup-go@v3
23+
with:
24+
go-version: 1.23.x
1625
- uses: actions/checkout@v2
1726
- name: golangci-lint
18-
uses: golangci/golangci-lint-action@v2.5.2
27+
uses: golangci/golangci-lint-action@v6.1.0
1928
with:
2029
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
21-
version: v1.40.1
30+
version: v1.61.0
2231

2332
# Optional: working directory, useful for monorepos
2433
# working-directory: somedir

.github/workflows/gorelease.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# This script is provided by github.com/bool64/dev.
2+
name: gorelease
3+
on:
4+
pull_request:
5+
6+
# Cancel the workflow in progress in newer build is about to start.
7+
concurrency:
8+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
9+
cancel-in-progress: true
10+
11+
env:
12+
GO_VERSION: 1.23.x
13+
jobs:
14+
gorelease:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Install Go stable
18+
if: env.GO_VERSION != 'tip'
19+
uses: actions/setup-go@v4
20+
with:
21+
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
31+
- name: Checkout code
32+
uses: actions/checkout@v3
33+
- name: Gorelease cache
34+
uses: actions/cache@v3
35+
with:
36+
path: |
37+
~/go/bin/gorelease
38+
key: ${{ runner.os }}-gorelease-generic
39+
- name: Gorelease
40+
id: gorelease
41+
run: |
42+
test -e ~/go/bin/gorelease || go install golang.org/x/exp/cmd/gorelease@latest
43+
OUTPUT=$(gorelease 2>&1 || exit 0)
44+
echo "${OUTPUT}"
45+
echo "report<<EOF" >> $GITHUB_OUTPUT && echo "$OUTPUT" >> $GITHUB_OUTPUT && echo "EOF" >> $GITHUB_OUTPUT
46+
- name: Comment report
47+
continue-on-error: true
48+
uses: marocchino/sticky-pull-request-comment@v2
49+
with:
50+
header: gorelease
51+
message: |
52+
### Go API Changes
53+
54+
<pre>
55+
${{ steps.gorelease.outputs.report }}
56+
</pre>

0 commit comments

Comments
 (0)