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

Enhance Linter Github Actions Reporting #4864

Merged
merged 1 commit into from
Jan 7, 2022

Conversation

ariskotsomitopoulos
Copy link
Contributor

@ariskotsomitopoulos ariskotsomitopoulos commented Jan 5, 2022

Improve Github Actions Linter reports:

  • Add ktlint Artifact report

Screenshot 2022-01-05 at 19 37 37

  • kotlint reports will be also added as comment in the PR
    • It will print exactly the lines that have problem
    • It will trim the output so the developer will be able to immediately find the class with the error
    • Support for all the different modules along with tests
    • The same comment will be reused
    Screenshot 2022-01-05 at 22 41 08 Screenshot 2022-01-05 at 22 56 08
  • It is also able to identify the success and print the result appropriately
    Screenshot 2022-01-05 at 22 58 50

@github-actions
Copy link

github-actions bot commented Jan 5, 2022

Unit Test Results

  66 files  ±0    66 suites  ±0   1m 22s ⏱️ +31s
135 tests ±0  135 ✔️ ±0  0 💤 ±0  0 ±0 
418 runs  ±0  418 ✔️ ±0  0 💤 ±0  0 ±0 

Results for commit 33a4eac. ± Comparison against base commit 1490854.

♻️ This comment has been updated with latest results.

@element-hq element-hq deleted a comment from github-actions bot Jan 5, 2022
@element-hq element-hq deleted a comment from github-actions bot Jan 5, 2022
@element-hq element-hq deleted a comment from github-actions bot Jan 5, 2022
@element-hq element-hq deleted a comment from github-actions bot Jan 5, 2022
@element-hq element-hq deleted a comment from github-actions bot Jan 5, 2022
@element-hq element-hq deleted a comment from github-actions bot Jan 5, 2022
@github-actions
Copy link

github-actions bot commented Jan 5, 2022

Ktlint Results

👍 ✅ 👍

@ariskotsomitopoulos ariskotsomitopoulos force-pushed the feature/aris/linter_github_actions_improvement branch 3 times, most recently from b39e9b0 to 6b85110 Compare January 5, 2022 20:55
Copy link
Member

@bmarty bmarty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work, thanks! A few little remarks

else
body="\`👎 ❌ 👎 ${results}\`"
fi
body="${body//'%'/'%25'}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would apply all the treatment you are doing on the else block above and on the results var, before affecting the value prefixed with emojis to body.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I agree, it's really sensitive, if it can support multiple commands inside the else block I will change it

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, thanks

if [ -z "$results" ]; then
body="👍 ✅ 👍"
else
body="\`👎 ❌ 👎 ${results}\`"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small remark, the Emojis could be outside of the "`", no?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure it would, however if you observe commenting with that lib do not support \n so I had to manually create the new lines by replacing via bash the aggregated results with <br>. But then I realised that code blocks do not support
new lines! 😵‍💫 So to support newlines along with code blocks I added multiple code blocks around <br>. So there should be an init left_code_block in order to work.

It was the tricky to support newlines with codeblocks without the lib supporting it

The best I can do is (that seems pretty nice):
👎 ❌ 👎Failed

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, thanks for the explaination.
Maybe do not add Emoji there but use the reactions, different depending on the result?
Anyway this is fine like this.

comment-author: 'github-actions[bot]'
body-includes: Ktlint Results
- name: Publish ktlint results to PR
if: always()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OOI, is there a necessity to add this line?

Copy link
Contributor Author

@ariskotsomitopoulos ariskotsomitopoulos Jan 5, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it is an important line, while when ktlint fails thats when we should publish the results, also that was the fix for the artifacts. The problem was that the jobs was killed so nothing happened after that

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, understood, thanks!


# Lint for main module and all the other modules
${{ steps.get-comment-body.outputs.body }}
reactions: rocket
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not see the added value to automatically add a reaction to the generated comment (except that it is nice to know that it is possible to do so)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

haha yes I just wanted to test it, I will remove it

@ariskotsomitopoulos ariskotsomitopoulos marked this pull request as ready for review January 5, 2022 21:49
- Publish results on PR via commenting
- Support for all modules along with tests
- Code format & emoticons
@ariskotsomitopoulos ariskotsomitopoulos force-pushed the feature/aris/linter_github_actions_improvement branch from aad7dff to 33a4eac Compare January 5, 2022 22:27
@ouchadam
Copy link
Contributor

ouchadam commented Jan 7, 2022

awesome change! 💯

would love to see a v2 that has url clickthroughs for the failing lines 🤩

@@ -74,7 +118,6 @@ jobs:
run: ./gradlew clean lint${{ matrix.target }}Release --stacktrace
- name: Upload ${{ matrix.target }} linting report
uses: actions/upload-artifact@v2
if: always()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a last remark, will the lint report be uplodoad if the command fails (so if there are lint issue) if you remove this line?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

@ariskotsomitopoulos ariskotsomitopoulos Jan 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Edit:
Here is a different case than before because the way command ./gradlew clean lint run needs to be succeed in order to generate the report! So there is no need to upload an artifact without the report. In comparison to ktlint that the report is generated when the build fails. Is it clear now?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, thanks!

@bmarty bmarty merged commit bcebfff into develop Jan 7, 2022
@bmarty bmarty deleted the feature/aris/linter_github_actions_improvement branch January 7, 2022 13:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants