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

[BUG] How to run only in a specific directory of a project? #90

Open
mfn opened this issue Feb 3, 2022 · 5 comments
Open

[BUG] How to run only in a specific directory of a project? #90

mfn opened this issue Feb 3, 2022 · 5 comments
Labels
bug Something isn't working hacktoberfest

Comments

@mfn
Copy link

mfn commented Feb 3, 2022

What exactly happened?
I used the action like this:

      - name: prettier check
        uses: creyD/prettier_action@v4.2
        with:
          dry: true
          prettier_version: ${{ env.PRETTIER_VERSION }}
          prettier_options: --no-editorconfig --check src/ internals/
          working_directory: subdir/

This didn't work and I get:

/home/ubuntu/actions-runner/_work/_actions/creyD/prettier_action/v4.2/entrypoint.sh: line 44: cd: subdir/: No such file or directory

I thought maybe I need to provide the workspace, tried with:

          working_directory: ${{ github.workspace }}/subdir/

But that gave only:

Installing prettier...
Error: Process completed with exit code 1.

No further details 🤷🏼

I then had to resorted to this:

      - name: prettier check
        uses: creyD/prettier_action@v4.2
        with:
          dry: true
          prettier_version: ${{ env.PRETTIER_VERSION }}
          prettier_options: --no-editorconfig --check --ignore-path subdir/.prettierignore subdir/src/ subdir/internals/

I'd have hoped that using a working_directory it would auto-pick up the .prettierignore from there etc.

But at this point, I've no idea how working_directory works and have the impression it's used for something else.

Is it possible to install prettier and point it to a specific directory and "work from there"?

thank you 🙏🏼

@mfn mfn added the bug Something isn't working label Feb 3, 2022
@markstos
Copy link

markstos commented Feb 4, 2022

@mfn You can search for working_directory in this repo to find out how it is used. It works just like you think: It's used to cd into that directory and that's it. Your problem may be elsewhere.

cd $INPUT_WORKING_DIRECTORY

@mfn
Copy link
Author

mfn commented Feb 4, 2022

@markstos thank you, good point!

But looking a few lines above, isn't the issue the the action changes into its own action directory first so working_directory is relative to that and not to the project being checked out?

cd "$GITHUB_ACTION_PATH"
echo "Installing prettier..."
case $INPUT_WORKING_DIRECTORY in
false)
;;
*)
cd $INPUT_WORKING_DIRECTORY

So relative paths are relative to this action and would make sense why something like working_directory: subdir/ won't work, as GITHUB_ACTION_PATH is documented being

The path where an action is located. This property is only supported in composite actions. You can use this path to access files located in the same repository as the action. For example, /home/runner/work/_actions/repo-owner/name-of-action-repo/v1.

vs. what this action documents (emphasis mine):

Specify a directory to cd into before installing prettier and running it, use relative file path to the repository root for example app/

Can't make sense why my version with the absolute path wouldn't work though.

I'd say that, for relative paths, at least that's unexpected / a bug somewhere?

@markstos
Copy link

markstos commented Feb 4, 2022

If the "working_directory" is not resolved relative to the project root, that seems like a bug to me.

I ran into my own path-related problem with a file-not-found error that doesn't tell me which file is not found. Nice tool, but still some rough edges here.

#91

@quinn-dougherty
Copy link

quinn-dougherty commented Apr 12, 2022

Desired behavior is for working_directory to be relative to root project dir, basically wherever the .git directory is.

quinn-dougherty added a commit to quantified-uncertainty/squiggle that referenced this issue Apr 12, 2022
@lnxd
Copy link

lnxd commented Feb 10, 2023

Anyone who lands here, might be worth checking my comment at #94 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working hacktoberfest
Projects
None yet
Development

No branches or pull requests

5 participants