test(postgrest): stabilize tests and setup prettier #233
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Supabase JS tests | |
| on: | |
| pull_request: | |
| paths: | |
| - 'package.json' | |
| - 'package-lock.json' | |
| - 'nx.json' | |
| - '.github/workflows/ci-supabase-js.yml' | |
| # any change in any of the packages should trigger these tests | |
| - 'packages/**' | |
| - '!packages/core/**/docs/**' | |
| - '!packages/core/**/*.md' | |
| - '!packages/**/.prettierrc' | |
| - '!packages/**/*ignore' | |
| workflow_call: | |
| env: | |
| NODE_VERSION: '20' | |
| jobs: | |
| build-package: | |
| name: Build all packages | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| filter: tree:0 | |
| fetch-depth: 0 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ env.NODE_VERSION }} | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm ci --legacy-peer-deps | |
| - uses: nrwl/nx-set-shas@v4 | |
| - name: Build all packages | |
| run: npx nx run-many --target=build --all | |
| - name: Upload built packages | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: packages-dist | |
| path: | | |
| packages/core/auth-js/dist | |
| packages/core/functions-js/dist | |
| packages/core/postgrest-js/dist | |
| packages/core/realtime-js/dist | |
| packages/core/storage-js/dist | |
| packages/core/supabase-js/dist | |
| - name: Upload UMD build | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: supabase-umd | |
| path: packages/core/supabase-js/dist/umd/supabase.js | |
| test: | |
| name: Unit + Type Check / Node.js ${{ matrix.node }} / OS ${{ matrix.os }} | |
| runs-on: ${{ matrix.os }} | |
| needs: build-package | |
| strategy: | |
| matrix: | |
| node: [20] | |
| os: [ubuntu-latest, macos-latest, windows-latest] | |
| fail-fast: false | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| filter: tree:0 | |
| fetch-depth: 0 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ matrix.node }} | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm ci --legacy-peer-deps | |
| - name: Type Check + Unit Tests + Coverage | |
| run: npx nx run-many --targets=test:types,test:coverage --projects=supabase-js | |
| - name: Upload coverage results to Coveralls | |
| uses: coverallsapp/github-action@v2 | |
| with: | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| path-to-lcov: ./packages/core/supabase-js/test/coverage/lcov.info | |
| parallel: true | |
| flag-name: node-${{ matrix.node }}-${{ matrix.os }} | |
| fail-on-error: false | |
| continue-on-error: true | |
| coveralls-finish: | |
| name: Coveralls Finished | |
| runs-on: ubuntu-latest | |
| needs: test | |
| steps: | |
| - name: Coveralls Finished | |
| uses: coverallsapp/github-action@v2 | |
| with: | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| parallel-finished: true | |
| fail-on-error: false | |
| continue-on-error: true | |
| deno-tests: | |
| name: Deno Tests / ${{ matrix.deno }} | |
| runs-on: ubuntu-latest | |
| needs: build-package | |
| strategy: | |
| matrix: | |
| deno: ['1.x', '2.x'] | |
| fail-fast: false | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| filter: tree:0 | |
| fetch-depth: 0 | |
| - name: Setup Deno | |
| uses: denoland/setup-deno@v2 | |
| with: | |
| deno-version: ${{ matrix.deno }} | |
| - name: Setup Supabase CLI | |
| uses: supabase/setup-cli@v1 | |
| with: | |
| version: latest | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ env.NODE_VERSION }} | |
| cache: 'npm' | |
| - name: Download built packages | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: packages-dist | |
| path: packages/core | |
| - name: Install dependencies | |
| run: npm ci --legacy-peer-deps | |
| - name: Start Verdaccio | |
| run: | | |
| npx verdaccio --config .verdaccio/config.yml & | |
| sleep 3 | |
| - name: Configure npm auth for Verdaccio | |
| run: npm config set //localhost:4873/:_authToken "secretVerdaccioToken" | |
| - name: Publish packages to Verdaccio | |
| run: node scripts/populate-verdaccio.mjs | |
| - name: Start Supabase and apply migrations | |
| run: | | |
| cd packages/core/supabase-js | |
| echo "Starting Supabase from packages/core/supabase-js directory" | |
| supabase start | |
| echo "Resetting database to apply migrations" | |
| supabase db reset --no-seed | |
| echo "Waiting for PostgREST schema cache to refresh" | |
| sleep 5 | |
| echo "Creating storage bucket" | |
| supabase db query "insert into storage.buckets (id, name, public) values ('test-bucket','test-bucket', false) on conflict (id) do nothing;" | |
| echo "Verifying todos table exists" | |
| supabase db query "select count(*) from public.todos;" | |
| echo "Verifying storage bucket exists" | |
| supabase db query "select id, name from storage.buckets where id = 'test-bucket';" | |
| - name: Verify packages in Verdaccio | |
| run: | | |
| echo "Verifying @supabase/supabase-js is available in Verdaccio..." | |
| npm view @supabase/supabase-js version --registry http://localhost:4873 | |
| npm view @supabase/supabase-js --registry http://localhost:4873 | head -20 | |
| - name: Run Deno Tests (1.x) | |
| if: ${{ matrix.deno == '1.x' }} | |
| env: | |
| STORAGE_JS_ENTRY: main | |
| DENO_NPM_REGISTRY: http://localhost:4873 | |
| run: | | |
| cd packages/core/supabase-js/test/deno | |
| echo "registry=http://localhost:4873/" > .npmrc | |
| npm install | |
| npm test || npm test | |
| rm -f .npmrc | |
| cd ../../.. | |
| - name: Run Deno Tests (2.x) | |
| if: ${{ matrix.deno == '2.x' }} | |
| env: | |
| DENO_NPM_REGISTRY: http://localhost:4873 | |
| run: | | |
| cd packages/core/supabase-js/test/deno | |
| echo "registry=http://localhost:4873/" > .npmrc | |
| npm install | |
| npm test || npm test | |
| rm -f .npmrc | |
| cd ../../.. | |
| - name: Run integration and browser tests on Deno 2.x only | |
| if: ${{ matrix.deno == '2.x' }} | |
| run: npx nx test:integration:browser supabase-js | |
| - name: Run Edge Functions Tests | |
| if: ${{ matrix.deno == '2.x' }} | |
| run: | | |
| cd packages/core/supabase-js/test/deno | |
| npm run test:edge-functions | |
| cd ../../.. | |
| - name: Stop Supabase | |
| if: always() | |
| run: | | |
| cd packages/core/supabase-js | |
| supabase stop | |
| node-integration: | |
| name: Node Integration | |
| runs-on: ubuntu-latest | |
| needs: build-package | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| filter: tree:0 | |
| fetch-depth: 0 | |
| - 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 and apply migrations | |
| run: | | |
| cd packages/core/supabase-js | |
| echo "Starting Supabase from packages/core/supabase-js directory" | |
| supabase start | |
| echo "Resetting database to apply migrations" | |
| supabase db reset --no-seed | |
| echo "Waiting for PostgREST schema cache to refresh" | |
| sleep 5 | |
| echo "Creating storage bucket" | |
| supabase db query "insert into storage.buckets (id, name, public) values ('test-bucket','test-bucket', false) on conflict (id) do nothing;" | |
| echo "Verifying todos table exists" | |
| supabase db query "select count(*) from public.todos;" | |
| echo "Verifying storage bucket exists" | |
| supabase db query "select id, name from storage.buckets where id = 'test-bucket';" | |
| - name: Install dependencies and build | |
| run: | | |
| npm ci --legacy-peer-deps | |
| npx nx build supabase-js | |
| - name: Install jq | |
| run: sudo apt-get update && sudo apt-get install -y jq | |
| - name: Run integration tests | |
| run: | | |
| cd packages/core/supabase-js | |
| export SUPABASE_SERVICE_ROLE_KEY="$(supabase status --output json | jq -r '.SERVICE_ROLE_KEY')" | |
| cd ../../.. | |
| npx nx test:integration supabase-js || npx nx test:integration supabase-js | |
| - name: Stop Supabase | |
| if: always() | |
| run: | | |
| cd packages/core/supabase-js | |
| supabase stop | |
| next-integration: | |
| name: Next.js Integration | |
| runs-on: ubuntu-latest | |
| needs: build-package | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| filter: tree:0 | |
| fetch-depth: 0 | |
| - 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: Download built packages | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: packages-dist | |
| path: packages/core | |
| - name: Install dependencies | |
| run: npm ci --legacy-peer-deps | |
| - name: Start Verdaccio | |
| run: | | |
| npx verdaccio --config .verdaccio/config.yml & | |
| sleep 3 | |
| - name: Configure npm auth for Verdaccio | |
| run: npm config set //localhost:4873/:_authToken "secretVerdaccioToken" | |
| - name: Publish packages to Verdaccio | |
| run: node scripts/populate-verdaccio.mjs | |
| - name: Start Supabase and apply migrations | |
| run: | | |
| cd packages/core/supabase-js | |
| echo "Starting Supabase from packages/core/supabase-js directory" | |
| supabase start | |
| echo "Resetting database to apply migrations" | |
| supabase db reset --no-seed | |
| echo "Waiting for PostgREST schema cache to refresh" | |
| sleep 5 | |
| echo "Creating storage bucket" | |
| supabase db query "insert into storage.buckets (id, name, public) values ('test-bucket','test-bucket', false) on conflict (id) do nothing;" | |
| echo "Verifying todos table exists" | |
| supabase db query "select count(*) from public.todos;" | |
| echo "Verifying storage bucket exists" | |
| supabase db query "select id, name from storage.buckets where id = 'test-bucket';" | |
| - name: Verify packages in Verdaccio | |
| run: | | |
| echo "Verifying @supabase/supabase-js is available in Verdaccio..." | |
| npm view @supabase/supabase-js version --registry http://localhost:4873 | |
| npm view @supabase/supabase-js --registry http://localhost:4873 | head -20 | |
| - name: Run integration tests in isolation | |
| run: | | |
| TEST_DIR="/tmp/test-next-${{ github.run_id }}" | |
| mkdir -p "$TEST_DIR" | |
| cp -r packages/core/supabase-js/test/integration/next/* "$TEST_DIR/" | |
| cd "$TEST_DIR" | |
| echo "registry=http://localhost:4873/" > .npmrc | |
| npm install --legacy-peer-deps | |
| npx playwright install --with-deps | |
| npm run test | |
| rm -f .npmrc | |
| - name: Stop Supabase | |
| if: always() | |
| run: | | |
| cd packages/core/supabase-js | |
| supabase stop | |
| expo-tests: | |
| name: Expo Tests | |
| runs-on: ubuntu-latest | |
| needs: build-package | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| filter: tree:0 | |
| fetch-depth: 0 | |
| - 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: Download built packages | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: packages-dist | |
| path: packages/core | |
| - name: Install dependencies | |
| run: npm ci --legacy-peer-deps | |
| - name: Start Verdaccio | |
| run: | | |
| npx verdaccio --config .verdaccio/config.yml & | |
| sleep 3 | |
| - name: Configure npm auth for Verdaccio | |
| run: npm config set //localhost:4873/:_authToken "secretVerdaccioToken" | |
| - name: Publish packages to Verdaccio | |
| run: node scripts/populate-verdaccio.mjs | |
| - name: Start Supabase and apply migrations | |
| run: | | |
| cd packages/core/supabase-js | |
| echo "Starting Supabase from packages/core/supabase-js directory" | |
| supabase start | |
| echo "Resetting database to apply migrations" | |
| supabase db reset --no-seed | |
| echo "Waiting for PostgREST schema cache to refresh" | |
| sleep 5 | |
| echo "Creating storage bucket" | |
| supabase db query "insert into storage.buckets (id, name, public) values ('test-bucket','test-bucket', false) on conflict (id) do nothing;" | |
| echo "Verifying todos table exists" | |
| supabase db query "select count(*) from public.todos;" | |
| echo "Verifying storage bucket exists" | |
| supabase db query "select id, name from storage.buckets where id = 'test-bucket';" | |
| - name: Verify packages in Verdaccio | |
| run: | | |
| echo "Verifying @supabase/supabase-js is available in Verdaccio..." | |
| npm view @supabase/supabase-js version --registry http://localhost:4873 | |
| npm view @supabase/supabase-js --registry http://localhost:4873 | head -20 | |
| - name: Install test dependencies and run tests in isolation | |
| run: | | |
| TEST_DIR="/tmp/test-expo-${{ github.run_id }}" | |
| mkdir -p "$TEST_DIR" | |
| cp -r packages/core/supabase-js/test/integration/expo/* "$TEST_DIR/" | |
| cd "$TEST_DIR" | |
| echo "registry=http://localhost:4873/" > .npmrc | |
| npm install | |
| npm test | |
| rm -f .npmrc | |
| - name: Stop Supabase | |
| if: always() | |
| run: | | |
| cd packages/core/supabase-js | |
| supabase stop | |
| bun-integration: | |
| name: Bun Integration | |
| runs-on: ubuntu-latest | |
| needs: build-package | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| filter: tree:0 | |
| fetch-depth: 0 | |
| - name: Setup Bun | |
| uses: oven-sh/setup-bun@v1 | |
| with: | |
| bun-version: latest | |
| - 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: Download built packages | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: packages-dist | |
| path: packages/core | |
| - name: Install dependencies | |
| run: npm ci --legacy-peer-deps | |
| - name: Start Verdaccio | |
| run: | | |
| npx verdaccio --config .verdaccio/config.yml & | |
| sleep 3 | |
| - name: Configure npm auth for Verdaccio | |
| run: npm config set //localhost:4873/:_authToken "secretVerdaccioToken" | |
| - name: Publish packages to Verdaccio | |
| run: node scripts/populate-verdaccio.mjs | |
| - name: Start Supabase and apply migrations | |
| run: | | |
| cd packages/core/supabase-js | |
| echo "Starting Supabase from packages/core/supabase-js directory" | |
| supabase start | |
| echo "Resetting database to apply migrations" | |
| supabase db reset --no-seed | |
| echo "Waiting for PostgREST schema cache to refresh" | |
| sleep 5 | |
| echo "Creating storage bucket" | |
| supabase db query "insert into storage.buckets (id, name, public) values ('test-bucket','test-bucket', false) on conflict (id) do nothing;" | |
| echo "Verifying todos table exists" | |
| supabase db query "select count(*) from public.todos;" | |
| echo "Verifying storage bucket exists" | |
| supabase db query "select id, name from storage.buckets where id = 'test-bucket';" | |
| - name: Verify packages in Verdaccio | |
| run: | | |
| echo "Verifying @supabase/supabase-js is available in Verdaccio..." | |
| npm view @supabase/supabase-js version --registry http://localhost:4873 | |
| npm view @supabase/supabase-js --registry http://localhost:4873 | head -20 | |
| - name: Install dependencies and run tests in isolation | |
| run: | | |
| TEST_DIR="/tmp/test-bun-${{ github.run_id }}" | |
| mkdir -p "$TEST_DIR" | |
| cp -r packages/core/supabase-js/test/integration/bun/* "$TEST_DIR/" | |
| cd "$TEST_DIR" | |
| echo "registry=http://localhost:4873/" > .npmrc | |
| bun install | |
| bun test | |
| rm -f .npmrc | |
| - name: Stop Supabase | |
| if: always() | |
| run: | | |
| cd packages/core/supabase-js | |
| supabase stop | |
| websocket-browser-tests: | |
| name: WebSocket Browser Tests | |
| runs-on: ubuntu-latest | |
| needs: build-package | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| filter: tree:0 | |
| fetch-depth: 0 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ env.NODE_VERSION }} | |
| - name: Download artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: supabase-umd | |
| path: ./packages/core/supabase-js/dist/umd/ | |
| - name: Setup Supabase CLI | |
| uses: supabase/setup-cli@v1 | |
| with: | |
| version: latest | |
| - name: Install Playwright browsers and dependencies | |
| run: npx playwright install --with-deps | |
| - name: Start Supabase and apply migrations | |
| run: | | |
| cd packages/core/supabase-js | |
| echo "Starting Supabase from packages/core/supabase-js directory" | |
| supabase start | |
| echo "Resetting database to apply migrations" | |
| supabase db reset --no-seed | |
| echo "Waiting for PostgREST schema cache to refresh" | |
| sleep 5 | |
| echo "Creating storage bucket" | |
| supabase db query "insert into storage.buckets (id, name, public) values ('test-bucket','test-bucket', false) on conflict (id) do nothing;" | |
| echo "Verifying todos table exists" | |
| supabase db query "select count(*) from public.todos;" | |
| echo "Verifying storage bucket exists" | |
| supabase db query "select id, name from storage.buckets where id = 'test-bucket';" | |
| - name: Run WebSocket tests | |
| run: | | |
| cd packages/core/supabase-js/test/integration/node-browser | |
| npm install | |
| cp ../../../dist/umd/supabase.js . | |
| npm run test | |
| - name: Stop Supabase | |
| if: always() | |
| run: | | |
| cd packages/core/supabase-js | |
| supabase stop |