Skip to content

Commit 0f98faa

Browse files
author
Chetan Bhasin
committed
OpenSource & GitHub Move
1 parent f34cde4 commit 0f98faa

22 files changed

+300
-89
lines changed

.github/workflows/deploy.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Publish Library & Plugin
2+
3+
on:
4+
push:
5+
tags:
6+
- '*'
7+
branches-ignore:
8+
- '*'
9+
10+
jobs:
11+
build-test-and-publish:
12+
13+
runs-on: ubuntu-latest
14+
15+
env:
16+
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE}}
17+
SECRING: ${{ secrets.SECRING}}
18+
PUBRING: ${{ secrets.PUBRING}}
19+
SONATYPE_SBT: ${{ secrets.SONATYPE_SBT}}
20+
21+
steps:
22+
- uses: actions/checkout@v2
23+
- name: Setup JDK 11
24+
uses: actions/setup-java@v1
25+
with:
26+
java-version: 11
27+
- name: Setup Keyring
28+
run: mkdir -p ~/.sbt/gpg && echo ${SECRING} > ~/.sbt/gpg/secring.asc && echo ${PUBRING} > ~/.sbt/gpg/pubring.asc
29+
- name: Import Keyring
30+
run: gpg --import ~/.sbt/gpg/secring.asc
31+
- name: Setup Sonatype Credentials
32+
run: mkdir -p ~/.sbt/1.0 && echo ${SONATYPE_SBT} > ~/.sbt/1.0/sonatype.sbt
33+
- name: Setup Version
34+
run: echo ::set-env name=RELEASE_VERSION::${GITHUB_REF:10}
35+
- name: Update Version
36+
run: sed "s/unstable-SNAPSHOT/${RELEASE_VERSION}/" build.sbt > build.sbt.2
37+
- name: Replace Build File
38+
run: mv build.sbt.2 build.sbt
39+
- name: Run tests
40+
run: sbt test
41+
- name: Publish
42+
run: sbt publishSigned
43+

.github/workflows/tests.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Scala Tests
2+
3+
on: [ push ]
4+
5+
jobs:
6+
build-and-test:
7+
8+
runs-on: ubuntu-latest
9+
10+
env:
11+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
12+
13+
steps:
14+
- uses: actions/checkout@v2
15+
- name: Setup JDK 11
16+
uses: actions/setup-java@v1
17+
with:
18+
java-version: 11
19+
- name: Run tests
20+
run: sbt test
21+

.gitlab-ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ build and test and publish:
2222
- internal
2323
- medium
2424
script:
25+
- export GITHUB_TOKEN=foo # Until we move to Github, this is required for making the application work
2526
- sbt coverage testOnly coverageReport coverageAggregate
2627
- if [ ! -z $CI_COMMIT_TAG ]; then export VERSION=$CI_COMMIT_TAG ; fi
2728
- sed "s/unstable-SNAPSHOT/${VERSION}/" build.sbt > build.sbt.2

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2014 Chetan Bhasin
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

build.sbt

Lines changed: 61 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
1-
import com.enfore.plugin.BuildInfo
2-
import com.enfore.plugin.BasicBuildPlugin._
1+
import Dependencies._
2+
import ScalaOptions._
33

4-
ThisBuild / organization := BuildInfo.organization
5-
ThisBuild / scalaVersion := Scala213Plugin.scala213Version
6-
ThisBuild / version := "unstable-SNAPSHOT"
4+
organization in ThisBuild := "com.enfore"
5+
version in ThisBuild := "unstable-SNAPSHOT"
6+
fork in Test in ThisBuild := true
7+
8+
lazy val http4s = Seq(http4sCore, http4sDsl, http4sCirce, http4sServer)
79

810
lazy val commonScalaSettings = Seq(
9-
scalacOptions ++= Seq("-language:implicitConversions"),
11+
scalacOptions ++= compilerFlags,
12+
Test / fork := true,
13+
scalaVersion := "2.12.11",
14+
organization := "com.enfore",
15+
scalacOptions ++= compilerFlags,
1016
scalacOptions in (Compile, console) ~= (_ filterNot (_ == "-Xfatal-warnings")),
1117
Compile / doc / javacOptions ++= Seq(
1218
"-no-link-warnings"
@@ -16,76 +22,81 @@ lazy val commonScalaSettings = Seq(
1622
)
1723
)
1824

19-
lazy val scalaMacros: Seq[Def.Setting[_]] = Seq(
20-
libraryDependencies ++= (CrossVersion.partialVersion(scalaVersion.value) match {
21-
case Some((2, 12)) => Seq(compilerPlugin("org.scalamacros" % "paradise" % "2.1.1" cross CrossVersion.full))
22-
case _ => Seq()
23-
}),
24-
scalacOptions ++= (CrossVersion.partialVersion(scalaVersion.value) match {
25-
case Some((2, 12)) => Seq()
26-
case _ => Seq("-Ymacro-annotations")
27-
})
28-
)
29-
30-
lazy val scalaCompat = "org.scala-lang.modules" %% "scala-collection-compat" % "2.1.2"
31-
lazy val sharedDependencies = Seq(
32-
"com.beachape" %% "enumeratum" % "1.5.13",
33-
"com.beachape" %% "enumeratum-circe" % "1.5.22",
34-
"io.circe" %% "circe-refined" % Circe.latestDependencies.head.revision,
35-
scalaCompat
36-
) ++ Circe.latestDependencies ++ ScalaTest.latestDependencies
25+
lazy val sharedDependencies =
26+
Seq(
27+
enumaratum,
28+
enumeratumCirce,
29+
circeRefined,
30+
circeCore,
31+
circeParser,
32+
circeGeneric,
33+
circeDerivation,
34+
scalaCompat,
35+
scalatest % Test
36+
)
3737

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

4344
lazy val `openapi-scala` = (project in file("openapi-scala"))
4445
.settings(
4546
name := "openapi-scala",
46-
scalaMacros,
47+
// publishMavenStyle := true,
4748
libraryDependencies ++= Seq(
48-
"io.circe" %% "circe-yaml" % "0.11.0-M1" % "test",
49-
"org.scalameta" %% "scalameta" % "4.3.0" % "test"
49+
circeYaml % "test",
50+
scalameta % "test"
5051
) ++ sharedDependencies
5152
)
52-
.settings(commonScalaSettings)
53-
.enablePlugins(Scala212Plugin, NexusPublishPlugin, BasicBuildPlugin)
53+
.settings(commonScalaSettings ++ publishSettings: _*)
5454

5555
lazy val `openapi-lib` = (project in file("openapi-lib"))
5656
.settings(
57-
name := "openapi-lib"
57+
name := "openapi-lib",
58+
crossScalaVersions := supportedVersions
5859
)
59-
.settings(commonScalaSettings)
60-
.enablePlugins(ScalaCrossPlugin, NexusPublishPlugin, BasicBuildPlugin)
60+
.settings(commonScalaSettings ++ publishSettings: _*)
6161

6262
lazy val `openapi-http4s-lib` = (project in file("openapi-http4s-lib"))
6363
.settings(
6464
name := "openapi-http4s-lib",
65-
scalaMacros,
66-
libraryDependencies ++= Seq(
67-
"io.circe" %% "circe-derivation" % "0.12.0-M7"
68-
) ++ sharedDependencies
69-
++ RefinedTypes.latestDependencies
70-
++ Http4sCirce.latestDependencies
65+
crossScalaVersions := supportedVersions,
66+
libraryDependencies ++= sharedDependencies ++ http4s
7167
)
7268
.dependsOn(`openapi-lib`)
73-
.settings(commonScalaSettings)
74-
.enablePlugins(ScalaCrossPlugin, NexusPublishPlugin, BasicBuildPlugin)
69+
.settings(commonScalaSettings ++ publishSettings: _*)
7570

7671
lazy val `sbt-openapi` = (project in file("sbt-openapi"))
7772
.settings(
7873
name := "sbt-openapi",
7974
sbtPlugin := true,
80-
organization := "com.enfore",
75+
publishMavenStyle := true,
8176
libraryDependencies ++= Seq(
82-
"io.swagger.core.v3" % "swagger-core" % "2.0.9",
83-
"io.swagger.parser.v3" % "swagger-parser" % "2.0.14"
84-
),
85-
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.9.0"),
86-
buildInfoKeys := Seq[BuildInfoKey](name, version, scalaVersion, sbtVersion, organization),
87-
buildInfoPackage := organization.value + ".openapi.plugin"
77+
Dependencies.scalafmt,
78+
swaggerCore,
79+
swaggerParser,
80+
scriptedPlugin(sbtVersion.value)
81+
)
8882
)
89-
.settings(commonScalaSettings)
83+
.settings(commonScalaSettings ++ publishSettings: _*)
9084
.dependsOn(`openapi-scala`)
91-
.enablePlugins(Scala212Plugin, SbtPlugin, NexusPublishPlugin, BasicBuildPlugin, BuildInfoPlugin)
85+
86+
lazy val publishSettings = Seq(
87+
crossPaths := false,
88+
autoAPIMappings := true,
89+
publishTo := Some(
90+
if (isSnapshot.value) Opts.resolver.sonatypeSnapshots
91+
else Opts.resolver.sonatypeStaging
92+
),
93+
homepage := Some(url("https://github.com/NumberFour/openapi-scala")),
94+
licenses := Seq("MIT" -> url("http://opensource.org/licenses/MIT")),
95+
scmInfo := Some(
96+
ScmInfo(
97+
url("https://github.com/NumberFour/openapi-scala"),
98+
"scm:git:[email protected]:NumberFour/openapi-scala",
99+
"scm:git:https://github.com/NumberFour/openapi-scala"
100+
)
101+
)
102+
)

openapi-scala/src/test/scala/com/enfore/apis/MainSpec.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@ package com.enfore.apis
22

33
import com.enfore.apis.generator.{GenericImplementation, Http4sImplementation}
44
import org.scalatest.flatspec.AnyFlatSpec
5-
import org.scalatest.matchers.should
5+
import org.scalatest.matchers.should.Matchers
66

7-
class MainSpec extends AnyFlatSpec with should.Matchers {
7+
class MainSpec extends AnyFlatSpec with Matchers {
88

99
it should "be able to generate scala for all yamls" in {
1010
val sources = List("catalog", "Contacts-API", "ERP-API", "problem", "purchasing", "registry").map(_ + ".json")
1111
sources.foreach { source: String =>
1212
info { source }
1313
val result = Main.generateScala(
14-
ClassLoader.getSystemResource(source).getPath,
14+
ClassLoader.getSystemClassLoader.getResource(source).getPath,
1515
"test.package",
1616
List(GenericImplementation, Http4sImplementation)
1717
)

openapi-scala/src/test/scala/com/enfore/apis/ast/ASTTranslationFunctionsTest.scala

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
11
package com.enfore.apis.ast
22

33
import com.enfore.apis.ast.ASTTranslationFunctions.PackageName
4-
import com.enfore.apis.ast.SwaggerAST._
4+
import com.enfore.apis.ast.SwaggerAST.{
5+
OperationObject,
6+
ParameterLocation,
7+
ParameterObject,
8+
ReferenceObject,
9+
RequestType,
10+
SchemaObject,
11+
SchemaObjectType,
12+
SchemaOrReferenceObject
13+
}
514
import org.scalatest.funsuite.AnyFunSuite
615

716
class ASTTranslationFunctionsTest extends AnyFunSuite {

openapi-scala/src/test/scala/com/enfore/apis/ast/AstTranslationSpec.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package com.enfore.apis.ast
22

33
import cats.data.NonEmptyList
4-
import cats.syntax.functor._
54
import com.enfore.apis.ast.ASTTranslationFunctions.PackageName
65
import com.enfore.apis.ast.SwaggerAST._
76
import com.enfore.apis.repr.ReqWithContentType.{PATCH, POST}
7+
import com.enfore.apis.repr.{PathItemAggregation, RequestWithPayload, TypeRepr}
88
import com.enfore.apis.repr.TypeRepr.{
99
Maximum,
1010
Minimum,
@@ -21,16 +21,16 @@ import com.enfore.apis.repr.TypeRepr.{
2121
PrimitiveUnion,
2222
Ref
2323
}
24-
import com.enfore.apis.repr.{PathItemAggregation, RequestWithPayload, TypeRepr}
2524
import io.circe
2625
import io.circe._
26+
import cats.syntax.functor._
2727
import io.circe.generic.auto._
2828
import org.scalatest.flatspec.AnyFlatSpec
29-
import org.scalatest.matchers.should
29+
import org.scalatest.matchers.should.Matchers
3030

3131
import scala.io.Source
3232

33-
class AstTranslationSpec extends AnyFlatSpec with should.Matchers {
33+
class AstTranslationSpec extends AnyFlatSpec with Matchers {
3434

3535
implicit val decoder: Decoder[SchemaOrReferenceObject] =
3636
List[Decoder[SchemaOrReferenceObject]](

openapi-scala/src/test/scala/com/enfore/apis/ast/ReadRoutesToInteropSpec.scala

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,26 @@
11
package com.enfore.apis.ast
22

33
import com.enfore.apis.ast.ASTTranslationFunctions.PackageName
4+
import com.enfore.apis.ast.SwaggerAST.{
5+
ComponentsObject,
6+
CoreASTRepr,
7+
MediaTypeObject,
8+
OperationObject,
9+
ParameterObject,
10+
ReferenceObject,
11+
RequestBodyObject,
12+
ResponseObject,
13+
SchemaObject,
14+
SchemaObjectType
15+
}
416
import com.enfore.apis.ast.SwaggerAST.ParameterLocation.path
5-
import com.enfore.apis.ast.SwaggerAST._
617
import com.enfore.apis.repr.ReqWithContentType.PUT
718
import com.enfore.apis.repr.TypeRepr.Ref
819
import com.enfore.apis.repr.{GetRequest, PathItemAggregation, PathParameter, RequestWithPayload}
920
import org.scalatest.flatspec.AnyFlatSpec
10-
import org.scalatest.matchers.should
21+
import org.scalatest.matchers.should.Matchers
1122

12-
class ReadRoutesToInteropSpec extends AnyFlatSpec with should.Matchers {
23+
class ReadRoutesToInteropSpec extends AnyFlatSpec with Matchers {
1324
"readRoutesToInerop" should "be able to read multiple methods per route" in {
1425
val expected = Map(
1526
"_contacts_individual_{contact-id}" ->

openapi-scala/src/test/scala/com/enfore/apis/generator/ComponentsTypeReprSpec.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ package com.enfore.apis.generator
33
import cats.data.NonEmptyList
44
import com.enfore.apis.repr.TypeRepr
55
import org.scalatest.flatspec.AnyFlatSpec
6-
import org.scalatest.matchers.should
6+
import org.scalatest.matchers.should.Matchers
77

88
import scala.meta._
99

10-
class ComponentsTypeReprSpec extends AnyFlatSpec with should.Matchers {
10+
class ComponentsTypeReprSpec extends AnyFlatSpec with Matchers {
1111
import TypeRepr._
1212

1313
"ComponentsObject TypeRepr Generator" should "be able to generate a basic case class" in {

0 commit comments

Comments
 (0)