Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ set -euo pipefail

ARTIFACTS_DIR="${1:-metrics-diff}"
OUTPUT_FILE="${2:-comparison.md}"
BASE_BRANCH="${BASE_BRANCH:-base branch}"

append_metric_cell() {
local file="$1"
Expand Down Expand Up @@ -43,4 +44,4 @@ fi

echo "" >> "$OUTPUT_FILE"
echo "---" >> "$OUTPUT_FILE"
echo "*Comparing synthesis results from main branch vs. this PR*" >> "$OUTPUT_FILE"
echo "*Comparing synthesis results from \`$BASE_BRANCH\` branch vs. this PR*" >> "$OUTPUT_FILE"
Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@
#!/bin/bash
# Script to compare a synthesis report between main and PR branches
# Usage: compare_metrics_diff.sh <main_report_path> <pr_report_path>
# Example: compare_metrics_diff.sh "main-reports/report.summary" "pr-reports/report.summary"
# Script to compare a synthesis report between base and PR branches
# Usage: compare_metrics_diff.sh <base_report_path> <pr_report_path>
# Example: compare_metrics_diff.sh "base-reports/report.summary" "pr-reports/report.summary"

set -e

if [ $# -lt 2 ]; then
echo "Usage: $0 <main_report_path> <pr_report_path>" >&2
echo "Usage: $0 <base_report_path> <pr_report_path>" >&2
exit 1
fi

MAIN_REPORT="$1"
BASE_REPORT="$1"
PR_REPORT="$2"
BASE_BRANCH="${BASE_BRANCH:-base branch}"

if [ ! -f "$PR_REPORT" ]; then
echo "ERROR: PR report not found at $PR_REPORT" >&2
exit 1
fi

{
if [ -f "$MAIN_REPORT" ]; then
if [ -f "$BASE_REPORT" ]; then
# Generate diff and capture output
DIFF_OUTPUT=$(diff -u "$MAIN_REPORT" "$PR_REPORT" | tail -n +3 || true)
DIFF_OUTPUT=$(diff -u "$BASE_REPORT" "$PR_REPORT" | tail -n +3 || true)
if [ -z "$DIFF_OUTPUT" ]; then
echo "*No changes detected*"
else
Expand All @@ -30,7 +31,7 @@ fi
echo "\`\`\`"
fi
else
echo "*No baseline available from main branch*"
echo "*No baseline available from \`$BASE_BRANCH\` branch*"
echo ""
echo "<details>"
echo "<summary>View PR synthesis results</summary>"
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,8 @@ jobs:
runs-on: ubuntu-latest
permissions:
pull-requests: write
env:
BASE_BRANCH: ${{ github.base_ref }}

strategy:
matrix: *utoss-risc-v-matrix
Expand Down Expand Up @@ -300,6 +302,8 @@ jobs:
runs-on: ubuntu-latest
permissions:
pull-requests: write
env:
BASE_BRANCH: ${{ github.base_ref }}

steps:
- name: Checkout code
Expand Down