我有一个非常简单的配置,以便在Nextjs应用程序中使用Github Actions使用Cypress运行e2e测试。当它到达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
如果命令由控制操作符&终止,则外壳程序将在以下位置执行命令
子外壳中的背景。外壳程序不等待命令完成,并且
返回状态为0。这些被称为异步命令。命令分开
由一个;按顺序执行; Shell等待每个命令依次终止。
返回状态是最后执行的命令的退出状态。
关于node.js - 在npm启动后Github操作不起作用,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/58423725/