From b392e12bddada0e6a44115865c1f10de4f5871af Mon Sep 17 00:00:00 2001 From: Roy Crihfield Date: Fri, 5 May 2023 18:22:13 +0800 Subject: [PATCH] CI workflows --- .github/workflows/on-pr.yml | 7 +++++++ .github/workflows/test.yml | 26 ++++++++++++++++++++++++++ go.mod | 6 +++--- test/compose.yml | 26 ++++++++++++++++++++++++++ 4 files changed, 62 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/on-pr.yml create mode 100644 .github/workflows/test.yml create mode 100644 test/compose.yml diff --git a/.github/workflows/on-pr.yml b/.github/workflows/on-pr.yml new file mode 100644 index 0000000..44a77d2 --- /dev/null +++ b/.github/workflows/on-pr.yml @@ -0,0 +1,7 @@ +name: PR actions +on: + - pull_request + +jobs: + run-tests: + uses: ./.github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..7380088 --- /dev/null +++ b/.github/workflows/test.yml @@ -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 ./... diff --git a/go.mod b/go.mod index 67d2676..8087592 100644 --- a/go.mod +++ b/go.mod @@ -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 diff --git a/test/compose.yml b/test/compose.yml new file mode 100644 index 0000000..d0ba3a2 --- /dev/null +++ b/test/compose.yml @@ -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"