From 2b796a0c9ab3614e7360bfbdb451dc5f753e6157 Mon Sep 17 00:00:00 2001 From: Karuppiah Natarajan Date: Fri, 2 Jul 2021 17:47:40 +0530 Subject: [PATCH 1/2] 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 --- scripts/measure-test-flakiness.sh | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100755 scripts/measure-test-flakiness.sh diff --git a/scripts/measure-test-flakiness.sh b/scripts/measure-test-flakiness.sh new file mode 100755 index 00000000000..84f9782ddad --- /dev/null +++ b/scripts/measure-test-flakiness.sh @@ -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} %" From 3317716fafedbf849583fd9df73f70cdfdb382b2 Mon Sep 17 00:00:00 2001 From: Karuppiah Natarajan Date: Tue, 13 Jul 2021 18:50:55 +0530 Subject: [PATCH 2/2] workflow: add workflow to invoke script that measures percentage of commits with failed status The workflow runs on a cron schedule on a weekly basis - once every week Fixes #13167 --- .github/workflows/measure-test-flakiness.yaml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 .github/workflows/measure-test-flakiness.yaml diff --git a/.github/workflows/measure-test-flakiness.yaml b/.github/workflows/measure-test-flakiness.yaml new file mode 100644 index 00000000000..0c128fb2b85 --- /dev/null +++ b/.github/workflows/measure-test-flakiness.yaml @@ -0,0 +1,15 @@ +name: Measure Test Flakiness + +on: + schedule: + - cron: "0 0 * * 0" + +jobs: + measure-test-flakiness: + name: Measure Test Flakiness + runs-on: ubuntu-latest + steps: + - name: Run script to measure test flakiness + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: "./scripts/measure-test-flakiness.sh"