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
16 changes: 16 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
version: 2

updates:
- package-ecosystem: "gomod"
directory: "/"
schedule:
interval: "weekly"
day: "monday"
open-pull-requests-limit: 5

- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
day: "monday"
open-pull-requests-limit: 5
41 changes: 33 additions & 8 deletions .github/workflows/client.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,39 +13,64 @@ jobs:
client-build-and-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Setup Go
uses: actions/setup-go@v3
uses: actions/setup-go@v4
with:
go-version: "1.18"
go-version: "1.22"
cache: true

- name: Run Go generators
run: go generate ./.../gen

- name: Ensure generated code is clean
run: git diff --exit-code

- name: Run Go vet
run: go vet ./...

- name: Build Go
run: go build ./...

- name: Install gotestsum
run: go install gotest.tools/gotestsum@latest
run: go install gotest.tools/gotestsum@v1.12.0

- name: Run Go tests
run: gotestsum

- name: Install govulncheck
run: go install golang.org/x/vuln/cmd/govulncheck@v1.1.1

- name: Run govulncheck
run: govulncheck ./...
continue-on-error: true

client-scan:
if: github.event_name != 'schedule'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: securego/gosec@master
- uses: securego/gosec@v2.19.0
with:
args: ./...

client-lint:
if: github.event_name != 'schedule'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: "1.22"
cache: true

- name: Run Go generators
run: go generate ./.../gen

- name: Install golint
run: go install golang.org/x/lint/golint@latest

- name: Lint Go
uses: keep-network/golint-action@v1.0.2
- name: Run golint
run: golint ./...
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Changelog

All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog and this fork follows Semantic Versioning for tagged releases.

## Unreleased
### Added
- Release guide and initial changelog stub for the fork of `keep-core/keep-common`.

## Upstream Baseline - v1.7.0
### Notes
- Latest upstream tag from https://github.com/keep-network/keep-common (tracked via git tags); upstream is unmaintained, so this fork continues independently from that point.
### Added
- Inherited upstream history through v1.7.0 as the starting point for forked releases.
32 changes: 30 additions & 2 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,30 @@ https://docs.threshold.network[image:https://img.shields.io/badge/docs-website-g
https://discord.gg/threshold[image:https://img.shields.io/badge/chat-Discord-5865f2.svg[Chat with us on Discord]]

Common libraries and tools used across Keep repositories. This repository is a
fork of https://github.com/keep-core/keep-common[`keep-core/keep-common`].
fork of https://github.com/keep-core/keep-common[`keep-core/keep-common`],
continuing independently from the upstream `v1.7.0` tag.

See link:RELEASE.md[Release guide] and link:CHANGELOG.md[Changelog] for versioning,
tagging, and history.

== Getting started

```
go mod tidy
go generate ./.../gen
go test ./...
```

== Toolchain & CI

- Go: 1.22 (CI uses `actions/setup-go@v4` with module cache).
- Checks: `go generate` (enforced clean), `go vet`, `go build`, `go test` via `gotestsum`.
- Security: `govulncheck` (informational), `gosec` pinned version.
- Lint: `golint` installed via `go install`.

== Releases

See link:RELEASE.md[Release guide] for versioning, tagging, and publishing steps.

== Directory structure

Expand Down Expand Up @@ -43,7 +66,12 @@ keep-common/
== Installation

* Clone this repo
* Install go v1.18: `$ brew install go@1.18`
* Install Go v1.22
* Generate go files: `$ go generate ./.../gen`
* Build the project: `$ go build ./...`
* Run tests: `$ go test ./...`

== Contributing

See link:CONTRIBUTING.adoc[Contribution Guide] for forking, signing, and PR
expectations; keep tests green and generators clean before review.
19 changes: 19 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Release Guide

Process for publishing tagged Go module releases for this fork of `keep-common`.

## Versioning
1) Use SemVer tags on `main`: `vX.Y.Z` when matching upstream versions; append `-tlabs.N` for fork-only releases (increment `N` for subsequent fork tags at the same base version).
2) Latest known upstream tag is `v1.7.0` from https://github.com/keep-network/keep-common (tracked via git tags). Upstream is unmaintained, so future releases proceed independently on this fork.

## Pre-release Checklist
1) Sync with upstream: pull the latest upstream tag/commit, resolve conflicts, and ensure CI is green.
2) Generators: `go generate ./.../gen`; verify the worktree is clean afterward.
3) Module sanity: `go mod tidy` (expect no diff) and `go list ./...` to confirm dependencies and packages resolve.
4) Quality gates: `go vet ./...` and `go test ./...`; add `go test -race ./...` for concurrency-heavy changes.
5) Changelog: update `CHANGELOG.md` with Added/Changed/Fixed/Breaking notes and mention the upstream commit/tag you synced.

## Tagging & Publishing
1) Tag: `git tag -a vX.Y.Z -m "Release vX.Y.Z"` (or `vX.Y.Z-tlabs.N` for fork-specific releases).
2) Push tag: `git push origin vX.Y.Z[-tlabs.N]`.
3) Create a GitHub release from the tag with the changelog excerpt and a note about the upstream baseline.
7 changes: 4 additions & 3 deletions pkg/chain/ethereum/ethutil/rate_limiter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,10 @@ func TestRateLimiter_RequestsPerSecondLimitOnly(t *testing.T) {
duration := time.Now().Sub(startTime)
averageRequestsPerSecond := float64(requests) / duration.Seconds()

// The actual average can exceed the limit a little bit.
// Here we set the maximum acceptable deviation to 5%.
maxDeviation := 0.05
// The actual average can exceed the limit a little bit because of
// scheduling jitter and coarse timer resolution. Allow a slightly
// wider deviation to avoid flakes on busy runners.
maxDeviation := 0.15

if averageRequestsPerSecond > (1+maxDeviation)*float64(requestsPerSecondLimit) {
t.Errorf(
Expand Down
3 changes: 2 additions & 1 deletion pkg/clientinfo/observer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ func TestObserve(t *testing.T) {
return 5000
}
gauge := &Gauge{}
ctx, _ := context.WithTimeout(context.Background(), 5*time.Millisecond)
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Millisecond)
defer cancel()

observer := &MetricObserver{input, gauge}

Expand Down
12 changes: 6 additions & 6 deletions tools/generators/promise/promise.go.tmpl
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{{/* This is a template for Promises */ -}}
// This is auto generated code
// Package async contains promise implementations generated for specific types.
// This is auto generated code.
package async

import (
Expand All @@ -11,11 +12,10 @@ import (
{{- end }}
)

// Promise represents an eventual completion of an ansynchronous operation
// and its resulting value. Promise can be either fulfilled or failed and
// it can happen only one time. All Promise operations are thread-safe.
//
// To create a promise use: `&{{ .Prefix }}Promise{}`
// {{ .Prefix }}Promise represents an eventual completion of an ansynchronous
// operation and its resulting value. Promise can be either fulfilled or
// failed and it can happen only one time. All Promise operations are
// thread-safe. To create a promise use: `&{{ .Prefix }}Promise{}`
type {{ .Prefix }}Promise struct {
mutex sync.Mutex
successFn func({{ .Type }})
Expand Down
12 changes: 6 additions & 6 deletions tools/generators/promise/promise_template_content.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ package main

// promiseTemplateContent contains the template string from promise.go.tmpl
var promiseTemplateContent = `{{/* This is a template for Promises */ -}}
// This is auto generated code
// Package async contains promise implementations generated for specific types.
// This is auto generated code.
package async

import (
Expand All @@ -14,11 +15,10 @@ import (
{{- end }}
)

// Promise represents an eventual completion of an ansynchronous operation
// and its resulting value. Promise can be either fulfilled or failed and
// it can happen only one time. All Promise operations are thread-safe.
//
// To create a promise use: ` + "`" + `&{{ .Prefix }}Promise{}` + "`" + `
// {{ .Prefix }}Promise represents an eventual completion of an ansynchronous
// operation and its resulting value. Promise can be either fulfilled or
// failed and it can happen only one time. All Promise operations are
// thread-safe. To create a promise use: ` + "`" + `&{{ .Prefix }}Promise{}` + "`" + `
type {{ .Prefix }}Promise struct {
mutex sync.Mutex
successFn func({{ .Type }})
Expand Down
Loading