Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accept a working-directory as an input argument #282

Closed
Nefcanto opened this issue Jul 2, 2021 · 8 comments
Closed

Accept a working-directory as an input argument #282

Nefcanto opened this issue Jul 2, 2021 · 8 comments

Comments

@Nefcanto
Copy link

Nefcanto commented Jul 2, 2021

I'm trying to setup node for my GitHub Action. But I'm not working in the default directory.

I clone a repo in dir_one/rep_one and then clone another repo in dir_two/rep_two and copy a couple of files from the first repo to the second repo.

Then I want to setup Node and npm install on the second repo.

working-directory doesn't work with uses and I also tried to - run: cd dir_two/repo_two, but again build fails because it's running in its folder.

I receive this error:

Error: Dependencies lock file is not found in /home/runner/work/Site/Site. Supported file patterns: package-lock.json,yarn.lock

Please create an input argument to accept path where node should search for package.json file.

@karlosos
Copy link

karlosos commented Jul 7, 2021

I have a similar problem. My monorepo has the following structure:

my-repo/
├─ frontend/
│  ├─ package.json
│  ├─ package-lock.json
│  ├─ src
├─ backend/

Is there a possibility of using actions/setup-node@v2 inside ./frontend directory?

I've tried following workflow:

# This workflow will do a clean install of node dependencies, cache/restore them, 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 ]

defaults:
  run:
    working-directory: frontend

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
    - name: Use Node.js ${{ matrix.node-version }}
      uses: actions/setup-node@v2
      with:
        node-version: ${{ matrix.node-version }}
        cache: 'npm'
    - run: npm ci
    - run: npm run build --if-present
    - run: npm test

With similar error:

Error: Dependencies lock file is not found in /home/runner/work/django_chatroom/django_chatroom. Supported file patterns: package-lock.json,yarn.lock

image

@dbaker-aa
Copy link

dbaker-aa commented Jul 8, 2021

@Nefcanto , @karlosos

Hey Folks, I was playing around with this myself and I was able to get it to work by changing from v2 to v1. My steps section now looks like this. if you use v1 instead of v2 you should only need to get rid of "cache"

 steps:
  - uses: actions/checkout@v2
  - name: Use Node.js ${{ matrix.node-version }}
    uses: actions/setup-node@v1
    with:
      node-version: ${{ matrix.node-version }}
  - run: npm ci
    working-directory: frontend
  - run: npm run build --if-present
    working-directory: frontend
  - run: npm test
    working-directory: frontend

@karlosos
Copy link

karlosos commented Jul 9, 2021

Thank you @dbaker-aa. Changing uses: actions/setup-node@v2 to uses: actions/setup-node@v1 solves the issue.

@Nefcanto
Copy link
Author

Nefcanto commented Jul 9, 2021

Hi @dbaker-aa , thank you for that note. However, I'm not going back. Software entities are supposed to move forward and add features, not remove them. This feature should exist in this action to become a more mature action.

@talldan
Copy link

talldan commented Jul 13, 2021

I think this was already requested in #275., so this might be a duplicate

Not a contributor though, was just browsing the repo 😄

@jlaamanen
Copy link

I had the same problem, but I didn't have to downgrade to v1 - just removing cache while still using v2 worked for me. There also seems to be a mention about this in the readme:

At the moment, only lock files in the project root are supported.

@maxim-lobanov
Copy link
Contributor

Hello everyone!

This feature request will be implemented soon. I have a small ADR under review #299 .
Proposed approach is a bit different from proposed in this issue - we would like allow specifying full path (directory path + filename) to lock file instead of working_directory (directory path only). We believe this approach will be a bit more generic and unblock more use-cases.

jsamr added a commit to meliorence/react-native-render-html that referenced this issue Jul 19, 2021
robertwood-mobile pushed a commit to robertwood-mobile/React-Native-Render-HTML that referenced this issue Jun 11, 2022
@jylin
Copy link

jylin commented Sep 10, 2022

Many actions support the "working-directory" input now, and it's even suggested on the GitHub docs to use this parameter: https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#defaultsrun

Would it please be possible to support "working-directory" input for this action to be consistent?

adibtatriantama added a commit to adibtatriantama/FCC-Voting-App that referenced this issue Oct 12, 2022
actions/setup-node@v3.3.0 doesn't support using working-directory.
Related Issue: actions/setup-node#282
deining pushed a commit to deining/setup-node that referenced this issue Nov 9, 2023
Bumps [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/eslint-plugin) from 4.29.3 to 4.30.0.
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v4.30.0/packages/eslint-plugin)

---
updated-dependencies:
- dependency-name: "@typescript-eslint/eslint-plugin"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants