2023-06-21 23:25:27 +00:00
|
|
|
name: Unit and integration tests
|
|
|
|
on:
|
|
|
|
workflow_call:
|
|
|
|
|
2023-09-11 15:24:09 +00:00
|
|
|
env:
|
|
|
|
# Needed until we can incorporate docker startup into the executor container
|
|
|
|
DOCKER_HOST: unix:///var/run/dind.sock
|
|
|
|
SO_VERSION: v1.1.0-c30c779-202309082138
|
|
|
|
|
2023-06-21 23:25:27 +00:00
|
|
|
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
|
2023-09-11 15:24:09 +00:00
|
|
|
- name: "Run dockerd"
|
|
|
|
run: |
|
|
|
|
dockerd -H $DOCKER_HOST --userland-proxy=false &
|
|
|
|
sleep 5
|
2023-06-21 23:25:27 +00:00
|
|
|
- name: "Run DB container"
|
|
|
|
run: |
|
|
|
|
docker compose -f test/compose-db.yml up --wait --quiet-pull
|
2023-09-11 15:24:09 +00:00
|
|
|
- name: "Set Gitea credentials"
|
|
|
|
env:
|
|
|
|
TOKEN: ${{ secrets.CICD_REPO_TOKEN }}
|
|
|
|
run: |
|
|
|
|
git config --global url."https://$TOKEN:@git.vdb.to/".insteadOf "https://git.vdb.to/"
|
2023-06-21 23:25:27 +00:00
|
|
|
- name: "Run tests"
|
|
|
|
run: |
|
|
|
|
go test -v ./pkg/...
|
|
|
|
|
|
|
|
integration-tests:
|
|
|
|
name: "Run integration tests"
|
|
|
|
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-11 15:24:09 +00:00
|
|
|
- name: "Run dockerd"
|
|
|
|
run: |
|
|
|
|
dockerd -H $DOCKER_HOST --userland-proxy=false &
|
|
|
|
sleep 5
|
2023-06-21 23:25:27 +00:00
|
|
|
- name: "Install stack-orchestrator"
|
2023-09-11 15:24:09 +00:00
|
|
|
run: |
|
|
|
|
curl -L -O https://github.com/cerc-io/stack-orchestrator/releases/download/$SO_VERSION/laconic-so
|
|
|
|
chmod +x laconic-so
|
2023-06-21 23:25:27 +00:00
|
|
|
- run: pip install ./stack-orchestrator
|
2023-09-11 15:24:09 +00:00
|
|
|
- name: "Set Gitea credentials"
|
|
|
|
env:
|
|
|
|
TOKEN: ${{ secrets.CICD_REPO_TOKEN }}
|
|
|
|
run: |
|
|
|
|
git config --global url."https://$TOKEN:@git.vdb.to/".insteadOf "https://git.vdb.to/"
|
|
|
|
|
2023-06-21 23:25:27 +00:00
|
|
|
- name: "Run testnet stack"
|
2023-09-11 15:24:09 +00:00
|
|
|
env:
|
|
|
|
CERC_GO_AUTH_TOKEN: ${{ secrets.CICD_REPO_TOKEN }}
|
2023-06-21 23:25:27 +00:00
|
|
|
run: ./scripts/integration-setup.sh
|
|
|
|
- name: "Run contract deployer"
|
|
|
|
run: |
|
|
|
|
docker compose -f test/compose-deployer.yml up --wait --quiet-pull
|
2023-09-11 15:24:09 +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"
|
|
|
|
- name: "Run tests"
|
|
|
|
run: |
|
2023-09-11 15:24:09 +00:00
|
|
|
go test ./integration/... -v -timeout=20m
|