Skip to content

[Merged by Bors] - fix(scripts/{lint_style,mk_all}): limit return value to 125#14272

Closed
grunweg wants to merge 3 commits intomasterfrom
MR-linters-exit-code
Closed

[Merged by Bors] - fix(scripts/{lint_style,mk_all}): limit return value to 125#14272
grunweg wants to merge 3 commits intomasterfrom
MR-linters-exit-code

Conversation

@grunweg
Copy link
Copy Markdown
Contributor

@grunweg grunweg commented Jun 30, 2024

so the executable's exit code can be used further in shell scripts, such as mathlib's CI.
See https://unix.stackexchange.com/a/418802 for background why a maximum of 125 is safest (on Linux).


Open in Gitpod

so the executable's exit code can be used further in shell scripts,
such as mathlib's CI.
See https://unix.stackexchange.com/a/418802 for background why a maximum
of 125 is safest (on Linux).
@github-actions
Copy link
Copy Markdown

github-actions bot commented Jun 30, 2024

PR summary 0342e28cef

Import changes

No significant changes to the import graph


Declarations diff

No declarations were harmed in the making of this PR! 🐙

You can run this locally as follows
## summary with just the declaration names:
./scripts/no_lost_declarations.sh short <optional_commit>

## more verbose report:
./scripts/no_lost_declarations.sh <optional_commit>

@grunweg
Copy link
Copy Markdown
Contributor Author

grunweg commented Jun 30, 2024

@adomani Since you raised this issue (thanks again for pointing me in this direction!), would you like to take a look?

Copy link
Copy Markdown
Contributor

@adomani adomani left a comment

Choose a reason for hiding this comment

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

This looks great, thanks!

Modulo the modulo,

maintainer merge

return numberErrorFiles
-- Make sure to return an exit code of at most 125, so this return value can be used further
-- in shell scripts.
return min numberErrorFiles 125
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
return min numberErrorFiles 125
return min (numberErrorFiles % 128) 125

I wonder whether this can be (ever so slightly) more meaningful:

  • reduce module 128=2^7 (since 126 and 127 are excluded for other reasons, but 128 appears to be the meaningful number);
  • truncate at 125 to avoid 126 and 127.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

But this would mishandle the case of exactly 128 errors, right? I just pushed a commit allowing 128 explicitly - it is somewhat longer. Do you think returning an exit code of 128 is an important feature? I am not convinced the longer code is worth it, but could be swayed otherwise.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Sorry, I got this wrong. We should special-case actual value 0 and everything else.

How about something like

if numberErrorFiles == 0 then return 0 else
  return max 1 (numberErrorFiles % 125)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This makes more sense! Why should we do modulo though, instead of saturating? I'd prefer 130 files to return a code of 125 over 2 (or 5), WDYT?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Sure, I do not have a preference. There might even be some value into specifying that exit code 1 means there were some errors and leave other error codes for potentially other meanings. Feel free to pick what you prefer: let's simply make sure that exit code 0 is if and only if numberErrorFiles = 0! 😄

Copy link
Copy Markdown
Contributor Author

@grunweg grunweg Jun 30, 2024

Choose a reason for hiding this comment

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

I'll let a maintainer weigh in on their preference: I have a weak preference for simply reverting the most recent commit (just pushed this); I'm happy to do either of the other options.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Saturation sounds better to me, but we're in the weeds here. :-)

@github-actions
Copy link
Copy Markdown

🚀 Pull request has been placed on the maintainer queue by adomani.

1 similar comment
@github-actions
Copy link
Copy Markdown

🚀 Pull request has been placed on the maintainer queue by adomani.

@github-actions github-actions bot added the maintainer-merge A reviewer has approved the changed; awaiting maintainer approval. label Jun 30, 2024
@github-actions
Copy link
Copy Markdown

🚀 Pull request has been placed on the maintainer queue by adomani.

@kim-em
Copy link
Copy Markdown
Contributor

kim-em commented Jun 30, 2024

bors d+

@mathlib-bors
Copy link
Copy Markdown
Contributor

mathlib-bors bot commented Jun 30, 2024

✌️ grunweg can now approve this pull request. To approve and merge a pull request, simply reply with bors r+. More detailed instructions are available here.

@github-actions github-actions bot added delegated This pull request has been delegated to the PR author (or occasionally another non-maintainer). and removed awaiting-review labels Jun 30, 2024
@grunweg
Copy link
Copy Markdown
Contributor Author

grunweg commented Jul 1, 2024

It seems that the current solution satisfies everybody - let's land this. Thanks for the reviews and the keen comments!
bors r+

mathlib-bors bot pushed a commit that referenced this pull request Jul 1, 2024
so the executable's exit code can be used further in shell scripts, such as mathlib's CI.
See https://unix.stackexchange.com/a/418802 for background why a maximum of 125 is safest (on Linux).
@mathlib-bors
Copy link
Copy Markdown
Contributor

mathlib-bors bot commented Jul 1, 2024

Build failed (retrying...):

mathlib-bors bot pushed a commit that referenced this pull request Jul 1, 2024
so the executable's exit code can be used further in shell scripts, such as mathlib's CI.
See https://unix.stackexchange.com/a/418802 for background why a maximum of 125 is safest (on Linux).
@mathlib-bors
Copy link
Copy Markdown
Contributor

mathlib-bors bot commented Jul 1, 2024

Pull request successfully merged into master.

Build succeeded:

@mathlib-bors mathlib-bors bot changed the title fix(scripts/{lint_style,mk_all}): limit return value to 125 [Merged by Bors] - fix(scripts/{lint_style,mk_all}): limit return value to 125 Jul 1, 2024
@mathlib-bors mathlib-bors bot closed this Jul 1, 2024
@mathlib-bors mathlib-bors bot deleted the MR-linters-exit-code branch July 1, 2024 11:37
dagurtomas pushed a commit that referenced this pull request Jul 2, 2024
so the executable's exit code can be used further in shell scripts, such as mathlib's CI.
See https://unix.stackexchange.com/a/418802 for background why a maximum of 125 is safest (on Linux).
@adomani adomani mentioned this pull request Aug 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

delegated This pull request has been delegated to the PR author (or occasionally another non-maintainer). maintainer-merge A reviewer has approved the changed; awaiting maintainer approval. t-linter Linter

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants