@@ -31,7 +31,7 @@ permissions:
3131jobs :
3232 run :
3333 runs-on : ${{ fromJSON(inputs.runs_on) }}
34- timeout-minutes : 600
34+ timeout-minutes : 600 # max is 360 on GitHub runners
3535 env :
3636 SCRIPT_PATH : ${{ inputs.script_path }}
3737
@@ -241,84 +241,84 @@ jobs:
241241 fi
242242
243243 # ---------------------------
244- # Commit benchmark results
244+ # Commit benchmark results (silent version)
245245 # ---------------------------
246246 - name : Commit benchmark results to current branch
247247 if : steps.benchmark.outputs.benchmark_success == 'true'
248248 run : |
249- echo "🔧 Configuring git user ..."
249+ echo "🔧 Configuring git..."
250250 git config --global user.name "github-actions[bot]"
251251 git config --global user.email "github-actions[bot]@users.noreply.github.com"
252- echo "✅ Git user configured"
253252
254- echo "🌳 Checking current git state..."
255- echo "Current HEAD: $(git rev-parse --short HEAD)"
256- echo "Current branch: $(git branch --show-current || echo 'DETACHED HEAD')"
257-
253+ # Identify current branch (works for PRs and pushes)
258254 if [ -n "${{ github.head_ref }}" ]; then
259255 BRANCH_NAME="${{ github.head_ref }}"
260- echo "🔄 This is a PR, switching to branch: $BRANCH_NAME"
261- git checkout -B "$BRANCH_NAME"
262- echo "✅ Now on branch: $(git branch --show-current)"
263256 else
264257 BRANCH_NAME="${{ github.ref_name }}"
265- echo "🔄 This is a push, switching to branch: $BRANCH_NAME"
266- git checkout -B "$BRANCH_NAME"
267- echo "✅ Now on branch: $(git branch --show-current)"
268258 fi
259+ echo "🌳 Working branch: $BRANCH_NAME"
269260
270- echo "📊 Adding benchmark results to current branch..."
271-
261+ # Fetch latest remote state quietly
262+ if git ls-remote --exit-code origin "$BRANCH_NAME" >/dev/null 2>&1; then
263+ git fetch origin "$BRANCH_NAME" --quiet
264+ git reset --mixed origin/"$BRANCH_NAME" --quiet
265+ fi
266+
267+ # Determine output directory
272268 if [ -f "$BENCHMARK_OUTPUT_FILE" ]; then
273269 OUTPUT_DIR=$(cat "$BENCHMARK_OUTPUT_FILE")
274- echo "📁 Using benchmark output directory: $OUTPUT_DIR"
275270 else
276271 echo "❌ ERROR: $BENCHMARK_OUTPUT_FILE not found"
277272 exit 1
278273 fi
279274
275+ echo "📁 Benchmark output directory: $OUTPUT_DIR"
280276 DIR_NAME=$(basename "$OUTPUT_DIR")
281-
277+
282278 ARTIFACTS=(
283279 "$OUTPUT_DIR/data.json"
284280 "$OUTPUT_DIR/Project.toml"
285281 "$OUTPUT_DIR/Manifest.toml"
286282 "$OUTPUT_DIR/$DIR_NAME.jl"
287283 )
288284
289- git add "${ARTIFACTS[@]}"
290-
291- STAGED_ALL=true
292- for artifact in "${ARTIFACTS[@]}"; do
293- if git diff --cached --name-only | grep -q "$artifact"; then
294- echo "✅ $artifact staged for commit"
295- else
296- echo "⚠️ $artifact not staged (possibly no changes)"
297- STAGED_ALL=false
298- fi
299- done
285+ # Add only benchmark artifacts
286+ git add "${ARTIFACTS[@]}" >/dev/null 2>&1
300287
301- if [ "$STAGED_ALL" = true ]; then
302- echo "📋 Files to be committed:"
303- git diff --cached --name-status
288+ # Quick summary of staged files
289+ STAGED=$(git diff --cached --name-only | wc -l)
290+ if [ "$STAGED" -eq 0 ]; then
291+ echo "ℹ️ No changes detected in benchmark results — skipping commit"
292+ exit 0
304293 fi
305294
306- if ! git diff --cached --quiet; then
307- echo "📝 Committing benchmark results to current branch..."
308- git commit -m "📊 Add benchmark results" -m "Generated by reusable benchmark workflow" -m "Results saved to ${OUTPUT_DIR}/data.json" -m "Includes environment TOMLs and benchmark script"
309- echo "✅ Benchmark results committed successfully"
310-
311- echo "🔄 Fetching remote branch state before overwrite..."
312- git fetch origin "$BRANCH_NAME" || echo "⚠️ Remote branch does not exist yet, will create it"
295+ echo "📝 Committing $STAGED file(s) to branch $BRANCH_NAME..."
296+ git commit -m "📊 Add benchmark results (${DIR_NAME})" \
297+ -m "Results saved to ${OUTPUT_DIR}/data.json" \
298+ -m "Includes environment TOMLs and benchmark script" \
299+ >/dev/null 2>&1 || {
300+ echo "❌ Commit failed"
301+ exit 1
302+ }
313303
314- echo "🚀 Force-pushing benchmark results to branch: $BRANCH_NAME"
315- git push --force-with-lease origin "$BRANCH_NAME"
316- echo "✅ Benchmark results force-pushed to $BRANCH_NAME"
317- else
318- echo "ℹ️ No changes detected in benchmark results"
319- echo "📊 Current results are identical to previous run"
304+ # Try to rebase quietly before pushing (handle concurrent runs)
305+ if git ls-remote --exit-code origin "$BRANCH_NAME" >/dev/null 2>&1; then
306+ git pull --rebase --autostash origin "$BRANCH_NAME" --quiet || {
307+ echo "⚠️ Rebase conflict — retrying with merge"
308+ git rebase --abort || true
309+ git pull --strategy=ours origin "$BRANCH_NAME" --quiet
310+ }
320311 fi
321312
313+ # Push only updated results
314+ echo "🚀 Pushing results to $BRANCH_NAME..."
315+ git push origin HEAD:"$BRANCH_NAME" --quiet || {
316+ echo "❌ Push failed (possible concurrency issue)"
317+ exit 1
318+ }
319+
320+ echo "✅ Benchmark results pushed successfully for $OUTPUT_DIR"
321+
322322 # ---------------------------
323323 # Workflow summary
324324 # ---------------------------
0 commit comments