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

Lintcheck: Rework and limit diff output for GH's CI #13139

Merged
merged 6 commits into from
Jul 25, 2024

Conversation

xFrednet
Copy link
Member

@xFrednet xFrednet commented Jul 21, 2024

Background

While working on #13136 I found an amazing limitation of GH's CI. The summary can at most have be 1MB of text. Here is the warning message:

$GITHUB_STEP_SUMMARY upload aborted, supports content up to a size of 1024k, got 46731k. For more information see: https://docs.github.com/actions/using-workflows/workflow-commands-for-github-actions#adding-a-markdown-summary

The PR produced a casual 61808 changes. Guess that's why those lints are not warn-by-default :P.

Changes:

This PR limits the lintcheck diff output in two ways.

  1. The diff is limited to 200 messages per lint per section. Hidden messages are indicated by a message at the end of the section.
  2. The output is first written to a file and only the first 1MB is written to >> $GITHUB_STEP_SUMMARY. The entire file is also written to the normal CI log. This helps for cases where several lints change and the total size exceeds the 1MB limit.

An example of these changes can be seen here: https://github.com/xFrednet/rust-clippy/actions/runs/10028799118?pr=4


changelog: none

r? @Alexendoo

Sorry for bombarding you with so many PR's lately 😅 Feel free to pass some of you reviews to me.

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Jul 21, 2024
@xFrednet xFrednet force-pushed the lintcheck-limit-summery-output branch from 1bd2b79 to 83a0f4a Compare July 21, 2024 13:58
lintcheck/src/json.rs Outdated Show resolved Hide resolved
lintcheck/src/json.rs Outdated Show resolved Hide resolved
lintcheck/src/json.rs Outdated Show resolved Hide resolved
@flip1995
Copy link
Member

flip1995 commented Jul 22, 2024

2. The entire file is also written to the normal CI log. This helps for cases where several lints change and the total size exceeds the 1MB limit.

Could you upload the entire file as an artifact, like in the head and base steps? This should make it easier to just download the file from the action summary page, if someone wants to do triage.

@xFrednet
Copy link
Member Author

Could you upload the entire file as an artifact.

I assume you mean the file markdown diff output? Yeah, I can do that, should be easy. It just means that the truncation has to be controlled by a CLI flag, but that's easy enough

@xFrednet xFrednet force-pushed the lintcheck-limit-summery-output branch from 83a0f4a to b67908a Compare July 22, 2024 16:01
@xFrednet xFrednet force-pushed the lintcheck-limit-summery-output branch from b67908a to 1f879fc Compare July 22, 2024 16:02
@xFrednet
Copy link
Member Author

xFrednet commented Jul 22, 2024

My repo is currently running these changes with an additional dummy commit that generates a lot of warnings. Here is the link:

https://github.com/xFrednet/rust-clippy/actions/runs/10044508861

@xFrednet
Copy link
Member Author

This is what the summary table looks like:

image

Do we want to also linkify the numbers or add a 🔗 emoji after them to jump directly to the relevant section? I considered this, but worry that this will become too noisy. The lints still have links to their sub sections

@xFrednet xFrednet force-pushed the lintcheck-limit-summery-output branch from 2f9cfa9 to 23b231a Compare July 22, 2024 16:19
@xFrednet
Copy link
Member Author

Example output with these changes: https://github.com/xFrednet/rust-clippy/actions/runs/10044508861

@xFrednet xFrednet mentioned this pull request Jul 23, 2024
Comment on lines 165 to 166
// The additional anchor is added for non GH viewers that don't prefix ID's
println!(r#"## `{name}` <a id="user-content-{html_id}"/>"#);
Copy link
Member

Choose a reason for hiding this comment

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

No longer additional by the looks of it

Doesn't actually change the DOM since it gets auto closed by the </h2> but a isn't a void element so this should be <a></a>, same for below

Copy link
Member Author

Choose a reason for hiding this comment

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

image

GH seems to accept it for me, but it's probably better to use </a> instead

Copy link
Member

Choose a reason for hiding this comment

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

Yeah it should result in the same DOM since HTML self closes elements - <h2><a /></h2> is the same as <h2><a></h2> because HTML treats /> and > identically

The open a tag is then auto closed when it hits the </h2> so it becomes <h2><a></a></h2> - but this seems like the kind of area where differing behaviour in markdown previewers would crop up

Copy link
Member Author

Choose a reason for hiding this comment

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

Makes sense, it's updated now :D

Comment on lines 68 to 80
for change in itertools::merge_join_by(old_warnings, new_warnings, |old, new| old.key().cmp(&new.key())) {
match change {
EitherOrBoth::Both(old, new) => {
if old.rendered != new.rendered {
changed.push((old, new));
}
},
EitherOrBoth::Left(old) => removed.push(old),
EitherOrBoth::Right(new) => added.push(new),
}
}

let lint_warnings = group_by_lint(added, removed, changed);
Copy link
Member

Choose a reason for hiding this comment

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

If we put the lint name first in the key function we could create lint_warnings directly via something like

for (name, chunk) in &merge_join_by(...).chunk_by(...) {}
// or however it needs to work for `ChunkBy`'s lifetime

rather than resorting/grouping it

Copy link
Member Author

@xFrednet xFrednet Jul 24, 2024

Choose a reason for hiding this comment

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

I like the idea. I currently can't figure out how to get chunk_by working on MergeBy. You suggestion produces the following error:

error[E0599]: no method named `chunk_by` found for struct `MergeBy` in the current scope
  --> src/json.rs:69:120
   |
69 |     for (_name, change) in &itertools::merge_join_by(old_warnings, new_warnings, |old, new| old.key().cmp(&new.key())).chunk_by(|change| change.into_left().lint.as_str()) {
   |                                                                                                                        ^^^^^^^^
   |
help: there is a method `chunks` with a similar name
   |
69 |     for (_name, change) in &itertools::merge_join_by(old_warnings, new_warnings, |old, new| old.key().cmp(&new.key())).chunks(|change| change.into_left().lint.as_str()) {
   |            

Do you know how to solve it? I could collect it first into a vec, but then it seems better to manually chunk them.

Copy link
Member

Choose a reason for hiding this comment

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

Ah it was renamed in itertools 0.13 and we're on 0.12

@xFrednet xFrednet force-pushed the lintcheck-limit-summery-output branch from f29ea77 to bdf3e58 Compare July 24, 2024 20:45
@xFrednet xFrednet changed the title Lintcheck: Limit diff output for GH's CI Lintcheck: Rework and limit diff output for GH's CI Jul 24, 2024
@Alexendoo
Copy link
Member

Nice, thanks!

@bors r+

@bors
Copy link
Contributor

bors commented Jul 25, 2024

📌 Commit bdf3e58 has been approved by Alexendoo

It is now in the queue for this repository.

@bors
Copy link
Contributor

bors commented Jul 25, 2024

⌛ Testing commit bdf3e58 with merge be82340...

@bors
Copy link
Contributor

bors commented Jul 25, 2024

☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test
Approved by: Alexendoo
Pushing be82340 to master...

@bors bors merged commit be82340 into rust-lang:master Jul 25, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants