Skip to content

Commit

Permalink
Merge pull request #46 from http4s/sbt-spiewak
Browse files Browse the repository at this point in the history
Adopt sbt-spiewak
  • Loading branch information
rossabaker authored Dec 4, 2020
2 parents 5ef5b5e + 4df1587 commit 626bd3d
Show file tree
Hide file tree
Showing 10 changed files with 78 additions and 289 deletions.
101 changes: 26 additions & 75 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,13 @@ on:
branches: ['*']
push:
branches: ['*']
tags: [v*]
tags: [v*, v*]

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
PGP_SECRET: ${{ secrets.PGP_SECRET }}

jobs:
build:
Expand All @@ -37,44 +40,17 @@ jobs:
with:
java-version: ${{ matrix.java }}

- name: Cache ivy2
uses: actions/cache@v1
with:
path: ~/.ivy2/cache
key: ${{ runner.os }}-sbt-ivy-cache-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }}

- name: Cache coursier (generic)
uses: actions/cache@v1
with:
path: ~/.coursier/cache/v1
key: ${{ runner.os }}-generic-sbt-coursier-cache-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }}

- name: Cache coursier (linux)
if: contains(runner.os, 'linux')
uses: actions/cache@v1
with:
path: ~/.cache/coursier/v1
key: ${{ runner.os }}-sbt-coursier-cache-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }}

- name: Cache coursier (macOS)
if: contains(runner.os, 'macos')
uses: actions/cache@v1
with:
path: ~/Library/Caches/Coursier/v1
key: ${{ runner.os }}-sbt-coursier-cache-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }}

- name: Cache coursier (windows)
if: contains(runner.os, 'windows')
uses: actions/cache@v1
with:
path: ~/AppData/Local/Coursier/Cache/v1
key: ${{ runner.os }}-sbt-coursier-cache-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }}

- name: Cache sbt
uses: actions/cache@v1
uses: actions/cache@v2
with:
path: ~/.sbt
key: ${{ runner.os }}-sbt-cache-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }}
path: |
~/.sbt
~/.ivy2/cache
~/.coursier/cache/v1
~/.cache/coursier/v1
~/AppData/Local/Coursier/Cache/v1
~/Library/Caches/Coursier/v1
key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }}

- name: Check that workflows are up to date
run: sbt ++${{ matrix.scala }} githubWorkflowCheck
Expand Down Expand Up @@ -121,44 +97,17 @@ jobs:
with:
java-version: ${{ matrix.java }}

- name: Cache ivy2
uses: actions/cache@v1
with:
path: ~/.ivy2/cache
key: ${{ runner.os }}-sbt-ivy-cache-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }}

- name: Cache coursier (generic)
uses: actions/cache@v1
with:
path: ~/.coursier/cache/v1
key: ${{ runner.os }}-generic-sbt-coursier-cache-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }}

- name: Cache coursier (linux)
if: contains(runner.os, 'linux')
uses: actions/cache@v1
with:
path: ~/.cache/coursier/v1
key: ${{ runner.os }}-sbt-coursier-cache-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }}

- name: Cache coursier (macOS)
if: contains(runner.os, 'macos')
uses: actions/cache@v1
with:
path: ~/Library/Caches/Coursier/v1
key: ${{ runner.os }}-sbt-coursier-cache-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }}

- name: Cache coursier (windows)
if: contains(runner.os, 'windows')
uses: actions/cache@v1
with:
path: ~/AppData/Local/Coursier/Cache/v1
key: ${{ runner.os }}-sbt-coursier-cache-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }}

- name: Cache sbt
uses: actions/cache@v1
uses: actions/cache@v2
with:
path: ~/.sbt
key: ${{ runner.os }}-sbt-cache-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }}
path: |
~/.sbt
~/.ivy2/cache
~/.coursier/cache/v1
~/.cache/coursier/v1
~/AppData/Local/Coursier/Cache/v1
~/Library/Caches/Coursier/v1
key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }}

- name: Download target directories (2.12.12)
uses: actions/download-artifact@v2
Expand All @@ -170,5 +119,7 @@ jobs:
tar xf targets.tar
rm targets.tar
- name: Release
run: sbt ++${{ matrix.scala }} ci-release
- name: Import signing key
run: echo $PGP_SECRET | base64 -d | gpg --import

- run: sbt ++${{ matrix.scala }} release
41 changes: 4 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# sbt-http4s-org

This project is intended to set up sensible defaults and standards for projects in the http4s organization.
It is not designed for outside use, but we offer it as an inspiration or warning to others.
This project is intended to set up sensible defaults and standards for projects under http4s.org.
If it's useful outside http4s.org, it probably should be pushed further upstream into [sbt-spiewak](https://github.com/djspiewak/sbt-spiewak/).

## Installing it

Expand All @@ -17,12 +17,9 @@ addSbtPlugin("org.http4s" % "sbt-http4s-org" % http4sOrgV)

Triggers automatically. Use on all http4s modules.

* Sets the organization to `org.http4s`
* Sets `-Ybackend-parallelism` compiler option
* Sets an appropriate `-doc-source-url` for your Scaladoc
* Activates the sensible defaults of [sbt-spiewak](https://github.com/djspiewak/sbt-spiewak/)
* Sets the organization info
* Enables automated SPDX license headers with appropriate years
* Enables [scalafmt](https://scalameta.org/scalafmt/)
* Enables [MiMa](https://github.com/lightbend/mima) checks for binary compatibility via [sbt-mima-version-check](https://christopherdavenport.github.io/sbt-mima-version-check/)
* Enables [sbt-github-actions](https://github.com/djspiewak/sbt-github-actions) with settings appropriate to our workflow

### `AlpnBootPlugin`
Expand All @@ -31,33 +28,3 @@ Enable with `enablePlugins(AlpnBootPlugin)`.
Use on example projects that require ALPN support.

* Sets up `-Xbootclasspath` for [ALPN](https://www.eclipse.org/jetty/documentation/current/alpn-chapter.html). Useful primarily for example projects.

### `CompileTimePlugin`

Enable with `enablePlugins(CompileTimePlugin)`.
Mostly useful to support other plugins.

* Sets up a `CompileTime` SBT configuration for libraries that exist at compile time, but not runtime.

### `JavaPlugin`

Enable with `enablePlugins(JavaPlugin)`.

* Turns on `-Xlint:all` warnings
* Enables [sbt-java-formatter](https://github.com/sbt/sbt-java-formatter)

### `PrivateProjectPlugin`

Enable with `enablePlugins(PrivateProjectPlugin)`.
Use on examples, benchmarks, docs, and other projects that should not be published.

* Skips publishing
* Disables MiMa checks.

### `SilencerPlugin`

Enable with `enablePlugins(SilencerPlugin)`

* Adds the [silencer](https://github.com/ghik/silencer) compiler plugin to suppress warnings.
* Adds the supporting library to `CompileTime` and `Test` scopes, so it doesn't leave a trace in production.
* Disabled automatically in Dotty
40 changes: 9 additions & 31 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,39 +1,29 @@
enablePlugins(SonatypeCiRelease)

// Projects
lazy val `sbt-http4s-org` = project
.in(file("."))
.disablePlugins(MimaPlugin)
.enablePlugins(NoPublishPlugin)
.aggregate(core)

lazy val core = project
.in(file("core"))
.enablePlugins(SbtPlugin)
.settings(commonSettings)
.settings(
name := "sbt-http4s-org",
addSbtPlugin("ch.epfl.lamp" % "sbt-dotty" % "0.4.6"),
addSbtPlugin("com.codecommit" % "sbt-github-actions" % "0.9.4"),
addSbtPlugin("com.github.cb372" % "sbt-explicit-dependencies" % "0.2.16"),
addSbtPlugin("com.lightbend.sbt" % "sbt-java-formatter" % "0.6.0"),
addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "0.8.1"),
addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "1.0.0"),
addSbtPlugin("de.heikoseeberger" % "sbt-header" % "5.6.0"),
addSbtPlugin("io.chrisdavenport" % "sbt-mima-version-check" % "0.1.2"),
addSbtPlugin("com.codecommit" % "sbt-spiewak-sonatype" % "0.18.3"),
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.2")
)

// General Settings
lazy val commonSettings = Seq(
scalaVersion := "2.12.12",
crossScalaVersions := Seq(scalaVersion.value),
libraryDependencies ++= Seq(
)
)

// General Settings
inThisBuild(
List(
organization := "org.http4s",
organizationName := "http4s.org",
publishGithubUser := "rossabaker",
publishFullName := "Ross A. Baker",
baseVersion := "0.5",
crossScalaVersions := Seq("2.12.12"),
developers := List(
Developer(
"rossabaker",
Expand All @@ -43,16 +33,6 @@ inThisBuild(
),
homepage := Some(url("https://github.com/http4s/sbt-http4s-org")),
licenses := Seq("Apache-2.0" -> url("https://www.apache.org/licenses/LICENSE-2.0.html")),
pomIncludeRepository := { _ =>
false
},
scalacOptions in (Compile, doc) ++= Seq(
"-groups",
"-sourcepath",
(baseDirectory in LocalRootProject).value.getAbsolutePath,
"-doc-source-url",
"https://github.com/http4s/sbt-http4s-org/blob/v" + version.value + "€{FILE_PATH}.scala"
),
githubWorkflowTargetTags ++= Seq("v*"),
githubWorkflowBuild := Seq(
WorkflowStep
Expand All @@ -61,7 +41,5 @@ inThisBuild(
WorkflowStep.Sbt(List("test"), name = Some("Run tests")),
WorkflowStep.Sbt(List("doc"), name = Some("Build docs"))
),
githubWorkflowPublish := Seq(WorkflowStep.Sbt(List("ci-release"), name = Some("Release"))),
githubWorkflowPublishTargetBranches :=
Seq(RefPredicate.StartsWith(Ref.Tag("v")))
spiewakMainBranches := Seq("main")
))
16 changes: 16 additions & 0 deletions core/src/main/scala/org/http4s/sbt/AlpnBootPlugin.scala
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* Copyright 2020 http4s.org
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.http4s.sbt

import sbt._
Expand Down
16 changes: 0 additions & 16 deletions core/src/main/scala/org/http4s/sbt/CompileTimePlugin.scala

This file was deleted.

Loading

0 comments on commit 626bd3d

Please sign in to comment.