Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactoring due to aggressive linting; add golanglint-ci github action #2

Merged
merged 1 commit into from
May 2, 2024
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
41 changes: 41 additions & 0 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: golangci-lint
on:
push:
branches:
- '**' # Run on all branches
pull_request:

permissions:
contents: read
# Optional: allow read access to pull request. Use with `only-new-issues` option.
# pull-requests: read

jobs:
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
check-latest: true
go-version: '1.22'
- name: golangci-lint
uses: golangci/golangci-lint-action@v5
with:
version: v1.57
skip-cache: true
args: --timeout=5m

test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
check-latest: true
go-version: '1.22'
- name: Test all
run: go test ./...
330 changes: 330 additions & 0 deletions .golangci.yml

Large diffs are not rendered by default.

6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,5 @@ pre-commit run --all-files

#### Go-licenses pre-commit hook

Windows users will not be able to run the `go-licenses` hook as yet - @momer will be sending through a
PR to that project to resolve the issue, which is to do with OS-agnostic filepath support!


Windows users: Ensure that you have `C:\Program Files\Git\usr\bin` added
to your `PATH`!
4 changes: 4 additions & 0 deletions bonsai/bonsai.go
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
// Package bonsai wraps the Bonsai.io HTTP API to create a Go API Client.
package bonsai

const (
Float64Epsilon = 1e-9
)
10 changes: 6 additions & 4 deletions bonsai/bonsai_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ package bonsai_test

import (
"fmt"
"log"
"log/slog"
"os"

_ "github.com/stretchr/testify/require"
)

func init() {
Expand All @@ -18,9 +17,12 @@ func initLogger() {

logHandler := slog.NewTextHandler(os.Stdout, &slog.HandlerOptions{
AddSource: true,
ReplaceAttr: func(groups []string, a slog.Attr) slog.Attr {
ReplaceAttr: func(_ []string, a slog.Attr) slog.Attr {
if a.Key == slog.SourceKey {
src := a.Value.Any().(*slog.Source)
src, ok := a.Value.Any().(*slog.Source)
if !ok {
log.Fatalf("sourceKey attr is not a Source: %v", a.Value)
}
// Ruby on Rails-ish formatting
a.Value = slog.StringValue(fmt.Sprintf("%s:%d:in '%s'", src.File, src.Line, src.Function))
}
Expand Down
Loading
Loading