---
name: Continuous Integration

on:
  push:
    branches:
      - main
  pull_request:

jobs:
  flutter:
    name: Flutter
    runs-on: ubuntu-latest
    defaults:
      run:
        working-directory: "app"

    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Setup Flutter
        uses: subosito/flutter-action@v2
        with:
          flutter-version: '3.29.0'
          channel: 'stable'
          cache: true
          cache-key: 'flutter-:os:-:channel:-:version:-:arch:-:hash:'
          cache-path: '${{ runner.tool_cache }}/flutter/:channel:-:version:-:arch:'

      - name: Install Dependencies
        run: |
          flutter pub get

      - name: Test
        run: |
          flutter test

  deno:
    name: Deno
    runs-on: ubuntu-latest

    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Setup Deno
        uses: denoland/setup-deno@v2
        with:
          deno-version: v1.x

      - name: Test
        run: |
          deno test --allow-env --import-map=supabase/functions/import_map.json supabase/functions
