From b6a4d2fa4825b3f15fe37eb67e4c45c16e390015 Mon Sep 17 00:00:00 2001 From: George Hicken Date: Tue, 20 Feb 2018 11:24:01 -0800 Subject: [PATCH 1/3] Fix github status automation filtering --- tests/pass-rate.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/pass-rate.sh b/tests/pass-rate.sh index d4ab97c07e..1339547ff1 100755 --- a/tests/pass-rate.sh +++ b/tests/pass-rate.sh @@ -13,7 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -curl -s https://api.github.com/repos/vmware/vic/commits?access_token=$GITHUB_AUTOMATION_API_KEY | jq -r ".[].sha" | xargs -n1 -I{} curl -s https://api.github.com/repos/vmware/vic/statuses/{}?access_token=$GITHUB_AUTOMATION_API_KEY | jq -r ".[-0].state" > status.out +commits=$(curl -s https://api.github.com/repos/vmware/vic/commits?access_token=$GITHUB_AUTOMATION_API_KEY | jq -r ' map(.sha) | join(",")') +curl -s https://api.github.com/repos/vmware/vic/statuses/{$commits}?access_token=$GITHUB_AUTOMATION_API_KEY | jq '.[] | select((.context == "continuous-integration/vic/push") and (.state != "pending")) | "\(.target_url): \(.state)"' failures=$(cat status.out | grep -c failure) echo "Number of failed merges to master in the last 30 merges: $failures" From 555d57fd7e97bb6d0f378f741487b52cd978c0e3 Mon Sep 17 00:00:00 2001 From: George Hicken Date: Thu, 22 Feb 2018 10:29:09 -0800 Subject: [PATCH 2/3] Use tee so we see the build report inline --- tests/pass-rate.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/pass-rate.sh b/tests/pass-rate.sh index 1339547ff1..a60aaae762 100755 --- a/tests/pass-rate.sh +++ b/tests/pass-rate.sh @@ -14,7 +14,7 @@ # limitations under the License. commits=$(curl -s https://api.github.com/repos/vmware/vic/commits?access_token=$GITHUB_AUTOMATION_API_KEY | jq -r ' map(.sha) | join(",")') -curl -s https://api.github.com/repos/vmware/vic/statuses/{$commits}?access_token=$GITHUB_AUTOMATION_API_KEY | jq '.[] | select((.context == "continuous-integration/vic/push") and (.state != "pending")) | "\(.target_url): \(.state)"' +curl -s https://api.github.com/repos/vmware/vic/statuses/{$commits}?access_token=$GITHUB_AUTOMATION_API_KEY | jq '.[] | select((.context == "continuous-integration/vic/push") and (.state != "pending")) | "\(.target_url): \(.state)"' | tee status.out failures=$(cat status.out | grep -c failure) echo "Number of failed merges to master in the last 30 merges: $failures" From 646f03d0982e9188bf7c7f1d80ba35b48449b254 Mon Sep 17 00:00:00 2001 From: George Hicken Date: Thu, 22 Feb 2018 10:35:33 -0800 Subject: [PATCH 3/3] Remove hard-coded total value from message --- tests/pass-rate.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/pass-rate.sh b/tests/pass-rate.sh index a60aaae762..0f6968793e 100755 --- a/tests/pass-rate.sh +++ b/tests/pass-rate.sh @@ -17,12 +17,13 @@ commits=$(curl -s https://api.github.com/repos/vmware/vic/commits?access_token=$ curl -s https://api.github.com/repos/vmware/vic/statuses/{$commits}?access_token=$GITHUB_AUTOMATION_API_KEY | jq '.[] | select((.context == "continuous-integration/vic/push") and (.state != "pending")) | "\(.target_url): \(.state)"' | tee status.out failures=$(cat status.out | grep -c failure) -echo "Number of failed merges to master in the last 30 merges: $failures" successes=$(cat status.out | grep -c success) -echo "Number of successful merges to master in the last 30 merges: $successes" let total=$successes+$failures passrate=$(bc -l <<< "scale=2;100 * ($successes / $total)") +echo "Number of failed merges to master in the last $total merges: $failures" +echo "Number of successful merges to master in the last $total merges: $successes" + echo "Current CI passrate: $passrate" curl --max-time 10 --retry 3 -s -d "payload={'channel': '#vic-bots', 'text': 'Current CI passrate: $passrate%'}" "$SLACK_URL"