Github actions not working after npm start

Viewed 2575

I have a very simple config in order to run e2e tests with Cypress using Github Actions in a Nextjs app. When it reaches the npm start command, although it seems to work since it gives the correct output: > Ready on http://localhost:3000, the step stays in pending state without ever advancing to the next step.

Any suggestions on how to fix this?

Following github actions config (.github/workflows/nodejs.yml):

name: Node CI

on: [push]

jobs:
  build:

    runs-on: ubuntu-latest

    strategy:
      matrix:
        node-version: [8.x, 10.x, 12.x]

    steps:
    - uses: actions/checkout@v1
    - name: Use Node.js ${{ matrix.node-version }}
      uses: actions/setup-node@v1
      with:
        node-version: ${{ matrix.node-version }}
    - name: npm install, build, and test
      run: |
        npm ci
        npm run build --if-present
        npm start
        npx wait-on http://localhost:3000
      env:
        CI: true
    - name: Run Cypress
      run: |
        npx cypress run
      env:
        CI: true
1 Answers

Using the control operator & works for me. Try the following.

    - name: npm install, build, and test
      run: |
        npm ci
        npm run build --if-present
        npm start & npx wait-on http://localhost:3000
      env:
        CI: true

From man bash

If a command is terminated by the control operator &, the shell executes the command in the background in a subshell. The shell does not wait for the command to finish, and the return status is 0. These are referred to as asynchronous commands. Commands separated by a ; are executed sequentially; the shell waits for each command to terminate in turn. The return status is the exit status of the last command executed.

Related