Code Monkey home page Code Monkey logo

Comments (14)

lnxd avatar lnxd commented on June 21, 2024 3

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/[email protected]
        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.

from prettier_action.

creyD avatar creyD commented on June 21, 2024 1

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?

from prettier_action.

creyD avatar creyD commented on June 21, 2024

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

from prettier_action.

Fatpandac avatar Fatpandac commented on June 21, 2024
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/[email protected]
        with:
          working_directory: 'site-vuepress/'
          same_commit: true
          prettier_options: --write .

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

from prettier_action.

ParthS007 avatar ParthS007 commented on June 21, 2024

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?

from prettier_action.

Fatpandac avatar Fatpandac commented on June 21, 2024

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

from prettier_action.

creyD avatar creyD commented on June 21, 2024

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

from prettier_action.

Fatpandac avatar Fatpandac commented on June 21, 2024

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.

from prettier_action.

creyD avatar creyD commented on June 21, 2024

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

from prettier_action.

ParthS007 avatar ParthS007 commented on June 21, 2024

@creyD Sure, Here's the workflow file:https://github.com/ParthS007/analysispreservation.cern.ch/blob/prettier/.github/workflows/ui-test.yml

and this is the latest workflow run: https://github.com/ParthS007/analysispreservation.cern.ch/runs/7575015767?check_suite_focus=true

Thanks for your time.

from prettier_action.

ParthS007 avatar ParthS007 commented on June 21, 2024

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

from prettier_action.

creyD avatar creyD commented on June 21, 2024

Can you try with working-status: ui/?

from prettier_action.

ParthS007 avatar ParthS007 commented on June 21, 2024

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?

from prettier_action.

totoprayogo1916 avatar totoprayogo1916 commented on June 21, 2024

still waiting for fix this issue 🙄

from prettier_action.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.