Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
2384da3
Add versioning and release
miguelemosreverte Apr 14, 2022
f954cd9
CI-CD. Normal commits will bump the version as patches, and minor and…
miguelemosreverte Apr 14, 2022
b54faa4
Bump version
Apr 14, 2022
f8a7814
Add PubSub
miguelemosreverte Apr 14, 2022
6afd634
Add Router
miguelemosreverte Apr 14, 2022
4ca5c21
Bump version
Apr 14, 2022
6d72fa9
Only abstracted out concepts
miguelemosreverte Apr 14, 2022
eb134a3
Bump version
Apr 14, 2022
eb9c8fb
Recover not-abstract code
miguelemosreverte Apr 14, 2022
3f15719
Merge branch 'main' of github.com:Prom3th3us/boring
miguelemosreverte Apr 14, 2022
4b466a5
Bump version
Apr 14, 2022
a1fa833
Moved example to branch 'example'
miguelemosreverte Apr 14, 2022
16234c5
Merge branch 'main' of github.com:Prom3th3us/boring
miguelemosreverte Apr 14, 2022
7ffd8c1
Bump version
Apr 14, 2022
90fe4e6
Allow manual dispatch of release/patch workflow
miguelemosreverte Apr 14, 2022
7bab280
Merge branch 'main' of github.com:Prom3th3us/boring
miguelemosreverte Apr 14, 2022
59d1801
Bump version
Apr 14, 2022
9ff78c7
Bump version
Apr 14, 2022
451fdbb
Because the Github Action for package deployment stopped working, rem…
miguelemosreverte Apr 14, 2022
78849da
Merge branch 'main' of github.com:Prom3th3us/boring
miguelemosreverte Apr 14, 2022
1b33a37
Bump version
Apr 14, 2022
c11c46a
Make Router impure
miguelemosreverte Apr 15, 2022
8dde98b
Bump version
Apr 15, 2022
dd6ee77
Add typeclass to RouterF
miguelemosreverte Apr 15, 2022
71c2145
Bump version
Apr 15, 2022
ea8d791
Fix .scalafix
miguelemosreverte Apr 15, 2022
7f370f4
Bump version
Apr 15, 2022
8cca2df
Action now is parametric on the Output type
miguelemosreverte Apr 15, 2022
30abb69
Bump version
Apr 15, 2022
6667b07
Remove type projection usage
miguelemosreverte Apr 15, 2022
e038745
Bump version
Apr 15, 2022
d1932e6
TRY remove action handler + use Any in Router
ffakenz Apr 16, 2022
3c6a8c9
Bump version
Apr 16, 2022
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
1 change: 1 addition & 0 deletions .bsp/sbt.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"name":"sbt","version":"1.6.2","bspVersion":"2.0.0-M5","languages":["scala"],"argv":["/Users/anastasia/.sdkman/candidates/java/11.0.14-zulu/zulu-11.jdk/Contents/Home/bin/java","-Xms100m","-Xmx100m","-classpath","/Users/anastasia/Library/Application Support/JetBrains/IdeaIC2021.3/plugins/Scala/launcher/sbt-launch.jar","xsbt.boot.Boot","-bsp","--sbt-launch-jar=/Users/anastasia/Library/Application%20Support/JetBrains/IdeaIC2021.3/plugins/Scala/launcher/sbt-launch.jar"]}
33 changes: 33 additions & 0 deletions .github/workflows/major.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# This is a basic workflow to help you get started with Actions

name: release/major

on:
workflow_dispatch:

jobs:
sbt:
name: sbt publish
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v2
with:
# we don't know what commit the last tag was it's safer to get entire repo so previousStableVersion resolves
fetch-depth: 0
- name: Set up JDK 11
uses: olafurpg/setup-scala@v10
with:
java-version: adopt@1.11.0-9
- name: Publish
if: github.event.pusher.name != 'GitHub Actions Bot'
run: |-
git config user.name "GitHub Actions Bot"
git config user.email "<>"
sbt "versionBump major"
git add version.sbt
git commit -m "Bump version"
git push origin main
sbt publish
env:
PUBLISH_TOKEN: ${{ secrets.PUBLISH_TOKEN }}
33 changes: 33 additions & 0 deletions .github/workflows/minor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# This is a basic workflow to help you get started with Actions

name: release/minor

on:
workflow_dispatch:

jobs:
sbt:
name: sbt publish
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v2
with:
# we don't know what commit the last tag was it's safer to get entire repo so previousStableVersion resolves
fetch-depth: 0
- name: Set up JDK 11
uses: olafurpg/setup-scala@v10
with:
java-version: adopt@1.11.0-9
- name: Publish
if: github.event.pusher.name != 'GitHub Actions Bot'
run: |-
git config user.name "GitHub Actions Bot"
git config user.email "<>"
sbt "versionBump minor"
git add version.sbt
git commit -m "Bump version"
git push origin main
sbt publish
env:
PUBLISH_TOKEN: ${{ secrets.PUBLISH_TOKEN }}
35 changes: 35 additions & 0 deletions .github/workflows/patch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: release/patch

on:
workflow_dispatch:
push:
branches:
- main
tags: ["*"]

jobs:
sbt:
name: sbt publish
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v2
with:
# we don't know what commit the last tag was it's safer to get entire repo so previousStableVersion resolves
fetch-depth: 0
- name: Set up JDK 11
uses: olafurpg/setup-scala@v10
with:
java-version: adopt@1.11.0-9
- name: Publish
if: github.event.pusher.name != 'GitHub Actions Bot'
run: |-
git config user.name "GitHub Actions Bot"
git config user.email "<>"
sbt "versionBump patch"
git add version.sbt
git commit -m "Bump version"
git push origin main
sbt publish
env:
PUBLISH_TOKEN: ${{ secrets.PUBLISH_TOKEN }}
1 change: 1 addition & 0 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
version = 2.7.5
39 changes: 26 additions & 13 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,13 +1,26 @@
name := "workshop"

version := "0.1"

scalaVersion := "2.13.6"

libraryDependencies ++= List(
"com.softwaremill.sttp.client3" %% "async-http-client-backend-monix" % "3.3.15",
"com.softwaremill.sttp.client3" %% "circe" % "3.3.15",
"io.circe" %% "circe-generic" % "0.14.1"
)

libraryDependencies += "ch.qos.logback" % "logback-classic" % "1.2.11" % Runtime
name := "boring"
scalaVersion := "2.13.3"
organization := "Prom3th3us"

/*
import sbtghpackages.TokenSource.{Environment, GitConfig}
githubOwner := "Prom3th3us"
githubRepository := "boring"
githubTokenSource := TokenSource.Or(
GitConfig("github.token"),
Environment("PUBLISH_TOKEN")
)*/

libraryDependencies += "org.typelevel" %% "cats-effect" % "3.3.11"

libraryDependencies ++= List(
"com.softwaremill.sttp.client3" %% "circe" % "3.3.15",
"io.circe" %% "circe-generic" % "0.14.1"
)

libraryDependencies += "ch.qos.logback" % "logback-classic" % "1.2.11" % Runtime
// https://mvnrepository.com/artifact/com.typesafe/config
libraryDependencies += "com.typesafe" % "config" % "1.4.2"

// https://mvnrepository.com/artifact/org.slf4j/slf4j-api
libraryDependencies += "org.slf4j" % "slf4j-api" % "1.7.36"
57 changes: 57 additions & 0 deletions project/VersionBump.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import sbt.Keys.version

import scala.util.Try

class VersionBump(currentVersion: String) {

def apply(arg: Option[String]): Option[Unit] =
for {
argument <- arg //
done <- argument match {
case "patch" =>
Versioning.increasePatchVersion
case "minor" =>
Versioning.increaseMinorVersion
case "major" =>
Versioning.increaseMajorVersion
case _ =>
None
}
} yield done

case class Version(major: Int, minor: Int, patch: Int) {
override def toString = s"""version := "$major.$minor.$patch""""
def majorRelease = copy(major = major + 1, minor = 0, patch = 0)
def minorRelease = copy(minor = minor + 1, patch = 0)
def patchRelease = copy(patch = patch + 1)
}
object Version {
def apply(version: String): Option[Version] = {
version.split('.').toList match {
case major :: minor :: patch :: ignored =>
for {
major <- Try(major.toInt).toOption
minor <- Try(minor.toInt).toOption
patch <- Try(patch.toInt).toOption
} yield Version(major, minor, patch)
case _ => None
}
}
}

object Versioning {
import java.io.PrintWriter
private def write(filename: String, text: String) =
new PrintWriter(filename) { write(text); close() }

private def perform(upgrade: Version => Version): Option[Unit] =
Version(currentVersion).map { version =>
write("version.sbt", s"${upgrade(version)}")
}

def increaseMajorVersion: Option[Unit] = perform(_.majorRelease)
def increaseMinorVersion: Option[Unit] = perform(_.minorRelease)
def increasePatchVersion: Option[Unit] = perform(_.patchRelease)
}

}
1 change: 1 addition & 0 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
//addSbtPlugin("com.codecommit" % "sbt-github-packages" % "0.5.2")
43 changes: 0 additions & 43 deletions src/main/scala/arch/app/Runner.scala

This file was deleted.

64 changes: 48 additions & 16 deletions src/main/scala/arch/common/Program.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,39 +10,71 @@ object Program {

type MError[F[_]] = MonadError[F, ProgramError]
case class Context(name: String, metadata: Map[String, Any] = Map.empty)
case class ProgramError(error: Any, msg: String, ctx: Context, errorCode: Int = unknownErrorCode, stackTrace: Seq[String] = Seq.empty)
case class ProgramError(
error: Any,
msg: String,
ctx: Context,
errorCode: Int = unknownErrorCode,
stackTrace: Seq[String] = Seq.empty
)

object ProgramError {
def fromThrowable(exception: Throwable): Context => Int => ProgramError = ctx => errorCode => {
val stackTrace = Seq.empty // exception.getStackTrace.map(_.toString).take(10)
ProgramError(exception, "error message: " + exception.getMessage, ctx, errorCode, stackTrace)
}
def fromError[E](e: E): Context => Int => ProgramError = ctx => errorCode => {
ProgramError(e, "error message: " + e.toString, ctx, errorCode, stackTrace = Seq.empty)
}
def fromThrowable(exception: Throwable): Context => Int => ProgramError =
ctx =>
errorCode => {
val stackTrace =
Seq.empty // exception.getStackTrace.map(_.toString).take(10)
ProgramError(
exception,
"error message: " + exception.getMessage,
ctx,
errorCode,
stackTrace
)
}
def fromError[E](e: E): Context => Int => ProgramError = ctx =>
errorCode => {
ProgramError(
e,
"error message: " + e.toString,
ctx,
errorCode,
stackTrace = Seq.empty
)
}
}

object MError {
def apply[F[_]](implicit m: MError[F]): MError[F] = m
}

object App {
def fromEither[F[_]: MError, E, A](ctx: Context)(errorCode: => Int = unknownErrorCode)(a: => Either[E, A]): F[A] =
def fromEither[F[_]: MError, E, A](
ctx: Context
)(errorCode: => Int = unknownErrorCode)(a: => Either[E, A]): F[A] =
MError[F].fromEither[A](
a match {
case Left(e) => Left(ProgramError.fromError(e)(ctx)(errorCode))
case Left(e) => Left(ProgramError.fromError(e)(ctx)(errorCode))
case Right(value) => Right(value)
}
)
def fromTry[F[_]: MError, A](ctx: Context)(errorCode: => Int = unknownErrorCode)(a: => Try[A]): F[A] =
def fromTry[F[_]: MError, A](
ctx: Context
)(errorCode: => Int = unknownErrorCode)(a: => Try[A]): F[A] =
MError[F].fromEither[A](
a match {
case Failure(exception) => Left(ProgramError.fromThrowable(exception)(ctx)(errorCode))
case Failure(exception) =>
Left(ProgramError.fromThrowable(exception)(ctx)(errorCode))
case Success(value) => Right(value)
}
)
def lift[F[_]: MError, A](ctx: Context)(errorCode: => Int = unknownErrorCode)(a: => A = ()): F[A] = fromTry(ctx)(errorCode)(Try(a))
def apply[F[_]: MError, A](ctx: Context, errorCode: => Int = unknownErrorCode)(a: => A): F[A] = lift(ctx)(errorCode)(a)
def unit[F[_]: MError](ctx: Context): F[Unit] = apply(ctx)()
def lift[F[_]: MError, A](ctx: Context)(
errorCode: => Int = unknownErrorCode
)(a: => A = ()): F[A] = fromTry(ctx)(errorCode)(Try(a))
def apply[F[_]: MError, A](
ctx: Context,
errorCode: => Int = unknownErrorCode
)(a: => A): F[A] = lift(ctx)(errorCode)(a)
def unit[F[_]: MError](ctx: Context): F[Unit] = apply[F, Unit](ctx)(())
}
}
}
52 changes: 0 additions & 52 deletions src/main/scala/arch/common/ProgramBuilder.scala

This file was deleted.

Loading