Skip to content

Commit

Permalink
Merge pull request #97 from dvgica/add-scala-3-support
Browse files Browse the repository at this point in the history
Add scala 3 support
  • Loading branch information
dvgica authored Jul 6, 2022
2 parents ec24a1e + a2f87d9 commit 6165c21
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 13 deletions.
12 changes: 11 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
scala: [2.13.8, 2.12.16]
scala: [2.13.8, 2.12.16, 3.0.2]
java: [temurin@8]
runs-on: ${{ matrix.os }}
steps:
Expand Down Expand Up @@ -124,6 +124,16 @@ jobs:
tar xf targets.tar
rm targets.tar
- name: Download target directories (3.0.2)
uses: actions/download-artifact@v2
with:
name: target-${{ matrix.os }}-3.0.2-${{ matrix.java }}

- name: Inflate target directories (3.0.2)
run: |
tar xf targets.tar
rm targets.tar
- env:
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
PGP_SECRET: ${{ secrets.PGP_SECRET }}
Expand Down
2 changes: 2 additions & 0 deletions .mergify.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
queue_rules:
- name: dependency-update
conditions:
- check-success=Build and Test (ubuntu-latest, 3.0.2, temurin@8)
- check-success=Build and Test (ubuntu-latest, 2.13.8, temurin@8)
- check-success=Build and Test (ubuntu-latest, 2.12.16, temurin@8)

pull_request_rules:
- name: Merge using the merge queue
conditions:
- base=main
- check-success=Build and Test (ubuntu-latest, 3.0.2, temurin@8)
- check-success=Build and Test (ubuntu-latest, 2.13.8, temurin@8)
- check-success=Build and Test (ubuntu-latest, 2.12.16, temurin@8)
- author=scala-steward
Expand Down
10 changes: 2 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,14 @@ None of the ideas in the lib are particularly novel (see [Related Libraries](#re

## Installation

Managerial is available on Maven Central for Scala 2.12 and 2.13. There are two artifacts:
Managerial is available on Maven Central for Scala 2.12, 2.13, and 3. There are two artifacts:
- `managerial`, which provides core functionality
- `managerial-twitter-util`, which provides [compatibility](#compatibility-with-twitter-util-managed) with Twitter Util's `Managed`

Add the following dependency description to your build.sbt:

`"ca.dvgi" %% "managerial" % "<latest>"`

For usage from a Scala 3 project, use:

`("ca.dvgi" %% "managerial" % "<latest>").cross(CrossVersion.for3Use2_13)`

as detailed in the [Scala 3 Migration Guide](https://docs.scala-lang.org/scala3/guides/migration/compatibility-classpath.html).

## Usage

`Managed[T]` instances are created via `Managed#apply`, `Managed#setup`, or `Managed#from`. Additionally, arbitrary actions can be made into `Managed[Unit]` instances via various `Managed#eval` methods.
Expand Down Expand Up @@ -170,7 +164,7 @@ Unlike the Twitter Util library, Managerial:
Managerial is also quite similar to [Scala ARM](https://github.com/jsuereth/scala-arm).

Unlike Scala ARM, Managerial:
- is (officially) published for Scala 2.13 (and usable from 3.0)
- is (officially) published for Scala 2.13 and 3
- lacks some of the "fancy" features, like Delimited Continuation style, reflection-based teardown, or JTA transaction support

### Scala Stdlib `Using`
Expand Down
7 changes: 5 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@ inThisBuild(

val scala212Version = "2.12.16"
val scala213Version = "2.13.8"
val scala3Version = "3.0.2"
val scalaVersions =
Seq(
scala213Version,
scala212Version
scala212Version,
scala3Version
)

def subproject(name: String) = Project(
Expand All @@ -39,7 +41,7 @@ lazy val managerialTwitterUtil =
subproject("managerial-twitter-util")
.dependsOn(managerial)
.settings(
libraryDependencies += "com.twitter" %% "util-core" % "22.4.0" % Provided
libraryDependencies += "com.twitter" %% "util-core" % "22.4.0" % Provided exclude ("org.scala-lang.modules", "scala-collection-compat_3")
)

lazy val root = project
Expand All @@ -50,6 +52,7 @@ lazy val root = project
)
.settings(
publish / skip := true,
crossScalaVersions := Nil,
sonatypeCredentialHost := "s01.oss.sonatype.org",
sonatypeRepository := "https://s01.oss.sonatype.org/service/local"
)
Expand Down
1 change: 1 addition & 0 deletions managerial/src/main/scala-3
Original file line number Diff line number Diff line change
Expand Up @@ -359,17 +359,18 @@ class ManagedTest extends munit.FunSuite {

test("Managed.sequence exception in teardown") {
val tr1 = new TestResource
val tr2 = new TestResource
val e = new RuntimeException("test")

val trs =
List(Managed(tr1)(_.teardown()), Managed.evalTeardown(throw e))
List(Managed(tr1)(_.teardown()), Managed(tr2)(_ => throw e))

val mtrs = Managed.sequence(trs)

assert(!tr1.tornDown)

val r = mtrs.build()
val expected: List[Any] = List(tr1, ())
val expected = List(tr1, tr2)
assertEquals(r.get, expected)

interceptMessage[RuntimeException](e.getMessage) {
Expand Down

0 comments on commit 6165c21

Please sign in to comment.