-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Publish to Dockerhub on every merge to develop and release (#1158)
- Loading branch information
1 parent
211182d
commit 768f265
Showing
12 changed files
with
246 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
name: CI/CD Release Pipeline | ||
on: | ||
push: | ||
branches: | ||
- "release/*" | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: true | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
- name: Setup Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: "18" | ||
- name: Setup Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: 1.21 | ||
- name: Cache npm modules | ||
uses: actions/cache@v2 | ||
with: | ||
path: ~/.npm | ||
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} | ||
restore-keys: | | ||
${{ runner.os }}-node- | ||
- name: Cache Go dependencies | ||
uses: actions/cache@v2 | ||
with: | ||
path: ~/go/pkg/mod | ||
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | ||
restore-keys: | | ||
${{ runner.os }}-go- | ||
- name: Install Dependencies | ||
run: | | ||
sudo add-apt-repository -y ppa:ethereum/ethereum | ||
sudo apt-get update | ||
sudo apt-get install -y npm ethereum | ||
npm install | ||
go get -d github.com/ethereum/go-ethereum@v1.12.2 | ||
go install github.com/ethereum/go-ethereum/cmd/abigen@v1.12.2 | ||
go install github.com/mattn/goveralls@v0.0.11 | ||
go install github.com/ory/go-acc@v0.2.7 | ||
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.54.2 | ||
- name: Run make setup for mainnet | ||
run: make setup | ||
- name: Run gofmt | ||
run: | | ||
gofmt | ||
- name: Run golangci-lint | ||
run: | | ||
golangci-lint run -v --timeout 5m | ||
- name: Execute test case | ||
run: | | ||
go-acc ./... --ignore razor/accounts/mocks --ignore razor/cmd/mocks --ignore razor/utils/mocks --ignore pkg --ignore razor/path/mocks --output coverage.txt | ||
- name: Run benchmarks | ||
run: | | ||
go test ./... -bench=. -run=^# | ||
- name: Publish Coverage to Coveralls.io | ||
env: | ||
COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: goveralls -coverprofile=coverage.txt -service=github | ||
- uses: bissolli/gh-action-persist-workspace@v1 | ||
with: | ||
action: persist | ||
|
||
push-docker-build: | ||
runs-on: ubuntu-latest | ||
needs: test | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
- name: Login to DockerHub | ||
uses: docker/login-action@v1 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
- name: Get short SHA | ||
id: sha | ||
run: echo "::set-output name=short::$(git rev-parse --short HEAD)" | ||
- name: Build and push Docker image | ||
uses: docker/build-push-action@v5 | ||
with: | ||
file: ./Dockerfile.mainnet | ||
context: . | ||
platforms: linux/amd64,linux/arm64/v8 | ||
push: true | ||
tags: razornetwork/razor-go:${{ steps.sha.outputs.short }} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
FROM golang:1.21.1-alpine AS go | ||
FROM ethereum/client-go:alltools-v1.12.2 AS ethereum | ||
|
||
FROM node:18.18.0-alpine AS builder | ||
|
||
COPY --from=ethereum /usr/local/bin/abigen /usr/local/bin/ | ||
COPY --from=go /usr/local/go/ /usr/local/go/ | ||
|
||
## Attaching current dir to workdir | ||
WORKDIR /app | ||
COPY . /app | ||
|
||
## Install and Cleanup | ||
|
||
RUN PATH="/usr/local/go/bin:${PATH}" \ | ||
&& apk add --update --no-cache python3 && ln -sf python3 /usr/bin/python \ | ||
&& apk add --update make gcc musl musl-dev g++ libc-dev bash linux-headers \ | ||
&& apk add --no-cache jq \ | ||
&& npm install \ | ||
&& npm run build-noargs-testnet \ | ||
&& cp build/bin/razor /usr/local/bin/ | ||
|
||
|
||
FROM alpine:latest | ||
RUN apk add --update bash | ||
COPY --from=builder /usr/local/bin/razor /usr/local/bin/ | ||
ENTRYPOINT [ "razor" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"Governance": "0xAc40E8dA38B5a381008059a38bb9bf45f0D3C4e2", | ||
"BlockManager": "0x11aB70d78f1Dd2c3F967180d8A64858Db03A0aBa", | ||
"CollectionManager": "0x367962d1462C568A0dDd0e2448311469451bF5a3", | ||
"StakeManager": "0xe0bC695203d9C9f379bcdE9260B9F71B64B85298", | ||
"RewardManager": "0x301779E4c95f951D2E17B4c3EdDC717551df2EBb", | ||
"VoteManager": "0x641BAD0641eB5B94B19568C0a22a55AEbDAF1870", | ||
"Delegator": "0xC74745eA5a3fac1864FAcd8f48d72C21A4ab883D", | ||
"RAZOR": "0xcbf70914Fae03B3acB91E953De60CfDAaCA8145f", | ||
"StakedTokenFactory": "0xEffA78888Dc1b6033286E5dF9b170bc5223178AB", | ||
"RandomNoManager": "0xC6eF45F5Add040800D30FE6dEe01b4EBC4BfC467" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"Governance": "0xD2A74B7A962FFc85827da0124A4278e731D15464", | ||
"BlockManager": "0x096e44B0d8b68376C8Efe40F28C3857951f03069", | ||
"CollectionManager": "0x3b76eB8c0282dAf531D7C507E4f3143A9A9c38b1", | ||
"StakeManager": "0x9f55a2C6C1F1Be8B01562cEae2df2F22931C7a46", | ||
"RewardManager": "0x07875369943951b1Af9c37f4ea137dcED9d9181d", | ||
"VoteManager": "0x11995b74D6d07a6Edc05653a71F3e8B3354caBF0", | ||
"Delegator": "0xe295863DF95AaAeC66E7de11D3aD0C35698d0fE9", | ||
"RAZOR": "0x4500E10fEb89e46E9fb642D0c62b1a761278155D", | ||
"StakedTokenFactory": "0xe20e11687F269fE9e356da92C4B15aBF98BbC9ff", | ||
"RandomNoManager": "0x31463bC4D5E67Bca623fFc6152D253Ea17216fA9" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,28 @@ | ||
{ | ||
"name": "razor-go", | ||
"version": "v1.0.0", | ||
"description": "Official node for running stakers in Golang.", | ||
"main": "index.js", | ||
"scripts": { | ||
"setup": "make setup", | ||
"build": "make build", | ||
"build-all": "make all", | ||
"build-noargs": "make build-noargs", | ||
"test": "go test ./... -v" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/razor-network/razor-go" | ||
}, | ||
"author": "Razor Network", | ||
"license": "ISC", | ||
"bugs": { | ||
"url": "https://github.com/razor-network/razor-go/issues" | ||
}, | ||
"homepage": "https://github.com/razor-network/razor-go#readme", | ||
"dependencies": { | ||
"@razor-network/contracts": "v1.0.2" | ||
"name": "razor-go", | ||
"version": "v1.1.0", | ||
"description": "Official node for running stakers in Golang.", | ||
"main": "index.js", | ||
"scripts": { | ||
"setup": "make setup", | ||
"build": "make build", | ||
"build-all": "make all", | ||
"build-noargs": "make build-noargs", | ||
"build-noargs-testnet": "make build-noargs-testnet", | ||
"test": "go test ./... -v" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/razor-network/razor-go" | ||
}, | ||
"author": "Razor Network", | ||
"license": "ISC", | ||
"bugs": { | ||
"url": "https://github.com/razor-network/razor-go/issues" | ||
}, | ||
"homepage": "https://github.com/razor-network/razor-go#readme", | ||
"dependencies": { | ||
"@razor-network/contracts": "v1.0.2" | ||
} | ||
} | ||
} | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/bin/bash | ||
|
||
# Define the ChainId value based on the network argument | ||
NETWORK=$1 | ||
CHAINID="" | ||
|
||
if [[ "$NETWORK" == "mainnet" ]]; then | ||
CHAINID="0x109B4597" | ||
elif [[ "$NETWORK" == "testnet" ]]; then | ||
CHAINID="0x5A79C44E" | ||
else | ||
echo "Invalid network specified. Please choose 'mainnet' or 'testnet'." | ||
exit 1 | ||
fi | ||
|
||
sed -i "s/var ChainId = big.NewInt(0x[a-fA-F0-9]*)/var ChainId = big.NewInt($CHAINID)/" core/constants.go | ||
|