Skip to content

Commit 94248b3

Browse files
authored
Update actions, simplify Go versions (#63)
* Update actions * Remove deprecated linters
1 parent 20f22ce commit 94248b3

12 files changed

Lines changed: 70 additions & 137 deletions

File tree

.github/workflows/cloc.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ 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

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import _ "github.com/bool64/dev" // Include development helpers to project.
2626
Add `Makefile` to your module with includes standard targets.
2727

2828
```Makefile
29-
#GOLANGCI_LINT_VERSION := "v1.61.0" # Optional configuration to pinpoint golangci-lint version.
29+
#GOLANGCI_LINT_VERSION := "v1.63.4" # Optional configuration to pinpoint golangci-lint version.
3030

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

makefiles/base.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#GOLANGCI_LINT_VERSION := "v1.61.0" # Optional configuration to pinpoint golangci-lint version.
1+
#GOLANGCI_LINT_VERSION := "v1.63.4" # 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

scripts/.golangci.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ linters:
2222
disable:
2323
- lll
2424
- gochecknoglobals
25-
- gomnd
2625
- wrapcheck
2726
- paralleltest
2827
- forbidigo
@@ -40,12 +39,12 @@ linters:
4039
- execinquery
4140
- mnd
4241
- testifylint
42+
- recvcheck
4343

4444
issues:
4545
exclude-use-default: false
4646
exclude-rules:
4747
- linters:
48-
- gomnd
4948
- mnd
5049
- goconst
5150
- noctx

scripts/lint.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env bash
22

33
[ -z "$GO" ] && GO=go
4-
[ -z "$GOLANGCI_LINT_VERSION" ] && GOLANGCI_LINT_VERSION="v1.61.0"
4+
[ -z "$GOLANGCI_LINT_VERSION" ] && GOLANGCI_LINT_VERSION="v1.63.4"
55

66
# detecting GOPATH and removing trailing "/" if any
77
GOPATH="$(go env GOPATH)"

templates/github/workflows/bench.yml

Lines changed: 33 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -12,43 +12,27 @@ 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-
2015
env:
2116
GO111MODULE: "on"
2217
CACHE_BENCHMARK: "off" # Enables benchmark result reuse between runs, may skew latency results.
2318
RUN_BASE_BENCHMARK: "on" # Runs benchmark for PR base in case benchmark result is missing.
24-
GO_VERSION: 1.23.x
2519
jobs:
2620
bench:
21+
strategy:
22+
matrix:
23+
go-version: [ stable ]
2724
runs-on: ubuntu-latest
2825
steps:
29-
- name: Install Go stable
30-
if: env.GO_VERSION != 'tip'
31-
uses: actions/setup-go@v4
26+
- name: Install Go
27+
uses: actions/setup-go@v5
3228
with:
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-
29+
go-version: ${{ matrix.go-version }}
4530
- name: Checkout code
46-
uses: actions/checkout@v3
31+
uses: actions/checkout@v4
4732
with:
4833
ref: ${{ (github.event.inputs.new != '') && github.event.inputs.new || github.event.ref }}
49-
5034
- name: Go cache
51-
uses: actions/cache@v3
35+
uses: actions/cache@v4
5236
with:
5337
# In order:
5438
# * Module download cache
@@ -59,58 +43,49 @@ jobs:
5943
key: ${{ runner.os }}-go-cache-${{ hashFiles('**/go.sum') }}
6044
restore-keys: |
6145
${{ runner.os }}-go-cache
62-
6346
- name: Restore benchstat
64-
uses: actions/cache@v3
47+
uses: actions/cache@v4
6548
with:
6649
path: ~/go/bin/benchstat
67-
key: ${{ runner.os }}-benchstat-legacy
68-
50+
key: ${{ runner.os }}-benchstat
6951
- name: Restore base benchmark result
70-
id: base-benchmark
7152
if: env.CACHE_BENCHMARK == 'on'
72-
uses: actions/cache@v3
53+
id: benchmark-base
54+
uses: actions/cache@v4
7355
with:
7456
path: |
7557
bench-master.txt
7658
bench-main.txt
7759
# Use base sha for PR or new commit hash for master/main push in benchmark result key.
7860
key: ${{ runner.os }}-bench-${{ (github.event.pull_request.base.sha != github.event.after) && github.event.pull_request.base.sha || github.event.after }}
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 != '')
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@v4
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 != '')
9369
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 }}
9770
export REF_NAME=master
98-
make bench-run bench-stat
99-
git reset --hard $HEAD
100-
101-
- name: Benchmark stats
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
10274
id: bench
10375
run: |
10476
export REF_NAME=new
77+
BENCH_COUNT=5 make bench
10578
OUTPUT=$(make bench-stat-diff)
106-
echo "${OUTPUT}"
107-
echo "diff<<EOF" >> $GITHUB_OUTPUT && echo "$OUTPUT" >> $GITHUB_OUTPUT && echo "EOF" >> $GITHUB_OUTPUT
79+
OUTPUT="${OUTPUT//'%'/'%25'}"
80+
OUTPUT="${OUTPUT//$'\n'/'%0A'}"
81+
OUTPUT="${OUTPUT//$'\r'/'%0D'}"
82+
echo "::set-output name=diff::$OUTPUT"
10883
OUTPUT=$(make bench-stat)
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
84+
OUTPUT="${OUTPUT//'%'/'%25'}"
85+
OUTPUT="${OUTPUT//$'\n'/'%0A'}"
86+
OUTPUT="${OUTPUT//$'\r'/'%0D'}"
87+
echo "::set-output name=result::$OUTPUT"
88+
- name: Comment Benchmark Result
11489
uses: marocchino/sticky-pull-request-comment@v2
11590
with:
11691
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

templates/github/workflows/cloc.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ jobs:
1313
runs-on: ubuntu-latest
1414
steps:
1515
- name: Checkout code
16-
uses: actions/checkout@v3
16+
uses: actions/checkout@v4
1717
with:
1818
path: pr
1919
- name: Checkout base code
20-
uses: actions/checkout@v3
20+
uses: actions/checkout@v4
2121
with:
2222
ref: ${{ github.event.pull_request.base.sha }}
2323
path: base

templates/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.23.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@v6.1.0
27+
uses: golangci/golangci-lint-action@v6.2.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.61.0
30+
version: v1.63.4
3131

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

templates/github/workflows/gorelease.yml

Lines changed: 5 additions & 15 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.23.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@v4
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@v3
22+
uses: actions/checkout@v4
3323
- name: Gorelease cache
34-
uses: actions/cache@v3
24+
uses: actions/cache@v4
3525
with:
3626
path: |
3727
~/go/bin/gorelease

templates/github/workflows/release-assets.yml

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,28 +8,18 @@ on:
88
- created
99
env:
1010
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
11-
GO_VERSION: 1.23.x
11+
GO_VERSION: stable
1212
jobs:
1313
build:
1414
name: Upload Release Assets
1515
runs-on: ubuntu-latest
1616
steps:
17-
- name: Install Go stable
18-
if: env.GO_VERSION != 'tip'
19-
uses: actions/setup-go@v4
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@v3
22+
uses: actions/checkout@v4
3323
- name: Build artifacts
3424
run: |
3525
make release-assets

0 commit comments

Comments
 (0)