Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
k-yang authored Feb 11, 2025
2 parents 21b8059 + b0131fe commit e29e6c7
Show file tree
Hide file tree
Showing 8 changed files with 127 additions and 3 deletions.
74 changes: 74 additions & 0 deletions .github/workflows/golangcli-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: Linter

# Run on every main merge and on PRs.
on:
push:
branches: ["main"]
paths: ["**.go", "**.proto", "go.mod", "go.sum", "**go.mod", "**go.sum"]
pull_request:
paths: ["**.go", "**.proto", "go.mod", "go.sum", "**go.mod", "**go.sum"]

# Allow concurrent runs on main/release branches but isolates other branches
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.head_ref }}
cancel-in-progress: ${{ ! (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/release/')) }}

permissions:
contents: read

jobs:
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-go@v5
with:
go-version: 1.21
cache: false # the golangci-lint action already caches for us (https://github.com/golangci/golangci-lint-action#performance)

# Use GitHub actions output paramters to get go paths. For more info, see
# https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions
- name: "Set output variables for go cache"
id: go-cache-paths
run: |
echo "go-build-cache=$(go env GOCACHE)" >> $GITHUB_OUTPUT
echo "go-mod-cache=$(go env GOMODCACHE)" >> $GITHUB_OUTPUT
- name: "Go build cache"
uses: actions/cache@v4
with:
path: ${{ steps.go-cache-paths.outputs.go-build-cache }}
key: go-build-cache-${{ hashFiles('**/go.sum') }}

- name: "Go mod cache"
uses: actions/cache@v4
with:
path: ${{ steps.go-cache-paths.outputs.go-mod-cache }}
key: go-mod-cache-${{ hashFiles('**/go.sum') }}

- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
version: v1.54.2

# Optional: working directory, useful for monorepos
# working-directory: somedir

# Optional: golangci-lint command line arguments.
args: --fix=false --timeout=5m

# 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 all caching functionality will be complete disabled,
# takes precedence over all other caching options.
# skip-cache: 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
18 changes: 18 additions & 0 deletions .github/workflows/pr-tittle-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: PR lint

on:
pull_request:
types: [opened, reopened, synchronize, edited]

jobs:
pr-lint:
runs-on: ubuntu-latest
steps:
- uses: seferov/[email protected]
with:
# taken from https://gist.github.com/marcojahn/482410b728c31b221b70ea6d2c433f0c
title-regex: '^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test){1}(\([\w\-\.]+\))?(!)?: ([\w ])+([\s\S]*)'
# title-regex-flags (Optional)
title-regex-flags: "g"
# error-message (Optional)
error-message: "Please follow conventional commit style: https://www.conventionalcommits.org/en/v1.0.0/"
17 changes: 17 additions & 0 deletions .github/workflows/skip-golangci-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Linter

on:
pull_request:
# paths-ignore makes the action run when the given paths are unchanged
# See "Handling skipped but required checks" in
# https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/defining-the-mergeability-of-pull-requests/troubleshooting-required-status-checks#handling-skipped-but-required-checks
paths-ignore: ["**.go", "**.proto", "go.mod", "go.sum"]

jobs:
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- name: skip-golangci
run: |
echo "job: golangci was skipped since Golang files were not changed."
7 changes: 6 additions & 1 deletion feeder/eventstream/stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/rs/zerolog"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"
"google.golang.org/grpc/credentials/insecure"
)

var _ types.EventStream = (*Stream)(nil)
Expand All @@ -24,7 +25,7 @@ type wsI interface {

// Dial opens two connections to the given endpoint, one for the websocket and one for the oracle grpc.
func Dial(tendermintRPCEndpoint string, grpcEndpoint string, enableTLS bool, logger zerolog.Logger) *Stream {
transportDialOpt := grpc.WithInsecure()
var transportDialOpt grpc.DialOption

if enableTLS {
transportDialOpt = grpc.WithTransportCredentials(
Expand All @@ -34,6 +35,10 @@ func Dial(tendermintRPCEndpoint string, grpcEndpoint string, enableTLS bool, log
},
),
)
} else {
transportDialOpt = grpc.WithTransportCredentials(
insecure.NewCredentials(),
)
}

conn, err := grpc.Dial(grpcEndpoint, transportDialOpt)
Expand Down
3 changes: 2 additions & 1 deletion feeder/eventstream/stream_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
)

type IntegrationTestSuite struct {
Expand Down Expand Up @@ -57,7 +58,7 @@ func (s *IntegrationTestSuite) SetupSuite() {
enableTLS,
zerolog.New(s.logs))

conn, err := grpc.Dial(grpcEndpoint, grpc.WithInsecure())
conn, err := grpc.Dial(grpcEndpoint, grpc.WithTransportCredentials(insecure.NewCredentials()))
require.NoError(s.T(), err)
s.oracleClient = oracletypes.NewQueryClient(conn)
}
Expand Down
7 changes: 6 additions & 1 deletion feeder/priceposter/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"github.com/rs/zerolog"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"
"google.golang.org/grpc/credentials/insecure"
)

var _ types.PricePoster = (*Client)(nil)
Expand Down Expand Up @@ -55,7 +56,7 @@ func Dial(
feeder sdk.AccAddress,
logger zerolog.Logger,
) *Client {
transportDialOpt := grpc.WithInsecure()
var transportDialOpt grpc.DialOption

if enableTLS {
transportDialOpt = grpc.WithTransportCredentials(
Expand All @@ -65,6 +66,10 @@ func Dial(
},
),
)
} else {
transportDialOpt = grpc.WithTransportCredentials(
insecure.NewCredentials(),
)
}

conn, err := grpc.Dial(grpcEndpoint, transportDialOpt)
Expand Down
3 changes: 3 additions & 0 deletions feeder/priceprovider/sources/coingecko_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ func TestCoingeckoPriceUpdate(t *testing.T) {
defer httpmock.DeactivateAndReset()

t.Run("success", func(t *testing.T) {
httpmock.Reset()
httpmock.RegisterResponder(
"GET", FreeLink+"simple/price?ids=bitcoin%2Cethereum&vs_currencies=usd",
httpmock.NewStringResponder(200, "{\"bitcoin\":{\"usd\":23829},\"ethereum\":{\"usd\":1676.85}}"),
Expand All @@ -41,6 +42,7 @@ func TestCoingeckoWithConfig(t *testing.T) {
defer httpmock.DeactivateAndReset()

t.Run("providing valid config", func(t *testing.T) {
httpmock.Reset()
httpmock.RegisterResponder(
"GET", PaidLink+"simple/price?ids=bitcoin%2Cethereum&vs_currencies=usd&"+ApiKeyParam+"=1234567890",
httpmock.NewStringResponder(200, "{\"bitcoin\":{\"usd\":23829},\"ethereum\":{\"usd\":1676.85}}"),
Expand Down Expand Up @@ -72,6 +74,7 @@ func TestCoingeckoWithConfig(t *testing.T) {
})

t.Run("providing config without api_key ignores and calls free endpoint", func(t *testing.T) {
httpmock.Reset()
httpmock.RegisterResponder(
"GET", FreeLink+"simple/price?ids=bitcoin%2Cethereum&vs_currencies=usd",
httpmock.NewStringResponder(200, "{\"bitcoin\":{\"usd\":23829},\"ethereum\":{\"usd\":1676.85}}"),
Expand Down
1 change: 1 addition & 0 deletions feeder/priceprovider/sources/coinmarketcap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ func TestCoinmarketcapPriceUpdate(t *testing.T) {
defer httpmock.DeactivateAndReset()

t.Run("success", func(t *testing.T) {
httpmock.Reset()
httpmock.RegisterResponder(
"GET", link+"?slug=bitcoin%2Cethereum",
httpmock.NewStringResponder(200, "{\"status\": {\"error_code\":0},\"data\":{\"1\":{\"slug\":\"bitcoin\",\"quote\":{\"USD\":{\"price\":23829}}}, \"100\":{\"slug\":\"ethereum\",\"quote\":{\"USD\":{\"price\":1676.85}}}}}"),
Expand Down

0 comments on commit e29e6c7

Please sign in to comment.