diff --git a/.github/workflows/diff.yaml b/.github/workflows/diff.yaml index df9ea6bbc..e161af297 100644 --- a/.github/workflows/diff.yaml +++ b/.github/workflows/diff.yaml @@ -377,6 +377,16 @@ jobs: --groups aggregation 1000_create unwind_create dense_expand match \ --no-strict + - name: Get branch name (merge) + if: github.event_name != 'pull_request' + shell: bash + run: echo "BRANCH_NAME=$(echo ${GITHUB_REF#refs/heads/} | tr / -)" >> $GITHUB_ENV + + - name: Get branch name (pull request) + if: github.event_name == 'pull_request' + shell: bash + run: echo "BRANCH_NAME=$(echo ${GITHUB_HEAD_REF} | tr / -)" >> $GITHUB_ENV + - name: Upload macro benchmark results run: | cd tools/bench-graph-client @@ -386,7 +396,8 @@ jobs: ./main.py --benchmark-name "macro_benchmark" \ --benchmark-results-path "../../tests/macro_benchmark/.harness_summary" \ --github-run-id "${{ github.run_id }}" \ - --github-run-number "${{ github.run_number }}" + --github-run-number "${{ github.run_number }}" \ + --head-branch-name "${{ env.BRANCH_NAME }}" - name: Run mgbench run: | @@ -402,4 +413,5 @@ jobs: ./main.py --benchmark-name "mgbench" \ --benchmark-results-path "../../tests/mgbench/benchmark_result.json" \ --github-run-id "${{ github.run_id }}" \ - --github-run-number "${{ github.run_number }}" + --github-run-number "${{ github.run_number }}" \ + --head-branch-name "${{ env.BRANCH_NAME }}" diff --git a/tools/bench-graph-client/main.py b/tools/bench-graph-client/main.py index e90340ef0..edb09ecde 100755 --- a/tools/bench-graph-client/main.py +++ b/tools/bench-graph-client/main.py @@ -8,10 +8,11 @@ the Bench Graph server. import json import logging import os -import requests import subprocess -from datetime import datetime from argparse import ArgumentParser +from datetime import datetime + +import requests SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) @@ -32,6 +33,7 @@ def parse_args(): argp.add_argument("--benchmark-results-path", type=str, required=True) argp.add_argument("--github-run-id", type=int, required=True) argp.add_argument("--github-run-number", type=int, required=True) + argp.add_argument("--head-branch-name", type=str, required=True) return argp.parse_args() @@ -39,10 +41,6 @@ def post_measurement(args): with open(args.benchmark_results_path, "r") as f: data = json.load(f) timestamp = datetime.now().timestamp() - branch = subprocess.run( - ["git", "rev-parse", "--abbrev-ref", "HEAD"], - stdout=subprocess.PIPE, - check=True).stdout.decode("utf-8").strip() req = requests.post( f"{BENCH_GRAPH_SERVER_ENDPOINT}/measurements", json={ @@ -54,7 +52,7 @@ def post_measurement(args): "github_run_id": args.github_run_id, "github_run_number": args.github_run_number, "results": data, - "git_branch": branch}, + "git_branch": args.head_branch_name}, timeout=1) assert req.status_code == 200, \ f"Uploading {args.benchmark_name} data failed."