Skip to content

Commit

Permalink
Revamp the template
Browse files Browse the repository at this point in the history
  • Loading branch information
TonioGela committed Apr 8, 2024
1 parent b606cbf commit 84c7595
Show file tree
Hide file tree
Showing 22 changed files with 100 additions and 172 deletions.
23 changes: 17 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,31 +16,42 @@ on:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}


concurrency:
group: ${{ github.workflow }} @ ${{ github.ref }}
cancel-in-progress: true

jobs:
build:
name: Build and Test
strategy:
matrix:
os: [ubuntu-latest]
scala: [2.12.15]
java: [temurin@8]
scala: [2.12.19]
java: [temurin@11]
runs-on: ${{ matrix.os }}
timeout-minutes: 60
steps:
- name: Checkout current branch (full)
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Java (temurin@8)
if: matrix.java == 'temurin@8'
- name: Setup Java (temurin@11)
id: setup-java-temurin-11
if: matrix.java == 'temurin@11'
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 8
java-version: 11
cache: sbt

- name: sbt update
if: matrix.java == 'temurin@11' && steps.setup-java-temurin-11.outputs.cache-hit == 'false'
run: sbt +update

- name: Check that workflows are up to date
run: sbt '++ ${{ matrix.scala }}' githubWorkflowCheck
run: sbt githubWorkflowCheck

- name: Testing template
run: sbt '++ ${{ matrix.scala }}' g8Test
3 changes: 1 addition & 2 deletions .github/workflows/clean.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Delete artifacts
shell: bash {0}
run: |
# Customize those three lines with your repository and credentials:
REPO=${GITHUB_API_URL}/repos/${{ github.repository }}
Expand All @@ -26,7 +25,7 @@ jobs:
ghapi() { curl --silent --location --user _:$GITHUB_TOKEN "$@"; }
# A temporary file which receives HTTP response headers.
TMPFILE=$(mktemp)
TMPFILE=/tmp/tmp.$$
# An associative array, key: artifact name, value: number of artifacts of that name.
declare -A ARTCOUNT
Expand Down
1 change: 0 additions & 1 deletion .scala-steward.conf

This file was deleted.

2 changes: 0 additions & 2 deletions .scalafix.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ rules = [
RemoveUnused
NoAutoTupling
DisableSyntax
ExplicitResultTypes
LeakingImplicitClassVal
NoValInForComprehension
ProcedureSyntax
OrganizeImports
]

Expand Down
6 changes: 3 additions & 3 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version = "3.8.1"
version = "3.6.1"

# These can be used to delimit zone to do not format
# // format: off
Expand All @@ -11,8 +11,8 @@ version = "3.8.1"
# project.excludeFilters = [regex1, regex2]
# project.includeFilters = [regex1, regex2]

runner.dialect = "scala213source3"
maxColumn = 120
runner.dialect = scala3
maxColumn = 100
assumeStandardLibraryStripMargin = true #x
trailingCommas = never
indentOperator.topLevelOnly = false #x
Expand Down
13 changes: 1 addition & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,4 @@
![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/TonioGela/base.g8/ci.yml?branch=main) ![GitHub last commit](https://img.shields.io/github/last-commit/TonioGela/base.g8) ![GitHub](https://img.shields.io/github/license/TonioGela/base.g8) [![Scala Steward badge](https://img.shields.io/badge/Scala_Steward-helping-blue.svg?style=flat&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAQCAMAAAARSr4IAAAAVFBMVEUAAACHjojlOy5NWlrKzcYRKjGFjIbp293YycuLa3pYY2LSqql4f3pCUFTgSjNodYRmcXUsPD/NTTbjRS+2jomhgnzNc223cGvZS0HaSD0XLjbaSjElhIr+AAAAAXRSTlMAQObYZgAAAHlJREFUCNdNyosOwyAIhWHAQS1Vt7a77/3fcxxdmv0xwmckutAR1nkm4ggbyEcg/wWmlGLDAA3oL50xi6fk5ffZ3E2E3QfZDCcCN2YtbEWZt+Drc6u6rlqv7Uk0LdKqqr5rk2UCRXOk0vmQKGfc94nOJyQjouF9H/wCc9gECEYfONoAAAAASUVORK5CYII=)](https://scala-steward.org)


A [Giter8](https://github.com/foundweekends/giter8) template for [Cats-effect 3](https://typelevel.org/cats-effect/) with a lot of bells and whistles!

This template features:
- a strong `scalafmt` configuration
- a strong `scalafix` configuration + organize import rule
- an opinionated overridden base import with `cats._` and `cats.effect._` stuff
- `munit-cats-effect-3` as test framework
- `sbt-github-actions`, `sbt-tpolecat`, `sbt-updates` plugins
- `kind-projector`, `scala-typed-holes` and `better-monadic-for` compiler plugins
- everything in a way too modular configuration

...plus it should stay up to date with dependencies thanks to [Scala-Steward](https://github.com/scala-steward-org/scala-steward-action)
A [Giter8](https://github.com/foundweekends/giter8) template for [Cats-effect 3](https://typelevel.org/cats-effect/) with a lot of bells and whistles!
41 changes: 18 additions & 23 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,30 +1,25 @@
// This build is for this Giter8 template.

// To test the template run `g8` or `g8Test` from the sbt session.
// See http://www.foundweekends.org/giter8/testing.html#Using+the+Giter8Plugin for more details.
lazy val root = (project in file(".")).enablePlugins(ScriptedPlugin).settings(
lazy val root = (project in file(".")).settings(
name := "base.g8",
scalaVersion := "2.12.15",
scalaVersion := "2.12.19",
Test / test := { val _ = (Test / g8Test).toTask("").value },
scriptedLaunchOpts ++=
List("-Xms1024m", "-Xmx1024m", "-XX:ReservedCodeCacheSize=128m", "-Xss2m", "-Dfile.encoding=UTF-8"),
resolvers +=
Resolver.url("typesafe", url("https://repo.typesafe.com/typesafe/ivy-releases/"))(Resolver.ivyStylePatterns),
// this makes g8 buggy
useSuperShell := false,
scriptedLaunchOpts ++= List(
"-Xms1024m",
"-Xmx1024m",
"-XX:ReservedCodeCacheSize=128m",
"-Xss2m",
"-Dfile.encoding=UTF-8"
),
ThisBuild / githubWorkflowPublishTargetBranches := Seq(),
ThisBuild / githubWorkflowScalaVersions := Seq("2.12.15"),
ThisBuild / githubWorkflowBuild := Seq(WorkflowStep.Sbt(List("g8Test"), name = Some("Testing template"))),
ThisBuild / githubWorkflowScalaVersions := Seq("2.12.19"),
ThisBuild / githubWorkflowBuild :=
Seq(WorkflowStep.Sbt(List("g8Test"), name = Some("Testing template"))),
// These are here for scala-steward
scalafixDependencies += "com.github.liancheng" %% "organize-imports" % "0.6.0",
libraryDependencies ++= Seq(
"org.typelevel" %% "cats-effect" % "3.5.4",
"co.fs2" %% "fs2-core" % "3.10.2",
"com.monovore" %% "decline-effect" % "2.4.1",
"is.cir" %% "ciris" % "3.5.0",
("org.typelevel" % "kind-projector" % "0.13.3").cross(CrossVersion.full),
("com.github.cb372" % "scala-typed-holes" % "0.1.11").cross(CrossVersion.full),
"com.olegpy" %% "better-monadic-for" % "0.3.1",
"org.typelevel" %% "munit-cats-effect-3" % "1.0.7"
"org.typelevel" %% "cats-core" % "2.10.0",
"org.typelevel" %% "cats-effect" % "3.5.4",
"co.fs2" %% "fs2-io" % "3.10.2",
"com.monovore" %% "decline-effect" % "2.4.1",
"com.disneystreaming" %% "weaver-cats" % "0.8.3",
"com.disneystreaming" %% "weaver-scalacheck" % "0.8.3"
)
)
1 change: 0 additions & 1 deletion project/giter8.test
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ $ exists src/main/scala/dev/toniogela/Effectfool.scala
$ exists src/main/scala/dev/toniogela/Main.scala
$ exists src/test/scala/dev/toniogela/EffectfoolSuite.scala
$ exists project/plugins.sbt
$ exists project/Settings.scala
$ exists project/Dependencies.scala
$ exists project/build.properties
$ exists build.sbt
Expand Down
13 changes: 6 additions & 7 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
addSbtPlugin("org.foundweekends.giter8" %% "sbt-giter8" % "0.16.2")
libraryDependencies += "org.scala-sbt" %% "scripted-plugin" % sbtVersion.value
addSbtPlugin("org.foundweekends.giter8" %% "sbt-giter8" % "0.16.2")
libraryDependencies += "org.scala-sbt" %% "scripted-plugin" % sbtVersion.value
// These are here for scala-steward
addSbtPlugin("com.github.sbt" % "sbt-github-actions" % "0.23.0")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.2")
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.12.0")
addSbtPlugin("org.typelevel" % "sbt-tpolecat" % "0.5.1")
addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.6.4")
addSbtPlugin("org.typelevel" % "sbt-typelevel-github-actions" % "0.6.7")
addSbtPlugin("org.typelevel" % "sbt-tpolecat" % "0.5.1")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.2")
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.12.0")
2 changes: 0 additions & 2 deletions src/main/g8/.scalafix.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ rules = [
RemoveUnused
NoAutoTupling
DisableSyntax
ExplicitResultTypes
LeakingImplicitClassVal
NoValInForComprehension
ProcedureSyntax
OrganizeImports
]

Expand Down
4 changes: 2 additions & 2 deletions src/main/g8/.scalafmt.conf
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ version = "3.6.1"
# project.excludeFilters = [regex1, regex2]
# project.includeFilters = [regex1, regex2]

runner.dialect = "scala213source3"
maxColumn = 120
runner.dialect = scala3
maxColumn = 100
assumeStandardLibraryStripMargin = true #x
trailingCommas = never
indentOperator.topLevelOnly = false #x
Expand Down
10 changes: 1 addition & 9 deletions src/main/g8/README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
# $name$

Don't forget to run `git init` and `sbt githubWorkflowGenerate` and to set an homepage url

# Useful commands in this project
- `scalafix`
- `scalafmtSbt`
- `scalafixAll`
- `githubWorkflowGenerate`

You can bundle it with [sbt-native-packager](https://github.com/sbt/sbt-native-packager) or [sbt-native-image](https://github.com/scalameta/sbt-native-image)
Don't forget to run `git init` and `sbt githubWorkflowGenerate`
23 changes: 18 additions & 5 deletions src/main/g8/build.sbt
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
import Dependencies._
import Settings._

inScope(Global)(globalSettings)
inThisBuild(scalaFixSettings ++ sbtGithubActionsSettings ++ publicSettings)
inScope(Global)(
List(onChangedBuildSource := ReloadOnSourceChanges, showSuccess := false, excludeLintKeys += showSuccess)
)

lazy val root = (project in file("."))
.settings(name := "$name$", commonSettings, libraryDependencies ++= coreDependencies ++ testDependencies)
inThisBuild(List(
crossScalaVersions := List("3.4.1"),
githubWorkflowPublishTargetBranches := Nil,
semanticdbEnabled := true,
semanticdbVersion := scalafixSemanticdb.revision
))

lazy val root = (project in file(".")).settings(
scalaVersion := "3.4.1",
name := "$name$",
organization := "dev.toniogela",
organizationName := "toniogela.dev",
version := "0.0.1-SNAPSHOT",
libraryDependencies ++= coreDependencies ++ testDependencies
)
5 changes: 1 addition & 4 deletions src/main/g8/default.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
verbatim=.gitignore .scalafix.conf .scalafmt.conf

name=Effectfool
description=Cats Effect template with a lot of bells and whistles
organization=dev.toniogela
organization_name=toniogela.dev
add_fs2=false
description=Cats Effect template with a lot of bells and whistles
12 changes: 7 additions & 5 deletions src/main/g8/project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ import sbt.Keys._
object Dependencies {

val coreDependencies: Seq[ModuleID] = Seq(
"org.typelevel" %% "cats-effect" % "3.5.4",
"com.monovore" %% "decline-effect" % "2.4.1",
"is.cir" %% "ciris" % "3.5.0",
$if(add_fs2.truthy) $ "co.fs2" %% "fs2-core" % "3.10.2" $endif$
"org.typelevel" %% "cats-core" % "2.10.0",
"org.typelevel" %% "cats-effect" % "3.5.4",
"co.fs2" %% "fs2-io" % "3.10.2",
"com.monovore" %% "decline-effect" % "2.4.1"
)

val testDependencies: Seq[ModuleID] = Seq("org.typelevel" %% "munit-cats-effect-3" % "1.0.7").map(_ % Test)
val testDependencies: Seq[ModuleID] =
Seq("com.disneystreaming" %% "weaver-cats" % "0.8.3", "com.disneystreaming" %% "weaver-scalacheck" % "0.8.3")
.map(_ % Test)

}
69 changes: 0 additions & 69 deletions src/main/g8/project/Settings.scala

This file was deleted.

9 changes: 4 additions & 5 deletions src/main/g8/project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
addSbtPlugin("com.github.sbt" % "sbt-github-actions" % "0.23.0")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.2")
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.12.0")
addSbtPlugin("org.typelevel" % "sbt-tpolecat" % "0.5.1")
addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.6.4")
addSbtPlugin("org.typelevel" % "sbt-typelevel-github-actions" % "0.6.7")
addSbtPlugin("org.typelevel" % "sbt-tpolecat" % "0.5.1")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.2")
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.12.0")

This file was deleted.

7 changes: 7 additions & 0 deletions src/main/g8/src/main/scala/dev/toniogela/$name__Camel$.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package dev.toniogela

import cats.effect.*

object $name; format = "Camel" $ {
def say(): IO[String] = IO.delay("Hello Cats Effect!")
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
package $organization;format="package"$
package dev.toniogela

import cats.effect.*

object Main extends IOApp.Simple {
def run: IO[Unit] = $name;format="Camel"$.say().flatMap(IO.println)
Expand Down

This file was deleted.

Loading

0 comments on commit 84c7595

Please sign in to comment.