Mithril Client multi-platform test #258
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Mithril Client multi-platform test | |
on: | |
workflow_call: | |
workflow_dispatch: | |
inputs: | |
commit_sha: | |
description: | | |
SHA of the commit on which the mithril-client binary should be obtained, a "ci.yml" workflow must have run | |
on it else no binary would be available leading to the failure of this. | |
If not provided the last commit on the main branch will be used instead. | |
required: false | |
type: string | |
docker_image_id: | |
description: The selected Docker image id. | |
required: true | |
type: string | |
default: latest | |
network: | |
description: The name of the selected Cardano network. | |
required: true | |
type: string | |
default: preview | |
aggregator_endpoint: | |
description: The endpoint of the selected aggregator of the Mithril network. | |
required: true | |
type: string | |
default: https://aggregator.pre-release-preview.api.mithril.network/aggregator | |
genesis_verification_key: | |
description: The genesis verification key location for the Mithril network. | |
required: false | |
type: string | |
default: https://raw.githubusercontent.com/input-output-hk/mithril/main/mithril-infra/configuration/pre-release-preview/genesis.vkey | |
transactions_hashes_to_certify: | |
description: Comma separated list of transactions hashes to test certification on. | |
required: false | |
type: string | |
enable_debug: | |
description: Enable debug output ("-vvv") for the mithril-client calls | |
required: true | |
type: boolean | |
default: false | |
jobs: | |
prepare: | |
runs-on: ubuntu-22.04 | |
outputs: | |
network: ${{ steps.set-env.outputs.network }} | |
aggregator_endpoint: ${{ steps.set-env.outputs.aggregator_endpoint }} | |
genesis_verification_key: ${{ steps.set-env.outputs.genesis_verification_key }} | |
transactions_hashes_to_certify: ${{ steps.set-env.outputs.transactions_hashes_to_certify }} | |
docker_image_id: ${{ steps.set-env.outputs.docker_image_id }} | |
sha: ${{ steps.set-env.outputs.sha }} | |
branch: ${{ steps.set-env.outputs.branch }} | |
enable_debug: ${{ steps.set-env.outputs.enable_debug }} | |
steps: | |
- name: Prepare variables | |
id: set-env | |
shell: bash | |
run: | | |
if [[ "${{ github.event_name }}" == "schedule" ]]; then | |
echo "network=preview" >> $GITHUB_OUTPUT | |
echo "aggregator_endpoint=https://aggregator.testing-preview.api.mithril.network/aggregator" >> $GITHUB_OUTPUT | |
echo "genesis_verification_key=$(curl -s https://raw.githubusercontent.com/input-output-hk/mithril/main/mithril-infra/configuration/testing-preview/genesis.vkey)" >> $GITHUB_OUTPUT | |
echo "transactions_hashes_to_certify=1f7dbc899a898ceb4274bbc33b31ca5f0de497753c6c6795fa34838fc252de9b,c43e809de628f7c1ba41a44f188ed3872bb1f97aa101271e35424a8e1d95bea9,c61e22ac4a79a02b28ed36217369ff6959465790a4fe9e66738b7a820e174fcd" >> $GITHUB_OUTPUT | |
echo "docker_image_id=latest" >> $GITHUB_OUTPUT | |
echo "debug_level=-vvv" >> $GITHUB_OUTPUT | |
echo "branch=main" >> $GITHUB_OUTPUT | |
else | |
echo "network=${{ inputs.network }}" >> $GITHUB_OUTPUT | |
echo "aggregator_endpoint=${{ inputs.aggregator_endpoint }}" >> $GITHUB_OUTPUT | |
echo "genesis_verification_key=$(curl -s ${{ inputs.genesis_verification_key }})" >> $GITHUB_OUTPUT | |
echo "transactions_hashes_to_certify=${{ inputs.transactions_hashes_to_certify }}" >> $GITHUB_OUTPUT | |
echo "docker_image_id=${{ inputs.docker_image_id }}" >> $GITHUB_OUTPUT | |
if [[ "${{ inputs.enable_debug }}" == "true" ]]; then | |
echo "debug_level=-vvv" >> $GITHUB_OUTPUT | |
fi | |
if [[ -n "${{ inputs.commit_sha }}" ]]; then | |
echo "sha=${{ inputs.commit_sha }}" >> $GITHUB_OUTPUT | |
else | |
echo "branch=main" >> $GITHUB_OUTPUT | |
fi | |
fi | |
test-binaries: | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu-22.04, macos-14, macos-14-large, windows-latest] | |
runs-on: ${{ matrix.os }} | |
needs: [prepare] | |
steps: | |
- name: Checkout sources | |
uses: actions/checkout@v4 | |
- name: Prepare variables | |
id: prepare | |
shell: bash | |
run: | | |
echo "sha=${{ needs.prepare.outputs.commit_sha }}" >> $GITHUB_OUTPUT | |
echo "branch=${{ needs.prepare.outputs.branch }}" >> $GITHUB_OUTPUT | |
echo "debug_level=${{ needs.prepare.outputs.enable_debug }}" >> $GITHUB_OUTPUT | |
echo "NETWORK=${{ needs.prepare.outputs.network }}" >> $GITHUB_ENV | |
echo "AGGREGATOR_ENDPOINT=${{ needs.prepare.outputs.aggregator_endpoint }}" >> $GITHUB_ENV | |
echo "GENESIS_VERIFICATION_KEY=$(curl -s ${{ needs.prepare.outputs.genesis_verification_key }})" >> $GITHUB_ENV | |
echo "TRANSACTIONS_HASHES_TO_CERTIFY=${{ needs.prepare.outputs.transactions_hashes_to_certify }}" >> $GITHUB_ENV | |
- name: Assessing aggregator capabilities (Unix) | |
id: aggregator_capability_unix | |
if: runner.os != 'Windows' | |
shell: bash | |
run: | | |
CTX_CAPABILITY=$(wget -q -O - $AGGREGATOR_ENDPOINT | jq '.capabilities.signed_entity_types | contains(["CardanoTransactions"])') | |
CSD_CAPABILITY=$(wget -q -O - $AGGREGATOR_ENDPOINT | jq '.capabilities.signed_entity_types | contains(["CardanoStakeDistribution"])') | |
echo "ctx_enabled=$CTX_CAPABILITY" >> $GITHUB_OUTPUT | |
echo "csd_enabled=$CSD_CAPABILITY" >> $GITHUB_OUTPUT | |
- name: Assessing aggregator capabilities (Windows) | |
id: aggregator_capability_windows | |
if: runner.os == 'Windows' | |
shell: bash | |
run: | | |
aria2c -o aggregator_capabilities.json $AGGREGATOR_ENDPOINT | |
CTX_CAPABILITY=$(jq '.capabilities.signed_entity_types | contains(["CardanoTransactions"])' aggregator_capabilities.json) | |
CSD_CAPABILITY=$(jq '.capabilities.signed_entity_types | contains(["CardanoStakeDistribution"])' aggregator_capabilities.json) | |
echo "ctx_enabled=$CTX_CAPABILITY" >> $GITHUB_OUTPUT | |
echo "csd_enabled=$CSD_CAPABILITY" >> $GITHUB_OUTPUT | |
- name: Checkout binary | |
uses: dawidd6/action-download-artifact@v6 | |
with: | |
name: mithril-distribution-${{ runner.os }}-${{ runner.arch }} | |
path: ./bin | |
commit: ${{ steps.prepare.outputs.sha }} | |
branch: ${{ steps.prepare.outputs.branch }} | |
workflow: ci.yml | |
workflow_conclusion: success | |
- name: Set permissions | |
shell: bash | |
working-directory: ./bin | |
run: chmod +x ./mithril-client | |
- name: Show client version | |
shell: bash | |
working-directory: ./bin | |
run: ./mithril-client ${{ steps.prepare.outputs.debug_level }} --version | |
- name: Cardano-db / list and get last digest | |
shell: bash | |
working-directory: ./bin | |
run: | | |
./mithril-client ${{ steps.prepare.outputs.debug_level }} cardano-db snapshot list | |
echo "CDB_SNAPSHOT_DIGEST=$(./mithril-client cardano-db snapshot list --json | jq -r '.[0].digest')" >> $GITHUB_ENV | |
- name: Cardano-db / download & restore latest | |
shell: bash | |
working-directory: ./bin | |
run: ./mithril-client ${{ steps.prepare.outputs.debug_level }} cardano-db download $CDB_SNAPSHOT_DIGEST | |
- name: Mithril Stake Distribution / list and get last hash | |
shell: bash | |
working-directory: ./bin | |
run: | | |
./mithril-client ${{ steps.prepare.outputs.debug_level }} mithril-stake-distribution list | |
echo "MITHRIL_STAKE_DISTRIBUTION_HASH=$(./mithril-client mithril-stake-distribution list --json | jq -r '.[0].hash')" >> $GITHUB_ENV | |
- name: Mithril Stake Distribution / download & restore latest | |
shell: bash | |
working-directory: ./bin | |
run: ./mithril-client ${{ steps.prepare.outputs.debug_level }} mithril-stake-distribution download $MITHRIL_STAKE_DISTRIBUTION_HASH | |
- name: Cardano transaction / list and get last snapshot | |
if: steps.aggregator_capability_unix.outputs.ctx_enabled == 'true' || steps.aggregator_capability_windows.outputs.ctx_enabled == 'true' | |
shell: bash | |
working-directory: ./bin | |
run: | | |
./mithril-client ${{ steps.prepare.outputs.debug_level }} cardano-transaction snapshot list | |
echo "CTX_SNAPSHOT_HASH=$(./mithril-client cardano-transaction snapshot list --json | jq -r '.[0].hash')" >> $GITHUB_ENV | |
- name: Cardano transaction / show snapshot | |
if: steps.aggregator_capability_unix.outputs.ctx_enabled == 'true' || steps.aggregator_capability_windows.outputs.ctx_enabled == 'true' | |
shell: bash | |
working-directory: ./bin | |
run: ./mithril-client cardano-transaction snapshot show $CTX_SNAPSHOT_HASH | |
- name: Cardano transaction certify | |
if: steps.aggregator_capability_unix.outputs.ctx_enabled == 'true' || steps.aggregator_capability_windows.outputs.ctx_enabled == 'true' | |
shell: bash | |
working-directory: ./bin | |
run: ./mithril-client ${{ steps.prepare.outputs.debug_level }} cardano-transaction certify $TRANSACTIONS_HASHES_TO_CERTIFY | |
- name: Cardano Stake Distribution / list and get last epoch and hash | |
if: steps.aggregator_capability_unix.outputs.csd_enabled == 'true' || steps.aggregator_capability_windows.outputs.csd_enabled == 'true' | |
shell: bash | |
working-directory: ./bin | |
run: | | |
./mithril-client ${{ steps.prepare.outputs.debug_level }} cardano-stake-distribution list | |
CMD_OUTPUT=$(./mithril-client cardano-stake-distribution list --json) | |
echo "CARDANO_STAKE_DISTRIBUTION_EPOCH=$(echo "$CMD_OUTPUT" | jq -r '.[0].epoch')" >> $GITHUB_ENV | |
echo "CARDANO_STAKE_DISTRIBUTION_HASH=$(echo "$CMD_OUTPUT" | jq -r '.[0].hash')" >> $GITHUB_ENV | |
- name: Cardano Stake Distribution / download & restore latest by epoch | |
if: steps.aggregator_capability_unix.outputs.csd_enabled == 'true' || steps.aggregator_capability_windows.outputs.csd_enabled == 'true' | |
shell: bash | |
working-directory: ./bin | |
run: ./mithril-client ${{ steps.prepare.outputs.debug_level }} cardano-stake-distribution download $CARDANO_STAKE_DISTRIBUTION_EPOCH | |
- name: Cardano Stake Distribution / download & restore latest by hash | |
if: steps.aggregator_capability_unix.outputs.csd_enabled == 'true' || steps.aggregator_capability_windows.outputs.csd_enabled == 'true' | |
shell: bash | |
working-directory: ./bin | |
run: ./mithril-client ${{ steps.prepare.outputs.debug_level }} cardano-stake-distribution download $CARDANO_STAKE_DISTRIBUTION_HASH | |
test-docker: | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu-22.04] | |
runs-on: ${{ matrix.os }} | |
needs: [prepare] | |
steps: | |
- name: Prepare variables | |
id: prepare | |
shell: bash | |
run: | | |
echo "debug_level=${{ needs.prepare.outputs.enable_debug }}" >> $GITHUB_OUTPUT | |
echo "MITHRIL_IMAGE_ID=${{ needs.prepare.outputs.docker_image_id }}" >> $GITHUB_ENV | |
- name: Assessing aggregator capabilities | |
id: aggregator_capability | |
shell: bash | |
run: | | |
CTX_CAPABILITY=$(wget -q -O - $AGGREGATOR_ENDPOINT | jq '.capabilities.signed_entity_types | contains(["CardanoTransactions"])') | |
CSD_CAPABILITY=$(wget -q -O - $AGGREGATOR_ENDPOINT | jq '.capabilities.signed_entity_types | contains(["CardanoStakeDistribution"])') | |
echo "ctx_enabled=$CTX_CAPABILITY" >> $GITHUB_OUTPUT | |
echo "csd_enabled=$CSD_CAPABILITY" >> $GITHUB_OUTPUT | |
- name: Prepare Mithril client command | |
id: command | |
shell: bash | |
run: | | |
echo "mithril_client=docker run --rm -e NETWORK=$NETWORK -e GENESIS_VERIFICATION_KEY=$GENESIS_VERIFICATION_KEY -e AGGREGATOR_ENDPOINT=$AGGREGATOR_ENDPOINT --name='mithril-client' ghcr.io/input-output-hk/mithril-client:$MITHRIL_IMAGE_ID" >> $GITHUB_OUTPUT | |
- name: Show client version | |
shell: bash | |
run: ${{ steps.command.outputs.mithril_client }} ${{ steps.prepare.outputs.debug_level }} --version | |
- name: Cardano-db / list and get last digest | |
shell: bash | |
run: | | |
${{ steps.command.outputs.mithril_client }} cardano-db snapshot list | |
echo "CDB_SNAPSHOT_DIGEST=$(${{ steps.command.outputs.mithril_client }} cardano-db snapshot list --json | jq -r '.[0].digest')" >> $GITHUB_ENV | |
- name: Cardano-db / download & restore latest | |
shell: bash | |
run: ${{ steps.command.outputs.mithril_client }} ${{ steps.prepare.outputs.debug_level }} cardano-db download $CDB_SNAPSHOT_DIGEST --download-dir /app | |
- name: Mithril Stake Distribution / list and get last hash | |
shell: bash | |
run: | | |
${{ steps.command.outputs.mithril_client }} mithril-stake-distribution list | |
echo "MITHRIL_STAKE_DISTRIBUTION_HASH=$(${{ steps.command.outputs.mithril_client }} mithril-stake-distribution list --json | jq -r '.[0].hash')" >> $GITHUB_ENV | |
- 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 | |
- name: Cardano transaction / list and get last snapshot | |
if: steps.aggregator_capability.outputs.ctx_enabled == 'true' | |
shell: bash | |
run: | | |
${{ steps.command.outputs.mithril_client }} cardano-transaction snapshot list | |
echo "CTX_SNAPSHOT_HASH=$(${{ steps.command.outputs.mithril_client }} cardano-transaction snapshot list --json | jq -r '.[0].hash')" >> $GITHUB_ENV | |
- name: Cardano transaction / show snapshot | |
if: steps.aggregator_capability.outputs.ctx_enabled == 'true' | |
shell: bash | |
run: ${{ steps.command.outputs.mithril_client }} cardano-transaction snapshot show $CTX_SNAPSHOT_HASH | |
- name: Cardano transaction certify | |
if: steps.aggregator_capability.outputs.ctx_enabled == 'true' | |
shell: bash | |
run: ${{ steps.command.outputs.mithril_client }} ${{ steps.prepare.outputs.debug_level }} cardano-transaction certify $TRANSACTIONS_HASHES_TO_CERTIFY | |
- name: Cardano Stake Distribution / list and get last epoch and hash | |
if: steps.aggregator_capability.outputs.csd_enabled == 'true' | |
shell: bash | |
run: | | |
${{ steps.command.outputs.mithril_client }} cardano-stake-distribution list | |
CMD_OUTPUT=$(${{ steps.command.outputs.mithril_client }} cardano-stake-distribution list --json) | |
echo "CARDANO_STAKE_DISTRIBUTION_EPOCH=$(echo "$CMD_OUTPUT" | jq -r '.[0].epoch')" >> $GITHUB_ENV | |
echo "CARDANO_STAKE_DISTRIBUTION_HASH=$(echo "$CMD_OUTPUT" | jq -r '.[0].hash')" >> $GITHUB_ENV | |
- name: Cardano Stake Distribution / download & restore latest by epoch | |
if: steps.aggregator_capability.outputs.csd_enabled == 'true' | |
shell: bash | |
run: ${{ steps.command.outputs.mithril_client }} ${{ steps.prepare.outputs.debug_level }} cardano-stake-distribution download $CARDANO_STAKE_DISTRIBUTION_EPOCH --download-dir /app | |
- name: Cardano Stake Distribution / download & restore latest by hash | |
if: steps.aggregator_capability.outputs.csd_enabled == 'true' | |
shell: bash | |
run: ${{ steps.command.outputs.mithril_client }} ${{ steps.prepare.outputs.debug_level }} cardano-stake-distribution download $CARDANO_STAKE_DISTRIBUTION_HASH --download-dir /app | |
test-mithril-client-wasm: | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu-22.04] | |
runs-on: ${{ matrix.os }} | |
needs: [prepare] | |
steps: | |
- name: Checkout sources | |
uses: actions/checkout@v4 | |
- name: Download built artifacts | |
uses: dawidd6/action-download-artifact@v6 | |
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 *.tgz && mv package/dist . | |
- name: Install dependencies | |
working-directory: mithril-client-wasm | |
run: make ci-test-install | |
- name: Create .env file | |
working-directory: mithril-client-wasm | |
run: | | |
echo "AGGREGATOR_ENDPOINT=${{ needs.prepare.outputs.aggregator_endpoint }}" > ./ci-test/.env | |
echo "GENESIS_VERIFICATION_KEY=$(curl -s ${{ needs.prepare.outputs.genesis_verification_key }})" >> ./ci-test/.env | |
echo "TRANSACTIONS_HASHES_TO_CERTIFY=${{ needs.prepare.outputs.transactions_hashes_to_certify }}" >> ./ci-test/.env | |
- name: Start the server | |
working-directory: mithril-client-wasm | |
shell: bash | |
run: make ci-test-serve & | |
- name: Wait for the server to be ready | |
shell: bash | |
run: | | |
MAX_ATTEMPTS=30 | |
CURRENT_ATTEMPT=0 | |
while true | |
do | |
sleep 1 | |
CURRENT_ATTEMPT=$(( ${CURRENT_ATTEMPT} + 1 )) | |
if nc -z localhost 8080; then | |
echo "Server is ready." | |
break | |
fi | |
if [ "$CURRENT_ATTEMPT" -ge "$MAX_ATTEMPTS" ]; then | |
echo "Error: Server not ready after $MAX_ATTEMPTS attempts." | |
exit 1 | |
fi | |
done | |
- name: Install selenium | |
shell: bash | |
run: pip install selenium | |
- name: Run Chrome headless | |
shell: bash | |
run: | | |
python3 ./.github/workflows/scripts/run-wasm-tests-browser-headless.py chrome | |
./.github/workflows/scripts/parse-wasm-headless-tests-results.sh chrome-results.html | |
- name: Run Firefox headless | |
shell: bash | |
run: | | |
python3 ./.github/workflows/scripts/run-wasm-tests-browser-headless.py firefox | |
./.github/workflows/scripts/parse-wasm-headless-tests-results.sh firefox-results.html |