-
Notifications
You must be signed in to change notification settings - Fork 30
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
Fix: ktlint not found error #39
Conversation
@@ -6,16 +6,16 @@ export BASELINE= | |||
export CUSTOM_RULE_PATH= | |||
|
|||
if [ "$INPUT_KTLINT_VERSION" = "latest" ]; then | |||
curl -sSL https://api.github.com/repos/pinterest/ktlint/releases/latest --header "authorization: Bearer ${INPUT_GITHUB_TOKEN}" | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I see. In that case, why don't you implement cache for limited time?
KtLint updates once in a while (I believe they don't update every day).
But this action checks every time.
I think once a day is enough.
(But I don't know the external action can create cache)
This error occurs you for got the backslash before line-end (\n)
, thus the pipe does not work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Backslash is not needed if the line ends with pipe |
. Is it always failing for you when you use ScaCap/action-ktlint
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without backslash, always fail.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@wf9a5m75 coming back to this again, can you replicate this in some public repository so we can take a look?
Hello again. Sorry for late response. I worked on another projects. However, even the current version does not work on Actions log - name: Kotlin linter
# uses: wf9a5m75/action-ktlint@fix_ktlint_not_found # <-- work on commit
uses: ScaCap/action-ktlint@master # <-- does not work on commit
with:
android: true Actions log - name: Kotlin linter
uses: wf9a5m75/action-ktlint@fix_ktlint_not_found # <-- work on commit
# uses: ScaCap/action-ktlint@master # <-- does not work on commit
with:
android: true |
@wf9a5m75 could you try to adjust your workflow with - name: Kotlin linter
uses: wf9a5m75/action-ktlint@fix_ktlint_not_found # <-- work on commit
# uses: ScaCap/action-ktlint@master # <-- does not work on commit
with:
android: true
github_token: ${{ secrets.GITHUB_TOKEN }} Also see https://github.com/ScaCap/action-ktlint#github_token and https://docs.github.com/en/actions/security-guides/automatic-token-authentication#using-the-github_token-in-a-workflow |
I also found the same problem. It happens on Github Enterprise. curl -sSL https://api.github.com/repos/pinterest/ktlint/releases/latest --header "authorization: Bearer ${INPUT_GITHUB_TOKEN}" | If you are a Github enterprise user, the 'INPUT_GITHUB_TOKEN' token generated by Github Enterpris cannot be used on public Github. In this case, if you specify the ktlint version, ktlint is downloaded and the action is available. - name: Kotlin linter
uses: ScaCap/action-ktlint@master
with:
github_token: ${{ secrets.github_token }}
ktlint_version: 0.50.0 |
Thank you @zipizigi I don't have experience with GitHub Enterprise. The main purpose of adding this token is to avoid issues related to rate limiting set by GitHub. Without it, the IP might be blocked because of too many requests (the limit is very low there): https://docs.github.com/en/rest/overview/resources-in-the-rest-api?apiVersion=2022-11-28#rate-limits-for-requests-from-personal-accounts
I guess we could add a separate flag anyway to instruct the action to just drop the token when downloading but you might still run in issues if many workflows run at the same time. Let me know if you have a better solution for GitHub Enterprise (e.g. another token that is not blocked). |
It is most accurate to use the api for the download URL. Among the environment variables provided in Github Enterprise, there are no variables used for public Github authentication. Therefore, it is better to change the method of specifying the version as above, or Github Enterprise users need to specify a version when running the action. |
Thanks, I'll consider it and see if it's an easy change. |
Thanks to this answer: https://stackoverflow.com/a/54836319, I figured that
I'll raise a separate PR. |
Here we go: #45 |
problem
This PR effort