https://cypress.io logo
Github actions connection issue
# i-need-help
a
Hi, I have a simple github actions workflow that does the following: 1. Clones the backend laravel repo and frontend Vue3 repo 2. Runs:
php artisan serve --host=127.0.0.1 --port=1234 &
3. Checks the server status using curl:
curl -vv http://127.0.0.1:1234
(it returns the correct default page of the api) 4. Runs cypress:
Copy code
- name: Cypress run
      uses: cypress-io/github-action@v5
      env:
        API_BASE_URL: http://127.0.0.1:1234/
      with:
        start: npm run dev
        wait-on: "http://127.0.0.1:1234/"
5. The cypress command fails on `http://127.0.0.1:1234/ timed out on retry 91 of 3, elapsed 90245ms, limit 90000ms`' in github actions. Any ideas on how I can debug this further? Thanks!
m
Hi, You can find debugging tips for this situation in https://github.com/cypress-io/github-action#debugging.
You might also find the issue https://github.com/cypress-io/github-action/issues/760 helpful, since it illustrates a workaround if the built-in wait-on command (which uses got) is not working.
a
Great options @many-airline-45402 ! I personally prefer to use start-server-and-test: https://github.com/bahmutov/start-server-and-test The
cypress run
command will only be executed when the URL http://127.0.0.1:1234/ responds with an HTTP status code of 200. The server will also shut down when the tests complete. You can find more in our docs here: https://docs.cypress.io/guides/continuous-integration/introduction#Solutions
m
start-server-and-test is a complete alternative to using the github-action. It depends how complex the needs are, which one is better. github-action has lots of options. start-server-and-test is based on the npm package wait-on. You can also use the npm package wait-on in github-action by specifying wait-on: 'npx wait-on --timeout 60000 http://127.0.0.1:1234' The first wait-on is the github-action parameter, the second wait-on, after npx, is the npm package wait-on, which is slightly confusing at first viewing!
a
Thanks for all the help. However I still get: Error: Timed out waiting for: http://127.0.0.1:1234 even with 'wait-on: 'npx wait-on --timeout 20000 http://127.0.0.1:1234'. Do you have an example of starting two different servers inside a github actions runner?
I know the server is up, because I've tried to run a curl -vv command and it actually returns the correct response
I would love to run a real e2e test inside github actions
m
Hi @adamant-printer-77643 You can check out the workflow examples in https://github.com/cypress-io/github-action/tree/master/.github/workflows, particularly https://github.com/cypress-io/github-action/blob/master/.github/workflows/example-wait-on.yml fits your use case. It starts various different servers including from react and vite. You can fork the repository and try out the examples yourself.
You could also try checking for http://localhost:1234/ or http://[::1]:1234/ (IPv6).
https://github.com/cypress-io/github-action/blob/master/.github/workflows/example-start.yml is another example which starts two servers. Have you tried using an alternative server like https://www.npmjs.com/package/serve?