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 build and pipeline #67

Draft
wants to merge 11 commits into
base: master
Choose a base branch
from
Draft
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
43 changes: 41 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,45 @@
# SBT
# bloop and metals
.bloop
.bsp

# metals
project/metals.sbt
.metals

# vs code
.vscode

# scala 3
.tasty

# sbt
project/project/
project/target/
target/

# IDE
# eclipse
build/
.classpath
.project
.settings
.worksheet
bin/
.cache

# intellij idea
*.log
*.iml
*.ipr
*.iws
.idea

# mac
.DS_Store

# other?
.history
.scala_dependencies
.cache-main

#general
*.class
21 changes: 21 additions & 0 deletions .scalafix.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
rules = [
RemoveUnused,
NoAutoTupling,
DisableSyntax,
LeakingImplicitClassVal,
NoValInForComprehension,
ProcedureSyntax
]

OrganizeImports {
coalesceToWildcardImportThreshold = 8
expandRelative = true
groupedImports = Merge
importSelectorsOrder = SymbolsFirst
removeUnused = false
groups = [
"java."
"*"
"scala."
]
}
11 changes: 11 additions & 0 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version = 3.5.8

align.preset = most
includeCurlyBraceInSelectChains = false
maxColumn = 120
newlines.sometimesBeforeColonInMethodReturnType = false
project.git = true
rewrite.rules = [SortImports, RedundantBraces, RedundantParens, PreferCurlyFors]
runner.dialect = scala3
spaces.beforeContextBoundColon = Always
style = defaultWithAlign
29 changes: 23 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,32 @@ jdk:
branches:
only:
- master
- /^v\d+\.\d+\.\d+$/

before_install:
- git fetch --tags

stages:
- name: test
- name: release
if: ((branch = master AND type = push) OR (tag IS present)) AND NOT fork

# https://www.scala-sbt.org/1.x/docs/Travis-CI-with-sbt.html
cache:
directories:
- $HOME/.cache/coursier
- $HOME/.ivy2/cache
- $HOME/.sbt/boot/
- $HOME/.sbt

before_cache:
- find $HOME/.ivy2 -name "ivydata-*.properties" -delete
- find $HOME/.sbt -name "*.lock" -delete
- rm -fv $HOME/.ivy2/.sbt.ivy.lock
- find $HOME/.ivy2/cache -name "ivydata-*.properties" -print -delete
- find $HOME/.sbt -name "*.lock" -print -delete

script:
- sbt ++$TRAVIS_SCALA_VERSION ciBuild
jobs:
include:
# stage="test" if no stage is specified
- name: ciBuild
script: sbt ciBuild
# run ci-release only if previous stages passed
- stage: release
script: sbt ci-release
43 changes: 24 additions & 19 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,24 +1,29 @@
Copyright (c) 2017-2019, Sky CP Ltd
BSD 3-Clause License

Copyright (c) 2018-2022, Sky CP Ltd
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the <organization> nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

* Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
42 changes: 30 additions & 12 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
import Aliases._
import Bintray._
import BuildInfo._
import Release._
import Docker._

val kafkaVersion = "2.4.1"
lazy val scmUrl = "https://github.com/sky-uk/kafka-configurator"

Global / onChangedBuildSource := ReloadOnSourceChanges
semanticdbEnabled := true
semanticdbVersion := scalafixSemanticdb.revision

ThisBuild / scalafixDependencies += "com.github.liancheng" %% "organize-imports" % "0.6.0"
ThisBuild / dynverSeparator := "-"

lazy val kafkaVersion = "2.4.1"

val kafkaDeps = Seq(
"org.apache.kafka" % "kafka-clients",
"org.apache.kafka" % "kafka-clients",
"org.apache.kafka" %% "kafka"
).map(_ % kafkaVersion)

Expand All @@ -22,7 +29,8 @@ val dependencies = Seq(
"org.slf4j" % "log4j-over-slf4j" % "1.7.25",
"org.slf4j" % "slf4j-api" % "1.7.25",
"ch.qos.logback" % "logback-classic" % "1.2.3" % Runtime,
"org.scalatest" %% "scalatest" % "3.0.5" % Test,
"org.scalatest" %% "scalatest" % "3.2.10" % Test,
"org.scalatestplus" %% "mockito-3-12" % "3.2.10.0" % Test,
"com.pirum" %% "scala-kafka-client-testkit" % s"$kafkaVersion-2" % Test,
"org.mockito" % "mockito-all" % "1.10.19" % Test
) ++ kafkaDeps
Expand All @@ -31,15 +39,25 @@ val root = (project in file("."))
.enablePlugins(BuildInfoPlugin, JavaAppPackaging, UniversalDeployPlugin, DockerPlugin, AshScriptPlugin)
.settings(
defineCommandAliases,
organization := "com.sky",
scalaVersion := "2.12.10",
name := "kafka-configurator",
name := "kafka-configurator",
organization := "uk.sky",
scalaVersion := "2.12.10",
sonatypeCredentialHost := "s01.oss.sonatype.org",
sonatypeRepository := "https://s01.oss.sonatype.org/service/local",
homepage := Some(url(scmUrl)),
licenses := List("BSD New" -> url("https://opensource.org/licenses/BSD-3-Clause")),
developers := List(
Developer(
"Sky UK OSS",
"Sky UK OSS",
sys.env.getOrElse("SONATYPE_EMAIL", scmUrl),
url(scmUrl)
)
),
libraryDependencies ++= dependencies,
resolvers += Resolver.bintrayRepo("cakesolutions", "maven"),
scalacOptions += "-language:implicitConversions",
fork in run := true,
scalacOptions -= "-Ywarn-value-discard",
run / fork := true,
buildInfoSettings,
releaseSettings,
bintraySettings,
dockerSettings
)
10 changes: 6 additions & 4 deletions project/Aliases.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ import sbt._

object Aliases {

lazy val defineCommandAliases = {
addCommandAlias("ciBuild", ";clean; test") ++
addCommandAlias("ciRelease", ";clean; release with-defaults")
}
lazy val defineCommandAliases: Seq[Def.Setting[State => State]] =
addCommandAlias("checkFix", "scalafixAll --check OrganizeImports; scalafixAll --check") ++
addCommandAlias("runFix", "scalafixAll OrganizeImports; scalafixAll") ++
addCommandAlias("checkFmt", "scalafmtCheckAll; scalafmtSbtCheck") ++
addCommandAlias("runFmt", "scalafmtAll; scalafmtSbt") ++
addCommandAlias("ciBuild", "clean; checkFmt; checkFix; test")
}
13 changes: 0 additions & 13 deletions project/Bintray.scala

This file was deleted.

2 changes: 1 addition & 1 deletion project/BuildInfo.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import sbtbuildinfo.BuildInfoPlugin.autoImport._

object BuildInfo {
lazy val buildInfoSettings = Seq(
buildInfoKeys := Seq[BuildInfoKey](name, version, scalaVersion, sbtVersion),
buildInfoKeys := Seq[BuildInfoKey](name, version, scalaVersion, sbtVersion),
buildInfoPackage := "com.sky"
)
}
19 changes: 9 additions & 10 deletions project/Docker.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,19 @@ import sbt.Keys._

object Docker {

lazy val dockerSettings = Seq(
packageName in docker := packageName.value,
dockerBaseImage := "alpine:3.13.0",
dockerUpdateLatest := updateLatest.value,
dockerRepository := Some("skyuk"),
lazy val dockerSettings: Seq[Def.Setting[_]] = Seq(
docker / packageName := packageName.value,
dockerBaseImage := "alpine:3.17.1",
dockerAliases ++= {
val dockerTag = (tag: String) => Seq(dockerAlias.value.withTag(Option(tag)))
if (isSnapshot.value) dockerTag("snapshot") else dockerTag("latest")
},
dockerRepository := Some("skyuk"),
dockerLabels := Map("maintainer" -> "Sky"),
dockerCommands ++= Seq(
Cmd("USER", "root"),
Cmd("RUN", "apk add --no-cache openjdk11-jre")
)
)

def updateLatest = Def.setting {
if (!version.value.contains("SNAPSHOT")) true
else false
}
}

37 changes: 0 additions & 37 deletions project/Release.scala

This file was deleted.

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.1
sbt.version=1.8.0
10 changes: 6 additions & 4 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.9.0" )
addSbtPlugin("com.github.gseitz" % "sbt-release" % "1.0.10")
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.3.15")
addSbtPlugin("org.foundweekends" % "sbt-bintray" % "0.5.1")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.0")
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.10.4")
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.11.0")
addSbtPlugin("com.github.sbt" % "sbt-native-packager" % "1.9.9")
addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.11")
addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat" % "0.4.1")
Loading