Skip to content

Commit d381a20

Browse files
committed
add CI
1 parent 3670270 commit d381a20

File tree

8 files changed

+204
-83
lines changed

8 files changed

+204
-83
lines changed

.github/workflows/build.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Build
2+
on: [push]
3+
jobs:
4+
build:
5+
runs-on: ubuntu-20.04
6+
steps:
7+
- uses: actions/checkout@v2
8+
- name: Set up JDK 11
9+
uses: actions/setup-java@v2
10+
with:
11+
java-version: '11'
12+
distribution: 'adopt'
13+
- name: Cache Java modules
14+
uses: actions/cache@v2
15+
env:
16+
cache-name: cache-java-modules
17+
with:
18+
path: ~/.m2
19+
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('./build.sbt') }}
20+
restore-keys: |
21+
${{ runner.os }}-build-${{ env.cache-name }}-
22+
${{ runner.os }}-build-
23+
${{ runner.os }}-
24+
- name: Cache Scala modules
25+
uses: actions/cache@v2
26+
env:
27+
cache-name: cache-scala-modules
28+
with:
29+
path: ~/.m2
30+
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('./build.sbt') }}
31+
restore-keys: |
32+
${{ runner.os }}-build-${{ env.cache-name }}-
33+
${{ runner.os }}-build-
34+
${{ runner.os }}-
35+
- name: Cache Sbt modules
36+
uses: actions/cache@v2
37+
env:
38+
cache-name: cache-sbt-modules
39+
with:
40+
path: ~/.sbt/1.0
41+
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('./build.sbt') }}
42+
restore-keys: |
43+
${{ runner.os }}-build-${{ env.cache-name }}-
44+
${{ runner.os }}-build-
45+
${{ runner.os }}-
46+
- name: Run Sbt Test and Generate Report on Multiple Scala Versions
47+
run: |
48+
sbt +package

.github/workflows/linter.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Linter CI
1+
name: Linter
22
on: [push]
33
jobs:
44
linter:

.github/workflows/release.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Publish documentation to project website and package to the Maven Central Repository
2+
on:
3+
release:
4+
types: [created]
5+
jobs:
6+
publish-doc:
7+
runs-on: ubuntu-20.04
8+
steps:
9+
-
10+
11+
publish-package:
12+
runs-on: ubuntu-latest
13+
needs: [publish-doc]
14+
steps:
15+
- uses: actions/checkout@v2
16+
- name: Set up Java
17+
uses: actions/setup-java@v2
18+
with:
19+
java-version: '11'
20+
distribution: 'adopt'
21+
- name: Publish package
22+
run: mvn --batch-mode deploy
23+
env:
24+
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
25+
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}

.github/workflows/test.yml

Lines changed: 0 additions & 59 deletions
This file was deleted.

.github/workflows/tests.yml

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
name: Unittests
2+
on: [push]
3+
jobs:
4+
retrieve-scala-versions:
5+
runs-on: ubuntu-20.04
6+
steps:
7+
- uses: actions/checkout@v2
8+
- name: Set up JDK 11
9+
uses: actions/setup-java@v2
10+
with:
11+
java-version: '11'
12+
distribution: 'adopt'
13+
- name: Retrieve Scala Versions from build.sbt file
14+
id: set-matrix
15+
run: |
16+
scalaVersionPref=$(sbt +scalaBinaryVersion | sed -r 's/[^ \t\r\n\v\f0-9\.]([0-9]\.[0-9]+)/SCALA_VERSION\1/' | grep -oE 'CALA_VERSION[0-9]\.[0-9]+')
17+
scala_versions=$(echo "$scalaVersionPref" | sed -r 's/CALA_VERSION([0-9]\.[0-9]+)/\1/' | tr '\n' ',')
18+
scala_versions="[${scala_versions%?}]"
19+
echo ::set-output name=matrix::"$scala_versions"
20+
outputs:
21+
scala_versions: ${{ steps.set-matrix.outputs.matrix }}
22+
23+
test-coverage:
24+
runs-on: ubuntu-20.04
25+
steps:
26+
- uses: actions/checkout@v2
27+
- name: Set up JDK 11
28+
uses: actions/setup-java@v2
29+
with:
30+
java-version: '11'
31+
distribution: 'adopt'
32+
- name: Cache Java modules
33+
uses: actions/cache@v2
34+
env:
35+
cache-name: cache-java-modules
36+
with:
37+
path: ~/.m2
38+
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('./build.sbt') }}
39+
restore-keys: |
40+
${{ runner.os }}-build-${{ env.cache-name }}-
41+
${{ runner.os }}-build-
42+
${{ runner.os }}-
43+
- name: Cache Scala modules
44+
uses: actions/cache@v2
45+
env:
46+
cache-name: cache-scala-modules
47+
with:
48+
path: ~/.m2
49+
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('./build.sbt') }}
50+
restore-keys: |
51+
${{ runner.os }}-build-${{ env.cache-name }}-
52+
${{ runner.os }}-build-
53+
${{ runner.os }}-
54+
- name: Cache Sbt modules
55+
uses: actions/cache@v2
56+
env:
57+
cache-name: cache-sbt-modules
58+
with:
59+
path: ~/.sbt/1.0
60+
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('./build.sbt') }}
61+
restore-keys: |
62+
${{ runner.os }}-build-${{ env.cache-name }}-
63+
${{ runner.os }}-build-
64+
${{ runner.os }}-
65+
- name: Run Sbt Test and Generate Report on Multiple Scala Versions
66+
run: |
67+
sbt +coverage +test
68+
sbt +coverageReport
69+
- uses: actions/upload-artifact@v2
70+
with:
71+
name: coverage-report
72+
path: ./target/scala-[0-9].[0-9][0-9]
73+
74+
upload-coverage:
75+
runs-on: ubuntu-latest
76+
needs: [retrieve-scala-versions, test-coverage]
77+
strategy:
78+
fail-fast: false
79+
matrix:
80+
scala_version: ${{ fromJSON(needs.retrieve-scala-versions.outputs.scala_versions) }}
81+
steps:
82+
- uses: actions/checkout@v2
83+
- uses: actions/download-artifact@v2
84+
with:
85+
name: coverage-report
86+
path: ./target/
87+
- uses: codecov/codecov-action@v2
88+
with:
89+
token: ${{ secrets.CODECOV_TOKEN }}
90+
directory: ./target/scala-${{ matrix.scala_version }}/
91+
flags: unittests,${{ matrix.scala_version }}/scoverage-report/scoverage.xml
92+
name: codecov-json-logic-scala
93+
fail_ci_if_error: true
94+
verbose: true

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
# Json Logic Scala
2+
3+
[![Scala versions](https://img.shields.io/badge/scala-2.11%7C2.12%7C2.13-blue.svg)]()
4+
[![Linter](https://github.com/celadari/json-logic-scala/actions/workflows/linter.yml/badge.svg)](https://github.com/celadari/json-logic-scala/actions/workflows/linter.yml)
5+
[![Unittests](https://github.com/celadari/json-logic-scala/actions/workflows/tests.yml/badge.svg)](https://github.com/celadari/json-logic-scala/actions/workflows/tests.yml)
6+
[![Build](https://github.com/celadari/json-logic-scala/actions/workflows/build.yml/badge.svg)](https://github.com/celadari/json-logic-scala/actions/workflows/build.yml)
7+
[![codecov](https://codecov.io/gh/celadari/json-logic-scala/branch/v2/graph/badge.svg?token=9LEB1I50R3)](https://codecov.io/gh/celadari/json-logic-scala)
8+
[![License](https://img.shields.io/badge/license-MIT-blue.svg)]()
9+
210
Build complex rules, serialize them as JSON, and execute them in Scala.
311

412
Json-logic-scala enables you to serialize in JSON format logical expressions.
@@ -17,7 +25,6 @@ scala.
1725
### Scala Versions
1826

1927
This project is compiled, tested, and published for the following Scala versions:
20-
* 2.10.7
2128
* 2.11.12
2229
* 2.12.6
2330
* 2.13.2

build.sbt

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,18 @@ name := "json-logic-scala"
22

33
organization := "com.github.celadari"
44

5-
homepage := Some(url("https://github.com/celadari/json-logic-scala"))
5+
homepage := Some(url("https://jsonlogicscala.com"))
66

7-
version := "2.0.0"
7+
developers := List(Developer(
8+
"celadari",
9+
"Charles",
10+
"celadari@jsonlogicscala.com",
11+
url("https://github.com/username")
12+
))
13+
14+
licenses += ("MIT", url("https://mit-license.org/"))
15+
16+
version := "SNAPSHOT-2.0.0"
817

918
scalaVersion := "2.13.2"
1019

@@ -21,7 +30,7 @@ autoScalaLibrary := false
2130
// scalastyle:off magic.number
2231
def resolveVersion(scalaV: String, versionsResolver: Map[String, String]): String = versionsResolver(scalaV.slice(0, 4))
2332

24-
val typeSafeVersions = Map("2.10" -> "2.6.14", "2.11" -> "2.7.4", "2.12" -> "2.8.1", "2.13" -> "2.8.1")
33+
val typeSafeVersions = Map("2.11" -> "2.7.4", "2.12" -> "2.8.1", "2.13" -> "2.8.1")
2534

2635
libraryDependencies ++= Seq(
2736
"com.typesafe.play" %% "play-json" % resolveVersion(scalaVersion.value, typeSafeVersions),
@@ -30,9 +39,9 @@ libraryDependencies ++= Seq(
3039
"org.scalatest" %% "scalatest" % "3.2.9" % Test
3140
)
3241

33-
// scalacOptions ++= ("-feature" :: "-language:postfixOps" :: "-language:implicitConversions" :: Nil)
3442
scalacOptions ++= Seq(
35-
"-encoding", "utf8",
43+
"-encoding",
44+
"utf8",
3645
"-deprecation",
3746
"-feature",
3847
"-language:higherKinds",
@@ -58,27 +67,22 @@ publishTo := {
5867

5968
publishConfiguration := publishConfiguration.value.withOverwrite(true)
6069

61-
credentials += Credentials(Path.userHome / ".sbt" / ".credentials")
70+
credentials += sys.env.get("SONATYPE_USERNAME").zip(sys.env.get("SONATYPE_PASSWORD"))
71+
.headOption
72+
.map{case (username, password) => Credentials("Sonatype Nexus Repository Manager", "oss.sonatype.org", username, password)}
73+
.getOrElse(Credentials(Path.userHome / ".sbt" / ".credentials"))
6274

6375
Test / publishArtifact := false
6476

6577
publishMavenStyle := true
6678

6779
pomIncludeRepository := { _ => false }
6880

69-
pomExtra :=
70-
<scm>
71-
<url>git@github.com:celadari/json-logic-scala.git</url>
72-
<connection>scm:git:git@github.com:celadari/json-logic-scala.git</connection>
73-
</scm>
74-
<developers>
75-
<developer>
76-
<id>celadari</id>
77-
<name>Charles-Edouard LADARI</name>
78-
<url>https://github.com/celadari</url>
79-
</developer>
80-
</developers>
81+
scmInfo := Some(ScmInfo(url("https://github.com/celadari/json-logic-scala"),
82+
"git@github.com:celadari/json-logic-scala.git"))
8183

82-
licenses += ("MIT", url("https://mit-license.org/"))
83-
84-
// Scaladoc publishing stuff
84+
// sonatype repository settings
85+
publishTo := Some(
86+
if (isSnapshot.value) Opts.resolver.sonatypeSnapshots
87+
else Opts.resolver.sonatypeStaging
88+
)

project/plugins.sbt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,6 @@ addSbtPlugin("com.beautiful-scala" % "sbt-scalastyle" % "1.5.0")
44

55
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.8.2")
66

7-
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "latest.integration")
7+
addSbtPlugin("com.github.sbt" % "sbt-pgp" % "2.1.2")
8+
9+
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.9.7")

0 commit comments

Comments
 (0)