[wip] CI tests

This commit is contained in:
Roy Crihfield 2023-08-31 00:04:11 +08:00
parent aa3d1aecf5
commit af452b174c
4 changed files with 46 additions and 43 deletions

45
.gitea/workflows/test.yml Normal file
View File

@ -0,0 +1,45 @@
name: Test
on:
pull_request:
branches: '*'
push:
branches:
- main
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 tests
run: make test
integration-tests:
name: Run integration tests
runs-on: ubuntu-latest
env:
GO111MODULE: on
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version-file: go.mod
check-latest: true
- name: Run DB container
run: docker compose -f test/compose.yml up --wait
# Run a sanity test against the fixture data
# Complete integration tests are TODO
- name: Run tests
run: |
cp ./environments/example.toml config.toml
go run . --config config.toml \
--snapshot-mode postgres \
--leveldb-path ./fixture/chain2data \
--ancient-path ./fixture/chain2data/ancient \
stateSnapshot

View File

@ -1,30 +0,0 @@
name: Docker Build
on: [pull_request]
jobs:
test:
name: Run unit tests
runs-on: ubuntu-latest
env:
GOPATH: /tmp/go
GO111MODULE: on
steps:
- name: Create GOPATH
run: mkdir -p /tmp/go
- uses: actions/setup-go@v3
with:
go-version: ">=1.19.0"
check-latest: true
- name: Checkout code
uses: actions/checkout@v2
- name: Run database
run: docker-compose up -d
- name: Run unit tests
run: |
sleep 45
make dbtest

View File

@ -9,15 +9,5 @@ $(MOCKS_DIR)/gen_indexer.go:
--mock_names Indexer=MockgenIndexer \
github.com/cerc-io/plugeth-statediff/indexer Indexer
clean:
rm -f mocks/snapshot/publisher.go
build:
go fmt ./...
go build
test: mocks
go clean -testcache && go test -p 1 -v ./...
dbtest: mocks
go clean -testcache && TEST_WITH_DB=true go test -p 1 -v ./...

View File

@ -1,5 +1,3 @@
version: '3.2'
services:
migrations:
restart: on-failure
@ -22,6 +20,6 @@ services:
POSTGRES_DB: "cerc_testing"
POSTGRES_PASSWORD: "password"
ports:
- "127.0.0.1:8077:5432"
- 127.0.0.1:8077:5432
volumes:
- /tmp:/tmp