Skip to content

Adds depcheck to CI#1989

Merged
tynes merged 1 commit intoethereum-optimism:developfrom
noahlitvin:feat/depcheck
Jan 18, 2022
Merged

Adds depcheck to CI#1989
tynes merged 1 commit intoethereum-optimism:developfrom
noahlitvin:feat/depcheck

Conversation

@noahlitvin
Copy link
Contributor

Description
This PR adds depcheck to the .github/workflows/ts-packages.yml CI workflow to detect unused packages in the codebase.

Additional context
The issue raised by @smartcontracts suggests relying on the --ignore-path option to avoid errors being thrown from false positives (such as packages being relied on by Solidity smart contracts, undetected by depcheck). The ignore-path option specifies files to ignore, rather than packages. This won't help with censoring false positives for unused packages. (i.e. depcheck will see packages in package.json and not be able to recognize their use in Solidity files; ignoring the Solidity files won't change this.) Instead, I've used the ignores option specified in .depcheckrc files.

Metadata

@changeset-bot
Copy link

changeset-bot bot commented Jan 6, 2022

⚠️ No Changeset found

Latest commit: 2b74b98

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions github-actions bot added 2-reviewers M-ci Meta: ci related work labels Jan 6, 2022
@smartcontracts
Copy link
Contributor

This is great, thank you! Whew

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's reasonable to assume that all of the packages within packages will be npm/yarn based (we're putting Go packages in the go directory). In that case, is it possible to loop over each directory within a GitHub action instead of listing every directory explicitly? I haven't worked with GitHub actions enough to know offhand. That way this script would work automatically for new packages and we wouldn't have to remember to add the packages to this list of directories.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, yeah I'm not finding a clean way to do this. There's the option to use a matrix, but I don't think it's possible to feed in a dynamic value there.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'll leave myself a reminder to add this to a doc that explains what needs to be modified when adding a new package.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'll make a separate issue for reviewing these dependencies and making sure that they all belong in this ignore list.

package.json Outdated
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we could do npx depcheck instead of installing it as a dependency here (depcheck seems to come with a lot of dependencies of its own and we try to avoid adding dependencies where possible), but that might be a bit incongruous with what we do elsewhere. cc @tynes what do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree that depcheck adds a ton of dependencies that we don't really need, for example the yarn.lock now has vue related dependencies... we would like to keep the attack surface as low as possible when it comes to adding in extra deps. Doing npx depcheck works as it will install it at runtime, it runs in CI so installing it there is fine. That would let us not need to include it in the package.json dependencies

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good call. Just updated.

@codecov-commenter
Copy link

codecov-commenter commented Jan 7, 2022

Codecov Report

Merging #1989 (66431cf) into develop (a21cec6) will increase coverage by 0.16%.
The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #1989      +/-   ##
===========================================
+ Coverage    74.42%   74.58%   +0.16%     
===========================================
  Files           79       79              
  Lines         2545     2554       +9     
  Branches       397      401       +4     
===========================================
+ Hits          1894     1905      +11     
+ Misses         651      649       -2     
Flag Coverage Δ
batch-submitter 62.50% <ø> (ø)
contracts 90.48% <ø> (ø)
core-utils 57.50% <ø> (ø)
data-transport-layer 38.64% <ø> (ø)
message-relayer 70.86% <ø> (ø)
sdk 88.38% <ø> (+1.31%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
packages/sdk/src/cross-chain-provider.ts 82.67% <0.00%> (+3.01%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a21cec6...66431cf. Read the comment docs.

Copy link
Contributor

@smartcontracts smartcontracts left a comment

Choose a reason for hiding this comment

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

LGTM! Would you mind just rebasing this on top of the latest develop and combining all of your commits into a single commit? And please use the commit message format (feat: <brief feature description>). Then I'll merge!

Copy link
Contributor

Choose a reason for hiding this comment

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

I'll leave myself a reminder to add this to a doc that explains what needs to be modified when adding a new package.

@noahlitvin
Copy link
Contributor Author

Yep! Should be all set @smartcontracts

@smartcontracts
Copy link
Contributor

smartcontracts commented Jan 14, 2022

@noahlitvin sorry for the delay here! I'm going to run the tests one more time. Should be good to merge after that. If you'd like a contributor NFT send an ETH address to kelvin AT optimism DOT io 🙂.

@smartcontracts
Copy link
Contributor

@noahlitvin would you mind rebasing this on top of develop one more time? Can get it merged after that.

@tynes tynes merged commit 5c96d27 into ethereum-optimism:develop Jan 18, 2022
nitaliano pushed a commit that referenced this pull request May 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

M-ci Meta: ci related work

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add depcheck to CI

4 participants