creyd / prettier_action Goto Github PK
View Code? Open in Web Editor NEWGitHub action for running prettier on your projects pull requests
License: MIT License
GitHub action for running prettier on your projects pull requests
License: MIT License
What exactly happened?
Failed check: https://github.com/FredyC/actions-test/pull/1/checks
Workflow file: https://github.com/FredyC/actions-test/blob/master/.github/workflows/prettier.yaml
What should've happened?
Prettified code should have been committed & pushed.
It's pretty much copy & paste of your example, but for some reason, it fails in this weird way.
It's missing the GITHUB_TOKEN
variable. According to the GitHub Docs this is automatically set in a repository. But somehow I get this error:
index.js 43ms
file2.js 8ms
file3.js 5ms
/entrypoint.sh: 7: /entrypoint.sh: GITHUB_TOKEN: parameter not set
Commiting and pushing changes...
##[error]Docker run failed with exit code 2
Am I missing something?
Is there an option to commit from the github actions[bot] user.
So not every commit will be from my account?
I will use this settings to commit. But don't know how to set it in you action.
git config user.name 'github-actions[bot]'
git config user.email 'github-actions[bot]@users.noreply.github.com'
What exactly happened?
Go to your fork, or create it from the main repository.
In the fork, create a new branch whose name does not exist in the main repository.
For example feature_534.
We finish work in our fork in the feature_534 branch, make a commit and make a pull request to the main repository - we get a prettier action error:
/usr/bin/git -c protocol.version=2 fetch --no-tags --prune --progress --no-recurse-submodules --depth=1 origin +refs/heads/feature_534*:refs/remotes/origin/feature_534* +refs/tags/feature_534*:refs/tags/feature_534*
The process '/usr/bin/git' - failed with exit code 1
We don't get an error if we use the branch name in our fork, which is in the main repository.
for example:
the main repository exists: feature_123.
In the fork we create feature_123 branch and do pull request in main repo - Prettier work done.
What should've happened?
The pretter action should work correctly, provided that the pull request is made from an external fork and a branch that does not exist in the main repository.
What exactly happened?
If prettier job successfully runs and adds commit with lint changes, other GitHub actions freeze and do not complete.
Steps to reproduce the behavior:
What should've happened?
Job should have successfully run and other GitHub actions should not have halted.
There might be a ; missing?
Lines 123 to 124 in b305fc8
Getting this error when running a CI job:
> Run creyD/[email protected]
/usr/bin/docker run --name ee6b...a3f0f --label 671ee6 --workdir /github/workspace --rm -e INPUT_COMMIT_MESSAGE -e INPUT_COMMIT_OPTIONS -e INPUT_FILE_PATTERN -e INPUT_PRETTIER_OPTIONS -e INPUT_BRANCH -e HOME -e GITHUB_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_ACTOR -e GITHUB_WORKFLOW -e GITHUB_HEAD_REF -e GITHUB_BASE_REF -e GITHUB_EVENT_NAME -e GITHUB_WORKSPACE -e GITHUB_ACTION -e GITHUB_EVENT_PATH -e RUNNER_OS -e RUNNER_TOOL_CACHE -e RUNNER_TEMP -e RUNNER_WORKSPACE -e ACTIONS_RUNTIME_URL -e ACTIONS_RUNTIME_TOKEN -e GITHUB_ACTIONS=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/queue/queue":"/github/workspace" 671ee6:b142...ead3 "Prettified Code!" "" "*" "" ""
Installing dependencies...
npm WARN saveError ENOENT: no such file or directory, open '/github/workspace/package.json'
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN enoent ENOENT: no such file or directory, open '/github/workspace/package.json'
npm WARN workspace No description
npm WARN workspace No repository field.
npm WARN workspace No README data
npm WARN workspace No license field.
up to date in 0.561s
found 0 vulnerabilities
/usr/local/bin/prettier -> /usr/local/lib/node_modules/prettier/bin-prettier.js
+ [email protected]
added 1 package from 1 contributor in 0.404s
Prettifing files...
[error] No parser and no file path given, couldn't infer a parser.
##[error]Docker run failed with exit code 2
In the config I just use the defaults:
steps:
- name: Prettier Action
uses: creyD/[email protected]
What exactly happened?
Steps to reproduce the behavior:
Warning: Unexpected input(s) 'prettier_plugins', valid inputs are ['entryPoint', 'args', 'commit_message', 'same_commit', 'commit_options', 'file_pattern', 'prettier_options', 'dry', 'prettier_version', 'only_changed']
name: Continuous Integration
# This action works with pull requests
on:
pull_request:
branches:
- main
jobs:
prettier:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
# Make sure the actual branch is checked out when running on pull requests
ref: ${{ github.head_ref }}
- name: Prettify code
uses: creyD/[email protected]
with:
# This part is also where you can pass other options, for example:
prettier_plugins: "@prettier/plugin-php"
prettier_options: --write **/*.{php,css,js,md}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
What should've happened?
No error. Would like to use the official prettier/prettier-php plugin.
Where did you encounter the problem?
Using Github Actions
Additional info
I understand that I should not encapsulate it in quotes, but I get another error below.
What would you like to change about the program?
As users can do in the shell, I would like to suggest an optional commit-description
option:
# The equivalent of:
git commit -m "$INPUT_COMMIT_MESSAGE" -m "$INPUT_COMMIT_DESCRIPTION"
Why do you think this is a cool idea?
It feels as it is being bottlenecked with what you can do, or a simple thing that should be implemented already. (no pressure, lol.)
I'm noticing that this prettier action is deleting my package-lock.json
file. (Note that runny prettier via npx doesn't do this)
My action.yml
name: Do Prettier
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Prettify code
uses: creyD/[email protected]
with:
prettier_options: --write .
my .prettierrc.json
{
"singleQuote": true,
"printWidth": 120
}
my .prettierignore
package-lock.json
*.html
*.min.js
Example commit where package-lock.json
gets removed
What would you like to change about the program?
2 of the forked projects have implemented a system where they just check the compliance and dont automatically apply it. Let's build this here.
If the action runs and changes the file I would rather it just update the original commit and force push rather then having a second commit.
Is something like this possible?
Thanks
Please consider adding import sorting to this plugin:
What exactly happened?
Steps to reproduce the behavior:
only_changed: true
fatal: pathspec 'deletedFile.js' did not match any files
What should've happened?
Deleted files should be excluded from prettification
This should be fixable by passing --diff-filter=d
to git diff
How can I ignore minified files? For example, I don't need to format *.min.js
and *.min.css
files.
Can I add multiple patterns? like this:
prettier_options: --write " **/*.js, **/*.!(min.js) " # Obviously not work
Or
prettier_options: --write **/*{!(.min.)css,!(.min.)js} # Not work too
We can do this by a simple .prettierignore
file but is there any way to ignore these files in command? I have no idea about that
Not sure if this is possible, but it would be nice to have only one step instead of these two:
- name: Prettier Action on PR
if: github.event_name == 'pull_request'
uses: creyD/[email protected]
with:
prettier_options: "--write {**/*,*}.{js,html,json,md,yml,css,scss}"
branch: ${{ github.head_ref }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Prettier Action on master
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
uses: creyD/[email protected]
with:
prettier_options: "--write {**/*,*}.{js,html,json,md,yml,css,scss}"
branch: master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Somehow it would be nice to not have to specify a branch. That is automatically would know if it's a PR or if it's just a push. If it's not available in your app than we could do something like this:
- name: Prettier Action
uses: creyD/[email protected]
with:
prettier_options: "--write {**/*,*}.{js,html,json,md,yml,css,scss}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
event_name: ${{ github.event_name }}
ref: ${{ github.ref }}
I have used below code in prettier.yml
name: Prettier
# This action works with pull requests and pushes
on:
pull_request:
push:
branches:
- master
jobs:
prettier:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
# Make sure the actual branch is checked out when running on pull requests
ref: ${{ github.head_ref }}
- name: Prettify code
uses: creyD/[email protected]
with:
# This part is also where you can pass other options, for example:
prettier_options: --write **/*.{css,html,js,md}
What would you like to change about the program?
The following are currently reported as 'errors'
[error] No parser could be inferred for file: frontend/Dockerfile
[error] No parser could be inferred for file: frontend/Makefile
[error] No parser could be inferred for file: frontend/yarn.lock
Suggestion
It is disconcerting that these flag up red and are reported as an error, when it is expected behaviour. Wondering if this is neccesary.
Great action, thanks anyway.
With this config:
- name: Prettier Action on PR
if: github.event_name == 'pull_request'
uses: creyD/[email protected]
with:
prettier_version: ^2.0.5
prettier_options: "--write {,!(static|.github)/**/}*.{js,html,json,md,yml,css,scss} static/js/**/*.js"
commit_message: "Run prettier via GitHub Action"
branch: ${{ github.head_ref }}
file_pattern: "."
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
I get this error:
file1.js 3ms
file2.js 42ms
Commiting and pushing changes...
[detached HEAD e646b5b] Run prettier via GitHub Action
Author: *** <***>
2 files changed, 108 insertions(+), 115 deletions(-)
fatal: You are not currently on a branch.
To push the history leading to the current (detached HEAD)
state now, use
git push origin HEAD:<name-of-remote-branch>
I solved the issue by running prettier on my machine before pushing, but it should work of course.
Can you see what I'm doing wrong here?
What exactly happened?
I used the action like this:
- name: prettier check
uses: creyD/[email protected]
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/[email protected]
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 🙏🏼
First of all, thanks for this project. 🚀
Problem
I'm using this action in a specific project for every Pull Request, but after it pushes the changes back to the PR, I expect this push to trigger another action. However, this seems to not work.
Why
This occurs because pushes using the default environment variable GITHUB_TOKEN
don't trigger a new workflow, even when configured. So as pointed in this discussion a possible solution is to create a personal token.
What I've tried
Following this idea, I've created a personal token, but as this action has no option to override the token yet, I tried to override the default env var GITHUB_TOKEN
.
env:
GITHUB_TOKEN: ${{ secrets.PERSONAL_GITHUB_TOKEN }}
However, as the docs says, if we attempt to override the value of one of the default environment variables, the assignment is ignored.
What would you like to change about the program?
I'd like to have an option to override the token used to push the changes.
It could be a new environment variable or a new parameter to the action.
Why do you think this is a cool idea?
With this change, we'll be able to trigger another workflow after the fixes have been pushed.
Idk if I'm missing something here, so please let me know.
If you think this feature makes sense, I can start working on the PR.
Using v3.1 on ubuntu-latest. The repo uses git LFS (though not for any files processed by prettier).
Fails to commit any changes with the error "This repository is configured for Git LFS but 'git-lfs' was not found on your path." It looks like git-lfs is not installed in the docker container, although it is on the outer GHA VM.
Probably the fix is just to add git-lfs
to the apk install line.
What exactly happened?
Failed run: https://github.com/FredyC/actions-test/runs/450564625
Workflow: https://github.com/FredyC/actions-test/blob/master/.github/workflows/prettier.yml
What should've happened?
Prettified code should have been pushed
Me again. I've decided to trigger this action on a push to master as it just behaves oddly with PRs. For some reason the INPUT_BRANCH
variable is empty.
What exactly happened?
Steps to reproduce the behavior:
- name: Run prettier on changed files
uses: creyD/[email protected]
with:
only_changed: True
dry: True
prettier_options: --config ./api/.prettierrc --ignore-path ./api/.prettierignore --check ./api/src/**
What should've happened?
It should have succeeded or failed with a clear error message.
How did it look?
Run PATH=$(cd $GITHUB_ACTION_PATH; npm bin):$PATH /home/github/action-runner/_work/_actions/creyD/prettier_action/v4.2/entrypoint.sh
PATH=$(cd $GITHUB_ACTION_PATH; npm bin):$PATH /home/github/action-runner/_work/_actions/creyD/prettier_action/v4.2/entrypoint.sh
shell: bash --noprofile --norc -e -o pipefail {0}
env:
INPUT_COMMIT_MESSAGE: Prettified Code!
INPUT_COMMIT_DESCRIPTION:
INPUT_SAME_COMMIT: false
INPUT_COMMIT_OPTIONS:
INPUT_FILE_PATTERN: *
INPUT_PRETTIER_OPTIONS: --config ./api/.prettierrc --ignore-path ./api/.prettierignore --check ./api/src/**
INPUT_DRY: true
INPUT_PRETTIER_VERSION: false
INPUT_ONLY_CHANGED: true
INPUT_PRETTIER_PLUGINS:
INPUT_WORKING_DIRECTORY: false
INPUT_GITHUB_TOKEN: ***
npm info it worked if it ends with ok
npm info using [email protected]
npm info using [email protected]
npm timing npm Completed in 48ms
npm info ok
/__w/_temp/cda1fe4d-556f-48b7-b555-744d14a51b4d.sh: line 1: /home/github/action-runner/_work/_actions/creyD/prettier_action/v4.2/entrypoint.sh: No such file or directory
Error: Process completed with exit code 127.
Where did you encounter the problem?
What would you like to change about the program?
I believe the documentation needs updating or improving as I tried to use the options below and always got the message that they were unknown options?
Providing some examples of how you're meant to use these options would help. Also showing an action that uses more than one option at a time would show how to chain them in case you have to do something different.
How are you meant to use the options like --dry and --only_changed?
[warn] Ignored unknown option --dry=true.
[warn] Ignored unknown option --only_changed=true.
[warn] Ignored unknown option --dry.
[warn] Ignored unknown option --only_changed.
Have tried both of these and always complained about unknown options.
Why do you think this is a cool idea?
The documentation needs to be more clear on the examples and how you're meant to use them. Also, I believe there is something that is required but is not mentioned as required.
Error: No parser and no file path given, couldn't infer a parser.
I get this error but no idea how to fix or what I'm missing.
Happy to update the readme file if I have the correct information!
Maybe a third example usage scenario can be included where you want to use Prettier as a CI pass/fail check rather than something that mangles commits (i.e. not using --write
).
Hello,
First let me just say thank you for being such an active maintainer. This project looks amazing.
I'm trying to set this action up in a repository that hosts a Salesforce project. I'm trying to install prettier-plugin-apex
, which is listed under the community plugins section of the official Prettier documentation.
However, the action doesn't seem to recognize this plugin as valid:
It looks like entrypoint.sh
is looking for the plugin string to contain @prettier/...
although plugins named prettier-plugin-...
are also valid according to Prettier's docs. Is this possible to do via this action or is it unable to install unofficial pugins?
Here is my full action for reference:
name: Prettify Code
on: [pull_request]
jobs:
prettier:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v2
with:
# Incremental diffs require fetch depth to be at 0 to grab the target branch
fetch-depth: "0"
- name: Prettify Modified Code
uses: creyD/[email protected]
with:
same_commit: true
only_changed: true
prettier_plugins: prettier-plugin-apex
prettier_options: --write --config .prettierrc {html, cls, trigger, apex, cmp, page, component}
There are many Prettier plugins that are not official (yet), like prettier-plugin-svelte. Unfortunately, trying to install it fails with:
Checking plugin: prettier-plugin-svelte
prettier-plugin-svelte does not seem to be a valid @prettier/plugin-x plugin. Exiting.
It would be great if other plugins could be installed as well :)
What would you like to change about the program?
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
I would like to be able to modify files without pushing
Why do you think this is a cool idea?
A clear and concise description of why your feature would improve the program.
for people who already have a commit and push process as part of their action, it is unnecessary to have to push twice.
What exactly happened?
Workflow with Prettier failing:
https://github.com/lambda-science/EHRoes/runs/4475783348?check_suite_focus=true
name: Format Check
on: [push, pull_request]
jobs:
format:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
# Make sure the actual branch is checked out when running on pull requests
ref: ${{ github.head_ref }}
# This is important to fetch the changes to the previous commit
fetch-depth: 0
- name: Check files using the black formatter
uses: rickstaa/action-black@v1
id: action_black
with:
black_args: ". --check"
- name: Prettify code
uses: creyD/[email protected]
with:
prettier_options: --check **/*.{css,js}
only_changed: True
What should've happened?
Should pass as there is not error.
Where did you encounter the problem?
Not sure why this is happening, but if I use v1.0 this does not happen:
Run creyD/[email protected]
with:
prettier_options: --write {**/*,*}.{js,html,json,md,yml,css,scss} !.github/workflows/**/* !static/**/*
commit_message: Run prettier via GitHub Action
branch: fix-twitter-hostname
file_pattern: .
dry: false
env:
GITHUB_TOKEN: ***
/usr/bin/docker run --name *** --label d00b33 --workdir /github/workspace --rm -e GITHUB_TOKEN -e INPUT_PRETTIER_OPTIONS -e INPUT_COMMIT_MESSAGE -e INPUT_BRANCH -e INPUT_FILE_PATTERN -e INPUT_COMMIT_OPTIONS -e INPUT_DRY -e INPUT_PRETTIER_VERSION -e HOME -e GITHUB_JOB -e GITHUB_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_RUN_ID -e GITHUB_RUN_NUMBER -e GITHUB_ACTOR -e GITHUB_WORKFLOW -e GITHUB_HEAD_REF -e GITHUB_BASE_REF -e GITHUB_EVENT_NAME -e GITHUB_WORKSPACE -e GITHUB_ACTION -e GITHUB_EVENT_PATH -e RUNNER_OS -e RUNNER_TOOL_CACHE -e RUNNER_TEMP -e RUNNER_WORKSPACE -e ACTIONS_RUNTIME_URL -e ACTIONS_RUNTIME_TOKEN -e ACTIONS_CACHE_URL -e GITHUB_ACTIONS=true -e CI=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/queue/queue":"/github/workspace" ***:***
/entrypoint.sh: line 40: : Permission denied
Installing prettier...
/usr/local/bin/prettier -> /usr/local/lib/node_modules/prettier/bin-prettier.js
+ [email protected]
added 1 package from 1 contributor in 0.546s
Prettifing files...
Files:
file1.js 50ms
file2.js 13ms
Nothing to commit. Exiting.
What would you like to change about the program?
A way to specify the prettier version number.
Why do you think this is a cool idea?
Some node versions don't support prettier v2.x.x. I'd like to use this action with prettier v1.19.1
Hi! Thank you for maintaining this action :-)
I'm unfortunaltely experiencing what I believe is unexpected behaviour when using the config below.
What exactly happened?
Fails even though all files in changed in the latest commit are formatted properly.
Steps to reproduce the behavior:
.prettierrc
jobs:
prettier:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
ref: ${{ github.head_ref }}
fetch-depth: 0
- name: Prettify code
uses: creyD/[email protected]
with:
dry: True
only_changed: True
prettier_options: --write **/*.{ts,js} --config ./.prettierrc
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
What should've happened?
I expected the job to pass. Other files in the repository are
not properly formatted, but I expected those to be ignored due to only_changed: True
.
I'm using v3.3.
I'm getting the following error when running with a standard prettier configuration
/home/runner/work/_actions/creyD/prettier_action/v4.1/entrypoint.sh: line 123: syntax error near unexpected token `then'
Error: Process completed with exit code 2.
Looks like the line was changed in commit dbdc557 any chance you can spot the error. It looks fine for me
Using the following .yml file:
name: Continuous Integration
on:
pull_request:
branches: [master]
jobs:
prettier:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
# Make sure the actual branch is checked out when running on pull requests
ref: ${{ github.head_ref }}
# This is important to fetch the changes to the previous commit
fetch-depth: 0
- name: Prettify code
uses: creyD/[email protected]
with:
prettier_version: '2.3.2'
# This part is also where you can pass other options, for example:
prettier_options: --write --config .prettierrc **/*.{js,jsx,less,ts,tsx}
only_changed: True
What exactly happened?
Steps to reproduce the behavior:
Due to an incompatibility between 2 prettier plugins (@trivago/prettier-plugin-sort-imports
and prettier-plugin-tailwindcss
), I'm using a workaround as described here. This requires me to use a prettier.config.js instead of a .prettierrc
with contents below:
const pluginSortImports = require('@trivago/prettier-plugin-sort-imports')
const pluginTailwindcss = require('prettier-plugin-tailwindcss')
/** @type {import("prettier").Parser} */
const myParser = {
...pluginSortImports.parsers.typescript,
parse: pluginTailwindcss.parsers.typescript.parse,
}
/** @type {import("prettier").Plugin} */
const myPlugin = {
parsers: {
typescript: myParser,
},
}
module.exports = {
plugins: [myPlugin],
endOfLine: 'auto',
singleQuote: true,
semi: false,
importOrder: [
'^(.*).css',
'<THIRD_PARTY_MODULES>',
'^@/components/(.*)$',
'^@/constants/(.*)$',
'^@/context/(.*)$',
'^@/lib/(.*)$',
'^[./]',
],
importOrderSeparation: true,
importOrderSortSpecifiers: true,
}
Here is my workflow config:
name: Lint
on:
pull_request:
push:
branches:
- main
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Prettify code
uses: creyD/[email protected]
with:
prettier_options: --check src
prettier_plugins: '@trivago/prettier-plugin-sort-imports prettier-plugin-tailwindcss'
The output complains that it can't find the @trivago/prettier-plugin-sort-imports
plugin:
2022-08-13T17:30:51.7371612Z ##[group]Run creyD/[email protected]
2022-08-13T17:30:51.7371947Z with:
2022-08-13T17:30:51.7372289Z prettier_options: --check src
2022-08-13T17:30:51.7372811Z prettier_plugins: @trivago/prettier-plugin-sort-imports prettier-plugin-tailwindcss
2022-08-13T17:30:51.7373340Z commit_message: Prettified Code!
2022-08-13T17:30:51.7373697Z same_commit: false
2022-08-13T17:30:51.7374088Z file_pattern: *
2022-08-13T17:30:51.7374348Z dry: false
2022-08-13T17:30:51.7374688Z prettier_version: false
2022-08-13T17:30:51.7375090Z working_directory: false
2022-08-13T17:30:51.7375379Z only_changed: false
2022-08-13T17:30:51.7376003Z github_token: ***
2022-08-13T17:30:51.7376332Z ##[endgroup]
2022-08-13T17:30:51.7740634Z ##[group]Run PATH=$(cd $GITHUB_ACTION_PATH; npm bin):$PATH /home/runner/work/_actions/creyD/prettier_action/v4.2/entrypoint.sh
2022-08-13T17:30:51.7741594Z �[36;1mPATH=$(cd $GITHUB_ACTION_PATH; npm bin):$PATH /home/runner/work/_actions/creyD/prettier_action/v4.2/entrypoint.sh�[0m
2022-08-13T17:30:51.7809219Z shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
2022-08-13T17:30:51.7809646Z env:
2022-08-13T17:30:51.7810121Z INPUT_COMMIT_MESSAGE: Prettified Code!
2022-08-13T17:30:51.7810518Z INPUT_COMMIT_DESCRIPTION:
2022-08-13T17:30:51.7810895Z INPUT_SAME_COMMIT: false
2022-08-13T17:30:51.7811284Z INPUT_COMMIT_OPTIONS:
2022-08-13T17:30:51.7811678Z INPUT_FILE_PATTERN: *
2022-08-13T17:30:51.7811997Z INPUT_PRETTIER_OPTIONS: --check src
2022-08-13T17:30:51.7812361Z INPUT_DRY: false
2022-08-13T17:30:51.7812735Z INPUT_PRETTIER_VERSION: false
2022-08-13T17:30:51.7813046Z INPUT_ONLY_CHANGED: false
2022-08-13T17:30:51.7813606Z INPUT_PRETTIER_PLUGINS: @trivago/prettier-plugin-sort-imports prettier-plugin-tailwindcss
2022-08-13T17:30:51.7814152Z INPUT_WORKING_DIRECTORY: false
2022-08-13T17:30:51.7814801Z INPUT_GITHUB_TOKEN: ***
2022-08-13T17:30:51.7815105Z ##[endgroup]
2022-08-13T17:30:52.5591973Z Installing prettier...
2022-08-13T17:30:53.5976437Z Checking plugin: @trivago/prettier-plugin-sort-imports
2022-08-13T17:30:53.5999005Z Checking plugin: prettier-plugin-tailwindcss
2022-08-13T17:30:57.4439033Z Prettifying files...
2022-08-13T17:30:57.4439804Z Files:
2022-08-13T17:30:58.5565091Z Checking formatting...
2022-08-13T17:30:58.6039900Z [error] Invalid configuration file `src/App.css`: Cannot find module '@trivago/prettier-plugin-sort-imports'
2022-08-13T17:30:58.6040619Z [error] Require stack:
2022-08-13T17:30:58.6041633Z [error] - /home/runner/work/react-wordle/react-wordle/prettier.config.js
2022-08-13T17:30:58.6044618Z [error] - /home/runner/work/_actions/creyD/prettier_action/v4.2/node_modules/prettier/third-party.js
2022-08-13T17:30:58.6045469Z [error] - /home/runner/work/_actions/creyD/prettier_action/v4.2/node_modules/prettier/index.js
2022-08-13T17:30:58.6046266Z [error] - /home/runner/work/_actions/creyD/prettier_action/v4.2/node_modules/prettier/cli.js
2022-08-13T17:30:58.6047097Z [error] - /home/runner/work/_actions/creyD/prettier_action/v4.2/node_modules/prettier/bin-prettier.js
2022-08-13T17:30:58.6141363Z Problem running prettier with --check src
2022-08-13T17:30:58.6171610Z ##[error]Process completed with exit code 1.
What should've happened?
I expect the plugin files to be found and executed properly.
Where did you encounter the problem?
https://github.com/cwackerfuss/react-wordle/runs/7820780587?check_suite_focus=true
What exactly happened?
Steps to reproduce the behavior:
prettier_options: --config ./.prettier.json --write **/*.js
What should've happened?
It should have used the file that's there but instead I got
Error: Invalid configuration file `events/error.js`: ENOENT: no such file or directory, open '/github/workspace/.prettier.json'
What exactly happened?
When performing a dry run, Prettier reports that all files match the code style, but this action reports unpretty files.
See: https://github.com/flarumite/simple-spoilers/runs/1731327132#step:4:19
What would you like to change about the program?
We have a monorepo with multiple npm packages, and run git actions on each one depending on whether or not files were changed in said package.
We have to specify the directory 3 times in the prettier options.
I think this could be simplified by being able to provide a working-directory
option that chooses where prettier gets CD'd to before running it in CI, then we wouldn't have to specify the config file either.
Why do you think this is a cool idea?
It would conslidate the commandline
from:
- name: Frontend Prettier
uses: creyD/[email protected]
with:
dry: true
prettier_options: "--config redacted/redacted/readacted/redacted/app/.prettierrc --ignore-path redacted/redacted/readacted/redacted/app/.prettierignore --write redacted/redacted/readacted/redacted/app/**/*.{json,md,scss,yaml,yml,js,jsx,tsx,ts}"
to:
- name: Frontend Prettier
uses: creyD/[email protected]
with:
dry: true
working-directory: "redacted/redacted/readacted/redacted/app/"
prettier_options: "--write **/*.{json,md,scss,yaml,yml,js,jsx,tsx,ts}"
# This is a basic workflow to help you get started with Actions
name: CI
# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the master branch
pull_request:
branches: [ staging ]
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
prettier:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
# Make sure the actual branch is checked out when running on pull requests
ref: ${{ github.head_ref }}
- name: Check code style
uses: creyD/[email protected]
with:
# This part is also where you can pass other options, for example:
dry: true
prettier_options: "-c src/**/*.{ts,vue}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
despite warnings being printed the job doesn't fail
I have this action config
name: Tests
on:
push:
branches: [master]
pull_request:
branches: [master]
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
ref: ${{ github.head_ref }}
- name: Prettier check
uses: creyD/[email protected]
with:
dry: true
prettier_options: --check **/*.ts
- name: Use deno
uses: denolib/setup-deno@v2
with:
deno-version: v1.x
- name: Run tests
run: deno test
I am running a check on typescript files.
Here is the .prettierrc
{
"semi": false,
"trailingComma": "all",
"singleQuote": true,
"printWidth": 70,
"arrowParens": "always",
"bracketSpacing": true
}
What exactly happened?
The action passed without fail, only showing warnings.
This is the output
Installing prettier...
/entrypoint.sh: line 40: : Permission denied
/usr/local/bin/prettier -> /usr/local/lib/node_modules/prettier/bin-prettier.js
+ [email protected]
added 1 package from 1 contributor in 0.765s
Prettifing files...
Files:
Checking formatting...
[warn] specs/when.test.ts
[warn] specs/whereAll.test.ts
[warn] specs/whereAny.test.ts
[warn] specs/zipWith.test.ts
[warn] Code style issues found in the above file(s). Forgot to run Prettier?
Problem running prettier with --check **/*.ts
Nothing to commit. Exiting.
What should've happened?
It should have failed the check and so the action.
Here is the link for the run
What exactly happened?
Prettier exited with code 1 resulting in a failed step even when it found all files formatted correctly.
What should've happened?
Prettier should exit with code 0 (no error)
How did it look?
If applicable, add screenshots to help explain your problem.
Where did you encounter the problem?
The repo is private and it was running on a fork but all permissions were given, even write permissions which wouldn't be required IMO.
What would you like to change about the program?
I would like to be able to use the repo prettier configuration, instead of putting it into the action configuration, if it is already possible, how can I do it?
Why do you think this is a cool idea?
Automate more the usage of this action.
@creyD The 4.0 pre-release version fails to recognize the options available in the latest versions of prettier/plugin-xml:
[warn] Ignored unknown option { xmlSelfClosingSpace: false }.
[warn] Ignored unknown option { xmlWhitespaceSensitivity: "strict" }.
Did you mean htmlWhitespaceSensitivity?
Reverting to v3.3 allows checks to pass.
Originally posted by @infotexture in #48 (comment)
I'd like to use this action on repos that include XML files, and format them with @prettier/plugin-xml
.
When I run the action as is, I get errors in the log:
[warn] Ignored unknown option { xmlWhitespaceSensitivity: "strict" }. Did you mean htmlWhitespaceSensitivity?
Error: No parser could be inferred for file: index.dita
This works fine when I run Prettier locally, as these options are provided by plugin-xml
.
💡 Add an option to that would allow users to specify the names of Prettier plugins to install.
I realize it would be possible to fork this action and hard-code additional plugins into the # PROGRAM
section where Prettier itself is installed, but it seems like something that others might want to do too, so it might be best to support this here with an option instead.
What exactly happened?
I want to use creyD/[email protected]
for checking if the json
and md
files are fine.
Locally it's working fine via homebrew
prettier --write **.md
But the action always returns the following error:
No node_modules/ folder.
No package-lock.json file.
I try to exclude both via .prettierignore, but it is not working.
What exactly happened?
I executed Prettier with workflow_dispatch
but it always failed while committing. It says that it can't commit since it's blocked.
Steps to reproduce the behavior:
What should've happened?
Prettier should've committed the changes flawlessly, like on the repo PRs.
How did it look?
This line:
https://github.com/im-coder-lg/docusaurus-blog/runs/4991433098?check_suite_focus=true#step:5:72
Where did you encounter the problem?
What would you like to change about the program?
I'm running this GHA on my react-querybuilder
repository. When I run Prettier on my local machines (yarn pretty-print
), it makes no changes. But when I push a commit to PR react-querybuilder/react-querybuilder#370 and it runs the Prettier action (which I assumed was running Prettier with the same options/config), I get the following output:
Run creyD/prettier_action@v4.[2](https://github.com/react-querybuilder/react-querybuilder/actions/runs/3056800420/jobs/4931305676#step:5:2)
with:
dry: true
prettier_options: --check *.js examples/**/* packages/*/src/** packages/*/dev/** website/*.js website/{docs,src,versioned_docs,versioned_sidebars}/**
prettier_version: 2.7.1
prettier_plugins: prettier-plugin-organize-imports
commit_message: Prettified Code!
same_commit: false
file_pattern: *
working_directory: false
only_changed: false
github_token: ***
env:
npm_config_cache: /home/runner/.npm
GITHUB_TOKEN: ***
Run PATH=$(cd $GITHUB_ACTION_PATH; npm bin):$PATH /home/runner/work/_actions/creyD/prettier_action/v4.2/entrypoint.sh
Installing prettier...
Checking plugin: prettier-plugin-organize-imports
Prettifying files...
Files:
Checking formatting...
[warn] website/src/components/HomepageFeatures.tsx
[warn] website/src/components/QueryBuilderEmbed.tsx
[warn] website/src/pages/index.tsx
[warn] Code style issues found in [3](https://github.com/react-querybuilder/react-querybuilder/actions/runs/3056800420/jobs/4931305676#step:5:3) files. Forgot to run Prettier?
Problem running prettier with --check *.js examples/**/* packages/*/src/** packages/*/dev/** website/*.js website/{docs,src,versioned_docs,versioned_sidebars}/**
Error: Process completed with exit code 1.
I can see that 3 files were changed, but I don't know what was changed. Is there a good way to run git diff
after a failed run of this GHA?
Why do you think this is a cool idea?
This may be more of a general GHA question (it's fairly easy to continue to the next step after error) than specific to this action, but it does seem like a useful feature. Maybe a show-changes: true
option or something.
Edit: I ended up just running Prettier directly, but I can't figure out what the difference was between that method and running this GHA.
What exactly happened?
Prettier Action checks all the codebase instead of the files which were changed only on the particular commit.
Steps to reproduce the behavior:
- name: Prettier Action
uses: creyD/[email protected]
with:
prettier_version: 1.19.1
prettier_options: --write **/*.{js,ts,tsx}
What should've happened?
Should be able to check only changed files during CI.
How did it look?
Check the whole codebase instead. Why?
Where did you encounter the problem?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.