Skip to content

Commit

Permalink
Replace TravisCI with CircleCI + GolangCI-Lint Action (#219)
Browse files Browse the repository at this point in the history
- Also fix flaky sfxclient test
  • Loading branch information
benkeith-splunk authored Jun 28, 2021
1 parent a2eaf9d commit a1d2d27
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 38 deletions.
26 changes: 26 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
version: 2.1
jobs:
build:
working_directory: ~/repo
docker:
- image: circleci/golang:1.16.5
steps:
- checkout
- restore_cache:
keys:
- go-mod-v4-{{ checksum "go.sum" }}
- run:
name: Install Dependencies
command: go mod download
- save_cache:
key: go-mod-v4-{{ checksum "go.sum" }}
paths:
- "/go/pkg/mod"
- run:
name: Run tests
command: |
set -x
go test -covermode atomic -race -timeout 120s -parallel 4 -coverprofile ./coverage.out $(go list ./...)
cov="$(go tool cover -func coverage.out | grep -v 100.0% || true)"
echo $cov
test -z "$cov"
33 changes: 33 additions & 0 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: golangci-lint
on:
push:
tags:
- v*
branches:
- master
- main
pull_request:
jobs:
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: golangci-lint
uses: golangci/golangci-lint-action@v2
with:
version: v1.30
# Optional: golangci-lint command line arguments.
# args: --issues-exit-code=0

# Optional: show only new issues if it's a pull request. The default value is `false`.
# only-new-issues: true

# Optional: if set to true then the action will use pre-installed Go.
# skip-go-installation: true

# Optional: if set to true then the action don't cache or restore ~/go/pkg.
# skip-pkg-cache: true

# Optional: if set to true then the action don't cache or restore ~/.cache/go-build.
# skip-build-cache: true
31 changes: 0 additions & 31 deletions .travis.yml

This file was deleted.

23 changes: 16 additions & 7 deletions sfxclient/sfxclient_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func TestScheduler_ReportingTimeout(t *testing.T) {
tk := timekeepertest.NewStubClock(time.Now())
s.Timer = tk

ctx := context.Background()
ctx, cancel := context.WithCancel(context.Background())
Convey("testing longer processing time for ReportOnce", t, func() {
s.ReportingTimeout(time.Nanosecond)
setupCollectors(250 * 10)
Expand All @@ -118,6 +118,7 @@ func TestScheduler_ReportingTimeout(t *testing.T) {
tk.Incr(time.Duration(s.ReportingDelayNs))
runtime.Gosched()
}
cancel()
So(atomic.LoadInt64(&s.stats.reportingTimeoutCounts), ShouldEqual, int64(1))
})
}
Expand All @@ -140,18 +141,26 @@ func TestCollectDatapointDebug(t *testing.T) {
tk := timekeepertest.NewStubClock(time.Now())
s.Timer = tk

ctx := context.Background()
ctx, cancel := context.WithCancel(context.Background())
Convey("testing collect datapoints with debug mode enabled", t, func() {
s.Debug(true)
s.AddCallback(GoMetricsSource)
s.AddGroupedCallback("goMetrics", GoMetricsSource)
go s.Schedule(ctx)
for atomic.LoadInt64(&s.stats.scheduledSleepCounts) == 0 {
runtime.Gosched()
tk.Incr(time.Duration(s.ReportingDelayNs))
runtime.Gosched()
}
go func() {
for {
runtime.Gosched()
tk.Incr(time.Duration(s.ReportingDelayNs))
runtime.Gosched()
select {
case <-ctx.Done():
return
default:
}
}
}()
dps := <-sink.lastDatapoints
cancel()
So(len(dps), ShouldEqual, 60)
})
}
Expand Down

0 comments on commit a1d2d27

Please sign in to comment.