Skip to content

Commit

Permalink
Demonstration
Browse files Browse the repository at this point in the history
  • Loading branch information
travisbrown committed Jun 24, 2015
1 parent d21b5b3 commit 4b2e427
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 9 deletions.
15 changes: 13 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# This is necessary until https://github.com/travis-ci/travis-ci/issues/3120 is
# fixed
sudo: required

language: scala

# These directories are cached to S3 at the end of the build
cache:
directories:
- $HOME/.ivy2/cache
- $HOME/.sbt/boot/scala-$TRAVIS_SCALA_VERSION

scala:
- 2.10.5
- 2.11.6
Expand All @@ -13,6 +23,7 @@ jdk:
before_script:
# default $SBT_OPTS is irrelevant to sbt lancher
- unset SBT_OPTS
- travis_retry ./sbt ++$TRAVIS_SCALA_VERSION update

script:
- ./sbt ++$TRAVIS_SCALA_VERSION test
script: ./sbt ++$TRAVIS_SCALA_VERSION coverage test && ./sbt ++$TRAVIS_SCALA_VERSION coverageAggregate
after_success: ./sbt ++$TRAVIS_SCALA_VERSION coveralls
19 changes: 13 additions & 6 deletions README.markdown → README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
A bunch of idiomatic, small General Purpose tools.
# Twitter Util

[![Build Status](https://secure.travis-ci.org/twitter/util.png?branch=master)](https://travis-ci.org/twitter/util)
[![Build status](https://travis-ci.org/travisbrown/util.svg?branch=develop)](https://travis-ci.org/travisbrown/util)
[![Coverage status](https://img.shields.io/coveralls/travisbrown/util/develop.svg)](https://coveralls.io/r/travisbrown/util?branch=develop)
[![Project status](https://img.shields.io/badge/status-active-brightgreen.svg)](#status)

See the Scaladoc [here](https://twitter.github.com/util)
A bunch of idiomatic, small, general purpose tools.

# Using in your Project
See the Scaladoc [here](https://twitter.github.com/util).

Pre-compiled jars for each set of tools (`util-core`, `util-collection` etc) are available in the Twitter Maven repository, here: http://maven.twttr.com/
## Status

We use [Semantic Versioning](http://semver.org/) for published artifacts.
This project is used in production at Twitter (and many other organizations),
and is being actively developed and maintained. Please note that some
sub-projects (including util-eval), classes, and methods may be deprecated,
however.

# Using in your project

An example SBT dependency string for the `util-collection` tools would look like this:

Expand Down
8 changes: 8 additions & 0 deletions project/Build.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import sbt.Keys._
import sbt._
import pl.project13.scala.sbt.JmhPlugin
import sbtunidoc.Plugin.unidocSettings
import scoverage.ScoverageSbtPlugin

object Util extends Build {
val branch = Process("git" :: "rev-parse" :: "--abbrev-ref" :: "HEAD" :: Nil).!!.trim
Expand Down Expand Up @@ -50,6 +51,13 @@ object Util extends Build {

resolvers += "twitter repo" at "http://maven.twttr.com",

ScoverageSbtPlugin.ScoverageKeys.coverageHighlighting := (
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, 10)) => false
case _ => true
}
),

publishM2Configuration <<= (packagedArtifacts, checksums in publish, ivyLoggingLevel) map { (arts, cs, level) =>
Classpaths.publishConfig(arts, None, resolverName = m2Repo.name, checksums = cs, logging = level)
},
Expand Down
6 changes: 5 additions & 1 deletion project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,8 @@ resolvers <<= (resolvers) { r =>

externalResolvers <<= (resolvers) map identity

addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.2.0")
resolvers += Classpaths.sbtPluginReleases

addSbtPlugin("org.scoverage" % "sbt-coveralls" % "1.0.0")
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.0.4")
addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.2.0")
28 changes: 28 additions & 0 deletions util-thrift/src/test/scala/com/twitter/util/ThriftCodecTest.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.twitter.util

import org.junit.runner.RunWith
import org.scalatest.FunSuite
import org.scalatest.junit.JUnitRunner

@RunWith(classOf[JUnitRunner])
class ThriftCodecTest extends FunSuite {

private def roundTrip(codec: ThriftCodec[TestThriftStructure, _]): Unit = {
val struct = new TestThriftStructure("aString", 5)
val encoded: Array[Byte] = codec.encode(struct)
val decoded: TestThriftStructure = codec.decode(encoded)

assert(decoded === struct)
}

test("BinaryThriftCodec") {
val codec = new BinaryThriftCodec[TestThriftStructure]()
roundTrip(codec)
}

test("CompactThriftCodec") {
val codec = new CompactThriftCodec[TestThriftStructure]()
roundTrip(codec)
}

}

0 comments on commit 4b2e427

Please sign in to comment.