CI workflows

This commit is contained in:
Roy Crihfield 2023-05-05 18:22:13 +08:00
parent 5eb6cd2ba8
commit b392e12bdd
4 changed files with 62 additions and 3 deletions

7
.github/workflows/on-pr.yml vendored Normal file
View File

@ -0,0 +1,7 @@
name: PR actions
on:
- pull_request
jobs:
run-tests:
uses: ./.github/workflows/test.yml

26
.github/workflows/test.yml vendored Normal file
View File

@ -0,0 +1,26 @@
name: Run tests
on:
workflow_call:
jobs:
unit-tests:
name: Run unit tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version-file: 'go.mod'
check-latest: true
- name: "Run DB container"
working-directory: ./test
run: |
docker compose up -d --quiet-pull
- name: "Build and run tests"
run: |
until [[ "$(docker inspect test-ipld-eth-db | jq -r '.[0].State.Status')" = 'running' ]]
do sleep 1; done &
go build ./...
wait $!
go test -v ./...

6
go.mod
View File

@ -1,6 +1,6 @@
module github.com/cerc-io/ipld-eth-statedb
go 1.18
go 1.19
require (
github.com/VictoriaMetrics/fastcache v1.6.0
@ -14,6 +14,7 @@ require (
github.com/jmoiron/sqlx v1.3.5
github.com/lib/pq v1.10.6
github.com/multiformats/go-multihash v0.1.0
github.com/sirupsen/logrus v1.9.0
github.com/stretchr/testify v1.8.1
golang.org/x/crypto v0.6.0
)
@ -90,7 +91,6 @@ require (
github.com/segmentio/fasthash v1.0.3 // indirect
github.com/shirou/gopsutil v3.21.11+incompatible // indirect
github.com/shopspring/decimal v1.2.0 // indirect
github.com/sirupsen/logrus v1.9.0 // indirect
github.com/spaolacci/murmur3 v1.1.0 // indirect
github.com/status-im/keycard-go v0.2.0 // indirect
github.com/stretchr/objx v0.5.0 // indirect
@ -113,4 +113,4 @@ require (
lukechampine.com/blake3 v1.1.6 // indirect
)
replace github.com/ethereum/go-ethereum v1.11.5 => github.com/cerc-io/go-ethereum v1.11.5-statediff-5.0.4
replace github.com/ethereum/go-ethereum v1.11.5 => github.com/cerc-io/go-ethereum v1.11.5-statediff-5.0.3-alpha

26
test/compose.yml Normal file
View File

@ -0,0 +1,26 @@
# Containers to run backing DB for unit testing
services:
migrations:
restart: on-failure
depends_on:
- ipld-eth-db
image: git.vdb.to/cerc-io/ipld-eth-db/ipld-eth-db:v5.0.2-alpha
environment:
DATABASE_USER: "vdbm"
DATABASE_NAME: "cerc_testing"
DATABASE_PASSWORD: "password"
DATABASE_HOSTNAME: "ipld-eth-db"
DATABASE_PORT: 5432
ipld-eth-db:
container_name: test-ipld-eth-db
image: timescale/timescaledb:latest-pg14
restart: always
command: ["postgres", "-c", "log_statement=all"]
environment:
POSTGRES_USER: "vdbm"
POSTGRES_DB: "cerc_testing"
POSTGRES_PASSWORD: "password"
ports:
- "127.0.0.1:8077:5432"