2023-08-30 16:04:11 +00:00
|
|
|
name: Test
|
|
|
|
|
|
|
|
on:
|
|
|
|
pull_request:
|
|
|
|
branches: '*'
|
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- main
|
|
|
|
|
|
|
|
env:
|
2023-09-28 08:33:05 +00:00
|
|
|
# Needed until we can incorporate docker startup into the executor container
|
2023-08-30 16:04:11 +00:00
|
|
|
DOCKER_HOST: unix:///var/run/dind.sock
|
2023-09-28 08:33:05 +00:00
|
|
|
CANONICAL_VERSION: v5.0.4-alpha
|
2023-08-30 16:04:11 +00:00
|
|
|
|
|
|
|
jobs:
|
|
|
|
tests:
|
|
|
|
name: Run unit and integration tests
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v3
|
2023-09-28 08:33:05 +00:00
|
|
|
- uses: actions/setup-go@v3
|
|
|
|
with:
|
|
|
|
go-version-file: go.mod
|
|
|
|
check-latest: true
|
2023-09-27 14:54:06 +00:00
|
|
|
- name: Install test fixtures
|
|
|
|
uses: actions/checkout@v3
|
|
|
|
with:
|
|
|
|
repository: cerc-io/eth-testing
|
|
|
|
path: ./fixtures
|
|
|
|
ref: v0.3.1
|
|
|
|
token: ${{ secrets.CICD_REPO_TOKEN }}
|
2023-08-30 16:04:11 +00:00
|
|
|
- name: Configure Gitea access
|
|
|
|
env:
|
|
|
|
TOKEN: ${{ secrets.CICD_REPO_TOKEN }}
|
|
|
|
run: |
|
2023-09-28 08:33:05 +00:00
|
|
|
git config --global url."https://$TOKEN:@git.vdb.to/".insteadOf https://git.vdb.to/
|
2023-08-30 16:04:11 +00:00
|
|
|
- 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
|
2023-09-27 14:54:06 +00:00
|
|
|
- name: Run basic integration test
|
2023-08-30 16:04:11 +00:00
|
|
|
env:
|
|
|
|
SNAPSHOT_MODE: postgres
|
2023-09-28 00:33:02 +00:00
|
|
|
SNAPSHOT_BLOCK_HEIGHT: 32
|
2023-09-27 16:02:07 +00:00
|
|
|
LEVELDB_PATH: ./fixtures/chaindata/_data/small
|
|
|
|
LEVELDB_ANCIENT: ./fixtures/chaindata/_data/small/ancient
|
2023-09-28 08:33:05 +00:00
|
|
|
ETH_GENESIS_BLOCK: "0x37cbb63c7150a7b60f2878433963ed8ba7e5f82fb2683ec7a945c974e1cf4e05"
|
2023-08-30 16:04:11 +00:00
|
|
|
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 ]]
|
2023-09-27 16:02:07 +00:00
|
|
|
[[ "$(count_results eth.state_cids)" = 5 ]]
|
|
|
|
[[ "$(count_results eth.storage_cids)" = 13 ]]
|
2023-09-28 08:33:05 +00:00
|
|
|
|
|
|
|
compliance-test:
|
|
|
|
name: Run compliance tests
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v3
|
|
|
|
with:
|
|
|
|
path: ./ipld-eth-state-snapshot
|
|
|
|
- uses: actions/setup-go@v3
|
|
|
|
with:
|
|
|
|
go-version-file: ./ipld-eth-state-snapshot/go.mod
|
|
|
|
check-latest: true
|
|
|
|
- name: Install test fixtures
|
|
|
|
uses: actions/checkout@v3
|
|
|
|
with:
|
|
|
|
repository: cerc-io/eth-testing
|
|
|
|
path: ./fixtures
|
|
|
|
ref: v0.3.1
|
|
|
|
- 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 current version
|
|
|
|
working-directory: ./ipld-eth-state-snapshot
|
|
|
|
run: go build -o ../snapshot-current .
|
|
|
|
|
|
|
|
- name: Checkout canonical version
|
|
|
|
uses: actions/checkout@v3
|
|
|
|
with:
|
|
|
|
path: ./ipld-eth-state-snapshot-canonical
|
|
|
|
ref: ${{ env.CANONICAL_VERSION }}
|
|
|
|
- name: Build canonical version
|
|
|
|
working-directory: ./ipld-eth-state-snapshot-canonical
|
|
|
|
run: go build -o ../snapshot-canonical .
|
|
|
|
|
|
|
|
- name: Run dockerd
|
|
|
|
run: |
|
|
|
|
dockerd -H $DOCKER_HOST --userland-proxy=false &
|
|
|
|
sleep 5
|
|
|
|
- name: Run DB container
|
|
|
|
working-directory: ./ipld-eth-state-snapshot
|
|
|
|
run: docker compose -f test/compose.yml up --wait
|
|
|
|
- name: Compare snapshot output
|
|
|
|
env:
|
|
|
|
SNAPSHOT_MODE: postgres
|
|
|
|
SNAPSHOT_BLOCK_HEIGHT: 200
|
|
|
|
LEVELDB_PATH: ./fixtures/chaindata/_data/small2
|
|
|
|
LEVELDB_ANCIENT: ./fixtures/chaindata/_data/small2/ancient
|
|
|
|
ETH_GENESIS_BLOCK: "0x8a3c7cddacbd1ab4ec1b03805fa2a287f3a75e43d87f4f987fcc399f5c042614"
|
|
|
|
run: |
|
|
|
|
./ipld-eth-state-snapshot/scripts/compare-snapshots.sh \
|
|
|
|
./snapshot-canonical ./snapshot-current
|