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

Move to nowarn instead of silencer #29932

Closed
wants to merge 10 commits into from
Closed

Conversation

andreaTP
Copy link
Contributor

@andreaTP andreaTP commented Jan 7, 2021

Follow up from:
#29929 (comment) (#29929)

Apart from the temporary workaround for Scala 2.12 I just validate that we can use the same approach for Scala 3.
Thanks, @ghik and @raboof

@andreaTP
Copy link
Contributor Author

andreaTP commented Jan 7, 2021

Side note:
I wanted to reformat just my changes to /project/*.scala with scalafmtSbt and ended up reformatting everything there, I hope is not a problem, in case I can revert.
Not sure where, but we probably want to add sbt scalafmtSbtCheck to the CI.

@akka-ci
Copy link

akka-ci commented Jan 7, 2021

Thank you for your pull request! After a quick sanity check one of the team will reply with 'OK ΤO ΤESΤ' to kick off our automated validation on Jenkins. This compiles the project, runs the tests, and checks for things like binary compatibility and source code formatting. When two team members have also manually reviewed and (perhaps after asking for some amendments) accepted your contribution, it should be good to be merged.

For more details about our contributing process, check out CONTRIBUTING.md - and feel free to ask!

@raboof
Copy link
Member

raboof commented Jan 7, 2021

OK TO TEST

@akka-ci akka-ci added the validating PR is currently being validated by Jenkins label Jan 7, 2021
"-P:silencer:globalFilters=The outer reference in this type test cannot be checked at run time",
// Because we show some things that are deprecated in
// 2.13 but don't have a replacement that was in 2.12:
"-P:silencer:globalFilters=deprecated \\(since 2.13.0\\)"))
Copy link
Member

Choose a reason for hiding this comment

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

It seems Scala 2.13 doesn't like these settings - are there equivalent settings to configure 'nowarn'?

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 will fix it

@akka-ci akka-ci added tested PR that was successfully built and tested by Jenkins and removed validating PR is currently being validated by Jenkins labels Jan 7, 2021
@akka-ci
Copy link

akka-ci commented Jan 7, 2021

Test PASSed.

@akka-ci akka-ci added validating PR is currently being validated by Jenkins and removed tested PR that was successfully built and tested by Jenkins labels Jan 8, 2021
("com.github.ghik" %% "silencer-lib" % silencerVersion % Provided).cross(CrossVersion.patch))
Seq(libraryDependencies ++= (if (autoScalaLibrary.value) libs else Nil))
case _ =>
Seq(scalacOptions ++= Seq("-nowarn", "-Wconf:any:e"))
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 have tried a bunch of patterns, but I have troubles and I might be falling into bugs.
E.g.
With this configuration: sbt -Dakka.build.scalaVersion=2.13 akka-actor/test:compile result in 12 errors in akka-actors all in:
@nowarn annotation does not suppress any warnings

The full scalacConfiguration is:

akka > show akka-actor/test:scalacOptions
[info] * -nowarn
[info] * -Wconf:any:e
[info] * -Xfatal-warnings
[info] * -Ywarn-extra-implicit
[info] * -Ywarn-unused:_
[info] * -Xlint
[info] * -deprecation
[info] * -encoding
[info] * UTF-8
[info] * -feature
[info] * -unchecked
[info] * -language:higherKinds
[info] * -target:jvm-1.8

It would be nice to get help from someone like @lrytz 🙏

Copy link
Contributor

Choose a reason for hiding this comment

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

👋 the compiler treats -Wconf before -nowarn. Using both -nowarn -Wconf:any:e first promotes all warnings to be errors, so the messages are issued using reporter.error, and -nowarn has no effect anymore as it's checked in reporter.warning.

@nowarn annotation does not suppress any warnings is a warning enabled by -Xlint, it means that a @nowarn annotation is redundant, i.e., doesn't silence anything. It is reported as an error here because of -Wconf:any:e.

Does that help..?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@akka-ci akka-ci added tested PR that was successfully built and tested by Jenkins and removed validating PR is currently being validated by Jenkins labels Jan 8, 2021
@akka-ci
Copy link

akka-ci commented Jan 8, 2021

Test PASSed.

@akka-ci akka-ci added validating PR is currently being validated by Jenkins tested PR that was successfully built and tested by Jenkins and removed tested PR that was successfully built and tested by Jenkins validating PR is currently being validated by Jenkins labels Jan 8, 2021
@akka-ci
Copy link

akka-ci commented Jan 8, 2021

Test PASSed.


// TODO: remove this when upgrading to Scala 2.12.13
// https://github.com/scala/scala/pull/9248
package scala.annotation
Copy link
Member

Choose a reason for hiding this comment

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

will this work with OSGi? I think it doesn't allow source in other packages than the root package of the module.
Eventually we will remove the OSGi support #28304 but we are not there yet.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

How can we test?
I was working under the assumption that, if the tests are passing, I'm not breaking anything.

That said, I'm not sure how can OSGi detect this, at best of my understanding:

  • Akka depends on Scala and scala library should be on the classpath
  • I'm not aware of a way to distinguish from which jar a specific class is coming from given a classpath
  • @nowarn is an annotation and should not spill to runtime

Am I making any wrong assumptions @patriknw ? I'm certainly not an OSGi expert ...

@andreaTP
Copy link
Contributor Author

Bumped Scala 2.12 to 2.12.13 that has nowarn.
I kept the pattern matching on the version since I'm going to use that structure sooner, is it ok?
This also removes the dependency on silencer.

@akka-ci akka-ci added validating PR is currently being validated by Jenkins needs-attention Indicates a PR validation failure (set by CI infrastructure) and removed tested PR that was successfully built and tested by Jenkins validating PR is currently being validated by Jenkins labels Jan 13, 2021
@akka-ci
Copy link

akka-ci commented Jan 13, 2021

Test FAILed.

@akka-ci akka-ci added validating PR is currently being validated by Jenkins needs-attention Indicates a PR validation failure (set by CI infrastructure) and removed needs-attention Indicates a PR validation failure (set by CI infrastructure) validating PR is currently being validated by Jenkins labels Jan 13, 2021
@akka-ci
Copy link

akka-ci commented Jan 13, 2021

Test FAILed.

@akka-ci akka-ci added validating PR is currently being validated by Jenkins needs-attention Indicates a PR validation failure (set by CI infrastructure) and removed needs-attention Indicates a PR validation failure (set by CI infrastructure) validating PR is currently being validated by Jenkins labels Jan 13, 2021
@akka-ci
Copy link

akka-ci commented Jan 13, 2021

Test FAILed.

@andreaTP
Copy link
Contributor Author

@akka-ci akka-ci added validating PR is currently being validated by Jenkins tested PR that was successfully built and tested by Jenkins and removed needs-attention Indicates a PR validation failure (set by CI infrastructure) validating PR is currently being validated by Jenkins labels Jan 13, 2021
@akka-ci
Copy link

akka-ci commented Jan 13, 2021

Test PASSed.

@@ -63,17 +63,39 @@ object AkkaDisciplinePlugin extends AutoPlugin {
"akka-stream-tests-tck",
"akka-testkit")

lazy val silencerSettings = {
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 the relevant diff for reviewers.

@andreaTP
Copy link
Contributor Author

Ready for a final review.

Copy link
Member

@raboof raboof left a comment

Choose a reason for hiding this comment

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

neat!

@@ -37,19 +37,21 @@ object Dependencies {
val scalaTestVersion = "3.1.4"
val scalaCheckVersion = "1.15.1"

def getScalaVersion() = {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
def getScalaVersion() = {
def getScalaVersion() = {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the formatting is done by scalafmtSbt, should I change it?

Copy link
Member

Choose a reason for hiding this comment

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

are you sure? sbt scalafmtSbt seems to change it for me as well

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'll re-run it so 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

scalafmt was breaking, fixed, and re-formatted

@@ -37,19 +37,21 @@ object Dependencies {
val scalaTestVersion = "3.1.4"
val scalaCheckVersion = "1.15.1"

def getScalaVersion() = {
// don't allow full override to keep compatible with the version of silencer
Copy link
Member

Choose a reason for hiding this comment

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

I guess this comment doesn't apply anymore as we don't use the silencer anymore?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch! This is an interesting subject, in the Scala 3 PR I'm heavily relying on this method, even if it looks like is not needed anymore, can I just remove the comment for now?

// don't allow full override to keep compatible with the version of silencer
// don't mandate patch not specified to allow builds to migrate
System.getProperty("akka.build.scalaVersion", "default") match {
case twoThirteen if twoThirteen.startsWith("2.13") => scala213Version
Copy link
Member

Choose a reason for hiding this comment

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

(a bit weird but it was already like this so 👍 :) )

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 can include any encoding you prefer, I found it weird too :)

Copy link
Member

Choose a reason for hiding this comment

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

I suspect we still have jenkins jobs that pass 2.13.x as akka.build.scalaVersion, and we wanted to fix those before changing the startsWith match to an exact match. Might be best to cover in another PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

deal 👍

@akka-ci akka-ci added validating PR is currently being validated by Jenkins tested PR that was successfully built and tested by Jenkins and removed tested PR that was successfully built and tested by Jenkins validating PR is currently being validated by Jenkins labels Jan 14, 2021
@akka-ci
Copy link

akka-ci commented Jan 14, 2021

Test PASSed.

@patriknw
Copy link
Member

Superseded by #29956, I assume

@patriknw patriknw closed this Jan 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tested PR that was successfully built and tested by Jenkins
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants