Skip to content

Commit

Permalink
refactor: better input handling with 'workflow_call' in 'Client Multi…
Browse files Browse the repository at this point in the history
… Platform' workflow
  • Loading branch information
jpraynaud committed Jan 6, 2025
1 parent ba66426 commit c8cfb65
Showing 1 changed file with 56 additions and 61 deletions.
117 changes: 56 additions & 61 deletions .github/workflows/test-client.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,34 @@ name: Mithril Client multi-platform test

on:
workflow_call:
inputs:
commit_sha:
required: false
type: string
docker_image_id:
required: true
type: string
default: latest
network:
required: true
type: string
default: preview
aggregator_endpoint:
required: true
type: string
default: https://aggregator.testing-preview.api.mithril.network/aggregator
genesis_verification_key:
required: true
type: string
default: https://raw.githubusercontent.com/input-output-hk/mithril/main/mithril-infra/configuration/testing-preview/genesis.vkey
transactions_hashes_to_certify:
required: true
type: string
default: 1f7dbc899a898ceb4274bbc33b31ca5f0de497753c6c6795fa34838fc252de9b,c43e809de628f7c1ba41a44f188ed3872bb1f97aa101271e35424a8e1d95bea9,c61e22ac4a79a02b28ed36217369ff6959465790a4fe9e66738b7a820e174fcd
enable_debug:
required: true
type: boolean
default: false
workflow_dispatch:
inputs:
commit_sha:
Expand Down Expand Up @@ -43,68 +71,34 @@ on:
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
- name: Prepare environment 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=${{ needs.prepare.outputs.genesis_verification_key }}" >> $GITHUB_ENV
echo "TRANSACTIONS_HASHES_TO_CERTIFY=${{ needs.prepare.outputs.transactions_hashes_to_certify }}" >> $GITHUB_ENV
if [[ -n "${{ inputs.commit_sha }}" ]]; then
echo "sha=${{ inputs.commit_sha }}" >> $GITHUB_OUTPUT
else
echo "branch=main" >> $GITHUB_OUTPUT
fi
if [[ "${{ inputs.enable_debug }}" == "true" ]]; then
echo "debug_level=-vvv" >> $GITHUB_OUTPUT
fi
echo "NETWORK=${{ inputs.network }}" >> $GITHUB_ENV
echo "AGGREGATOR_ENDPOINT=${{ inputs.aggregator_endpoint }}" >> $GITHUB_ENV
echo "GENESIS_VERIFICATION_KEY=$(curl -s ${{ inputs.genesis_verification_key }})" >> $GITHUB_ENV
echo "TRANSACTIONS_HASHES_TO_CERTIFY=${{ inputs.transactions_hashes_to_certify }}" >> $GITHUB_ENV
- name: Assessing aggregator capabilities (Unix)
id: aggregator_capability_unix
Expand Down Expand Up @@ -219,18 +213,20 @@ jobs:
matrix:
os: [ubuntu-22.04]
runs-on: ${{ matrix.os }}
needs: [prepare]
steps:
- name: Prepare variables
- name: Prepare environment 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
echo "NETWORK=${{ needs.prepare.outputs.network }}" >> $GITHUB_ENV
echo "AGGREGATOR_ENDPOINT=${{ needs.prepare.outputs.aggregator_endpoint }}" >> $GITHUB_ENV
echo "GENESIS_VERIFICATION_KEY=${{ needs.prepare.outputs.genesis_verification_key }}" >> $GITHUB_ENV
echo "TRANSACTIONS_HASHES_TO_CERTIFY=${{ needs.prepare.outputs.transactions_hashes_to_certify }}" >> $GITHUB_ENV
if [[ "${{ inputs.enable_debug }}" == "true" ]]; then
echo "debug_level=-vvv" >> $GITHUB_OUTPUT
fi
echo "MITHRIL_IMAGE_ID=${{ inputs.docker_image_id }}" >> $GITHUB_ENV
echo "NETWORK=${{ inputs.network }}" >> $GITHUB_ENV
echo "AGGREGATOR_ENDPOINT=${{ inputs.aggregator_endpoint }}" >> $GITHUB_ENV
echo "GENESIS_VERIFICATION_KEY=$(curl -s ${{ inputs.genesis_verification_key }})" >> $GITHUB_ENV
echo "TRANSACTIONS_HASHES_TO_CERTIFY=${{ inputs.transactions_hashes_to_certify }}" >> $GITHUB_ENV
- name: Assessing aggregator capabilities
id: aggregator_capability
Expand Down Expand Up @@ -313,7 +309,6 @@ jobs:
matrix:
os: [ubuntu-22.04]
runs-on: ${{ matrix.os }}
needs: [prepare]
steps:
- name: Checkout sources
uses: actions/checkout@v4
Expand All @@ -339,9 +334,9 @@ jobs:
- 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=${{ needs.prepare.outputs.genesis_verification_key }}" >> ./ci-test/.env
echo "TRANSACTIONS_HASHES_TO_CERTIFY=${{ needs.prepare.outputs.transactions_hashes_to_certify }}" >> ./ci-test/.env
echo "AGGREGATOR_ENDPOINT=${{ inputs.aggregator_endpoint }}" > ./ci-test/.env
echo "GENESIS_VERIFICATION_KEY=$(curl -s ${{ inputs.genesis_verification_key }})" >> ./ci-test/.env
echo "TRANSACTIONS_HASHES_TO_CERTIFY=${{ inputs.transactions_hashes_to_certify }}" >> ./ci-test/.env
- name: Start the server
working-directory: mithril-client-wasm
Expand Down

0 comments on commit c8cfb65

Please sign in to comment.