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

support all scala-cli dependency directives #3188

Merged

Conversation

bishabosha
Copy link
Contributor

I have made a list of dependency aliases from https://github.com/VirtusLab/scala-cli/blob/9e22d4a91ba8699ac2727d2ac3042d64abe951e1/modules/directives/src/main/scala/scala/build/preprocessing/directives/Dependency.scala#L33-L48

as far as I know these are not exposed programatically, but I guess they could be scraped using a source generator

fixes #3174

gitAlg
.findFilesContaining(buildRoot.repo, "//> using lib ")
ScalaCliAlg.directives
.flatTraverse(gitAlg.findFilesContaining(buildRoot.repo, _))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I guess there is probably a more efficient way to do this, e.g. using one command, but I didn't spend too long looking into this

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, git grep (which is used by findFilesContaining) can search for multiple patterns in one go by combining them via --or.

I just measured the wall clock time of containsBuild before and with this change for this repo and it went from 7 to 82 milliseconds. IMO this is acceptable since it is still dwarfed by actually running any build tool to extract dependencies.

@bishabosha
Copy link
Contributor Author

I updated the BuildToolDispatcherTest to account for the new searches

Copy link

codecov bot commented Nov 1, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (72c442c) 91.07% compared to head (1e69d10) 91.12%.
Report is 37 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3188      +/-   ##
==========================================
+ Coverage   91.07%   91.12%   +0.05%     
==========================================
  Files         163      163              
  Lines        3406     3404       -2     
  Branches      284      311      +27     
==========================================
  Hits         3102     3102              
+ Misses        304      302       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@bishabosha bishabosha changed the title update scala cli directives for dependencies support all scala-cli dependency directives Nov 24, 2023
@bishabosha
Copy link
Contributor Author

@fthomas is there something I should change about the approach? We'd like to enable scala-steward on scala/toolkit and this would help

"compileOnly.dep",
"compileOnly.deps",
"compileOnly.dependencies"
).map(alias => s"//> $alias ")
Copy link
Member

Choose a reason for hiding this comment

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

Isn't using missing here?

Suggested change
).map(alias => s"//> $alias ")
).map(alias => s"//> using $alias ")

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh good point!
Edit: added a new commit

@fthomas fthomas added the enhancement New feature or request label Nov 29, 2023
@fthomas fthomas added this to the 0.28.0 milestone Nov 29, 2023
@fthomas fthomas merged commit 1a9c3c1 into scala-steward-org:main Nov 29, 2023
6 checks passed
@bishabosha bishabosha deleted the support-more-deps-scala-cli branch November 30, 2023 07:12
Comment on lines +34 to +49
List(
"lib",
"libs",
"dep",
"deps",
"dependencies",
"test.dependency",
"test.dep",
"test.deps",
"test.dependencies",
"compileOnly.lib",
"compileOnly.libs",
"compileOnly.dep",
"compileOnly.deps",
"compileOnly.dependencies"
).map(alias => s"//> using $alias ")
Copy link
Contributor

Choose a reason for hiding this comment

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

@bishabosha do we need toolkit in this list as well? So we can get updates for directives like

//> using toolkit 0.2.1

Copy link
Contributor Author

Choose a reason for hiding this comment

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

From what I could see this would need a bigger change as the algorithm searches for explicit strings so unless you want to search for all possible toolkits this isn't very flexible

Copy link
Contributor

Choose a reason for hiding this comment

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

@bishabosha thanks for looking at it but I'm not sure I understand what you mean. Are you saying that adding toolkit here wouldn't match

//> using toolkit typelevel:0.1.19

why not?

Copy link
Member

Choose a reason for hiding this comment

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

Scala Steward can already update toolkits: https://github.com/scala-steward-org/test-repo-1/pull/82/files
So I think it makes sense to add //> using toolkit here so that projects, that have no other dependencies than a toolkit, are recognized as Scala CLI projects.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

scala-cli updates not getting picked up
3 participants