cypress-io / github-action

GitHub Action for running Cypress end-to-end & component tests
https://on.cypress.io/guides/continuous-integration/github-actions
MIT License
1.37k stars 345 forks source link

Does the server started with the start parameter shut down at the end? #360

Closed bahmutov closed 1 year ago

bahmutov commented 3 years ago

Seems from https://github.com/bahmutov/cypress-grep-example results that not:

name: ci
on: [push]
jobs:
  cypress-run:
    runs-on: ubuntu-20.04
    steps:
      - name: Checkout πŸ›Ž
        uses: actions/checkout@v2

      - name: Install dependencies πŸ“¦
        uses: cypress-io/github-action@v2
        with:
          # just perform install
          runTests: false

      # run just the smoke tests with "@smoke" string in their names
      - name: Smoke tests πŸ’¨
        uses: cypress-io/github-action@v2
        with:
          # we have already installed all dependencies above
          install: false
          start: npm start
          # quote the url to be safe against YML parsing surprises
          wait-on: 'http://localhost:8888'
          # pass the grep string
          env: grep=@smoke
          # record the results on the Cypress Dashboard
          # https://on.cypress.io/dashboard-introduction
          record: true
          # tag the smoke tests for quick find
          tag: smoke
        # environment variables while running Cypress
        env:
          # pass the Dashboard record key as an environment variable
          CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
          # pass GitHub token to allow accurately detecting a build vs a re-run build
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

      # if smoke tests passed, run all the tests
      - name: E2E tests πŸ’¨
        uses: cypress-io/github-action@v2
        with:
          # we have already installed all dependencies above
          install: false
          start: npm start
          # quote the url to be safe against YML parsing surprises
          wait-on: 'http://localhost:8888'
          # record the results on the Cypress Dashboard
          # https://on.cypress.io/dashboard-introduction
          record: true
          tag: all
        # environment variables while running Cypress
        env:
          # pass the Dashboard record key as an environment variable
          CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
          # pass GitHub token to allow accurately detecting a build vs a re-run build
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

The smoke tests pass just fine, but the second action launch is showing an error

Screen Shot 2021-04-29 at 12 12 13 PM

mswaagman-godaddy commented 3 years ago

Seeing similar behavior for one of our GHA workflows. Imho the action should just clean up processes rather than leaving them dangling and πŸ™πŸ» the GHA will clean up all leftovers.

Edit: likely GHAs only clean up processes until the entire workflow is complete rather than in between steps!?

karlhorky commented 2 years ago

Workaround

Yeah I think the processes don't end - we're trying to start the same server right afterwards, and the port is blocked.

In the meantime, our (somewhat overkill) workaround is:

- run: killall node

Edit: Wonder if this is a general thing with some things running on GitHub Actions (maybe Corepack?):

commonpike commented 1 year ago

Or more finegrained, if your server runs on 8080

 - run: kill $(lsof -t -i :8080)
commonpike commented 1 year ago

This is imho a real 'documentation bug' - here https://github.com/cypress-io/github-action#start-server

it says

the server will run in the background and will shut down after tests complete

and

Note: GitHub cleans up the running server processes automatically. This action does not stop them.

both lines seem to contradict eachother.

MikeMcC399 commented 1 year ago

@commonpike

Is this just a documentation issue for you or do you have an example workflow using the current version of the action (v5) where it is causing you a problem?

commonpike commented 1 year ago

@MikeMcC399 - no, I'm killing the server now and that works. I didn't read the note until I found out the first line was not true :-)

So it's just a documentation issue.

MikeMcC399 commented 1 year ago

Probably if there was a need to start a server a second time, then I would put it into a separate job rather than a step in the same job. I'm not sure if the original issue from 2 years ago is the optimal way to use the action. In any case the documentation could be made more precise.

MikeMcC399 commented 1 year ago

I haven't looked at this too closely, but I think in the original example I would have just deleted the second start: npm start, unless there is some special reason to want to restart the server.

MikeMcC399 commented 1 year ago
github-actions[bot] commented 1 year ago

:tada: This issue has been resolved in version 5.8.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket: