2023-06-21 23:25:27 +00:00
|
|
|
name: Unit and integration tests
|
|
|
|
on:
|
2023-09-21 08:01:49 +00:00
|
|
|
# workflow_call:
|
|
|
|
|
|
|
|
# Job headers are hidden when not top-level - run them directly for readability until fixed:
|
|
|
|
# https://github.com/go-gitea/gitea/issues/26736
|
|
|
|
pull_request:
|
|
|
|
branches: '*'
|
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- main
|
|
|
|
- ci-test
|
|
|
|
|
|
|
|
env:
|
|
|
|
# Needed until we can incorporate docker startup into the executor container
|
|
|
|
DOCKER_HOST: unix:///var/run/dind.sock
|
|
|
|
SO_VERSION: v1.1.0-e0b5318-202309201927 # contains fixes for plugeth stack
|
2023-06-21 23:25:27 +00:00
|
|
|
|
|
|
|
jobs:
|
|
|
|
unit-tests:
|
2023-09-21 08:01:49 +00:00
|
|
|
name: Run unit tests
|
2023-06-21 23:25:27 +00:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v3
|
|
|
|
- uses: actions/setup-go@v4
|
|
|
|
with:
|
|
|
|
go-version-file: 'go.mod'
|
|
|
|
check-latest: true
|
2023-09-21 08:01:49 +00:00
|
|
|
- name: Run dockerd
|
|
|
|
run: |
|
|
|
|
dockerd -H $DOCKER_HOST --userland-proxy=false &
|
|
|
|
sleep 5
|
|
|
|
- name: Run DB container
|
2023-06-21 23:25:27 +00:00
|
|
|
run: |
|
|
|
|
docker compose -f test/compose-db.yml up --wait --quiet-pull
|
2023-09-21 08:01:49 +00:00
|
|
|
- name: Set access token
|
|
|
|
env:
|
|
|
|
TOKEN: ${{ secrets.CICD_REPO_TOKEN }}
|
2023-06-21 23:25:27 +00:00
|
|
|
run: |
|
2023-09-21 08:01:49 +00:00
|
|
|
git config --global url."https://$TOKEN:@git.vdb.to/".insteadOf https://git.vdb.to/
|
|
|
|
- name: Run tests
|
|
|
|
run: go test -p 1 -v ./pkg/...
|
2023-06-21 23:25:27 +00:00
|
|
|
|
|
|
|
integration-tests:
|
2023-09-21 08:01:49 +00:00
|
|
|
name: Run integration tests
|
2023-06-21 23:25:27 +00:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v3
|
|
|
|
- uses: actions/setup-go@v4
|
|
|
|
with:
|
|
|
|
go-version-file: 'go.mod'
|
|
|
|
check-latest: true
|
2023-09-21 08:01:49 +00:00
|
|
|
- name: Run dockerd
|
|
|
|
run: |
|
|
|
|
dockerd -H $DOCKER_HOST --userland-proxy=false &
|
|
|
|
sleep 5
|
|
|
|
- name: Set Gitea access token
|
|
|
|
env:
|
|
|
|
TOKEN: ${{ secrets.CICD_REPO_TOKEN }}
|
|
|
|
run: |
|
|
|
|
git config --global url."https://$TOKEN:@git.vdb.to/".insteadOf https://git.vdb.to/
|
|
|
|
|
|
|
|
- name: Install jq
|
|
|
|
env:
|
|
|
|
DEBIAN_FRONTEND: noninteractive
|
|
|
|
run: apt-get update && apt-get install -y jq
|
|
|
|
- name: Install Python
|
|
|
|
uses: actions/setup-python@v4
|
|
|
|
with:
|
|
|
|
python-version: '3.11'
|
|
|
|
- name: Install stack-orchestrator
|
2023-06-21 23:25:27 +00:00
|
|
|
uses: actions/checkout@v3
|
|
|
|
with:
|
|
|
|
repository: cerc-io/stack-orchestrator
|
2023-09-21 08:01:49 +00:00
|
|
|
ref: ${{ env.SO_VERSION }}
|
2023-06-21 23:25:27 +00:00
|
|
|
path: ./stack-orchestrator
|
|
|
|
- run: pip install ./stack-orchestrator
|
2023-09-21 08:01:49 +00:00
|
|
|
|
|
|
|
- name: Run testnet stack
|
|
|
|
env:
|
|
|
|
CERC_GO_AUTH_TOKEN: ${{ secrets.CICD_REPO_TOKEN }}
|
2023-06-21 23:25:27 +00:00
|
|
|
run: ./scripts/integration-setup.sh
|
2023-09-21 08:01:49 +00:00
|
|
|
- name: Run contract deployer
|
2023-06-21 23:25:27 +00:00
|
|
|
run: |
|
|
|
|
docker compose -f test/compose-deployer.yml up --wait --quiet-pull
|
2023-09-21 08:01:49 +00:00
|
|
|
- name: Wait for testnet
|
2023-06-21 23:25:27 +00:00
|
|
|
run: |
|
|
|
|
# Start validator at current head, but not before Merge (block 1 on test chain)
|
|
|
|
echo "Waiting for chain head to progress..."
|
|
|
|
while
|
|
|
|
height=$(./scripts/get-block-number.sh $ETH_HTTP_PATH)
|
|
|
|
[[ "$height" < 2 ]];
|
|
|
|
do sleep 5; done
|
|
|
|
echo "Chain has reached block $height"
|
|
|
|
echo VALIDATE_FROM_BLOCK=$height >> "$GITHUB_ENV"
|
2023-09-21 08:01:49 +00:00
|
|
|
- name: Run tests
|
2023-06-21 23:25:27 +00:00
|
|
|
run: |
|
2023-09-21 08:01:49 +00:00
|
|
|
go test ./integration/... -v -timeout=20m
|