github-action icon indicating copy to clipboard operation
github-action copied to clipboard

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

Open bahmutov opened this issue 4 years ago • 2 comments

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

bahmutov avatar Apr 29 '21 16:04 bahmutov

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!?

mswaagman-godaddy avatar Jun 16 '21 11:06 mswaagman-godaddy

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

karlhorky avatar Jan 18 '22 20:01 karlhorky

Or more finegrained, if your server runs on 8080

 - run: kill $(lsof -t -i :8080)

commonpike avatar May 17 '23 10:05 commonpike

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.

commonpike avatar May 17 '23 10:05 commonpike

@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?

MikeMcC399 avatar May 17 '23 10:05 MikeMcC399

@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.

commonpike avatar May 17 '23 10:05 commonpike

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 avatar May 17 '23 10:05 MikeMcC399

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 avatar May 17 '23 11:05 MikeMcC399

  • I submitted PR https://github.com/cypress-io/github-action/pull/915 to modify the documentation.

MikeMcC399 avatar May 17 '23 12:05 MikeMcC399

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

The release is available on:

Your semantic-release bot :package::rocket:

github-actions[bot] avatar May 22 '23 19:05 github-actions[bot]