Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
15 changes: 15 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
version: 2
updates:
# keeps the commit-pinned actions in the workflows up to date, updating the version comments too
- package-ecosystem: github-actions
directory: /
schedule:
interval: weekly
# give the ecosystem a week to catch a compromised release before it gets proposed here
cooldown:
default-days: 7
# one PR for all the actions instead of one per action
groups:
github-actions:
patterns:
- "*"
23 changes: 14 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,26 @@ on:
branches: [ main ]
pull_request:

permissions:
contents: read

jobs:
build:
ci-build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
# fetch tags - tags are needed for versionPolicyCheck binary and source compat checks
fetch-tags: true
- uses: coursier/cache-action@v6
# SBT 1 base JDK version is 1.8
- uses: actions/setup-java@v5
# Fetch all history for all branches and tags.
# Tags are needed for versionPolicyCheck binary and source compat checks.
# In a shallow clone the previous release tag isn't reachable from HEAD and the checks are silently skipped.
fetch-depth: 0
persist-credentials: false
- uses: coursier/cache-action@ee0650f98295f27a505e4bfd284c9bfaa913a465 # v9.0.1
- uses: actions/setup-java@b843ebf9b913146b38da2eaa7aeddf76074ae1ad # v6.1.0
with:
java-version: 8
java-version-file: .java-version
distribution: temurin
cache: sbt
- uses: sbt/setup-sbt@v1
- uses: sbt/setup-sbt@b113b960ba361e87e08ce02a390d51871b7ee459 # v1.5.13
- name: sbt build
run: sbt clean buildFull
2 changes: 1 addition & 1 deletion .github/workflows/dependency-graph.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ permissions:

jobs:
submit:
uses: evolution-gaming/scala-github-actions/.github/workflows/dependency-graph.yml@2a50f1819b6fef2657ba802fd62612b7fc8450f0 # v6.4.0
uses: evolution-gaming/scala-github-actions/.github/workflows/dependency-graph.yml@144b8762ece97a25b24621f9d470542fa1e068b4 # v7.2.0
39 changes: 29 additions & 10 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,40 +4,59 @@ on:
push:
tags: [ "v*" ]

# deleting the release tag and creating the GitHub release both need write access
permissions:
contents: write

# run only one release action at a time for the repo, wait for the previous to finish before running another one
concurrency:
group: ${{ github.repository }}-${{ github.workflow }}
# by default only one run can be pending, an older pending run gets cancelled and leaves its tag behind
queue: max

jobs:
publish:
runs-on: ubuntu-latest
# a timed out job is cancelled instead of hanging for the default 6 hours,
# see the tag deletion step for what happens to the release tag then
timeout-minutes: 90
steps:
- uses: actions/checkout@v5
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
# Fetch all history for all branches and tags - just in case it's all necessary for ci-release.
# Tags are needed for versionPolicyCheck binary and source compat checks.
fetch-depth: 0
- uses: coursier/cache-action@v6
# SBT 1 base JDK version is 1.8
- uses: actions/setup-java@v5
# don't leave the write token in the git config where the build and its plugins can read it
persist-credentials: false
# No dependency caches here: caches written by main branch CI runs are restorable by tag runs,
# so anything that gets to run in CI could plant code into the job holding the publishing secrets.
- uses: actions/setup-java@b843ebf9b913146b38da2eaa7aeddf76074ae1ad # v6.1.0
with:
java-version: 8
java-version-file: .java-version
distribution: temurin
cache: sbt
- uses: sbt/setup-sbt@v1
# setup-sbt has no option to disable restoring the sbt runner itself from the cache
- uses: sbt/setup-sbt@b113b960ba361e87e08ce02a390d51871b7ee459 # v1.5.13
with:
disk-cache: false
# sbt ci-release doesn't verify the build, need to do it explicitly
- name: sbt build
run: sbt clean buildFull
- run: sbt ci-release
- id: ci-release
run: sbt ci-release
env:
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
PGP_SECRET: ${{ secrets.PGP_SECRET }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}

# A cancellation (manual or by the timeout) during sbt ci-release can come after the bundle got uploaded,
# and Maven Central then publishes the version anyway - the tag is kept to point at the published commit.
- name: delete release tag if failed
if: failure()
run: git push --delete origin ${{ github.ref_name }}
if: failure() || (cancelled() && steps.ci-release.outcome == 'skipped')
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ github.ref_name }}
run: gh api --method DELETE "repos/$GITHUB_REPOSITORY/git/refs/tags/$tag"

- name: publish release notes
if: success()
Expand Down
1 change: 1 addition & 0 deletions .java-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
17
2 changes: 1 addition & 1 deletion .scalafmt.conf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# - better interop with default IntelliJ IDEA setup (matching import and modifiers sorting logic)
# - better developer experience on laptop screens (like 16' MBPs) with IntelliJ IDEA (line wraps)

version = 3.9.9
version = 3.11.5

runner.dialect = scala213source3
fileOverride {
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ SBT version support:

| Supported major SBT version | Built against concrete SBT Version | Build JDK version |
|-----------------------------|------------------------------------|-------------------|
| 1 | 1.4.5 | 1.8 |
| 2 | 2.0.0-RC6 | 1.8 |
| 1 | 1.2.15 | 17 |
| 2 | 2.0.12 | 17 |

If your SBT version is earlier than the build SBT version, the plugin might still work, but the support is not
guaranteed.
Expand Down Expand Up @@ -148,7 +148,7 @@ create your own custom rules.

### Build Requirements

The GitHub Actions CI build is done using JDK 1.8, but locally you can use any JDK up to 17 (including).
JDK 17 and sbt installed.

### Useful SBT commands

Expand Down
65 changes: 37 additions & 28 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -35,48 +35,57 @@ versionPolicyIntention := Compatibility.BinaryCompatible

// setting up sbt 1 and 2 cross-build
// https://www.scala-sbt.org/2.x/docs/en/changes/migrating-from-sbt-1.x.html#cross-building-sbt-plugin-with-sbt-1x
crossScalaVersions += "3.7.3" // version used by SBT 2.0.0-RC6
crossScalaVersions += "3.8.4" // version used by SBT 2.0.12
pluginCrossBuild / sbtVersion := {
scalaBinaryVersion.value match {
// set minimal supported sbt 1 version
// pre 1.4.5 sbt doesn't work on M1 macs: https://github.com/sbt/sbt/issues/6162
case "2.12" => "1.4.5"
case "3" => "2.0.0-RC6"
case "2.12" => "1.12.15"
case "3" => "2.0.12"
}
}

// scalac and scaladoc options
autoAPIMappings := true
scalacOptions ++= Seq(
"-release:8", // increase the version here if sbt 2 changes min JDK reqs
"-deprecation",
)
scalacOptions ++= crossSettings(
scalaVersion = scalaVersion.value,
if2 = Seq(
"-Xsource:3",
),
// Good compiler options for Scala 2.12 are coming from com.evolution:sbt-scalac-opts-plugin:0.0.9,
// but its support for Scala 3 is limited, especially what concerns linting options.
//
// If Scala 3 is made the primary target, good linting scalac options for it should be added first.
if3 = Seq(
"-Xkind-projector:underscores",
scalacOptions := {
val curOptions = scalacOptions.value

// disable new brace-less syntax:
// https://alexn.org/blog/2022/10/24/scala-3-optional-braces/
"-no-indent",
scalaBinaryVersion.value match {
case "2.12" =>
// options for 2.12 come mostly from com.evolution:sbt-scalac-opts-plugin
curOptions ++ Seq(
"-Xsource:3",
)

// improve error messages:
"-explain",
"-explain-types",
),
case "3" =>
// Discarding scalacOptions coming from com.evolution:sbt-scalac-opts-plugin,
// because it adds an option which fails compilation on 3.8.x:
//
// [warn] Option -Xfatal-warnings is a deprecated alias: use -Werror instead
// [error] No warnings can be incurred under -Werror
// [warn] one warning found
// [error] one error found
Seq(
"-Xkind-projector:underscores",

// disable new brace-less syntax:
// https://alexn.org/blog/2022/10/24/scala-3-optional-braces/
"-no-indent",

// improve error messages:
"-explain",
"-explain-types",
)
}
}
// common options
scalacOptions ++= Seq(
"-release:17", // sbt 2 requires JDK 17+
"-deprecation",
)

// migesok: tried several test frameworks, but only munit worked here:
// - scalatest with AnyFreeSpec gave weird compilation errors on valid test code
// - utest 0.9.1 didn't work on Java 8, only 11+, but Java 8 is required for sbt 1
libraryDependencies += "org.scalameta" %% "munit" % "1.2.0" % Test
libraryDependencies += "org.scalameta" %% "munit" % "1.3.6" % Test
// disable parallel test execution and bufferization to have nice linear stdout:
// https://scalameta.org/munit/docs/tests.html#run-tests-in-parallel
Test / parallelExecution := false
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.11.7
sbt.version=1.13.1
8 changes: 4 additions & 4 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
addSbtPlugin("com.evolution" % "sbt-scalac-opts-plugin" % "0.0.9")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.5")
addSbtPlugin("ch.epfl.scala" % "sbt-version-policy" % "3.2.1")
addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.11.2")
addSbtPlugin("com.evolution" % "sbt-scalac-opts-plugin" % "0.2.1")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.6.2")
addSbtPlugin("ch.epfl.scala" % "sbt-version-policy" % "3.4.0")
addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.12.1")
Loading