Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update sbt to 1.9.0, migrate to new sbt syntax && Modernize a bit the CI (add ScalaSteward, dependabot and release-drafter) #220

Merged
merged 3 commits into from
Jun 5, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: "github-actions"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Helps maintaining Github Actions workflows up-to-date

directory: "/"
schedule:
interval: "weekly"
19 changes: 19 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name-template: 'v$NEXT_PATCH_VERSION'
tag-template: 'v$NEXT_PATCH_VERSION'
categories:
- title: '🚀 Features'
labels:
- 'feature'
- title: '🐛 Bug Fixes'
labels:
- 'bug'
- title: '🧰 Maintenance'
labels:
- 'build'
- title: '🌱 Dependency Updates'
labels:
- 'dependency-update'
change-template: '- $TITLE @$AUTHOR (#$NUMBER)'
template: |
## Changes
$CHANGES
12 changes: 5 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,12 @@ jobs:
include:
- java: 8
- java: 11
- java: 17
steps:
- uses: actions/checkout@v2.3.4
- uses: olafurpg/setup-scala@v10
Copy link
Contributor Author

@guizmaii guizmaii Jun 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replaced by setup-java as setup-scala is using Jabba, which is not maintained anymore

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setup-java includes caching:
cache: sbt
Then you could remove the rm command, too

- uses: actions/setup-java@v3
with:
java-version: "adopt@1.${{ matrix.java }}"
- uses: coursier/cache-action@v5
distribution: 'temurin'
java-version: ${{ matrix.java }}
- uses: coursier/cache-action@v6
- run: sbt -v test scripted
- run:
rm -rf "$HOME/.ivy2/local" || true
find "$HOME/.ivy2/cache" -name "ivydata-*.properties" -print -delete
find "$HOME/.sbt" -name "*.lock" -print -delete
13 changes: 13 additions & 0 deletions .github/workflows/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Release Drafter

on:
push:
branches: ['master']

jobs:
update_release_draft:
runs-on: ubuntu-20.04
steps:
- uses: release-drafter/release-drafter@v5
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automatically maintain a changelog in the Github releases

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
16 changes: 16 additions & 0 deletions .github/workflows/scala-steward.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Scala Steward
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other repos in this organisation are using the public Scala-steward, by adding the repo here: https://github.com/search?q=repo%3AVirtusLab%2Fscala-steward-repos%20sbt%2Fsbt-&type=code

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO, it's better to use the Github Actions. It's local to the repo, you have more control to when it's launched, you can launch it manually if needed and the PRs don't come from a fork so they're easier to update if necessary

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense


# This workflow will launch every day at 00:00
on:
schedule:
- cron: '0 0 * * *'
workflow_dispatch: {}

jobs:
scala-steward:
timeout-minutes: 45
runs-on: ubuntu-latest
name: Scala Steward
steps:
- name: Scala Steward
uses: scala-steward-org/scala-steward-action@v2.54.0
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ val jmhVersion = {

val commonSettings = Seq(
organization := "pl.project13.scala",
publishTo := Some(if (isSnapshot.value) Opts.resolver.sonatypeSnapshots else Opts.resolver.sonatypeStaging),
publishTo := Some(if (isSnapshot.value) Opts.resolver.sonatypeOssSnapshots.last else Opts.resolver.sonatypeStaging),
startYear := Some(2014),
licenses += ("Apache-2.0", url("http://www.apache.org/licenses/LICENSE-2.0.html")),
homepage := Some(url("https://github.com/ktoso/sbt-jmh")),
Expand Down
31 changes: 13 additions & 18 deletions plugin/src/main/scala/pl/project13/scala/sbt/JmhPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,10 @@

package pl.project13.scala.sbt

import java.util.Properties

import sbt._
import sbt.Keys._
import org.openjdk.jmh.annotations.Benchmark
import org.openjdk.jmh.generators.bytecode.JmhBytecodeGenerator
import sbt.KeyRanks.AMinusSetting
import sbt.*
import sbt.Keys.*

import scala.tools.nsc.util.ScalaClassLoader.URLClassLoader
import java.util.Properties

object JmhPlugin extends AutoPlugin {

Expand All @@ -33,7 +28,7 @@ object JmhPlugin extends AutoPlugin {
val generatorType = settingKey[String]("Benchmark code generator type. Available: `default`, `reflection` or `asm`.")
}

import JmhKeys._
import JmhKeys.*

val autoImport = JmhKeys

Expand All @@ -52,17 +47,17 @@ object JmhPlugin extends AutoPlugin {
version := jmhVersionFromProps(),
generatorType := "default",

mainClass in run := Some("org.openjdk.jmh.Main"),
fork in run := true, // makes sure that sbt manages classpath for JMH when forking
run / mainClass := Some("org.openjdk.jmh.Main"),
run / fork := true, // makes sure that sbt manages classpath for JMH when forking
// allow users to configure another classesDirectory like e.g. test:classDirectory
classDirectory := (classDirectory in Compile).value,
dependencyClasspath := (dependencyClasspath in Compile).value,
classDirectory := (Compile / classDirectory).value,
dependencyClasspath := (Compile / dependencyClasspath).value,

resourceDirectory := (resourceDirectory in Compile).value,
resourceDirectory := (Compile / resourceDirectory).value,
sourceGenerators := Seq(Def.task { generateJmhSourcesAndResources.value._1 }.taskValue),
resourceGenerators := Seq(Def.task { generateJmhSourcesAndResources.value._2 }.taskValue),
generateJmhSourcesAndResources := generateBenchmarkSourcesAndResources(streams.value, crossTarget.value / "jmh-cache", (classDirectory in Jmh).value, sourceManaged.value, resourceManaged.value, generatorType.value, (dependencyClasspath in Jmh).value, new Run(scalaInstance.value, true, taskTemporaryDirectory.value)),
generateJmhSourcesAndResources := (generateJmhSourcesAndResources dependsOn(compile in Compile)).value,
generateJmhSourcesAndResources := generateBenchmarkSourcesAndResources(streams.value, crossTarget.value / "jmh-cache", (Jmh / classDirectory).value, sourceManaged.value, resourceManaged.value, generatorType.value, (Jmh / dependencyClasspath).value, new Run(scalaInstance.value, true, taskTemporaryDirectory.value)),
generateJmhSourcesAndResources := (generateJmhSourcesAndResources dependsOn(Compile / compile)).value,

// local copy of https://github.com/sbt/sbt/blob/e4231ac03903e174bc9975ee00d34064a1d1f373/main/src/main/scala/sbt/Keys.scala#L400
// so that it does not break on sbt version below 1.4.0
Expand All @@ -72,13 +67,13 @@ object JmhPlugin extends AutoPlugin {

// includes the asm jar only if needed
libraryDependencies ++= {
val jmhV = (version in Jmh).value
val jmhV = (Jmh / version).value

Seq(
"org.openjdk.jmh" % "jmh-core" % jmhV, // GPLv2
"org.openjdk.jmh" % "jmh-generator-bytecode" % jmhV, // GPLv2
"org.openjdk.jmh" % "jmh-generator-reflection" % jmhV // GPLv2
) ++ ((generatorType in Jmh).value match {
) ++ ((Jmh / generatorType).value match {
case "default" | "reflection" => Nil // default == reflection (0.9)
case "asm" => Seq("org.openjdk.jmh" % "jmh-generator-asm" % jmhV) // GPLv2
case unknown => throw new IllegalArgumentException(s"Unknown benchmark generator type: $unknown, please use one of the supported generators!")
Expand Down
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.3.13
sbt.version=1.9.0
4 changes: 2 additions & 2 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "2.0.1")
addSbtPlugin("de.heikoseeberger" % "sbt-header" % "5.6.0")
addSbtPlugin("com.github.sbt" % "sbt-pgp" % "2.2.1")
addSbtPlugin("de.heikoseeberger" % "sbt-header" % "5.9.0")
2 changes: 1 addition & 1 deletion version.sbt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version in ThisBuild := "0.4.4"
ThisBuild / version := "0.4.4"