Created
May 24, 2019 18:38
-
-
Save nolar/35c73e7a0caa37a30f0a37bdebb5d574 to your computer and use it in GitHub Desktop.
Ad-hoc script to replay code coverage over the whole git history (used in https://github.com/zalando-incubator/kopf/pull/72)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -eux | |
unset E2E # e2e covers everything, but this is not a fair coverage. | |
first=981e664e39955f38d9a279af24ee5be77c7e9a3e | |
last=b6e3ec407f46d8db0f1c5c15fce41359ac76ebf1 # or upstream/master | |
# Master-only commits (i.e. where "master" branch was on merges). | |
# These ones are fast, since it walks "first parent" way only | |
while read -r rev; do | |
git checkout master | |
git reset --hard "$rev" | |
rm -rf .coverage coverage.* htmlcov || true | |
pytest --cov=kopf/ --cov-report=term --cov-branch || true | |
codecov || true | |
done < <( git rev-list ${first}..${last} --reverse --first-parent ) | |
# All the regular commits (those not failing) under their branch names! | |
# These ones are slow, since it is every commit, and e2e tests are slow'ish. | |
prev="${first}" | |
while read -r rev; do | |
subject=$( git log --pretty=format:%s -1 "$rev" ) | |
if [[ "$subject" =~ "from "([^[:space:]]+) ]] ; then | |
branch=$(basename "${BASH_REMATCH[1]}") | |
while read -r subrev; do | |
git branch --force "$branch" "$subrev" | |
git checkout "$branch" | |
rm -rf .coverage coverage.* htmlcov || true | |
pytest --cov=kopf/ --cov-report=term --cov-branch || true | |
codecov || true | |
git checkout master | |
done < <( git rev-list ${prev}..${rev} --reverse ) | |
git branch -D "$branch" || true | |
fi | |
prev="$rev" | |
done < <( git rev-list ${first}..${last} --reverse --first-parent ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment