From f4bc1d81430463f6994d2e79bb32ce70db9a2bc3 Mon Sep 17 00:00:00 2001 From: Katerina Skroumpelou Date: Tue, 12 Aug 2025 17:27:31 +0300 Subject: [PATCH 1/5] chore: add external test --- .github/workflows/external-test.yml | 144 ++++++++++++++++++++++++++++ 1 file changed, 144 insertions(+) create mode 100644 .github/workflows/external-test.yml diff --git a/.github/workflows/external-test.yml b/.github/workflows/external-test.yml new file mode 100644 index 000000000..273fde7c9 --- /dev/null +++ b/.github/workflows/external-test.yml @@ -0,0 +1,144 @@ +# Add this to the supabase-js repository as .github/workflows/external-test.yml +name: External Dependency Test + +on: + repository_dispatch: + types: [test-with-preview] + +env: + NODE_VERSION: '20' + +jobs: + test-with-preview-dependency: + name: Test supabase-js with preview dependency + runs-on: ubuntu-latest + steps: + - name: Checkout supabase-js + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: ${{ env.NODE_VERSION }} + cache: 'npm' + + - name: Setup Supabase CLI + uses: supabase/setup-cli@v1 + with: + version: latest + + - name: Start Supabase + run: supabase start + + - name: Install jq for JSON parsing + run: sudo apt-get update && sudo apt-get install -y jq + + - name: Install dependencies and build supabase-js + run: | + npm ci + npm run build + + - name: Install preview dependency + run: | + # Install the preview package + PREVIEW_PACKAGE="${{ github.event.client_payload.preview_url }}" + echo "Installing preview package: $PREVIEW_PACKAGE" + npm install "$PREVIEW_PACKAGE" --no-save + + - name: Run Type Check + id: type-check + continue-on-error: true + run: | + if npm run test:types; then + echo "result=success" >> $GITHUB_OUTPUT + else + echo "result=failure" >> $GITHUB_OUTPUT + fi + + - name: Run Unit Tests + id: unit-tests + continue-on-error: true + run: | + if npm run test:coverage; then + echo "result=success" >> $GITHUB_OUTPUT + else + echo "result=failure" >> $GITHUB_OUTPUT + fi + + - name: Run Integration Tests + id: integration-tests + continue-on-error: true + run: | + export SUPABASE_SERVICE_ROLE_KEY="$(supabase status --output json | jq -r '.SERVICE_ROLE_KEY')" + if npm run test:integration; then + echo "result=success" >> $GITHUB_OUTPUT + else + echo "result=failure" >> $GITHUB_OUTPUT + fi + + - name: Stop Supabase + if: always() + run: supabase stop + + - name: Report results to triggering PR + if: always() + uses: actions/github-script@v7 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const payload = ${{ toJson(github.event.client_payload) }}; + const typeCheckResult = '${{ steps.type-check.outputs.result }}' || 'failure'; + const unitTestResult = '${{ steps.unit-tests.outputs.result }}' || 'failure'; + const integrationTestResult = '${{ steps.integration-tests.outputs.result }}' || 'failure'; + + const allPassed = typeCheckResult === 'success' && + unitTestResult === 'success' && + integrationTestResult === 'success'; + + const statusIcon = allPassed ? '✅' : '❌'; + const overallStatus = allPassed ? 'PASSED' : 'FAILED'; + + const body = `## ${statusIcon} supabase-js CI Test Results + + **Overall Status: ${overallStatus}** + + Tests triggered by preview release of \`${payload.package_name}\` + + | Test Suite | Result | + |------------|--------| + | Type Check | ${typeCheckResult === 'success' ? '✅ PASSED' : '❌ FAILED'} | + | Unit Tests | ${unitTestResult === 'success' ? '✅ PASSED' : '❌ FAILED'} | + | Integration Tests | ${integrationTestResult === 'success' ? '✅ PASSED' : '❌ FAILED'} | + + **Preview Package:** \`${payload.preview_url}\` + **Commit:** [\`${payload.triggering_sha.substring(0, 7)}\`](https://github.com/supabase/${payload.triggering_repo}/commit/${payload.triggering_sha}) + + ${allPassed ? + '🎉 All tests passed! This preview release is compatible with supabase-js.' : + '⚠️ Some tests failed. Please review the failing tests before merging.'} + +
+ View workflow run + + [View full test results](https://github.com/supabase/supabase-js/actions/runs/${context.runId}) +
`; + + // Post comment to the triggering PR + try { + await github.rest.issues.createComment({ + owner: 'supabase', + repo: payload.triggering_repo, + issue_number: parseInt(payload.triggering_pr), + body: body + }); + console.log('Successfully posted comment to PR'); + } catch (error) { + console.log('Failed to post comment:', error.message); + // Still log the results for manual review + console.log('Test Results Summary:', { + typeCheck: typeCheckResult, + unitTests: unitTestResult, + integrationTests: integrationTestResult, + overallStatus: overallStatus + }); + } From 81a1ad0adf099ce44c945c0d8d169bacab0a5c61 Mon Sep 17 00:00:00 2001 From: Katerina Skroumpelou Date: Tue, 12 Aug 2025 17:43:02 +0300 Subject: [PATCH 2/5] chore: temp change to workflow dispatch --- .github/workflows/external-test.yml | 42 ++++++++++++++++++++++------- 1 file changed, 32 insertions(+), 10 deletions(-) diff --git a/.github/workflows/external-test.yml b/.github/workflows/external-test.yml index 273fde7c9..22c1bb160 100644 --- a/.github/workflows/external-test.yml +++ b/.github/workflows/external-test.yml @@ -1,9 +1,32 @@ -# Add this to the supabase-js repository as .github/workflows/external-test.yml name: External Dependency Test on: - repository_dispatch: - types: [test-with-preview] + workflow_dispatch: + inputs: + triggering_repo: + description: 'Repository that triggered this test' + required: true + type: string + triggering_pr: + description: 'PR number from triggering repository' + required: true + type: string + preview_url: + description: 'Preview package URL' + required: true + type: string + package_name: + description: 'Package name being tested' + required: true + type: string + triggering_sha: + description: 'SHA from triggering repository' + required: true + type: string + triggering_ref: + description: 'Git ref from triggering repository' + required: true + type: string env: NODE_VERSION: '20' @@ -41,7 +64,7 @@ jobs: - name: Install preview dependency run: | # Install the preview package - PREVIEW_PACKAGE="${{ github.event.client_payload.preview_url }}" + PREVIEW_PACKAGE="${{ inputs.preview_url }}" echo "Installing preview package: $PREVIEW_PACKAGE" npm install "$PREVIEW_PACKAGE" --no-save @@ -86,7 +109,6 @@ jobs: with: github-token: ${{ secrets.GITHUB_TOKEN }} script: | - const payload = ${{ toJson(github.event.client_payload) }}; const typeCheckResult = '${{ steps.type-check.outputs.result }}' || 'failure'; const unitTestResult = '${{ steps.unit-tests.outputs.result }}' || 'failure'; const integrationTestResult = '${{ steps.integration-tests.outputs.result }}' || 'failure'; @@ -102,7 +124,7 @@ jobs: **Overall Status: ${overallStatus}** - Tests triggered by preview release of \`${payload.package_name}\` + Tests triggered by preview release of \`${{ inputs.package_name }}\` | Test Suite | Result | |------------|--------| @@ -110,8 +132,8 @@ jobs: | Unit Tests | ${unitTestResult === 'success' ? '✅ PASSED' : '❌ FAILED'} | | Integration Tests | ${integrationTestResult === 'success' ? '✅ PASSED' : '❌ FAILED'} | - **Preview Package:** \`${payload.preview_url}\` - **Commit:** [\`${payload.triggering_sha.substring(0, 7)}\`](https://github.com/supabase/${payload.triggering_repo}/commit/${payload.triggering_sha}) + **Preview Package:** \`${{ inputs.preview_url }}\` + **Commit:** [\`${{ inputs.triggering_sha }}\`](https://github.com/supabase/${{ inputs.triggering_repo }}/commit/${{ inputs.triggering_sha }}) ${allPassed ? '🎉 All tests passed! This preview release is compatible with supabase-js.' : @@ -127,8 +149,8 @@ jobs: try { await github.rest.issues.createComment({ owner: 'supabase', - repo: payload.triggering_repo, - issue_number: parseInt(payload.triggering_pr), + repo: '${{ inputs.triggering_repo }}', + issue_number: parseInt('${{ inputs.triggering_pr }}'), body: body }); console.log('Successfully posted comment to PR'); From a7ca6f21dc17bf4f5ee981dcd4bc0e00bb61c122 Mon Sep 17 00:00:00 2001 From: Katerina Skroumpelou Date: Wed, 13 Aug 2025 11:18:05 +0300 Subject: [PATCH 3/5] chore: change to gihub app auth --- .github/workflows/external-test.yml | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/.github/workflows/external-test.yml b/.github/workflows/external-test.yml index 22c1bb160..f35bdb70b 100644 --- a/.github/workflows/external-test.yml +++ b/.github/workflows/external-test.yml @@ -99,6 +99,33 @@ jobs: echo "result=failure" >> $GITHUB_OUTPUT fi + - name: Generate GitHub App token + id: generate-token + uses: actions/github-script@v7 + with: + script: | + const { createAppAuth } = require('@octokit/auth-app'); + + const appId = '${{ secrets.CROSS_REPO_APP_ID }}'; + const privateKey = `${{ secrets.CROSS_REPO_APP_PRIVATE_KEY }}`; + const installationId = '${{ secrets.CROSS_REPO_APP_INSTALLATION_ID }}'; + + // Create authenticated app instance + const auth = createAppAuth({ + appId: appId, + privateKey: privateKey, + installationId: installationId, + }); + + // Get installation access token + const { token } = await auth({ type: 'installation' }); + + // Set the token as output + core.setSecret(token); + core.setOutput('token', token); + + console.log('Successfully generated installation access token'); + - name: Stop Supabase if: always() run: supabase stop @@ -107,7 +134,7 @@ jobs: if: always() uses: actions/github-script@v7 with: - github-token: ${{ secrets.GITHUB_TOKEN }} + github-token: ${{ steps.generate-token.outputs.token }} script: | const typeCheckResult = '${{ steps.type-check.outputs.result }}' || 'failure'; const unitTestResult = '${{ steps.unit-tests.outputs.result }}' || 'failure'; From 9e41771e511f7f711797da175716b88d4b30cfc2 Mon Sep 17 00:00:00 2001 From: Katerina Skroumpelou Date: Wed, 13 Aug 2025 11:38:32 +0300 Subject: [PATCH 4/5] chore: change auth --- .github/workflows/external-test.yml | 28 +++++----------------------- 1 file changed, 5 insertions(+), 23 deletions(-) diff --git a/.github/workflows/external-test.yml b/.github/workflows/external-test.yml index f35bdb70b..a08947438 100644 --- a/.github/workflows/external-test.yml +++ b/.github/workflows/external-test.yml @@ -101,30 +101,12 @@ jobs: - name: Generate GitHub App token id: generate-token - uses: actions/github-script@v7 + uses: actions/create-github-app-token@v1 with: - script: | - const { createAppAuth } = require('@octokit/auth-app'); - - const appId = '${{ secrets.CROSS_REPO_APP_ID }}'; - const privateKey = `${{ secrets.CROSS_REPO_APP_PRIVATE_KEY }}`; - const installationId = '${{ secrets.CROSS_REPO_APP_INSTALLATION_ID }}'; - - // Create authenticated app instance - const auth = createAppAuth({ - appId: appId, - privateKey: privateKey, - installationId: installationId, - }); - - // Get installation access token - const { token } = await auth({ type: 'installation' }); - - // Set the token as output - core.setSecret(token); - core.setOutput('token', token); - - console.log('Successfully generated installation access token'); + app-id: ${{ secrets.CROSS_REPO_APP_ID }} + private-key: ${{ secrets.CROSS_REPO_APP_PRIVATE_KEY }} + owner: supabase + repositories: realtime-js,supabase-js - name: Stop Supabase if: always() From c83418f8dc95e2979a40c3fdbfbbb75d135ef378 Mon Sep 17 00:00:00 2001 From: Katerina Skroumpelou Date: Wed, 13 Aug 2025 11:49:54 +0300 Subject: [PATCH 5/5] app id as var --- .github/workflows/external-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/external-test.yml b/.github/workflows/external-test.yml index a08947438..c1e1581c9 100644 --- a/.github/workflows/external-test.yml +++ b/.github/workflows/external-test.yml @@ -103,7 +103,7 @@ jobs: id: generate-token uses: actions/create-github-app-token@v1 with: - app-id: ${{ secrets.CROSS_REPO_APP_ID }} + app-id: ${{ vars.CROSS_REPO_APP_ID }} private-key: ${{ secrets.CROSS_REPO_APP_PRIVATE_KEY }} owner: supabase repositories: realtime-js,supabase-js