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

cabal check: Warn if changelogs are omitted from extra-doc-files #8657

Merged
merged 17 commits into from
Jan 23, 2023

Conversation

wismill
Copy link
Collaborator

@wismill wismill commented Jan 7, 2023

Fixes #3964.

Based on @sjakobi’s work.

@wismill wismill marked this pull request as ready for review January 8, 2023 11:36
@Mikolaj
Copy link
Member

Mikolaj commented Jan 9, 2023

It seems the OSX runner of CI locked up. I've taken the liberty of restarting failed jobs.

Copy link
Member

@Mikolaj Mikolaj left a comment

Choose a reason for hiding this comment

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

LGTM

Cabal/src/Distribution/PackageDescription/Check.hs Outdated Show resolved Hide resolved
ffaf1
ffaf1 previously requested changes Jan 9, 2023
Copy link
Collaborator

@ffaf1 ffaf1 left a comment

Choose a reason for hiding this comment

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

Thanks, this is a very useful check. As noted in my review, I think this should go in checkPackageFilesPreDistribution, because once the .tar.gz is made/uploaded, then it is too late.

Please tell me if what I say makes sense and whether I can help you in modifying the patch.

Cabal/src/Distribution/PackageDescription/Check.hs Outdated Show resolved Hide resolved
@Mikolaj
Copy link
Member

Mikolaj commented Jan 10, 2023

BTW, I've just found #8068.

@wismill
Copy link
Collaborator Author

wismill commented Jan 10, 2023

BTW, I've just found #8068.

Somehow I missed it 😅. If I understand it well, it is also based on sjakobi’s work but does not modify CheckPackageContentOps. Anyway, it does not solve what @ffaf1 pointed out here either.

There is also a comment of phadej to be addressed:

Warning: These warnings may cause trouble when distributing the package:

Is not correct.

There needs to be even weaker level.

I have packages where README is just for GitHub to not look stupid. All "README" is already in main module documentation or package description.

(ghc-options: -O2 having PackageDistSuspiciousWarn is acceptable, it's a fluke we ought to fix: If cabal-install is compiling with optimizations: False it would be great if packages weren't -O2, but if optimizations are enabled package authors could choose prefer -O2 over -O1 (or some other additional GHC flags). I.e. .cabal format isn't descriptive enough. Missing README isn't that level of trouble.)

@phadej Would it be ok to display the warning for readmes only if there is no long description of the package, or if it is too short1?

Footnotes

  1. Say, 70 characters or so, to avoid: See the readme on <https://github.com/haskell/cabal Github>.

@phadej
Copy link
Collaborator

phadej commented Jan 10, 2023

Say, 70 characters or so, to avoid: See the readme on <https://github.com/haskell/cabal Github>. leftwards_arrow_with_hook

I agree with Herbert on the fact that these stack introduced description:s can be just warned about as well. They serve no purpose. Write an abstract about your package. Put the rest of the info (if any) into readme.

That's really a problem with stack new, not with cabal check.

EDIT: Also stack template omitted readmes from extra-source-files, which made packages created with it look quite stupid.

@Bodigrim
Copy link
Collaborator

+100 to warn on missing changelogs. I can live without README, but changelogs are essential.

@wismill
Copy link
Collaborator Author

wismill commented Jan 11, 2023

I agree with Herbert on the fact that these stack introduced description:s can be just warned about as well. They serve no purpose. Write an abstract about your package. Put the rest of the info (if any) into readme.

@phadej I am not sure I follow you: I find description field quite useful. When I look for a package on Hackage:

  1. I get first a short description with synopsis in the list of results,
  2. then I get a good summary with description on the package’s page, without having to scroll down to the readme (if exisisting) nor open the doc pages.

Also, in order to understand the context better, could you link or summarize which discussion with Herbert you refer to?

@ffaf1
Copy link
Collaborator

ffaf1 commented Jan 11, 2023

(will repost here for better visibility)

@wismill what is your current idea about this PR? Warning about “file is present in the working tree but not in extra-doc-files” or “missing changelog and readme from extra-doc-file” (irrespective of files present in the working tree)?

If the latter, you can do it by a simple, pure check; the former would not be needed anymore, I think.

@wismill
Copy link
Collaborator Author

wismill commented Jan 11, 2023

@wismill what is your current idea about this PR? Warning about “file is present in the working tree but not in extra-doc-files” or “missing changelog and readme from extra-doc-file” (irrespective of files present in the working tree)?

  • changelog: latter approach. But it will probably break lots of tests.
  • readme: initially I thought about the former approach, but maybe refined (see my comment): readme may not be necessary if the package has already a good description, or if it is reserved for another use (for example: Github only). Now I am inclined to used the latter approach, if refined.

@ffaf1
Copy link
Collaborator

ffaf1 commented Jan 11, 2023

I see, thanks. Let’s see if more people chime in.

re: tests you can mass --accept them. Not the cleanest solution, but it would do.

@phadej
Copy link
Collaborator

phadej commented Jan 11, 2023

@wismill

description: See the readme on <https://github.com/haskell/cabal Github>.

is useless. Proper descriptions (i.e. short abstracts describing the package) are great.

@wismill
Copy link
Collaborator Author

wismill commented Jan 11, 2023

@phadej OK then, we agree these descriptions are useless. So if I understand well, these kind of descriptions are generated by stack when it creates a cabal file from a stack.yaml file. Is it correct?

Now, there are two questions to consider:

  1. Has the package a good-enough description field to avoid needing a readme? This is necessary to address your comment about some readmes existing only for repository browsing. This can be solved by requiring for example at least 10 words. This will avoid stack-generated descriptions.
  2. What is a good description field? This is more general and may require another issue to be addressed.

I am addressing 1) in a further commit.

@phadej
Copy link
Collaborator

phadej commented Jan 11, 2023

This can be solved by requiring for example at least 10 words. This will avoid stack-generated descriptions.

You are really touching a very old s**t pile. The check for descriptions to be longer than synopsis is good enough and not annoying people.

For the record, there are many people who turn e.g. cabal check off in the haskell-ci (or not use it in their CI at all), so making it more annoying (and non configurable) will make more people use cabal check less, which is a net loss.

@wismill
Copy link
Collaborator Author

wismill commented Jan 11, 2023

OK then: should we:

  1. Target specifically stack-generated description?
  2. Always ask for readme?
  3. Aks to include a readme only if the file already exists?
  4. Only check for changelog?
  5. New ideas?

I prefer 3 > 4 > 2 > 1

Check only globs, not the filesystem.
Copy link
Member

@Mikolaj Mikolaj left a comment

Choose a reason for hiding this comment

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

Brilliant. Please kindly set the label (I guess squash+merge_me) and this will give everybody 2 more days to re-review or otherwise comment.

@Mikolaj Mikolaj dismissed ffaf1’s stale review January 16, 2023 17:01

thank you for the review; I presume the changes have been applied, so I'm taking the liberty to unblock merging

Copy link
Collaborator

@phadej phadej left a comment

Choose a reason for hiding this comment

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

Add tests for cabal-version: 1.12 (i.e. which doesn't yet have extra-doc-files) and adjust the check warnings accordingly.

@Mikolaj
Copy link
Member

Mikolaj commented Jan 16, 2023

*could you please

@wismill wismill added the squash+merge me Tell Mergify Bot to squash-merge label Jan 17, 2023
@wismill
Copy link
Collaborator Author

wismill commented Jan 17, 2023

I adjusted the code for Cabal <= 1.12 and I added label quash+merge_me.

Copy link
Collaborator

@ffaf1 ffaf1 left a comment

Choose a reason for hiding this comment

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

Well done

@mergify mergify bot added the merge delay passed Applied (usually by Mergify) when PR approved and received no updates for 2 days label Jan 20, 2023
@Mikolaj
Copy link
Member

Mikolaj commented Jan 21, 2023

Some random net outage crashed CI, so I restarted affected tests.

@Mikolaj
Copy link
Member

Mikolaj commented Jan 23, 2023

@mergify refresh

@mergify
Copy link
Contributor

mergify bot commented Jan 23, 2023

refresh

✅ Pull request refreshed

@Mikolaj Mikolaj requested a review from joshleeb January 23, 2023 08:21
@mergify mergify bot merged commit 6fb48c7 into haskell:master Jan 23, 2023
@ulysses4ever
Copy link
Collaborator

@wismill since the changelog-only version is merged, could you, perhaps, rename the PR and the corresponding issue, to reflect the actual change?

@wismill wismill changed the title cabal check: Warn if readmes or changelogs are omitted from extra-doc-files cabal check: Warn if rea changelogs are omitted from extra-doc-files Jan 24, 2023
@wismill wismill changed the title cabal check: Warn if rea changelogs are omitted from extra-doc-files cabal check: Warn if changelogs are omitted from extra-doc-files Jan 24, 2023
@ffaf1 ffaf1 mentioned this pull request Feb 6, 2023
4 tasks
@andreasabel
Copy link
Member

andreasabel commented Feb 9, 2023

@wismill: Thanks for this awesome new feature!

I encountered this:

Warning: Please consider including the file './CHANGELOG.md~' in the
'extra-doc-files' section of the .cabal file if it contains useful information
for users of the package.

I think the file filter should exclude common backup file extensions.

Ah, yes, and we should test for this. A single test containing lots of variants for files that should not be considered would suffice here.

CC: @ffaf1

isDesirableExtraDocFile :: [FilePath] -> FilePath -> Bool
isDesirableExtraDocFile paths path = map toLower basename `elem` paths
where
(basename, _ext) = splitExtension path
Copy link
Member

@andreasabel andreasabel Feb 9, 2023

Choose a reason for hiding this comment

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

Extensions like .bak, tmp, .*~, files ending in ~ etc. should be ruled out here.

Ideally, you would rule out anything in .gitignore as well.

Copy link
Collaborator

Choose a reason for hiding this comment

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

.swp, .swn, swo,...

Almost better to whitelist extensions (no extension, txt, md, rst).

Copy link
Member

Choose a reason for hiding this comment

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

also .markdown

Copy link
Collaborator

Choose a reason for hiding this comment

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

“no extension“ should be whitelisted too, NEWS is common in GNU programs.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

See #8747

@Mikolaj
Copy link
Member

Mikolaj commented Feb 13, 2023

Am I correct this needs a backport to 3.10?

@ulysses4ever
Copy link
Collaborator

I'd vote yes: I can't imagine this could backfire. (Although, my imagination is limited!)

@Mikolaj
Copy link
Member

Mikolaj commented Feb 13, 2023

If I understand this right, our choice is to revert the original change or apply the fix. Keeping the change that we know has problems doesn't make sense to me.

Actually, good that I asked, because I misplaced the comment. I meant to ask this about #8747. Unless I'm mixing everything up and the original change is not on branch 3.10?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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
None yet
Development

Successfully merging this pull request may close these issues.

cabal check should warn when readme or changelog exist but aren't included in extra-source-files
8 participants