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

First draft of the mill plugin for smithy4s #450

Merged
merged 16 commits into from
Sep 15, 2022
Merged

First draft of the mill plugin for smithy4s #450

merged 16 commits into from
Sep 15, 2022

Conversation

daddykotex
Copy link
Contributor

@daddykotex daddykotex commented Sep 12, 2022

This brings mill support on top of `multimodule

@daddykotex daddykotex marked this pull request as ready for review September 12, 2022 18:23
build.sbt Show resolved Hide resolved

/** Input directory for .smithy files */
protected def smithy4sInputDir: Source = T.source {
PathRef(millSourcePath / "smithy")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

changed from os.pwd


test("multi-module codegen works") {
val fooEv = testKit.staticTestEvaluator(foo)(FullName("multi-module-foo"))
val barEv = testKit.staticTestEvaluator(foo)(FullName("multi-module-bar"))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

also the implicit FullName here is rather pointless

I'd rather have the evaluator for foo to write in foo

in this example if I don't provide it, it writes to barEv and if you have multiple tests that use an evaluator with the same name, they write to the same out directory.

I think this is more a criticism of https://github.com/com-lihaoyi/mill/pull/1893/files rather than this PR though

Copy link
Contributor

@Baccata Baccata Sep 13, 2022

Choose a reason for hiding this comment

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

I think this is more a criticism of https://github.com/com-lihaoyi/mill/pull/1893/files rather than this PR though

UX can be improved as we learn more by using it. MiMa has not been set on this module, specifically to be able to iterate.

.github/workflows/ci.yml Outdated Show resolved Hide resolved
def smithy4sCodegenDependencies: T[List[String]] = List.empty[String]

def smithy4sLocalJars: T[List[os.Path]] = T {
T.traverse(moduleDeps)(_.jar)
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

Base automatically changed from multimodule-codegen to 0.16.0 September 13, 2022 18:20
.mill-version Outdated Show resolved Hide resolved
@daddykotex
Copy link
Contributor Author

that's great:
Screen Shot 2022-09-14 at 10 42 52

it's common sense but I never thought github would do that automatically

@daddykotex
Copy link
Contributor Author

the new tests add quite a bit of overhead

@daddykotex
Copy link
Contributor Author

artifact name of other mill plugin:

    <name>de.tobiasroeser.mill.integrationtest_mill0.10_2.13</name>
    <groupId>de.tototec</groupId>
    <artifactId>de.tobiasroeser.mill.integrationtest_mill0.10_2.13</artifactId>

@kubukoz
Copy link
Member

kubukoz commented Sep 14, 2022

the new tests add quite a bit of overhead

@daddykotex I've been thinking the IDE experience hasn't been great recently due to how large the matrix is 😬 I think Oli mentioned one time that a Mill build would work better in Metals.

As for new tests slowing this down, maybe we can run scripted tests in parallel with some others (on a separate job)?

@Baccata
Copy link
Contributor

Baccata commented Sep 14, 2022

It's not about the build being large, it's that IJ sucks at cross-built modules.

As for new tests slowing this down, maybe we can run scripted tests in parallel with some others

Meh, the scripted tests need some compilation resulting from this job, so it'd be suboptimal to parallelise only to compile the same thing twice.

@Baccata
Copy link
Contributor

Baccata commented Sep 14, 2022

@daddykotex looks like this is what we want, let's add it to this PR

@daddykotex
Copy link
Contributor Author

yeah, I've been working on that for the last two hours, I can't figure out the right config
I had:

lazy val millPublishSettings = Def.settings(
  // EG:
  // sbt => com/disneystreaming/smithy4s/smithy4s-sbt-codegen_2.12_1.0/0.15.3/
  // mill => com/disneystreaming/smithy4s/smithy4s-mill-codegen-plugin_mill0.10_2.13/0.15.3
  Compile / sbt.Keys.artifact := {
    val sv = scalaBinaryVersion.value
    val artifact = sbt.Keys.artifact.value
    artifact.withName(
      s"${artifact.name}_mill${millPlatform(Dependencies.Mill.millVersion)}_${sv}"
    )
  }
)

But this produce:

[info] [millCodegenPlugin]      published smithy4s-mill-codegen-plugin_2.13 to local/com.disneystreaming.smithy4s/smithy4s-mill-codegen-plugin_2.13/dev-SNAPSHOT/poms/smithy4s-mill-codegen-plugin_2.13.pom
[info] [millCodegenPlugin]      published smithy4s-mill-codegen-plugin_mill0.10_2.13_2.13 to local/com.disneystreaming.smithy4s/smithy4s-mill-codegen-plugin_2.13/dev-SNAPSHOT/jars/smithy4s-mill-codegen-plugin_mill0.10_2.13_2.13.jar
[info] [millCodegenPlugin]      published smithy4s-mill-codegen-plugin_mill0.10_2.13_2.13 to local/com.disneystreaming.smithy4s/smithy4s-mill-codegen-plugin_2.13/dev-SNAPSHOT/srcs/smithy4s-mill-codegen-plugin_mill0.10_2.13_2.13-sources.jar
[info] [millCodegenPlugin]      published smithy4s-mill-codegen-plugin_mill0.10_2.13_2.13 to local/com.disneystreaming.smithy4s/smithy4s-mill-codegen-plugin_2.13/dev-SNAPSHOT/docs/smithy4s-mill-codegen-plugin_mill0.10_2.13_2.13-javadoc.jar

which is slightly off, we want:
com.disneystreaming.smithy4s/smithy4s-mill-codegen-plugin_mill0.10_2.13/dev-SNAPSHOT/

@daddykotex
Copy link
Contributor Author

reached out to discord

@daddykotex
Copy link
Contributor Author

Added a bit of logic to override the artifact to change the name following the logic of this mill-integrationtest: // mill => de/tototec/de.tobiasroeser.mill.integrationtest_mill0.10_2.13/0.5.1-2-5042de/

from this url, we can see that the artifact contain the mill and the scala version like: ed a bit of logic to override the artifactto change the name following the logic of thismill-integrationtest: [// mill => $GROUP/$ARTIFACT_mill${MILL_VERSION}_${SCALA_VERSION}/$VERSION/


I've tested locally, given a dummy project like:

tree .
.
├── build.sc
└── demo
    └── src
        └── Test.scala

2 directories, 2 files

I can update my build.sc from:

import mill._, mill.scalalib._
object demo extends ScalaModule {
  def scalaVersion = "2.13.8"
}

to:

import $ivy.`com.disneystreaming.smithy4s::smithy4s-mill-codegen-plugin::dev-SNAPSHOT`
import smithy4s.codegen.mill._

import mill._, mill.scalalib._
object demo extends ScalaModule with Smithy4sModule {
  def scalaVersion = "2.13.8"
  override def ivyDeps = Agg(
    ivy"com.disneystreaming.smithy4s::smithy4s-core:dev-SNAPSHOT"
  )
}

Then add a smithy/somefile.smithy under demo/ and get codegen to work!

@daddykotex
Copy link
Contributor Author

you can also use: ivy"com.disneystreaming.smithy4s::smithy4s-core:${smithy4sVersion()}"

@kubukoz
Copy link
Member

kubukoz commented Sep 14, 2022

It's not about the build being large, it's that IJ sucks at cross-built modules.

I meant metals though!

@daddykotex
Copy link
Contributor Author

From the 2.13 job:

[info] [millCodegenPlugin] :: delivering :: com.disneystreaming.smithy4s#smithy4s-mill-codegen-plugin_mill0.10_2.13;0.16-176-35b69e1 :: 0.16-176-35b69e1 :: integration :: Wed Sep 14 19:50:01 UTC 2022
[info] [millCodegenPlugin] 	delivering ivy file to /home/runner/work/smithy4s/smithy4s/modules/mill-codegen-plugin/target/jvm-2.13/ivy-0.16-176-35b69e1.xml
[info] [millCodegenPlugin] 	published smithy4s-mill-codegen-plugin_mill0.10_2.13 to /home/runner/.ivy2/local/com.disneystreaming.smithy4s/smithy4s-mill-codegen-plugin_mill0.10_2.13/0.16-176-35b69e1/poms/smithy4s-mill-codegen-plugin_mill0.10_2.13.pom
[info] [millCodegenPlugin] 	published smithy4s-mill-codegen-plugin_mill0.10_2.13 to /home/runner/.ivy2/local/com.disneystreaming.smithy4s/smithy4s-mill-codegen-plugin_mill0.10_2.13/0.16-176-35b69e1/jars/smithy4s-mill-codegen-plugin_mill0.10_2.13.jar
[info] [millCodegenPlugin] 	published smithy4s-mill-codegen-plugin_mill0.10_2.13 to /home/runner/.ivy2/local/com.disneystreaming.smithy4s/smithy4s-mill-codegen-plugin_mill0.10_2.13/0.16-176-35b69e1/srcs/smithy4s-mill-codegen-plugin_mill0.10_2.13-sources.jar
[info] [millCodegenPlugin] 	published smithy4s-mill-codegen-plugin_mill0.10_2.13 to /home/runner/.ivy2/local/com.disneystreaming.smithy4s/smithy4s-mill-codegen-plugin_mill0.10_2.13/0.16-176-35b69e1/docs/smithy4s-mill-codegen-plugin_mill0.10_2.13-javadoc.jar

👍

@Baccata
Copy link
Contributor

Baccata commented Sep 15, 2022

@daddykotex could you add some docs in a subsequent PR ?

@Baccata Baccata merged commit 5a17d8a into 0.16.0 Sep 15, 2022
@Baccata Baccata deleted the dfrancoeur/mill branch September 15, 2022 19:59
@daddykotex
Copy link
Contributor Author

oh yes, I forgot about that

@daddykotex
Copy link
Contributor Author

docs PR: #458

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.

None yet

4 participants