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 30, 2023
1 parent ceb9dc8 commit 80802b8
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 1 deletion.
23 changes: 22 additions & 1 deletion .github/workflows/docker-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
docker:
Expand Down Expand Up @@ -33,7 +36,24 @@ 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 }}:local
load: true

- name: Test
timeout-minutes: 5
working-directory: docker/${{ matrix.docker_image }}
run: ./test.sh

- name: Push
if: ${{ github.event_name == 'push' }}
uses: docker/build-push-action@v5
with:
build-args: |
Expand All @@ -49,6 +69,7 @@ jobs:
org.opencontainers.image.revision=${{ github.sha }}
- name: Prune old ghcr.io/oasisprotocol/${{ matrix.docker_image }} images
if: ${{ github.event_name == 'push' }}
uses: vlaurin/action-ghcr-prune@v0.5.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
Expand Down
29 changes: 29 additions & 0 deletions docker/emerald-dev/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash

# Temporarily disabled. See https://github.com/oasisprotocol/oasis-web3-gateway/issues/471
exit 0

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 80802b8

Please sign in to comment.