Skip to content
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
35 changes: 35 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Test

# Replaces the Prow jobs pull-appkit-go-test and post-appkit-go-test.
on:
pull_request:
paths:
- '**.go'
- 'go.mod'
- 'go.sum'
- '.github/workflows/test.yaml'
push:
branches:
- master
paths:
- '**.go'
- 'go.mod'
- 'go.sum'
- '.github/workflows/test.yaml'

permissions:
contents: read

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false

- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: go.mod

- run: go test ./...
12 changes: 10 additions & 2 deletions log/log_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import (
"context"
"errors"
"fmt"
"go/build"
"io"
"path/filepath"
"runtime"
"strings"
"testing"
"time"
Expand Down Expand Up @@ -77,8 +78,15 @@ func TestLogError(t *testing.T) {
}
}

// moduleRoot is the directory of the appkit module. The stack traces
// have absolute file paths, and the expected values do not.
var moduleRoot = func() string {
_, file, _, _ := runtime.Caller(0)
return filepath.Dir(filepath.Dir(file))
}()

func cleanStacktrace(stacktrace string) (cleantrace string) {
cleantrace = strings.Replace(stacktrace, build.Default.GOPATH+"/src/", "", -1)
cleantrace = strings.Replace(stacktrace, moduleRoot+"/", "github.com/theplant/appkit/", -1)
lines := strings.Split(cleantrace, "\n")
if len(lines) >= 4 {
lines = lines[0:5]
Expand Down
Loading