From 0c2bd3b46082beb14491d4ee8f1b90fb5e18a41d Mon Sep 17 00:00:00 2001 From: Marc Durdin Date: Tue, 25 Oct 2022 11:53:48 +1100 Subject: [PATCH] chore(common): stats script for planning --- resources/stats/.gitignore | 1 + resources/stats/gh-pr.txt | 9 +++++++++ resources/stats/stats.sh | 37 +++++++++++++++++++++++++++++++++++++ 3 files changed, 47 insertions(+) create mode 100644 resources/stats/.gitignore create mode 100644 resources/stats/gh-pr.txt create mode 100755 resources/stats/stats.sh diff --git a/resources/stats/.gitignore b/resources/stats/.gitignore new file mode 100644 index 0000000000..adbb97d2d3 --- /dev/null +++ b/resources/stats/.gitignore @@ -0,0 +1 @@ +data/ \ No newline at end of file diff --git a/resources/stats/gh-pr.txt b/resources/stats/gh-pr.txt new file mode 100644 index 0000000000..defd0b49a0 --- /dev/null +++ b/resources/stats/gh-pr.txt @@ -0,0 +1,9 @@ +{{range .}}{{ + printf "%s\t%s\t%s\t%s\t%s\t%s\n" + (.number | printf "#%v" | autocolor "green") + .state + (.author.login | printf "%s" | autocolor "red") + .title + (.labels | pluck "name" | join "," | printf "%s" | autocolor "blue") + .createdAt +}}{{end}} \ No newline at end of file diff --git a/resources/stats/stats.sh b/resources/stats/stats.sh new file mode 100755 index 0000000000..cb9c02fbb4 --- /dev/null +++ b/resources/stats/stats.sh @@ -0,0 +1,37 @@ +#!/usr/bin/env bash + +set -e +set -u + +## START STANDARD BUILD SCRIPT INCLUDE +# adjust relative paths as necessary +THIS_SCRIPT="$(greadlink -f "${BASH_SOURCE[0]}" 2>/dev/null || readlink -f "${BASH_SOURCE[0]}")" +. "$(dirname "$THIS_SCRIPT")/../build/build-utils.sh" +## END STANDARD BUILD SCRIPT INCLUDE + +. "$KEYMAN_ROOT/resources/shellHelperFunctions.sh" + +cd "$THIS_SCRIPT_PATH" + +platforms=(android/ ios/ linux/ mac/ web/ windows/ developer/ core/ common/models/) + +startdate=2022-05-01 +stable=stable-15.0 +STATS_ROOT="$KEYMAN_ROOT/resources/stats/data/" +mkdir -p "$STATS_ROOT" + +echo -e "Platform\tAll PRs\t${stable}\tFeatures\tIssues" > "${STATS_ROOT}stats.tsv" + +for p in "${platforms[@]}"; do + echo "Getting stats for $p" + mkdir -p "$STATS_ROOT/$p" + gh pr list --json author,createdAt,number,title,labels,state --template "$(cat gh-pr.txt)" --limit 1000 --search "created:>$startdate -label:auto label:$p" --state all > "$STATS_ROOT/${p}pulls.tsv" + gh pr list --json author,createdAt,number,title,labels,state --template "$(cat gh-pr.txt)" --limit 1000 --search "base:$stable created:>$startdate -label:auto label:$p" --state all > "$STATS_ROOT/${p}pulls-stable.tsv" + gh pr list --json author,createdAt,number,title,labels,state --template "$(cat gh-pr.txt)" --limit 1000 --search "created:>$startdate -label:auto label:feat label:$p" --state all > "$STATS_ROOT/${p}pulls-feat.tsv" + gh issue list --json author,createdAt,number,title,labels,state --template "$(cat gh-pr.txt)" --limit 1000 --search "created:>$startdate -label:auto label:$p" --state all > "$STATS_ROOT/${p}issues.tsv" + stat_all=`cat "$STATS_ROOT/${p}pulls.tsv" | wc -l` + stat_stable=`cat "$STATS_ROOT/${p}pulls-stable.tsv" | wc -l` + stat_feat=`cat "$STATS_ROOT/${p}pulls-feat.tsv" | wc -l` + stat_issues=`cat "$STATS_ROOT/${p}issues.tsv" | wc -l` + echo -e "$p\t$stat_all\t$stat_stable\t$stat_feat\t$stat_issues" >> "${STATS_ROOT}stats.tsv" +done