Skip to content
Open
Show file tree
Hide file tree
Changes from 4 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
242 changes: 121 additions & 121 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -1,126 +1,126 @@
name: Go

on:
push:
paths-ignore:
- packaging/**
branches:
- 'master'
pull_request:
paths-ignore:
- packaging/**
branches:
- '**'
push:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unnecessary indentation doubling on each line.

paths-ignore:
- packaging/**
branches:
- "master"
pull_request:
paths-ignore:
- packaging/**
branches:
- "**"

jobs:
test:
name: Test
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
cache: true
go-version-file: go.mod
- name: Build
run: make build
- name: Test with race detector (Ubuntu and MacOS)
if: matrix.os != 'windows-latest'
run: make test-ci-race
- name: Test without race detector (Windows)
if: matrix.os == 'windows-latest'
run: make test-ci
test-flaky:
name: Test (flaky)
runs-on: ubuntu-latest
continue-on-error: ${{ github.ref == 'refs/heads/master' }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
cache: true
go-version-file: go.mod
- name: Run flaky test
run: make test-ci-flaky
continue-on-error: ${{ github.ref == 'refs/heads/master' }}
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Go
uses: actions/setup-go@v5
with:
cache: false
go-version-file: go.mod
- name: Commit linting
if: github.ref != 'refs/heads/master'
uses: wagoid/commitlint-github-action@v5
- name: GolangCI-Lint
uses: golangci/golangci-lint-action@v6
with:
skip-cache: false
version: v1.64.5
- name: Whitespace check
run: make check-whitespace
- name: go mod tidy check
uses: katexochen/go-tidy-check@v2
coverage:
name: Coverage Report
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
cache: false
go-version-file: go.mod
- name: Cache Go Modules
uses: actions/cache@v4
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-coverage-${{ hashFiles('**/go.sum') }}
- name: Test with code coverage
run: make cover=1 test-ci
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
files: ./cover.out
trigger-beekeeper:
name: Trigger Beekeeper
runs-on: ubuntu-latest
needs: [test, lint, coverage]
if: github.ref == 'refs/heads/master'
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Go
uses: actions/setup-go@v5
with:
cache: false
go-version-file: go.mod
- name: Trigger Beekeeper
uses: peter-evans/repository-dispatch@v2
with:
token: ${{ secrets.GHA_PAT_BASIC }}
repository: ${{ github.repository }}
event-type: trigger-beekeeper
client-payload: '{"ref": "${{ github.ref }}", "sha": "${{ github.sha }}"}'
test:
name: Test
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
cache: true
go-version-file: go.mod
- name: Build
run: make build
- name: Test with race detector (Ubuntu and MacOS)
if: matrix.os != 'windows-latest'
run: make test-ci-race
- name: Test without race detector (Windows)
if: matrix.os == 'windows-latest'
run: make test-ci
test-flaky:
name: Test (flaky)
runs-on: ubuntu-latest
continue-on-error: ${{ github.ref == 'refs/heads/master' }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
cache: true
go-version-file: go.mod
- name: Run flaky test
run: make test-ci-flaky
continue-on-error: ${{ github.ref == 'refs/heads/master' }}
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Go
uses: actions/setup-go@v5
with:
cache: false
go-version-file: go.mod
- name: Commit linting
if: github.ref != 'refs/heads/master'
uses: wagoid/commitlint-github-action@v5
- name: GolangCI-Lint
uses: golangci/golangci-lint-action@v7
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bump required here as v2.1.6 of GolangCI-lint is only supported in @7

with:
skip-cache: false
version: v2.1.6
- name: Whitespace check
run: make check-whitespace
- name: go mod tidy check
uses: katexochen/go-tidy-check@v2
coverage:
name: Coverage Report
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
cache: false
go-version-file: go.mod
- name: Cache Go Modules
uses: actions/cache@v4
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-coverage-${{ hashFiles('**/go.sum') }}
- name: Test with code coverage
run: make cover=1 test-ci
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
files: ./cover.out
trigger-beekeeper:
name: Trigger Beekeeper
runs-on: ubuntu-latest
needs: [test, lint, coverage]
if: github.ref == 'refs/heads/master'
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Go
uses: actions/setup-go@v5
with:
cache: false
go-version-file: go.mod
- name: Trigger Beekeeper
uses: peter-evans/repository-dispatch@v2
with:
token: ${{ secrets.GHA_PAT_BASIC }}
repository: ${{ github.repository }}
event-type: trigger-beekeeper
client-payload: '{"ref": "${{ github.ref }}", "sha": "${{ github.sha }}"}'
118 changes: 72 additions & 46 deletions .golangci.yml
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Migrates the golang CI yaml to version 2, given that the project now uses go 1.24.0

Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
run:
timeout: 10m
version: "2"
linters:
enable:
- asciicheck
Expand All @@ -13,10 +12,8 @@ linters:
- forbidigo
- gochecknoinits
- goconst
- gofmt
- goheader
- goprintffuncname
- gosimple
- govet
- importas
- ineffassign
Expand All @@ -29,47 +26,76 @@ linters:
- promlinter
- staticcheck
- thelper
- typecheck
- unconvert
- unused
# - depguard disable temporary until this issue is resolved: https://github.com/golangci/golangci-lint/issues/3906

linters-settings:
govet:
enable-all: true
disable:
- fieldalignment ## temporally disabled
- shadow ## temporally disabled
goheader:
values:
regexp:
date: "20[1-2][0-9]"
template: |-
Copyright {{date}} The Swarm Authors. All rights reserved.
Use of this source code is governed by a BSD-style
license that can be found in the LICENSE file.
paralleltest:
# Ignore missing calls to `t.Parallel()` and only report incorrect uses of `t.Parallel()`.
ignore-missing: true
issues:
exclude-rules:
- linters:
- goheader
text: "go-ethereum Authors" ## disable check for other authors
- path: _test\.go
linters:
- goconst ## temporally disable goconst in test
- linters:
- forbidigo
path: cmd/bee/cmd
text: "use of `fmt.Print" ## allow fmt.Print in cmd directory
- linters:
- dogsled
path: pkg/api/(.+)_test\.go # temporally disable dogsled in api test files
- linters:
- dogsled
path: pkg/pushsync/(.+)_test\.go # temporally disable dogsled in pushsync test files
# temporally disable paralleltest in following packages
- linters:
- paralleltest
path: pkg/log
settings:
goheader:
values:
regexp:
date: 20[1-2][0-9]
template: |-
Copyright {{date}} The Swarm Authors. All rights reserved.
Use of this source code is governed by a BSD-style
license that can be found in the LICENSE file.
govet:
disable:
- fieldalignment
- shadow
enable-all: true
paralleltest:
ignore-missing: true
exclusions:
generated: lax
presets:
- comments
- common-false-positives
- legacy
- std-error-handling
rules:
- linters:
- goheader
text: go-ethereum Authors
- linters:
- goconst
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

originally, next to the rules there we comments like "temporally disable...", but this is how temporal solutions work usually : D

path: _test\.go
- linters:
- forbidigo
path: cmd/bee/cmd
text: use of `fmt.Print
- linters:
- dogsled
path: pkg/api/(.+)_test\.go
- linters:
- dogsled
path: pkg/pushsync/(.+)_test\.go
- linters:
- paralleltest
path: pkg/log
- linters:
- staticcheck
text: "QF1008:"
- linters:
- staticcheck
text: "QF1001:"
- linters:
- staticcheck
text: "QF1002:"
- linters:
- staticcheck
text: "QF1003:"
- linters:
- staticcheck
text: "QF1006:"
Comment on lines +74 to +88
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Disregarded as these are general in nature

paths:
- third_party$
- builtin$
- examples$
formatters:
enable:
- gofmt
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,7 +1,7 @@
GO ?= go
GOBIN ?= $$($(GO) env GOPATH)/bin
GOLANGCI_LINT ?= $(GOBIN)/golangci-lint
GOLANGCI_LINT_VERSION ?= v1.64.5
GOLANGCI_LINT_VERSION ?= v2.1.6
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Raising golangci-lint version to 2 involves a larger set of changes in this PR which as a different purpose. I would recommend to create a separate PR for improvimg golangci-lint usage.

GOGOPROTOBUF ?= protoc-gen-gogofaster
GOGOPROTOBUF_VERSION ?= v1.3.1
BEEKEEPER_INSTALL_DIR ?= $(GOBIN)
Expand Down
Loading
Loading