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 mill module #9

Merged
merged 8 commits into from
Jun 6, 2022
Merged

Add mill module #9

merged 8 commits into from
Jun 6, 2022

Conversation

Baccata
Copy link
Contributor

@Baccata Baccata commented Jun 5, 2022

Adds a mill module

  • factors most of the logic away from the SBT module, in a way that makes SBT and mill usage consistent
  • adds a mill module
  • adds unit tests for the mill module
  • renames maven org to com.indoorvivants.vcpkg (to make it easier for Anton to get relevant stats from sonatype)

Addresses #5

build.sbt Outdated
@@ -44,14 +45,23 @@ lazy val `sbt-plugin` = projectMatrix
.dependsOn(core)
.enablePlugins(ScriptedPlugin)
.settings(
name := """sbt-vcpkg""",

Choose a reason for hiding this comment

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

sbt plugins are usually named sbt-xyz. Why change it?

Copy link
Contributor

Choose a reason for hiding this comment

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

Note that this is still a draft PR and is constantly changing :)

Copy link
Contributor

Choose a reason for hiding this comment

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

In the end I think it will be sbt-vcpkg and mill-vcpkg.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It was to keep consistency with the vcpkg-core module, but I'll abide with whatever @keynmol says

Copy link
Contributor

Choose a reason for hiding this comment

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

Let's go with

  • core
  • sbt-vcpkg
  • mill-vcpkg

It seems to follow what ScalablyTyped is like and I want to mimic it.
Also, can be changed before the release, no biggie.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no problem, I'll amend it here :)

* Mill's native plugin constructs, which can then delegate to these functions,
* keeping the build-tool-specific code down to a minimum.
*/
trait VcpkgPluginImpl {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@keynmol I've factored most of the logic that I had to repeat in this build-tool-agnostic trait.

This reduces the size of both sbt and mill plugins to ~65

Copy link
Contributor

Choose a reason for hiding this comment

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

That looks great, thanks

import mill.api.{DummyInputStream, Result}

// Borrowed from the mill codebase : https://github.com/Baccata/mill/blob/master/main/test/src/util/TestEvaluator.scala
object TestEvaluator {
Copy link
Contributor Author

@Baccata Baccata Jun 6, 2022

Choose a reason for hiding this comment

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

I've resorted to copying this test evaluator from mill's codebase, as it allows to tests plugins in unit tests (from SBT, or any build tool), which makes it drastically easier to set up than having SBT shell-out to a mill process in order to run integration tests.

I'll probably spend some to try and make this available from mill as an opt-in artifact, though not sure how easy it'll be to decouple it from upickle.

Copy link
Contributor

Choose a reason for hiding this comment

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

Alternatively, is it possible to just run mill's integration tests as a separate stage?
We no longer have sbt-gha so if it's easier, you can just add a mill stage to the workflow?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We no longer have sbt-gha so if it's easier, you can just add a mill stage to the workflow?

The problem is really that you'd have to add an explicit call to publishLocal from SBT before being able to run the tests from mill, which is like, totally fair enough in CI, but utterly shite in terms of developer experience on local machines

Copy link
Contributor

Choose a reason for hiding this comment

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

Alright.

Not fantastic that a copypasta has to live here, so I sure hope at some point it can be made into a dependency.
At this point it's more important to have a mill plugin + tests, so let's keep it this way.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

so I sure hope at some point it can be made into a dependency.

I hope so too, I have a number of usecases for this

import mill.util.TestEvaluator
import mill.util.TestUtil

object VcpkgModuleSpec extends utest.TestSuite {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is what the tests of mill plugins look like (once the TestEvaluator is made available). It looks quite decent and has the quality of being runnable from sbt as a mere test task call

@Baccata Baccata marked this pull request as ready for review June 6, 2022 13:16
@Baccata Baccata changed the title Add mill module (no tests yet) Add mill module Jun 6, 2022
@keynmol
Copy link
Contributor

keynmol commented Jun 6, 2022

Can you also add a build.sc to the example?

Without the binding generator part, as it doesn't have Mill plugin yet :)

Just to show the usage and eventually I want to make it runnable on CI

@Baccata
Copy link
Contributor Author

Baccata commented Jun 6, 2022

Sure. I can make a manual binding to show end to end usage. I'll get on it later today

Copy link
Contributor

@keynmol keynmol left a comment

Choose a reason for hiding this comment

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

No need to add example in this PR.

I'm happy with it as is, and if you are as well let's hit that like and subscribe button merge button

@keynmol keynmol merged commit 91d9f35 into indoorvivants:main Jun 6, 2022
@keynmol keynmol mentioned this pull request Jun 6, 2022
@Baccata Baccata deleted the mill branch June 6, 2022 16:45
@keynmol keynmol mentioned this pull request Jun 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants