From 1145a6c9901b2a7de1559b771c365f56cfb00b37 Mon Sep 17 00:00:00 2001 From: Cody Allen Date: Sun, 20 Jan 2019 10:52:45 -0800 Subject: [PATCH] Attempt to set up sbt-ci-release --- .travis.yml | 49 +++++++----- README.md | 2 +- build.sbt | 138 +++++++++++++++++++++------------- project/plugins.sbt | 1 + readme/src/main/tut/README.md | 2 +- scripts/travis-ci.sh | 22 ------ 6 files changed, 117 insertions(+), 97 deletions(-) delete mode 100755 scripts/travis-ci.sh diff --git a/.travis.yml b/.travis.yml index 4c4daf9..8b76a63 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,28 +1,39 @@ language: scala sudo: false -scala: - - 2.12.6 +jdk: +- oraclejdk8 -sbt_args: "-J-Xmx2G" +before_install: + - git fetch --tags + +stages: + - name: test + - name: release + if: (branch = master AND type = push) OR (tag IS present) jobs: include: - - stage: Documentation - env: PHASE=A - - stage: Unit Tests - env: PHASE=B - - stage: Publish - env: PHASE=C - -script: - - scripts/travis-ci.sh - -after_script: - - find $HOME/.sbt -name "*.lock" | xargs rm - - find $HOME/.ivy2 -name "ivydata-*.properties" | xargs rm + - env: TEST="docs" + script: sbt tut + - env: TEST="test" + script: sbt +test + - env: TEST="coverage" + script: sbt coverage test && sbt coverageReport && bash <(curl -s https://codecov.io/bash) + - stage: release + script: sbt ci-release # These directories are cached to S3 at the end of the build cache: - directories: - - $HOME/.ivy2/cache - - $HOME/.sbt/boot/ +directories: + - $HOME/.sbt/1.0/dependency + - $HOME/.sbt/boot/scala* + - $HOME/.sbt/launchers + - $HOME/.ivy2/cache + - $HOME/.coursier + +before_cache: + - du -h -d 1 $HOME/.ivy2/cache + - du -h -d 2 $HOME/.sbt/ + - find $HOME/.sbt -name "*.lock" -type f -delete + - find $HOME/.ivy2/cache -name "ivydata-*.properties" -type f -delete + - rm -rf $HOME/.ivy2/local diff --git a/README.md b/README.md index 1c8ef38..e47276d 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # irrec -[![Build Status](https://api.travis-ci.org/ceedubs/irrec.svg)](https://travis-ci.org/ceedubs/irrec) +[![Build Status](https://travis-ci.org/ceedubs/irrec.svg?branch=master)](https://travis-ci.org/ceedubs/irrec/branches) [![codecov.io](http://codecov.io/github/ceedubs/irrec/coverage.svg?branch=master)](http://codecov.io/github/ceedubs/irrec?branch=master) An implementation of regular expressions based on recursion schemes and Kleene algebras. diff --git a/build.sbt b/build.sbt index 7853e34..ea61980 100644 --- a/build.sbt +++ b/build.sbt @@ -1,10 +1,19 @@ import dependencies._ -scalaVersion in ThisBuild := "2.12.6" - -organization in ThisBuild := "ceedubs" +inThisBuild(List( + organization := "net.ceedubs", + homepage := Some(url("https://github.com/ceedubs/irrec")), + licenses := List("Apache-2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0")), + developers := List( + Developer( + "ceedubs", + "Cody Allen", + "ceedubs@gmail.com", + url("https://github.com/ceedubs") + ) + ) +)) -version in ThisBuild := "0.1.0-SNAPSHOT" coverageExcludedPackages in ThisBuild := "ceedubs.irrec.bench" @@ -64,59 +73,80 @@ lazy val root = project ).aggregate(kleene, regex, regexGen) // Thanks, Rob! https://tpolecat.github.io/2017/04/25/scalac-flags.html -val scalacOptionSettings: Seq[Setting[_]] = Seq( - scalacOptions ++= Seq( - "-deprecation", // Emit warning and location for usages of deprecated APIs. - "-encoding", "utf-8", // Specify character encoding used by source files. - "-explaintypes", // Explain type errors in more detail. - "-feature", // Emit warning and location for usages of features that should be imported explicitly. - "-language:existentials", // Existential types (besides wildcard types) can be written and inferred - "-language:experimental.macros", // Allow macro definition (besides implementation and application) - "-language:higherKinds", // Allow higher-kinded types - "-language:implicitConversions", // Allow definition of implicit functions called views - "-unchecked", // Enable additional warnings where generated code depends on assumptions. - "-Xcheckinit", // Wrap field accessors to throw an exception on uninitialized access. - "-Xfatal-warnings", // Fail the compilation if there are any warnings. - "-Xfuture", // Turn on future language features. - "-Xlint:adapted-args", // Warn if an argument list is modified to match the receiver. - "-Xlint:by-name-right-associative", // By-name parameter of right associative operator. - "-Xlint:constant", // Evaluation of a constant arithmetic expression results in an error. - "-Xlint:delayedinit-select", // Selecting member of DelayedInit. - "-Xlint:doc-detached", // A Scaladoc comment appears to be detached from its element. - "-Xlint:inaccessible", // Warn about inaccessible types in method signatures. - "-Xlint:infer-any", // Warn when a type argument is inferred to be `Any`. - "-Xlint:missing-interpolator", // A string literal appears to be missing an interpolator id. - "-Xlint:nullary-override", // Warn when non-nullary `def f()' overrides nullary `def f'. - "-Xlint:nullary-unit", // Warn when nullary methods return Unit. - "-Xlint:option-implicit", // Option.apply used implicit view. - "-Xlint:package-object-classes", // Class or object defined in package object. - "-Xlint:poly-implicit-overload", // Parameterized overloaded implicit methods are not visible as view bounds. - "-Xlint:private-shadow", // A private field (or class parameter) shadows a superclass field. - "-Xlint:stars-align", // Pattern sequence wildcard must align with sequence component. - "-Xlint:type-parameter-shadow", // A local type parameter shadows a type already in scope. - "-Xlint:unsound-match", // Pattern match may not be typesafe. - "-Yno-adapted-args", // Do not adapt an argument list (either by inserting () or creating a tuple) to match the receiver. - "-Ypartial-unification", // Enable partial unification in type constructor inference - "-Ywarn-dead-code", // Warn when dead code is identified. - "-Ywarn-extra-implicit", // Warn when more than one implicit parameter section is defined. - "-Ywarn-inaccessible", // Warn about inaccessible types in method signatures. - "-Ywarn-infer-any", // Warn when a type argument is inferred to be `Any`. - "-Ywarn-nullary-override", // Warn when non-nullary `def f()' overrides nullary `def f'. - "-Ywarn-nullary-unit", // Warn when nullary methods return Unit. - "-Ywarn-numeric-widen", // Warn when numerics are widened. - "-Ywarn-unused:implicits", // Warn if an implicit parameter is unused. - "-Ywarn-unused:imports", // Warn if an import selector is not referenced. - "-Ywarn-unused:locals", // Warn if a local definition is unused. - "-Ywarn-unused:params", // Warn if a value parameter is unused. - "-Ywarn-unused:patvars", // Warn if a variable bound in a pattern is unused. - "-Ywarn-unused:privates", // Warn if a private member is unused. - "-Ywarn-value-discard" // Warn when non-Unit expression results are unused. - ), - scalacOptions in (Compile, console) --= Seq("-Ywarn-unused:imports", "-Xfatal-warnings") +val scalac212Options: Seq[String] = Seq( + "-deprecation", // Emit warning and location for usages of deprecated APIs. + "-encoding", "utf-8", // Specify character encoding used by source files. + "-explaintypes", // Explain type errors in more detail. + "-feature", // Emit warning and location for usages of features that should be imported explicitly. + "-language:existentials", // Existential types (besides wildcard types) can be written and inferred + "-language:experimental.macros", // Allow macro definition (besides implementation and application) + "-language:higherKinds", // Allow higher-kinded types + "-language:implicitConversions", // Allow definition of implicit functions called views + "-unchecked", // Enable additional warnings where generated code depends on assumptions. + "-Xcheckinit", // Wrap field accessors to throw an exception on uninitialized access. + "-Xfatal-warnings", // Fail the compilation if there are any warnings. + "-Xfuture", // Turn on future language features. + "-Xlint:adapted-args", // Warn if an argument list is modified to match the receiver. + "-Xlint:by-name-right-associative", // By-name parameter of right associative operator. + "-Xlint:constant", // Evaluation of a constant arithmetic expression results in an error. + "-Xlint:delayedinit-select", // Selecting member of DelayedInit. + "-Xlint:doc-detached", // A Scaladoc comment appears to be detached from its element. + "-Xlint:inaccessible", // Warn about inaccessible types in method signatures. + "-Xlint:infer-any", // Warn when a type argument is inferred to be `Any`. + "-Xlint:missing-interpolator", // A string literal appears to be missing an interpolator id. + "-Xlint:nullary-override", // Warn when non-nullary `def f()' overrides nullary `def f'. + "-Xlint:nullary-unit", // Warn when nullary methods return Unit. + "-Xlint:option-implicit", // Option.apply used implicit view. + "-Xlint:package-object-classes", // Class or object defined in package object. + "-Xlint:poly-implicit-overload", // Parameterized overloaded implicit methods are not visible as view bounds. + "-Xlint:private-shadow", // A private field (or class parameter) shadows a superclass field. + "-Xlint:stars-align", // Pattern sequence wildcard must align with sequence component. + "-Xlint:type-parameter-shadow", // A local type parameter shadows a type already in scope. + "-Xlint:unsound-match", // Pattern match may not be typesafe. + "-Yno-adapted-args", // Do not adapt an argument list (either by inserting () or creating a tuple) to match the receiver. + "-Ypartial-unification", // Enable partial unification in type constructor inference + "-Ywarn-dead-code", // Warn when dead code is identified. + "-Ywarn-extra-implicit", // Warn when more than one implicit parameter section is defined. + "-Ywarn-inaccessible", // Warn about inaccessible types in method signatures. + "-Ywarn-infer-any", // Warn when a type argument is inferred to be `Any`. + "-Ywarn-nullary-override", // Warn when non-nullary `def f()' overrides nullary `def f'. + "-Ywarn-nullary-unit", // Warn when nullary methods return Unit. + "-Ywarn-numeric-widen", // Warn when numerics are widened. + "-Ywarn-unused:implicits", // Warn if an implicit parameter is unused. + "-Ywarn-unused:imports", // Warn if an import selector is not referenced. + "-Ywarn-unused:locals", // Warn if a local definition is unused. + "-Ywarn-unused:params", // Warn if a value parameter is unused. + "-Ywarn-unused:patvars", // Warn if a variable bound in a pattern is unused. + "-Ywarn-unused:privates", // Warn if a private member is unused. + "-Ywarn-value-discard" // Warn when non-Unit expression results are unused. ) +val scalac211Options: Seq[String] = { + val exclusions = Set( + "-Xlint:constant", + "-Ywarn-extra-implicit" + ) + scalac212Options.filter(s => + !s.startsWith("-Ywarn-unused") && + !exclusions.contains(s)) +} + +val scalacOptionSettings: Seq[Setting[_]] = { + def baseScalaCOptions(scalaVersion: String) = CrossVersion.partialVersion(scalaVersion) match { + case Some((2, 11)) => scalac211Options + case _ => scalac212Options + } + + Seq( + scalacOptions ++= baseScalaCOptions(scalaVersion.value), + scalacOptions in (Compile, console) --= Seq("-Ywarn-unused:imports", "-Xfatal-warnings") + ) +} + val commonSettings: Seq[Setting[_]] = Seq( - addCompilerPlugin("org.spire-math" %% "kind-projector" % "0.9.7") + addCompilerPlugin("org.spire-math" %% "kind-projector" % "0.9.7"), + scalaVersion := "2.12.8", + crossScalaVersions := List("2.11.12", "2.12.8") ) ++ scalacOptionSettings val noPublishSettings = Seq( diff --git a/project/plugins.sbt b/project/plugins.sbt index 3ccfc9a..b82295a 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -2,3 +2,4 @@ addSbtPlugin("io.get-coursier" % "sbt-coursier" % "1.0.3") addSbtPlugin("org.tpolecat" % "tut-plugin" % "0.6.7") addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.5.1") addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.3.4") +addSbtPlugin("com.geirsson" % "sbt-ci-release" % "1.2.1") diff --git a/readme/src/main/tut/README.md b/readme/src/main/tut/README.md index 4510b9b..209bbf8 100644 --- a/readme/src/main/tut/README.md +++ b/readme/src/main/tut/README.md @@ -1,6 +1,6 @@ # irrec -[![Build Status](https://api.travis-ci.org/ceedubs/irrec.svg)](https://travis-ci.org/ceedubs/irrec) +[![Build Status](https://travis-ci.org/ceedubs/irrec.svg?branch=master)](https://travis-ci.org/ceedubs/irrec/branches) [![codecov.io](http://codecov.io/github/ceedubs/irrec/coverage.svg?branch=master)](http://codecov.io/github/ceedubs/irrec?branch=master) An implementation of regular expressions based on recursion schemes and Kleene algebras. diff --git a/scripts/travis-ci.sh b/scripts/travis-ci.sh deleted file mode 100755 index 808752d..0000000 --- a/scripts/travis-ci.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/bash - -# Taken + modified from typelevel/frameless - -export publish_cmd="publishLocal" - -sbt_cmd="sbt ++$TRAVIS_SCALA_VERSION -Dfile.encoding=UTF8 -J-XX:ReservedCodeCacheSize=256M" - -case "$PHASE" in - A) - docs_cmd="$sbt_cmd tut" - run_cmd="$docs_cmd" - ;; - B) - coverage="$sbt_cmd coverage test && sbt coverageReport && bash <(curl -s https://codecov.io/bash)" - run_cmd="$coverage" - ;; - C) - run_cmd="$sbt_cmd clean $publish_cmd" - ;; -esac -eval $run_cmd