@@ -120,94 +120,79 @@ jobs:
120120 if : always()
121121 run : supabase stop
122122
123- - name : Report results to triggering PR
123+ - name : Find existing test results comment
124+ if : always() && inputs.triggering_pr != 'push'
125+ uses : peter-evans/find-comment@v3
126+ id : find-comment
127+ with :
128+ repository : supabase/${{ inputs.triggering_repo }}
129+ issue-number : ${{ inputs.triggering_pr }}
130+ comment-author : ' github-actions[bot]'
131+ body-includes : ' <!-- supabase-js-test-results -->'
132+ token : ${{ steps.generate-token.outputs.token }}
133+
134+ - name : Prepare test results body
124135 if : always()
125- uses : actions/github-script@v7
136+ id : prepare-body
137+ run : |
138+ TYPE_CHECK="${{ steps.type-check.outputs.result }}"
139+ UNIT_TEST="${{ steps.unit-tests.outputs.result }}"
140+ INTEGRATION_TEST="${{ steps.integration-tests.outputs.result }}"
141+
142+ TYPE_CHECK=${TYPE_CHECK:-failure}
143+ UNIT_TEST=${UNIT_TEST:-failure}
144+ INTEGRATION_TEST=${INTEGRATION_TEST:-failure}
145+
146+ if [[ "$TYPE_CHECK" == "success" && "$UNIT_TEST" == "success" && "$INTEGRATION_TEST" == "success" ]]; then
147+ STATUS_ICON="✅"
148+ OVERALL_STATUS="PASSED"
149+ STATUS_MESSAGE="🎉 All tests passed! This preview release is compatible with supabase-js."
150+ else
151+ STATUS_ICON="❌"
152+ OVERALL_STATUS="FAILED"
153+ STATUS_MESSAGE="⚠️ Some tests failed. Please review the failing tests before merging."
154+ fi
155+
156+ TYPE_CHECK_DISPLAY=$([ "$TYPE_CHECK" == "success" ] && echo "✅ PASSED" || echo "❌ FAILED")
157+ UNIT_TEST_DISPLAY=$([ "$UNIT_TEST" == "success" ] && echo "✅ PASSED" || echo "❌ FAILED")
158+ INTEGRATION_TEST_DISPLAY=$([ "$INTEGRATION_TEST" == "success" ] && echo "✅ PASSED" || echo "❌ FAILED")
159+
160+ cat << EOF > comment-body.md
161+ <!-- supabase-js-test-results -->
162+ ## ${STATUS_ICON} supabase-js CI Test Results
163+
164+ **Overall Status: ${OVERALL_STATUS}**
165+
166+ Tests triggered by preview release of \`${{ inputs.package_name }}\`
167+
168+ | Test Suite | Result |
169+ |------------|--------|
170+ | Type Check | ${TYPE_CHECK_DISPLAY} |
171+ | Unit Tests | ${UNIT_TEST_DISPLAY} |
172+ | Integration Tests | ${INTEGRATION_TEST_DISPLAY} |
173+
174+ **Preview Package:** \`${{ inputs.preview_url }}\`
175+ **Commit:** [\`${{ inputs.triggering_sha }}\`](https://github.com/supabase/${{ inputs.triggering_repo }}/commit/${{ inputs.triggering_sha }})
176+
177+ ${STATUS_MESSAGE}
178+
179+ <details>
180+ <summary>View workflow run</summary>
181+
182+ [View full test results](https://github.com/supabase/supabase-js/actions/runs/${{ github.run_id }})
183+ </details>
184+
185+ ---
186+ <sub>Last updated: $(date -u +"%Y-%m-%dT%H:%M:%SZ")</sub>
187+ EOF
188+
189+ - name : Report results to triggering PR
190+ if : always() && inputs.triggering_pr != 'push'
191+ uses : peter-evans/create-or-update-comment@v4
126192 with :
127- github-token : ${{ steps.generate-token.outputs.token }}
128- script : |
129- const typeCheckResult = '${{ steps.type-check.outputs.result }}' || 'failure';
130- const unitTestResult = '${{ steps.unit-tests.outputs.result }}' || 'failure';
131- const integrationTestResult = '${{ steps.integration-tests.outputs.result }}' || 'failure';
132-
133- const allPassed = typeCheckResult === 'success' &&
134- unitTestResult === 'success' &&
135- integrationTestResult === 'success';
136-
137- const statusIcon = allPassed ? '✅' : '❌';
138- const overallStatus = allPassed ? 'PASSED' : 'FAILED';
139-
140- // Unique identifier for this bot's comments
141- const commentIdentifier = '<!-- supabase-js-test-results -->';
142-
143- const body = `${commentIdentifier}
144- ## ${statusIcon} supabase-js CI Test Results
145-
146- **Overall Status: ${overallStatus}**
147-
148- Tests triggered by preview release of \`${{ inputs.package_name }}\`
149-
150- | Test Suite | Result |
151- |------------|--------|
152- | Type Check | ${typeCheckResult === 'success' ? '✅ PASSED' : '❌ FAILED'} |
153- | Unit Tests | ${unitTestResult === 'success' ? '✅ PASSED' : '❌ FAILED'} |
154- | Integration Tests | ${integrationTestResult === 'success' ? '✅ PASSED' : '❌ FAILED'} |
155-
156- **Preview Package:** \`${{ inputs.preview_url }}\`
157- **Commit:** [\`${{ inputs.triggering_sha }}\`](https://github.com/supabase/${{ inputs.triggering_repo }}/commit/${{ inputs.triggering_sha }})
158-
159- ${allPassed ?
160- '🎉 All tests passed! This preview release is compatible with supabase-js.' :
161- '⚠️ Some tests failed. Please review the failing tests before merging.'}
162-
163- <details>
164- <summary>View workflow run</summary>
165-
166- [View full test results](https://github.com/supabase/supabase-js/actions/runs/${context.runId})
167- </details>
168-
169- ---
170- <sub>Last updated: ${new Date().toISOString()}</sub>`;
171-
172- try {
173- // First, try to find an existing comment from this bot
174- const { data: comments } = await github.rest.issues.listComments({
175- owner: 'supabase',
176- repo: '${{ inputs.triggering_repo }}',
177- issue_number: parseInt('${{ inputs.triggering_pr }}')
178- });
179-
180- // Look for a comment with our identifier
181- const botComment = comments.find(comment =>
182- comment.body && comment.body.includes(commentIdentifier)
183- );
184-
185- if (botComment) {
186- // Update existing comment
187- await github.rest.issues.updateComment({
188- owner: 'supabase',
189- repo: '${{ inputs.triggering_repo }}',
190- comment_id: botComment.id,
191- body: body
192- });
193- console.log('Successfully updated existing comment');
194- } else {
195- // Create new comment if none exists
196- await github.rest.issues.createComment({
197- owner: 'supabase',
198- repo: '${{ inputs.triggering_repo }}',
199- issue_number: parseInt('${{ inputs.triggering_pr }}'),
200- body: body
201- });
202- console.log('Successfully posted new comment to PR');
203- }
204- } catch (error) {
205- console.log('Failed to post/update comment:', error.message);
206- // Still log the results for manual review
207- console.log('Test Results Summary:', {
208- typeCheck: typeCheckResult,
209- unitTests: unitTestResult,
210- integrationTests: integrationTestResult,
211- overallStatus: overallStatus
212- });
213- }
193+ repository : supabase/${{ inputs.triggering_repo }}
194+ comment-id : ${{ steps.find-comment.outputs.comment-id }}
195+ issue-number : ${{ inputs.triggering_pr }}
196+ body-path : comment-body.md
197+ edit-mode : replace
198+ token : ${{ steps.generate-token.outputs.token }}
0 commit comments