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] working_directory alway return the path is not a file or dir #94

Open
Fatpandac opened this issue Jul 7, 2022 · 14 comments
Open
Labels
bug Something isn't working hacktoberfest

Comments

@Fatpandac
Copy link

Fatpandac commented Jul 7, 2022

how to use working_directory ?
image

@Fatpandac Fatpandac added the bug Something isn't working label Jul 7, 2022
@creyD
Copy link
Owner

creyD commented Jul 7, 2022

Can you please add your config and if the repo is public a link to the repo?

@Fatpandac
Copy link
Author

name: auto prettier

on:
  push:
    branches:
      - feat/refactor_docs_site
    paths:
      - 'site-vuepress/**'

jobs:
  prettier:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout
        uses: actions/checkout@v2
        with:
          ref: ${{ github.head_ref }}
      
      - name: Prettify code
        uses: creyD/prettier_action@v4.2
        with:
          working_directory: 'site-vuepress/'
          same_commit: true
          prettier_options: --write .

repo link: https://github.com/Fatpandac/arthas

@ParthS007
Copy link

Screenshot 2022-07-28 at 09 16 53

@creyD Same is happening , did you had the time to look into this?

Some info that might help:

I have another workflow where I use the working-directory variable and it works fine with ./ui directory. Maybe some where in the code where you parse the arg to working-directory. Thanks for your time.

Screenshot 2022-07-28 at 09 19 04

@Fatpandac Do you have a workaround for this already?

@Fatpandac
Copy link
Author

Fatpandac commented Jul 28, 2022

@ParthS007 No idea. I give up on using working-directory in the end.

@creyD
Copy link
Owner

creyD commented Jul 28, 2022

Really sorry, I didn't find the time yet to look at this properly. Could you test please without the ''? So this would be working_directory: site-vuepress/? @Fatpandac

@Fatpandac
Copy link
Author

Thank you so much for your reply to me again.
I do not need to work out this problem now.
You can help @ParthS007 to work out this problem.

@creyD
Copy link
Owner

creyD commented Jul 28, 2022

@ParthS007 Could you please post your repo or the action config here?

@ParthS007
Copy link

ParthS007 commented Jul 29, 2022

@ParthS007
Copy link

@creyD Any updates on this bug if you had the time to look into the issue. Thanks

@creyD
Copy link
Owner

creyD commented Aug 1, 2022

Can you try with working-status: ui/?

@ParthS007
Copy link

Thanks, The error is not there anymore but I see this warning:

Warning: Unexpected input(s) 'working-status', valid inputs are ['commit_message', 'commit_description', 'same_commit', 'commit_options', 'push_options', 'file_pattern', 'prettier_options', 'dry', 'prettier_version', 'working_directory', 'only_changed', 'prettier_plugins', 'github_token']

This is the workflow file.

Although, I see now only_changed is not taken in consideration. I want to run this action only on changed files in the commit, It checks all code in the ui/. Is this related or something not possible?

@totoprayogo1916
Copy link

still waiting for fix this issue 🙄

@lnxd
Copy link

lnxd commented Feb 10, 2023

I'm rewriting this comment as I have a feeling that this issue is actually a misinterpretation of the working_directory option. It's rather confusing because Github seems to treat the working directory option as the place that data is going to be accessed and modified, and this action seems to treat it as something else entirely.

Please note that the following might be entirely wrong, it's just my interpretation.

If you're here because you want to use prettier on a subdirectory in your repo

(ie. in my case, I have a Laravel instance at /api and a Vue instance at /app. I use laravel-pint for /api so I wanted prettier for /app)

  • The working_directory option appears to be for something else, the README.md and code gives this away.
  • What you're looking for is the prettier_options option.
  • I might be incorrect with my implementation, but the following is a copy of my workflow.yml that's currently working for me:
name: Fix Code Style (App)

on:
  workflow_dispatch:

jobs:
  prettier:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout
        uses: actions/checkout@v3
        with:
          fetch-depth: 0
          ref: ${{ github.head_ref }}
          # Make sure the value of GH_REPO_WRITE_TOKEN will not be persisted in repo's config
          persist-credentials: false

      - name: Prettify code
        uses: creyD/prettier_action@v4.2
        with:
          prettier_options: --write /home/runner/work/repo_name/repo_name/working_directory/**/*.{js,jsx,ts,tsx,html,vue}
          github_token: ${{ secrets.GH_REPO_WRITE_TOKEN }}

If you're here because you have a reason to want to install prettier to a specific directory on the runner

(which I believe the working_directory option is for, although I'm pretty sure it's not working at the moment):

  • The working_directory value requires absolute paths, and the path has to exist. That's why @Fatpandac was getting this error initially. I think the correct way to use it would either be to use an absolute path to an existing directory in your checked out repo, or to have a step above it that creates a folder somewhere else on the runner.
  • I'm not sure when this option would be useful, but based on the location checkout checked out to for me, I needed to enter working_directory path in the format:
    /home/runner/work/repo-name/repo-name/working-directory-name.
  • Once I got it working, I got this error:
    /home/runner/work/_actions/creyD/prettier_action/v4.2/entrypoint.sh: line 74: prettier: command not found
  • I'm thinking possible solutions to this would be to ensure prettier is in $PATH, working_directory possibly could be added to the prettier command instead of cding to the directory, or the entrypoint.sh might need to be updated to use an ./absolute/path/to/prettier instead.

@creyD I can put together a pull request that will hopefully clear up this confusion if my interpretation is correct. Looks like it'd mostly consist of changes to the readme, although again I'm really not sure of a use case where the working_directory option would be useful outside of specifically working on this action.

@creyD
Copy link
Owner

creyD commented Jun 30, 2023

Thanks for the comment, sorry I didn't see it earlier. The working_directory option changes before prettier command is installed and sets the directory for the entire action. So yes, prettier is installed at the path you specify. That being said prettier_options can -like you showed- be used to specify directory as well. So it should actually work in my opinion.

@ParthS007 If you are still up to it (after such a long time) we should tackle this once and for all. I believe my autocorrect messed up when I wrote working-status, I meant working_directory. But I think you already tested it, right?

LordTermor added a commit to LordTermor/bxt that referenced this issue Feb 29, 2024
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