Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
zhouop0 committed Feb 5, 2024
0 parents commit 78c1c49
Show file tree
Hide file tree
Showing 65 changed files with 13,128 additions and 0 deletions.
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ETHERMINT_IMAGE=ghcr.io/b2network/b2-committer:sha-f151b04
32 changes: 32 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<!-- < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < ☺
v ✰ Thanks for creating a PR! ✰
v Before smashing the submit button please review the checkboxes.
v If a checkbox is n/a - please still include it but + a little note why
☺ > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > -->

Closes: #XXX

## Description

<!-- Add a description of the changes that this PR introduces and the files that
are the most critical to review.
-->

______

For contributor use:

- [ ] Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
- [ ] Wrote unit
- [ ] Updated relevant documentation (`docs/`)
- [ ] Added relevant `godoc` [comments](https://blog.golang.org/godoc-documenting-go-code).
- [ ] Added a relevant changelog entry to the `Unreleased` section in `CHANGELOG.md`
- [ ] Re-reviewed `Files changed` in the Github PR explorer

______

For admin use:

- [ ] Added appropriate labels to PR (ex. `WIP`, `R4R`, `docs`, etc)
- [ ] Reviewers assigned
- [ ] Squashed all commits, uses message "Merge pull request #XYZ: [title]"
34 changes: 34 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Build
on:
pull_request:
branches:
- main
- dev

jobs:
cleanup-runs:
runs-on: ubuntu-latest
steps:
- uses: rokroskar/workflow-run-cleanup-action@master
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
if: "!startsWith(github.ref, 'refs/tags/') && github.ref != 'refs/heads/main'"

build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: 1.21
check-latest: true
- uses: technote-space/[email protected]
id: git_diff
with:
PATTERNS: |
**/**.go
go.mod
go.sum
- run: |
make build
if: env.GIT_DIFF
65 changes: 65 additions & 0 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Build docker images

on:
push:
branches:
- "main"
- "dev"
tags:
- "v*.*.*"
pull_request:
branches:
- "main"
- "dev"

jobs:
docker:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Git fetch everything
run: git fetch --prune --unshallow
-
name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
# list of Docker images to use as base name for tags
images: |
ghcr.io/${{ github.repository }}
# generate Docker tags based on the following events/attributes
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=sha
-
name: Set up QEMU
uses: docker/setup-qemu-action@v3
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
-
name: Login to GHCR
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
-
name: Build and push
uses: docker/build-push-action@v5
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
platforms: linux/amd64, linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
54 changes: 54 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Lint
# Lint runs golangci-lint over the entire ethermint repository This workflow is
# run on every pull request and push to main The `golangci` will pass without
# running if no *.{go, mod, sum} files have been changed.
on:
pull_request:
push:
branches:
- main
- dev
jobs:
golangci:
name: Run golangci-lint
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
# Required: setup-go, for all versions v3.0.0+ of golangci-lint
- uses: actions/setup-go@v4
with:
go-version: 1.21
check-latest: true
- uses: actions/checkout@v3
- uses: technote-space/[email protected]
with:
PATTERNS: |
**/**.go
go.mod
go.sum
- uses: golangci/[email protected]
with:
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
version: latest
args: --timeout 10m
github-token: ${{ secrets.github_token }}
# Check only if there are differences in the source code
if: env.GIT_DIFF
markdown-lint:
name: Run markdown-lint
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v3
- uses: technote-space/[email protected]
with:
PATTERNS: |
docs/**/*.md
README.md
- uses: nosborn/[email protected]
with:
files: .
config_file: .markdownlint.yml
ignore_path: .markdownlintignore
# Check only if there are differences in the source code
if: env.GIT_DIFF
30 changes: 30 additions & 0 deletions .github/workflows/markdown-links.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Check Markdown links
on:
pull_request:
paths:
- '**.md'
push:
branches:
- main
- dev
paths:
- '**.md'

jobs:
markdown-link-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: technote-space/[email protected]
id: git_diff
with:
PATTERNS: |
**/**.md
- uses: gaurav-nelson/github-action-markdown-link-check@master
with:
folder-path: "docs"
check-modified-files-only: "yes"
use-quiet-mode: "yes"
base-branch: "dev"
config-file: "mlc_config.json"
if: env.GIT_DIFF
28 changes: 28 additions & 0 deletions .github/workflows/proto.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Protobuf
# Protobuf runs buf (https://buf.build/) lint and check-breakage
# This workflow is only run when a .proto file has been changed
on:
pull_request:
paths:
- "proto/**"

jobs:
lint:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v3
- uses: bufbuild/[email protected]
- uses: bufbuild/buf-lint-action@v1
with:
input: "proto"

break-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: bufbuild/[email protected]
- uses: bufbuild/buf-breaking-action@v1
with:
input: "proto"
against: "https://github.com/${{ github.repository }}.git#branch=${{ github.event.pull_request.base.ref }},ref=HEAD~1,subdir=proto"
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# 默认忽略的文件
.idea
.DS_Store
b2-committer
54 changes: 54 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
stages:
- build
- deploy

build-image-dev:
stage: build
tags: [ ikey-shell ]
only:
- develop
script:
- GO111MODULE=on CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o ./build/main main.go
- docker buildx build -f Dockerfile.slim -t ${DOCKER_REGISTRY}/${IMAGE_NAME}:dev --push .

build-image-prod:
stage: build
tags: [ ikey-shell ]
only:
- tags
script:
- GIT_TERMINAL_PROMPT=1 GO111MODULE=on CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o ./build/main main.go
- docker buildx build -f Dockerfile.slim -t ${DOCKER_REGISTRY}/${IMAGE_NAME}:${CI_COMMIT_TAG} --push .


deploy-to-dev:
stage: deploy
tags: [ ikey-shell ]
only:
- develop
dependencies:
- build-image-dev
before_script:
- git config --global user.email "[email protected]"
- git config --global user.name "GitLab CI/CD"
script:
- git clone -b main ${GIT_SSH_REPO}
- cd argocd && sed -i "s/gitTag:.*/gitTag:\ '$CI_COMMIT_SHORT_SHA'/g" $PROJECT/dev-values.yaml
- git commit -am "update image tag to $CI_COMMIT_SHORT_SHA"
- git push origin main

deploy-to-prod:
stage: deploy
tags: [ ikey-shell ]
only:
- tags
dependencies:
- build-image-prod
before_script:
- git config --global user.email "[email protected]"
- git config --global user.name "GitLab CI/CD"
script:
- git clone -b main ${GIT_SSH_REPO}
- cd argocd && sed -i "s/tag:.*/tag:\ '$CI_COMMIT_TAG'/g" $PROJECT/prod-values.yaml
- git commit -am "update image tag to $CI_COMMIT_TAG"
- git push origin main
75 changes: 75 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
run:
tests: false
# timeout for analysis, e.g. 30s, 5m, default is 1m
# timeout: 5m

linters:
enable:
- bodyclose
# - depguard
- dogsled
- dupl
- errcheck
- goconst
- gocritic
- gofumpt
- revive
- gosec
- gosimple
- govet
- ineffassign
- lll
- misspell
- nakedret
- prealloc
- exportloopref
- staticcheck
- stylecheck
- typecheck
- unconvert
- unparam
- unused
- nolintlint
- asciicheck
- exportloopref
- gofumpt
- gomodguard
- whitespace

issues:
exclude-rules:
- path: _test\.go
linters:
- gosec
- linters:
- lll
source: "https://"
max-same-issues: 50

linters-settings:
lll:
line-length: 200
dogsled:
max-blank-identifiers: 3
golint:
min-confidence: 0
maligned:
suggest-new: true
misspell:
locale: US
nolintlint:
allow-unused: false
allow-leading-space: true
require-explanation: false
require-specific: false
gofumpt:
lang-version: "1.21"
gomodguard:
blocked:
versions: # List of blocked module version constraints
- https://github.com/etcd-io/etcd: # Blocked module with version constraint
version: ">= 3.4.10 || ~3.3.23" # Version constraint, see https://github.com/Masterminds/semver#basic-comparisons
reason: "CVE-2020-15114; CVE-2020-15136; CVE-2020-15115" # Reason why the version constraint exists. (Optional)
- https://github.com/dgrijalva/jwt-go: # Blocked module with version constraint
version: ">= 4.0.0-preview1" # Version constraint, see https://github.com/Masterminds/semver#basic-comparisons
reason: "CVE-2020-26160" # Reason why the version constraint exists. (Optional)
Loading

0 comments on commit 78c1c49

Please sign in to comment.