Skip to content

Commit 0870e1a

Browse files
committed
consolidate CI
1 parent 1f72346 commit 0870e1a

File tree

9 files changed

+22
-58
lines changed

9 files changed

+22
-58
lines changed

.github/workflows/ci.yml

Lines changed: 13 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -12,38 +12,25 @@ on:
1212
workflow_dispatch:
1313

1414
jobs:
15-
fmt:
16-
runs-on: ubuntu-20.04
15+
go:
16+
runs-on: ubuntu-latest
1717
steps:
1818
- uses: actions/checkout@v3
19-
20-
- name: make fmt
21-
uses: ./ci/image
19+
- name: Cache npm
20+
uses: actions/cache@v3
2221
with:
23-
args: make fmt
24-
25-
lint:
26-
runs-on: ubuntu-20.04
27-
steps:
28-
- uses: actions/checkout@v3
29-
30-
- name: make lint
31-
uses: ./ci/image
22+
path: ~/.npm
23+
key: "npm-cache"
24+
- uses: actions/setup-go@v4
3225
with:
33-
args: make lint
34-
35-
test:
36-
runs-on: ubuntu-20.04
37-
steps:
38-
- uses: actions/checkout@v3
39-
40-
- name: make test
41-
uses: ./ci/image
42-
with:
43-
args: make test
26+
go-version: "1.20"
27+
cache-dependency-path: go.sum
28+
- name: "make"
29+
run: |
30+
git config --global --add safe.directory /github/workspace
31+
make -O -j fmt lint test
4432
env:
4533
COVERALLS_TOKEN: ${{ secrets.github_token }}
46-
4734
- name: Upload coverage.html
4835
uses: actions/upload-artifact@v2
4936
with:

ci/fmt.mk

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
fmt: modtidy gofmt goimports prettier
1+
fmt: modtidy gofmt prettier
22
ifdef CI
33
if [[ $$(git ls-files --other --modified --exclude-standard) != "" ]]; then
44
echo "Files need generation or are formatted incorrectly:"
@@ -13,13 +13,10 @@ modtidy: gen
1313
go mod tidy
1414

1515
gofmt: gen
16-
gofmt -w -s .
17-
18-
goimports: gen
19-
goimports -w "-local=$$(go list -m)" .
16+
go run mvdan.cc/gofumpt@latest -w .
2017

2118
prettier:
22-
prettier --write --print-width=120 --no-semi --trailing-comma=all --loglevel=warn $$(git ls-files "*.yml")
19+
npx prettier --write --print-width=120 --no-semi --trailing-comma=all --loglevel=warn $$(git ls-files "*.yml")
2320

2421
gen:
2522
go generate ./...

ci/image/Dockerfile

Lines changed: 0 additions & 14 deletions
This file was deleted.

ci/lint.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ govet:
44
go vet ./...
55

66
golint:
7-
golint -set_exit_status ./...
7+
go run github.com/golangci/golangci-lint/cmd/golangci-lint@latest run .

ci/test.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ coveralls: gotest
1515
export CI_PULL_REQUEST="$$(jq .number "$$GITHUB_EVENT_PATH")"
1616
BUILD_NUMBER="$$BUILD_NUMBER-PR-$$CI_PULL_REQUEST"
1717
fi
18-
goveralls -coverprofile=ci/out/coverage.prof -service=github
18+
go run github.com/mattn/goveralls@latest -coverprofile=ci/out/coverage.prof -service=github
1919

2020
gotest:
2121
go test -covermode=count -coverprofile=ci/out/coverage.prof -coverpkg=./... $${GOTESTFLAGS-} ./...

internal/entryhuman/entry.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ func Fmt(
7272
ts := ent.Time.Format(TimeFormat)
7373
buf.WriteString(ts + " ")
7474

75-
level := ent.Level.String()
75+
level := strings.ToLower(ent.Level.String())
7676
if len(level) > 4 {
7777
level = level[:4]
7878
}
@@ -162,7 +162,7 @@ var (
162162
levelDebugStyle = renderer.NewStyle().Foreground(lipgloss.Color("#ffffff"))
163163
levelInfoStyle = renderer.NewStyle().Foreground(lipgloss.Color("#0091FF"))
164164
levelWarnStyle = renderer.NewStyle().Foreground(lipgloss.Color("#FFCF0D"))
165-
levelErrorStyle = renderer.NewStyle().Foreground(lipgloss.Color("#FF5A0D"))
165+
levelErrorStyle = renderer.NewStyle().Foreground(lipgloss.Color("#FF5A0D")).Bold(true)
166166
)
167167

168168
func levelStyle(level slog.Level) lipgloss.Style {

map_test.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ func TestMap(t *testing.T) {
187187
t.Parallel()
188188

189189
test(t, slog.M(
190-
slog.F("val", time.Date(2000, 02, 05, 4, 4, 4, 0, time.UTC)),
190+
slog.F("val", time.Date(2000, 0o2, 0o5, 4, 4, 4, 0, time.UTC)),
191191
), `{
192192
"val": "2000-02-05T04:04:04Z"
193193
}`)
@@ -222,10 +222,6 @@ func TestMap(t *testing.T) {
222222
})
223223
}
224224

225-
type meow struct {
226-
a int
227-
}
228-
229225
func indentJSON(t *testing.T, j string) string {
230226
b := &bytes.Buffer{}
231227
err := json.Indent(b, []byte(j), "", strings.Repeat(" ", 4))

sloggers/slogtest/assert/assert.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,5 +89,4 @@ func stringContainsFold(errs, sub string) bool {
8989
sub = strings.ToLower(sub)
9090

9191
return strings.Contains(errs, sub)
92-
9392
}

sloggers/slogtest/assert/assert_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,10 @@ func TestErrorContains(t *testing.T) {
4444
defer func() {
4545
recover()
4646
simpleassert.Equal(t, "fatals", 1, tb.fatals)
47-
4847
}()
4948
assert.ErrorContains(tb, "meow", io.ErrClosedPipe, "eof")
50-
5149
}
50+
5251
func TestSuccess(t *testing.T) {
5352
t.Parallel()
5453

0 commit comments

Comments
 (0)