Skip to content

Commit 600d7a9

Browse files
committed
Add CI to github pushes
1 parent 147eaa8 commit 600d7a9

File tree

6 files changed

+96
-21
lines changed

6 files changed

+96
-21
lines changed

.github/workflows/ci.yaml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Run CI
2+
3+
on:
4+
push:
5+
branches:
6+
- "*"
7+
8+
jobs:
9+
lint_test:
10+
name: Linting and tests
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: write
14+
15+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@v4
18+
19+
- name: Set up Go
20+
uses: actions/setup-go@v5
21+
with:
22+
go-version-file: "go.mod"
23+
24+
- name: Run linting
25+
run: "make lint"
26+
27+
- name: Run tests
28+
run: "make test"

.github/workflows/release.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ name: Release
33
on:
44
push:
55
tags:
6-
- "*"
6+
- "v*"
77

88
jobs:
99
build_release:
10+
name: Build logfmt binaries
1011
runs-on: ubuntu-latest
1112
strategy:
1213
matrix:
@@ -30,7 +31,7 @@ jobs:
3031
GOARCH: ${{ matrix.goarch }}
3132
run: |
3233
go build -ldflags="-s -w" -o logfmt-${{ matrix.goos }}-${{ matrix.goarch }}-${{ github.ref_name }}
33-
34+
3435
- name: Compress with UPX (Linux only)
3536
if: matrix.goos == 'linux'
3637
uses: crazy-max/ghaction-upx@v3
@@ -47,6 +48,7 @@ jobs:
4748
retention-days: 1
4849

4950
create_release:
51+
name: Create GitHub release from tag version
5052
runs-on: ubuntu-latest
5153
needs: build_release
5254
permissions:
@@ -68,4 +70,4 @@ jobs:
6870
name: "Release ${{ github.ref_name }}"
6971
body: |
7072
Automated release for tag ${{ github.ref_name }}.
71-
files: release-artifacts/*/*
73+
files: release-artifacts/*/*

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
bin/

.golangci.yml

Lines changed: 41 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,46 @@
11
---
2+
version: "2"
23
linters:
34
enable:
4-
- goimports
5-
- stylecheck
5+
- forbidigo
66
- lll
7+
- prealloc
8+
- predeclared
9+
- staticcheck
710
- errcheck
8-
9-
run:
10-
go: '1.22'
11-
timeout: 30s
12-
13-
issues:
14-
exclude-rules:
15-
- linters:
16-
- lll
17-
source: "// nolint:lll"
18-
- linters:
19-
- unused
20-
- deadcode
21-
- varcheck
22-
source: "// nolint:unused"
11+
exclusions:
12+
generated: lax
13+
presets:
14+
- comments
15+
- common-false-positives
16+
- legacy
17+
- std-error-handling
18+
rules:
19+
- linters:
20+
- lll
21+
source: // nolint:lll
22+
- linters:
23+
- staticcheck
24+
source: // nolint:stylecheck
25+
- linters:
26+
- deadcode
27+
- revive
28+
- unused
29+
- varcheck
30+
source: // nolint:unused
31+
- linters:
32+
- staticcheck
33+
text: 'SA1019:'
34+
source: // ignore:deprecated
35+
formatters:
36+
enable:
37+
- gci
38+
- gofmt
39+
- gofumpt
40+
- goimports
41+
settings:
42+
gci:
43+
sections:
44+
- standard
45+
- default
46+
- localmodule

Makefile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
.PHONY: setup lint test
2+
3+
setup: bin/golangci-lint
4+
go mod download
5+
6+
bin:
7+
mkdir bin
8+
9+
bin/golangci-lint: bin
10+
GOBIN=$(PWD)/bin go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.3.0
11+
12+
lint: bin/golangci-lint
13+
bin/golangci-lint fmt
14+
go vet ./...
15+
go mod tidy
16+
bin/golangci-lint -c .golangci.yml run ./...
17+
18+
test:
19+
go test -timeout=10s -race -cover ./...

parser/record.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@ import (
77
"strings"
88
"time"
99

10-
"github.com/TheEdgeOfRage/logfmt/config"
1110
"github.com/fatih/color"
1211
"github.com/go-logfmt/logfmt"
12+
13+
"github.com/TheEdgeOfRage/logfmt/config"
1314
)
1415

1516
var (

0 commit comments

Comments
 (0)