Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create lint.yml #164

Merged
merged 6 commits into from
Nov 13, 2020
Merged
Show file tree
Hide file tree
Changes from 5 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
26 changes: 26 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: golangci-lint
on:
push:
tags:
- v*
branches:
- master
- main
pull_request:
jobs:
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: ^1.13
- uses: actions/checkout@v2
- name: Make Dependencies
run: make deps && make build
- name: golangci-lint
uses: golangci/golangci-lint-action@v2
with:
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
version: v1.29
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ testfull:
testshort:
go test -short ./... -v

# lint runs linting against code base
.PHONY: lint
lint:
go run github.com/golangci/golangci-lint/cmd/golangci-lint run

.PHONY: visor
visor:
rm -f visor
Expand Down
50 changes: 25 additions & 25 deletions metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,68 +12,68 @@ import (
var defaultMillisecondsDistribution = view.Distribution(0.01, 0.05, 0.1, 0.3, 0.6, 0.8, 1, 2, 3, 4, 5, 6, 8, 10, 13, 16, 20, 25, 30, 40, 50, 65, 80, 100, 130, 160, 200, 250, 300, 400, 500, 650, 800, 1000, 2000, 5000, 10000, 20000, 30000, 50000, 100000, 200000, 500000, 1000000, 2000000, 5000000, 10000000, 10000000)

var (
Error, _ = tag.NewKey("error")
TaskType, _ = tag.NewKey("task")
Error, _ = tag.NewKey("error")
TaskType, _ = tag.NewKey("task")
ConnState, _ = tag.NewKey("conn_state")
State, _ = tag.NewKey("state")
API, _ = tag.NewKey("api")
State, _ = tag.NewKey("state")
API, _ = tag.NewKey("api")
)

var (
ProcessingDuration = stats.Float64("processing_duration_ms", "Time taken to process a single item", stats.UnitMilliseconds)
PersistDuration = stats.Float64("persist_duration_ms", "Duration of a models persist operation", stats.UnitMilliseconds)
DBConns = stats.Int64("db_conns", "Database connections held", stats.UnitDimensionless)
ProcessingDuration = stats.Float64("processing_duration_ms", "Time taken to process a single item", stats.UnitMilliseconds)
PersistDuration = stats.Float64("persist_duration_ms", "Duration of a models persist operation", stats.UnitMilliseconds)
DBConns = stats.Int64("db_conns", "Database connections held", stats.UnitDimensionless)
HistoricalIndexerHeight = stats.Int64("historical_sync_height", "Sync height of the historical indexer", stats.UnitDimensionless)
EpochsToSync = stats.Int64("epochs_to_sync", "Epochs yet to sync", stats.UnitDimensionless)
LensRequestDuration = stats.Float64("lens_request_duration_ms", "Duration of lotus api requets", stats.UnitMilliseconds)
TipsetHeight = stats.Int64("tipset_height", "The height of the tipset being processed", stats.UnitDimensionless)
EpochsToSync = stats.Int64("epochs_to_sync", "Epochs yet to sync", stats.UnitDimensionless)
LensRequestDuration = stats.Float64("lens_request_duration_ms", "Duration of lotus api requets", stats.UnitMilliseconds)
TipsetHeight = stats.Int64("tipset_height", "The height of the tipset being processed", stats.UnitDimensionless)
)

var (
ProcessingDurationView = &view.View{
Measure: ProcessingDuration,
Measure: ProcessingDuration,
Aggregation: defaultMillisecondsDistribution,
TagKeys: []tag.Key{TaskType},
TagKeys: []tag.Key{TaskType},
}
PersistDurationView = &view.View{
Measure: PersistDuration,
Measure: PersistDuration,
Aggregation: defaultMillisecondsDistribution,
TagKeys: []tag.Key{TaskType},
TagKeys: []tag.Key{TaskType},
}
DBConnsView = &view.View{
Measure: DBConns,
Measure: DBConns,
Aggregation: view.Count(),
TagKeys: []tag.Key{ConnState},
TagKeys: []tag.Key{ConnState},
}
HistoricalIndexerHeightView = &view.View{
Measure: HistoricalIndexerHeight,
Measure: HistoricalIndexerHeight,
Aggregation: view.Sum(),
}
EpochsToSyncView = &view.View{
Measure: EpochsToSync,
Measure: EpochsToSync,
Aggregation: view.LastValue(),
}
LensRequestDurationView = &view.View{
Measure: LensRequestDuration,
Measure: LensRequestDuration,
Aggregation: defaultMillisecondsDistribution,
TagKeys: []tag.Key{TaskType, API},
TagKeys: []tag.Key{TaskType, API},
}
TipsetHeightView = &view.View{
Measure: TipsetHeight,
Measure: TipsetHeight,
Aggregation: view.LastValue(),
TagKeys: []tag.Key{TaskType},
TagKeys: []tag.Key{TaskType},
}
)

var DefaultViews = append([]*view.View{
var DefaultViews = []*view.View{
ProcessingDurationView,
PersistDurationView,
DBConnsView,
HistoricalIndexerHeightView,
EpochsToSyncView,
LensRequestDurationView,
TipsetHeightView,
})
}

// SinceInMilliseconds returns the duration of time since the provide time as a float64.
func SinceInMilliseconds(startTime time.Time) float64 {
Expand All @@ -87,4 +87,4 @@ func Timer(ctx context.Context, m *stats.Float64Measure) func() {
return func() {
stats.Record(ctx, m.M(SinceInMilliseconds(start)))
}
}
}
18 changes: 9 additions & 9 deletions storage/sql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func TestSchemaIsCurrent(t *testing.T) {

db, cleanup, err := testutil.WaitForExclusiveDatabase(ctx, t)
require.NoError(t, err)
defer cleanup()
defer require.NoError(t, cleanup())

for _, model := range models {
t.Run(fmt.Sprintf("%T", model), func(t *testing.T) {
Expand All @@ -59,7 +59,7 @@ func TestLeaseStateChanges(t *testing.T) {

db, cleanup, err := testutil.WaitForExclusiveDatabase(ctx, t)
require.NoError(t, err)
defer cleanup()
defer require.NoError(t, cleanup())

truncateVisorProcessingTables(t, db)

Expand Down Expand Up @@ -183,7 +183,7 @@ func TestLeaseActors(t *testing.T) {

db, cleanup, err := testutil.WaitForExclusiveDatabase(ctx, t)
require.NoError(t, err)
defer cleanup()
defer require.NoError(t, cleanup())

truncateVisorProcessingTables(t, db)

Expand Down Expand Up @@ -291,7 +291,7 @@ func TestMarkActorComplete(t *testing.T) {

db, cleanup, err := testutil.WaitForExclusiveDatabase(ctx, t)
require.NoError(t, err)
defer cleanup()
defer require.NoError(t, cleanup())

truncateVisorProcessingTables(t, db)

Expand Down Expand Up @@ -362,7 +362,7 @@ func TestLeaseTipSetMessages(t *testing.T) {

db, cleanup, err := testutil.WaitForExclusiveDatabase(ctx, t)
require.NoError(t, err)
defer cleanup()
defer require.NoError(t, cleanup())

truncateVisorProcessingTables(t, db)

Expand Down Expand Up @@ -461,7 +461,7 @@ func TestLeaseGasOutputsMessages(t *testing.T) {

db, cleanup, err := testutil.WaitForExclusiveDatabase(ctx, t)
require.NoError(t, err)
defer cleanup()
defer require.NoError(t, cleanup())

truncateVisorProcessingTables(t, db)

Expand Down Expand Up @@ -676,7 +676,7 @@ func TestMarkGasOutputsMessagesComplete(t *testing.T) {

db, cleanup, err := testutil.WaitForExclusiveDatabase(ctx, t)
require.NoError(t, err)
defer cleanup()
defer require.NoError(t, cleanup())

truncateVisorProcessingTables(t, db)

Expand Down Expand Up @@ -746,7 +746,7 @@ func TestLeaseTipSetEconomics(t *testing.T) {

db, cleanup, err := testutil.WaitForExclusiveDatabase(ctx, t)
require.NoError(t, err)
defer cleanup()
defer require.NoError(t, cleanup())

truncateVisorProcessingTables(t, db)

Expand Down Expand Up @@ -845,7 +845,7 @@ func TestMarkTipSetComplete(t *testing.T) {

db, cleanup, err := testutil.WaitForExclusiveDatabase(ctx, t)
require.NoError(t, err)
defer cleanup()
defer require.NoError(t, cleanup())

truncateVisorProcessingTables(t, db)

Expand Down
2 changes: 1 addition & 1 deletion testutil/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func WaitForExclusiveDatabase(ctx context.Context, tb testing.TB) (*pg.DB, func(
}

cleanup := func() error {
release()
_ = release()
return db.Close()
}

Expand Down