Skip to content
Open
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
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.23.x
- uses: actions/checkout@v2
go-version: stable
- uses: actions/checkout@v4
- name: golangci-lint
uses: golangci/golangci-lint-action@v6.1.0
uses: golangci/golangci-lint-action@v8.0.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.61.0
version: v2.4.0

# 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.23.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
34 changes: 12 additions & 22 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.16.x, 1.22.x, 1.23.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 @@ -91,8 +80,9 @@ jobs:
curl -sLO https://github.com/vearutop/gocovdiff/releases/download/v1.4.2/linux_amd64.tar.gz && tar xf linux_amd64.tar.gz && rm linux_amd64.tar.gz
gocovdiff_hash=$(git hash-object ./gocovdiff)
[ "$gocovdiff_hash" == "c37862c73a677e5a9c069470287823ab5bbf0244" ] || (echo "::error::unexpected hash for gocovdiff, possible tampering: $gocovdiff_hash" && exit 1)
git fetch origin master ${{ github.event.pull_request.base.sha }}
REP=$(./gocovdiff -mod github.com/$GITHUB_REPOSITORY -cov unit.coverprofile -gha-annotations gha-unit.txt -delta-cov-file delta-cov-unit.txt -target-delta-cov ${TARGET_DELTA_COV})
# Fetch PR diff from GitHub API.
curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -H "Accept: application/vnd.github.v3.diff" https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }} > pull_request.diff
REP=$(./gocovdiff -diff pull_request.diff -mod github.com/$GITHUB_REPOSITORY -cov unit.coverprofile -gha-annotations gha-unit.txt -delta-cov-file delta-cov-unit.txt -target-delta-cov ${TARGET_DELTA_COV})
echo "${REP}"
cat gha-unit.txt
DIFF=$(test -e unit-base.txt && ./gocovdiff -mod github.com/$GITHUB_REPOSITORY -func-cov unit.txt -func-base-cov unit-base.txt || echo "Missing base coverage file")
Expand Down Expand Up @@ -130,7 +120,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
135 changes: 75 additions & 60 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,71 +1,86 @@
# See https://github.com/golangci/golangci-lint/blob/master/.golangci.example.yml
# See https://golangci-lint.run/docs/linters/configuration/
version: "2"
run:
tests: true

linters-settings:
errcheck:
check-type-assertions: true
check-blank: true
gocyclo:
min-complexity: 20
dupl:
threshold: 100
misspell:
locale: US
unused:
check-exported: false
unparam:
check-exported: true
cyclop:
max-complexity: 15

linters:
enable-all: true
default: all
disable:
- embeddedstructfieldcheck
- noinlineerr
- wsl_v5
- funcorder
- copyloopvar
- gosec
- nilnil
- lll
- gochecknoglobals
- gomnd
- wrapcheck
- paralleltest
- depguard
- dupword
- errname
- exhaustruct
- forbidigo
- forcetypeassert
- varnamelen
- tagliatelle
- errname
- gochecknoglobals
- intrange
- ireturn
- exhaustruct
- lll
- mnd
- nilnil
- nonamedreturns
- testableexamples
- dupword
- depguard
- paralleltest
- recvcheck
- tagalign
- execinquery
- mnd
- tagliatelle
- testableexamples
- testifylint

issues:
exclude-use-default: false
exclude-rules:
- linters:
- gomnd
- mnd
- goconst
- err113
- 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"

- varnamelen
- wrapcheck
settings:
cyclop:
max-complexity: 15
dupl:
threshold: 100
errcheck:
check-type-assertions: true
check-blank: true
gocyclo:
min-complexity: 20
misspell:
locale: US
unparam:
check-exported: true
exclusions:
generated: lax
rules:
- linters:
- dupl
- err113
- funlen
- goconst
- mnd
- noctx
- nosnakecase
- structcheck
- unparam
- unused
path: _test.go
- linters:
- errcheck
- gosec
path: example_
- linters:
- revive
text: 'unused-parameter: parameter'
paths:
- third_party$
- builtin$
- examples$
formatters:
enable:
- gci
- gofmt
- gofumpt
- goimports
exclusions:
generated: lax
paths:
- third_party$
- builtin$
- examples$
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.61.0" # Optional configuration to pinpoint golangci-lint version.
#GOLANGCI_LINT_VERSION := "v2.3.1" # 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 _testdata/Database.feature
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ Feature: Database Query
"""

And these rows are stored in table "my_table" of database "my_db"
| id | foo | bar | created_at | deleted_at |
| 1 | foo-1 | abc | 2021-01-01T00:00:00Z | NULL |
| id | created_at | deleted_at | foo | bar |
| 1 | 2021-01-01T00:00:00Z | NULL | foo-1 | abc |

Then only these rows are available in table "my_table" of database "my_db"
| id | foo | bar | created_at | deleted_at |
Expand Down
8 changes: 4 additions & 4 deletions _testdata/rows.csv
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
id,foo,bar,created_at,deleted_at
1,foo-1,abc,2021-01-01T00:00:00Z,NULL
2,foo-1,def,2021-01-02T00:00:00Z,2021-01-03T00:00:00Z
3,foo-2,hij,2021-01-03T00:00:00Z,2021-01-03T00:00:00Z
id,created_at,deleted_at,foo,bar
1,2021-01-01T00:00:00Z,NULL,foo-1,abc
2,2021-01-02T00:00:00Z,2021-01-03T00:00:00Z,foo-1,def
3,2021-01-03T00:00:00Z,2021-01-03T00:00:00Z,foo-2,hij
Loading
Loading