cli icon indicating copy to clipboard operation
cli copied to clipboard

Cannot run Edge function test in CI

Open riderx opened this issue 1 year ago • 2 comments

Describe the bug This blog article describes how to run Deno test : https://github.com/supabase/supabase/blob/master/apps/docs/content/guides/functions/unit-test.mdx

On my side, when I reproduce it, the serve function never releases the shell and the next step cannot be executed.

To Reproduce Follow the exact step of the doc, also it seems the doc speak about folder supabase/tests but in the image just after it's supabase/functions/tests

Expected behavior The example in the doc should work and run the test properly

Screenshots CleanShot 2024-05-12 at 14 17 28@2x I had to cancel the job after 6 min as it will just max out the GitHub action timeout Link of the run: https://github.com/Cap-go/capgo/actions/runs/9051465646/job/24868015866

riderx avatar May 12 '24 13:05 riderx

I did a PR to resolve the doc issue: https://github.com/supabase/supabase/pull/26211

riderx avatar May 12 '24 13:05 riderx

i managed to make test work on CI with this step:

      - uses: JarvusInnovations/background-action@v1
        name: Bootstrap Edge server
        with:
          run: supabase functions serve &
          wait-on: |
            http-get://127.0.0.1:54321/functions/v1/ok
          # IMPORTANT: to use environment variables in wait-on, you must use this form: ${{ env.VAR }}
          # See wait-on section below for all resource types and prefixes

          tail: true # true = stderr,stdout
          # This will allow you to monitor the progress live

          log-output-resume: stderr
          # Eliminates previously output stderr log entries from post-run output

          wait-for: 1m

          log-output: stderr,stdout # same as true

          log-output-if: failure
          # failure = exit-early or timeout

          working-directory: .

With a custom function, ok who direct respond. Action who did pass here: https://github.com/Cap-go/capgo/actions/runs/9051894658/job/24868953981

riderx avatar May 12 '24 13:05 riderx

Thanks for contributing the docs update. Alternatively, you can also use supabase start in CI for testing functions.

sweatybridge avatar Jun 07 '24 03:06 sweatybridge

@sweatybridge how do i set env var for the edge function then?

riderx avatar Jun 14 '24 21:06 riderx

Ok, I found I can set the env with $ENV. But I see my test failing in GitHub action, where in local it works properly. One weird thing is the test are taking in GitHub action very long time to run when in local all run under one sec. https://github.com/Cap-go/capgo/actions/runs/9522755417/job/26252929906#logs

riderx avatar Jun 14 '24 22:06 riderx

@riderx did you get this working?

adityamookerjee avatar Jul 19 '24 21:07 adityamookerjee