Skip to content
This repository has been archived by the owner on Aug 13, 2022. It is now read-only.

default working-directory not respected for yarn.lock #21

Closed
philihp opened this issue Dec 7, 2021 · 3 comments
Closed

default working-directory not respected for yarn.lock #21

philihp opened this issue Dec 7, 2021 · 3 comments

Comments

@philihp
Copy link

philihp commented Dec 7, 2021

I do not mean to shame people who like monorepos, but I have found that this action might not work for them without some additional configuration. The following will fail:

# .github/workflows/someproject.yml
name: someproject
on:
  - push

jobs:
  tests:
    runs-on: ubuntu-latest
    defaults:
      run:
        working-directory: someproject
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-node@v1
        with:
          # AWS executes lambdas on Node.js 14
          node-version: 14.x
      - uses: c-hive/gha-yarn-cache@v2
      - run: yarn install
      - run: yarn test

because it still looks for a yarn.lock in the root. Perhaps in addition to looking at its own config, this action could look at defaults.run.working-directory here?

const directory = core.getInput("directory");

As a stopgap, the user can work around by specifying the working directory twice.

      - uses: c-hive/gha-yarn-cache@v2
        with:
          directory: someproject
@thisismydesign
Copy link
Member

This is correct, thanks for pointing it out. Happy to take a PR for it.

@philihp
Copy link
Author

philihp commented Dec 8, 2021

Took an attempt, and it appears this default variable isn't made available to custom actions 😞 actions/runner#467

@thisismydesign
Copy link
Member

Ah yes, I remember now.. As pointed out in actions/runner#467 (comment)

The issue is that - uses: my/action@v1 will not run in the working-directory specified by the defaults ... the docs clearly say the working dir only applies for - run:.

I agree that this is confusing, but it can be equally confusing to use a run default when it is not intended that way. Since monorepo support is solved and documented in the readme, I'm happy with the current state.

Closing for now, feel free to ping this issue if there's a default we can use in the future.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants