Github npm 启动后操作不起作用
Github actions not working after npm start
我有一个非常简单的配置,以便 运行 在 Nextjs 应用程序中使用 Github 操作对 Cypress 进行端到端测试。当它到达 npm start
命令时,虽然它似乎可以工作,因为它给出了正确的输出:> Ready on http://localhost:3000
,但该步骤仍处于挂起状态,而不会前进到下一步。
关于如何解决这个问题有什么建议吗?
以下 github 个操作配置 (.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
使用控制运算符 &
对我有用。请尝试以下操作。
- 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
来自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.
我有一个非常简单的配置,以便 运行 在 Nextjs 应用程序中使用 Github 操作对 Cypress 进行端到端测试。当它到达 npm start
命令时,虽然它似乎可以工作,因为它给出了正确的输出:> Ready on http://localhost:3000
,但该步骤仍处于挂起状态,而不会前进到下一步。
关于如何解决这个问题有什么建议吗?
以下 github 个操作配置 (.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
使用控制运算符 &
对我有用。请尝试以下操作。
- 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
来自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.