Reputation: 392
I'm trying to use Github's node.js workflow for automating test on my repository. However, I'm having difficulties because node is set up in a child directory instead of the root of my repository. I have been looking for a way to specify the directory in which to run the npm commands but have not found any answer.
Here is the workflow code:
# 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
Here is the error generated by the action 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.
Upvotes: 10
Views: 11455
Reputation: 817
Please specify the "Working-Directory". Please refer to my .yml file.
Work flow file for reference: https://github.com/vishipayyallore/mini-projects-2021/actions/workflows/booksstore-nodeexpressmongo.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
Upvotes: 7
Reputation: 817
Looks like this has been answered already.
How do I run my CI steps in a specific folder in github action
Upvotes: 10