Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 33 additions & 58 deletions .github/workflows/bench.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,43 +12,27 @@ on:
description: 'New Ref'
required: true

# Cancel the workflow in progress in newer build is about to start.
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

env:
GO111MODULE: "on"
CACHE_BENCHMARK: "off" # Enables benchmark result reuse between runs, may skew latency results.
RUN_BASE_BENCHMARK: "on" # Runs benchmark for PR base in case benchmark result is missing.
GO_VERSION: 1.22.x
jobs:
bench:
strategy:
matrix:
go-version: [ stable ]
runs-on: ubuntu-latest
steps:
- name: Install Go stable
if: env.GO_VERSION != 'tip'
uses: actions/setup-go@v4
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}

- name: Install Go tip
if: env.GO_VERSION == 'tip'
run: |
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
ls -lah gotip.tar.gz
mkdir -p ~/sdk/gotip
tar -C ~/sdk/gotip -xzf gotip.tar.gz
~/sdk/gotip/bin/go version
echo "PATH=$HOME/go/bin:$HOME/sdk/gotip/bin/:$PATH" >> $GITHUB_ENV

go-version: ${{ matrix.go-version }}
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: ${{ (github.event.inputs.new != '') && github.event.inputs.new || github.event.ref }}

- name: Go cache
uses: actions/cache@v3
uses: actions/cache@v4
with:
# In order:
# * Module download cache
Expand All @@ -59,58 +43,49 @@ jobs:
key: ${{ runner.os }}-go-cache-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-cache

- name: Restore benchstat
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/go/bin/benchstat
key: ${{ runner.os }}-benchstat-legacy

key: ${{ runner.os }}-benchstat
- name: Restore base benchmark result
id: base-benchmark
if: env.CACHE_BENCHMARK == 'on'
uses: actions/cache@v3
id: benchmark-base
uses: actions/cache@v4
with:
path: |
bench-master.txt
bench-main.txt
# Use base sha for PR or new commit hash for master/main push in benchmark result key.
key: ${{ runner.os }}-bench-${{ (github.event.pull_request.base.sha != github.event.after) && github.event.pull_request.base.sha || github.event.after }}

- name: Run benchmark
run: |
export REF_NAME=new
make bench
OUTPUT=$(make bench-stat-diff)
echo "${OUTPUT}"
echo "diff<<EOF" >> $GITHUB_OUTPUT && echo "$OUTPUT" >> $GITHUB_OUTPUT && echo "EOF" >> $GITHUB_OUTPUT
OUTPUT=$(make bench-stat)
echo "${OUTPUT}"
echo "result<<EOF" >> $GITHUB_OUTPUT && echo "$OUTPUT" >> $GITHUB_OUTPUT && echo "EOF" >> $GITHUB_OUTPUT

- name: Run benchmark for base code
if: env.RUN_BASE_BENCHMARK == 'on' && steps.base-benchmark.outputs.cache-hit != 'true' && (github.event.pull_request.base.sha != '' || github.event.inputs.old != '')
- name: Checkout base code
if: env.RUN_BASE_BENCHMARK == 'on' && steps.benchmark-base.outputs.cache-hit != 'true' && (github.event.pull_request.base.sha != '' || github.event.inputs.old != '')
uses: actions/checkout@v4
with:
ref: ${{ (github.event.pull_request.base.sha != '' ) && github.event.pull_request.base.sha || github.event.inputs.old }}
path: __base
- name: Run base benchmark
if: env.RUN_BASE_BENCHMARK == 'on' && steps.benchmark-base.outputs.cache-hit != 'true' && (github.event.pull_request.base.sha != '' || github.event.inputs.old != '')
run: |
git fetch origin master ${{ github.event.pull_request.base.sha }}
HEAD=$(git rev-parse HEAD)
git reset --hard ${{ github.event.pull_request.base.sha }}
export REF_NAME=master
make bench-run bench-stat
git reset --hard $HEAD

- name: Benchmark stats
cd __base
make | grep bench-run && (BENCH_COUNT=5 make bench-run bench-stat && cp bench-master.txt ../bench-master.txt) || echo "No benchmarks in base"
- name: Benchmark
id: bench
run: |
export REF_NAME=new
BENCH_COUNT=5 make bench
OUTPUT=$(make bench-stat-diff)
echo "${OUTPUT}"
echo "diff<<EOF" >> $GITHUB_OUTPUT && echo "$OUTPUT" >> $GITHUB_OUTPUT && echo "EOF" >> $GITHUB_OUTPUT
OUTPUT="${OUTPUT//'%'/'%25'}"
OUTPUT="${OUTPUT//$'\n'/'%0A'}"
OUTPUT="${OUTPUT//$'\r'/'%0D'}"
echo "::set-output name=diff::$OUTPUT"
OUTPUT=$(make bench-stat)
echo "${OUTPUT}"
echo "result<<EOF" >> $GITHUB_OUTPUT && echo "$OUTPUT" >> $GITHUB_OUTPUT && echo "EOF" >> $GITHUB_OUTPUT

- name: Comment benchmark result
continue-on-error: true
OUTPUT="${OUTPUT//'%'/'%25'}"
OUTPUT="${OUTPUT//$'\n'/'%0A'}"
OUTPUT="${OUTPUT//$'\r'/'%0D'}"
echo "::set-output name=result::$OUTPUT"
- name: Comment Benchmark Result
uses: marocchino/sticky-pull-request-comment@v2
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/cloc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
path: pr
- name: Checkout base code
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.base.sha }}
path: base
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ jobs:
name: golangci-lint
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v3
- uses: actions/setup-go@v5
with:
go-version: 1.22.x
- uses: actions/checkout@v2
go-version: stable
- uses: actions/checkout@v4
- name: golangci-lint
uses: golangci/golangci-lint-action@v4.0.0
uses: golangci/golangci-lint-action@v6.2.0
with:
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
version: v1.56.2
version: v1.63.4

# Optional: working directory, useful for monorepos
# working-directory: somedir
Expand Down
20 changes: 5 additions & 15 deletions .github/workflows/gorelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,19 @@ concurrency:
cancel-in-progress: true

env:
GO_VERSION: 1.22.x
GO_VERSION: stable
jobs:
gorelease:
runs-on: ubuntu-latest
steps:
- name: Install Go stable
if: env.GO_VERSION != 'tip'
uses: actions/setup-go@v4
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- name: Install Go tip
if: env.GO_VERSION == 'tip'
run: |
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
ls -lah gotip.tar.gz
mkdir -p ~/sdk/gotip
tar -C ~/sdk/gotip -xzf gotip.tar.gz
~/sdk/gotip/bin/go version
echo "PATH=$HOME/go/bin:$HOME/sdk/gotip/bin/:$PATH" >> $GITHUB_ENV
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Gorelease cache
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: |
~/go/bin/gorelease
Expand Down
29 changes: 9 additions & 20 deletions .github/workflows/test-unit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,36 +15,25 @@ concurrency:
env:
GO111MODULE: "on"
RUN_BASE_COVERAGE: "on" # Runs test for PR base in case base test coverage is missing.
COV_GO_VERSION: 1.22.x # Version of Go to collect coverage
COV_GO_VERSION: stable # Version of Go to collect coverage
TARGET_DELTA_COV: 90 # Target coverage of changed lines, in percents
jobs:
test:
strategy:
matrix:
go-version: [ 1.20.x, 1.21.x, 1.22.x ]
go-version: [ stable, oldstable ]
runs-on: ubuntu-latest
steps:
- name: Install Go stable
if: matrix.go-version != 'tip'
uses: actions/setup-go@v4
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}

- name: Install Go tip
if: matrix.go-version == 'tip'
run: |
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
ls -lah gotip.tar.gz
mkdir -p ~/sdk/gotip
tar -C ~/sdk/gotip -xzf gotip.tar.gz
~/sdk/gotip/bin/go version
echo "PATH=$HOME/go/bin:$HOME/sdk/gotip/bin/:$PATH" >> $GITHUB_ENV

- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Go cache
uses: actions/cache@v3
uses: actions/cache@v4
with:
# In order:
# * Module download cache
Expand All @@ -59,7 +48,7 @@ jobs:
- name: Restore base test coverage
id: base-coverage
if: matrix.go-version == env.COV_GO_VERSION && github.event.pull_request.base.sha != ''
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: |
unit-base.txt
Expand Down Expand Up @@ -130,7 +119,7 @@ jobs:

- name: Upload code coverage
if: matrix.go-version == env.COV_GO_VERSION
uses: codecov/codecov-action@v1
uses: codecov/codecov-action@v5
with:
file: ./unit.coverprofile
files: ./unit.coverprofile
flags: unittests
28 changes: 12 additions & 16 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,53 +22,49 @@ linters-settings:
linters:
enable-all: true
disable:
- spancheck
- intrange
- copyloopvar
- lll
- maligned
- gochecknoglobals
- gomnd
- wrapcheck
- paralleltest
- forbidigo
- exhaustivestruct
- interfacer # deprecated
- forcetypeassert
- scopelint # deprecated
- ifshort # too many false positives
- golint # deprecated
- varnamelen
- tagliatelle
- errname
- ireturn
- exhaustruct
- nonamedreturns
- nosnakecase
- structcheck
- varcheck
- deadcode
- testableexamples
- dupword
- depguard
- tagalign
- mnd
- testifylint
- recvcheck

issues:
exclude-use-default: false
exclude-rules:
- linters:
- testifylint
- gomnd
- gosec
text: 'G115: integer overflow conversion'
- linters:
- mnd
- goconst
- goerr113
- noctx
- funlen
- dupl
- structcheck
- unused
- unparam
- nosnakecase
path: "_test.go"
- linters:
- errcheck # Error checking omitted for brevity.
- gosec
path: "example_"
- linters:
- revive
text: "unused-parameter: parameter"

2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#GOLANGCI_LINT_VERSION := "v1.56.2" # Optional configuration to pinpoint golangci-lint version.
#GOLANGCI_LINT_VERSION := "v1.63.4" # Optional configuration to pinpoint golangci-lint version.

# The head of Makefile determines location of dev-go to include standard targets.
GO ?= go
Expand Down
4 changes: 2 additions & 2 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ func TestLoad(t *testing.T) {
Baz bool
}{}

require.NoError(t, os.Setenv("TEST_ENVIRONMENT", "test"))
t.Setenv("TEST_ENVIRONMENT", "test")
assert.EqualError(t, config.Load("TEST", &cfg), "validate: I[#/Bar] S[#/properties/Bar/minimum] must be >= 500/1 but found 321")
require.NoError(t, os.Setenv("TEST_BAR", "600"))
t.Setenv("TEST_BAR", "600")
assert.NoError(t, config.Load("TEST", &cfg))

assert.Equal(t, 600, cfg.Bar)
Expand Down
3 changes: 2 additions & 1 deletion database/observability.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@

if operation == dbwrap.RowsClose {
statsTracker.Add(ctx, "sql_storage_rows_close", 1, "method", caller)
return

return nil, nil

Check notice on line 93 in database/observability.go

View workflow job for this annotation

GitHub Actions / test (stable)

2 statement(s) on lines 90:94 are not covered by tests.
}

ctx, span := trace.StartSpan(ctx, caller+":"+string(operation))
Expand Down
Loading
Loading