From 3c3e3258ec9f5693ccc470ad545c541d2ba2aae7 Mon Sep 17 00:00:00 2001 From: Seth Tisue Date: Tue, 31 Aug 2021 16:00:19 -0400 Subject: [PATCH 1/2] update headers with sbt-header --- build.sbt | 12 +++++++++--- src/main/scala/scala/async/FutureStateMachine.scala | 1 + src/test/scala/scala/async/ExceptionalTest.scala | 12 ++++++++++++ src/test/scala/scala/async/FutureSpec.scala | 1 + src/test/scala/scala/async/SmokeTest.scala | 1 + src/test/scala/scala/async/TestUtil.scala | 1 + 6 files changed, 25 insertions(+), 3 deletions(-) diff --git a/build.sbt b/build.sbt index 25c20f98..c2c26acd 100644 --- a/build.sbt +++ b/build.sbt @@ -1,7 +1,6 @@ val sharedSettings = ScalaModulePlugin.scalaModuleSettings ++ ScalaModulePlugin.scalaModuleOsgiSettings ++ Seq( name := "scala-async", scalaModuleAutomaticModuleName := Some("scala.async"), - versionPolicyIntention := Compatibility.BinaryAndSourceCompatible, OsgiKeys.exportPackage := Seq(s"scala.async.*;version=${version.value}"), @@ -12,7 +11,7 @@ val sharedSettings = ScalaModulePlugin.scalaModuleSettings ++ ScalaModulePlugin. ScalaModulePlugin.enableOptimizer, testOptions += Tests.Argument(TestFrameworks.JUnit, "-q", "-v", "-s"), Test / scalacOptions ++= Seq("-Yrangepos"), - scalacOptions ++= List("-deprecation" , "-Xasync") + scalacOptions ++= List("-deprecation" , "-Xasync"), ) lazy val proj = crossProject(JSPlatform, JVMPlatform) @@ -20,8 +19,15 @@ lazy val proj = crossProject(JSPlatform, JVMPlatform) .crossType(CrossType.Pure) .in(file(".")) .settings(sharedSettings) + // until we have actually published for Scala.js + .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) +lazy val root = project.in(file(".")) + .settings(sharedSettings) + .aggregate(proj.jvm, proj.js) Global / parallelExecution := false diff --git a/src/main/scala/scala/async/FutureStateMachine.scala b/src/main/scala/scala/async/FutureStateMachine.scala index 7d016541..4c651906 100644 --- a/src/main/scala/scala/async/FutureStateMachine.scala +++ b/src/main/scala/scala/async/FutureStateMachine.scala @@ -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..fcdf5c1a 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. + * + * 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..262d748a 100644 --- a/src/test/scala/scala/async/FutureSpec.scala +++ b/src/test/scala/scala/async/FutureSpec.scala @@ -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..4804893a 100644 --- a/src/test/scala/scala/async/SmokeTest.scala +++ b/src/test/scala/scala/async/SmokeTest.scala @@ -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..11bab02e 100644 --- a/src/test/scala/scala/async/TestUtil.scala +++ b/src/test/scala/scala/async/TestUtil.scala @@ -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} From b6ee2185be2f07a17731466535f5d67dfb3a8692 Mon Sep 17 00:00:00 2001 From: Seth Tisue Date: Tue, 31 Aug 2021 15:48:31 -0400 Subject: [PATCH 2/2] replace Travis-CI with GitHub Actions --- .github/workflows/ci.yml | 23 ++++++++++++ .github/workflows/release.yml | 21 +++++++++++ .travis.yml | 24 ------------- README.md | 14 +++----- build.sbt | 3 ++ build.sh | 66 ----------------------------------- project/plugins.sbt | 2 +- 7 files changed, 53 insertions(+), 100 deletions(-) create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/release.yml delete mode 100644 .travis.yml delete mode 100755 build.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..d64c4b84 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,23 @@ +name: test +on: + push: + branches: + - main + pull_request: +jobs: + test: + strategy: + fail-fast: false + matrix: + java: [8, 11, 17-ea] + scala: [2.12.14, 2.13.6] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: coursier/cache-action@v6 + - uses: actions/setup-java@v2 + with: + distribution: adopt + java-version: ${{matrix.java}} + - name: Test + run: sbt ++${{matrix.scala}} test proj/headerCheck package diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..dc337111 --- /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: adopt + java-version: 8 + - run: sbt 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/README.md b/README.md index f3e5f0e1..3a466548 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. @@ -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 c2c26acd..fd51543c 100644 --- a/build.sbt +++ b/build.sbt @@ -2,6 +2,9 @@ val sharedSettings = ScalaModulePlugin.scalaModuleSettings ++ ScalaModulePlugin. name := "scala-async", scalaModuleAutomaticModuleName := Some("scala.async"), + crossScalaVersions := Seq("2.13.6", "2.12.14"), + scalaVersion := crossScalaVersions.value.head, + OsgiKeys.exportPackage := Seq(s"scala.async.*;version=${version.value}"), libraryDependencies += "org.scala-lang" % "scala-reflect" % scalaVersion.value % "provided", diff --git a/build.sh b/build.sh deleted file mode 100755 index 7b807f8a..00000000 --- a/build.sh +++ /dev/null @@ -1,66 +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" - versionCheckTask="versionCheck" - 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 $versionCheckTask $releaseTask diff --git a/project/plugins.sbt b/project/plugins.sbt index 5d5094e1..7af85ff7 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,3 +1,3 @@ -addSbtPlugin("org.scala-lang.modules" % "sbt-scala-module" % "2.4.0") +addSbtPlugin("org.scala-lang.modules" % "sbt-scala-module" % "3.0.0") addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.7.0") addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.0.0")