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

ci: improve linting #580

Merged
merged 7 commits into from
Jul 27, 2024
Merged

Conversation

benoit-pierre
Copy link
Contributor

@benoit-pierre benoit-pierre commented Jul 22, 2024

Cf. #579 (comment).


This change is Reviewable

@benoit-pierre
Copy link
Contributor Author

Rewrote the whole thing, main commit:

  • fix cppcheck & clang-tidy configurations to avoid parsing, processing, and/or spurious errors.
  • parallelize all checks to speed up linting (which is much slower now that cppcheck & clang-tidy can actually do their jobs).
  • always lint all files (we care about), instead of trying to determine what changed: even if a source file, say crengine/src/lvtinydom.cpp, was not changed in a PR, some change to included headers may broke something that could be detected by one of the checks.
  • plus colors, groups and error annotations on Github Actions!

@benoit-pierre
Copy link
Contributor Author

How slow you ask? ~4 minutes without lvtinydom.cpp, 9 minutes for everything.

@benoit-pierre benoit-pierre force-pushed the pr/improve_ci_linting branch 4 times, most recently from 1263590 to ea22cc1 Compare July 23, 2024 03:45
@Frenzie
Copy link
Member

Frenzie commented Jul 23, 2024

That approach looks very nice. :-) (Talking about the code.)

Wrt to the output I'm not the biggest fan of hiding the stuff you actually want to see, though I suppose it's workable.

@benoit-pierre
Copy link
Contributor Author

Wrt to the output I'm not the biggest fan of hiding the stuff you actually want to see, though I suppose it's workable.

It does make it easier to zero-in on the problematic part, without being flooded with all the traces. And avoid the need GA horrible slow search mechanism. I agree that it would be better if there was a way to create already opened groups (for those containing errors).

Let's see if annotation created by problem matchers can help (but there's a stupidly low limit of 10 annotations max in the summary…).

@benoit-pierre
Copy link
Contributor Author

But the summary is showing more than 10… Maybe 10 errors and 10 warnings?

But if you look at the PR diff, there are some annotations there, now!

@benoit-pierre
Copy link
Contributor Author

There are definitively more than 10 warnings in the log, so yeah, 10 max annotations for each type in the summary.

@benoit-pierre
Copy link
Contributor Author

I was going to say adding problem matchers to the lint check on koreader & koreader-base would be nice too, but I remembered we're using CircleCI. :P

@Frenzie
Copy link
Member

Frenzie commented Jul 23, 2024

I suppose they could still be helpful in time, and in any case the collapsing (and slow search) aren't an issue when running the lint locally. What do you think @poire-z?

@benoit-pierre
Copy link
Contributor Author

No annotation for cr3gui/data/hyph/languages.json however, although technically possible with a multi-line matcher, I think.

@benoit-pierre benoit-pierre marked this pull request as ready for review July 23, 2024 17:28
@Frenzie
Copy link
Member

Frenzie commented Jul 23, 2024

PS typo in the first commit message: "may brake" (break)

@@ -35,7 +35,10 @@ jobs:
sudo dpkg -i *.deb

- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
Copy link
Member

Choose a reason for hiding this comment

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

It's not really clear to me why that dependabot thing automatically shows up in some repos and has to be explicitly set up in others.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To receive Dependabot alerts, you must first enable Dependabot alerts in this repository’s settings.

Copy link
Member

@Frenzie Frenzie Jul 23, 2024

Choose a reason for hiding this comment

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

I feel like back in 2022 it just showed up out of the blue without being (explicitly) enabled on for example repos with a requirements.txt (i.e., Python).

But anyway, my implicit point was provided that thing is set to open its trap at most once a week it could keep an eye on trivialities like the version of the checkout action.

@benoit-pierre
Copy link
Contributor Author

PS typo in the first commit message: "may brake" (break)

D'oh! /o\

@benoit-pierre
Copy link
Contributor Author

It does not look like clicking on the annotation link to the workflow log get you to the line that created the annotation (in the PR diff). And there's another 10 max limit there too. ;(

@Frenzie
Copy link
Member

Frenzie commented Jul 23, 2024

I have to say I'm somewhat surprised they'd even add that. But presumably it's different for paying customers.

@benoit-pierre benoit-pierre mentioned this pull request Jul 23, 2024
@poire-z
Copy link
Contributor

poire-z commented Jul 23, 2024

I suppose they could still be helpful in time, and in any case the collapsing (and slow search) aren't an issue when running the lint locally. What do you think @poire-z?

I probably won't install and run any lint stuff, so I'll be using Github/CircleCI CIs to check how I did :)
The output I see on #582 looks ok to me (a bit long height to scroll to look for the red stuff, but I'll be ok).

Does this mean that ALL our warnings are resolved ?! And any new one shouted by CI will be to solve ? Do all/most warnings get some -- crenginecheck: ignore kind of solution when we don't have a reaol one?

@benoit-pierre
Copy link
Contributor Author

Previously, the exit codes of clang-tidy / cppcheck were ignored, so the workflow would fail only on linting the hyphenation patterns or CSS files.

Annotations don't fail the workflow, a non-zero exit code by one of the linters does. So this warning in #582 for example would not fail the job.

With cppcheck, some warnings still result in a non-zero exit code, which is the case with the remaining failures. Those will have to be addressed.

It's similar zlib related code in all 3 instances (in crengine/src/pdbfmt.cpp and crengine/src/lvtinydom.cpp).

@poire-z
Copy link
Contributor

poire-z commented Jul 27, 2024

Good to go ? Or still working on it?

@benoit-pierre
Copy link
Contributor Author

This one is ready.

@poire-z
Copy link
Contributor

poire-z commented Jul 27, 2024

Or should we wait until the PR that fixes the warnings is ready ? Seeing the CI failure just below?

@benoit-pierre
Copy link
Contributor Author

I think it's better to merge this now, since that's the whole point: improve linting. And then fix the CI failures in subsequent PR(s).

@poire-z
Copy link
Contributor

poire-z commented Jul 27, 2024

You'll be ready soon with your other PR ? Otherwise, we'll keep getting failures, and it will be hard to notice that any other new PR introduce some new ones or bugs because of the noise.

@benoit-pierre
Copy link
Contributor Author

Let's wait a little then, I want to address your comments about asserts.

@benoit-pierre
Copy link
Contributor Author

I've added -DUSE_ZSTD=1 to the compilation flags, and have all the necessary fixes ready to pass the lint. Most of #579 is unrelated anyway, since we don't compile. I'll pull the lint related fixes to separate PR(s) (and the uncontroversial stuff too, to move it out of the way).

This can be merged.

@poire-z
Copy link
Contributor

poire-z commented Jul 27, 2024

A little git rebase with my date update & sleep trick to update the commits from Jul 23 to 28 svp ?
(Less bothering for ci stuff than for sources, but good to get the habit :))

- fix cppcheck & clang-tidy configurations to avoid parsing, processing,
  and/or spurious errors.
- parallelize all checks to speed up linting (which is much slower now
  that cppcheck & clang-tidy can actually do their jobs).
- always lint all files (we care about), instead of trying to determine
  what changed: even if a source file, say `crengine/src/lvtinydom.cpp`,
  was not changed in a PR, some change to included headers may break
  something that could be detected by one of the checks.
- plus colors, groups and error annotations on Github Actions!
@benoit-pierre
Copy link
Contributor Author

Done.

@poire-z poire-z merged commit cae5259 into koreader:master Jul 27, 2024
1 check failed
@benoit-pierre benoit-pierre deleted the pr/improve_ci_linting branch July 27, 2024 22:47
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