Skip to content

Commit

Permalink
Merge pull request #131 from dims/switch-to-github-actions
Browse files Browse the repository at this point in the history
Add github actions
  • Loading branch information
k8s-ci-robot committed Apr 8, 2020
2 parents c4e2294 + df739ca commit 51df65e
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 11 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Test
on: [push, pull_request]
jobs:
test:
strategy:
matrix:
go-versions: [1.12.x, 1.13.x, 1.14.x]
platform: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.platform }}
steps:
- name: Install Go
uses: actions/setup-go@v1
with:
go-version: ${{ matrix.go-version }}
- name: Checkout code
uses: actions/checkout@v2
- name: Test
run: |
go get -t -v ./...
go test -v -race ./...
lint:
runs-on: ubuntu-latest
steps:
- name: Install Go
uses: actions/setup-go@v1
- name: Checkout code
uses: actions/checkout@v2
- name: Lint
run: |
docker run --rm -v `pwd`:/go/src/k8s.io/klog -w /go/src/k8s.io/klog \
golangci/golangci-lint:v1.23.8 golangci-lint run --disable-all -v \
-E govet -E misspell -E gofmt -E ineffassign -E golint
15 changes: 4 additions & 11 deletions klog_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
stdLog "log"
"os"
"path/filepath"
"regexp"
"runtime"
"strconv"
"strings"
Expand Down Expand Up @@ -210,17 +211,9 @@ func TestHeaderWithDir(t *testing.T) {
}
pid = 1234
Info("test")
var line int
format := "I0102 15:04:05.067890 1234 v2/klog_test.go:%d] test\n"
n, err := fmt.Sscanf(contents(infoLog), format, &line)
if n != 1 || err != nil {
t.Errorf("log format error: %d elements, error %s:\n%s", n, err, contents(infoLog))
}
// Scanf treats multiple spaces as equivalent to a single space,
// so check for correct space-padding also.
want := fmt.Sprintf(format, line)
if contents(infoLog) != want {
t.Errorf("log format error: got:\n\t%q\nwant:\t%q", contents(infoLog), want)
re := regexp.MustCompile(`I0102 15:04:05.067890 1234 (klog|v2)/klog_test.go:(\d+)] test\n`)
if !re.MatchString(contents(infoLog)) {
t.Errorf("log format error: line does not match regex:\n\t%q\n", contents(infoLog))
}
}

Expand Down

0 comments on commit 51df65e

Please sign in to comment.