Skip to content

Commit

Permalink
change scalafmt
Browse files Browse the repository at this point in the history
  • Loading branch information
pjfanning committed May 8, 2024
1 parent a8f29c9 commit 3ad8f09
Show file tree
Hide file tree
Showing 18 changed files with 248 additions and 229 deletions.
89 changes: 77 additions & 12 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,12 +1,77 @@
version = 3.7.1
runner.dialect = scala213
preset = default
align.preset = more
maxColumn = 120
project.git = true
align.openParenDefnSite = true
align.openParenCallSite = true
align.arrowEnumeratorGenerator = true
danglingParentheses.preset = true
rewrite.rules = [RedundantBraces, RedundantParens]
project.layout = StandardConvention
version = 3.8.1
runner.dialect = scala213
project.git = true
style = defaultWithAlign
docstrings.style = Asterisk
docstrings.wrap = false
indentOperator.preset = spray
maxColumn = 120
lineEndings = preserve
rewrite.rules = [RedundantParens, SortImports, AvoidInfix]
indentOperator.exemptScope = all
align.preset = some
align.tokens."+" = [
{
code = "~>"
owners = [
{ regex = "Term.ApplyInfix" }
]
}
]
literals.hexDigits = upper
literals.hexPrefix = lower
binPack.unsafeCallSite = always
binPack.unsafeDefnSite = always
binPack.indentCallSiteSingleArg = false
binPack.indentCallSiteOnce = true
newlines.avoidForSimpleOverflow = [slc]
newlines.source = keep
newlines.beforeMultiline = keep
align.openParenDefnSite = false
align.openParenCallSite = false
align.allowOverflow = true
optIn.breakChainOnFirstMethodDot = false
optIn.configStyleArguments = false
danglingParentheses.preset = false
spaces.inImportCurlyBraces = true
rewrite.neverInfix.excludeFilters = [
and
min
max
until
to
by
eq
ne
"should.*"
"contain.*"
"must.*"
in
ignore
be
taggedAs
thrownBy
synchronized
have
when
size
only
noneOf
oneElementOf
noElementsOf
atLeastOneElementOf
atMostOneElementOf
allElementsOf
inOrderElementsOf
theSameElementsAs
theSameElementsInOrderAs
]
rewriteTokens = {
"⇒": "=>"
"→": "->"
"←": "<-"
}
project.excludeFilters = [
"scripts/authors.scala"
]
project.layout = StandardConvention
75 changes: 34 additions & 41 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,23 @@
* limitations under the License.
*/

ThisBuild / organization := "com.github.pjfanning"
ThisBuild / organization := "com.github.pjfanning"
ThisBuild / crossScalaVersions := List("2.12.18", "2.13.12", "3.3.1")
ThisBuild / scalaVersion := "2.13.12"
ThisBuild / scalaVersion := "2.13.12"

ThisBuild / githubWorkflowTargetTags ++= Seq("v*")
ThisBuild / githubWorkflowPublishTargetBranches := Seq(
RefPredicate.Equals(Ref.Branch("main")),
RefPredicate.StartsWith(Ref.Tag("v"))
)
RefPredicate.StartsWith(Ref.Tag("v")))
ThisBuild / githubWorkflowPublish := Seq(
WorkflowStep.Sbt(
List("ci-release"),
env = Map(
"PGP_PASSPHRASE" -> "${{ secrets.PGP_PASSPHRASE }}",
"PGP_SECRET" -> "${{ secrets.PGP_SECRET }}",
"SONATYPE_PASSWORD" -> "${{ secrets.SONATYPE_PASSWORD }}",
"SONATYPE_USERNAME" -> "${{ secrets.SONATYPE_USERNAME }}",
"CI_SNAPSHOT_RELEASE" -> "+publishSigned"
)
)
)
"PGP_PASSPHRASE" -> "${{ secrets.PGP_PASSPHRASE }}",
"PGP_SECRET" -> "${{ secrets.PGP_SECRET }}",
"SONATYPE_PASSWORD" -> "${{ secrets.SONATYPE_PASSWORD }}",
"SONATYPE_USERNAME" -> "${{ secrets.SONATYPE_USERNAME }}",
"CI_SNAPSHOT_RELEASE" -> "+publishSigned")))

ThisBuild / githubWorkflowBuild := Seq(WorkflowStep.Sbt(List("it:compile", "test"), name = Some("Build project")))

Expand All @@ -49,54 +45,51 @@ lazy val commonSettings = Seq(
Seq.empty // Inliner not available for Scala 3 yet
),
description := "An alternative non-blocking async http engine for aws-sdk-java-v2 based on pekko-http",
name := "aws-spi-pekko-http",
name := "aws-spi-pekko-http",
licenses += ("Apache-2.0", new URL("https://github.com/pjfanning/aws-spi-pekko-http/blob/main/LICENSE")),
startYear := Some(2023),
homepage := Some(url("https://github.com/pjfanning/aws-spi-pekko-http")),
startYear := Some(2023),
homepage := Some(url("https://github.com/pjfanning/aws-spi-pekko-http")),
organizationHomepage := Some(url("https://github.com/pjfanning/aws-spi-pekko-http")),
developers := Developer("matsluni", "Matthias Lüneberg", "", url("https://github.com/matsluni")) ::
Developer("pjfanning", "PJ Fanning", "", url("https://github.com/pjfanning")) :: Nil,
Developer("pjfanning", "PJ Fanning", "", url("https://github.com/pjfanning")) :: Nil,
scmInfo := Some(
ScmInfo(
browseUrl = url("https://github.com/pjfanning/aws-spi-pekko-http.git"),
connection = "scm:git:git@github.com:pjfanning/aws-spi-pekko-http.git"
)
)
)
connection = "scm:git:git@github.com:pjfanning/aws-spi-pekko-http.git")))

lazy val IntegrationTest = config("it") extend Test
lazy val IntegrationTest = config("it").extend(Test)

lazy val root = (project in file("."))
.configs(IntegrationTest)
.settings(
commonSettings,
Defaults.itSettings,
libraryDependencies ++= deps,
Test / fork := true,
publishMavenStyle := true,
Test / fork := true,
publishMavenStyle := true,
Test / publishArtifact := false,
pomIncludeRepository := (_ => false),
publishTo := sonatypePublishToBundle.value
)
pomIncludeRepository := (_ => false),
publishTo := sonatypePublishToBundle.value)

lazy val deps = {
val awsSDKVersion = "2.20.162"
val pekkoVersion = "1.0.2"
val awsSDKVersion = "2.20.162"
val pekkoVersion = "1.0.2"
val pekkoHttpVersion = "1.0.1"

Seq(
"org.apache.pekko" %% "pekko-stream" % pekkoVersion,
"org.apache.pekko" %% "pekko-http" % pekkoHttpVersion,
"org.apache.pekko" %% "pekko-stream" % pekkoVersion,
"org.apache.pekko" %% "pekko-http" % pekkoHttpVersion,
"software.amazon.awssdk" % "http-client-spi" % awsSDKVersion,
"software.amazon.awssdk" % "s3" % awsSDKVersion % "test" exclude ("software.amazon.awssdk", "netty-nio-client"),
"software.amazon.awssdk" % "dynamodb" % awsSDKVersion % "test" exclude ("software.amazon.awssdk", "netty-nio-client"),
"software.amazon.awssdk" % "sqs" % awsSDKVersion % "test" exclude ("software.amazon.awssdk", "netty-nio-client"),
"software.amazon.awssdk" % "sns" % awsSDKVersion % "test" exclude ("software.amazon.awssdk", "netty-nio-client"),
"software.amazon.awssdk" % "kinesis" % awsSDKVersion % "test" exclude ("software.amazon.awssdk", "netty-nio-client"),
"com.dimafeng" %% "testcontainers-scala" % "0.41.0" % "test",
"junit" % "junit" % "4.13.2" % "test",
"org.scalatest" %% "scalatest" % "3.2.18" % "it,test",
"org.scalatestplus" %% "junit-4-13" % "3.2.18.0" % "it,test",
"ch.qos.logback" % "logback-classic" % "1.2.13" % "it,test"
)
("software.amazon.awssdk" % "s3" % awsSDKVersion % "test").exclude("software.amazon.awssdk", "netty-nio-client"),
("software.amazon.awssdk" % "dynamodb" % awsSDKVersion % "test").exclude("software.amazon.awssdk",
"netty-nio-client"),
("software.amazon.awssdk" % "sqs" % awsSDKVersion % "test").exclude("software.amazon.awssdk", "netty-nio-client"),
("software.amazon.awssdk" % "sns" % awsSDKVersion % "test").exclude("software.amazon.awssdk", "netty-nio-client"),
("software.amazon.awssdk" % "kinesis" % awsSDKVersion % "test").exclude("software.amazon.awssdk",
"netty-nio-client"),
"com.dimafeng" %% "testcontainers-scala" % "0.41.0" % "test",
"junit" % "junit" % "4.13.2" % "test",
"org.scalatest" %% "scalatest" % "3.2.18" % "it,test",
"org.scalatestplus" %% "junit-4-13" % "3.2.18.0" % "it,test",
"ch.qos.logback" % "logback-classic" % "1.2.13" % "it,test")
}
6 changes: 3 additions & 3 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

addSbtPlugin("com.github.sbt" % "sbt-github-actions" % "0.22.0")
addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.12")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.2")
addSbtPlugin("com.github.sbt" % "sbt-github-actions" % "0.22.0")
addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.12")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.2")
addSbtPlugin("com.lightbend.sbt" % "sbt-java-formatter" % "0.7.0")
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ trait TestBase {
SystemPropertyCredentialsProvider.create,
ProfileCredentialsProvider.builder
.profileName(credentialProfileName)
.build
)
.build)
.build
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

package com.github.pjfanning.pekkohttpspi.dynamodb

import com.github.pjfanning.pekkohttpspi.{FutureConverters, PekkoHttpAsyncHttpService, TestBase}
import org.scalatest.concurrent.{Eventually, Futures, IntegrationPatience}
import com.github.pjfanning.pekkohttpspi.{ FutureConverters, PekkoHttpAsyncHttpService, TestBase }
import org.scalatest.concurrent.{ Eventually, Futures, IntegrationPatience }
import org.scalatest.wordspec.AnyWordSpec
import org.scalatest.matchers.should.Matchers
import software.amazon.awssdk.services.dynamodb.DynamoDbAsyncClient
Expand Down Expand Up @@ -54,9 +54,9 @@ class ITTestDynamoDB

"DynamoDB" should {
"create a table" in withClient { implicit client =>
val tableName = s"Movies-${randomIdentifier(5)}"
val tableName = s"Movies-${randomIdentifier(5)}"
val attributes = AttributeDefinition.builder.attributeName("film_id").attributeType(ScalarAttributeType.S).build()
val keySchema = KeySchemaElement.builder.attributeName("film_id").keyType(KeyType.HASH).build()
val keySchema = KeySchemaElement.builder.attributeName("film_id").keyType(KeyType.HASH).build()

val result = client
.createTable(
Expand All @@ -69,10 +69,8 @@ class ITTestDynamoDB
ProvisionedThroughput.builder
.readCapacityUnits(1L)
.writeCapacityUnits(1L)
.build()
)
.build()
)
.build())
.build())
.join

val desc = result.tableDescription()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

package com.github.pjfanning.pekkohttpspi.kinesis

import com.github.pjfanning.pekkohttpspi.{PekkoHttpAsyncHttpService, TestBase}
import com.github.pjfanning.pekkohttpspi.{ PekkoHttpAsyncHttpService, TestBase }
import org.scalatest.wordspec.AnyWordSpec
import org.scalatest.matchers.should.Matchers
import software.amazon.awssdk.core.SdkBytes
Expand Down Expand Up @@ -51,15 +51,15 @@ class ITTestKinesis extends AnyWordSpec with Matchers with TestBase {

"use a data stream: create + put + get + delete" in withClient { implicit client =>
val streamName = "aws-spi-test-" + Random.alphanumeric.take(10).filterNot(_.isUpper).mkString
val data = "123"
val data = "123"

val createRequest = CreateStreamRequest
.builder()
.streamName(streamName)
.shardCount(1)
.build()

val _ = client.createStream(createRequest).join()
val _ = client.createStream(createRequest).join()
val describeStreamRequest = DescribeStreamRequest.builder().streamName(streamName).build()

Thread.sleep(5000)
Expand Down
36 changes: 14 additions & 22 deletions src/it/scala/com/github/pjfanning/pekkohttpspi/s3/ITTestS3.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@

package com.github.pjfanning.pekkohttpspi.s3

import java.io.{File, FileWriter}
import com.github.pjfanning.pekkohttpspi.{PekkoHttpAsyncHttpService, TestBase}
import java.io.{ File, FileWriter }
import com.github.pjfanning.pekkohttpspi.{ PekkoHttpAsyncHttpService, TestBase }
import org.scalatest.wordspec.AnyWordSpec
import org.scalatest.matchers.should.Matchers
import software.amazon.awssdk.core.async.{AsyncRequestBody, AsyncResponseTransformer}
import software.amazon.awssdk.services.s3.{S3AsyncClient, S3Configuration}
import software.amazon.awssdk.core.async.{ AsyncRequestBody, AsyncResponseTransformer }
import software.amazon.awssdk.services.s3.{ S3AsyncClient, S3Configuration }
import software.amazon.awssdk.services.s3.model._

import scala.util.Random
Expand Down Expand Up @@ -53,17 +53,16 @@ class ITTestS3 extends AnyWordSpec with Matchers with TestBase {
"upload and download a file to a bucket + cleanup" in withClient(checksumEnabled = true) { implicit client =>
val bucketName = "aws-spi-test-" + Random.alphanumeric.take(10).filterNot(_.isUpper).mkString
createBucket(bucketName)
val randomFile = File.createTempFile("aws", Random.alphanumeric.take(5).mkString)
val randomFile = File.createTempFile("aws", Random.alphanumeric.take(5).mkString)
val fileContent = Random.alphanumeric.take(1000).mkString
val fileWriter = new FileWriter(randomFile)
val fileWriter = new FileWriter(randomFile)
fileWriter.write(fileContent)
fileWriter.flush()
client.putObject(PutObjectRequest.builder().bucket(bucketName).key("my-file").build(), randomFile.toPath).join

val result = client
.getObject(GetObjectRequest.builder().bucket(bucketName).key("my-file").build(),
AsyncResponseTransformer.toBytes[GetObjectResponse]()
)
AsyncResponseTransformer.toBytes[GetObjectResponse]())
.join
result.asUtf8String() should be(fileContent)

Expand All @@ -78,8 +77,7 @@ class ITTestS3 extends AnyWordSpec with Matchers with TestBase {
val fileContent = (0 to 1000000).mkString
val createMultipartUploadResponse = client
.createMultipartUpload(
CreateMultipartUploadRequest.builder().bucket(bucketName).key("bar").contentType("text/plain").build()
)
CreateMultipartUploadRequest.builder().bucket(bucketName).key("bar").contentType("text/plain").build())
.join()

val p1 = client
Expand All @@ -91,8 +89,7 @@ class ITTestS3 extends AnyWordSpec with Matchers with TestBase {
.partNumber(1)
.uploadId(createMultipartUploadResponse.uploadId())
.build(),
AsyncRequestBody.fromString(fileContent)
)
AsyncRequestBody.fromString(fileContent))
.join
val p2 = client
.uploadPart(
Expand All @@ -103,8 +100,7 @@ class ITTestS3 extends AnyWordSpec with Matchers with TestBase {
.partNumber(2)
.uploadId(createMultipartUploadResponse.uploadId())
.build(),
AsyncRequestBody.fromString(fileContent)
)
AsyncRequestBody.fromString(fileContent))
.join

client
Expand All @@ -118,18 +114,14 @@ class ITTestS3 extends AnyWordSpec with Matchers with TestBase {
CompletedMultipartUpload
.builder()
.parts(CompletedPart.builder().partNumber(1).eTag(p1.eTag()).build(),
CompletedPart.builder().partNumber(2).eTag(p2.eTag()).build()
)
.build()
)
.build()
)
CompletedPart.builder().partNumber(2).eTag(p2.eTag()).build())
.build())
.build())
.join

val result = client
.getObject(GetObjectRequest.builder().bucket(bucketName).key("bar").build(),
AsyncResponseTransformer.toBytes[GetObjectResponse]()
)
AsyncResponseTransformer.toBytes[GetObjectResponse]())
.join
result.asUtf8String() should be(fileContent + fileContent)

Expand Down
Loading

0 comments on commit 3ad8f09

Please sign in to comment.