Skip to content

Commit

Permalink
Enable GH Actions (ChainSafe#580)
Browse files Browse the repository at this point in the history
* Copy workflow in

* Adds docker-compose

* Adds subkey

* Add delay before tests

* Adds coverage to make cmd

* Adds e2e tests

* Add delay to test

* Adds missing wait

* Adds license-check

* Adds dependabot and docker deployment

* Adds missing headers

* Add badge

* Seperate testing and linting

* Fix links in readme

* Bump golangci-lint version

* Fix test for real

Co-authored-by: Kirill <[email protected]>
  • Loading branch information
ansermino and P1sar authored Feb 9, 2021
1 parent cdb8445 commit 83482ba
Show file tree
Hide file tree
Showing 8 changed files with 167 additions and 10 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"
38 changes: 38 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Copyright 2020 ChainSafe Systems
# SPDX-License-Identifier: LGPL-3.0-only

name: Docker Deployment

on:
push:
branches:
- master
tags:
- "v*.*.*"

jobs:
main:
runs-on: ubuntu-latest
steps:
-
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: true
tag_with_ref: true
-
name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
87 changes: 87 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# Copyright 2020 ChainSafe Systems
# SPDX-License-Identifier: LGPL-3.0-only

name: Tests

on:
pull_request:
types: [opened, synchronize, reopened]

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
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-v2.0.0
mv $HOME/.local/bin/subkey-v2.0.0 $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
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-v2.0.0
mv $HOME/.local/bin/subkey-v2.0.0 $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
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ install-subkey:
## Runs go test for all packages except the solidity bindings
test:
@echo " > \033[32mRunning tests...\033[0m "
go test -v `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 "
Expand Down
14 changes: 10 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# ChainBridge

[![Build Status](https://travis-ci.com/ChainSafe/ChainBridge.svg?branch=master)](https://travis-ci.com/ChainSafe/ChainBridge)
<a href="https://discord.gg/ykXsJKfhgq">
<img alt="discord" src="https://img.shields.io/discord/593655374469660673?label=Discord&logo=discord&style=flat" />
</a>
<a href="https://github.com/ChainSafe/ChainBridge/actions">
<img alt="build status" src="https://github.com/ChainSafe/ChainBridge/workflows/Tests/badge.svg?branch=master" />
</a>


# Contents

Expand All @@ -12,9 +18,9 @@
- [Simulations](#simulations)

# Getting Started
- Check out our [documentation](https://chainsafe.github.io/ChainBridge/).
- Try [running ChainBridge locally](https://chainsafe.github.io/ChainBridge/local/).
- Chat with us on [discord](https://discord.com/invite/n2U6x9c).
- Check out our [documentation](https://chainbridge.chainsafe.io).
- Try [running ChainBridge locally](https://chainbridge.chainsafe.io/local/).
- Chat with us on [discord](https://discord.gg/ykXsJKfhgq).

# Installation

Expand Down
1 change: 0 additions & 1 deletion chains/ethereum/writer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ func TestCreateAndExecuteErc20DepositProposal(t *testing.T) {
defer stopB()
defer writerA.conn.Close()
defer writerB.conn.Close()

erc20Address := ethtest.DeployMintApproveErc20(t, client, contracts.ERC20HandlerAddress, big.NewInt(100))
ethtest.FundErc20Handler(t, client, contracts.ERC20HandlerAddress, erc20Address, big.NewInt(100))

Expand Down
13 changes: 10 additions & 3 deletions shared/ethereum/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@ package utils

import (
"context"
"errors"
"fmt"
"math/big"
"sync"
"time"

"github.com/ethereum/go-ethereum"

"github.com/ChainSafe/chainbridge-utils/crypto/secp256k1"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
ethtypes "github.com/ethereum/go-ethereum/core/types"
Expand Down Expand Up @@ -76,9 +79,13 @@ func WaitForTx(client *Client, tx *ethtypes.Transaction) error {
for retry > 0 {
receipt, err := client.Client.TransactionReceipt(context.Background(), tx.Hash())
if err != nil {
retry--
time.Sleep(ExpectedBlockTime)
continue
if errors.Is(err, ethereum.NotFound) {
retry--
time.Sleep(ExpectedBlockTime)
continue
} else {
return err
}
}

if receipt.Status != 1 {
Expand Down
7 changes: 6 additions & 1 deletion shared/ethereum/erc20.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,12 @@ func DeployMintApproveErc20(client *Client, erc20Handler common.Address, amount
return ZeroAddress, err
}

_, err = erc20Instance.Mint(client.Opts, client.Opts.From, amount)
tx, err = erc20Instance.Mint(client.Opts, client.Opts.From, amount)
if err != nil {
return ZeroAddress, err
}

err = WaitForTx(client, tx)
if err != nil {
return ZeroAddress, err
}
Expand Down

0 comments on commit 83482ba

Please sign in to comment.