Skip to content

Commit 3efd088

Browse files
committed
fix: wait for the checks to be started
1 parent c9ae532 commit 3efd088

File tree

3 files changed

+59
-9
lines changed

3 files changed

+59
-9
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
# Order is important: the last matching pattern takes the most precedence
55

66
# These owners will be the default owners for everything
7-
* @masterpointio/masterpoint-open-source
7+
* @masterpointio/masterpoint-open-source

.github/workflows/trunk-upgrade.yaml

Lines changed: 55 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,26 +37,75 @@ jobs:
3737
- name: Wait for checks to pass + Merge PR
3838
if: steps.trunk-upgrade.outputs.pull-request-number != ''
3939
env:
40-
GH_TOKEN: ${{ steps.generate-token.outputs.token }}
40+
GH_TOKEN: ${{ secrets.MASTERPOINT_TEAM_PAT }}
4141
PR_NUMBER: ${{ steps.trunk-upgrade.outputs.pull-request-number }}
4242
run: |
43-
echo "Waiting for required status checks to pass on PR #$PR_NUMBER..."
43+
echo "Waiting for status checks to pass on PR #$PR_NUMBER..."
44+
45+
# Wait a bit for checks to start
46+
echo "Waiting 30 seconds for checks to initialize..."
47+
sleep 30
48+
49+
# Try to get all checks first to see if any exist
50+
ALL_CHECKS_JSON=$(gh pr checks "$PR_NUMBER" --json state,bucket || echo "[]")
51+
echo "All checks: $ALL_CHECKS_JSON"
52+
53+
# Get required checks
54+
REQUIRED_CHECKS_JSON=$(gh pr checks "$PR_NUMBER" --required --json state,bucket || echo "[]")
55+
echo "Required checks: $REQUIRED_CHECKS_JSON"
56+
57+
# Check if we have any required checks
58+
REQUIRED_CHECKS_COUNT=$(echo "$REQUIRED_CHECKS_JSON" | jq '. | length')
59+
ALL_CHECKS_COUNT=$(echo "$ALL_CHECKS_JSON" | jq '. | length')
60+
61+
if [ "$REQUIRED_CHECKS_COUNT" -eq 0 ] && [ "$ALL_CHECKS_COUNT" -eq 0 ]; then
62+
echo "No status checks found. This might be expected if no checks are configured."
63+
echo "Proceeding with auto-approval and merge..."
64+
65+
# Auto-approve the PR
66+
gh pr review "$PR_NUMBER" --approve --body "Auto-approved by trunk upgrade workflow (no status checks configured)"
67+
68+
# Merge the PR
69+
gh pr merge "$PR_NUMBER" --squash --delete-branch --admin
70+
exit 0
71+
fi
72+
73+
# If we have required checks, wait for them. Otherwise, wait for all checks.
74+
if [ "$REQUIRED_CHECKS_COUNT" -gt 0 ]; then
75+
echo "Waiting for $REQUIRED_CHECKS_COUNT required status checks..."
76+
CHECKS_TO_MONITOR="required"
77+
else
78+
echo "No required checks configured. Waiting for all $ALL_CHECKS_COUNT status checks..."
79+
CHECKS_TO_MONITOR="all"
80+
fi
81+
82+
# Wait for checks to complete
4483
while true; do
45-
CHECKS_JSON=$(gh pr checks "$PR_NUMBER" --required --json state,bucket)
84+
if [ "$CHECKS_TO_MONITOR" = "required" ]; then
85+
CHECKS_JSON=$(gh pr checks "$PR_NUMBER" --required --json state,bucket)
86+
else
87+
CHECKS_JSON=$(gh pr checks "$PR_NUMBER" --json state,bucket)
88+
fi
89+
4690
echo "Current checks status: $CHECKS_JSON"
4791
4892
if echo "$CHECKS_JSON" | jq -e '.[] | select(.bucket=="fail")' > /dev/null; then
49-
echo "One or more required checks have failed. Exiting..."
93+
echo "One or more checks have failed. Exiting..."
5094
exit 1
5195
fi
5296
5397
FAILED_OR_PENDING_CHECKS=$(echo "$CHECKS_JSON" | jq '[.[] | select(.state!="SUCCESS" or .bucket!="pass")] | length')
5498
if [ "$FAILED_OR_PENDING_CHECKS" -eq 0 ]; then
55-
echo "All required checks passed. Merging PR https://github.com/${{ github.repository }}/pull/$PR_NUMBER..."
99+
echo "All checks passed. Auto-approving and merging PR https://github.com/${{ github.repository }}/pull/$PR_NUMBER..."
100+
101+
# Auto-approve the PR
102+
gh pr review "$PR_NUMBER" --approve --body "Auto-approved by trunk upgrade workflow"
103+
104+
# Merge the PR
56105
gh pr merge "$PR_NUMBER" --squash --delete-branch --admin
57106
break
58107
else
59-
echo "Some required checks are still running or pending. Retrying in 30s..."
108+
echo "Some checks are still running or pending. Retrying in 30s..."
60109
sleep 30
61110
fi
62111
done

.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ backend.tf.json
4646
**/*.*swp
4747
**/.DS_Store
4848

49-
# Claude Code - we beleive engineers are responsible for the code they push no matter how it's generated.
50-
# Therefore, configs specific to their coding practices are their responsibilty to judiciously manage.
49+
# AI code gen tools - we beleive engineers are responsible for the code they push no matter how it's generated
5150
.claude/*
51+
.cursor/*
52+
CLAUDE.md

0 commit comments

Comments
 (0)