Skip to content

Commit 9ae06de

Browse files
authored
Add issue templates, update bench CI task (#49)
1 parent 04c565b commit 9ae06de

File tree

11 files changed

+114
-43
lines changed

11 files changed

+114
-43
lines changed

makefiles/bench.mk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
GO ?= go
2-
BENCH_COUNT ?= 5
2+
BENCH_COUNT ?= 6
33
MASTER_BRANCH ?= master
44
REF_NAME ?= $(shell git symbolic-ref -q --short HEAD || git describe --tags --exact-match)
55
SHELL := /bin/bash
@@ -8,7 +8,7 @@ SHELL := /bin/bash
88
bench: bench-run bench-stat-diff bench-stat
99

1010
bench-stat-cli:
11-
@test -s $(GOPATH)/bin/benchstat || GOFLAGS= GOBIN=$(GOPATH)/bin $(GO) install golang.org/x/perf/cmd/benchstat@latest
11+
@test -s $(GOPATH)/bin/benchstat || GOFLAGS= GOBIN=$(GOPATH)/bin $(GO) install golang.org/x/perf/cmd/benchstat@a1b99499bab64a73929f3ed7c2103c28d30e9ac2
1212

1313
## Run benchmark, iterations count controlled by BENCH_COUNT, default 5.
1414
bench-run:

makefiles/github-actions.mk

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,12 @@ github-actions:
55
@mkdir -p $(PWD)/.github/workflows && (chmod +w $(PWD)/.github/workflows/*.yml || echo "could not chmod +w existing workflows") \
66
&& cp $(DEVGO_PATH)/templates/github/workflows/*.yml $(PWD)/.github/workflows/ \
77
&& chmod +w $(PWD)/.github/workflows/*.yml && git add $(PWD)/.github/workflows \
8+
&& mkdir -p $(PWD)/.github/ISSUE_TEMPLATE && (chmod +w $(PWD)/.github/ISSUE_TEMPLATE/*.md || echo "could not chmod +w existing issue templates") \
9+
&& cp $(DEVGO_PATH)/templates/github/ISSUE_TEMPLATE/*.md $(PWD)/.github/ISSUE_TEMPLATE/ \
10+
&& chmod +w $(PWD)/.github/ISSUE_TEMPLATE/*.md && git add $(PWD)/.github/ISSUE_TEMPLATE \
811
&& (test -z "$(BENCH_COUNT)" && rm $(PWD)/.github/workflows/bench.yml || echo "keeping bench.yml") \
912
&& (test -z "$(RELEASE_TARGETS)" && rm $(PWD)/.github/workflows/release-assets.yml || echo "keeping release-assets.yml") \
10-
&& (test -z "$(INTEGRATION_TEST_TARGET)" && rm $(PWD)/.github/workflows/test-integration.yml || echo "keeping test-integration.yml")
13+
&& (test -z "$(INTEGRATION_TEST_TARGET)" && rm $(PWD)/.github/workflows/test-integration.yml || echo "keeping test-integration.yml") \
14+
&& /bin/bash $(DEVGO_PATH)/replace.sh
1115

1216
.PHONY: github-actions

replace.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env bash
2+
set -e
3+
4+
# Replace template with actual repo data.
5+
url=$(git remote get-url origin)
6+
7+
url_nopro=${url#*//}
8+
url_noatsign=${url_nopro#*@}
9+
10+
gh_repo=${url_noatsign#"github.com:"}
11+
gh_repo=${gh_repo#"github.com/"}
12+
gh_repo=${gh_repo%".git"}
13+
14+
project_name=$(basename $gh_repo)
15+
16+
echo "## Replacing all bool64/go-template references by $project_name"
17+
find ./.github -type f -print0 | xargs -0 perl -i -pe "s|bool64/go-template|$gh_repo|g"
18+
find ./.github -type f -print0 | xargs -0 perl -i -pe "s|go-template|$project_name|g"
19+
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
name: Bug report
3+
about: Create a report to help us improve
4+
title: ''
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
**Describe the bug**
11+
A clear and concise description of what the bug is.
12+
13+
**To Reproduce**
14+
If feasible/relevant, please provide a code snippet (inline or with Go playground) to reproduce the issue.
15+
16+
17+
**Expected behavior**
18+
A clear and concise description of what you expected to happen.
19+
20+
**Additional context**
21+
Add any other context about the problem here.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
name: Feature request
3+
about: Suggest an idea for this project
4+
title: ''
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
Please use discussions https://github.com/bool64/go-template/discussions/categories/ideas to share feature ideas.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
name: Question
3+
about: Any question about features or usage
4+
title: ''
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
Please use discussions https://github.com/bool64/go-template/discussions/categories/q-a to make your question more discoverable by other folks.

templates/github/workflows/bench.yml

Lines changed: 32 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ jobs:
3131
uses: actions/setup-go@v3
3232
with:
3333
go-version: ${{ env.GO_VERSION }}
34+
3435
- name: Install Go tip
3536
if: env.GO_VERSION == 'tip'
3637
run: |
@@ -40,10 +41,12 @@ jobs:
4041
tar -C ~/sdk/gotip -xzf gotip.tar.gz
4142
~/sdk/gotip/bin/go version
4243
echo "PATH=$HOME/go/bin:$HOME/sdk/gotip/bin/:$PATH" >> $GITHUB_ENV
44+
4345
- name: Checkout code
4446
uses: actions/checkout@v2
4547
with:
4648
ref: ${{ (github.event.inputs.new != '') && github.event.inputs.new || github.event.ref }}
49+
4750
- name: Go cache
4851
uses: actions/cache@v2
4952
with:
@@ -56,47 +59,57 @@ jobs:
5659
key: ${{ runner.os }}-go-cache-${{ hashFiles('**/go.sum') }}
5760
restore-keys: |
5861
${{ runner.os }}-go-cache
62+
5963
- name: Restore benchstat
6064
uses: actions/cache@v2
6165
with:
6266
path: ~/go/bin/benchstat
63-
key: ${{ runner.os }}-benchstat
67+
key: ${{ runner.os }}-benchstat-legacy
68+
6469
- name: Restore base benchmark result
70+
id: base-benchmark
6571
if: env.CACHE_BENCHMARK == 'on'
66-
id: benchmark-base
6772
uses: actions/cache@v2
6873
with:
6974
path: |
7075
bench-master.txt
7176
bench-main.txt
7277
# Use base sha for PR or new commit hash for master/main push in benchmark result key.
7378
key: ${{ runner.os }}-bench-${{ (github.event.pull_request.base.sha != github.event.after) && github.event.pull_request.base.sha || github.event.after }}
74-
- name: Checkout base code
75-
if: env.RUN_BASE_BENCHMARK == 'on' && steps.benchmark-base.outputs.cache-hit != 'true' && (github.event.pull_request.base.sha != '' || github.event.inputs.old != '')
76-
uses: actions/checkout@v2
77-
with:
78-
ref: ${{ (github.event.pull_request.base.sha != '' ) && github.event.pull_request.base.sha || github.event.inputs.old }}
79-
path: __base
80-
- name: Run base benchmark
81-
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
8281
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 != '')
93+
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 }}
8397
export REF_NAME=master
84-
cd __base
85-
make | grep bench-run && (BENCH_COUNT=5 make bench-run bench-stat && cp bench-master.txt ../bench-master.txt) || echo "No benchmarks in base"
86-
- name: Benchmark
98+
make bench-run bench-stat
99+
git reset --hard $HEAD
100+
101+
- name: Benchmark stats
87102
id: bench
88103
run: |
89104
export REF_NAME=new
90-
BENCH_COUNT=5 make bench
91105
OUTPUT=$(make bench-stat-diff)
92106
echo "${OUTPUT}"
93-
OUTPUT="${OUTPUT//$'\n'/%0A}"
94-
echo "::set-output name=diff::$OUTPUT"
107+
echo "diff<<EOF" >> $GITHUB_OUTPUT && echo "$OUTPUT" >> $GITHUB_OUTPUT && echo "EOF" >> $GITHUB_OUTPUT
95108
OUTPUT=$(make bench-stat)
96109
echo "${OUTPUT}"
97-
OUTPUT="${OUTPUT//$'\n'/%0A}"
98-
echo "::set-output name=result::$OUTPUT"
99-
- name: Comment Benchmark Result
110+
echo "result<<EOF" >> $GITHUB_OUTPUT && echo "$OUTPUT" >> $GITHUB_OUTPUT && echo "EOF" >> $GITHUB_OUTPUT
111+
112+
- name: Comment benchmark result
100113
continue-on-error: true
101114
uses: marocchino/sticky-pull-request-comment@v2
102115
with:

templates/github/workflows/cloc.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,17 @@ jobs:
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: |
2727
curl -sLO https://github.com/vearutop/sccdiff/releases/download/v1.0.3/linux_amd64.tar.gz && tar xf linux_amd64.tar.gz
2828
sccdiff_hash=$(git hash-object ./sccdiff)
2929
[ "$sccdiff_hash" == "ae8a07b687bd3dba60861584efe724351aa7ff63" ] || (echo "::error::unexpected hash for sccdiff, possible tampering: $sccdiff_hash" && exit 1)
3030
OUTPUT=$(cd pr && ../sccdiff -basedir ../base)
3131
echo "${OUTPUT}"
32-
OUTPUT="${OUTPUT//$'\n'/%0A}"
33-
echo "::set-output name=diff::$OUTPUT"
32+
echo "diff<<EOF" >> $GITHUB_OUTPUT && echo "$OUTPUT" >> $GITHUB_OUTPUT && echo "EOF" >> $GITHUB_OUTPUT
3433
35-
- name: Comment Code Lines
34+
- name: Comment lines of code
3635
continue-on-error: true
3736
uses: marocchino/sticky-pull-request-comment@v2
3837
with:

templates/github/workflows/gorelease.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,8 @@ jobs:
4242
test -e ~/go/bin/gorelease || go install golang.org/x/exp/cmd/gorelease@latest
4343
OUTPUT=$(gorelease 2>&1 || exit 0)
4444
echo "${OUTPUT}"
45-
OUTPUT="${OUTPUT//$'\n'/%0A}"
46-
echo "::set-output name=report::$OUTPUT"
47-
- name: Comment Report
45+
echo "report<<EOF" >> $GITHUB_OUTPUT && echo "$OUTPUT" >> $GITHUB_OUTPUT && echo "EOF" >> $GITHUB_OUTPUT
46+
- name: Comment report
4847
continue-on-error: true
4948
uses: marocchino/sticky-pull-request-comment@v2
5049
with:

templates/github/workflows/test-integration.yml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ jobs:
7979
go tool cover -func=./integration.coverprofile > integration.txt
8080
TOTAL=$(grep 'total:' integration.txt)
8181
echo "${TOTAL}"
82-
echo "::set-output name=total::$TOTAL"
82+
echo "total<<EOF" >> $GITHUB_OUTPUT && echo "$TOTAL" >> $GITHUB_OUTPUT && echo "EOF" >> $GITHUB_OUTPUT
8383
8484
- name: Annotate missing test coverage
8585
id: annotate
@@ -91,16 +91,14 @@ jobs:
9191
git fetch origin master ${{ github.event.pull_request.base.sha }}
9292
REP=$(./gocovdiff -cov integration.coverprofile -gha-annotations gha-integration.txt -delta-cov-file delta-cov-integration.txt -target-delta-cov ${TARGET_DELTA_COV})
9393
echo "${REP}"
94-
REP="${REP//$'\n'/%0A}"
9594
cat gha-integration.txt
9695
DIFF=$(test -e integration-base.txt && ./gocovdiff -func-cov integration.txt -func-base-cov integration-base.txt || echo "Missing base coverage file")
97-
DIFF="${DIFF//$'\n'/%0A}"
9896
TOTAL=$(cat delta-cov-integration.txt)
99-
echo "::set-output name=rep::$REP"
100-
echo "::set-output name=diff::$DIFF"
101-
echo "::set-output name=total::$TOTAL"
97+
echo "rep<<EOF" >> $GITHUB_OUTPUT && echo "$REP" >> $GITHUB_OUTPUT && echo "EOF" >> $GITHUB_OUTPUT
98+
echo "diff<<EOF" >> $GITHUB_OUTPUT && echo "$DIFF" >> $GITHUB_OUTPUT && echo "EOF" >> $GITHUB_OUTPUT
99+
echo "total<<EOF" >> $GITHUB_OUTPUT && echo "$TOTAL" >> $GITHUB_OUTPUT && echo "EOF" >> $GITHUB_OUTPUT
102100
103-
- name: Comment Test Coverage
101+
- name: Comment test coverage
104102
continue-on-error: true
105103
if: github.event.pull_request.base.sha != ''
106104
uses: marocchino/sticky-pull-request-comment@v2

0 commit comments

Comments
 (0)