Vic*_*ico 10 npm github-actions
我正在尝试使用 Github 的 node.js 工作流程在我的存储库上进行自动化测试。但是,我遇到了困难,因为节点是在子目录中设置的,而不是在存储库的根目录中。我一直在寻找一种方法来指定运行 npm 命令的目录,但没有找到任何答案。
这是工作流程代码:
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
name: Node.js CI
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [12.x, 14.x, 16.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
steps:
- uses: actions/checkout@v2
with:
path: backend_app
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
- run: cd backend_app
- run: npm ci
- run: npm run build --if-present
- run: npm test
Run Code Online (Sandbox Code Playgroud)
这是操作 run 生成的错误:
Run npm ci
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path /home/runner/work/directory_name/directory_name/package.json
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, open '/home/runner/work/directory_name/directory_name/package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
npm ERR! /home/runner/.npm/_logs/2021-06-16T03_36_41_777Z-debug.log
Error: Process completed with exit code 254.
Run Code Online (Sandbox Code Playgroud)
请指定“工作目录”。请参考我的 .yml 文件。
# This workflow will do a clean install of node dependencies, build the source code, and run tests across different versions of the node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
name: Node.js CI
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [14.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
working-directory: ./Projects/books-store-mean/webapi
- run: npm run build --if-present
working-directory: ./Projects/books-store-mean/webapi
- run: npm test
working-directory: ./Projects/books-store-mean/webapi
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
10097 次 |
| 最近记录: |