Skip to content

Commit

Permalink
Merge branch 'main' into mantrachain/govulncheck
Browse files Browse the repository at this point in the history
  • Loading branch information
mantrachain-support authored Sep 17, 2024
2 parents 99d32e5 + d4632f7 commit 647a454
Show file tree
Hide file tree
Showing 146 changed files with 46,950 additions and 443 deletions.
5 changes: 5 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "MANTRA Chain Dev Container",
"image": "mcr.microsoft.com/devcontainers/go:1-1.23-bookworm",
"postCreateCommand": "curl https://get.ignite.com/cli | bash && mv ignite /usr/local/go/bin"
}
7 changes: 5 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
on: [push, pull_request]
name: Test
name: Build and validate genesis
jobs:
test:
strategy:
Expand All @@ -12,4 +12,7 @@ jobs:
with:
go-version: ${{ matrix.go-version }}
- uses: actions/checkout@v4
- run: go build ./...
- name: install
run: make install
- name: validate genesis
run: mantrachaind genesis validate-genesis networks/dukong/genesis.json
10 changes: 10 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ on:
push:
tags:
- "v*.*.*"
workflow_dispatch:
inputs:
release_tag:
description: "The desired tag for the release (e.g. v0.1.0)."
required: true

env:
REGISTRY: ghcr.io
Expand All @@ -22,6 +27,9 @@ jobs:
runs-on: chain-runner
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.inputs.release_tag || github.ref }}

- uses: docker/setup-qemu-action@v3

Expand All @@ -43,6 +51,8 @@ jobs:
chain: mantrachain
chains-spec-file: chains.yaml
clone-key: ${{ secrets.GIT_CLONE_KEY }}
heighliner-owner: ${{ github.repository_owner }}
heighliner-tag: v1.6.4
github-organization: ${{ github.repository_owner }}
github-repo: ${{ github.event.repository.name }}
registry: ghcr.io/${{ env.OWNER_LC }}
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
strategy:
matrix:
go: [stable]
os: [ubuntu-latest]
os: [ubuntu-latest, macos-latest]
name: lint
runs-on: ${{ matrix.os }}
steps:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/osv-scanner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ permissions:
jobs:
scan-scheduled:
if: ${{ github.event_name == 'push' || github.event_name == 'schedule' }}
uses: "google/osv-scanner-action/.github/workflows/osv-scanner-reusable.yml@678a866dcba398c8ed0124a09928d250f187b52a" # v1.8.4
uses: "google/osv-scanner-action/.github/workflows/osv-scanner-reusable.yml@f0e6719deb666cd19a0b56bc56d01161bd848b4f" # v1.8.5
with:
# Example of specifying custom arguments
scan-args: |-
Expand All @@ -39,7 +39,7 @@ jobs:
./
scan-pr:
if: ${{ github.event_name == 'pull_request' || github.event_name == 'merge_group' }}
uses: "google/osv-scanner-action/.github/workflows/osv-scanner-reusable-pr.yml@678a866dcba398c8ed0124a09928d250f187b52a" # v1.8.4
uses: "google/osv-scanner-action/.github/workflows/osv-scanner-reusable-pr.yml@f0e6719deb666cd19a0b56bc56d01161bd848b4f" # v1.8.5
with:
# Example of specifying custom arguments
scan-args: |-
Expand Down
52 changes: 50 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# This workflow creates a release using goreleaser
# via the 'make release' command.

name: Create release

on:
Expand All @@ -17,19 +15,69 @@ permissions:
contents: write

jobs:
build:
name: Build - ${{ matrix.platform.name }}
runs-on: ${{ matrix.platform.runner || 'chain-runner' }}
strategy:
matrix:
platform:
- name: Linux x86_64
ids: mantrachaind-linux-amd64
cross: false
- name: Linux aarch64
ids: mantrachaind-linux-arm64
runner: ubuntu-arm64
docker-platform: linux/arm64
cross: false
- name: MacOS x86_64 and aarch64
ids: mantrachaind-darwin-amd64,mantrachaind-darwin-arm64
cross: true

steps:
- name: Checkout Git repo
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.inputs.release_tag || github.ref }}

- name: Make goreleaser build
run: |
make goreleaser-build-local
env:
GORELEASER_IDS: ${{ matrix.platform.ids }}
GORELEASER_CROSS_DISABLE: ${{ !matrix.platform.cross }}
GORELEASER_PLATFORM: ${{ matrix.platform.docker-platform || 'linux/amd64' }}

- name: Store artifact
uses: actions/upload-artifact@v4
with:
name: release-${{ github.sha }}-${{ matrix.platform.name }}
path: dist/*/
retention-days: 1

release:
name: Create release
needs: [build]
runs-on: chain-runner
steps:
- name: Check out repository code
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.inputs.release_tag || github.ref }}

# Download all artifacts
- uses: actions/download-artifact@v4
with:
path: dist-merged
pattern: release-${{ github.sha }}-*
merge-multiple: true
- name: Make release
run: |
make release
env:
REPO_OWNER: ${{ github.repository_owner }}
REPO_NAME: ${{ github.event.repository.name }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GORELEASER_SKIP: validate
GORELEASER_CONFIG: ./scripts/ci-goreleaser/.goreleaser.yaml
51 changes: 51 additions & 0 deletions .github/workflows/visualize_genesis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Generate Genesis PDF Report

on:
pull_request:
branches:
- main
push:
branches:
- main
paths:
- 'networks/dukong/genesis.json'
- 'networks/visualize_genesis.py'
- 'networks/template.tex'
- '.github/workflows/generate_pdf.yml'
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'

- name: Install Dependencies
run: |
sudo apt-get update
sudo apt-get install -y pandoc texlive-xetex texlive-fonts-recommended texlive-latex-recommended texlive-fonts-extra
pip install matplotlib
- name: Run visualize_genesis.py
working-directory: networks
run: |
python visualize_genesis.py
- name: Convert Markdown to PDF
working-directory: networks
run: |
pandoc report.md -o report.pdf --from markdown --template=template.tex --pdf-engine=xelatex
- name: Upload PDF Artifact
uses: actions/upload-artifact@v4
with:
name: Genesis Report
path: networks/report.pdf

1 change: 0 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ linters:
- thelper
- tparallel
- typecheck
- thelper
- unconvert
- unused
- whitespace
Expand Down
18 changes: 2 additions & 16 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,14 @@ builds:
binary: mantrachaind
hooks:
pre:
- apk add --update linux-headers
- wget https://github.com/CosmWasm/wasmvm/releases/download/{{ .Env.COSMWASM_VERSION }}/libwasmvm_muslc.x86_64.a -O /lib/libwasmvm_muslc.x86_64.a
# verify checksum
- sha256sum /lib/libwasmvm_muslc.x86_64.a | grep $(cat /tmp/checksums.txt | grep libwasmvm_muslc.x86_64 | cut -d ' ' -f 1) || exit 1
goos:
- linux
goarch:
- amd64
env:
- CC=x86_64-linux-gnu-gcc
flags:
- -mod=readonly
- -trimpath
Expand All @@ -113,15 +112,14 @@ builds:
binary: mantrachaind
hooks:
pre:
- apk add --update linux-headers
- wget https://github.com/CosmWasm/wasmvm/releases/download/{{ .Env.COSMWASM_VERSION }}/libwasmvm_muslc.aarch64.a -O /lib/libwasmvm_muslc.aarch64.a
# verify checksum
- sha256sum /lib/libwasmvm_muslc.aarch64.a | grep $(cat /tmp/checksums.txt | grep libwasmvm_muslc.aarch64 | cut -d ' ' -f 1) || exit 1
goos:
- linux
goarch:
- arm64
env:
- CC=aarch64-linux-gnu-gcc
flags:
- -mod=readonly
- -trimpath
Expand All @@ -141,17 +139,9 @@ builds:
- muslc
- osusergo

universal_binaries:
- id: mantrachaind-darwin-universal
ids:
- mantrachaind-darwin-amd64
- mantrachaind-darwin-arm64
replace: false

archives:
- id: zipped
builds:
# - mantrachaind-darwin-universal
- mantrachaind-linux-amd64
- mantrachaind-linux-arm64
- mantrachaind-darwin-amd64
Expand All @@ -162,7 +152,6 @@ archives:
- none*
- id: binaries
builds:
# - mantrachaind-darwin-universal
- mantrachaind-linux-amd64
- mantrachaind-linux-arm64
- mantrachaind-darwin-amd64
Expand Down Expand Up @@ -207,9 +196,6 @@ release:
mode: replace
draft: true

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

# Docs: https://goreleaser.com/customization/announce/
# We could automatically announce the release in
# - discord
Expand Down
28 changes: 20 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ $(BUILDDIR)/:
mkdir -p $(BUILDDIR)/

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

test: test-unit
Expand All @@ -149,7 +149,12 @@ test-connect: build-image
###############################################################################
### Release ###
###############################################################################
ifeq ($(strip $(GORELEASER_CROSS_DISABLE)),true)
GORELEASER_IMAGE := goreleaser/goreleaser:v2.3.1
else
GORELEASER_IMAGE := ghcr.io/goreleaser/goreleaser-cross:v$(GO_VERSION)
endif
GORELEASER_PLATFORM ?= linux/amd64
COSMWASM_VERSION := $(shell go list -m github.com/CosmWasm/wasmvm/v2 | sed 's/.* //')
REPO_OWNER ?= MANTRA-Chain
REPO_NAME ?= mantrachain
Expand All @@ -170,16 +175,16 @@ release:
-e REPO_NAME=$(REPO_NAME) \
-v `pwd`:/go/src/mantrachaind \
-w /go/src/mantrachaind \
--platform=linux/amd64 \
--platform=$(GORELEASER_PLATFORM) \
$(GORELEASER_IMAGE) \
release \
release $(if $(GORELEASER_SKIP),--skip=$(GORELEASER_SKIP)) $(if $(GORELEASER_CONFIG),--config=$(GORELEASER_CONFIG)) \
--clean
else
release:
@echo "Error: $(MISSING_TOKEN) is not defined. Please define it before running 'make release'."
endif

# uses goreleaser to create static binaries for linux an darwin on local machine
# uses goreleaser to create static binaries for linux and darwin on local machine
# platform is set because not setting it results in broken builds for linux-amd64
goreleaser-build-local:
docker run \
Expand All @@ -190,12 +195,19 @@ goreleaser-build-local:
-e REPO_NAME=$(REPO_NAME) \
-v `pwd`:/go/src/mantrachaind \
-w /go/src/mantrachaind \
--platform=linux/amd64 \
--platform=$(GORELEASER_PLATFORM) \
$(GORELEASER_IMAGE) \
release \
--snapshot \
--skip=publish \
build $(if $(GORELEASER_IDS),$(shell echo $(GORELEASER_IDS) | tr ',' ' ' | sed 's/[^ ]*/--id=&/g')) \
--skip=validate \
--clean \
--timeout 90m \
--verbose

.PHONY: build build-linux lint release

###############################################################################
### Mocks ###
###############################################################################

mocks:
go generate ./...
Loading

0 comments on commit 647a454

Please sign in to comment.