Skip to content

Commit

Permalink
refactor: better input handling with 'workflow_call' in 'Backward com…
Browse files Browse the repository at this point in the history
…patibility' workflow
  • Loading branch information
jpraynaud committed Jan 6, 2025
1 parent 3e7c174 commit fca928a
Showing 1 changed file with 20 additions and 29 deletions.
49 changes: 20 additions & 29 deletions .github/workflows/backward-compatibility.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,19 @@ name: Backward compatibility

on:
workflow_call:
inputs:
total-releases:
required: true
type: number
default: 3
cardano-node-version:
required: true
type: string
default: "10.1.3"
signed-entity-types:
required: true
type: string
default: "CardanoTransactions,CardanoStakeDistribution"
workflow_dispatch:
inputs:
total-releases:
Expand All @@ -21,30 +34,8 @@ on:
default: "CardanoTransactions,CardanoStakeDistribution"

jobs:
prepare-env-variables:
runs-on: ubuntu-22.04
outputs:
total_releases: ${{ steps.set-env.outputs.total_releases }}
cardano_node_version: ${{ steps.set-env.outputs.cardano_node_version }}
signed-entity-types: ${{ steps.set-env.outputs.signed-entity-types }}
steps:
- name: Prepare env variables
id: set-env
shell: bash
run: |
if [[ "${{ github.event_name }}" == "schedule" ]]; then
echo "total_releases=3" >> $GITHUB_OUTPUT
echo 'cardano_node_version=["10.1.3"]' >> $GITHUB_OUTPUT
echo 'signed-entity-types=CardanoTransactions,CardanoStakeDistribution' >> $GITHUB_OUTPUT
else
echo "total_releases=${{ inputs.total-releases }}" >> $GITHUB_OUTPUT
echo "cardano_node_version=[\"${{ inputs.cardano-node-version }}\"]" >> $GITHUB_OUTPUT
echo 'signed-entity-types=${{ inputs.signed-entity-types }}' >> $GITHUB_OUTPUT
fi
prepare-binaries:
runs-on: ubuntu-22.04
needs: [prepare-env-variables]
outputs:
tags: ${{ steps.tags-test-lab.outputs.tags }}
steps:
Expand All @@ -56,7 +47,7 @@ jobs:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: bash
run: |
./.github/workflows/scripts/download-distribution-binaries.sh ${{ needs.prepare-env-variables.outputs.total_releases }}
./.github/workflows/scripts/download-distribution-binaries.sh ${{ inputs.total_releases }}
- name: Install stable toolchain
uses: dtolnay/rust-toolchain@master
Expand Down Expand Up @@ -85,13 +76,13 @@ jobs:
e2e:
runs-on: ubuntu-22.04
needs: [prepare-env-variables, prepare-binaries]
needs: [prepare-binaries]
strategy:
fail-fast: false
matrix:
tag: ${{ fromJSON(needs.prepare-binaries.outputs.tags) }}
node: [mithril-aggregator, mithril-client, mithril-signer]
cardano_node_version: ${{ fromJSON(needs.prepare-env-variables.outputs.cardano_node_version) }}
cardano_node_version: ${{ fromJSON(inputs.cardano_node_version) }}
run_id: ["#1"]

steps:
Expand Down Expand Up @@ -134,7 +125,7 @@ jobs:
--cardano-node-version ${{ matrix.cardano_node_version }} \
--cardano-slot-length 0.25 \
--cardano-epoch-length 45.0 \
--signed-entity-types ${{ needs.prepare-env-variables.outputs.signed-entity-types }}
--signed-entity-types ${{ inputs.signed-entity-types }}
EXIT_CODE=$?
if [ $EXIT_CODE -eq 0 ]; then
echo "SUCCESS=true" >> $GITHUB_ENV
Expand Down Expand Up @@ -200,7 +191,7 @@ jobs:

summarize-test-results:
runs-on: ubuntu-22.04
needs: [prepare-env-variables, e2e]
needs: [e2e]
if: success() || failure()

steps:
Expand Down Expand Up @@ -228,8 +219,8 @@ jobs:
echo "This is the compatibility report of previous distributions nodes with the current unstable nodes." >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Signed entity types**: ${{ needs.prepare-env-variables.outputs.signed-entity-types }}" >> $GITHUB_STEP_SUMMARY
echo "**Cardano nodes**: ${{ needs.prepare-env-variables.outputs.cardano_node_version }}" >> $GITHUB_STEP_SUMMARY
echo "**Signed entity types**: ${{ inputs.signed-entity-types }}" >> $GITHUB_STEP_SUMMARY
echo "**Cardano nodes**: ${{ inputs.cardano_node_version }}" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "| Compatibility | mithril-signer | mithril-aggregator | mithril-client |" >> $GITHUB_STEP_SUMMARY
Expand Down

0 comments on commit fca928a

Please sign in to comment.