Skip to content

Commit

Permalink
feat: Add test for sapphire- and emerald-dev images
Browse files Browse the repository at this point in the history
  • Loading branch information
matevz committed Oct 26, 2023
1 parent c651412 commit d787d67
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 1 deletion.
22 changes: 21 additions & 1 deletion .github/workflows/docker-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,27 @@ jobs:
run: |
echo "VERSION=$(date +%Y-%m-%d-git$(git rev-parse --short HEAD))" >> $GITHUB_ENV
- name: Build and push
- name: Build
uses: docker/build-push-action@v5
with:
build-args: |
VERSION=${{ env.VERSION }}
context: .
file: docker/${{ matrix.docker_image }}/Dockerfile
tags: |
ghcr.io/oasisprotocol/${{ matrix.docker_image }}:latest
ghcr.io/oasisprotocol/${{ matrix.docker_image }}:latest-${{ env.VERSION }}
load: true
labels: |
org.opencontainers.image.source=${{ github.event.repository.html_url }}
org.opencontainers.image.revision=${{ github.sha }}
- name: Test
timeout-minutes: 1
working-directory: docker/${{ matrix.docker_image }}
run: ./test.sh

- name: Push
uses: docker/build-push-action@v5
with:
build-args: |
Expand Down
26 changes: 26 additions & 0 deletions docker/emerald-dev/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash

set -euo pipefail

TAG=${TAG:-ghcr.io/oasisprotocol/emerald-dev:local}
NAME="emerald-dev-test"

cleanup() {
# Print standard output content.
docker logs "${NAME}" || true
# Stop the docker container.
docker stop "${NAME}" >/dev/null || true
}

trap cleanup INT TERM

docker run -itd --rm -p8545:8545 --name "${NAME}" "${TAG}" -test-mnemonic >/dev/null

# Check, if depositing tokens to test accounts worked.
while true; do
OUT=$(curl -s -H "Content-Type: application/json" -X POST --data '{"jsonrpc":"2.0","method":"eth_getBalance","params":["0x15d34AAf54267DB7D7c367839AAf71A00a2C6A65", "latest"],"id":1}' http://localhost:8545 || true)
echo $OUT | grep -q 0x21e19e0c9bab2400000 && break
sleep 1
done

cleanup
33 changes: 33 additions & 0 deletions docker/sapphire-dev/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash

set -euo pipefail

TAG=${TAG:-ghcr.io/oasisprotocol/sapphire-dev:local}
NAME="sapphire-dev-test"

cleanup() {
# Print standard output content.
docker logs "${NAME}" || true
# Stop the docker container.
docker stop "${NAME}" >/dev/null || true
}

trap cleanup INT TERM

docker run -itd --rm -p8545:8545 --name "${NAME}" "${TAG}" -test-mnemonic >/dev/null

# Check, if depositing tokens to test accounts worked.
while true; do
OUT=$(curl -s -H "Content-Type: application/json" -X POST --data '{"jsonrpc":"2.0","method":"eth_getBalance","params":["0x15d34AAf54267DB7D7c367839AAf71A00a2C6A65", "latest"],"id":1}' http://localhost:8545 || true)
echo $OUT | grep -q 0x21e19e0c9bab2400000 && break
sleep 1
done

# Check, if public ephemeral key needed for c10l contracts exists.
while true; do
OUT=$(curl -s -H "Content-Type: application/json" -X POST --data '{"jsonrpc":"2.0","method":"oasis_callDataPublicKey","params":[],"id":2}' http://localhost:8545 || true)
echo $OUT | grep -q checksum && break
sleep 1
done

cleanup

0 comments on commit d787d67

Please sign in to comment.