mirror of
https://github.com/oven-sh/bun
synced 2026-02-11 03:18:53 +00:00
## Summary Fixes the broken update hdrhistogram GitHub Action workflow that was failing due to multiple issues. ## Issues Fixed 1. **Tag SHA resolution failure**: The workflow failed when trying to resolve commit SHA from lightweight tags, causing the error "Could not fetch SHA for tag 0.11.8 @ 8dcce8f68512fca460b171bccc3a5afce0048779" 2. **Branch naming bug**: The workflow was creating branches named `deps/update-cares-*` instead of `deps/update-hdrhistogram-*` 3. **Wrong workflow link**: PR body was linking to `update-cares.yml` instead of `update-hdrhistogram.yml` ## Fix Details - **Improved tag SHA resolution**: Updated logic to handle both lightweight and annotated tags: - Try to get commit SHA from tag object (for annotated tags) - If that fails, use the tag SHA directly (for lightweight tags) - Uses jq's `// empty` operator and proper error handling with `2>/dev/null` - **Fixed branch naming**: Changed from `deps/update-cares-*` to `deps/update-hdrhistogram-*` - **Updated workflow link**: Fixed PR body to link to correct workflow file ## Test Plan - [x] Verified current workflow logs show the exact error being fixed - [x] Tested API calls locally to confirm the new logic works with latest tag (0.11.8) - [x] Confirmed the latest tag is a lightweight tag pointing directly to commit The workflow should now run successfully on the next scheduled execution or manual trigger. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-authored-by: Claude Bot <claude-bot@bun.sh> Co-authored-by: Claude <noreply@anthropic.com>
103 lines
4.2 KiB
YAML
103 lines
4.2 KiB
YAML
name: Update hdrhistogram
|
|
|
|
on:
|
|
schedule:
|
|
- cron: "0 4 * * 0"
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
check-update:
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: write
|
|
pull-requests: write
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Check hdrhistogram version
|
|
id: check-version
|
|
run: |
|
|
set -euo pipefail
|
|
|
|
# Extract the commit hash from the line after COMMIT
|
|
CURRENT_VERSION=$(awk '/[[:space:]]*COMMIT[[:space:]]*$/{getline; gsub(/^[[:space:]]+|[[:space:]]+$/,"",$0); print}' cmake/targets/BuildHdrHistogram.cmake)
|
|
|
|
if [ -z "$CURRENT_VERSION" ]; then
|
|
echo "Error: Could not find COMMIT line in BuildHdrHistogram.cmake"
|
|
exit 1
|
|
fi
|
|
|
|
# Validate that it looks like a git hash
|
|
if ! [[ $CURRENT_VERSION =~ ^[0-9a-f]{40}$ ]]; then
|
|
echo "Error: Invalid git hash format in BuildHdrHistogram.cmake"
|
|
echo "Found: $CURRENT_VERSION"
|
|
echo "Expected: 40 character hexadecimal string"
|
|
exit 1
|
|
fi
|
|
|
|
echo "current=$CURRENT_VERSION" >> $GITHUB_OUTPUT
|
|
|
|
LATEST_RELEASE=$(curl -sL https://api.github.com/repos/HdrHistogram/HdrHistogram_c/releases/latest)
|
|
if [ -z "$LATEST_RELEASE" ]; then
|
|
echo "Error: Failed to fetch latest release from GitHub API"
|
|
exit 1
|
|
fi
|
|
|
|
LATEST_TAG=$(echo "$LATEST_RELEASE" | jq -r '.tag_name')
|
|
if [ -z "$LATEST_TAG" ] || [ "$LATEST_TAG" = "null" ]; then
|
|
echo "Error: Could not extract tag name from GitHub API response"
|
|
exit 1
|
|
fi
|
|
|
|
LATEST_TAG_SHA=$(curl -sL "https://api.github.com/repos/HdrHistogram/HdrHistogram_c/git/refs/tags/$LATEST_TAG" | jq -r '.object.sha')
|
|
if [ -z "$LATEST_TAG_SHA" ] || [ "$LATEST_TAG_SHA" = "null" ]; then
|
|
echo "Error: Could not fetch SHA for tag $LATEST_TAG"
|
|
exit 1
|
|
fi
|
|
|
|
# Try to get commit SHA from tag object (for annotated tags)
|
|
# If it fails, assume it's a lightweight tag pointing directly to commit
|
|
LATEST_SHA=$(curl -sL "https://api.github.com/repos/HdrHistogram/HdrHistogram_c/git/tags/$LATEST_TAG_SHA" 2>/dev/null | jq -r '.object.sha // empty')
|
|
if [ -z "$LATEST_SHA" ]; then
|
|
# Lightweight tag - SHA points directly to commit
|
|
LATEST_SHA="$LATEST_TAG_SHA"
|
|
fi
|
|
|
|
if ! [[ $LATEST_SHA =~ ^[0-9a-f]{40}$ ]]; then
|
|
echo "Error: Invalid SHA format received from GitHub"
|
|
echo "Found: $LATEST_SHA"
|
|
echo "Expected: 40 character hexadecimal string"
|
|
exit 1
|
|
fi
|
|
|
|
echo "latest=$LATEST_SHA" >> $GITHUB_OUTPUT
|
|
echo "tag=$LATEST_TAG" >> $GITHUB_OUTPUT
|
|
|
|
- name: Update version if needed
|
|
if: success() && steps.check-version.outputs.current != steps.check-version.outputs.latest
|
|
run: |
|
|
set -euo pipefail
|
|
# Handle multi-line format where COMMIT and its value are on separate lines
|
|
sed -i -E '/[[:space:]]*COMMIT[[:space:]]*$/{n;s/[[:space:]]*([0-9a-f]+)[[:space:]]*$/ ${{ steps.check-version.outputs.latest }}/}' cmake/targets/BuildHdrHistogram.cmake
|
|
|
|
- name: Create Pull Request
|
|
if: success() && steps.check-version.outputs.current != steps.check-version.outputs.latest
|
|
uses: peter-evans/create-pull-request@v4
|
|
with:
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
|
add-paths: |
|
|
cmake/targets/BuildHdrHistogram.cmake
|
|
commit-message: "deps: update hdrhistogram to ${{ steps.check-version.outputs.tag }} (${{ steps.check-version.outputs.latest }})"
|
|
title: "deps: update hdrhistogram to ${{ steps.check-version.outputs.tag }}"
|
|
delete-branch: true
|
|
branch: deps/update-hdrhistogram-${{ github.run_number }}
|
|
body: |
|
|
## What does this PR do?
|
|
|
|
Updates hdrhistogram to version ${{ steps.check-version.outputs.tag }}
|
|
|
|
Compare: https://github.com/HdrHistogram/HdrHistogram_c/compare/${{ steps.check-version.outputs.current }}...${{ steps.check-version.outputs.latest }}
|
|
|
|
Auto-updated by [this workflow](https://github.com/oven-sh/bun/actions/workflows/update-hdrhistogram.yml)
|