Skip to content

Commit

Permalink
OpenFeature: Enable publishing of openfeature modules (#22)
Browse files Browse the repository at this point in the history
Switch publishing on, remove `ff4s` from package and module names
  • Loading branch information
alexcardell authored Sep 10, 2024
1 parent d7515da commit b4e047f
Show file tree
Hide file tree
Showing 39 changed files with 121 additions and 80 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,11 @@ jobs:

- name: Make target directories
if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main')
run: mkdir -p flipt/sdk-server/native/target flipt/sdk-server/js/target flipt/sdk-server-it/.jvm/target flipt/sdk-server/jvm/target project/target
run: mkdir -p openfeature/provider-flipt/.jvm/target flipt/sdk-server/native/target flipt/sdk-server/js/target flipt/sdk-server-it/.jvm/target openfeature/sdk-circe/.native/target openfeature/sdk-circe/.jvm/target openfeature/provider-flipt/.native/target openfeature/sdk-circe/.js/target openfeature/sdk/.native/target openfeature/provider-flipt/.js/target openfeature/sdk/.jvm/target openfeature/sdk/.js/target flipt/sdk-server/jvm/target project/target

- name: Compress target directories
if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main')
run: tar cf targets.tar flipt/sdk-server/native/target flipt/sdk-server/js/target flipt/sdk-server-it/.jvm/target flipt/sdk-server/jvm/target project/target
run: tar cf targets.tar openfeature/provider-flipt/.jvm/target flipt/sdk-server/native/target flipt/sdk-server/js/target flipt/sdk-server-it/.jvm/target openfeature/sdk-circe/.native/target openfeature/sdk-circe/.jvm/target openfeature/provider-flipt/.native/target openfeature/sdk-circe/.js/target openfeature/sdk/.native/target openfeature/provider-flipt/.js/target openfeature/sdk/.jvm/target openfeature/sdk/.js/target flipt/sdk-server/jvm/target project/target

- name: Upload target directories
if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main')
Expand Down Expand Up @@ -251,7 +251,7 @@ jobs:
- name: Submit Dependencies
uses: scalacenter/sbt-dependency-submission@v2
with:
modules-ignore: ff4s-open-feature-provider-flipt-it_2.13 ff4s-open-feature-provider-flipt-it_3 ff4s-open-feature-sdk-circe_native0.4_2.13 ff4s-open-feature-sdk-circe_native0.4_3 ff4s-open-feature-provider-flipt_native0.4_2.13 ff4s-open-feature-provider-flipt_native0.4_3 ff4s-open-feature-sdk-circe_2.13 ff4s-open-feature-sdk-circe_3 ff4s-open-feature-sdk-circe_sjs1_2.13 ff4s-open-feature-sdk-circe_sjs1_3 ff4s-open-feature-sdk_native0.4_2.13 ff4s-open-feature-sdk_native0.4_3 ff4s-open-feature-provider-flipt_2.13 ff4s-open-feature-provider-flipt_3 ff4s-open-feature-sdk_2.13 ff4s-open-feature-sdk_3 rootjs_2.13 rootjs_3 docs_2.13 docs_3 ff4s-open-feature-provider-flipt_sjs1_2.13 ff4s-open-feature-provider-flipt_sjs1_3 rootjvm_2.13 rootjvm_3 rootnative_2.13 rootnative_3 examples_2.13 examples_3 ff4s-open-feature-sdk_sjs1_2.13 ff4s-open-feature-sdk_sjs1_3
modules-ignore: rootjs_2.13 rootjs_3 docs_2.13 docs_3 openfeature-provider-flipt-it_2.13 openfeature-provider-flipt-it_3 rootjvm_2.13 rootjvm_3 rootnative_2.13 rootnative_3 examples_2.13 examples_3
configs-ignore: test scala-tool scala-doc-tool test-internal

site:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ff4s - Feature Flags

[![Latest version](https://index.scala-lang.org/alexcardell/ff4s/ff4s-flipt-sdk-server/latest.svg?color=orange)](https://index.scala-lang.org/alexcardell/ff4s/ff4s-flipt-sdk-server)
[![Latest version](https://index.scala-lang.org/alexcardell/ff4s/openfeature-sdk/latest.svg?color=green)](https://index.scala-lang.org/alexcardell/ff4s/openfeature-sdk)

Visit the [site](https://alexcardell.github.io/ff4s)
54 changes: 28 additions & 26 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// https://typelevel.org/sbt-typelevel/faq.html#what-is-a-base-version-anyway
ThisBuild / tlBaseVersion := "0.1" // your current series x.y
ThisBuild / tlBaseVersion := "0.2" // your current series x.y

ThisBuild / organization := "io.cardell"
ThisBuild / organizationName := "Alex Cardell"
Expand Down Expand Up @@ -30,9 +30,11 @@ Global / concurrentRestrictions += Tags.limit(Tags.Test, 1)
lazy val projects = Seq(
`flipt-sdk-server`,
`flipt-sdk-server-it`,
`open-feature-sdk`,
`open-feature-provider-flipt`,
`open-feature-provider-flipt-it`,
`openfeature-sdk`,
`openfeature-sdk-circe`,
`openfeature-provider-flipt`,
`openfeature-provider-flipt-it`,
examples,
docs
)

Expand All @@ -56,7 +58,7 @@ lazy val `flipt-sdk-server` = crossProject(
.in(file("flipt/sdk-server"))
.settings(commonDependencies)
.settings(
name := "ff4s-flipt-sdk-server",
name := "flipt-sdk-server",
libraryDependencies ++= Seq(
"org.http4s" %%% "http4s-client" % "0.23.26",
"org.http4s" %%% "http4s-circe" % "0.23.26",
Expand All @@ -78,77 +80,74 @@ lazy val `flipt-sdk-server-it` = crossProject(JVMPlatform)
)
.dependsOn(`flipt-sdk-server`)

lazy val `open-feature-sdk` = crossProject(
lazy val `openfeature-sdk` = crossProject(
JVMPlatform,
JSPlatform,
NativePlatform
)
.crossType(CrossType.Pure)
.in(file("open-feature/sdk"))
.enablePlugins(NoPublishPlugin)
.in(file("openfeature/sdk"))
.settings(commonDependencies)
.settings(
name := "ff4s-open-feature-sdk"
name := "openfeature-sdk"
)

lazy val `open-feature-sdk-circe` = crossProject(
lazy val `openfeature-sdk-circe` = crossProject(
JVMPlatform,
JSPlatform,
NativePlatform
)
.crossType(CrossType.Pure)
.in(file("open-feature/sdk-circe"))
.enablePlugins(NoPublishPlugin)
.in(file("openfeature/sdk-circe"))
.settings(commonDependencies)
.settings(
name := "ff4s-open-feature-sdk-circe",
name := "openfeature-sdk-circe",
libraryDependencies ++= Seq(
"io.circe" %%% "circe-core" % "0.14.7",
"io.circe" %%% "circe-parser" % "0.14.7"
)
)
.dependsOn(`open-feature-sdk`)
.dependsOn(`openfeature-sdk`)

lazy val `open-feature-provider-flipt` = crossProject(
lazy val `openfeature-provider-flipt` = crossProject(
JVMPlatform,
JSPlatform,
NativePlatform
)
.crossType(CrossType.Pure)
.in(file("open-feature/provider-flipt"))
.enablePlugins(NoPublishPlugin)
.in(file("openfeature/provider-flipt"))
.settings(commonDependencies)
.settings(
name := "ff4s-open-feature-provider-flipt"
name := "openfeature-provider-flipt"
)
.dependsOn(
`open-feature-sdk`,
`openfeature-sdk`,
`flipt-sdk-server`
)

lazy val `open-feature-provider-flipt-it` = crossProject(JVMPlatform)
lazy val `openfeature-provider-flipt-it` = crossProject(JVMPlatform)
.crossType(CrossType.Pure)
.in(file("open-feature/provider-flipt-it"))
.in(file("openfeature/provider-flipt-it"))
.enablePlugins(NoPublishPlugin)
.settings(commonDependencies)
.settings(
name := "ff4s-open-feature-provider-flipt-it",
name := "openfeature-provider-flipt-it",
libraryDependencies ++= Seq(
"org.http4s" %%% "http4s-ember-client" % "0.23.26" % Test,
"com.dimafeng" %% "testcontainers-scala-munit" % "0.41.3" % Test,
"io.circe" %%% "circe-generic" % "0.14.7" % Test
)
)
.dependsOn(
`open-feature-provider-flipt`,
`open-feature-sdk-circe`
`openfeature-provider-flipt`,
`openfeature-sdk-circe`
)

lazy val examples = crossProject(JVMPlatform)
.crossType(CrossType.Pure)
.in(file("examples"))
.enablePlugins(NoPublishPlugin)
.dependsOn(`open-feature-provider-flipt`)
.dependsOn(`openfeature-provider-flipt`)

lazy val docs = project
.in(file("site"))
Expand All @@ -166,6 +165,9 @@ lazy val docs = project
"org.http4s" %%% "http4s-ember-client" % "0.23.26"
)
)
.dependsOn(`open-feature-provider-flipt`.jvm)
.dependsOn(
`openfeature-provider-flipt`.jvm,
`openfeature-sdk-circe`.jvm
)

addCommandAlias("fix", "headerCreateAll;scalafixAll;scalafmtAll;scalafmtSbt")
45 changes: 34 additions & 11 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,26 @@

## Features

- ✅ Cross-platform, cross-version Scala feature flagging
-[Flipt](https://flipt.io) client
- 🚧 [OpenFeature](https://openfeature.dev) SDK
- 🚧 Flipt OpenFeature provider
- Cross-platform, cross-version Scala feature flagging
- [Flipt](https://flipt.io) client
- [OpenFeature](https://openfeature.dev) SDK
- Provider Evaluation
- 🚧 Hooks
- Flipt OpenFeature provider
- LaunchDarkly OpenFeature provider with [Catalyst](https://typelevel.org/catapult)

## Installing

```scala
libraryDependencies += "io.cardell" %%% "ff4s-flipt-server-sdk" % "@VERSION@"
libraryDependencies += "io.cardell" %%% "flipt-sdk-server" % "@VERSION@"
// or
libraryDependencies ++= Seq(
"io.cardell" %%% "openfeature-sdk" % "@VERSION@",
// for circe json variant types
"io.cardell" %%% "openfeature-sdk-circe" % "@VERSION@",
// to use flipt as a backend
"io.cardell" %%% "openfeature-provider-flipt" % "@VERSION@"
)
```

## OpenFeature Usage
Expand All @@ -24,15 +34,28 @@ See `Flipt usage` on how to set up the `FliptApi`. Once done, set up a provider:

```scala mdoc
import cats.effect.IO
import io.circe.Decoder

import io.cardell.flipt.FliptApi
import io.cardell.openfeature.OpenFeature
import io.cardell.ff4s.flipt.FliptApi
import io.cardell.openfeature.provider.flipt.FliptProvider
import io.cardell.openfeature.circe._

case class SomeVariant(field: String, field2: Int)

def provider(flipt: FliptApi[IO]) = {
def provider(flipt: FliptApi[IO])(implicit d: Decoder[SomeVariant]) = {
val featureSdk = OpenFeature[IO](new FliptProvider[IO](flipt, "some-namespace"))

featureSdk.client.flatMap { featureClient =>
featureClient.getBooleanValue("boolean-flag", false)
for {
eval <- featureClient.getBooleanValue("boolean-flag", false)
_ <- IO.println(s"${eval}")
eval2 <- featureClient.getStructureValue[SomeVariant](
"structure-flag",
SomeVariant("a", 1)
)
_ <- IO.println(s"${eval2}")
} yield ()
}
}
```
Expand All @@ -45,9 +68,9 @@ The Flipt client is bare-bones, using it is not recommended, unless as OpenFeatu
import cats.effect.IO
import org.http4s.ember.client.EmberClientBuilder
import org.http4s.Uri
import io.cardell.ff4s.flipt.FliptApi
import io.cardell.ff4s.flipt.EvaluationRequest
import io.cardell.ff4s.flipt.auth.AuthenticationStrategy
import io.cardell.flipt.FliptApi
import io.cardell.flipt.EvaluationRequest
import io.cardell.flipt.auth.AuthenticationStrategy

val url: Uri = Uri.unsafeFromString("https://flipt.example.com")
val token: String = "token"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,29 @@
/*
* Copyright 2023 Alex Cardell
*
* 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 io.cardell.openfeature.examples

import io.cardell.ff4s.flipt.FliptApiImpl
import cats.effect.IO
import org.http4s.client.Client
import io.cardell.ff4s.flipt.FliptApi
import org.http4s.Uri
import io.cardell.ff4s.flipt.auth.AuthenticationStrategy
import io.cardell.openfeature.provider.flipt.FliptProvider
import org.http4s.client.Client

import io.cardell.flipt.FliptApi
import io.cardell.flipt.auth.AuthenticationStrategy
import io.cardell.openfeature.OpenFeature
import io.cardell.openfeature.provider.flipt.FliptProvider

object OpenFeatureExample {

Expand All @@ -21,7 +37,7 @@ object OpenFeatureExample {
new FliptProvider[IO](flipt, namespace = "example")
)

featureSdk.client.flatMap { client =>
featureSdk.client.flatMap { client =>
client.getBooleanValue("boolean-flag", false)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package io.cardell.ff4s.flipt
package io.cardell.flipt

import cats.effect.IO
import cats.effect.kernel.Resource
Expand All @@ -30,7 +30,7 @@ import org.http4s.Uri
import org.http4s.ember.client.EmberClientBuilder
import org.testcontainers.containers.wait.strategy.Wait

import io.cardell.ff4s.flipt.auth.AuthenticationStrategy
import io.cardell.flipt.auth.AuthenticationStrategy

class FliptApiImplItTest extends CatsEffectSuite with TestContainerForAll {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,21 @@
* limitations under the License.
*/

package io.cardell.ff4s.flipt
package io.cardell.flipt

import cats.effect.Concurrent
import io.circe.Decoder
import org.http4s.Uri
import org.http4s.client.Client

import io.cardell.ff4s.flipt.auth.AuthMiddleware
import io.cardell.ff4s.flipt.auth.AuthenticationStrategy
import io.cardell.ff4s.flipt.model.AttachmentDecodingError
import io.cardell.ff4s.flipt.model.BatchEvaluationRequest
import io.cardell.ff4s.flipt.model.BatchEvaluationResponse
import io.cardell.ff4s.flipt.model.BooleanEvaluationResponse
import io.cardell.ff4s.flipt.model.StructuredVariantEvaluationResponse
import io.cardell.ff4s.flipt.model.VariantEvaluationResponse
import io.cardell.flipt.auth.AuthMiddleware
import io.cardell.flipt.auth.AuthenticationStrategy
import io.cardell.flipt.model.AttachmentDecodingError
import io.cardell.flipt.model.BatchEvaluationRequest
import io.cardell.flipt.model.BatchEvaluationResponse
import io.cardell.flipt.model.BooleanEvaluationResponse
import io.cardell.flipt.model.StructuredVariantEvaluationResponse
import io.cardell.flipt.model.VariantEvaluationResponse

trait FliptApi[F[_]] {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package io.cardell.ff4s.flipt
package io.cardell.flipt

import cats.effect.Concurrent
import cats.syntax.all._
Expand All @@ -25,12 +25,12 @@ import org.http4s.Uri
import org.http4s.circe.CirceEntityCodec._
import org.http4s.client.Client

import io.cardell.ff4s.flipt.model.AttachmentDecodingError
import io.cardell.ff4s.flipt.model.BatchEvaluationRequest
import io.cardell.ff4s.flipt.model.BatchEvaluationResponse
import io.cardell.ff4s.flipt.model.BooleanEvaluationResponse
import io.cardell.ff4s.flipt.model.StructuredVariantEvaluationResponse
import io.cardell.ff4s.flipt.model.VariantEvaluationResponse
import io.cardell.flipt.model.AttachmentDecodingError
import io.cardell.flipt.model.BatchEvaluationRequest
import io.cardell.flipt.model.BatchEvaluationResponse
import io.cardell.flipt.model.BooleanEvaluationResponse
import io.cardell.flipt.model.StructuredVariantEvaluationResponse
import io.cardell.flipt.model.VariantEvaluationResponse

protected[flipt] class FliptApiImpl[F[_]: Concurrent](
client: Client[F],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package io.cardell.ff4s.flipt.auth
package io.cardell.flipt.auth

import cats.effect.kernel.MonadCancelThrow
import org.http4s.AuthScheme
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package io.cardell.ff4s.flipt.auth
package io.cardell.flipt.auth

sealed trait AuthenticationStrategy

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
* limitations under the License.
*/

package io.cardell.ff4s.flipt.model
package io.cardell.flipt.model

import io.circe.Encoder
import io.circe.generic.semiauto.deriveEncoder

import io.cardell.ff4s.flipt.EvaluationRequest
import io.cardell.flipt.EvaluationRequest

case class BatchEvaluationRequest(
requestId: Option[String],
Expand Down
Loading

0 comments on commit b4e047f

Please sign in to comment.