Skip to content

Commit

Permalink
Update sbt to 1.9.0, migrate to new sbt syntax && Modernize a bit the…
Browse files Browse the repository at this point in the history
… CI (add ScalaSteward, dependabot and release-drafter) (#220)

* Update sbt to 1.9.0, migrate to new sbt syntax && Modernize a bit the CI (add ScalaSteward, dependabot and release-drafter)
  • Loading branch information
guizmaii committed Jun 5, 2023
1 parent f785d91 commit 6edee72
Show file tree
Hide file tree
Showing 10 changed files with 77 additions and 30 deletions.
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"
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
- uses: actions/setup-java@v3
with:
java-version: "adopt@1.${{ matrix.java }}"
- uses: coursier/cache-action@v5
distribution: temurin
java-version: ${{ matrix.java }}
cache: sbt
- 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
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

# 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"

0 comments on commit 6edee72

Please sign in to comment.