Skip to content

Commit

Permalink
Merge branch 'main' into chore/ramin/rename-cmd-parse-client
Browse files Browse the repository at this point in the history
  • Loading branch information
ramin authored Nov 6, 2023
2 parents 5ee17e9 + 33f5cd3 commit 9f9b3d0
Show file tree
Hide file tree
Showing 106 changed files with 1,632 additions and 1,213 deletions.
4 changes: 4 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ updates:
day: monday
time: "11:00"
open-pull-requests-limit: 10
labels:
- kind:deps
- package-ecosystem: gomod
directory: "/"
schedule:
Expand All @@ -30,3 +32,5 @@ updates:
day: monday
time: "11:00"
open-pull-requests-limit: 10
labels:
- kind:deps
14 changes: 14 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!--
Thank you for submitting a pull request!
Please make sure you have reviewed our contributors guide before submitting your
first PR.
Please ensure you've addressed or included references to any related issues.
Tips:
- Use keywords like "closes" or "fixes" followed by an issue number to automatically close related issues when the PR is merged (e.g., "closes #123" or "fixes #123").
- Describe the changes made in the PR.
- Ensure the PR has one of the required tags (kind:fix, kind:misc, kind:break!, kind:refactor, kind:feat, kind:deps, kind:docs, kind:ci, kind:chore, kind:testing)
-->
49 changes: 41 additions & 8 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,32 +22,56 @@ 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].3 # yamllint disable-line rule:line-length
uses: celestiaorg/.github/.github/workflows/[email protected].8 # yamllint disable-line rule:line-length
with:
dockerfile: Dockerfile

yamllint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: celestiaorg/.github/.github/actions/[email protected].3
- uses: celestiaorg/.github/.github/actions/[email protected].8

markdown-lint:
name: Markdown Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: 18
- run: |
npm install -g [email protected]
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,10 +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 All @@ -95,6 +127,7 @@ jobs:
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}

# TODO: permission issue, but not worth fixing as this should be refactored
# into the celestiaorg/.github repo, at which point any permission issues will
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/docker-build-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
merge_group:
push:
branches:
- "**"
- "main"
tags:
- "v[0-9]+.[0-9]+.[0-9]+"
- "v[0-9]+.[0-9]+.[0-9]+-alpha.[0-9]+"
Expand All @@ -18,6 +18,6 @@ jobs:
permissions:
contents: write
packages: write
uses: celestiaorg/.github/.github/workflows/[email protected].3 # yamllint disable-line rule:line-length
uses: celestiaorg/.github/.github/workflows/[email protected].8 # yamllint disable-line rule:line-length
with:
dockerfile: Dockerfile
37 changes: 27 additions & 10 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,12 +22,14 @@ jobs:

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

- name: golangci-lint
uses: golangci/[email protected]
with:
version: v1.54.2
version: v1.55
skip-pkg-cache: true
skip-build-cache: true

go_mod_tidy_check:
name: Go Mod Tidy Check
Expand All @@ -36,35 +40,44 @@ jobs:

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

- run: go mod tidy

- name: check for diff
run: git diff --exit-code

test_coverage:
needs: [lint, go_mod_tidy_check]
name: Unit Tests Coverage
runs-on: ubuntu-latest
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
env:
OS: ${{ matrix.os }}

steps:
- uses: actions/checkout@v4

- 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

- name: upload coverage
uses: codecov/[email protected]
with:
env_vars: OS
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage.txt
name: coverage-${{ matrix.os }}

unit_race_test:
needs: [lint, go_mod_tidy_check]
name: Run Unit Tests with Race Detector
runs-on: ubuntu-latest

Expand All @@ -74,12 +87,14 @@ 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]
name: Run Integration Tests
runs-on: ubuntu-latest

Expand All @@ -89,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
2 changes: 1 addition & 1 deletion .github/workflows/issue-label-automation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:

steps:
- name: Check for External Contributor
uses: tspascoal/get-user-teams-membership@v2
uses: tspascoal/get-user-teams-membership@v3
id: teamCheck
with:
username: ${{ github.actor }}
Expand Down
12 changes: 12 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,18 @@ archives:
{{- if .Arm }}v{{ .Arm }}{{ end }}
checksum:
name_template: "checksums.txt"
signs:
- artifacts: checksum
args:
[
"--batch",
"-u",
"{{ .Env.GPG_FINGERPRINT }}",
"--output",
"${signature}",
"--detach-sign",
"${artifact}",
]
snapshot:
name_template: "{{ incpatch .Version }}-next"
changelog:
Expand Down
19 changes: 15 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
FROM --platform=$BUILDPLATFORM docker.io/golang:1.21-alpine3.18 as builder

ARG TARGETPLATFORM
ARG BUILDPLATFORM
ARG TARGETOS
ARG TARGETARCH

ENV CGO_ENABLED=0
ENV GO111MODULE=on

# hadolint ignore=DL3018
RUN apk update && apk add --no-cache \
RUN uname -a && apk update && apk add --no-cache \
bash \
gcc \
git \
Expand All @@ -13,9 +21,11 @@ COPY go.mod go.sum ./
RUN go mod download
COPY . .

RUN make build && make cel-key
RUN uname -a &&\
CGO_ENABLED=${CGO_ENABLED} GOOS=${TARGETOS} GOARCH=${TARGETARCH} \
make build && make cel-key

FROM --platform=$BUILDPLATFORM docker.io/alpine:3.18.3
FROM docker.io/alpine:3.18.4

# Read here why UID 10001: https://github.com/hexops/dockerfile/blob/main/README.md#do-not-use-a-uid-below-10000
ARG UID=10001
Expand All @@ -28,7 +38,8 @@ ENV NODE_TYPE bridge
ENV P2P_NETWORK mocha

# hadolint ignore=DL3018
RUN apk update && apk add --no-cache \
RUN uname -a &&\
apk update && apk add --no-cache \
bash \
curl \
jq \
Expand Down
16 changes: 4 additions & 12 deletions api/gateway/availability.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ const heightAvailabilityEndpoint = "/data_available"
// AvailabilityResponse represents the response to a
// `/data_available` request.
type AvailabilityResponse struct {
Available bool `json:"available"`
Probability string `json:"probability_of_availability"`
Available bool `json:"available"`
}

func (h *Handler) handleHeightAvailabilityRequest(w http.ResponseWriter, r *http.Request) {
Expand All @@ -33,16 +32,10 @@ func (h *Handler) handleHeightAvailabilityRequest(w http.ResponseWriter, r *http
return
}

availResp := &AvailabilityResponse{
Probability: strconv.FormatFloat(
h.share.ProbabilityOfAvailability(r.Context()), 'g', -1, 64),
}

err = h.share.SharesAvailable(r.Context(), header.DAH)
err = h.share.SharesAvailable(r.Context(), header)
switch err {
case nil:
availResp.Available = true
resp, err := json.Marshal(availResp)
resp, err := json.Marshal(&AvailabilityResponse{Available: true})
if err != nil {
writeError(w, http.StatusInternalServerError, heightAvailabilityEndpoint, err)
return
Expand All @@ -52,8 +45,7 @@ func (h *Handler) handleHeightAvailabilityRequest(w http.ResponseWriter, r *http
log.Errorw("serving request", "endpoint", heightAvailabilityEndpoint, "err", err)
}
case share.ErrNotAvailable:
availResp.Available = false
resp, err := json.Marshal(availResp)
resp, err := json.Marshal(&AvailabilityResponse{Available: false})
if err != nil {
writeError(w, http.StatusInternalServerError, heightAvailabilityEndpoint, err)
return
Expand Down
2 changes: 1 addition & 1 deletion api/gateway/share.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func (h *Handler) getShares(ctx context.Context, height uint64, namespace share.
return nil, err
}

shares, err := h.share.GetSharesByNamespace(ctx, header.DAH, namespace)
shares, err := h.share.GetSharesByNamespace(ctx, header, namespace)
if err != nil {
return nil, err
}
Expand Down
Loading

0 comments on commit 9f9b3d0

Please sign in to comment.