diff --git a/.github/workflows/auto-merge-dependabot.yml b/.github/workflows/auto-merge-dependabot.yml index 711d8fb..c9ce728 100644 --- a/.github/workflows/auto-merge-dependabot.yml +++ b/.github/workflows/auto-merge-dependabot.yml @@ -8,7 +8,7 @@ on: # This workflow uses a GitHub App token to approve and merge Dependabot PRs # The token is created using the `actions/create-github-app-token` action -# The token is used so that the updates are made by the GitHub App instead of GitHub Actions +# The token is used so that the updates are made by the GitHub App instead of GitHub Actions # and will show up as such in the PR comments and history # In addition, the token is scoped to only the permissions needed for this workflow # see https://docs.github.com/en/apps/creating-github-apps/authenticating-with-a-github-app/making-authenticated-api-requests-with-a-github-app-in-a-github-actions-workflow for details diff --git a/.github/workflows/pr-validate.yml b/.github/workflows/pr-validate.yml index f11e83b..ea3078a 100644 --- a/.github/workflows/pr-validate.yml +++ b/.github/workflows/pr-validate.yml @@ -59,7 +59,7 @@ jobs: name: Lint & Test needs: [docs-pr] if: needs.docs-pr.outputs.docs-only != 'true' - runs-on: [self-hosted, Linux, X64, "1ES.Pool=hld-kvm-amd"] + runs-on: [self-hosted, Linux, X64, "1ES.Pool=hld-kvm-amd","JobId=hyperagent-pr-validate-${{ github.run_id }}-${{ github.run_number }}-${{ github.run_attempt }}"] steps: - uses: actions/checkout@v6 @@ -99,30 +99,31 @@ jobs: - windows-whp-release include: - build: linux-kvm-debug - os: [self-hosted, Linux, X64, "1ES.Pool=hld-kvm-amd"] hypervisor: kvm config: debug - build: linux-kvm-release - os: [self-hosted, Linux, X64, "1ES.Pool=hld-kvm-amd"] hypervisor: kvm config: release - build: linux-mshv-debug - os: [self-hosted, Linux, X64, "1ES.Pool=hld-azlinux3-mshv-amd"] hypervisor: mshv config: debug - build: linux-mshv-release - os: [self-hosted, Linux, X64, "1ES.Pool=hld-azlinux3-mshv-amd"] hypervisor: mshv config: release - build: windows-whp-debug - os: [self-hosted, Windows, X64, "1ES.Pool=hld-win2022-amd"] hypervisor: whp config: debug - build: windows-whp-release - os: [self-hosted, Windows, X64, "1ES.Pool=hld-win2022-amd"] hypervisor: whp config: release - runs-on: ${{ matrix.os }} + runs-on: ${{ fromJson( + format('["self-hosted", "{0}", "X64", "1ES.Pool=hld-{1}-amd", "JobId={2}-{3}-{4}-{5}"]', + matrix.hypervisor == 'whp' && 'Windows' || 'Linux', + matrix.hypervisor == 'whp' && 'win2025' || matrix.hypervisor == 'mshv' && 'azlinux3-mshv' || 'kvm', + matrix.build, + github.run_id, + github.run_number, + github.run_attempt)) }} steps: - uses: actions/checkout@v6 diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index bfe5f64..0163819 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -34,18 +34,22 @@ jobs: build: [linux-kvm, linux-musl, windows-whp] include: - build: linux-kvm - os: [self-hosted, Linux, X64, "1ES.Pool=hld-kvm-amd"] hypervisor: kvm run_tests: true - build: linux-musl - os: [self-hosted, Linux, X64, "1ES.Pool=hld-kvm-amd"] hypervisor: kvm run_tests: false # musl .node can't run on glibc host - build: windows-whp - os: [self-hosted, Windows, X64, "1ES.Pool=hld-win2022-amd"] hypervisor: whp run_tests: true - runs-on: ${{ matrix.os }} + runs-on: ${{ fromJson( + format('["self-hosted", "{0}", "X64", "1ES.Pool=hld-{1}-amd", "JobId={2}-{3}-{4}-{5}"]', + matrix.hypervisor == 'whp' && 'Windows' || 'Linux', + matrix.hypervisor == 'whp' && 'win2025' || 'kvm', + matrix.build, + github.run_id, + github.run_number, + github.run_attempt)) }} steps: - uses: actions/checkout@v6 @@ -110,7 +114,7 @@ jobs: publish-npm: name: Publish to npmjs.org needs: [build-native] - runs-on: [self-hosted, Linux, X64, "1ES.Pool=hld-kvm-amd"] + runs-on: [self-hosted, Linux, X64, "1ES.Pool=hld-kvm-amd","JobId=hyperagent-publish-npm-${{ github.run_id }}-${{ github.run_number }}-${{ github.run_attempt }}"] steps: - uses: actions/checkout@v6 diff --git a/scripts/auto-approve-dependabot.sh b/scripts/auto-approve-dependabot.sh index ef8a82d..fbd1927 100644 --- a/scripts/auto-approve-dependabot.sh +++ b/scripts/auto-approve-dependabot.sh @@ -121,38 +121,37 @@ echo "$dependabot_prs" | jq -c '.[]' | while read -r pr; do echo " ℹ️ PR #$pr_number is already approved" fi - if [ "$has_pending_checks" = true ] || [ "$all_checks_pass" = true ]; then - # Check if PR is draft and whether it is up-to-date with base branch - pr_merge_info=$(gh pr view "$pr_number" -R "$REPO" --json isDraft,mergeStateStatus) - is_draft=$(echo "$pr_merge_info" | jq -r '.isDraft') - merge_status=$(echo "$pr_merge_info" | jq -r '.mergeStateStatus') - - if [ "$is_draft" = "true" ]; then - echo " ⚠️ PR #$pr_number is a draft PR; skipping merge" - continue - fi - - if [ "$merge_status" != "CLEAN" ]; then - echo " ⚠️ PR #$pr_number is not up to date (status: $merge_status)" - # Enable auto-merge to merge once checks pass - echo " ✅ Enabling auto-merge (squash strategy) for PR #$pr_number" - if gh pr merge "$pr_number" -R "$REPO" --auto --squash; then - echo " ✅ Auto-merge enabled for PR #$pr_number" - else - echo " ⚠️ Failed to enable auto-merge for PR #$pr_number; continuing to next PR" - continue - fi - else - echo " ✅ PR #$pr_number is up to date with base branch" - # PR is already clean/mergeable - merge directly instead of enabling auto-merge - echo " ✅ Merging PR #$pr_number directly (squash strategy)" - if gh pr merge "$pr_number" -R "$REPO" --squash; then + if [ "$has_pending_checks" = true ]; then + echo " ⏳ PR #$pr_number still has pending checks" + echo " ✅ Enabling auto-merge (squash strategy) for PR #$pr_number" + gh pr merge "$pr_number" -R "$REPO" --auto --squash + echo " ✅ Auto-merge enabled for PR #$pr_number" + elif [ "$all_checks_pass" = true ]; then + # Check if PR is up-to-date with base branch + merge_status=$(gh pr view "$pr_number" -R "$REPO" --json mergeStateStatus -q '.mergeStateStatus') + + case "$merge_status" in + CLEAN) + echo " ✅ PR #$pr_number is up to date with base branch" + # PR is already clean/mergeable - merge directly instead of enabling auto-merge + echo " ✅ Merging PR #$pr_number directly (squash strategy)" + gh pr merge "$pr_number" -R "$REPO" --squash echo " ✅ PR #$pr_number merged successfully" - else - echo " ⚠️ Failed to merge PR #$pr_number; continuing to next PR" - continue - fi - fi + ;; + BEHIND) + echo " ⚠️ PR #$pr_number is behind the base branch" + # Enable auto-merge to merge once the branch is updated and checks pass + echo " ✅ Enabling auto-merge (squash strategy) for PR #$pr_number" + gh pr merge "$pr_number" -R "$REPO" --auto --squash + echo " ✅ Auto-merge enabled for PR #$pr_number" + ;; + DIRTY|BLOCKED) + echo " ⚠️ Skipping PR #$pr_number because it cannot be auto-merged (status: $merge_status)" + ;; + *) + echo " ⚠️ Skipping PR #$pr_number due to unsupported merge status: $merge_status" + ;; + esac fi done