Skip to content

Commit ce1f116

Browse files
authored
chore: trigger supabase-js tests (#1098)
## What kind of change does this PR introduce? CI/CD enhancement - Improves the preview release workflow and cross-repository testing integration. ## What is the current behavior? - Preview releases are created but there's no automated way to test compatibility with downstream packages - No cross-repository testing between `auth-js` and `supabase-js` - Manual testing required to verify changes don't break integration points - Limited feedback loop for developers on cross-package compatibility ## What is the new behavior? - **Automated Cross-Repo Testing**: Preview releases automatically trigger compatibility tests in `supabase-js` - **Smart Triggering**: Only runs on actual source code changes (src/, package files, tsconfig) to avoid unnecessary builds - **Enhanced Control**: Manual workflow dispatch with configurable options for target branch and test triggering - **Better UX**: PR comments show preview package URLs and test status updates - **Secure Integration**: Uses GitHub App authentication for cross-repository workflow triggering ## Key Features ### 🚀 **Cross-Repository Test Integration** - Automatically triggers `supabase-js` external tests when `auth-js` changes are made - Passes preview package URL and metadata to downstream tests - Supports both PR and push-based workflows ### ⚡ **Optimized Triggering** - **Path-based filtering**: Only triggers on meaningful changes (`src/**`, `package.json`, etc.) - **Label-based control**: PRs require `trigger: preview` label for activation - **Manual override**: Workflow dispatch with configurable target branch ### 💬 **Enhanced Feedback** - Automated PR comments with preview package links - Status updates on cross-repo test progress - Clear visibility into the testing pipeline ### 🔒 **Secure Cross-Repo Access** - GitHub App-based authentication for repository access - Scoped permissions to `auth-js` and `supabase-js` repositories only ## Testing This workflow enables: - Early detection of breaking changes between `auth-js` and `supabase-js` - Automated compatibility verification for all preview releases - Faster feedback cycles for developers working on authentication features - Reduced risk of integration issues in production releases ## Additional context This enhancement creates a robust CI/CD pipeline that ensures `auth-js` changes are automatically validated against its primary consumer (`supabase-js`), significantly improving the development workflow and reducing integration risks. More context: supabase/supabase-js#1532
1 parent d59e1eb commit ce1f116

File tree

1 file changed

+131
-4
lines changed

1 file changed

+131
-4
lines changed

.github/workflows/preview-release.yml

Lines changed: 131 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,46 @@ permissions:
44
pull-requests: write
55

66
on:
7+
# Manual trigger with inputs for control
8+
workflow_dispatch:
9+
inputs:
10+
trigger_supabase_js:
11+
description: 'Trigger supabase-js tests'
12+
type: boolean
13+
default: true
14+
target_branch:
15+
description: 'Target branch for supabase-js tests'
16+
type: string
17+
default: 'master'
18+
19+
# Push to master - only when source code changes
720
push:
821
branches:
922
- master
23+
paths:
24+
- 'src/**'
25+
- 'package.json'
26+
- 'package-lock.json'
27+
- 'tsconfig.json'
28+
29+
# PR triggers - only when labeled
1030
pull_request:
11-
types: [opened, synchronize, labeled]
31+
types: [labeled, synchronize]
1232

1333
jobs:
1434
preview:
35+
# Run only for PRs with 'trigger: preview' label or pushes to master
1536
if: >
1637
github.repository == 'supabase/auth-js' &&
17-
(github.event_name == 'push' ||
18-
(github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'trigger: preview')))
38+
(
39+
github.event_name == 'workflow_dispatch' ||
40+
github.event_name == 'push' ||
41+
(github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'trigger: preview'))
42+
)
1943
runs-on: ubuntu-latest
44+
outputs:
45+
preview-url: ${{ steps.preview.outputs.url }}
46+
package-name: ${{ steps.preview.outputs.package }}
2047
steps:
2148
- name: Checkout code
2249
uses: actions/checkout@v4
@@ -33,4 +60,104 @@ jobs:
3360
- name: Build
3461
run: npm run build
3562

36-
- run: npx pkg-pr-new@latest publish --compact
63+
- name: Publish preview
64+
id: preview
65+
run: |
66+
OUTPUT=$(npx pkg-pr-new@latest publish --compact 2>&1)
67+
PREVIEW_URL=$(echo "$OUTPUT" | grep -o 'https://pkg\.pr\.new/@supabase/[^[:space:]]*' | head -1)
68+
REPO_NAME=$(echo "$GITHUB_REPOSITORY" | cut -d'/' -f2)
69+
70+
if [ -z "$PREVIEW_URL" ]; then
71+
echo "Error: Failed to extract preview URL from pkg-pr-new output"
72+
echo "Output was: $OUTPUT"
73+
exit 1
74+
fi
75+
76+
echo "Preview Release URL: $PREVIEW_URL"
77+
echo "url=$PREVIEW_URL" >> $GITHUB_OUTPUT
78+
echo "package=$REPO_NAME" >> $GITHUB_OUTPUT
79+
80+
trigger-supabase-js-tests:
81+
needs: preview
82+
# Only run if preview URL exists and either:
83+
# - Not workflow_dispatch, OR
84+
# - workflow_dispatch with trigger_supabase_js = true
85+
if: >
86+
needs.preview.outputs.preview-url != '' &&
87+
(
88+
github.event_name != 'workflow_dispatch' ||
89+
github.event.inputs.trigger_supabase_js == 'true'
90+
)
91+
runs-on: ubuntu-latest
92+
steps:
93+
- name: Generate GitHub App token
94+
id: generate-token
95+
uses: actions/create-github-app-token@v1
96+
with:
97+
app-id: ${{ vars.CROSS_REPO_APP_ID }}
98+
private-key: ${{ secrets.CROSS_REPO_APP_PRIVATE_KEY }}
99+
owner: supabase
100+
repositories: auth-js,supabase-js
101+
102+
- name: Trigger supabase-js CI tests
103+
uses: actions/github-script@v7
104+
with:
105+
github-token: ${{ steps.generate-token.outputs.token }}
106+
script: |
107+
const prNumber = context.issue.number || 'push';
108+
const triggeringRepo = context.repo.repo;
109+
// Use input target_branch if workflow_dispatch, otherwise default to master
110+
const targetBranch = context.eventName === 'workflow_dispatch' && context.payload.inputs?.target_branch
111+
? context.payload.inputs.target_branch
112+
: 'master';
113+
114+
try {
115+
const response = await github.rest.actions.createWorkflowDispatch({
116+
owner: 'supabase',
117+
repo: 'supabase-js',
118+
workflow_id: 'external-test.yml',
119+
ref: targetBranch,
120+
inputs: {
121+
triggering_repo: triggeringRepo,
122+
triggering_pr: prNumber.toString(),
123+
preview_url: '${{ needs.preview.outputs.preview-url }}',
124+
package_name: '${{ needs.preview.outputs.package-name }}',
125+
triggering_sha: context.eventName === 'pull_request' ? context.payload.pull_request.head.sha : context.sha
126+
}
127+
});
128+
129+
console.log('Successfully triggered supabase-js tests');
130+
console.log('Response:', response.status);
131+
} catch (error) {
132+
console.error('Failed to trigger supabase-js tests:', error);
133+
throw error;
134+
}
135+
136+
- name: Find existing preview comment
137+
if: github.event_name == 'pull_request'
138+
uses: peter-evans/find-comment@v3
139+
id: find-comment
140+
with:
141+
token: ${{ secrets.GITHUB_TOKEN }}
142+
issue-number: ${{ github.event.pull_request.number }}
143+
comment-author: 'github-actions[bot]'
144+
body-includes: '<!-- auth-js-preview-status -->'
145+
146+
- name: Create or update preview comment
147+
if: github.event_name == 'pull_request'
148+
uses: peter-evans/create-or-update-comment@v4
149+
with:
150+
token: ${{ secrets.GITHUB_TOKEN }}
151+
comment-id: ${{ steps.find-comment.outputs.comment-id }}
152+
issue-number: ${{ github.event.pull_request.number }}
153+
body: |
154+
<!-- auth-js-preview-status -->
155+
🚀 **Preview release created!**
156+
157+
supabase-js CI tests have been automatically triggered on feature branch to verify compatibility.
158+
159+
**Preview package:** `${{ needs.preview.outputs.preview-url }}`
160+
161+
Results will be posted here once testing is complete.
162+
163+
edit-mode: replace

0 commit comments

Comments
 (0)