Skip to content

Commit 364d282

Browse files
committed
community-build: Hardcode the version of some projects
Some projects rely on plugins (sbt-dynver, sbt-git) to compute a version number that includes the current git commit sha, this makes the community build really fragile since we need to hardcode the version numbers of published projects, and that number will change everytime we add a commit to a project. Moreover, `git submodule update` doesn't fetch new tags and sbt-dynver relies on the latest to set the version number, so we can end up in confusing situations where we're not publishing the version we think we're publishing. Hardcoding version numbers avoids this problem. An alternative solution would be to get the version number from the sbt project, but I don't know any good way to do that, parsing the output of `sbt "show version"` to get just the version number doesn't seem easy. I guess we could inject a new task that writes the version number to a file on disk. Revert the previous commit since we no longer need to fetch tags and so that would just slowdown the CI for no benefits.
1 parent 5d27ead commit 364d282

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

.github/workflows/ci.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,6 @@ jobs:
166166
run: |
167167
git submodule sync
168168
git submodule update --init --recursive --jobs 7
169-
git submodule foreach --recursive 'git fetch -f --tags'
170169
./project/scripts/sbt "community-build/testOnly dotty.communitybuild.CommunityBuildTestA"
171170
172171
community_build_b:
@@ -202,7 +201,6 @@ jobs:
202201
run: |
203202
git submodule sync
204203
git submodule update --init --recursive --jobs 7
205-
git submodule foreach --recursive 'git fetch -f --tags'
206204
./project/scripts/sbt "community-build/testOnly dotty.communitybuild.CommunityBuildTestB"
207205
208206
test_sbt:

community-build/src/scala/dotty/communitybuild/projects.scala

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,17 @@ def exec(projectDir: Path, binary: String, arguments: String*): Int =
2727
exitCode
2828

2929

30-
/** Versions of published projects, needs to be updated when a project in the build is updated. */
30+
/** Versions of published projects, needs to be updated when a project in the build is updated.
31+
*
32+
* TODO: instead of harcoding these numbers, we could get them from the
33+
* projects themselves. This likely requires injecting a custom task in the
34+
* projects to output the version number to a file.
35+
*/
3136
object Versions:
3237
val scalacheck = "1.15.2-SNAPSHOT"
3338
val scalatest = "3.2.3"
34-
val munit = "0.7.19+7-3ce72dda-SNAPSHOT"
35-
val scodecBits = "1.1-17-c6dbf21"
39+
val munit = "0.7.19+DOTTY-SNAPSHOT"
40+
val scodecBits = "1.1+DOTTY-SNAPSHOT"
3641

3742
sealed trait CommunityProject:
3843
private var published = false
@@ -294,14 +299,16 @@ object projects:
294299
lazy val munit = SbtCommunityProject(
295300
project = "munit",
296301
sbtTestCommand = "testsJVM/test;testsJS/test;",
297-
sbtPublishCommand = "munitJVM/publishLocal;munitJS/publishLocal;munitScalacheckJVM/publishLocal;munitScalacheckJS/publishLocal;junit/publishLocal",
302+
// Hardcode the version to avoid having to deal with something set by sbt-dynver
303+
sbtPublishCommand = s"""set every version := "${Versions.munit}"; munitJVM/publishLocal; munitJS/publishLocal; munitScalacheckJVM/publishLocal; munitScalacheckJS/publishLocal; junit/publishLocal""",
298304
dependencies = List(scalacheck)
299305
)
300306

301307
lazy val scodecBits = SbtCommunityProject(
302308
project = "scodec-bits",
303309
sbtTestCommand = "coreJVM/test;coreJS/test",
304-
sbtPublishCommand = "coreJVM/publishLocal;coreJS/publishLocal",
310+
// Hardcode the version to avoid having to deal with something set by sbt-git
311+
sbtPublishCommand = s"""set every version := "${Versions.scodecBits}"; coreJVM/publishLocal;coreJS/publishLocal""",
305312
dependencies = List(munit)
306313
)
307314

0 commit comments

Comments
 (0)