Skip to content

Commit

Permalink
develop: setup the initial version
Browse files Browse the repository at this point in the history
  • Loading branch information
forcodedancing committed Oct 10, 2023
1 parent 5097b46 commit 763fbf3
Show file tree
Hide file tree
Showing 96 changed files with 15,196 additions and 0 deletions.
30 changes: 30 additions & 0 deletions .github/ISSUE_TEMPLATE/bug.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
name: Report a bug
about: Something with greenfield-relayer is not working as expected
title: ''
labels: 'type:bug'
assignees: ''
---

#### System information

Relayer version: (if getting from release page)
OS & Version: Windows/Linux/OSX
Commit hash : (if `develop`)

#### Expected behaviour


#### Actual behaviour


#### Steps to reproduce the behaviour


#### Backtrace

````
[backtrace]
````

When submitting logs: please submit them as text and not screenshots.
17 changes: 17 additions & 0 deletions .github/ISSUE_TEMPLATE/feature.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
name: Request a feature
about: Report a missing feature - e.g. as a step before submitting a PR
title: ''
labels: 'type:feature'
assignees: ''
---

# Rationale

Why should this feature exist?
What are the use-cases?

# Implementation

Do you have ideas regarding the implementation of this feature?
Are you willing to implement this feature?
9 changes: 9 additions & 0 deletions .github/ISSUE_TEMPLATE/question.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
name: Ask a question
about: Something is unclear
title: ''
labels: 'type:docs'
assignees: ''
---

This should only be used in very rare cases e.g. if you are not 100% sure if something is a bug or asking a question that leads to improving the documentation. For general questions please use [discord](https://discord.gg/bnbchain).
17 changes: 17 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
### Description

add a description of your changes here...

### Rationale

tell us why we need these changes...

### Example

add an example CLI or API response...

### Changes

Notable changes:
* add each change in a bullet point here
* ...
54 changes: 54 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Build Test

on:
push:
branches:
- master
- develop

pull_request:
branches:
- master
- develop

jobs:
build-test:
strategy:
matrix:
go-version: [1.20.x]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
env:
GOPRIVATE: github.com/bnb-chain
GH_ACCESS_TOKEN: ${{ secrets.GH_TOKEN }}
steps:
- name: Install Go
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}

- name: Checkout code
uses: actions/checkout@v3

- uses: actions/cache@v3
with:
# In order:
# * Module download cache
# * Build cache (Linux)
# * Build cache (Mac)
# * Build cache (Windows)
path: |
~/go/pkg/mod
~/.cache/go-build
~/Library/Caches/go-build
%LocalAppData%\go-build
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Setup GitHub Token
run: git config --global url.https://[email protected]/.insteadOf https://github.com/

- name: Test Build
run: |
make build
56 changes: 56 additions & 0 deletions .github/workflows/docker-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Docker

on:
push:
# Publish `v1.2.3` tags as releases.
tags:
- v*

env:
IMAGE_NAME: ghcr.io/${{ github.repository }}
IMAGE_SOURCE: https://github.com/${{ github.repository }}

jobs:
# Push image to GitHub Packages.
push:
runs-on: ubuntu-latest
if: github.event_name == 'push'

steps:
- uses: actions/checkout@v3

- name: Build image
run: |
docker build . \
--label "org.opencontainers.image.source=${IMAGE_SOURCE}" \
--label "org.opencontainers.image.revision=$(git rev-parse HEAD)" \
--label "org.opencontainers.image.version=$(git describe --tags --abbrev=0)" \
-f ./server-distroless.dockerfile -t "${IMAGE_NAME}:server-distroless"
docker build . \
--label "org.opencontainers.image.source=${IMAGE_SOURCE}" \
--label "org.opencontainers.image.revision=$(git rev-parse HEAD)" \
--label "org.opencontainers.image.version=$(git describe --tags --abbrev=0)" \
-f ./monitor-distroless.dockerfile -t "${IMAGE_NAME}:monitor-distroless"
- name: Login to GHCR
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Push image
run: |
# Strip git ref prefix from version
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
# Strip "v" prefix from tag name
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
# Use Docker `latest` tag convention
[ "$VERSION" == "master" ] && VERSION=latest
echo IMAGE_NAME=$IMAGE_NAME
echo VERSION=$VERSION
docker tag ${IMAGE_NAME}:server-distroless $IMAGE_NAME:$VERSION-server-distroless
docker tag ${IMAGE_NAME}:monitor-distroless $IMAGE_NAME:$VERSION-monitor-distroless
docker push $IMAGE_NAME:$VERSION-server-distroless
docker push $IMAGE_NAME:$VERSION-monitor-distroless
51 changes: 51 additions & 0 deletions .github/workflows/gosec.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: gosec

on:
push:
branches:
- master
- develop
pull_request:
branches:
- master
- develop
jobs:
gosec:
name: gosec
strategy:
matrix:
go-version: [1.20.x]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
env:
GOPRIVATE: github.com/bnb-chain
GH_ACCESS_TOKEN: ${{ secrets.GH_TOKEN }}
steps:
- uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}
- uses: actions/checkout@v3
- name: Setup GitHub Token
run: git config --global url.https://[email protected]/.insteadOf https://github.com/
- uses: actions/cache@v3
with:
# In order:
# * Module download cache
# * Build cache (Linux)
# * Build cache (Mac)
# * Build cache (Windows)
path: |
~/go/pkg/mod
~/.cache/go-build
~/Library/Caches/go-build
%LocalAppData%\go-build
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- run: |
go mod tidy
go mod download
- name: Run Gosec Security Scanner
uses: securego/gosec@master
with:
args: -quiet -confidence high -severity high ./...
30 changes: 30 additions & 0 deletions .github/workflows/lint-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: "Lint PR"

on:
pull_request_target:
types:
- opened
- edited
- synchronize

jobs:
main:
runs-on: ubuntu-latest
steps:
- uses: amannn/action-semantic-pull-request@v5
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
with:
types: |
feat
fix
docs
style
refactor
perf
test
build
ci
chore
revert
release
55 changes: 55 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Lint
on:
push:
branches:
- master
- develop
pull_request:
permissions:
contents: read
# Optional: allow read access to pull request. Use with `only-new-issues` option.
# pull-requests: read
jobs:
golangci:
name: golangci-lint
strategy:
matrix:
go-version: [1.20.x]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
env:
GOPRIVATE: github.com/bnb-chain
steps:
- uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}
- uses: actions/checkout@v3

- run: go env -w GOPRIVATE="github.com/bnb-chain/*"
- run: git config --global url."https://${{ secrets.GH_TOKEN }}@github.com".insteadOf "https://github.com"

- uses: actions/cache@v3
with:
# In order:
# * Module download cache
# * Build cache (Linux)
# * Build cache (Mac)
# * Build cache (Windows)
path: |
~/go/pkg/mod
~/.cache/go-build
~/Library/Caches/go-build
%LocalAppData%\go-build
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- run: |
go mod tidy
go mod download
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
version: latest
skip-pkg-cache: true
args: --timeout=99m
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,10 @@

# Go workspace file
go.work

.idea

# Local configrations
config

build
42 changes: 42 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
BUILD_TAGS = netgo
PACKAGES=$(shell go list ./dao ./service ./monitor/.)

build_monitor:
ifeq ($(OS),Windows_NT)
go build $(BUILD_FLAGS) -o build/monitor.exe cmd/greenfield-data-marketplace-monitor/main.go
else
go build $(BUILD_FLAGS) -o build/monitor cmd/greenfield-data-marketplace-monitor/main.go
endif

#build_monitor_docker:
# docker build --build-arg GITHUB_TOKEN=${GITHUB_TOKEN} -f monitor.dockerfile -t monitor .

build_server:
ifeq ($(OS),Windows_NT)
go build $(BUILD_FLAGS) -o build/server.exe cmd/greenfield-data-marketplace-server/main.go
else
go build $(BUILD_FLAGS) -o build/server cmd/greenfield-data-marketplace-server/main.go
endif

#build_server_docker:
# docker build --build-arg GITHUB_TOKEN=${GITHUB_TOKEN} -f server.dockerfile -t server .

build: build_server build_monitor

#build_docker: build_server_docker build_monitor_docker

test:
go test -race -v $(PACKAGES)

lint:
golangci-lint cache clean
golangci-lint run

genswagger:
swagger generate server -f ./swagger.yaml -A greenfield-data-marketplace --default-scheme=http

genabi:
./script/abigen --abi ./monitor/contracts/marketplace.abi --pkg contracts --out ./monitor/contracts/marketplace.go --type Marketplace


.PHONY: build build_docker test lint genswagger genabi
Loading

0 comments on commit 763fbf3

Please sign in to comment.