Skip to content

Commit

Permalink
OpenSource & GitHub Move
Browse files Browse the repository at this point in the history
  • Loading branch information
Chetan Bhasin committed May 4, 2020
1 parent f34cde4 commit 0f98faa
Show file tree
Hide file tree
Showing 22 changed files with 300 additions and 89 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Publish Library & Plugin

on:
push:
tags:
- '*'
branches-ignore:
- '*'

jobs:
build-test-and-publish:

runs-on: ubuntu-latest

env:
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE}}
SECRING: ${{ secrets.SECRING}}
PUBRING: ${{ secrets.PUBRING}}
SONATYPE_SBT: ${{ secrets.SONATYPE_SBT}}

steps:
- uses: actions/checkout@v2
- name: Setup JDK 11
uses: actions/setup-java@v1
with:
java-version: 11
- name: Setup Keyring
run: mkdir -p ~/.sbt/gpg && echo ${SECRING} > ~/.sbt/gpg/secring.asc && echo ${PUBRING} > ~/.sbt/gpg/pubring.asc
- name: Import Keyring
run: gpg --import ~/.sbt/gpg/secring.asc
- name: Setup Sonatype Credentials
run: mkdir -p ~/.sbt/1.0 && echo ${SONATYPE_SBT} > ~/.sbt/1.0/sonatype.sbt
- name: Setup Version
run: echo ::set-env name=RELEASE_VERSION::${GITHUB_REF:10}
- name: Update Version
run: sed "s/unstable-SNAPSHOT/${RELEASE_VERSION}/" build.sbt > build.sbt.2
- name: Replace Build File
run: mv build.sbt.2 build.sbt
- name: Run tests
run: sbt test
- name: Publish
run: sbt publishSigned

21 changes: 21 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Scala Tests

on: [ push ]

jobs:
build-and-test:

runs-on: ubuntu-latest

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

steps:
- uses: actions/checkout@v2
- name: Setup JDK 11
uses: actions/setup-java@v1
with:
java-version: 11
- name: Run tests
run: sbt test

1 change: 1 addition & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ build and test and publish:
- internal
- medium
script:
- export GITHUB_TOKEN=foo # Until we move to Github, this is required for making the application work
- sbt coverage testOnly coverageReport coverageAggregate
- if [ ! -z $CI_COMMIT_TAG ]; then export VERSION=$CI_COMMIT_TAG ; fi
- sed "s/unstable-SNAPSHOT/${VERSION}/" build.sbt > build.sbt.2
Expand Down
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2014 Chetan Bhasin

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.
111 changes: 61 additions & 50 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
import com.enfore.plugin.BuildInfo
import com.enfore.plugin.BasicBuildPlugin._
import Dependencies._
import ScalaOptions._

ThisBuild / organization := BuildInfo.organization
ThisBuild / scalaVersion := Scala213Plugin.scala213Version
ThisBuild / version := "unstable-SNAPSHOT"
organization in ThisBuild := "com.enfore"
version in ThisBuild := "unstable-SNAPSHOT"
fork in Test in ThisBuild := true

lazy val http4s = Seq(http4sCore, http4sDsl, http4sCirce, http4sServer)

lazy val commonScalaSettings = Seq(
scalacOptions ++= Seq("-language:implicitConversions"),
scalacOptions ++= compilerFlags,
Test / fork := true,
scalaVersion := "2.12.11",
organization := "com.enfore",
scalacOptions ++= compilerFlags,
scalacOptions in (Compile, console) ~= (_ filterNot (_ == "-Xfatal-warnings")),
Compile / doc / javacOptions ++= Seq(
"-no-link-warnings"
Expand All @@ -16,76 +22,81 @@ lazy val commonScalaSettings = Seq(
)
)

lazy val scalaMacros: Seq[Def.Setting[_]] = Seq(
libraryDependencies ++= (CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, 12)) => Seq(compilerPlugin("org.scalamacros" % "paradise" % "2.1.1" cross CrossVersion.full))
case _ => Seq()
}),
scalacOptions ++= (CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, 12)) => Seq()
case _ => Seq("-Ymacro-annotations")
})
)

lazy val scalaCompat = "org.scala-lang.modules" %% "scala-collection-compat" % "2.1.2"
lazy val sharedDependencies = Seq(
"com.beachape" %% "enumeratum" % "1.5.13",
"com.beachape" %% "enumeratum-circe" % "1.5.22",
"io.circe" %% "circe-refined" % Circe.latestDependencies.head.revision,
scalaCompat
) ++ Circe.latestDependencies ++ ScalaTest.latestDependencies
lazy val sharedDependencies =
Seq(
enumaratum,
enumeratumCirce,
circeRefined,
circeCore,
circeParser,
circeGeneric,
circeDerivation,
scalaCompat,
scalatest % Test
)

lazy val root = (project in file("."))
.settings(name := "openapi")
.settings(publish / skip := true)
.settings(commonScalaSettings: _*)
.aggregate(`openapi-scala`, `openapi-lib`, `openapi-http4s-lib`, `sbt-openapi`)
.enablePlugins(ScalaCrossPlugin, NexusPublishPlugin)

lazy val `openapi-scala` = (project in file("openapi-scala"))
.settings(
name := "openapi-scala",
scalaMacros,
// publishMavenStyle := true,
libraryDependencies ++= Seq(
"io.circe" %% "circe-yaml" % "0.11.0-M1" % "test",
"org.scalameta" %% "scalameta" % "4.3.0" % "test"
circeYaml % "test",
scalameta % "test"
) ++ sharedDependencies
)
.settings(commonScalaSettings)
.enablePlugins(Scala212Plugin, NexusPublishPlugin, BasicBuildPlugin)
.settings(commonScalaSettings ++ publishSettings: _*)

lazy val `openapi-lib` = (project in file("openapi-lib"))
.settings(
name := "openapi-lib"
name := "openapi-lib",
crossScalaVersions := supportedVersions
)
.settings(commonScalaSettings)
.enablePlugins(ScalaCrossPlugin, NexusPublishPlugin, BasicBuildPlugin)
.settings(commonScalaSettings ++ publishSettings: _*)

lazy val `openapi-http4s-lib` = (project in file("openapi-http4s-lib"))
.settings(
name := "openapi-http4s-lib",
scalaMacros,
libraryDependencies ++= Seq(
"io.circe" %% "circe-derivation" % "0.12.0-M7"
) ++ sharedDependencies
++ RefinedTypes.latestDependencies
++ Http4sCirce.latestDependencies
crossScalaVersions := supportedVersions,
libraryDependencies ++= sharedDependencies ++ http4s
)
.dependsOn(`openapi-lib`)
.settings(commonScalaSettings)
.enablePlugins(ScalaCrossPlugin, NexusPublishPlugin, BasicBuildPlugin)
.settings(commonScalaSettings ++ publishSettings: _*)

lazy val `sbt-openapi` = (project in file("sbt-openapi"))
.settings(
name := "sbt-openapi",
sbtPlugin := true,
organization := "com.enfore",
publishMavenStyle := true,
libraryDependencies ++= Seq(
"io.swagger.core.v3" % "swagger-core" % "2.0.9",
"io.swagger.parser.v3" % "swagger-parser" % "2.0.14"
),
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.9.0"),
buildInfoKeys := Seq[BuildInfoKey](name, version, scalaVersion, sbtVersion, organization),
buildInfoPackage := organization.value + ".openapi.plugin"
Dependencies.scalafmt,
swaggerCore,
swaggerParser,
scriptedPlugin(sbtVersion.value)
)
)
.settings(commonScalaSettings)
.settings(commonScalaSettings ++ publishSettings: _*)
.dependsOn(`openapi-scala`)
.enablePlugins(Scala212Plugin, SbtPlugin, NexusPublishPlugin, BasicBuildPlugin, BuildInfoPlugin)

lazy val publishSettings = Seq(
crossPaths := false,
autoAPIMappings := true,
publishTo := Some(
if (isSnapshot.value) Opts.resolver.sonatypeSnapshots
else Opts.resolver.sonatypeStaging
),
homepage := Some(url("https://github.com/NumberFour/openapi-scala")),
licenses := Seq("MIT" -> url("http://opensource.org/licenses/MIT")),
scmInfo := Some(
ScmInfo(
url("https://github.com/NumberFour/openapi-scala"),
"scm:git:[email protected]:NumberFour/openapi-scala",
"scm:git:https://github.com/NumberFour/openapi-scala"
)
)
)
6 changes: 3 additions & 3 deletions openapi-scala/src/test/scala/com/enfore/apis/MainSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ package com.enfore.apis

import com.enfore.apis.generator.{GenericImplementation, Http4sImplementation}
import org.scalatest.flatspec.AnyFlatSpec
import org.scalatest.matchers.should
import org.scalatest.matchers.should.Matchers

class MainSpec extends AnyFlatSpec with should.Matchers {
class MainSpec extends AnyFlatSpec with Matchers {

it should "be able to generate scala for all yamls" in {
val sources = List("catalog", "Contacts-API", "ERP-API", "problem", "purchasing", "registry").map(_ + ".json")
sources.foreach { source: String =>
info { source }
val result = Main.generateScala(
ClassLoader.getSystemResource(source).getPath,
ClassLoader.getSystemClassLoader.getResource(source).getPath,
"test.package",
List(GenericImplementation, Http4sImplementation)
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
package com.enfore.apis.ast

import com.enfore.apis.ast.ASTTranslationFunctions.PackageName
import com.enfore.apis.ast.SwaggerAST._
import com.enfore.apis.ast.SwaggerAST.{
OperationObject,
ParameterLocation,
ParameterObject,
ReferenceObject,
RequestType,
SchemaObject,
SchemaObjectType,
SchemaOrReferenceObject
}
import org.scalatest.funsuite.AnyFunSuite

class ASTTranslationFunctionsTest extends AnyFunSuite {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.enfore.apis.ast

import cats.data.NonEmptyList
import cats.syntax.functor._
import com.enfore.apis.ast.ASTTranslationFunctions.PackageName
import com.enfore.apis.ast.SwaggerAST._
import com.enfore.apis.repr.ReqWithContentType.{PATCH, POST}
import com.enfore.apis.repr.{PathItemAggregation, RequestWithPayload, TypeRepr}
import com.enfore.apis.repr.TypeRepr.{
Maximum,
Minimum,
Expand All @@ -21,16 +21,16 @@ import com.enfore.apis.repr.TypeRepr.{
PrimitiveUnion,
Ref
}
import com.enfore.apis.repr.{PathItemAggregation, RequestWithPayload, TypeRepr}
import io.circe
import io.circe._
import cats.syntax.functor._
import io.circe.generic.auto._
import org.scalatest.flatspec.AnyFlatSpec
import org.scalatest.matchers.should
import org.scalatest.matchers.should.Matchers

import scala.io.Source

class AstTranslationSpec extends AnyFlatSpec with should.Matchers {
class AstTranslationSpec extends AnyFlatSpec with Matchers {

implicit val decoder: Decoder[SchemaOrReferenceObject] =
List[Decoder[SchemaOrReferenceObject]](
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,26 @@
package com.enfore.apis.ast

import com.enfore.apis.ast.ASTTranslationFunctions.PackageName
import com.enfore.apis.ast.SwaggerAST.{
ComponentsObject,
CoreASTRepr,
MediaTypeObject,
OperationObject,
ParameterObject,
ReferenceObject,
RequestBodyObject,
ResponseObject,
SchemaObject,
SchemaObjectType
}
import com.enfore.apis.ast.SwaggerAST.ParameterLocation.path
import com.enfore.apis.ast.SwaggerAST._
import com.enfore.apis.repr.ReqWithContentType.PUT
import com.enfore.apis.repr.TypeRepr.Ref
import com.enfore.apis.repr.{GetRequest, PathItemAggregation, PathParameter, RequestWithPayload}
import org.scalatest.flatspec.AnyFlatSpec
import org.scalatest.matchers.should
import org.scalatest.matchers.should.Matchers

class ReadRoutesToInteropSpec extends AnyFlatSpec with should.Matchers {
class ReadRoutesToInteropSpec extends AnyFlatSpec with Matchers {
"readRoutesToInerop" should "be able to read multiple methods per route" in {
val expected = Map(
"_contacts_individual_{contact-id}" ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ package com.enfore.apis.generator
import cats.data.NonEmptyList
import com.enfore.apis.repr.TypeRepr
import org.scalatest.flatspec.AnyFlatSpec
import org.scalatest.matchers.should
import org.scalatest.matchers.should.Matchers

import scala.meta._

class ComponentsTypeReprSpec extends AnyFlatSpec with should.Matchers {
class ComponentsTypeReprSpec extends AnyFlatSpec with Matchers {
import TypeRepr._

"ComponentsObject TypeRepr Generator" should "be able to generate a basic case class" in {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import com.enfore.apis.ast.ASTTranslationFunctions.PackageName
import com.enfore.apis.repr.TypeRepr.{Ref => TypeReprRef}
import com.enfore.apis.repr.{GetRequest, PathParameter, ReqWithContentType, RequestWithPayload}
import org.scalatest.flatspec.AnyFlatSpec
import org.scalatest.matchers.should
import org.scalatest.matchers.should.Matchers

import scala.meta._

class PathInterfaceGeneratorSpec extends AnyFlatSpec with should.Matchers {
class PathInterfaceGeneratorSpec extends AnyFlatSpec with Matchers {

implicit val packageName: PackageName = PackageName("com.enfore.apis")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package com.enfore.apis.generator
import cats.data.NonEmptyList
import com.enfore.apis.repr.TypeRepr.{MaxLength, MinLength, PrimitiveString}
import org.scalatest.flatspec.AnyFlatSpec
import org.scalatest.matchers.should
import org.scalatest.matchers.should.Matchers

class SymbolAnnotationMakerSpec extends AnyFlatSpec with should.Matchers {
class SymbolAnnotationMakerSpec extends AnyFlatSpec with Matchers {

"dataRefinementMatcher" should "generate proper type signatures for refined primitives" in {
val op: String =
Expand Down
Loading

0 comments on commit 0f98faa

Please sign in to comment.