Skip to content

Commit

Permalink
Merge pull request #4 from vedhavyas/feat/upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
vedhavyas authored Apr 6, 2021
2 parents 4ae6223 + 0e42d3d commit 24afb1a
Show file tree
Hide file tree
Showing 171 changed files with 8,900 additions and 6,629 deletions.
15 changes: 15 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright 2020 ChainSafe Systems
# SPDX-License-Identifier: LGPL-3.0-only

version: 2
updates:
# Maintain dependencies for GitHub Actions
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"

- package-ecosystem: "gomod"
directory: "/"
schedule:
interval: "daily"
92 changes: 92 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# Copyright 2020 ChainSafe Systems
# SPDX-License-Identifier: LGPL-3.0-only

name: CI

on:
pull_request:
types: [opened, synchronize, reopened]
push:
branches:
- main
tags:
- "v*.*.*"

jobs:
test:
name: Tests
strategy:
matrix:
go-version: [1.15.x]
platform: [ubuntu-latest]
runs-on: ${{ matrix.platform }}
steps:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}
- name: Checkout code
uses: actions/checkout@v2
- uses: actions/cache@v2.1.4
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Install Subkey
run: |
wget -P $HOME/.local/bin/ https://chainbridge.ams3.digitaloceanspaces.com/subkey-rc6
mv $HOME/.local/bin/subkey-rc6 $HOME/.local/bin/subkey
chmod +x $HOME/.local/bin/subkey
echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: Test
run: |
docker-compose -f ./docker-compose-e2e.yml up -d
sleep 3
docker ps
make test
e2e:
name: E2E Tests
strategy:
matrix:
go-version: [ 1.15.x ]
platform: [ ubuntu-latest ]
runs-on: ${{ matrix.platform }}
steps:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}
- name: Checkout code
uses: actions/checkout@v2
- uses: actions/cache@v2.1.4
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Install Subkey
run: |
wget -P $HOME/.local/bin/ https://chainbridge.ams3.digitaloceanspaces.com/subkey-rc6
mv $HOME/.local/bin/subkey-rc6 $HOME/.local/bin/subkey
chmod +x $HOME/.local/bin/subkey
echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: Test
run: |
docker-compose -f ./docker-compose-e2e.yml up -d
docker ps
make test-e2e
lint:
name: Lint and License Headers
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: golangci-lint
uses: golangci/golangci-lint-action@v2
with:
version: v1.36
args: --timeout=5m
- name: License Check
run: make license-check
53 changes: 53 additions & 0 deletions .github/workflows/docker-build-and-push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Copyright 2020 ChainSafe Systems
# SPDX-License-Identifier: LGPL-3.0-only

name: Docker build and push

on:
push:
branches:
- main
tags:
- "v*.*.*"
release:
types:
- created
jobs:
build-and-deploy:
name: Docker Deployment
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main' || contains(github.ref, '/tags/v')
steps:
- name: Prepare
id: prep
run: |
DOCKER_IMAGE=chainsafe/chainbridge
VERSION=edge
if [[ $GITHUB_REF == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/v}
fi
if [ "${{ github.event_name }}" = "schedule" ]; then
VERSION=nightly
fi
TAGS="${DOCKER_IMAGE}:${VERSION}"
if [[ $VERSION =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
TAGS="$TAGS,${DOCKER_IMAGE}:latest"
fi
echo ::set-output name=tags::${TAGS}
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- 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: Build and push
id: docker_build
uses: docker/build-push-action@v2
with:
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.prep.outputs.tags }}
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
9 changes: 7 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,21 @@ coverage.txt
# Builds
build/
bin/
site/

# golang
.env
bridge
keys/
*.key

# Chainbridge
config.toml
./centrifuge-chain
config.json
*.block

gethdata1/
gethdata2/
centrifuge-chain/
# Solidity
/solidity
/cfgBuilder/*.toml
54 changes: 0 additions & 54 deletions .travis.yml

This file was deleted.

19 changes: 0 additions & 19 deletions Docker/Bridge.Dockerfile

This file was deleted.

14 changes: 0 additions & 14 deletions Docker/Ganache.Dockerfile

This file was deleted.

21 changes: 21 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright 2020 ChainSafe Systems
# SPDX-License-Identifier: LGPL-3.0-only

FROM golang:1.13-stretch AS builder
ADD . /src
WORKDIR /src
RUN go mod download
RUN cd cmd/chainbridge && go build -o /bridge .

# # final stage
FROM debian:stretch-slim
RUN apt-get -y update && apt-get -y upgrade && apt-get install ca-certificates wget -y
RUN wget -P /usr/local/bin/ https://chainbridge.ams3.digitaloceanspaces.com/subkey-rc6 \
&& mv /usr/local/bin/subkey-rc6 /usr/local/bin/subkey \
&& chmod +x /usr/local/bin/subkey
RUN subkey --version

COPY --from=builder /bridge ./
RUN chmod +x ./bridge

ENTRYPOINT ["./bridge"]
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -162,4 +162,4 @@ General Public License ever published by the Free Software Foundation.
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.
Library.
32 changes: 24 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
PROJECTNAME=$(shell basename "$(PWD)")
VERSION=-ldflags="-X main.Version=$(shell git describe --tags)"
SOL_DIR=./solidity

CENT_EMITTER_ADDR?=0x1
Expand All @@ -22,7 +23,7 @@ get:
go mod tidy && go mod download

get-lint:
curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s latest
curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s v1.31.0

.PHONY: lint
lint:
Expand All @@ -31,13 +32,22 @@ lint:
fi;
./bin/golangci-lint run ./... --timeout 5m0s

lint-fix:
if [ ! -f ./bin/golangci-lint ]; then \
$(MAKE) get-lint; \
fi;
./bin/golangci-lint run ./... --timeout 5m0s --fix

build:
@echo " > \033[32mBuilding binary...\033[0m "
cd cmd/chainbridge && env GOARCH=amd64 go build -o ../../build/chainbridge
cd cmd/chainbridge && env GOARCH=amd64 go build -o ../../build/chainbridge $(VERSION)

install:
@echo " > \033[32mInstalling bridge...\033[0m "
cd cmd/chainbridge && go install
cd cmd/chainbridge && go install $(VERSION)

build-mkdocs:
docker run --rm -it -v ${PWD}:/docs squidfunk/mkdocs-material build

setup-sol-cli:
@echo " > \033[32mSetting up solidity cli... \033[0m "
Expand All @@ -51,13 +61,13 @@ rebuild-contracts:
license:
@echo " > \033[32mAdding license headers...\033[0m "
GO111MODULE=off go get -u github.com/google/addlicense
addlicense -c "ChainSafe Systems" -f ./copyright.txt -y 2020 .
addlicense -c "ChainSafe Systems" -f ./scripts/header.txt -y 2020 .

## license-check: Checks for missing license headers
license-check:
@echo " > \033[Checking for license headers...\033[0m "
GO111MODULE=off go get -u github.com/google/addlicense
addlicense -check -c "ChainSafe Systems" -f ./copyright.txt -y 2020 .
addlicense -check -c "ChainSafe Systems" -f ./scripts/header.txt -y 2020 .

## Install dependency subkey
install-subkey:
Expand All @@ -67,11 +77,11 @@ install-subkey:
## Runs go test for all packages except the solidity bindings
test:
@echo " > \033[32mRunning tests...\033[0m "
go test `go list ./... | grep -v bindings | grep -v e2e`
go test -coverprofile=cover.out -v `go list ./... | grep -v bindings | grep -v e2e`

test-e2e:
@echo " > \033[32mRunning e2e tests...\033[0m "
go test ./e2e
go test -v -timeout 0 ./e2e

test-eth:
@echo " > \033[32mRunning ethereum tests...\033[0m "
Expand All @@ -84,5 +94,11 @@ test-sub:
docker-start:
./scripts/docker/start-docker.sh

docker-e2e:
docker-compose -f ./docker-compose-e2e.yml up -V

mkdocs:
docker run --rm -it -p 8000:8000 -v ${PWD}:/docs squidfunk/mkdocs-material

clean:
rm -rf build/ solidity/
rm -rf build/ solidity/
Loading

0 comments on commit 24afb1a

Please sign in to comment.