Skip to content

Commit

Permalink
Merge pull request #439 from circe/upgradathon
Browse files Browse the repository at this point in the history
Upgradathon
  • Loading branch information
hamnis authored Jul 15, 2024
2 parents 790a649 + 936b2b1 commit 79c1f03
Show file tree
Hide file tree
Showing 28 changed files with 650 additions and 280 deletions.
120 changes: 99 additions & 21 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,47 +9,125 @@ name: Continuous Integration

on:
pull_request:
branches: ['**']
branches: ['**', '!update/**', '!pr/**']
push:
branches: ['**']
branches: ['**', '!update/**', '!pr/**']
tags: [v*]

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}


concurrency:
group: ${{ github.workflow }} @ ${{ github.ref }}
cancel-in-progress: true

jobs:
build:
name: Build and Test
strategy:
matrix:
os: [ubuntu-latest]
scala: [2.13.10, 2.12.17, 3.2.2]
java: [[email protected]]
scala: [2.13, 2.12, 3]
java: [temurin@11, temurin@17]
exclude:
- scala: 2.12
java: temurin@17
- scala: 3
java: temurin@17
runs-on: ${{ matrix.os }}
timeout-minutes: 60
steps:
- name: Checkout current branch (full)
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Java and Scala
uses: olafurpg/setup-scala@v13
- name: Setup Java (temurin@11)
id: setup-java-temurin-11
if: matrix.java == 'temurin@11'
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.java }}
distribution: temurin
java-version: 11
cache: sbt

- name: sbt update
if: matrix.java == 'temurin@11' && steps.setup-java-temurin-11.outputs.cache-hit == 'false'
run: sbt +update

- name: Cache sbt
uses: actions/cache@v2
- name: Setup Java (temurin@17)
id: setup-java-temurin-17
if: matrix.java == 'temurin@17'
uses: actions/setup-java@v4
with:
path: |
~/.sbt
~/.ivy2/cache
~/.coursier/cache/v1
~/.cache/coursier/v1
~/AppData/Local/Coursier/Cache/v1
~/Library/Caches/Coursier/v1
key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }}
distribution: temurin
java-version: 17
cache: sbt

- name: sbt update
if: matrix.java == 'temurin@17' && steps.setup-java-temurin-17.outputs.cache-hit == 'false'
run: sbt +update

- name: Check that workflows are up to date
run: sbt ++${{ matrix.scala }} githubWorkflowCheck
run: sbt githubWorkflowCheck

- name: Check headers and formatting
if: matrix.java == 'temurin@11' && matrix.os == 'ubuntu-latest'
run: sbt '++ ${{ matrix.scala }}' headerCheckAll scalafmtCheckAll 'project /' scalafmtSbtCheck

- name: Test
run: sbt '++ ${{ matrix.scala }}' test

- name: Check binary compatibility
if: matrix.java == 'temurin@11' && matrix.os == 'ubuntu-latest'
run: sbt '++ ${{ matrix.scala }}' mimaReportBinaryIssues

- name: Generate API documentation
if: matrix.java == 'temurin@11' && matrix.os == 'ubuntu-latest'
run: sbt '++ ${{ matrix.scala }}' doc

dependency-submission:
name: Submit Dependencies
if: github.event_name != 'pull_request'
strategy:
matrix:
os: [ubuntu-latest]
java: [temurin@11]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout current branch (full)
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Java (temurin@11)
id: setup-java-temurin-11
if: matrix.java == 'temurin@11'
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 11
cache: sbt

- name: sbt update
if: matrix.java == 'temurin@11' && steps.setup-java-temurin-11.outputs.cache-hit == 'false'
run: sbt +update

- name: Setup Java (temurin@17)
id: setup-java-temurin-17
if: matrix.java == 'temurin@17'
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 17
cache: sbt

- name: sbt update
if: matrix.java == 'temurin@17' && steps.setup-java-temurin-17.outputs.cache-hit == 'false'
run: sbt +update

- name: Build project
run: sbt ++${{ matrix.scala }} test
- name: Submit Dependencies
uses: scalacenter/sbt-dependency-submission@v2
with:
configs-ignore: test scala-tool scala-doc-tool test-internal
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ target/
.classpath
tmp/
.bsp/
.metals
.vscode
3 changes: 3 additions & 0 deletions .scalafix.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
rules = [
OrganizeImports
]
18 changes: 16 additions & 2 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
version = 3.5.9
version = 3.8.2
project.git = true
runner.dialect = scala213
project.layout = StandardConvention
continuationIndent.defnSite = 2
docstrings = JavaDoc
docstrings.style = Asterisk
docstrings.wrap = no
includeCurlyBraceInSelectChains = false
maxColumn = 120
newlines.alwaysBeforeElseAfterCurlyIf = false
Expand All @@ -13,3 +17,13 @@ rewrite.rules = [
AsciiSortImports,
PreferCurlyFors
]
newlines.afterCurlyLambda = preserve
newlines.beforeCurlyLambdaParams = multilineWithCaseOnly

fileOverride {
"glob:**/scala-3/src/main/scala/**" {
runner.dialect = scala3
rewrite.scala3.convertToNewSyntax = true
rewrite.scala3.removeOptionalBraces = true
}
}
27 changes: 25 additions & 2 deletions 210/src/main/scala/io/circe/jackson/JacksonCompat.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,26 @@
/*
* Copyright 2016 circe
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package io.circe.jackson

import com.fasterxml.jackson.core.JsonParser
import com.fasterxml.jackson.databind.{ DeserializationContext, JsonNode, ObjectMapper, ObjectWriter }
import com.fasterxml.jackson.databind.DeserializationContext
import com.fasterxml.jackson.databind.JsonNode
import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.databind.ObjectWriter
import com.fasterxml.jackson.databind.node.ObjectNode

private[jackson] trait JacksonCompat {
Expand All @@ -10,9 +29,13 @@ private[jackson] trait JacksonCompat {
protected def handleUnexpectedToken(context: DeserializationContext)(
klass: Class[_],
parser: JsonParser
): Unit =
): Unit = {
context.handleUnexpectedToken(klass, parser)
()
}

protected def objectNodeSetAll(node: ObjectNode, fields: java.util.Map[String, JsonNode]): JsonNode =
node.setAll[JsonNode](fields)

protected def currentName(jp: JsonParser): String = jp.currentName
}
3 changes: 3 additions & 0 deletions 25/src/main/scala/io/circe/jackson/JacksonCompat.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,7 @@ private[jackson] trait JacksonCompat {

protected def objectNodeSetAll(node: ObjectNode, fields: java.util.Map[String, JsonNode]): JsonNode =
node.setAll(fields)

protected def currentName(jp: JsonParser): String = jp.getCurrentName

}
28 changes: 26 additions & 2 deletions 27/src/main/scala/io/circe/jackson/JacksonCompat.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,26 @@
/*
* Copyright 2016 circe
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package io.circe.jackson

import com.fasterxml.jackson.core.JsonParser
import com.fasterxml.jackson.databind.{ DeserializationContext, JsonNode, ObjectMapper, ObjectWriter }
import com.fasterxml.jackson.databind.DeserializationContext
import com.fasterxml.jackson.databind.JsonNode
import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.databind.ObjectWriter
import com.fasterxml.jackson.databind.node.ObjectNode

private[jackson] trait JacksonCompat {
Expand All @@ -10,9 +29,14 @@ private[jackson] trait JacksonCompat {
protected def handleUnexpectedToken(context: DeserializationContext)(
klass: Class[_],
parser: JsonParser
): Unit =
): Unit = {
val _ = parser
throw context.mappingException(klass)
}

protected def objectNodeSetAll(node: ObjectNode, fields: java.util.Map[String, JsonNode]): JsonNode =
node.setAll(fields)

protected def currentName(jp: JsonParser): String = jp.getCurrentName

}
27 changes: 25 additions & 2 deletions 28/src/main/scala/io/circe/jackson/JacksonCompat.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,26 @@
/*
* Copyright 2016 circe
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package io.circe.jackson

import com.fasterxml.jackson.core.JsonParser
import com.fasterxml.jackson.databind.{ DeserializationContext, JsonNode, ObjectMapper, ObjectWriter }
import com.fasterxml.jackson.databind.DeserializationContext
import com.fasterxml.jackson.databind.JsonNode
import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.databind.ObjectWriter
import com.fasterxml.jackson.databind.node.ObjectNode

private[jackson] trait JacksonCompat {
Expand All @@ -10,9 +29,13 @@ private[jackson] trait JacksonCompat {
protected def handleUnexpectedToken(context: DeserializationContext)(
klass: Class[_],
parser: JsonParser
): Unit =
): Unit = {
context.handleUnexpectedToken(klass, parser)
()
}

protected def objectNodeSetAll(node: ObjectNode, fields: java.util.Map[String, JsonNode]): JsonNode =
node.setAll(fields)

protected def currentName(jp: JsonParser): String = jp.getCurrentName
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,32 @@
/*
* Copyright 2016 circe
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package io.circe.jackson.benchmark

import cats.Eq
import io.circe.{ Decoder, Encoder, Json => JsonC }
import io.circe.Decoder
import io.circe.Encoder
import io.circe.generic.semiauto._
import io.circe.jawn._
import io.circe.{ Json => JsonC }
import org.openjdk.jmh.annotations._

import java.nio.ByteBuffer
import java.util.concurrent.TimeUnit
import org.openjdk.jmh.annotations._
import scala.annotation.nowarn

case class Foo(s: String, d: Double, i: Int, l: Long, bs: List[Boolean])

Expand Down Expand Up @@ -46,15 +66,19 @@ class ExampleData {
@OutputTimeUnit(TimeUnit.SECONDS)
class ParsingBenchmark extends ExampleData {
@Benchmark
@nowarn("cat=deprecation")
def parseIntsC: JsonC = parse(intsJson).right.getOrElse(throw new Exception)

@Benchmark
@nowarn("cat=deprecation")
def parseIntsCJ: JsonC = io.circe.jackson.parse(intsJson).right.getOrElse(throw new Exception)

@Benchmark
@nowarn("cat=deprecation")
def parseFoosC: JsonC = parse(foosJson).right.getOrElse(throw new Exception)

@Benchmark
@nowarn("cat=deprecation")
def parseFoosCJ: JsonC = io.circe.jackson.parse(foosJson).right.getOrElse(throw new Exception)
}

Expand Down
Loading

0 comments on commit 79c1f03

Please sign in to comment.