Skip to content

Commit 6c41772

Browse files
authored
Add CI, upgrade various dependencies to run in 2025 (#304)
* modernize build * pre-commit conifg * fix
1 parent 9b7c372 commit 6c41772

File tree

11 files changed

+122
-89
lines changed

11 files changed

+122
-89
lines changed

.github/workflows/ci.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: ci
2+
on:
3+
pull_request:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
checks:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
- uses: actions/setup-java@v4
14+
with:
15+
cache: "sbt"
16+
distribution: "temurin"
17+
java-version: 21
18+
- uses: sbt/setup-sbt@v1
19+
- run: sbt "; scalafmtCheckAll; scalafmtSbtCheck"
20+
21+
test:
22+
runs-on: ubuntu-latest
23+
steps:
24+
- uses: actions/checkout@v4
25+
- uses: actions/setup-java@v4
26+
with:
27+
cache: "sbt"
28+
distribution: "temurin"
29+
java-version: 21
30+
- uses: sbt/setup-sbt@v1
31+
- run: sbt test

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,6 @@ images/
5656
# Auto-copied by sbt-microsites
5757
docs/src/main/tut/contributing.md
5858

59-
.ruby_version
59+
.ruby_version
60+
.vscode
61+
project

.jvmopts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,4 @@
55
-XX:ReservedCodeCacheSize=250M
66
-XX:+TieredCompilation
77
-XX:-UseGCOverheadLimit
8-
# effectively adds GC to Perm space
9-
-XX:+CMSClassUnloadingEnabled
10-
# must be enabled for CMSClassUnloadingEnabled to work
11-
-XX:+UseConcMarkSweepGC
8+
-Djava.security.manager=allow

.pre-commit-config.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v5.0.0
4+
hooks:
5+
- id: check-yaml
6+
args: [--unsafe]
7+
- id: end-of-file-fixer
8+
- id: trailing-whitespace

.projectile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
-*.semanticdb
1+
-*.semanticdb

.scalafmt.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ version=2.3.2
22
maxColumn = 110
33
newlines.penalizeSingleSelectMultiArgList = false
44
align.openParenCallSite = false
5-
rewrite.rules = [AvoidInfix, SortImports, RedundantBraces, RedundantParens, PreferCurlyFors]
5+
rewrite.rules = [AvoidInfix, SortImports, RedundantBraces, RedundantParens, PreferCurlyFors]

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,4 +174,4 @@
174174
incurred by, or claims asserted against, such Contributor by reason
175175
of your accepting any such warranty or additional liability.
176176

177-
END OF TERMS AND CONDITIONS
177+
END OF TERMS AND CONDITIONS

build.sbt

Lines changed: 71 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ Global / onChangedBuildSource := ReloadOnSourceChanges
99
lazy val V = new {
1010
val algebird = "0.13.6"
1111
val cats = "2.1.0"
12-
val evilplot = "0.7.0"
12+
val evilplot = "0.9.0"
1313
val kindProjector = "0.10.3"
1414
val rainier = "0.2.3"
15-
val scala = "2.12.13"
15+
val scala = "2.12.18"
1616
val scalacheck = "1.15.3"
1717
val scalatest = "3.1.0"
1818
val scalaTestPlus = "3.1.0.1"
@@ -33,19 +33,20 @@ val compilerOptions = Seq(
3333

3434
// The console can't handle these.
3535
val consoleExclusions = Seq(
36-
"-Ywarn-unused:imports", "-Xfatal-warnings", "-Xlint"
36+
"-Ywarn-unused:imports",
37+
"-Xfatal-warnings",
38+
"-Xlint"
3739
)
3840

3941
val ignoredWarts: Set[Wart] =
40-
Set(Wart.DefaultArguments, Wart.TraversableOps, Wart.Any, Wart.NonUnitStatements)
42+
Set(Wart.DefaultArguments, Wart.IterableOps, Wart.Any, Wart.NonUnitStatements)
4143

4244
def unsafeWartsExcept(ws: Set[wartremover.Wart]): Seq[wartremover.Wart] =
4345
Warts.unsafe.filterNot(w => ws.exists(_.clazz == w.clazz))
4446

4547
val sharedSettings = Seq(
4648
organization := "io.samritchie",
4749
scalaVersion := V.scala,
48-
4950
// Lets me C-c out of the running process.
5051
cancelable in Global := true,
5152
parallelExecution in Test := true,
@@ -61,36 +62,32 @@ val sharedSettings = Seq(
6162
"-Xlint",
6263
"-language:implicitConversions",
6364
"-language:higherKinds",
64-
"-language:existentials"),
65-
66-
65+
"-language:existentials"
66+
),
6767
scalacOptions in (Compile, console) --= consoleExclusions,
6868
scalacOptions in (Test, console) --= consoleExclusions,
69-
7069
// Publishing options:
7170
releaseCrossBuild := true,
7271
releasePublishArtifactsAction := PgpKeys.publishSigned.value,
7372
releaseVersionBump := sbtrelease.Version.Bump.Minor, // need to tweak based on mima results
7473
publishMavenStyle := true,
7574
publishArtifact in Test := false,
76-
pomIncludeRepository := { x => false },
77-
75+
pomIncludeRepository := { x =>
76+
false
77+
},
7878
publishTo := Some(
79-
if (version.value.trim.endsWith("SNAPSHOT"))
80-
Opts.resolver.sonatypeSnapshots
81-
else
82-
Opts.resolver.sonatypeStaging
83-
),
84-
79+
if (version.value.trim.endsWith("SNAPSHOT"))
80+
Opts.resolver.sonatypeSnapshots
81+
else
82+
Opts.resolver.sonatypeStaging
83+
),
8584
scmInfo := Some(
8685
ScmInfo(
8786
url("https://github.com/sritchie/scala-rl"),
8887
"scm:git@github.com:sritchie/scala-rl.git"
8988
)
9089
),
91-
92-
pomExtra := (
93-
<url>https://github.com/sritchie/scala-rl</url>
90+
pomExtra := (<url>https://github.com/sritchie/scala-rl</url>
9491
<licenses>
9592
<license>
9693
<name>Apache 2</name>
@@ -109,10 +106,10 @@ val sharedSettings = Seq(
109106
) ++ mimaDefaultSettings
110107

111108
lazy val noPublishSettings = Seq(
112-
publish := {},
113-
publishLocal := {},
114-
test := {},
115-
publishArtifact := false
109+
publish := {},
110+
publishLocal := {},
111+
test := {},
112+
publishArtifact := false
116113
)
117114

118115
/**
@@ -124,28 +121,25 @@ val noBinaryCompatCheck = Set[String]("core")
124121
def previousVersion(subProj: String) =
125122
Some(subProj)
126123
.filterNot(noBinaryCompatCheck.contains(_))
127-
.map { s => "io.sritchie" %% ("scala-rl-" + s) % "0.0.1" }
124+
.map { s =>
125+
"io.sritchie" %% ("scala-rl-" + s) % "0.0.1"
126+
}
128127

129-
lazy val rl = Project(
130-
id = "scala-rl",
131-
base = file("."))
128+
lazy val rl = Project(id = "scala-rl", base = file("."))
132129
.settings(sharedSettings)
133130
.settings(noPublishSettings)
134131
.aggregate(rlCore, rlBook, rlPlot, rlWorld)
135132

136133
def module(name: String) = {
137134
val id = "scala-rl-%s".format(name)
138-
Project(id = id, base = file(id)).settings(sharedSettings ++ Seq(
139-
Keys.name := id,
140-
mimaPreviousArtifacts := previousVersion(name).toSet)
141-
)
135+
Project(id = id, base = file(id))
136+
.settings(sharedSettings ++ Seq(Keys.name := id, mimaPreviousArtifacts := previousVersion(name).toSet))
142137
}
143138

144139
lazy val rlCore = module("core").settings(
145140
libraryDependencies ++= Seq(
146-
"com.stripe" %% "rainier-cats" % V.rainier,
147-
"com.stripe" %% "rainier-core" % V.rainier,
148-
141+
"com.stripe" %% "rainier-cats" % V.rainier,
142+
"com.stripe" %% "rainier-core" % V.rainier,
149143
// For the monoids and implementations.
150144
"com.twitter" %% "algebird-core" % V.algebird,
151145
"com.twitter" %% "util-core" % V.util,
@@ -157,40 +151,46 @@ lazy val rlCore = module("core").settings(
157151
"org.scalatest" %% "scalatest" % V.scalatest % Test,
158152
"org.scalacheck" %% "scalacheck" % V.scalacheck % Test,
159153
"org.scalatestplus" %% "scalacheck-1-14" % V.scalaTestPlus % Test
160-
) ++ Seq(compilerPlugin("org.typelevel" %% "kind-projector" % V.kindProjector)),
154+
) ++ Seq(compilerPlugin("org.typelevel" %% "kind-projector" % V.kindProjector))
161155
)
162156

163-
lazy val rlWorld = module("world").settings(
164-
libraryDependencies ++= Seq(
165-
"org.scalatest" %% "scalatest" % V.scalatest % Test,
166-
"org.scalacheck" %% "scalacheck" % V.scalacheck % Test
157+
lazy val rlWorld = module("world")
158+
.settings(
159+
libraryDependencies ++= Seq(
160+
"org.scalatest" %% "scalatest" % V.scalatest % Test,
161+
"org.scalacheck" %% "scalacheck" % V.scalacheck % Test
162+
)
167163
)
168-
).dependsOn(rlCore)
169-
170-
lazy val rlPlot = module("plot").settings(
171-
libraryDependencies ++= Seq(
172-
// Charts.
173-
"com.cibo" %% "evilplot" % V.evilplot,
174-
"com.cibo" %% "evilplot-repl" % V.evilplot,
164+
.dependsOn(rlCore)
165+
166+
lazy val rlPlot = module("plot")
167+
.settings(
168+
libraryDependencies ++= Seq(
169+
// Charts.
170+
"io.github.cibotech" %% "evilplot" % V.evilplot,
171+
"io.github.cibotech" %% "evilplot-repl" % V.evilplot
172+
)
175173
)
176-
).dependsOn(rlCore)
174+
.dependsOn(rlCore)
177175

178-
lazy val rlBook = module("book").settings(
179-
libraryDependencies ++= Seq(
180-
"org.scalatest" %% "scalatest" % V.scalatest % Test,
181-
"org.scalacheck" %% "scalacheck" % V.scalacheck % Test
182-
),
183-
initialCommands :=
184-
"""
176+
lazy val rlBook = module("book")
177+
.settings(
178+
libraryDependencies ++= Seq(
179+
"org.scalatest" %% "scalatest" % V.scalatest % Test,
180+
"org.scalacheck" %% "scalacheck" % V.scalacheck % Test
181+
),
182+
initialCommands :=
183+
"""
185184
import com.scalarl._
186185
import com.stripe.rainier.sampler.RNG
187186
import com.stripe.rainier.compute.{Evaluator, Real}
188187
189188
implicit val rng: RNG = RNG.default
190189
implicit val evaluator: Numeric[Real] = new Evaluator(Map.empty)
191190
""".stripMargin('|'),
192-
mainClass in (Compile, run) := Some("scalarl.book.Chapter2"),
193-
).dependsOn(rlCore, rlPlot, rlWorld)
191+
mainClass in (Compile, run) := Some("scalarl.book.Chapter2")
192+
)
193+
.dependsOn(rlCore, rlPlot, rlWorld)
194194

195195
lazy val docsMappingsAPIDir = settingKey[String]("Name of subdirectory in site target directory for api docs")
196196

@@ -200,31 +200,25 @@ lazy val docSettings = Seq(
200200
micrositeAuthor := "Sam Ritchie",
201201
micrositeUrl := "http://www.scalarl.com",
202202
micrositeDocumentationUrl := "/api/com/scalarl/index.html",
203-
204203
micrositeHomepage := "http://www.scalarl.com/",
205204
micrositeOrganizationHomepage := "https://www.samritchie.io",
206205
micrositeTwitter := "@scalaRLProject",
207206
micrositeTwitterCreator := "@sritchie",
208-
209207
micrositeGitterChannelUrl := "ScalaRL/community",
210208
micrositeGithubOwner := "sritchie",
211209
micrositeGithubRepo := "scala-rl",
212-
213210
micrositeAnalyticsToken := "UA-146772284-1",
214-
215211
micrositeExtraMdFiles := Map(
216212
file("CONTRIBUTING.md") ->
217213
microsites.ExtraMdFileConfig(
218214
"contributing.md",
219215
"page",
220216
Map("title" -> "Contributing", "section" -> "contributing", "position" -> "5")
221-
)),
222-
217+
)
218+
),
223219
micrositeEditButton := Some(
224-
MicrositeEditButton(
225-
"Help us improve this page",
226-
"/edit/develop/docs/src/main/tut/{{ page.path }}")),
227-
220+
MicrositeEditButton("Help us improve this page", "/edit/develop/docs/src/main/tut/{{ page.path }}")
221+
),
228222
micrositeHighlightTheme := "atom-one-light",
229223
micrositePalette := Map(
230224
"brand-primary" -> "#5B5988",
@@ -234,28 +228,29 @@ lazy val docSettings = Seq(
234228
"gray" -> "#7B7B7E",
235229
"gray-light" -> "#E5E5E6",
236230
"gray-lighter" -> "#F4F3F4",
237-
"white-color" -> "#FFFFFF"),
238-
231+
"white-color" -> "#FFFFFF"
232+
),
239233
autoAPIMappings := true,
240234
unidocProjectFilter in (ScalaUnidoc, unidoc) :=
241-
inProjects(docsSourcesAndProjects:_*),
235+
inProjects(docsSourcesAndProjects: _*),
242236
docsMappingsAPIDir := "api",
243237
addMappingsToSiteDir(mappings in (ScalaUnidoc, packageDoc), docsMappingsAPIDir),
244238
ghpagesNoJekyll := false,
245-
246239
// Don't kill the cname redirect.
247240
excludeFilter in ghpagesCleanSite :=
248-
new FileFilter{
241+
new FileFilter {
249242
def accept(f: File) = (ghpagesRepository.value / "CNAME").getCanonicalPath == f.getCanonicalPath
250243
} || "versions.html",
251-
252244
fork in tut := true,
253245
fork in (ScalaUnidoc, unidoc) := true,
254246
scalacOptions in (ScalaUnidoc, unidoc) ++= Seq(
255-
"-doc-source-url", "https://github.com/sritchie/scala-rl/tree/develop€{FILE_PATH}.scala",
256-
"-sourcepath", baseDirectory.in(LocalRootProject).value.getAbsolutePath,
247+
"-doc-source-url",
248+
"https://github.com/sritchie/scala-rl/tree/develop€{FILE_PATH}.scala",
249+
"-sourcepath",
250+
baseDirectory.in(LocalRootProject).value.getAbsolutePath,
257251
// "-diagrams", // Not working locally; wait until graphviz is reliable.
258-
"-doc-root-content", "scaladoc-root.txt"
252+
"-doc-root-content",
253+
"scaladoc-root.txt"
259254
),
260255
git.remoteRepo := "git@github.com:sritchie/scala-rl.git"
261256
)

docs/src/main/resources/microsite/data/menu.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,4 +90,4 @@ options:
9090

9191
- title: Planning and Learning with Tabular Methods
9292
url: course/tabular/tabular_methods.html
93-
menu_section: tabular
93+
menu_section: tabular

project/build.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
sbt.version=1.3.13
1+
sbt.version=1.9.8

0 commit comments

Comments
 (0)