mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
scripts: add script to measure percentage of commits with failed status
This is to start measuring the test flakiness and see the numbers improving once we improve and deflake flaky tests Fixes #13167
This commit is contained in:
parent
1ad2150220
commit
2b796a0c9a
27
scripts/measure-test-flakiness.sh
Executable file
27
scripts/measure-test-flakiness.sh
Executable file
@ -0,0 +1,27 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
set -o pipefail
|
||||
|
||||
if [[ -z ${GITHUB_TOKEN} ]]
|
||||
then
|
||||
echo "Please set the \$GITHUB_TOKEN environment variable for the script to work"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
temp_dir=$(mktemp -d)
|
||||
|
||||
trap '{ rm -rf -- "${temp_dir}"; }' EXIT
|
||||
|
||||
json_file="${temp_dir}/commit-and-check-data.json"
|
||||
|
||||
curl --fail --show-error --silent -H "Authorization: token ${GITHUB_TOKEN}" \
|
||||
-X POST \
|
||||
-d '{
|
||||
"query": "query { repository(owner: \"etcd-io\", name: \"etcd\") { defaultBranchRef { target { ... on Commit { history(first: 100) { edges { node { ... on Commit { commitUrl statusCheckRollup { state } } } } } } } } } }"
|
||||
}' \
|
||||
https://api.github.com/graphql | jq . > "${json_file}"
|
||||
|
||||
failure_percentage=$(jq '.data.repository.defaultBranchRef.target.history.edges | reduce .[] as $item (0; if $item.node.statusCheckRollup.state == "FAILURE" then (. + 1) else . end)' "${json_file}")
|
||||
|
||||
echo "Commit status failure percentage is - ${failure_percentage} %"
|
Loading…
x
Reference in New Issue
Block a user