Skip to content

Make check comply with Hackage requirements #8897

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

Merged
merged 9 commits into from
Apr 17, 2023

Conversation

ffaf1
Copy link
Collaborator

@ffaf1 ffaf1 commented Apr 4, 2023

tl;dr: cabal check will exit with 1 if and only if Hackage would reject the package.

As today, cabal check handles reports a “failure” in two distinct ways:

  • first one: with an informative Hackage would reject this package. string
  • second one: with exitcode 1. This one is not the same as Hackage would reject this package. It is a bit more strict: you could end up with exitcode 1 but no Hackage would reject this package. string.

What this patch does: make the two “failures” bijective. You will get exitcode 1 iif Hackage would reject this package.

Examples of checks which will not exit with 1 anymore:

  • description longer than synopsis;
  • -O1 usage;
  • missing maintainer.

Check last commit for all of them. If someone has a good reason for them to return 1, let me know (would CI get more annoying to set up? Third-party tools? Maybe it is better to return multiple failure exitcodes?).

Towards: #8880
Reviewers: review by commit to skip testsuite changes.
Related from an UX point of view: #8587


QA notes:

  • run cabal check in any project of yours
  • take note if you see Hackage would reject this package in the output.
  • take note of the exit code (printf '%d\n' $?).
  • exit code should be 1 if and only if you see the message Hackage would reject this package.

(a quick way to get Hackage would refuse this package string is to remove default-language: Haskell2010 from your .cabal)

Specific to this patch:

  • modify your package synopsis to be longer than your description
  • exit code should be 0 and you should not see any Hackage would reject this package. message

Please include the following checklist in your PR:

Tests: I have adjusted the testsuite appropriately.

ffaf1 added a commit to ffaf1/cabal that referenced this pull request Apr 4, 2023
ffaf1 added a commit to ffaf1/cabal that referenced this pull request Apr 4, 2023
@ffaf1 ffaf1 marked this pull request as ready for review April 4, 2023 16:43
@Kleidukos Kleidukos added the attention: needs-manual-qa PR is destined for manual QA label Apr 5, 2023
Copy link
Member

@andreasabel andreasabel left a comment

Choose a reason for hiding this comment

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

Great feature!

Copy link
Collaborator

@ulysses4ever ulysses4ever left a comment

Choose a reason for hiding this comment

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

Tremendous! Thanks!

ffaf1 added 7 commits April 15, 2023 16:59
There are two places in cabal codebase where `isDistError` is defined
(would Hackage refuse the package based on this error?), plus another
one in hackage-server (src/Distribution/Server/Packages/Unpack.hs).

This commit refactors the definitions into a singel `isHackageDistError`
(in Distribution.Client.Check) so everything is in sync. The function
is exported, for the benefit of third-party tools.
`cabal check` exits with 0 or 1. As now the `1` exit is slightly
stricter than “Hackage would reject this”, as even PackageDistSuspicious
errors will trigger a `1` exit.

This patch rectifies this and also specifies the behaviour in the
documentation. Notice the usage of “should” and “will”: we cannot
be sure Hackage will accept a package (e.g.: maybe there are name
clashes) but there are no type I errors: if it fails `cabal check`,
Hackage will refuse it.
All the modified tests returned 1 on exit, now they return 0.
(Andreas’ review) For `isHackageDistError`, so that in the future, when
constructors are added, the compiler will warn about missing them missing and
a thoughtful choice will be made.
(Artem’s review) Saves typing `isHackageDistError` four times more.
(Artem’s review) Make clear that errors will make `check` return 1.
@ffaf1 ffaf1 added squash+merge me Tell Mergify Bot to squash-merge and removed attention: needs-review labels Apr 15, 2023
@mergify mergify bot added the merge delay passed Applied (usually by Mergify) when PR approved and received no updates for 2 days label Apr 17, 2023
@mergify mergify bot merged commit b101f2d into haskell:master Apr 17, 2023
@ffaf1 ffaf1 deleted the hackage-errors branch April 17, 2023 19:46
@ffaf1 ffaf1 mentioned this pull request Jun 1, 2023
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
attention: needs-manual-qa PR is destined for manual QA cabal-install: cmd/check merge delay passed Applied (usually by Mergify) when PR approved and received no updates for 2 days squash+merge me Tell Mergify Bot to squash-merge
Projects
Status: Testing Approved
Development

Successfully merging this pull request may close these issues.

5 participants