Skip to content

Commit

Permalink
feat: [WIP] add test-mithril-client-wasm job
Browse files Browse the repository at this point in the history
  • Loading branch information
dlachaume committed Jan 29, 2024
1 parent ab19bd4 commit 8e04fb5
Showing 1 changed file with 70 additions and 0 deletions.
70 changes: 70 additions & 0 deletions .github/workflows/test-client.yml
Original file line number Diff line number Diff line change
Expand Up @@ -159,3 +159,73 @@ jobs:
- name: Mithril Stake Distribution / download & restore latest
shell: bash
run: ${{ steps.command.outputs.mithril_client }} ${{ steps.prepare.outputs.debug_level }} mithril-stake-distribution download $MITHRIL_STAKE_DISTRIBUTION_HASH --download-dir /app

test-mithril-client-wasm:
strategy:
fail-fast: false
matrix:
os: [ ubuntu-22.04 ]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout sources
uses: actions/checkout@v3

- name: Download built artifacts
uses: dawidd6/action-download-artifact@v2
with:
name: mithril-distribution-wasm
path: ./mithril-client-wasm
commit: ${{ steps.prepare.outputs.sha }}
branch: ${{ steps.prepare.outputs.branch }}
workflow: ci.yml
workflow_conclusion: success

- name: Unpack 'mithril-client-wasm' package
working-directory: mithril-client-wasm
run: tar -xvzf pkg/*.tgz -C pkg/ && mv pkg/package/* pkg/

- name: Install dependencies
working-directory: mithril-client-wasm
run: make www-test-install

- name: Create .env file
working-directory: mithril-client-wasm
run: |
echo "AGGREGATOR_ENDPOINT=${{ inputs.aggregator_endpoint }}" > ./www-test/.env
echo "GENESIS_VERIFICATION_KEY=$(curl -s ${{ inputs.genesis_verification_key }})" >> ./www-test/.env
- name: Start the server
working-directory: mithril-client-wasm
shell: bash
run: make www-test-serve &

- name: Wait for the server to be ready
shell: bash
run: |
max_attempts=30
current_attempt=0
while ! nc -z localhost 8080 || true; do
sleep 1
((current_attempt++))
if [ "$current_attempt" -ge "$max_attempts" ]; then
echo "Error: Server not ready after $max_attempts attempts."
exit 1
fi
done
- name: Run Chrome headless
working-directory: mithril-client-wasm
shell: bash
run: |
/usr/bin/google-chrome --headless --virtual-time-budget=60000 --dump-dom http://localhost:8080 > www-test-results.html
cat www-test-results.html
# Handle results
if grep -q 'title="FAILED"' www-test-results.html; then
failed_info=$(grep -oE '<div id="[^"]+" title="FAILED">([^<]+)' www-test-results.html | awk 'NR==1 {print substr($0, index($0,$4))}')
echo $failed_info
exit 1
else
echo "All tests passed."
fi

0 comments on commit 8e04fb5

Please sign in to comment.