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

Add weeder (dead code elimination tool) to dev environment #4088

Merged
merged 24 commits into from
Jun 17, 2024
Merged

Conversation

fisx
Copy link
Contributor

@fisx fisx commented Jun 8, 2024

https://wearezeta.atlassian.net/browse/WPB-9667

i've run weeder from a PR locally with success (>1400 weeds, but many of them are false positives). now we only need to add that patch to our nix envs. (we should probably not run it on ci for now, until we have fine-tuned weeder.toml and eliminated all the legitimate weed.)

the purpose of this PR is:

  • add weeder to the dev env so people can run it and fine-tune it

the purpose of this PR is NOT:

Checklist

  • Add a new entry in an appropriate subdirectory of changelog.d
  • Read and follow the PR guidelines

@zebot zebot added the ok-to-test Approved for running tests in CI, overrides not-ok-to-test if both labels exist label Jun 8, 2024
@@ -70,4 +70,5 @@ hself: hsuper: {
types-common-journal = hlib.addBuildTool hsuper.types-common-journal protobuf;
wire-api = hlib.addBuildTool hsuper.wire-api mls-test-cli;
wire-message-proto-lens = hlib.addBuildTool hsuper.wire-message-proto-lens protobuf;
# weeder = hlib.addBuildTool hsuper.weeder;
Copy link
Contributor

Choose a reason for hiding this comment

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

dead code?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

not done yet! :)

@fisx
Copy link
Contributor Author

fisx commented Jun 12, 2024

This doesn't install the pinned version of weeder, but the one from hackage (2.7).

cabal.project Outdated Show resolved Hide resolved
akshaymankar and others added 6 commits June 13, 2024 09:30
Since we added weeder patch to the haskell-pins.nix, it doesn't exist in the
pkgs.haskelPackages package set.

N.B.: This still doesn't work because some dependency of weeder doesn't compile,
we should try to move it to pkgs.haskellPackages using overlay.nix and see if it works.
…kages."

This reverts commit 98dc98b.

(`package *` refers to all packages, but we only want local packages here.)
@fisx fisx marked this pull request as ready for review June 13, 2024 08:56
@fisx fisx requested a review from elland June 13, 2024 08:56
Makefile Outdated

.PHONY: weeder
weeder:
time weeder -N || echo -e '\n\n*** make sure you have added this to your cabal.project.local and make clean before building wire-server:\n\npackage *\n ghc-options: -fwrite-ide-info\n\n'
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
time weeder -N || echo -e '\n\n*** make sure you have added this to your cabal.project.local and make clean before building wire-server:\n\npackage *\n ghc-options: -fwrite-ide-info\n\n'
weeder -N || echo -e '\n\n*** make sure you have added this to your cabal.project.local and make clean before building wire-server:\n\npackage *\n ghc-options: -fwrite-ide-info\n\n'

Also it seems like we're gonna print this message on any failure, my guess is that it will definitely be confusing in future.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

why are you opposed to the time thingy? ok, fine, let's remove it.

nix/overlay.nix Outdated
Comment on lines 93 to 95
overrides = hself: hsuper: {
weeder = self.haskell.lib.dontCheck (hself.callPackage ./pkgs/weeder { });
};
Copy link
Member

Choose a reason for hiding this comment

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

We should write the reason we're using a fork and link to a PR if we have expectation that this is temporary.

weeder.toml Outdated
Comment on lines 5 to 6
# TODO: unused-types = true
# TODO: type-class-roots = false, and see how bad it gets
Copy link
Member

Choose a reason for hiding this comment

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

Forgotten todos?

weeder.toml Outdated
@@ -0,0 +1,6 @@
# weeder intro and further reading: https://github.com/ocharles/weeder?tab=readme-ov-file#weeder
roots = ["^Main.main$", "^Paths_.*\\..*"]
Copy link
Member

Choose a reason for hiding this comment

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

I just ran weeder and I think this is not complete.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the purpose of this PR is not to have a perfectly calibrated weeder.toml, but for devs to be able to run weeder and calibrate it.

i'll clarify in the PR description and title. 👍

@fisx fisx changed the title Introduce weeder for dead code elimination Add weeder (dead code elimination tool) to dev environment Jun 17, 2024
@fisx fisx requested a review from akshaymankar June 17, 2024 09:31
Makefile Show resolved Hide resolved
fisx added 4 commits June 17, 2024 11:58
Rationale: this is called by CI.  if the `pr` argument is implemented
correctly, it is impossible that files not covered here have been
changed and potentially un-ormulized.
@fisx fisx merged commit 5ef2be0 into develop Jun 17, 2024
8 checks passed
@fisx fisx deleted the fisx/weeder branch June 17, 2024 20:26
@echoes-hq echoes-hq bot added echoes: technical-roadmap/technical-debt More specific category, to highlight Technical Debt being tackled. echoes: throughput/ci-maintenance and removed echoes: technical-roadmap/technical-debt More specific category, to highlight Technical Debt being tackled. echoes: throughput/ci-maintenance labels Jun 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
echoes: technical-roadmap/technical-debt More specific category, to highlight Technical Debt being tackled. ok-to-test Approved for running tests in CI, overrides not-ok-to-test if both labels exist
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants