Skip to content

Commit 7441791

Browse files
Update reference, MiMa previous version and sync TASTy version (scala#22187)
* Update reference version to 3.6.3-RC1 (from 3.6.0) * Update mima previous binary verison to 3.6.2 (instead of unofficial 3.6.1) * Set TASTy version to `28.7-experimental-1` - it should have been set when branching of 3.6.3. * We now document better how and when tasty version should be set * Add additional runtime test to ensure we don't emit invalid TASTy version during Release / NIGHTLY releases and the expected version set in build matches version defined in TastyFormat
1 parent 91063dd commit 7441791

File tree

3 files changed

+85
-6
lines changed

3 files changed

+85
-6
lines changed

Diff for: project/Build.scala

+58-5
Original file line numberDiff line numberDiff line change
@@ -93,18 +93,21 @@ object Build {
9393

9494
/** Version of the Scala compiler used to build the artifacts.
9595
* Reference version should track the latest version pushed to Maven:
96-
* - In main branch it should be the last RC version (using experimental TASTy required for non-bootstrapped tests)
96+
* - In main branch it should be the last RC version
9797
* - In release branch it should be the last stable release
98-
* 3.6.0-RC1 was released as 3.6.0 - it's having and experimental TASTy version
98+
*
99+
* Warning: Change of this variable needs to be consulted with `expectedTastyVersion`
99100
*/
100-
val referenceVersion = "3.6.0"
101+
val referenceVersion = "3.6.3-RC1"
101102

102103
/** Version of the Scala compiler targeted in the current release cycle
103104
* Contains a version without RC/SNAPSHOT/NIGHTLY specific suffixes
104105
* Should be updated ONLY after release or cutoff for previous release cycle.
105106
*
106107
* Should only be referred from `dottyVersion` or settings/tasks requiring simplified version string,
107108
* eg. `compatMode` or Windows native distribution version.
109+
*
110+
* Warning: Change of this variable might require updating `expectedTastyVersion`
108111
*/
109112
val developedVersion = "3.6.4"
110113

@@ -116,6 +119,25 @@ object Build {
116119
* During final, stable release is set exactly to `developedVersion`.
117120
*/
118121
val baseVersion = s"$developedVersion-RC1"
122+
123+
/** The version of TASTY that should be emitted, checked in runtime test
124+
* For defails on how TASTY version should be set see related discussions:
125+
* - https://github.com/scala/scala3/issues/13447#issuecomment-912447107
126+
* - https://github.com/scala/scala3/issues/14306#issuecomment-1069333516
127+
* - https://github.com/scala/scala3/pull/19321
128+
*
129+
* Simplified rules, given 3.$minor.$patch = $developedVersion
130+
* - Major version is always 28
131+
* - TASTY minor version:
132+
* - in main (NIGHTLY): {if $patch == 0 then $minor else ${minor + 1}}
133+
* - in release branch is always equal to $minor
134+
* - TASTY experimental version:
135+
* - in main (NIGHTLY) is always experimental
136+
* - in release candidate branch is experimental if {patch == 0}
137+
* - in stable release is always non-experimetnal
138+
*/
139+
val expectedTastyVersion = "28.7-experimental-1"
140+
checkReleasedTastyVersion()
119141

120142
/** Final version of Scala compiler, controlled by environment variables. */
121143
val dottyVersion = {
@@ -149,9 +171,9 @@ object Build {
149171
* For a developedVersion `3.M.P` the mimaPreviousDottyVersion should be set to:
150172
* - `3.M.0` if `P > 0`
151173
* - `3.(M-1).0` if `P = 0`
152-
* 3.6.1 is an exception from this rule - 3.6.0 was a broken release
174+
* 3.6.2 is an exception from this rule - 3.6.0 was a broken release, 3.6.1 was hotfix (unstable) release
153175
*/
154-
val mimaPreviousDottyVersion = "3.6.1"
176+
val mimaPreviousDottyVersion = "3.6.2"
155177

156178
/** LTS version against which we check binary compatibility.
157179
*
@@ -2424,6 +2446,9 @@ object Build {
24242446
settings(disableDocSetting).
24252447
settings(
24262448
versionScheme := Some("semver-spec"),
2449+
Test / envVars ++= Map(
2450+
"EXPECTED_TASTY_VERSION" -> expectedTastyVersion,
2451+
),
24272452
if (mode == Bootstrapped) Def.settings(
24282453
commonMiMaSettings,
24292454
mimaForwardIssueFilters := MiMaFilters.TastyCore.ForwardsBreakingChanges,
@@ -2473,6 +2498,34 @@ object Build {
24732498
case Bootstrapped => commonBootstrappedSettings
24742499
})
24752500
}
2501+
2502+
/* Tests TASTy version invariants during NIGHLY, RC or Stable releases */
2503+
def checkReleasedTastyVersion(): Unit = {
2504+
lazy val (scalaMinor, scalaPatch, scalaIsRC) = baseVersion.split("\\.|-").take(4) match {
2505+
case Array("3", minor, patch) => (minor.toInt, patch.toInt, false)
2506+
case Array("3", minor, patch, _) => (minor.toInt, patch.toInt, true)
2507+
case other => sys.error(s"Invalid Scala base version string: $baseVersion")
2508+
}
2509+
lazy val (tastyMinor, tastyIsExperimental) = expectedTastyVersion.split("\\.|-").take(4) match {
2510+
case Array("28", minor) => (minor.toInt, false)
2511+
case Array("28", minor, "experimental", _) => (minor.toInt, true)
2512+
case other => sys.error(s"Invalid TASTy version string: $expectedTastyVersion")
2513+
}
2514+
2515+
if(isNightly) {
2516+
assert(tastyIsExperimental, "TASTY needs to be experimental in nightly builds")
2517+
val expectedTastyMinor = if(scalaPatch == 0) scalaMinor else scalaMinor + 1
2518+
assert(tastyMinor == expectedTastyMinor, "Invalid TASTy minor version")
2519+
}
2520+
2521+
if(isRelease) {
2522+
assert(scalaMinor == tastyMinor, "Minor versions of TASTY vesion and Scala version should match in release builds")
2523+
if (scalaIsRC && scalaPatch == 0)
2524+
assert(tastyIsExperimental, "TASTy should be experimental when releasing a new minor version RC")
2525+
else
2526+
assert(!tastyIsExperimental, "Stable version cannot use experimental TASTY")
2527+
}
2528+
}
24762529
}
24772530

24782531
object ScaladocConfigs {

Diff for: tasty/src/dotty/tools/tasty/TastyFormat.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ object TastyFormat {
324324
* compatibility, but remains backwards compatible, with all
325325
* preceding `MinorVersion`.
326326
*/
327-
final val MinorVersion: Int = 6
327+
final val MinorVersion: Int = 7
328328

329329
/** Natural Number. The `ExperimentalVersion` allows for
330330
* experimentation with changes to TASTy without committing
+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package dotty.tools.tasty
2+
3+
import org.junit.Assert._
4+
import org.junit.Test
5+
6+
import TastyBuffer._
7+
8+
// Tests ensuring TASTY version emitted by compiler is matching expected TASTY version
9+
class BuildTastyVersionTest {
10+
11+
val CurrentTastyVersion = TastyVersion(TastyFormat.MajorVersion, TastyFormat.MinorVersion, TastyFormat.ExperimentalVersion)
12+
13+
// Needs to be defined in build Test/envVars
14+
val ExpectedTastyVersionEnvVar = "EXPECTED_TASTY_VERSION"
15+
16+
@Test def testBuildTastyVersion(): Unit = {
17+
val expectedVersion = sys.env.get(ExpectedTastyVersionEnvVar)
18+
.getOrElse(fail(s"Env variable $ExpectedTastyVersionEnvVar not defined"))
19+
.match {
20+
case s"$major.$minor-experimental-$experimental" => TastyVersion(major.toInt, minor.toInt, experimental.toInt)
21+
case s"$major.$minor" if minor.forall(_.isDigit) => TastyVersion(major.toInt, minor.toInt, 0)
22+
case other => fail(s"Invalid TASTY version string: $other")
23+
}
24+
assertEquals(CurrentTastyVersion, expectedVersion)
25+
}
26+
}

0 commit comments

Comments
 (0)