diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs new file mode 100644 index 0000000..6cf3a47 --- /dev/null +++ b/.git-blame-ignore-revs @@ -0,0 +1,5 @@ +# Scala Steward: Reformat with scalafmt 3.8.3 +74504eabba695079dc83931746f073bc5eeb9a38 + +# Scala Steward: Reformat with scalafmt 3.9.7 +fa901af121af0329e7bfcc215f4cda57c9cb33cd diff --git a/.github/dependabot.yml b/.github/dependabot.yml deleted file mode 100644 index b3e0cb6..0000000 --- a/.github/dependabot.yml +++ /dev/null @@ -1,13 +0,0 @@ -version: 2 -updates: - - package-ecosystem: "github-actions" - directory: "/" - schedule: - interval: "weekly" - - package-ecosystem: "github-actions" - directory: "/" - schedule: - interval: "weekly" - target-branch: "2.3.x" - commit-message: - prefix: "[2.3.x] " diff --git a/.github/scala-steward.conf b/.github/scala-steward.conf index c17dba6..b363832 100644 --- a/.github/scala-steward.conf +++ b/.github/scala-steward.conf @@ -1,7 +1,5 @@ -pullRequests.frequency = "@monthly" - -commits.message = "${artifactName} ${nextVersion} (was ${currentVersion})" +commits.message = "[3.0.x] ${artifactName} ${nextVersion} (was ${currentVersion})" pullRequests.grouping = [ - { name = "patches", "title" = "Patch updates", "filter" = [{"version" = "patch"}] } + { name = "patches", "title" = "[3.0.x] Patch updates", "filter" = [{"version" = "patch"}] } ] diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index 4f08498..3be3389 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -5,7 +5,7 @@ on: push: branches: - - main # Check branch after merge + - 3.0.x # Check branch after merge concurrency: # Only run once for latest commit per ref and cancel other (previous) runs. diff --git a/.github/workflows/dependency-graph.yml b/.github/workflows/dependency-graph.yml index df0daa3..6fafdce 100644 --- a/.github/workflows/dependency-graph.yml +++ b/.github/workflows/dependency-graph.yml @@ -2,7 +2,7 @@ name: Dependency Graph on: push: branches: - - main + - 3.0.x concurrency: # Only run once for latest commit per ref and cancel other (previous) runs. @@ -17,8 +17,9 @@ jobs: name: Submit dependencies to GitHub runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 with: fetch-depth: 0 ref: ${{ inputs.ref }} + - uses: sbt/setup-sbt@v1 - uses: scalacenter/sbt-dependency-submission@v3 diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index db1edc7..3c87054 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -3,7 +3,7 @@ name: Publish on: push: branches: # Snapshots - - main + - 3.0.x tags: ["**"] # Releases jobs: diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml index eb1a1fa..f00f60e 100644 --- a/.github/workflows/release-drafter.yml +++ b/.github/workflows/release-drafter.yml @@ -3,16 +3,16 @@ name: Release Drafter on: push: branches: - - main + - 3.0.x jobs: update_release_draft: runs-on: ubuntu-latest steps: - - uses: release-drafter/release-drafter@v6 + - uses: release-drafter/release-drafter@v7 with: name: "cachecontrol $RESOLVED_VERSION" - config-name: release-drafts/increasing-minor-version.yml # located in .github/ in the default branch within this or the .github repo + config-name: release-drafts/increasing-patch-version.yml # located in .github/ in the default branch within this or the .github repo commitish: ${{ github.ref_name }} env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.scalafmt.conf b/.scalafmt.conf index f30b359..e4f5e34 100644 --- a/.scalafmt.conf +++ b/.scalafmt.conf @@ -13,4 +13,4 @@ rewrite.rules = [ AvoidInfix, ExpandImportSelectors, RedundantParens, SortModifi rewrite.sortModifiers.order = [ "private", "protected", "final", "sealed", "abstract", "implicit", "override", "lazy" ] spaces.inImportCurlyBraces = true # more idiomatic to include whitepsace in import x.{ yyy } trailingCommas = preserve -version = 3.8.1 +version = 3.11.0 diff --git a/build.sbt b/build.sbt index 391c9af..a13624e 100644 --- a/build.sbt +++ b/build.sbt @@ -22,7 +22,7 @@ lazy val cachecontrol = (project in file(".")) slf4jSimple % Test ), mimaPreviousArtifacts := previousVersion.map(organization.value %% moduleName.value % _).toSet, - headerLicense := { + headerLicense := { Some( HeaderLicense.Custom( s"Copyright (C) from 2022 The Play Framework Contributors , 2011-2021 Lightbend Inc. " diff --git a/project/Dependencies.scala b/project/Dependencies.scala index 8536dd2..ce102fe 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -4,13 +4,13 @@ import sbt._ object Dependencies { - val Scala212 = "2.12.19" - val Scala213 = "2.13.14" - val Scala3 = "3.3.3" + val Scala212 = "2.12.21" + val Scala213 = "2.13.18" + val Scala3 = "3.3.7" val ScalaVersions = Seq(Scala212, Scala213, Scala3) - def scalaTest = "org.scalatest" %% "scalatest" % "3.2.18" % Test + def scalaTest = "org.scalatest" %% "scalatest" % "3.2.20" % Test def parserCombinators(scalaVersion: String) = "org.scala-lang.modules" %% "scala-parser-combinators" % { @@ -20,7 +20,7 @@ object Dependencies { } } - val slf4jVersion = "2.0.13" + val slf4jVersion = "2.0.17" val slf4j = "org.slf4j" % "slf4j-api" % slf4jVersion val slf4jSimple = "org.slf4j" % "slf4j-simple" % slf4jVersion } diff --git a/project/build.properties b/project/build.properties index 1894b62..3e06ee3 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1,4 +1,4 @@ # # Copyright (C) from 2022 The Play Framework Contributors , 2011-2021 Lightbend Inc. # -sbt.version=1.10.0 +sbt.version=1.12.9 diff --git a/project/plugins.sbt b/project/plugins.sbt index 3b3efaa..a2fa528 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,5 +1,5 @@ -addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "1.1.3") -addSbtPlugin("com.lightbend.sbt" % "sbt-java-formatter" % "0.8.0") -addSbtPlugin("de.heikoseeberger" % "sbt-header" % "5.10.0") -addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.2") -addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.12") +addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "1.1.5") +addSbtPlugin("com.github.sbt" % "sbt-java-formatter" % "0.11.0") +addSbtPlugin("com.github.sbt" % "sbt-header" % "5.11.0") +addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.6.0") +addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.11.2") diff --git a/src/main/scala/org/playframework/cachecontrol/CacheDefaults.scala b/src/main/scala/org/playframework/cachecontrol/CacheDefaults.scala index a08a5b8..4b6f967 100644 --- a/src/main/scala/org/playframework/cachecontrol/CacheDefaults.scala +++ b/src/main/scala/org/playframework/cachecontrol/CacheDefaults.scala @@ -116,7 +116,7 @@ trait CacheDefaults extends Cache { while (nominatedHeadersIter.hasNext) { val nominatedHeaderName = nominatedHeadersIter.next() presentedHeaders.get(nominatedHeaderName) match { - case None => return false + case None => return false case Some(presentedHeaderValues) => val nominatedHeaderValues = nominatedHeaders(nominatedHeaderName) // There's a list of header values, so we need a way to normalize it. diff --git a/src/main/scala/org/playframework/cachecontrol/CacheDirectiveParser.scala b/src/main/scala/org/playframework/cachecontrol/CacheDirectiveParser.scala index 81774d9..e944b31 100644 --- a/src/main/scala/org/playframework/cachecontrol/CacheDirectiveParser.scala +++ b/src/main/scala/org/playframework/cachecontrol/CacheDirectiveParser.scala @@ -34,7 +34,6 @@ object CacheDirectiveParser { // http://bitwalker.org/blog/2013/08/10/learn-by-example-scala-parser-combinators/ // https://wiki.scala-lang.org/display/SW/Parser+Combinators--Getting+Started // http://www.bizcoder.com/everything-you-need-to-know-about-http-header-syntax-but-were-afraid-to-ask - import CacheDirectives._ private val logger = LoggerFactory.getLogger("org.playframework.cachecontrol.CacheControlParser") @@ -53,9 +52,9 @@ object CacheDirectiveParser { * * These patterns are translated directly using the same naming */ - val ctl = acceptIf { c => (c >= 0 && c <= 0x1f) || c.toInt == 0x7f }(_ => "Expected a control character") - val char = acceptIf(_ < 0x80)(_ => "Expected an ascii character") - val text = not(ctl) ~> any + val ctl = acceptIf { c => (c >= 0 && c <= 0x1f) || c.toInt == 0x7f }(_ => "Expected a control character") + val char = acceptIf(_ < 0x80)(_ => "Expected an ascii character") + val text = not(ctl) ~> any val separators = { acceptIf(c => separatorBitSet(c.toInt))(_ => "Expected one of " + separatorChars) } diff --git a/src/main/scala/org/playframework/cachecontrol/CacheDirectiveParserCompat.scala b/src/main/scala/org/playframework/cachecontrol/CacheDirectiveParserCompat.scala index dba778f..66fee96 100644 --- a/src/main/scala/org/playframework/cachecontrol/CacheDirectiveParserCompat.scala +++ b/src/main/scala/org/playframework/cachecontrol/CacheDirectiveParserCompat.scala @@ -8,7 +8,7 @@ object CacheDirectiveParserCompat { def toImmutableSeq[T](seq: Seq[T]): scala.collection.immutable.Seq[T] = { seq match { case xs: scala.collection.immutable.Seq[T @unchecked] => xs - case _ => + case _ => val b = scala.collection.immutable.Seq.newBuilder[T] seq.iterator.foreach(b += _) b.result() diff --git a/src/test/scala/org/playframework/cachecontrol/CacheDirectiveParserSpec.scala b/src/test/scala/org/playframework/cachecontrol/CacheDirectiveParserSpec.scala index 501c898..c02ccbf 100644 --- a/src/test/scala/org/playframework/cachecontrol/CacheDirectiveParserSpec.scala +++ b/src/test/scala/org/playframework/cachecontrol/CacheDirectiveParserSpec.scala @@ -154,7 +154,7 @@ class CacheDirectiveParserSpec extends AnyWordSpec { "parse random input as cache directives" in { // include embedded commas to make things interesting... - val directives = CacheDirectiveParser.parse(Seq("""i, have, no=idea, what="I'm, doing"""")) + val directives = CacheDirectiveParser.parse(Seq("""i, have, no=idea, what="I'm, doing"""")) val badSequence = Seq( CacheDirectiveExtension("i", None), CacheDirectiveExtension("have", None), diff --git a/src/test/scala/org/playframework/cachecontrol/ResponseCachingCalculatorSpec.scala b/src/test/scala/org/playframework/cachecontrol/ResponseCachingCalculatorSpec.scala index 5b66ed6..37745ed 100644 --- a/src/test/scala/org/playframework/cachecontrol/ResponseCachingCalculatorSpec.scala +++ b/src/test/scala/org/playframework/cachecontrol/ResponseCachingCalculatorSpec.scala @@ -173,10 +173,10 @@ class ResponseCachingCalculatorSpec extends AnyWordSpec { "with qualified private and qualified no-cache response directives" should { "return DoCache with only no-cache stripped headers when private" in { import CacheDirectives._ - val policy = new ResponseCachingCalculator(privateCache) - val request: CacheRequest = defaultRequest - val noCache = NoCache(Some(List("Set-Cookie"))) - val privDirective = Private(Some(List("Some-Header"))) + val policy = new ResponseCachingCalculator(privateCache) + val request: CacheRequest = defaultRequest + val noCache = NoCache(Some(List("Set-Cookie"))) + val privDirective = Private(Some(List("Some-Header"))) val response: OriginResponse = defaultResponse.copy(headers = h(privDirective.toString + "," + noCache.toString)) val result = policy.isCacheable(request, response) @@ -185,10 +185,10 @@ class ResponseCachingCalculatorSpec extends AnyWordSpec { "return DoCache with both stripped headers when shared cache" in { import CacheDirectives._ - val policy = new ResponseCachingCalculator(sharedCache) - val request: CacheRequest = defaultRequest - val noCache = NoCache(Some(List("Set-Cookie"))) - val privDirective = Private(Some(List("Some-Header"))) + val policy = new ResponseCachingCalculator(sharedCache) + val request: CacheRequest = defaultRequest + val noCache = NoCache(Some(List("Set-Cookie"))) + val privDirective = Private(Some(List("Some-Header"))) val response: OriginResponse = defaultResponse.copy(headers = h(privDirective.toString + "," + noCache.toString)) val result = policy.isCacheable(request, response) @@ -241,7 +241,7 @@ class ResponseCachingCalculatorSpec extends AnyWordSpec { "with a containsCachableExtension" should { "return DoCacheResponse" in { - var called = false + var called = false val cacheWithExtensions = new StubCache(shared = false) { override def isCacheableExtension(extension: CacheDirectives.CacheDirectiveExtension): Boolean = { called = extension.name == "public-on-tuesday" diff --git a/src/test/scala/org/playframework/cachecontrol/ResponseSelectionCalculatorSpec.scala b/src/test/scala/org/playframework/cachecontrol/ResponseSelectionCalculatorSpec.scala index 69343d0..bffba3b 100644 --- a/src/test/scala/org/playframework/cachecontrol/ResponseSelectionCalculatorSpec.scala +++ b/src/test/scala/org/playframework/cachecontrol/ResponseSelectionCalculatorSpec.scala @@ -113,7 +113,7 @@ class ResponseSelectionCalculatorSpec extends AnyWordSpec { val policy = new ResponseSelectionCalculator(cache) val presentingHeaders = Map(HeaderName("X-Custom-Header") -> Seq("value1")) val request = defaultRequest.copy(headers = presentingHeaders) - val nominatedHeaders = + val nominatedHeaders = Map(HeaderName("X-Custom-Header") -> Seq("value1"), HeaderName("X-Custom-Header") -> Seq("value2")) val response = defaultResponse.copy(nominatedHeaders = nominatedHeaders) val action = policy.selectResponse(request, Seq(response)) diff --git a/src/test/scala/org/playframework/cachecontrol/ResponseServingcalculatorSpec.scala b/src/test/scala/org/playframework/cachecontrol/ResponseServingcalculatorSpec.scala index 62e3283..123197e 100644 --- a/src/test/scala/org/playframework/cachecontrol/ResponseServingcalculatorSpec.scala +++ b/src/test/scala/org/playframework/cachecontrol/ResponseServingcalculatorSpec.scala @@ -44,7 +44,7 @@ class ResponseServingCalculatorSpec extends AnyWordSpec { "return Validate" in { val policy = new ResponseServingCalculator(privateCache) - val request = defaultRequest.copy(headers = defaultRequest.headers ++ Map(`Cache-Control` -> Seq("no-cache"))) + val request = defaultRequest.copy(headers = defaultRequest.headers ++ Map(`Cache-Control` -> Seq("no-cache"))) val response = defaultResponse.copy(headers = defaultResponse.headers ++ Map(`Cache-Control` -> Seq("max-age=60"))) @@ -58,12 +58,12 @@ class ResponseServingCalculatorSpec extends AnyWordSpec { "return Validate" in { val policy = new ResponseServingCalculator(privateCache) - val request = defaultRequest.copy(headers = defaultRequest.headers ++ Map(`Pragma` -> Seq("no-cache"))) + val request = defaultRequest.copy(headers = defaultRequest.headers ++ Map(`Pragma` -> Seq("no-cache"))) val response = defaultResponse.copy(headers = defaultResponse.headers ++ Map(`Cache-Control` -> Seq("max-age=60"))) val action: ResponseServeAction = policy.serveResponse(request, response, Duration.ofSeconds(5)) - val msg = + val msg = "Request does not contain Cache-Control header found, but does contains no-cache Pragma header, validation required" action should be(Validate(msg)) } @@ -73,7 +73,7 @@ class ResponseServingCalculatorSpec extends AnyWordSpec { "return ServeFresh when fresh" in { val policy = new ResponseServingCalculator(privateCache) - val request = defaultRequest.copy(headers = defaultRequest.headers ++ Map(`Cache-Control` -> Seq("no-store"))) + val request = defaultRequest.copy(headers = defaultRequest.headers ++ Map(`Cache-Control` -> Seq("no-store"))) val response = defaultResponse.copy(headers = defaultResponse.headers ++ Map(`Cache-Control` -> Seq("publish,max-age=60"))) @@ -85,7 +85,7 @@ class ResponseServingCalculatorSpec extends AnyWordSpec { "return Validate when stale" in { val policy = new ResponseServingCalculator(privateCache) - val request = defaultRequest.copy(headers = defaultRequest.headers ++ Map(`Cache-Control` -> Seq("no-store"))) + val request = defaultRequest.copy(headers = defaultRequest.headers ++ Map(`Cache-Control` -> Seq("no-store"))) val response = defaultResponse.copy(headers = defaultResponse.headers ++ Map(`Cache-Control` -> Seq("publish,max-age=60"))) diff --git a/src/test/scala/org/playframework/cachecontrol/SecondaryKeyCalculatorSpec.scala b/src/test/scala/org/playframework/cachecontrol/SecondaryKeyCalculatorSpec.scala index 1d7b8ec..09619be 100644 --- a/src/test/scala/org/playframework/cachecontrol/SecondaryKeyCalculatorSpec.scala +++ b/src/test/scala/org/playframework/cachecontrol/SecondaryKeyCalculatorSpec.scala @@ -12,8 +12,8 @@ import org.scalatest.wordspec.AnyWordSpec class SecondaryKeyCalculatorSpec extends AnyWordSpec { def responseHeaders = { - val now = HttpDate.now - val age = Duration.ofSeconds(60) + val now = HttpDate.now + val age = Duration.ofSeconds(60) val headers = Map( `Date` -> Seq(HttpDate.format(now)), `Age` -> Seq(age.getSeconds.toString),