-
Notifications
You must be signed in to change notification settings - Fork 42
251 lines (221 loc) · 9.5 KB
/
backward-compatibility.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
name: Backward compatibility
on:
workflow_call:
workflow_dispatch:
inputs:
total-releases:
description: "Total number of releases to test"
required: true
type: number
default: 3
cardano-node-version:
description: "Cardano node version used in e2e"
required: true
type: string
default: "10.1.3"
signed-entity-types:
description: "Signed entity types parameters (discriminants names in an ordered comma separated list)"
required: true
type: string
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:
- name: Checkout
uses: actions/checkout@v4
- name: Download releases artifacts binaries
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: bash
run: |
./.github/workflows/scripts/download-distribution-binaries.sh ${{ needs.prepare-env-variables.outputs.total_releases }}
- name: Install stable toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
- name: Build e2e
shell: bash
run: |
cargo build --release --bin mithril-end-to-end
cp ./target/release/mithril-end-to-end ./mithril-binaries/unstable
- name: Upload Mithril binaries
uses: actions/upload-artifact@v4
with:
name: mithril-binaries
path: ./mithril-binaries
- name: Prepare test lab tags
id: tags-test-lab
shell: bash
run: |
TAGS=$(jq -c '.' ./mithril-binaries/tags.json)
echo "Test Lab Tags: $TAGS"
echo "tags=$TAGS" >> $GITHUB_OUTPUT
e2e:
runs-on: ubuntu-22.04
needs: [prepare-env-variables, 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) }}
run_id: ["#1"]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download binaries
uses: actions/download-artifact@v4
with:
name: mithril-binaries
path: ./mithril-binaries
- name: Prepare binaries
shell: bash
run: |
mkdir -p mithril-binaries/e2e
cp ./mithril-binaries/unstable/* ./mithril-binaries/e2e
cp --remove-destination ./mithril-binaries/${{ matrix.tag }}/${{ matrix.node }} ./mithril-binaries/e2e/
chmod +x ./mithril-binaries/e2e/mithril-aggregator
chmod +x ./mithril-binaries/e2e/mithril-client
chmod +x ./mithril-binaries/e2e/mithril-signer
chmod +x ./mithril-binaries/e2e/mithril-relay
chmod +x ./mithril-binaries/e2e/mithril-end-to-end
mkdir artifacts
- name: Run E2E tests
uses: nick-fields/retry@v3
with:
shell: bash
max_attempts: 3
retry_on_exit_code: 2
timeout_minutes: 10
warning_on_retry: true
command: |
./mithril-binaries/e2e/mithril-end-to-end -vvv \
--bin-directory ./mithril-binaries/e2e \
--work-directory=./artifacts \
--devnet-scripts-directory=./mithril-test-lab/mithril-devnet \
--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 }}
EXIT_CODE=$?
if [ $EXIT_CODE -eq 0 ]; then
echo "SUCCESS=true" >> $GITHUB_ENV
else
echo "SUCCESS=false" >> $GITHUB_ENV
fi
exit $EXIT_CODE
- name: Define the JSON file name for the test result
shell: bash
if: success() || failure()
run: echo "RESULT_FILE_NAME=e2e-test-result-run_${{ github.run_number }}-attempt_${{ github.run_attempt }}-tag_${{ matrix.tag }}-node-${{ matrix.node }}-cardano-${{ matrix.cardano_node_version }}-run_id_${{ matrix.run_id }}" >> $GITHUB_ENV
- name: Write test result JSON
if: success() || failure()
shell: bash
run: |
AGGREGATOR_TAG="unstable"
SIGNER_TAG="unstable"
CLIENT_TAG="unstable"
case "$NODE" in
mithril-aggregator)
AGGREGATOR_TAG="${{ matrix.tag }}"
;;
mithril-signer)
SIGNER_TAG="${{ matrix.tag }}"
;;
mithril-client)
CLIENT_TAG="${{ matrix.tag }}"
;;
esac
jq -n --arg TAG "${{ matrix.tag }}" \
--arg NODE "${{ matrix.node }}" \
--arg CARDANO_NODE "${{ matrix.cardano_node_version }}" \
--arg AGGREGATOR "$AGGREGATOR_TAG" \
--arg SIGNER "$SIGNER_TAG" \
--arg CLIENT "$CLIENT_TAG" \
--argjson SUCCESS "${{ env.SUCCESS }}" \
'{tag: $TAG, node: $NODE, mithril_signer: $SIGNER, mithril_aggregator: $AGGREGATOR, mithril_client: $CLIENT, cardano_node_version: $CARDANO_NODE, success: $SUCCESS}' \
> ./${{ env.RESULT_FILE_NAME }}.json
- name: Upload test result JSON
if: success() || failure()
uses: actions/upload-artifact@v4
with:
name: ${{ env.RESULT_FILE_NAME }}
path: ./${{ env.RESULT_FILE_NAME }}.json
- name: Upload E2E Tests Artifacts
if: ${{ failure() }}
uses: actions/upload-artifact@v4
with:
name: mithril-e2e-tests-artifacts-run_${{ github.run_number }}-attempt_${{ github.run_attempt }}-tag_${{ matrix.tag }}-node-${{ matrix.node }}-cardano-${{ matrix.cardano_node_version }}-run_id_${{ matrix.run_id }}
path: |
./artifacts/*
# including node.sock makes the upload fails so exclude them:
!./artifacts/**/node.sock
# exclude cardano tools, saving ~500mb of data:
!./artifacts/devnet/bin/
if-no-files-found: error
summarize-test-results:
runs-on: ubuntu-22.04
needs: [prepare-env-variables, e2e]
if: success() || failure()
steps:
- name: Download all test result artifacts
uses: actions/download-artifact@v4
with:
path: ./test-results
pattern: e2e-test-result*
merge-multiple: true
- name: Concatenate JSON result files into summary.json
shell: bash
run: |
jq -s '.' ./test-results/e2e-test-result-*.json > ./test-results/summary.json
- name: Add distributions backward compatibility summary
shell: bash
run: |
CHECK_MARK=":heavy_check_mark:"
CROSS_MARK=":no_entry:"
echo "## Distributions backward compatibility" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
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 "" >> $GITHUB_STEP_SUMMARY
echo "| Compatibility | mithril-signer | mithril-aggregator | mithril-client |" >> $GITHUB_STEP_SUMMARY
echo "| --- | :---: | :---: | :---: |" >> $GITHUB_STEP_SUMMARY
# Transform summary.json into Markdown table rows
jq -r --arg CHECK_MARK "$CHECK_MARK" --arg CROSS_MARK "$CROSS_MARK" \
'group_by(.tag) |
sort_by(.[0].tag | tonumber) | reverse |
.[] |
{
tag: .[0].tag,
signer: (map(select(.node == "mithril-signer") | if .success then $CHECK_MARK else $CROSS_MARK end) | join("")),
aggregator: (map(select(.node == "mithril-aggregator") | if .success then $CHECK_MARK else $CROSS_MARK end) | join("")),
client: (map(select(.node == "mithril-client") | if .success then $CHECK_MARK else $CROSS_MARK end) | join(""))
} |
"| `\(.tag)` | \(.signer) | \(.aggregator) | \(.client) |"' "./test-results/summary.json" >> $GITHUB_STEP_SUMMARY
cat "$GITHUB_STEP_SUMMARY"