Skip to content

Commit

Permalink
Merge branch 'main' into hy/scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
hacheigriega authored Oct 12, 2023
2 parents 14b9c6f + a3c4930 commit de69099
Show file tree
Hide file tree
Showing 10 changed files with 363 additions and 30 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/realease.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# triggered when a semantic version tag is pushed (vX.X.X)
name: Release
on:
push:
tags:
- "*"
- "v[0-9]+\\.[0-9]+\\.[0-9]+-alpha[0-9]+" # vX.X.X-alphaX
- "v[0-9]+\\.[0-9]+\\.[0-9]+-beta[0-9]+" # vX.X.X-betaX
- "v[0-9]+\\.[0-9]+\\.[0-9]+-rc[0-9]+" # vX.X.X-rcX
- "v[0-9]+\\.[0-9]+\\.[0-9]+" # vX.X.X
concurrency:
group: ci-${{ github.ref }}-${{ github.workflow }}
cancel-in-progress: true

jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-go@v4
with:
go-version: "1.21"
cache: true

- name: Set ENV
run: echo "COMET_VERSION=$(go list -m github.com/cometbft/cometbft | sed 's:.* ::')" >> $GITHUB_ENV

- name: goreleaser test-build
uses: goreleaser/goreleaser-action@v5
if: github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'Enable:ReleaseBuild')
with:
version: latest
args: build --clean --skip=validate
env:
COMET_VERSION: ${{ env.COMET_VERSION }}
- name: Release
uses: goreleaser/goreleaser-action@v5
if: startsWith(github.ref, 'refs/tags/')
with:
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COMET_VERSION: ${{ env.COMET_VERSION }}
84 changes: 84 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: Tests / Code Coverage
on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened, labeled]
merge_group:
types: [checks_requested]

permissions:
contents: read

concurrency:
group: ci-${{ github.ref }}-tests
cancel-in-progress: true

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
arch: [amd64, arm64]
targetos: [darwin, linux]
name: sedad ${{ matrix.targetos }}-${{ matrix.arch }}
steps:
- uses: actions/checkout@v4
- name: Cache binaries
id: cache-binaries
uses: actions/cache@v3
with:
path: ./cmd/sedad/sedad
key: sedad-${{ matrix.targetos }}-${{ matrix.arch }}
- uses: technote-space/[email protected]
with:
PATTERNS: |
**/**.go
go.mod
go.sum
- name: Setup go
if: steps.cache-binaries.outputs.cache-hit != 'true' && env.GIT_DIFF
uses: actions/setup-go@v4
with:
go-version: "1.19"
cache: true
env:
GOOS: ${{ matrix.targetos }}
GOARCH: ${{ matrix.arch }}
- name: Compile
if: steps.cache-binaries.outputs.cache-hit != 'true' && env.GIT_DIFF
run: |
go mod download
make build
tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version: "1.21"
check-latest: true
cache: true
cache-dependency-path: go.sum
- uses: technote-space/[email protected]
id: git_diff
with:
PATTERNS: |
**/*.go
go.mod
go.sum
**/go.mod
**/go.sum
**/Makefile
Makefile
- name: test & coverage report creation
if: env.GIT_DIFF
run: make test-unit-cover
- uses: actions/upload-artifact@v3
if: env.GIT_DIFF
with:
name: "${{ github.sha }}-${{ matrix.part }}-coverage"
path: ./${{ matrix.part }}profile.out

2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,7 @@ build/
.idea/
.vscode/
.DS_Store
dist/
/.act-event-file
scripts/testnet/config.sh
scripts/testnet/nodes
44 changes: 44 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
project_name: seda

env:
- CGO_ENABLED=1
# - GOOS=linux # for local m1 mac run

before:
hooks:
- go mod download

builds:
- main: ./cmd/seda-chaind
id: "sedad"
binary: sedad
mod_timestamp: "{{ .CommitTimestamp }}"
flags:
- -tags=badgerdb ledger netgo
- -trimpath
ldflags:
- -s -w -X main.commit={{.Commit}} -X main.date={{ .CommitDate }} -X github.com/cosmos/cosmos-sdk/version.Name=seda-chain -X github.com/cosmos/cosmos-sdk/version.AppName=sedad-chain -X github.com/cosmos/cosmos-sdk/version.Version={{ .Version }} -X github.com/cosmos/cosmos-sdk/version.Commit={{ .Commit }} -X github.com/cosmos/cosmos-sdk/version.BuildTags=netgo,ledger -X github.com/cometbft/cometbft/version.TMCoreSemVer={{ .Env.COMET_VERSION }}
goos:
- linux
goarch:
- amd64
# - arm64 # github only supports linux @ amd64 :'(

archives:
- id: tarball
format: tar.gz
wrap_in_directory: false # must not wrap into directory to support cosmwasm
name_template: "{{ .Binary }}-v{{ .Version }}-{{ .Os }}-{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}"
files:
- LICENSE
- README.md

snapshot:
name_template: SNAPSHOT-{{ .Commit }}

checksum:
name_template: SHA256SUMS-v{{.Version}}.txt
algorithm: sha256

changelog:
skip: false
35 changes: 35 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
FROM golang:1.21-alpine AS build-env

# Install minimum necessary dependencies
ENV PACKAGES curl make git libc-dev bash gcc linux-headers eudev-dev
RUN apk add --no-cache $PACKAGES


WORKDIR /go/src/github.com/sedaprotocol/seda-chain

# Optimized fetching of dependencies
COPY go.mod go.sum ./

RUN go mod download

# Copy and build the project
COPY . .

# Dockerfile Cross-Compilation Guide
# https://www.docker.com/blog/faster-multi-platform-builds-dockerfile-cross-compilation-guide
ARG TARGETOS TARGETARCH


RUN GOOS=${TARGETOS} GOARCH=${TARGETARCH} make build


FROM alpine:3

RUN apk add --no-cache curl make bash jq sed
COPY --from=build-env /go/src/github.com/cosmos/cosmos-sdk/build/seda-chaid /usr/bin/seda-chaind

EXPOSE 26656 26657 1317 9090

CMD ["seda-chaind", "start"]
STOPSIGNAL SIGTERM
WORKDIR /root
42 changes: 42 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -131,3 +131,45 @@ proto-update-deps:
$(DOCKER) run --rm -v $(CURDIR)/proto:/workspace --workdir /workspace $(protoImageName) buf mod update

.PHONY: proto-gen proto-lint proto-update-deps

###############################################################################
## Tests ##
###############################################################################

PACKAGES_UNIT=$(shell go list ./...)
TEST_PACKAGES=./...
TEST_TARGETS := test-unit test-unit-cover test-race
TEST_COVERAGE_PROFILE=coverage.txt

UNIT_TEST_TAGS = norace
TEST_RACE_TAGS = ""

ifeq ($(EXPERIMENTAL),true)
UNIT_TEST_TAGS += experimental
TEST_RACE_TAGS += experimental
endif

test-unit: ARGS=-timeout=10m -tags='$(UNIT_TEST_TAGS)'
test-unit: TEST_PACKAGES=$(PACKAGES_UNIT)
test-unit-cover: ARGS=-timeout=10m -tags='$(UNIT_TEST_TAGS)' -coverprofile=$(TEST_COVERAGE_PROFILE) -covermode=atomic
test-unit-cover: TEST_PACKAGES=$(PACKAGES_UNIT)
test-race: ARGS=-timeout=10m -race -tags='$(TEST_RACE_TAGS)'
test-race: TEST_PACKAGES=$(PACKAGES_UNIT)
$(TEST_TARGETS): run-tests

run-tests:
ifneq (,$(shell which tparse 2>/dev/null))
@echo "--> Running tests"
@go test -mod=readonly -json $(ARGS) $(TEST_PACKAGES) | tparse
else
@echo "--> Running tests"
@go test -mod=readonly $(ARGS) $(TEST_PACKAGES)
endif

cover-html: test-unit-cover
@echo "--> Opening in the browser"
@go tool cover -html=$(TEST_COVERAGE_PROFILE)

.PHONY: cover-html run-tests $(TEST_TARGETS)


2 changes: 1 addition & 1 deletion x/wasm-storage/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ func unzipWasm(wasm []byte) ([]byte, error) {
}
unzipped, err = ioutils.Uncompress(wasm, types.MaxWasmSize)
if err != nil {
return unzipped, nil
return nil, err
}
return unzipped, nil
}
Loading

0 comments on commit de69099

Please sign in to comment.