Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: Add GitHub action to collect build statistics
Also reorganise the scripts used for workflows.
- Loading branch information
Showing
8 changed files
with
145 additions
and
8 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
name: Stats | ||
|
||
on: | ||
status: | ||
push: | ||
branches: | ||
- master | ||
- rvl/adp-921/optimize-hydra-eval | ||
|
||
jobs: | ||
stats: | ||
env: | ||
branch: ci-stats | ||
if: ${{ (github.ref == 'refs/heads/master' && (github.event.state == 'success' || github.event.state == 'failure') && github.event.context == 'ci/hydra-build:required') || github.ref == 'refs/heads/rvl/adp-921/optimize-hydra-eval' }} | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- name: '❄ Wait for Hydra build' | ||
uses: rvl/hydra-build-products-action@master | ||
id: hydra | ||
with: | ||
hydra: https://hydra.iohk.io | ||
statusName: ci/hydra-eval | ||
jobs: required | ||
requiredJob: required | ||
project: Cardano | ||
jobset: cardano-wallet | ||
badge: "${{ github.event_name == 'status' && 'yes' || 'no' }}" | ||
|
||
- name: '📥 Checkout Code' | ||
uses: actions/checkout@v2 | ||
|
||
- name: '📥 Checkout Stats' | ||
uses: actions/checkout@v2 | ||
with: | ||
ref: ${{ env.branch }} | ||
fetch-depth: 1 | ||
path: _build | ||
|
||
- name: '📘 Publish Stats' | ||
if: ${{ github.ref == 'refs/heads/master' || github.ref == 'refs/heads/rvl/adp-921/optimize-hydra-eval' }} | ||
working-directory: _build | ||
run: | | ||
echo '${{ steps.hydra.outputs.evaluation }}' > eval.json | ||
echo '${{ steps.hydra.outputs.builds }}' > builds.json | ||
echo '${{ steps.hydra.outputs.timings }}' > timings.json | ||
../scripts/gh/update-stats.sh '${{ env.branch}}' eval.json builds.json timings.json | ||
- name: '📛 Update Badge' | ||
if: ${{ github.event_name == 'status' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/rvl/adp-921/optimize-hydra-eval') }} | ||
working-directory: _build | ||
run: | | ||
../scripts/gh/update-badge.sh '${{ env.branch}}' <(echo '${{ steps.hydra.outputs.badge }}') |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/usr/bin/env bash | ||
# shellcheck disable=SC2034 # Sourcing script uses variables | ||
|
||
check_branch() { | ||
branch=$(git branch --show-current) | ||
if [ -n "$1" ] && [ "$1" != "$branch" ]; then | ||
echo "error: Current branch $branch is not the intended destination branch $1" > /dev/stderr | ||
exit 2 | ||
fi | ||
} | ||
|
||
exit_unless_index_changed() { | ||
if git diff-index --cached --quiet HEAD --; then | ||
echo "No changes to commit, exiting." | ||
exit 0 | ||
fi | ||
} | ||
|
||
commit_and_push() { | ||
exit_unless_index_changed | ||
git commit -m "$1$commit_msg_suffix" | ||
if [ -z "${NO_PUSH:-}" ]; then | ||
git push | ||
fi | ||
} | ||
|
||
export GIT_AUTHOR_NAME='William King Noel Bot' | ||
export GIT_AUTHOR_EMAIL='adrestia@iohk.io' | ||
|
||
commit_msg_suffix=" ${GITHUB_SHA:-update}" | ||
dir=$(date +%Y-%m) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
source "${BASH_SOURCE%/*}/common.sh" | ||
|
||
dest_branch=${1:-} | ||
badge_url=${2:-} | ||
|
||
if [ -z "$badge_url" ]; then | ||
echo "usage: $0 DEST_BRANCH BADGE_URL" | ||
exit 1 | ||
fi | ||
|
||
check_branch "$dest_branch" | ||
|
||
out="hydra-badge.svg" | ||
|
||
echo "GET $badge_url" | ||
curl --fail "$badge_url" -o "$out" | ||
git add "$out" | ||
|
||
commit_and_push "badge: hydra" |
File renamed without changes.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
source "${BASH_SOURCE%/*}/common.sh" | ||
|
||
dest_branch="${1:-}" | ||
eval="${2:-}" | ||
builds="${3:-}" | ||
timings="${4:-}" | ||
|
||
if [ -z "$timings" ]; then | ||
echo "usage: $0 DEST_BRANCH EVAL.json BUILDS.json TIMINGS.json" | ||
exit 1 | ||
fi | ||
|
||
check_branch "$dest_branch" | ||
|
||
eval_id=$(jq .id "$eval") | ||
|
||
out="$dir/hydra/eval-$eval_id.json" | ||
|
||
mkdir -p "$(dirname "$out")" | ||
|
||
jq --slurpfile evals "$eval" --slurpfile builds "$builds" '$evals[0] as $eval | { eval: $eval.id, builds: { required: $builds[0].required|{id,finished,buildstatus,buildmetrics} }, rev: $eval.jobsetevalinputs["cardano-wallet"].revision, timings: . }' "$timings" > "$out" | ||
|
||
git add "$out" | ||
commit_and_push "stats: hydra" |