-
Notifications
You must be signed in to change notification settings - Fork 165
98 lines (93 loc) · 3.83 KB
/
flaky.yaml
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
# Run all tests, including flaky test.
#
# The default CI workflow ignores flaky tests. This workflow will run
# all tests, including ignored ones.
#
# To use this workflow you can either:
#
# - Label a PR with "flaky-test", the normal CI workflow will not run
# any jobs but the jobs here will be run. Note that to merge the PR
# you'll need to remove the label eventually because the normal CI
# jobs are required by branch protection.
#
# - Manually trigger the workflow, you may choose a branch for this to
# run on.
#
# Additionally this jobs runs once a day on a schedule.
#
# Currently doctests are not run by this workflow.
name: Flaky CI
on:
pull_request:
types: [ 'labeled', 'unlabeled', 'opened', 'synchronize', 'reopened' ]
schedule:
# 06:30 UTC every day
- cron: '30 6 * * *'
workflow_dispatch:
inputs:
branch:
description: 'Branch to run on, defaults to main'
required: true
default: 'main'
type: string
concurrency:
group: flaky-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env:
IROH_FORCE_STAGING_RELAYS: "1"
jobs:
tests:
if: "contains(github.event.pull_request.labels.*.name, 'flaky-test') || github.event_name == 'workflow_dispatch' || github.event_name == 'schedule'"
uses: './.github/workflows/tests.yaml'
with:
flaky: true
git-ref: ${{ inputs.branch }}
notify:
needs: tests
if: ${{ always() }}
runs-on: ubuntu-latest
steps:
- name: Extract test results
run: |
printf '${{ toJSON(needs) }}\n'
result=$(echo '${{ toJSON(needs) }}' | jq -r .tests.result)
echo TESTS_RESULT=$result
echo "TESTS_RESULT=$result" >>"$GITHUB_ENV"
- name: download nextest reports
uses: actions/download-artifact@v4
with:
pattern: libtest_run_${{ github.run_number }}-${{ github.run_attempt }}-*
merge-multiple: true
path: nextest-results
- name: create summary report
id: make_summary
run: |
# prevent the glob expression in the loop to match on itself when the dir is empty
shopt -s nullglob
# to deal with multiline outputs it's recommended to use a random EOF, the syntax is based on
# https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#multiline-strings
EOF=aP51VriWCxNJ1JjvmO9i
echo "summary<<$EOF" >> $GITHUB_OUTPUT
echo "Flaky tests failure:" >> $GITHUB_OUTPUT
echo " " >> $GITHUB_OUTPUT
for report in nextest-results/*.json; do
# remove the name prefix and extension, and split the parts
name=$(echo ${report:16:-5} | tr _ ' ')
echo $name
echo "- **$name**" >> $GITHUB_OUTPUT
# select the failed tests
# the tests have this format "crate::module$test_name", the sed expressions remove the quotes and replace $ for ::
failure=$(jq --slurp '.[] | select(.["type"] == "test" and .["event"] == "failed" ) | .["name"]' $report | sed -e 's/^"//g' -e 's/\$/::/' -e 's/"//')
echo "$failure"
echo "$failure" >> $GITHUB_OUTPUT
done
echo "" >> $GITHUB_OUTPUT
echo "See https://github.com/n0-computer/iroh/actions/workflows/flaky.yaml" >> $GITHUB_OUTPUT
echo "$EOF" >> $GITHUB_OUTPUT
- name: Notify discord on failure
uses: n0-computer/discord-webhook-notify@v1
if: ${{ env.TESTS_RESULT == 'failure' || env.TESTS_RESULT == 'success' }}
with:
severity: ${{ env.TESTS_RESULT == 'failure' && 'warn' || 'info' }}
details: ${{ env.TESTS_RESULT == 'failure' && steps.make_summary.outputs.summary || 'No flaky failures!' }}
webhookUrl: ${{ secrets.DISCORD_N0_GITHUB_CHANNEL_WEBHOOK_URL }}