Skip to content

Instantly share code, notes, and snippets.

@lukeledet
Created August 8, 2020 23:12
Show Gist options
  • Save lukeledet/13fb742cba2a9f1f83938f632569276a to your computer and use it in GitHub Desktop.
Save lukeledet/13fb742cba2a9f1f83938f632569276a to your computer and use it in GitHub Desktop.
Sum duration of travis builds for a list of repos
#!/bin/bash
#
# Get the sum of the duration of all builds on a specific day for a list of repos
#
# example:
# $ sh travis_seconds.sh
# 2020-08-06
# 47014
#
# repos (org/repo) are in repos.txt, 1 per line
# Get the history for each
# Find the builds in the last day
# Run travis show on each and store the duration
DATE=$(gdate +%Y-%m-%d -d "yesterday")
sed -E 's/(.*)/travis history -l 20 -d -r \1 | ts \1/g' repos.txt | \
parallel -j 4 --delay 3 | \
tee history.txt | \
rg "(.*?) $DATE .*?#(\d+)" -o -r 'travis show $2 -r $1' | \
parallel -j 4 --delay 3 | \
rg "Duration:\s+(\d+) min (\d+) sec" -o -r 'echo $((($1 * 60) + $2))' | \
parallel > $DATE-seconds.txt
echo $DATE
paste -s -d+ $DATE-seconds.txt | bc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment