Skip to content

Commit

Permalink
Initial Baseline
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristopherDavenport committed Sep 6, 2019
0 parents commit f06195b
Show file tree
Hide file tree
Showing 18 changed files with 706 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
target/
.idea/
# vim
*.sw?

# Ignore [ce]tags files
tags

.bloop
.metals
25 changes: 25 additions & 0 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# tune this file as appropriate to your style! see: https://olafurpg.github.io/scalafmt/#Configuration

maxColumn = 100

continuationIndent.callSite = 2

newlines {
sometimesBeforeColonInMethodReturnType = false
}

align {
arrowEnumeratorGenerator = false
ifWhileOpenParen = false
openParenCallSite = false
openParenDefnSite = false

tokens = ["%", "%%"]
}

docstrings = JavaDoc

rewrite {
rules = [SortImports, RedundantBraces]
redundantBraces.maxLines = 1
}
33 changes: 33 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
sudo: false
language: scala

scala:
- 2.12.8
- 2.11.12

jdk:
- openjdk11

before_install:
- export PATH=${PATH}:./vendor/bundle

install:
- rvm use 2.6.0 --install --fuzzy
- gem update --system
- gem install sass
- gem install jekyll -v 3.2.1

script:
- sbt ++$TRAVIS_SCALA_VERSION test
- sbt ++$TRAVIS_SCALA_VERSION mimaReportBinaryIssues
- sbt ++$TRAVIS_SCALA_VERSION docs/makeMicrosite

after_success:
- test $TRAVIS_PULL_REQUEST == "false" && test $TRAVIS_BRANCH == "master" && test $TRAVIS_REPO_SLUG == "ChristopherDavenport/github" && sbt ++$TRAVIS_SCALA_VERSION publish
- test $TRAVIS_PULL_REQUEST == "false" && test $TRAVIS_BRANCH == "master" && test $TRAVIS_REPO_SLUG == "ChristopherDavenport/github" && test $TRAVIS_SCALA_VERSION == "2.12.8" && sbt docs/publishMicrosite

cache:
directories:
- $HOME/.ivy2/cache
- $HOME/.coursier/cache
- $HOME/.sbt
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# changelog

This file summarizes **notable** changes for each release, but does not describe internal changes unless they are particularly exciting. This change log is ordered chronologically, so each release contains all changes described below it.

----

## <a name="Unreleased"></a>Unreleased Changes
13 changes: 13 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Code of Conduct

We are committed to providing a friendly, safe and welcoming environment for all, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, religion, nationality, or other such characteristics.

Everyone is expected to follow the [Scala Code of Conduct] when discussing the project on the available communication channels. If you are being harassed, please contact us immediately so that we can support you.

## Moderation

Any questions, concerns, or moderation requests please contact a member of the project.

- [Christopher Davenport](mailto:[email protected])

[Scala Code of Conduct]: https://www.scala-lang.org/conduct/
7 changes: 7 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Copyright 2019 Christopher Davenport

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# github - Github Integration for Scala [![Build Status](https://travis-ci.com/ChristopherDavenport/github.svg?branch=master)](https://travis-ci.com/ChristopherDavenport/github) [![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.chrisdavenport/github_2.12/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.chrisdavenport/github_2.12) ![Code of Consuct](https://img.shields.io/badge/Code%20of%20Conduct-Scala-blue.svg)

## [Head on over to the microsite](https://ChristopherDavenport.github.io/github)

## Quick Start

To use github in an existing SBT project with Scala 2.11 or a later version, add the following dependencies to your
`build.sbt` depending on your needs:

```scala
libraryDependencies ++= Seq(
"io.chrisdavenport" %% "github" % "<version>"
)
```
252 changes: 252 additions & 0 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,252 @@
import sbtcrossproject.CrossPlugin.autoImport.{crossProject, CrossType}

lazy val `github` = project.in(file("."))
.disablePlugins(MimaPlugin)
.settings(commonSettings, releaseSettings, skipOnPublishSettings)
.aggregate(core)

lazy val core = project.in(file("core"))
.enablePlugins(BuildInfoPlugin)
.settings(commonSettings, releaseSettings, mimaSettings)
.settings(
name := "github",
buildInfoKeys := Seq[BuildInfoKey](version),
buildInfoPackage := "io.chrisdavenport.github"
)

lazy val docs = project.in(file("docs"))
.disablePlugins(MimaPlugin)
.settings(commonSettings, skipOnPublishSettings, micrositeSettings)
.dependsOn(core)
.enablePlugins(MicrositesPlugin)
.enablePlugins(TutPlugin)

lazy val contributors = Seq(
"ChristopherDavenport" -> "Christopher Davenport"
)

val catsV = "2.0.0-RC2"
val catsEffectV = "2.0.0-RC2"
val fs2V = "1.1.0-M1"
val http4sV = "0.21.0-M4"
val circeV = "0.12.0-RC4"
val log4catsV = "1.0.0-RC3"

val specs2V = "4.7.0"

val kindProjectorV = "0.10.3"
val betterMonadicForV = "0.3.1"

// General Settings
lazy val commonSettings = Seq(
organization := "io.chrisdavenport",

scalaVersion := "2.13.0",
crossScalaVersions := Seq(scalaVersion.value, "2.12.9"),

scalacOptions in (Compile, doc) ++= Seq(
"-groups",
"-sourcepath", (baseDirectory in LocalRootProject).value.getAbsolutePath,
"-doc-source-url", "https://github.com/ChristopherDavenport/github/blob/v" + version.value + "€{FILE_PATH}.scala"
),

addCompilerPlugin("org.typelevel" % "kind-projector" % kindProjectorV cross CrossVersion.binary),
addCompilerPlugin("com.olegpy" %% "better-monadic-for" % betterMonadicForV),
libraryDependencies ++= Seq(
"org.typelevel" %% "cats-core" % catsV,
"org.typelevel" %% "cats-effect" % catsEffectV,
"co.fs2" %% "fs2-core" % fs2V,
"co.fs2" %% "fs2-io" % fs2V,

"org.http4s" %% "http4s-dsl" % http4sV,
"org.http4s" %% "http4s-client" % http4sV,
"org.http4s" %% "http4s-circe" % http4sV,

// For Testing As I go
"org.http4s" %% "http4s-blaze-client" % http4sV,

"io.circe" %% "circe-core" % circeV,
// "io.circe" %% "circe-generic" % circeV,
// "io.circe" %% "circe-parser" % circeV,

"io.chrisdavenport" %% "log4cats-core" % log4catsV,
// "io.chrisdavenport" %% "log4cats-slf4j" % log4catsV,
// "io.chrisdavenport" %% "log4cats-extras" % log4catsV,
"io.chrisdavenport" %% "log4cats-testing" % log4catsV % Test,

"org.specs2" %% "specs2-core" % specs2V % Test,
"org.specs2" %% "specs2-scalacheck" % specs2V % Test
)
)

lazy val releaseSettings = {
import ReleaseTransformations._
Seq(
releaseCrossBuild := true,
releaseProcess := Seq[ReleaseStep](
checkSnapshotDependencies,
inquireVersions,
runClean,
runTest,
setReleaseVersion,
commitReleaseVersion,
tagRelease,
// For non cross-build projects, use releaseStepCommand("publishSigned")
releaseStepCommandAndRemaining("+publishSigned"),
setNextVersion,
commitNextVersion,
releaseStepCommand("sonatypeReleaseAll"),
pushChanges
),
publishTo := {
val nexus = "https://oss.sonatype.org/"
if (isSnapshot.value)
Some("snapshots" at nexus + "content/repositories/snapshots")
else
Some("releases" at nexus + "service/local/staging/deploy/maven2")
},
credentials ++= (
for {
username <- Option(System.getenv().get("SONATYPE_USERNAME"))
password <- Option(System.getenv().get("SONATYPE_PASSWORD"))
} yield
Credentials(
"Sonatype Nexus Repository Manager",
"oss.sonatype.org",
username,
password
)
).toSeq,
publishArtifact in Test := false,
releasePublishArtifactsAction := PgpKeys.publishSigned.value,
scmInfo := Some(
ScmInfo(
url("https://github.com/ChristopherDavenport/github"),
"[email protected]:ChristopherDavenport/github.git"
)
),
homepage := Some(url("https://github.com/ChristopherDavenport/github")),
licenses += ("MIT", url("http://opensource.org/licenses/MIT")),
publishMavenStyle := true,
pomIncludeRepository := { _ =>
false
},
pomExtra := {
<developers>
{for ((username, name) <- contributors) yield
<developer>
<id>{username}</id>
<name>{name}</name>
<url>http://github.com/{username}</url>
</developer>
}
</developers>
}
)
}

lazy val mimaSettings = {
import sbtrelease.Version

def semverBinCompatVersions(major: Int, minor: Int, patch: Int): Set[(Int, Int, Int)] = {
val majorVersions: List[Int] =
if (major == 0 && minor == 0) List.empty[Int] // If 0.0.x do not check MiMa
else List(major)
val minorVersions : List[Int] =
if (major >= 1) Range(0, minor).inclusive.toList
else List(minor)
def patchVersions(currentMinVersion: Int): List[Int] =
if (minor == 0 && patch == 0) List.empty[Int]
else if (currentMinVersion != minor) List(0)
else Range(0, patch - 1).inclusive.toList

val versions = for {
maj <- majorVersions
min <- minorVersions
pat <- patchVersions(min)
} yield (maj, min, pat)
versions.toSet
}

def mimaVersions(version: String): Set[String] = {
Version(version) match {
case Some(Version(major, Seq(minor, patch), _)) =>
semverBinCompatVersions(major.toInt, minor.toInt, patch.toInt)
.map{case (maj, min, pat) => maj.toString + "." + min.toString + "." + pat.toString}
case _ =>
Set.empty[String]
}
}
// Safety Net For Exclusions
lazy val excludedVersions: Set[String] = Set()

// Safety Net for Inclusions
lazy val extraVersions: Set[String] = Set()

Seq(
mimaFailOnNoPrevious := false,
mimaFailOnProblem := mimaVersions(version.value).toList.headOption.isDefined,
mimaPreviousArtifacts := (mimaVersions(version.value) ++ extraVersions)
.filterNot(excludedVersions.contains(_))
.map{v =>
val moduleN = moduleName.value + "_" + scalaBinaryVersion.value.toString
organization.value % moduleN % v
},
mimaBinaryIssueFilters ++= {
import com.typesafe.tools.mima.core._
import com.typesafe.tools.mima.core.ProblemFilters._
Seq()
}
)
}

lazy val micrositeSettings = {
import microsites._
Seq(
micrositeName := "github",
micrositeDescription := "Github Integration for Scala",
micrositeAuthor := "Christopher Davenport",
micrositeGithubOwner := "ChristopherDavenport",
micrositeGithubRepo := "github",
micrositeBaseUrl := "/github",
micrositeDocumentationUrl := "https://www.javadoc.io/doc/io.chrisdavenport/github_2.12",
micrositeGitterChannelUrl := "ChristopherDavenport/libraries", // Feel Free to Set To Something Else
micrositeFooterText := None,
micrositeHighlightTheme := "atom-one-light",
micrositePalette := Map(
"brand-primary" -> "#3e5b95",
"brand-secondary" -> "#294066",
"brand-tertiary" -> "#2d5799",
"gray-dark" -> "#49494B",
"gray" -> "#7B7B7E",
"gray-light" -> "#E5E5E6",
"gray-lighter" -> "#F4F3F4",
"white-color" -> "#FFFFFF"
),
fork in tut := true,
scalacOptions in Tut --= Seq(
"-Xfatal-warnings",
"-Ywarn-unused-import",
"-Ywarn-numeric-widen",
"-Ywarn-dead-code",
"-Ywarn-unused:imports",
"-Xlint:-missing-interpolator,_"
),
libraryDependencies += "com.47deg" %% "github4s" % "0.20.1",
micrositePushSiteWith := GitHub4s,
micrositeGithubToken := sys.env.get("GITHUB_TOKEN"),
micrositeExtraMdFiles := Map(
file("CHANGELOG.md") -> ExtraMdFileConfig("changelog.md", "page", Map("title" -> "changelog", "section" -> "changelog", "position" -> "100")),
file("CODE_OF_CONDUCT.md") -> ExtraMdFileConfig("code-of-conduct.md", "page", Map("title" -> "code of conduct", "section" -> "code of conduct", "position" -> "101")),
file("LICENSE") -> ExtraMdFileConfig("license.md", "page", Map("title" -> "license", "section" -> "license", "position" -> "102"))
)
)
}

lazy val skipOnPublishSettings = Seq(
skip in publish := true,
publish := (()),
publishLocal := (()),
publishArtifact := false,
publishTo := None
)
8 changes: 8 additions & 0 deletions core/src/main/scala/io/chrisdavenport/github/Auth.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package io.chrisdavenport.github

import org.http4s.Uri

sealed trait Auth
final case class BasicAuth(username: String, password: String) extends Auth
final case class OAuth(token: String) extends Auth
final case class EnterpriseOAuth(apiEndpoint: Uri, token: String) extends Auth
Loading

0 comments on commit f06195b

Please sign in to comment.