Skip to content

Commit

Permalink
Merge pull request #83 from vulcanize/fix-ci
Browse files Browse the repository at this point in the history
Add unit test in Github action CI.
  • Loading branch information
arijitAD authored Jun 18, 2021
2 parents a952b72 + 3d53160 commit 300d43e
Show file tree
Hide file tree
Showing 26 changed files with 204 additions and 301 deletions.
11 changes: 11 additions & 0 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: checks

on: [pull_request]

jobs:
linter-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Run linter
run: go run build/ci.go lint
56 changes: 55 additions & 1 deletion .github/workflows/on-pr.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Docker Build
name: Build and test

on: [pull_request]

Expand All @@ -10,3 +10,57 @@ jobs:
- uses: actions/checkout@v2
- name: Run docker build
run: docker build -t vulcanize/go-ethereum .

geth-unit-test:
name: Run geth unit test
strategy:
matrix:
go-version: [ 1.15.x]
platform: [ubuntu-latest]
runs-on: ${{ matrix.platform }}
env:
GO111MODULE: on
GOPATH: /tmp/go
steps:
- name: Create GOPATH
run: mkdir -p /tmp/go

- name: Install Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}

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

- name: Run unit tests
run: |
make test
statediff-unit-test:
name: Run state diff unit test
env:
GOPATH: /tmp/go
strategy:
matrix:
go-version: [ 1.15.x]
platform: [ubuntu-latest]
runs-on: ${{ matrix.platform }}
steps:
- name: Create GOPATH
run: mkdir -p /tmp/go

- name: Install Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}

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

- name: Start database
run: docker-compose -f docker-compose.yml up -d db

- name: Run unit tests
run:
make statedifftest
229 changes: 0 additions & 229 deletions .travis.yml

This file was deleted.

30 changes: 30 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,31 @@
.PHONY: geth-darwin geth-darwin-386 geth-darwin-amd64
.PHONY: geth-windows geth-windows-386 geth-windows-amd64

BIN = $(GOPATH)/bin

## Migration tool
GOOSE = $(BIN)/goose
$(BIN)/goose:
go get -u github.com/pressly/goose/cmd/goose

GOBIN = ./build/bin
GO ?= latest
GORUN = env GO111MODULE=on go run

#Database
HOST_NAME = localhost
PORT = 5432
USER = postgres
PASSWORD = password

# Set env variable
# `PGPASSWORD` is used by `createdb` and `dropdb`
export PGPASSWORD=$(PASSWORD)

#Test
TEST_DB = vulcanize_testing
TEST_CONNECT_STRING = postgresql://$(USER):$(PASSWORD)@$(HOST_NAME):$(PORT)/$(TEST_DB)?sslmode=disable

geth:
$(GORUN) build/ci.go install ./cmd/geth
@echo "Done building."
Expand All @@ -32,6 +53,15 @@ ios:
@echo "Done building."
@echo "Import \"$(GOBIN)/Geth.framework\" to use the library."


.PHONY: statedifftest
statedifftest: | $(GOOSE)
dropdb -h $(HOST_NAME) -p $(PORT) -U $(USER) --if-exists $(TEST_DB)
createdb -h $(HOST_NAME) -p $(PORT) -U $(USER) $(TEST_DB)
$(GOOSE) -dir ./statediff/db/migrations postgres "$(TEST_CONNECT_STRING)" up
@echo " > \033[32mRunning StateDiff Tests...\033[0m "
MODE=statediff go test ./statediff/... -v

test: all
$(GORUN) build/ci.go test

Expand Down
1 change: 1 addition & 0 deletions cmd/faucet/faucet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
)

func TestFacebook(t *testing.T) {
t.Skip("skipping this as it loads a different facebook page in CI environment")
for _, tt := range []struct {
url string
want common.Address
Expand Down
17 changes: 17 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
version: '3.2'

services:
db:
restart: always
image: postgres:10.12-alpine
environment:
POSTGRES_USER: "postgres"
POSTGRES_DB: "vulcanize_testing"
POSTGRES_PASSWORD: "password"
volumes:
- geth_node:/var/lib/postgresql/data
ports:
- "127.0.0.1:5432:5432"

volumes:
geth_node:
Loading

0 comments on commit 300d43e

Please sign in to comment.