diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index afbded6..f8b6a30 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,4 +1,57 @@ +# name: Test +# on: +# push: +# branches: +# - '*' +# pull_request: +# branches: +# - '*' +# defaults: +# run: +# working-directory: ./ +# jobs: +# build: +# runs-on: ubuntu-latest +# strategy: +# matrix: +# node-version: [20] +# steps: +# - name: Checkout the Repository +# uses: actions/checkout@v4 + +# - name: Setup Node.js +# uses: actions/setup-node@v4 +# with: +# node-version: ${{ matrix.node-version }} +# registry-url: 'https://registry.npmjs.org' +# cache: 'npm' + +# - name: Install dependencies +# run: | +# npm install +# npm run build + +# - name: Install Playwright browsers +# run: | +# npx playwright install chromium --with-deps +# npx playwright install firefox --with-deps +# npx playwright install webkit --with-deps + +# - name: Run tests +# env: +# NEXT_PUBLIC_SUPABASE_URL: ${{ secrets.SUPABASE_URL }} +# NEXT_PUBLIC_SUPABASE_ANON_KEY: ${{ secrets.SUPABASE_ANON_KEY }} +# run: npm run test:coverage && npm run test:e2e + +# - name: Upload coverage reports to Codecov +# uses: codecov/codecov-action@v4 +# env: +# CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + + + name: Test + on: push: branches: @@ -6,15 +59,29 @@ on: pull_request: branches: - '*' + defaults: run: working-directory: ./ + jobs: build: runs-on: ubuntu-latest strategy: matrix: node-version: [20] + env: + # Server-Side Environment Variables + SUPABASE_URL: ${{ secrets.SUPABASE_URL }} + SUPABASE_API_KEY: ${{ secrets.SUPABASE_API_KEY }} + + # Client-Side Environment Variables + NEXT_PUBLIC_SUPABASE_URL: ${{ secrets.NEXT_PUBLIC_SUPABASE_URL }} + NEXT_PUBLIC_SUPABASE_ANON_KEY: ${{ secrets.NEXT_PUBLIC_SUPABASE_ANON_KEY }} + + # Codecov Token + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + steps: - name: Checkout the Repository uses: actions/checkout@v4 @@ -29,6 +96,9 @@ jobs: - name: Install dependencies run: | npm install + + - name: Build the app + run: | npm run build - name: Install Playwright browsers @@ -38,10 +108,9 @@ jobs: npx playwright install webkit --with-deps - name: Run tests - env: - NEXT_PUBLIC_SUPABASE_URL: ${{ secrets.SUPABASE_URL }} - NEXT_PUBLIC_SUPABASE_ANON_KEY: ${{ secrets.SUPABASE_ANON_KEY }} - run: npm run test:coverage && npm run test:e2e + run: | + npm run test:coverage + npm run test:e2e - name: Upload coverage reports to Codecov uses: codecov/codecov-action@v4 diff --git a/lib/supbaseClient.ts b/lib/supbaseClient.ts new file mode 100644 index 0000000..3398d15 --- /dev/null +++ b/lib/supbaseClient.ts @@ -0,0 +1,23 @@ +// lib/supabaseClient.js + +import { createClient } from '@supabase/supabase-js'; + +// Server-Side +const supabaseUrl = process.env.SUPABASE_URL; +const supabaseApiKey = process.env.SUPABASE_API_KEY; + +if (!supabaseUrl || !supabaseApiKey) { + throw new Error('Missing Supabase URL or API Key'); +} + +export const supabaseServer = createClient(supabaseUrl, supabaseApiKey); + +// Client-Side +const supabasePublicUrl = process.env.NEXT_PUBLIC_SUPABASE_URL; +const supabaseAnonKey = process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY; + +if (!supabasePublicUrl || !supabaseAnonKey) { + throw new Error('Missing Supabase Public URL or Anon Key'); +} + +export const supabaseClient = createClient(supabasePublicUrl, supabaseAnonKey);