Leaderboard Update workflow (itbench-hub/ITBench)
The Leaderboard Update workflow from itbench-hub/ITBench, explained and optimized by Latchkey.
A
CI health: A - excellent
Point runs-on at Latchkey and get job timeouts, self-healing for flaky steps, and up to 58% lower cost, applied automatically.
What it does
This is the Leaderboard Update workflow from the itbench-hub/ITBench repository, a real project running GitHub Actions. It is shown here with attribution under its Apache-2.0 license.
Below, Latchkey shows a faster, safer version produced by its optimization engine.
The workflow
workflow (.yml)
name: Leaderboard Update
on:
workflow_dispatch:
inputs:
use-sample:
type: boolean
required: false
description: If set, display leaderboard with sample data
benchmark-id:
type: string
required: false
description: If set, display leaderboard of the provided benchmark id
github-username:
type: string
required: false
description: If set, display leaderboard of the provided github username
jobs:
update_leaderboard:
runs-on: ubuntu-latest
environment: onboarding
name: Update the Leaderboard
steps:
- name: Checkout Repository
uses: actions/checkout@v7.0.0
- name: List Issues of Finished Benchmark
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
run: |
gh issue list --label "benchmark" --state "closed" --json number,author,comments > issues.json
jq -c '[.[].number]' issues.json
usernames=($(jq -r '.[].author.login' issues.json | sort -u))
query='{'$'\n'
for i in "${!usernames[@]}"; do
login="${usernames[$i]}"
query+=" u$((i+1)): user(login: \"${login}\") { login company }"$'\n'
done
query+='}'
gh api graphql -f query="$query" | jq -r '
.data |
to_entries |
map({ key: .value.login, value: { company: .value.company } }) |
from_entries
' > users.json
- name: Pull Leaderboard data
env:
ITBENCH_API: ${{vars.ITBENCH_API}}
ITBENCH_API_TOKEN: ${{ secrets.ITBENCH_API_TOKEN }}
GH_REPO: ${{ github.repository }}
USE_SAMPLE: ${{ github.event.inputs.use-sample }}
BENCHMARK_ID: ${{ github.event.inputs.benchmark-id }}
GITHUB_USERNAME: ${{ github.event.inputs.github-username }}
run: |
echo "Parse gh issues"
python ./.github/workflows/update_benchmark_helper.py parse -i issues.json -o updated_issues.json
echo "Requesting Leaderboard data from API"
if [ "$USE_SAMPLE" == "true" ]; then
python ./.github/workflows/leaderboard.py global --sample -b $BENCHMARK_ID -u $GITHUB_USERNAME --issues updated_issues.json --users users.json --out-overall LEADERBOARD.md --out-ciso LEADERBOARD_CISO.md --out-sre LEADERBOARD_SRE.md
else
python ./.github/workflows/leaderboard.py global --issues updated_issues.json --users users.json --out-overall LEADERBOARD.md --out-ciso LEADERBOARD_CISO.md --out-sre LEADERBOARD_SRE.md
fi
- name: Open PR
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config --global user.name "GitHub Actions"
git config --global user.email "actions@github.com"
git checkout -b leaderboard
git add LEADERBOARD_CISO.md LEADERBOARD_SRE.md
git commit -m "chore: update leaderboard data"
git push origin leaderboard -f
gh pr create \
--base main \
--head leaderboard \
--title "chore: update leaderboard data" \
--body "This PR updates the leaderboard automatically via GitHub Actions."
The same workflow, on Latchkey
Removes redundant runs and caps runaway jobs. Added and changed lines are highlighted.
name: Leaderboard Update on: workflow_dispatch: inputs: use-sample: type: boolean required: false description: If set, display leaderboard with sample data benchmark-id: type: string required: false description: If set, display leaderboard of the provided benchmark id github-username: type: string required: false description: If set, display leaderboard of the provided github username jobs: update_leaderboard: timeout-minutes: 30 runs-on: latchkey-small environment: onboarding name: Update the Leaderboard steps: - name: Checkout Repository uses: actions/checkout@v7.0.0 - name: List Issues of Finished Benchmark env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GH_REPO: ${{ github.repository }} run: | gh issue list --label "benchmark" --state "closed" --json number,author,comments > issues.json jq -c '[.[].number]' issues.json usernames=($(jq -r '.[].author.login' issues.json | sort -u)) query='{'$'\n' for i in "${!usernames[@]}"; do login="${usernames[$i]}" query+=" u$((i+1)): user(login: \"${login}\") { login company }"$'\n' done query+='}' gh api graphql -f query="$query" | jq -r ' .data | to_entries | map({ key: .value.login, value: { company: .value.company } }) | from_entries ' > users.json - name: Pull Leaderboard data env: ITBENCH_API: ${{vars.ITBENCH_API}} ITBENCH_API_TOKEN: ${{ secrets.ITBENCH_API_TOKEN }} GH_REPO: ${{ github.repository }} USE_SAMPLE: ${{ github.event.inputs.use-sample }} BENCHMARK_ID: ${{ github.event.inputs.benchmark-id }} GITHUB_USERNAME: ${{ github.event.inputs.github-username }} run: | echo "Parse gh issues" python ./.github/workflows/update_benchmark_helper.py parse -i issues.json -o updated_issues.json echo "Requesting Leaderboard data from API" if [ "$USE_SAMPLE" == "true" ]; then python ./.github/workflows/leaderboard.py global --sample -b $BENCHMARK_ID -u $GITHUB_USERNAME --issues updated_issues.json --users users.json --out-overall LEADERBOARD.md --out-ciso LEADERBOARD_CISO.md --out-sre LEADERBOARD_SRE.md else python ./.github/workflows/leaderboard.py global --issues updated_issues.json --users users.json --out-overall LEADERBOARD.md --out-ciso LEADERBOARD_CISO.md --out-sre LEADERBOARD_SRE.md fi - name: Open PR env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | git config --global user.name "GitHub Actions" git config --global user.email "actions@github.com" git checkout -b leaderboard git add LEADERBOARD_CISO.md LEADERBOARD_SRE.md git commit -m "chore: update leaderboard data" git push origin leaderboard -f gh pr create \ --base main \ --head leaderboard \ --title "chore: update leaderboard data" \ --body "This PR updates the leaderboard automatically via GitHub Actions."
What changed
- Run on Latchkey managed runners with one line (
runs-on), which apply the fixes below automatically and self-heal transient failures. This example useslatchkey-small; pick the runner size that fits the job. - Add a job timeout so a hung step cannot burn hours of runner time.
This workflow runs 1 job per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.