ipld-eth-state-snapshot/.gitea/workflows/test.yml
Roy Crihfield c6170f063c
All checks were successful
Test / Run unit and integration tests (pull_request) Successful in 4m25s
CI tests
2023-09-02 19:36:55 +08:00

68 lines
2.0 KiB
YAML

name: Test
on:
pull_request:
branches: '*'
push:
branches:
- main
# Needed until we can incorporate docker startup into the executor container
env:
DOCKER_HOST: unix:///var/run/dind.sock
jobs:
tests:
name: Run unit and integration tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version-file: go.mod
check-latest: true
- name: Configure Gitea access
env:
TOKEN: ${{ secrets.CICD_REPO_TOKEN }}
run: |
git config --global url."https://$TOKEN:@git.vdb.to/".insteadOf "https://git.vdb.to/"
- name: Build package
run: go build .
- name: Run unit tests
run: make test
- name: Run dockerd
run: |
dockerd -H $DOCKER_HOST --userland-proxy=false &
sleep 5
- 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 integration tests
env:
SNAPSHOT_MODE: postgres
SNAPSHOT_BLOCK_HEIGHT: 32
LEVELDB_PATH: ./fixture/chain2data
LEVELDB_ANCIENT: ./fixture/chain2data/ancient
run: |
until
ready_query='select max(version_id) from goose_db_version;'
version=$(docker exec -e PGPASSWORD=password test-ipld-eth-db-1 \
psql -tA cerc_testing -U vdbm -c "$ready_query")
[[ "$version" -ge 18 ]]
do sleep 1; done
./ipld-eth-state-snapshot --config test/ci-config.toml stateSnapshot
count_results() {
query="select count(*) from $1;"
docker exec -e PGPASSWORD=password test-ipld-eth-db-1 \
psql -tA cerc_testing -U vdbm -c "$query"
}
set -x
[[ "$(count_results eth.header_cids)" = 1 ]]
[[ "$(count_results eth.state_cids)" = 5 ]]
[[ "$(count_results eth.storage_cids)" = 13 ]]