Skip to content

Commit

Permalink
Merge branch 'main' into chore/ramin/jwt-newline
Browse files Browse the repository at this point in the history
  • Loading branch information
ramin authored Oct 30, 2023
2 parents 4552536 + 2066478 commit 4970f8d
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 46 deletions.
36 changes: 31 additions & 5 deletions .github/workflows/ci_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ on:
- "v*"
pull_request:
workflow_dispatch:
# Inputs the workflow accepts.
inputs:
version:
# Friendly description to be shown in the UI instead of 'name'
Expand All @@ -23,6 +22,27 @@ on:
- major

jobs:
# set up go version for use through pipelines, setting
# variable one time and setting outputs to access passing it
# to other jobs
setup:
runs-on: ubuntu-latest
env:
# upgrade go version throughout pipeline here
GO_VERSION: "1.21"
outputs:
go-version: ${{ steps.set-vars.outputs.go-version }}
branch: ${{ steps.trim_ref.outputs.branch }}
steps:
- name: Set go version
id: set-vars
run: echo "go-version=${{env.GO_VERSION}}" >> "$GITHUB_OUTPUT"

- name: Trim branch name
id: trim_ref
run: |
echo "branch=$(${${{ github.ref }}:11})" >> $GITHUB_OUTPUT
# Dockerfile Linting
hadolint:
uses: celestiaorg/.github/.github/workflows/[email protected] # yamllint disable-line rule:line-length
Expand All @@ -48,7 +68,10 @@ jobs:
markdownlint --config .markdownlint.yaml '**/*.md'
go-ci:
needs: setup
uses: ./.github/workflows/go-ci.yml
with:
go-version: ${{ needs.setup.outputs.go-version }}

# If this was a workflow dispatch event, we need to generate and push a tag
# for goreleaser to grab
Expand All @@ -58,6 +81,7 @@ jobs:
permissions: "write-all"
steps:
- uses: actions/checkout@v4

- name: Bump version and push tag
# Placing the if condition here is a workaround for needing to block
# on this step during workflow dispatch events but the step not
Expand All @@ -66,12 +90,10 @@ jobs:
# in goreleaser not running either.
if: ${{ github.event_name == 'workflow_dispatch' }}
uses: mathieudutour/[email protected]

- name: Version Release
uses: celestiaorg/.github/.github/actions/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
default_bump: ${{ inputs.version }}
release_branches: ${{ needs.setup.outputs.branch }}

# Generate the release with goreleaser to include pre-built binaries
goreleaser:
Expand All @@ -83,16 +105,20 @@ jobs:
permissions: "write-all"
steps:
- uses: actions/checkout@v4

- run: git fetch --force --tags

- uses: actions/setup-go@v4
with:
go-version: 1.21
go-version: ${{ needs.setup.outputs.go-version }}

- name: Import GPG key
id: import_gpg
uses: crazy-max/ghaction-import-gpg@v4
with:
gpg_private_key: ${{ secrets.GPG_SIGNING_KEY }}
passphrase: ${{ secrets.GPG_PASSPHRASE }}

# Generate the binaries and release
- uses: goreleaser/goreleaser-action@v5
with:
Expand Down
21 changes: 13 additions & 8 deletions .github/workflows/go-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ name: Go CI

on:
workflow_call:

env:
GO_VERSION: '1.21'
inputs:
go-version:
description: 'Go version'
required: true
type: string

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
Expand All @@ -20,7 +22,7 @@ jobs:

- uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
go-version: ${{ inputs.go-version }}

- name: golangci-lint
uses: golangci/[email protected]
Expand All @@ -38,7 +40,7 @@ jobs:

- uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
go-version: ${{ inputs.go-version }}

- run: go mod tidy

Expand All @@ -61,7 +63,7 @@ jobs:
- name: set up go
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
go-version: ${{ inputs.go-version }}

- name: run unit tests
run: make test-unit
Expand All @@ -85,10 +87,11 @@ jobs:
- name: set up go
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
go-version: ${{ inputs.go-version }}

- name: execute test run
run: make test-unit-race
continue-on-error: true

integration_test:
needs: [lint, go_mod_tidy_check]
Expand All @@ -101,10 +104,12 @@ jobs:
- name: set up go
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
go-version: ${{ inputs.go-version }}

- name: Swamp Tests
run: make test-swamp
continue-on-error: true

- name: Swamp Tests with Race Detector
run: make test-swamp-race
continue-on-error: true
10 changes: 10 additions & 0 deletions nodebuilder/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"time"

logging "github.com/ipfs/go-log/v2"
"github.com/libp2p/go-libp2p/core/peer"
"github.com/pyroscope-io/client/pyroscope"
otelpyroscope "github.com/pyroscope-io/otel-profiling-go"
Expand Down Expand Up @@ -208,5 +209,14 @@ func initializeMetrics(
},
})
otel.SetMeterProvider(provider)
otel.SetErrorHandler(&loggingErrorHandler{})
return nil
}

var metricsLogger = logging.Logger("otlp")

type loggingErrorHandler struct{}

func (loggingErrorHandler) Handle(err error) {
metricsLogger.Error(err)
}
54 changes: 21 additions & 33 deletions nodebuilder/share/cmd/share.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package cmd

import (
"context"
"encoding/hex"
"encoding/json"
"fmt"
"strconv"

"github.com/spf13/cobra"

rpc "github.com/celestiaorg/celestia-node/api/rpc/client"
cmdnode "github.com/celestiaorg/celestia-node/cmd"
"github.com/celestiaorg/celestia-node/header"
"github.com/celestiaorg/celestia-node/share"
Expand Down Expand Up @@ -39,13 +41,8 @@ var sharesAvailableCmd = &cobra.Command{
}
defer client.Close()

raw, err := parseJSON(args[0])
if err != nil {
return err
}
eh, err := getExtendedHeaderFromCmdArg(cmd.Context(), client, args[0])

var eh *header.ExtendedHeader
err = json.Unmarshal(raw, &eh)
if err != nil {
return err
}
Expand All @@ -72,7 +69,7 @@ var sharesAvailableCmd = &cobra.Command{
}

var getSharesByNamespaceCmd = &cobra.Command{
Use: "get-by-namespace [extended header, namespace]",
Use: "get-by-namespace (height | hash) namespace",
Short: "Gets all shares from an EDS within the given namespace.",
Args: cobra.ExactArgs(2),
RunE: func(cmd *cobra.Command, args []string) error {
Expand All @@ -82,13 +79,8 @@ var getSharesByNamespaceCmd = &cobra.Command{
}
defer client.Close()

raw, err := parseJSON(args[0])
if err != nil {
return err
}
eh, err := getExtendedHeaderFromCmdArg(cmd.Context(), client, args[0])

var eh *header.ExtendedHeader
err = json.Unmarshal(raw, &eh)
if err != nil {
return err
}
Expand All @@ -104,7 +96,7 @@ var getSharesByNamespaceCmd = &cobra.Command{
}

var getShare = &cobra.Command{
Use: "get-share [extended header, row, col]",
Use: "get-share (height | hash) row col",
Short: "Gets a Share by coordinates in EDS.",
Args: cobra.ExactArgs(3),
RunE: func(cmd *cobra.Command, args []string) error {
Expand All @@ -114,13 +106,8 @@ var getShare = &cobra.Command{
}
defer client.Close()

raw, err := parseJSON(args[0])
if err != nil {
return err
}
eh, err := getExtendedHeaderFromCmdArg(cmd.Context(), client, args[0])

var eh *header.ExtendedHeader
err = json.Unmarshal(raw, &eh)
if err != nil {
return err
}
Expand Down Expand Up @@ -158,8 +145,8 @@ var getShare = &cobra.Command{
}

var getEDS = &cobra.Command{
Use: "get-eds [extended header]",
Short: "Gets the full EDS identified by the given extended header",
Use: "get-eds (height | hash)",
Short: "Gets the full EDS identified by the given block height",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
client, err := cmdnode.ParseClientFromCtx(cmd.Context())
Expand All @@ -168,13 +155,8 @@ var getEDS = &cobra.Command{
}
defer client.Close()

raw, err := parseJSON(args[0])
if err != nil {
return err
}
eh, err := getExtendedHeaderFromCmdArg(cmd.Context(), client, args[0])

var eh *header.ExtendedHeader
err = json.Unmarshal(raw, &eh)
if err != nil {
return err
}
Expand All @@ -184,8 +166,14 @@ var getEDS = &cobra.Command{
},
}

func parseJSON(param string) (json.RawMessage, error) {
var raw json.RawMessage
err := json.Unmarshal([]byte(param), &raw)
return raw, err
func getExtendedHeaderFromCmdArg(ctx context.Context, client *rpc.Client, arg string) (*header.ExtendedHeader, error) {
hash, err := hex.DecodeString(arg)
if err == nil {
return client.Header.GetByHash(ctx, hash)
}
height, err := strconv.ParseUint(arg, 10, 64)
if err != nil {
return nil, fmt.Errorf("can't parse the height/hash argument: %w", err)
}
return client.Header.GetByHeight(ctx, height)
}

0 comments on commit 4970f8d

Please sign in to comment.