Skip to content

Commit 6b78501

Browse files
committed
chore: add external test
1 parent d6bcf99 commit 6b78501

File tree

1 file changed

+144
-0
lines changed

1 file changed

+144
-0
lines changed
Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
# Add this to the supabase-js repository as .github/workflows/external-test.yml
2+
name: External Dependency Test
3+
4+
on:
5+
repository_dispatch:
6+
types: [test-with-preview]
7+
8+
env:
9+
NODE_VERSION: '20'
10+
11+
jobs:
12+
test-with-preview-dependency:
13+
name: Test supabase-js with preview dependency
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout supabase-js
17+
uses: actions/checkout@v4
18+
19+
- name: Setup Node.js
20+
uses: actions/setup-node@v4
21+
with:
22+
node-version: ${{ env.NODE_VERSION }}
23+
cache: 'npm'
24+
25+
- name: Setup Supabase CLI
26+
uses: supabase/setup-cli@v1
27+
with:
28+
version: latest
29+
30+
- name: Start Supabase
31+
run: supabase start
32+
33+
- name: Install jq for JSON parsing
34+
run: sudo apt-get update && sudo apt-get install -y jq
35+
36+
- name: Install dependencies and build supabase-js
37+
run: |
38+
npm ci
39+
npm run build
40+
41+
- name: Install preview dependency
42+
run: |
43+
# Install the preview package
44+
PREVIEW_PACKAGE="${{ github.event.client_payload.preview_url }}"
45+
echo "Installing preview package: $PREVIEW_PACKAGE"
46+
npm install "$PREVIEW_PACKAGE" --no-save
47+
48+
- name: Run Type Check
49+
id: type-check
50+
continue-on-error: true
51+
run: |
52+
if npm run test:types; then
53+
echo "result=success" >> $GITHUB_OUTPUT
54+
else
55+
echo "result=failure" >> $GITHUB_OUTPUT
56+
fi
57+
58+
- name: Run Unit Tests
59+
id: unit-tests
60+
continue-on-error: true
61+
run: |
62+
if npm run test:coverage; then
63+
echo "result=success" >> $GITHUB_OUTPUT
64+
else
65+
echo "result=failure" >> $GITHUB_OUTPUT
66+
fi
67+
68+
- name: Run Integration Tests
69+
id: integration-tests
70+
continue-on-error: true
71+
run: |
72+
export SUPABASE_SERVICE_ROLE_KEY="$(supabase status --output json | jq -r '.SERVICE_ROLE_KEY')"
73+
if npm run test:integration; then
74+
echo "result=success" >> $GITHUB_OUTPUT
75+
else
76+
echo "result=failure" >> $GITHUB_OUTPUT
77+
fi
78+
79+
- name: Stop Supabase
80+
if: always()
81+
run: supabase stop
82+
83+
- name: Report results to triggering PR
84+
if: always()
85+
uses: actions/github-script@v7
86+
with:
87+
github-token: ${{ secrets.GITHUB_TOKEN }}
88+
script: |
89+
const payload = ${{ toJson(github.event.client_payload) }};
90+
const typeCheckResult = '${{ steps.type-check.outputs.result }}' || 'failure';
91+
const unitTestResult = '${{ steps.unit-tests.outputs.result }}' || 'failure';
92+
const integrationTestResult = '${{ steps.integration-tests.outputs.result }}' || 'failure';
93+
94+
const allPassed = typeCheckResult === 'success' &&
95+
unitTestResult === 'success' &&
96+
integrationTestResult === 'success';
97+
98+
const statusIcon = allPassed ? '✅' : '❌';
99+
const overallStatus = allPassed ? 'PASSED' : 'FAILED';
100+
101+
const body = `## ${statusIcon} supabase-js CI Test Results
102+
103+
**Overall Status: ${overallStatus}**
104+
105+
Tests triggered by preview release of \`${payload.package_name}\`
106+
107+
| Test Suite | Result |
108+
|------------|--------|
109+
| Type Check | ${typeCheckResult === 'success' ? '✅ PASSED' : '❌ FAILED'} |
110+
| Unit Tests | ${unitTestResult === 'success' ? '✅ PASSED' : '❌ FAILED'} |
111+
| Integration Tests | ${integrationTestResult === 'success' ? '✅ PASSED' : '❌ FAILED'} |
112+
113+
**Preview Package:** \`${payload.preview_url}\`
114+
**Commit:** [\`${payload.triggering_sha.substring(0, 7)}\`](https://github.com/supabase/${payload.triggering_repo}/commit/${payload.triggering_sha})
115+
116+
${allPassed ?
117+
'🎉 All tests passed! This preview release is compatible with supabase-js.' :
118+
'⚠️ Some tests failed. Please review the failing tests before merging.'}
119+
120+
<details>
121+
<summary>View workflow run</summary>
122+
123+
[View full test results](https://github.com/supabase/supabase-js/actions/runs/${context.runId})
124+
</details>`;
125+
126+
// Post comment to the triggering PR
127+
try {
128+
await github.rest.issues.createComment({
129+
owner: 'supabase',
130+
repo: payload.triggering_repo,
131+
issue_number: parseInt(payload.triggering_pr),
132+
body: body
133+
});
134+
console.log('Successfully posted comment to PR');
135+
} catch (error) {
136+
console.log('Failed to post comment:', error.message);
137+
// Still log the results for manual review
138+
console.log('Test Results Summary:', {
139+
typeCheck: typeCheckResult,
140+
unitTests: unitTestResult,
141+
integrationTests: integrationTestResult,
142+
overallStatus: overallStatus
143+
});
144+
}

0 commit comments

Comments
 (0)