diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..e01e4404 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,26 @@ +name: test +on: + push: + branches: + - main + pull_request: +jobs: + test: + strategy: + fail-fast: false + matrix: + java: [8, 11, 17] + scala: [2.12.x, 2.13.x] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + - uses: coursier/cache-action@v6 + - uses: actions/setup-java@v2 + with: + distribution: temurin + java-version: ${{matrix.java}} + - uses: sbt/setup-sbt@v1 + - name: Test + run: sbt ++${{matrix.scala}} test proj/headerCheck package diff --git a/.github/workflows/cla.yml b/.github/workflows/cla.yml new file mode 100644 index 00000000..3549dedc --- /dev/null +++ b/.github/workflows/cla.yml @@ -0,0 +1,11 @@ +name: "Check Scala CLA" +on: + pull_request: +jobs: + cla-check: + runs-on: ubuntu-latest + steps: + - name: Verify CLA + uses: scala/cla-checker@v1 + with: + author: ${{ github.event.pull_request.user.login }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..0123f96b --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,21 @@ +name: Release +on: + push: + tags: ["*"] +jobs: + publish: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + - uses: actions/setup-java@v2 + with: + distribution: temurin + java-version: 8 + - run: sbt proj/versionCheck ci-release + env: + PGP_PASSPHRASE: ${{secrets.PGP_PASSPHRASE}} + PGP_SECRET: ${{secrets.PGP_SECRET}} + SONATYPE_PASSWORD: ${{secrets.SONATYPE_PASSWORD}} + SONATYPE_USERNAME: ${{secrets.SONATYPE_USERNAME}} diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 8404aaeb..00000000 --- a/.travis.yml +++ /dev/null @@ -1,24 +0,0 @@ -version: ~> 1.0 # needed for imports - -import: scala/scala-dev:travis/default.yml - -language: scala - -scala: - - 2.12.14 - - 2.13.6 - -env: - - ADOPTOPENJDK=8 - - ADOPTOPENJDK=11 - - ADOPTOPENJDK=17 - -install: - - git fetch --tags # get all tags for sbt-dynver - -script: ./build.sh - -notifications: - email: - - jason.zaugg@lightbend.com - - seth.tisue@lightbend.com diff --git a/NOTICE b/NOTICE index f89d67de..c0e32e62 100644 --- a/NOTICE +++ b/NOTICE @@ -1,10 +1,10 @@ Scala async -Copyright (c) 2012-2021 EPFL -Copyright (c) 2012-2021 Lightbend, Inc. +Copyright (c) 2012-2025 EPFL +Copyright (c) 2012-2025 Lightbend, Inc. dba Akka Scala includes software developed at LAMP/EPFL (https://lamp.epfl.ch/) and -Lightbend, Inc. (https://www.lightbend.com/). +Akka (https://akka.io/). Licensed under the Apache License, Version 2.0 (the "License"). Unless required by applicable law or agreed to in writing, software diff --git a/README.md b/README.md index f3e5f0e1..5678bac4 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,8 @@ -# scala-async [![Build Status](https://travis-ci.org/scala/scala-async.svg?branch=master)](https://travis-ci.org/scala/scala-async) [](http://search.maven.org/#search%7Cga%7C1%7Cg%3Aorg.scala-lang.modules%20a%3Ascala-async_2.12) [](http://search.maven.org/#search%7Cga%7C1%7Cg%3Aorg.scala-lang.modules%20a%3Ascala-async_2.13) +# scala-async [](http://search.maven.org/#search%7Cga%7C1%7Cg%3Aorg.scala-lang.modules%20a%3Ascala-async_2.12) [](http://search.maven.org/#search%7Cga%7C1%7Cg%3Aorg.scala-lang.modules%20a%3Ascala-async_2.13) -A DSL to enable a direct style of programming with when composing values wrapped in Scala `Future`s. +A Scala DSL to enable a direct style of coding when composing `Future`s. -## Quick start - -To include scala-async in an existing project use the library published on Maven Central. -For sbt projects add the following to your build definition - build.sbt or project/Build.scala: - -### Use a modern Scala compiler +## Usage As of scala-async 1.0, Scala 2.12.12+ or 2.13.3+ are required. @@ -16,7 +11,7 @@ As of scala-async 1.0, Scala 2.12.12+ or 2.13.3+ are required. #### SBT Example ```scala -libraryDependencies += "org.scala-lang.modules" %% "scala-async" % "0.10.0" +libraryDependencies += "org.scala-lang.modules" %% "scala-async" % "1.0.1" libraryDependencies += "org.scala-lang" % "scala-reflect" % scalaVersion.value % Provided ``` @@ -29,12 +24,12 @@ to match your project’s Scala binary version): org.scala-lang.modules scala-async_2.13 - 1.0.0 + 1.0.1 org.scala-lang scala-reflect - 2.13.6 + 2.13.8 provided ``` @@ -44,6 +39,7 @@ to match your project’s Scala binary version): Add the `-Xasync` to the Scala compiler options. #### SBT Example + ```scala scalacOptions += "-Xasync" ``` @@ -133,7 +129,7 @@ def combined: Future[Int] = async { ### `await` must be directly in the control flow of the async expression -The `await` cannot be nested under a local method, object, class or lambda: +The `await` cannot be nested under a local method, object, class or lambda: ``` async { diff --git a/build.sbt b/build.sbt index 1f17478b..94953efd 100644 --- a/build.sbt +++ b/build.sbt @@ -1,17 +1,38 @@ -ScalaModulePlugin.scalaModuleSettings -ScalaModulePlugin.scalaModuleOsgiSettings +val sharedSettings = ScalaModulePlugin.scalaModuleSettings ++ ScalaModulePlugin.scalaModuleOsgiSettings ++ Seq( + name := "scala-async", + scalaModuleAutomaticModuleName := Some("scala.async"), -name := "scala-async" -scalaModuleAutomaticModuleName := Some("scala.async") + crossScalaVersions := Seq("2.13.16", "2.12.20"), + scalaVersion := crossScalaVersions.value.head, -libraryDependencies += "org.scala-lang" % "scala-reflect" % scalaVersion.value % "provided" -libraryDependencies += "junit" % "junit" % "4.13.2" % Test -libraryDependencies += "com.novocode" % "junit-interface" % "0.11" % Test + OsgiKeys.exportPackage := Seq(s"scala.async.*;version=${version.value}"), -ScalaModulePlugin.enableOptimizer -testOptions += Tests.Argument(TestFrameworks.JUnit, "-q", "-v", "-s") -Test / scalacOptions ++= Seq("-Yrangepos") -scalacOptions ++= List("-deprecation" , "-Xasync") + libraryDependencies += "org.scala-lang" % "scala-reflect" % scalaVersion.value % "provided", + libraryDependencies += "junit" % "junit" % "4.13.2" % Test, + libraryDependencies += "com.github.sbt" % "junit-interface" % "0.13.3" % Test, + + ScalaModulePlugin.enableOptimizer, + testOptions += Tests.Argument(TestFrameworks.JUnit, "-q", "-v", "-s"), + Test / scalacOptions ++= Seq("-Yrangepos"), + scalacOptions ++= List("-deprecation" , "-Xasync"), +) + +lazy val proj = crossProject(JSPlatform, JVMPlatform) + .withoutSuffixFor(JVMPlatform) + .crossType(CrossType.Pure) + .in(file(".")) + .settings(sharedSettings) + .jvmEnablePlugins(SbtOsgi) + // until we have actually published for Scala.js. this is also why, + // for now, release.yml does just `proj/versionCheck` instead of `versionCheck` + .jvmSettings(versionPolicyIntention := Compatibility.BinaryAndSourceCompatible) + .jsSettings(versionPolicyIntention := Compatibility.None) + // override sbt-scala-module default (which is unsuitable for Scala.js) + .jsSettings(Test / fork := false) + +lazy val root = project.in(file(".")) + .settings(sharedSettings) + .aggregate(proj.jvm, proj.js) Global / parallelExecution := false @@ -41,7 +62,6 @@ pomExtra := ( ) -OsgiKeys.exportPackage := Seq(s"scala.async.*;version=${version.value}") commands += testDeterminism diff --git a/build.sh b/build.sh deleted file mode 100755 index 65cc465d..00000000 --- a/build.sh +++ /dev/null @@ -1,65 +0,0 @@ -#!/bin/bash - -set -e - -# Builds of tagged revisions are published to sonatype staging. - -# Travis runs a build on new revisions and on new tags, so a tagged revision is built twice. -# Builds for a tag have TRAVIS_TAG defined, which we use for identifying tagged builds. - -# sbt-dynver sets the version number from the tag -# sbt-travisci sets the Scala version from the travis job matrix - -# When a new binary incompatible Scala version becomes available, a previously released version -# can be released using that new Scala version by creating a new tag containing the Scala version -# after a hash, e.g., v1.2.3#2.13.0-M3. - -# For normal tags that are cross-built, we release on JDK 8 for Scala 2.x -isReleaseJob() { - if [[ "$ADOPTOPENJDK" == "8" ]]; then - true - else - false - fi -} - -# For tags that define a Scala version, we pick the jobs of one Scala version (2.13.x) to do the releases -isTagScalaReleaseJob() { - if [[ "$ADOPTOPENJDK" == "8" && "$TRAVIS_SCALA_VERSION" =~ ^2\.13\.[0-9]+$ ]]; then - true - else - false - fi -} - -verPat="[0-9]+\.[0-9]+\.[0-9]+(-[A-Za-z0-9-]+)?" -tagPat="^v$verPat(#$verPat)?$" - -if [[ "$TRAVIS_TAG" =~ $tagPat ]]; then - releaseTask="ci-release" - tagScalaVer=$(echo $TRAVIS_TAG | sed s/[^#]*// | sed s/^#//) - if [[ "$tagScalaVer" == "" ]]; then - if ! isReleaseJob; then - echo "Not releasing on Java $ADOPTOPENJDK with Scala $TRAVIS_SCALA_VERSION" - exit 0 - fi - else - if isTagScalaReleaseJob; then - setTagScalaVersion='set every scalaVersion := "'$tagScalaVer'"' - else - echo "The releases for Scala $tagScalaVer are built by other jobs in the travis job matrix" - exit 0 - fi - fi -fi - -# default is +publishSigned; we cross-build with travis jobs, not sbt's crossScalaVersions -export CI_RELEASE="publishSigned" -export CI_SNAPSHOT_RELEASE="publish" - -# default is sonatypeBundleRelease, which closes and releases the staging repo -# see https://github.com/xerial/sbt-sonatype#commands -# for now, until we're confident in the new release scripts, just close the staging repo. -export CI_SONATYPE_RELEASE="; sonatypePrepare; sonatypeBundleUpload; sonatypeClose" - -sbt "$setTagScalaVersion" clean test publishLocal $releaseTask diff --git a/project/build.properties b/project/build.properties index 9edb75b7..6520f698 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=1.5.4 +sbt.version=1.11.0 diff --git a/project/plugins.sbt b/project/plugins.sbt index 33d01074..d228ee37 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1 +1,3 @@ -addSbtPlugin("org.scala-lang.modules" % "sbt-scala-module" % "2.3.1") +addSbtPlugin("org.scala-lang.modules" % "sbt-scala-module" % "3.2.2") +addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.19.0") +addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.3.2") diff --git a/src/main/scala/scala/async/Async.scala b/src/main/scala/scala/async/Async.scala index b4399e15..b592f0ad 100644 --- a/src/main/scala/scala/async/Async.scala +++ b/src/main/scala/scala/async/Async.scala @@ -1,7 +1,7 @@ /* * Scala (https://www.scala-lang.org) * - * Copyright EPFL and Lightbend, Inc. + * Copyright EPFL and Lightbend, Inc. dba Akka * * Licensed under Apache License 2.0 * (http://www.apache.org/licenses/LICENSE-2.0). diff --git a/src/main/scala/scala/async/FutureStateMachine.scala b/src/main/scala/scala/async/FutureStateMachine.scala index 7d016541..8b8c5cfb 100644 --- a/src/main/scala/scala/async/FutureStateMachine.scala +++ b/src/main/scala/scala/async/FutureStateMachine.scala @@ -1,7 +1,7 @@ /* * Scala (https://www.scala-lang.org) * - * Copyright EPFL and Lightbend, Inc. + * Copyright EPFL and Lightbend, Inc. dba Akka * * Licensed under Apache License 2.0 * (http://www.apache.org/licenses/LICENSE-2.0). @@ -9,6 +9,7 @@ * See the NOTICE file distributed with this work for * additional information regarding copyright ownership. */ + package scala.async import java.util.Objects diff --git a/src/test/scala/scala/async/ExceptionalTest.scala b/src/test/scala/scala/async/ExceptionalTest.scala index 67751027..1caf1341 100644 --- a/src/test/scala/scala/async/ExceptionalTest.scala +++ b/src/test/scala/scala/async/ExceptionalTest.scala @@ -1,3 +1,15 @@ +/* + * Scala (https://www.scala-lang.org) + * + * Copyright EPFL and Lightbend, Inc. dba Akka + * + * Licensed under Apache License 2.0 + * (http://www.apache.org/licenses/LICENSE-2.0). + * + * See the NOTICE file distributed with this work for + * additional information regarding copyright ownership. + */ + package scala.async import java.util.concurrent.atomic.AtomicReference diff --git a/src/test/scala/scala/async/FutureSpec.scala b/src/test/scala/scala/async/FutureSpec.scala index 794be3f9..9713b816 100644 --- a/src/test/scala/scala/async/FutureSpec.scala +++ b/src/test/scala/scala/async/FutureSpec.scala @@ -1,7 +1,7 @@ /* * Scala (https://www.scala-lang.org) * - * Copyright EPFL and Lightbend, Inc. + * Copyright EPFL and Lightbend, Inc. dba Akka * * Licensed under Apache License 2.0 * (http://www.apache.org/licenses/LICENSE-2.0). @@ -9,6 +9,7 @@ * See the NOTICE file distributed with this work for * additional information regarding copyright ownership. */ + package scala.async import java.util.concurrent.ConcurrentHashMap diff --git a/src/test/scala/scala/async/SmokeTest.scala b/src/test/scala/scala/async/SmokeTest.scala index 204481d1..b04dbdb8 100644 --- a/src/test/scala/scala/async/SmokeTest.scala +++ b/src/test/scala/scala/async/SmokeTest.scala @@ -1,7 +1,7 @@ /* * Scala (https://www.scala-lang.org) * - * Copyright EPFL and Lightbend, Inc. + * Copyright EPFL and Lightbend, Inc. dba Akka * * Licensed under Apache License 2.0 * (http://www.apache.org/licenses/LICENSE-2.0). @@ -9,6 +9,7 @@ * See the NOTICE file distributed with this work for * additional information regarding copyright ownership. */ + package scala.async import org.junit.{Assert, Test} diff --git a/src/test/scala/scala/async/TestUtil.scala b/src/test/scala/scala/async/TestUtil.scala index ff91aca5..57624671 100644 --- a/src/test/scala/scala/async/TestUtil.scala +++ b/src/test/scala/scala/async/TestUtil.scala @@ -1,7 +1,7 @@ /* * Scala (https://www.scala-lang.org) * - * Copyright EPFL and Lightbend, Inc. + * Copyright EPFL and Lightbend, Inc. dba Akka * * Licensed under Apache License 2.0 * (http://www.apache.org/licenses/LICENSE-2.0). @@ -9,6 +9,7 @@ * See the NOTICE file distributed with this work for * additional information regarding copyright ownership. */ + package scala.async import java.util.concurrent.{CountDownLatch, TimeUnit}