diff --git a/.gitignore b/.gitignore index dbb48c6e1535..bd21a4b042c4 100644 --- a/.gitignore +++ b/.gitignore @@ -22,4 +22,5 @@ hack/tls-setup/certs *.bak .gobincache/ /Documentation/dev-guide/api_reference_v3.md -/Documentation/dev-guide/api_concurrency_reference_v3.md \ No newline at end of file +/Documentation/dev-guide/api_concurrency_reference_v3.md +commit-and-check-data.json \ No newline at end of file diff --git a/scripts/measure-test-flakyness.sh b/scripts/measure-test-flakyness.sh new file mode 100755 index 000000000000..2bc3b8fcf1d0 --- /dev/null +++ b/scripts/measure-test-flakyness.sh @@ -0,0 +1,21 @@ +#!/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 + +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 . > commit-and-check-data.json + +failure_percentage=$(jq '.data.repository.defaultBranchRef.target.history.edges | reduce .[] as $item (0; if $item.node.statusCheckRollup.state == "FAILURE" then (. + 1) else . end)' commit-and-check-data.json) + +echo "Commit status failure percentage is - ${failure_percentage} %"