scacap / action-ktlint Goto Github PK
View Code? Open in Web Editor NEWRun Ktlint with reviewdog
License: Apache License 2.0
Run Ktlint with reviewdog
License: Apache License 2.0
workflow defined as follows:
# This is a basic workflow to help you get started with Actions
name: reviewdog
# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
# 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"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- name: ktlint
uses: ScaCap/action-ktlint@master
with:
github_token: ${{ secrets.github_token }}
reporter: github-pr-review # Change reporter
- name: Kotlin Linter
uses: vroy/gha-kotlin-linter@v2
About 2 months ago we updated to use ktlint version 1.1.1
Since last 2 weeks we've had a few cases with PRs having >300 files.
action-ktlint fails on these PRs with the following error excerpt.
2024-04-11T13:09:41.4432546Z ktlint version: 1.1.1
2024-04-11T13:13:25.4815816Z reviewdog: post failed for ktlint: fail to parse diff: GET https://api.github.com/repos/Org/my-repo/pulls/123: 406 Sorry, the diff exceeded the maximum number of files (300). Consider using 'List pull requests files' API or locally cloning the repository instead. [{Resource:PullRequest Field:diff Code:too_large Message:}]
Not sure if this is failing now due to v1.1.1 or some new Github API changes.
Hi!
I faced the problem that in output I have a lot of error messages but GitHub bot reports only one.
I'm expecting that if I have 50 ktlint errors it will see 50 PR comments.
GA workflow:
name: Code Review Workflow
on: [pull_request]
jobs:
ktlint:
name: Check Code Style
runs-on: [self-hosted, nonroot]
steps:
- uses: actions/checkout@v3
- uses: ScaCap/action-ktlint@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
reporter: github-pr-review
fail_on_error: true
filter_mode: file
Is it possible to exclude specific directories from linting?
ktlint itself does support this
Hi,
I would like to propose a third mechanism of report: A comment that will be added by the GitHub action including the report that is currently available via github-pr-check
.
This would make the report a bit more present than the additional GitHub Check, but would not be as intrusive/verbose as the github-pr-review
is.
Suggestion for naming would be github-pr-comment
I have an issue like that. I read from references, that it must modify some rules. can I change it?
app/src/main/java/id/kompas/app/view/base/BaseAuthActivity.kt:1:1: error: File must end with a newline (\n) (final-newline) app/src/main/java/id/kompas/app/view/base/BaseAuthActivity.kt:3:1: error: Imports must be ordered in lexicographic order without any empty lines in-between with "java", "javax", "kotlin" and aliases in the end (import-ordering) app/src/main/java/id/kompas/app/view/base/BaseAuthEmailActivity.kt:1:1: error: File must end with a newline (\n) (final-newline) app/src/main/java/id/kompas/app/view/base/BaseAuthEmailPhoneActivity.kt:1:1: error: File must end with a newline (\n) (final-newline) app/src/main/java/id/kompas/app/view/base/BaseAuthEmailPhoneActivity.kt:3:1: error: Imports must be ordered in lexicographic order without any empty lines in-between with "java", "javax", "kotlin" and aliases in the end (import-ordering) app/src/main/java/id/kompas/app/view/base/BaseAuthIntentActivity.kt:1:1: error: File must end with a newline (\n) (final-newline)
1.2.0
got released today, and CI is failing for us using latest
.
ktlint version: ktlint version 1.2.0
Parameter '--code-style' is no longer valid. The code style should be defined as '.editorconfig' property 'ktlint_code_style='
reviewdog: parse error: EOF
Seems like this has been deprecated for a while now, so perhaps time to remove it?
CI runs
ktlint
will return an error without executing.
Hey there, I was trying to add this to my open source project. I'd like the ktlint job to run for new PRs and if an issue is detected I want an error to be reported so the PR cannot be merged. However, the issue with this is it seems the ktlint job stops running once it encounters an issue. Is there a way to make it continue to lint after it has found an issue? If a PR had multiple lint issues it would be better to get a report of all the issues rather than fixing them one commit at a time.
Fyi I had fail_on_error = true
. If I set it to false then it seems to report all the ktlint issues.
Version 1.2.0 has just been released.
When using the action with that version of ktlint, it fails with:
ktlint version: ktlint version 1.2.0
Parameter '--code-style' is no longer valid. The code style should be defined as '.editorconfig' property 'ktlint_code_style='
reviewdog: EOF
Hi,
I can see that the action logs show the following:
kex-angebote-service/src/main/kotlin/de/europace/privatkredit/kex/angebote/TaskExecutorConfig.kt:23:1: error: Unexpected indentation (12) (should be 6) (indent)
When I look at the comment however the rule name is not shown:
Would be good if that was added into the comment
I have run reviewdog with fastlane on ubuntu-latest and it works perfect.
When I run it on self-hosted It gives me below error
This is my yml file
lintCheck:
name: Lint Check
runs-on: self-hosted
steps:
- name: checkout
uses: actions/checkout@v2
- name: Set up Ruby 2.6
uses: actions/setup-ruby@v1
with:
ruby-version: 2.6.x
- name: Install Dependencies
run: gem install bundler && bundle install
- name: Lint
run: bundle exec fastlane lint
- name: Run Android Lint
uses: dvdandroid/action-android-lint@master
with:
github_token: ${{ secrets.TOKEN_GITHUB }}
lint_xml_file: app/build/reports/lint-results.xml
Any Ideas what could be the reason?
it was working when i tested it with errors, it detects them and leaves comments
But even setting level: warning or level: info, it didn't fix it.
I have fail_on_error: true, but there were no errors to fail on? Logs don't provide much on the surface
Run ScaCap/[email protected]
with:
github_token: ***
reporter: github-pr-review
fail_on_error: true
level: info
relative: true
android: false
/usr/bin/docker run --name d8a[2](https://github.com/CenturyLinkCloud/as-storagefabric-middle-tier/runs/6425000286?check_suite_focus=true#step:4:2)1abc4f6004[3](https://github.com/CenturyLinkCloud/as-storagefabric-middle-tier/runs/6425000286?check_suite_focus=true#step:4:3)a3a3a88da828d018[4](https://github.com/CenturyLinkCloud/as-storagefabric-middle-tier/runs/6425000286?check_suite_focus=true#step:4:4)4_f1816f --label 084[5](https://github.com/CenturyLinkCloud/as-storagefabric-middle-tier/runs/6425000286?check_suite_focus=true#step:4:5)0d --workdir /github/workspace --rm -e INPUT_GITHUB_TOKEN -e INPUT_REPORTER -e INPUT_FAIL_ON_ERROR -e INPUT_LEVEL -e INPUT_RELATIVE -e INPUT_ANDROID -e HOME -e GITHUB_JOB -e GITHUB_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_REPOSITORY_OWNER -e GITHUB_RUN_ID -e GITHUB_RUN_NUMBER -e GITHUB_RETENTION_DAYS -e GITHUB_RUN_ATTEMPT -e GITHUB_ACTOR -e GITHUB_WORKFLOW -e GITHUB_HEAD_REF -e GITHUB_BASE_REF -e GITHUB_EVENT_NAME -e GITHUB_SERVER_URL -e GITHUB_API_URL -e GITHUB_GRAPHQL_URL -e GITHUB_REF_NAME -e GITHUB_REF_PROTECTED -e GITHUB_REF_TYPE -e GITHUB_WORKSPACE -e GITHUB_ACTION -e GITHUB_EVENT_PATH -e GITHUB_ACTION_REPOSITORY -e GITHUB_ACTION_REF -e GITHUB_PATH -e GITHUB_ENV -e GITHUB_STEP_SUMMARY -e RUNNER_OS -e RUNNER_ARCH -e RUNNER_NAME -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/_temp/_runner_file_commands":"/github/file_commands" -v "/home/runner/work/as-storagefabric-middle-tier/as-storagefabric-middle-tier":"/github/workspace" 08450d:8a21abc4f[6](https://github.com/CenturyLinkCloud/as-storagefabric-middle-tier/runs/6425000286?check_suite_focus=true#step:4:6)0043a3a3a[8](https://github.com/CenturyLinkCloud/as-storagefabric-middle-tier/runs/6425000286?check_suite_focus=true#step:4:8)8da828d01844 "***" "info" "github-pr-review" "true" "true" "false"
KtLint version: 0.45.2
Hi.
I have an issue like that:
Using the code in the README.md, I got the following error when running Actions.
Step 5/7 : RUN wget -O - -q https://raw.githubusercontent.com/reviewdog/reviewdog/master/install.sh| sh -s -- -b /usr/local/bin/ ${REVIEWDOG_VERSION}
---> Running in 3b77dd471421
reviewdog/reviewdog info checking GitHub for tag 'v0.14.1'
reviewdog/reviewdog info found version: <!DOCTYPE html> <html lang= for <!DOCTYPE html> <html lang=/Linux/x86_64
The command '/bin/ash -eo pipefail -c wget -O - -q https://raw.githubusercontent.com/reviewdog/reviewdog/master/install.sh| sh -s -- -b /usr/local/bin/ ${REVIEWDOG_VERSION}' returned a non-zero code: 3
Warning: Docker build failed with exit code 3, back off 5.742 seconds before retry.
...
Error: Docker build failed with exit code 3
I'm sorry that my writing may be a little strange because I'm not a native English speaker.
Is there a way to configure ktlint?
It should be possible to read files from repository inside Docker container of the action (https://github.community/t/how-can-i-access-the-current-repo-context-and-files-from-a-docker-container-action/17711).
It should allow to read .editorconfig file, used in the project from the root project folder or provided path to make sure that rules are the same for local ktlint runs and github actions lint checks.
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.