Skip to content

Commit

Permalink
migrate the repository to Open Feature
Browse files Browse the repository at this point in the history
  • Loading branch information
nickybondarenko committed Aug 7, 2023
1 parent 74c467d commit 5a116e9
Show file tree
Hide file tree
Showing 63 changed files with 3,372 additions and 0 deletions.
133 changes: 133 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = space
insert_final_newline = false
max_line_length = 100
tab_width = 4
ij_continuation_indent_size = 8
ij_formatter_off_tag = @formatter:off
ij_formatter_on_tag = @formatter:on
ij_formatter_tags_enabled = false
ij_smart_tabs = false
ij_visual_guides = none
ij_wrap_on_typing = false

[{*.kt,*.kts}]
ij_kotlin_align_in_columns_case_branch = false
ij_kotlin_align_multiline_binary_operation = false
ij_kotlin_align_multiline_extends_list = false
ij_kotlin_align_multiline_method_parentheses = false
ij_kotlin_align_multiline_parameters = true
ij_kotlin_align_multiline_parameters_in_calls = false
ij_kotlin_allow_trailing_comma = false
ij_kotlin_allow_trailing_comma_on_call_site = false
ij_kotlin_assignment_wrap = normal
ij_kotlin_blank_lines_after_class_header = 0
ij_kotlin_blank_lines_around_block_when_branches = 0
ij_kotlin_blank_lines_before_declaration_with_comment_or_annotation_on_separate_line = 1
ij_kotlin_block_comment_add_space = false
ij_kotlin_block_comment_at_first_column = true
ij_kotlin_call_parameters_new_line_after_left_paren = true
ij_kotlin_call_parameters_right_paren_on_new_line = true
ij_kotlin_call_parameters_wrap = on_every_item
ij_kotlin_catch_on_new_line = false
ij_kotlin_class_annotation_wrap = split_into_lines
ij_kotlin_code_style_defaults = KOTLIN_OFFICIAL
ij_kotlin_continuation_indent_for_chained_calls = false
ij_kotlin_continuation_indent_for_expression_bodies = false
ij_kotlin_continuation_indent_in_argument_lists = false
ij_kotlin_continuation_indent_in_elvis = false
ij_kotlin_continuation_indent_in_if_conditions = false
ij_kotlin_continuation_indent_in_parameter_lists = false
ij_kotlin_continuation_indent_in_supertype_lists = false
ij_kotlin_else_on_new_line = false
ij_kotlin_enum_constants_wrap = off
ij_kotlin_extends_list_wrap = normal
ij_kotlin_field_annotation_wrap = split_into_lines
ij_kotlin_finally_on_new_line = false
ij_kotlin_if_rparen_on_new_line = true
ij_kotlin_import_nested_classes = false
ij_kotlin_imports_layout = *,java.**,javax.**,kotlin.**,^
ij_kotlin_insert_whitespaces_in_simple_one_line_method = true
ij_kotlin_keep_blank_lines_before_right_brace = 2
ij_kotlin_keep_blank_lines_in_code = 2
ij_kotlin_keep_blank_lines_in_declarations = 2
ij_kotlin_keep_first_column_comment = true
ij_kotlin_keep_indents_on_empty_lines = false
ij_kotlin_keep_line_breaks = true
ij_kotlin_lbrace_on_next_line = false
ij_kotlin_line_comment_add_space = false
ij_kotlin_line_comment_add_space_on_reformat = false
ij_kotlin_line_comment_at_first_column = true
ij_kotlin_method_annotation_wrap = split_into_lines
ij_kotlin_method_call_chain_wrap = normal
ij_kotlin_method_parameters_new_line_after_left_paren = true
ij_kotlin_method_parameters_right_paren_on_new_line = true
ij_kotlin_method_parameters_wrap = on_every_item
ij_kotlin_name_count_to_use_star_import = 5
ij_kotlin_name_count_to_use_star_import_for_members = 3
ij_kotlin_packages_to_use_import_on_demand = unset
ij_kotlin_parameter_annotation_wrap = off
ij_kotlin_space_after_comma = true
ij_kotlin_space_after_extend_colon = true
ij_kotlin_space_after_type_colon = true
ij_kotlin_space_before_catch_parentheses = true
ij_kotlin_space_before_comma = false
ij_kotlin_space_before_extend_colon = true
ij_kotlin_space_before_for_parentheses = true
ij_kotlin_space_before_if_parentheses = true
ij_kotlin_space_before_lambda_arrow = true
ij_kotlin_space_before_type_colon = false
ij_kotlin_space_before_when_parentheses = true
ij_kotlin_space_before_while_parentheses = true
ij_kotlin_spaces_around_additive_operators = true
ij_kotlin_spaces_around_assignment_operators = true
ij_kotlin_spaces_around_equality_operators = true
ij_kotlin_spaces_around_function_type_arrow = true
ij_kotlin_spaces_around_logical_operators = true
ij_kotlin_spaces_around_multiplicative_operators = true
ij_kotlin_spaces_around_range = false
ij_kotlin_spaces_around_relational_operators = true
ij_kotlin_spaces_around_unary_operator = false
ij_kotlin_spaces_around_when_arrow = true
ij_kotlin_use_custom_formatting_for_modifiers = true
ij_kotlin_variable_annotation_wrap = off
ij_kotlin_while_on_new_line = false
ij_kotlin_wrap_elvis_expressions = 1
ij_kotlin_wrap_expression_body_functions = 1
ij_kotlin_wrap_first_method_in_call_chain = false


# Copied from internal settings
[*.kt]
continuation_indent_size = 4
ktlint_standard_annotation = disabled # Annotations don't have to be on separate lines
ktlint_standard_annotation-spacing = disabled # It is ok with a comment between annotation and declaration
ktlint_standard_argument-list-wrapping = disabled # It is ok to have multiple args on one line
ktlint_standard_spacing-between-declarations-with-annotations = disabled # No need for empty line between these
ktlint_standard_spacing-between-declarations-with-comments = disabled # No need for empty line between these
ktlint_standard_trailing-comma-on-call-site = disabled # Trailing commas are ok
ktlint_standard_trailing-comma-on-declaration-site = disabled # Trailing commas are ok

# There is a bug in ktlint making multiline typealias indent in the wrong way:
# https://github.com/pinterest/ktlint/issues/1788 - enable this one this is fixed.
ktlint_standard_indent = disabled

ktlint_experimental_class-naming = enabled
ktlint_experimental_fun-keyword-spacing = enabled
ktlint_experimental_function-type-reference-spacing = enabled
ktlint_experimental_nullable-type-spacing = enabled
ktlint_experimental_spacing-between-function-name-and-opening-parenthesis = enabled
ktlint_experimental_unnecessary-parentheses-before-trailing-lambda = enabled

# Setting max line for Kotlin files, exactly as Detekt config (120 by default) to insure IDE and ktlint formatter
# format the code that is valid for Detekt, avoiding mismatch.
max_line_length=120

# Ignore max line for kotlin test files, the same as Detekt.
[**/{test,androidTest}/**/*.kt]
max_line_length=off
3 changes: 3 additions & 0 deletions .github/CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Code of Conduct

Please refer to the [OpenFeature community page](https://openfeature.dev/community/#code-of-conduct) for more information on Code of Conduct.
18 changes: 18 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: CI

on:
push:
branches:
- 'main'
pull_request:
branches:
- '*'

jobs:
Tests:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Run checks
run: ./gradlew check --no-daemon --stacktrace
54 changes: 54 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Release
on:
push:
tags:
- 'v*'

jobs:
publish:
name: Release Openfeature SDK
runs-on: ubuntu-latest

steps:
- name: Cache Gradle and wrapper
uses: actions/cache@v2
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
restore-keys: |
${{ runner.os }}-gradle-
- uses: actions/checkout@v1

- name: Set up JDK 12
uses: actions/setup-java@v1
with:
java-version: 12

- name: Grant Permission for Gradlew to Execute
run: chmod +x gradlew

- name: Build AAR ⚙️🛠
run: bash ./gradlew :openfeature:assemble
- name: Create Release ✅
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.TOKEN_PUBLISH }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
draft: true
prerelease: false

- name: Upload Openfeature SDK AAR 🗳
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.TOKEN_PUBLISH }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: OpenFeature/build/outputs/aar/OpenFeature-release.aar
asset_name: openfeature-sdk.aar
asset_content_type: application/aar
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build/
17 changes: 17 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
## Getting Started

OpenFeature is not keen on vendor-specific stuff in this library, but if there are changes that need to happen in the spec to enable vendor-specific stuff in user code or other extension points, check out [the spec](https://github.com/open-feature/spec).

## Formatting

This repo uses [ktlint](https://github.com/JLLeitschuh/ktlint-gradle) for formatting.

Please consider adding a pre-commit hook for formatting using

```
./gradlew addKtlintCheckGitPreCommitHook
```
Manual formatting is done by invoking
```
./gradlew ktlintFormat
```
10 changes: 10 additions & 0 deletions OWNERS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Owners

- See [CONTRIBUTING.md](CONTRIBUTING.md) for general contribution guidelines.

## Core Developers

- Fabrizio Demaria (fabriziodemaria, Spotify)
- Nicklas Lundin (nicklasl, Spotify)
- Vahid Torkaman (vahidlazio, Spotify)
- Nicky Bondarenko (nickybondarenko, Spotify)
1 change: 1 addition & 0 deletions OpenFeature/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
74 changes: 74 additions & 0 deletions OpenFeature/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
// ktlint-disable max-line-length
plugins {
id("com.android.library")
id("org.jetbrains.kotlin.android")
id("maven-publish")
id("org.jlleitschuh.gradle.ktlint")
kotlin("plugin.serialization") version "1.8.10"
}

android {
namespace = "dev.openfeature.sdk"
compileSdk = 33

defaultConfig {
minSdk = 21
version = "0.0.1"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
getByName("release") {
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_11.toString()
}
}

dependencies {
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.2")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.5.1")
testImplementation("junit:junit:4.13.2")
testImplementation("org.mockito.kotlin:mockito-kotlin:5.0.0")
testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.7.2")
}

afterEvaluate {
publishing {
publications {
register<MavenPublication>("release") {
groupId = "dev.openfeature"
artifactId = "kotlin-sdk"
version = "0.0.1-SNAPSHOT"

from(components["release"])
artifact(androidSourcesJar.get())

pom {
name.set("OpenfeatureSDK")
}
}
}
}
}

val androidSourcesJar by tasks.registering(Jar::class) {
archiveClassifier.set("sources")
from(android.sourceSets.getByName("main").java.srcDirs)
}

// Assembling should be performed before publishing package
tasks.named("publish") {
dependsOn("assemble")
}
2 changes: 2 additions & 0 deletions OpenFeature/jitpack.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
jdk:
- openjdk11
21 changes: 21 additions & 0 deletions OpenFeature/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.kts.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
3 changes: 3 additions & 0 deletions OpenFeature/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest>
</manifest>
11 changes: 11 additions & 0 deletions OpenFeature/src/main/java/dev/openfeature/sdk/BaseEvaluation.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package dev.openfeature.sdk

import dev.openfeature.sdk.exceptions.ErrorCode

interface BaseEvaluation<T> {
val value: T
val variant: String?
val reason: String?
val errorCode: ErrorCode?
val errorMessage: String?
}
8 changes: 8 additions & 0 deletions OpenFeature/src/main/java/dev/openfeature/sdk/Client.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package dev.openfeature.sdk

interface Client : Features {
val metadata: ClientMetadata
val hooks: List<Hook<*>>

fun addHooks(hooks: List<Hook<*>>)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package dev.openfeature.sdk

interface ClientMetadata {
val name: String?
}
10 changes: 10 additions & 0 deletions OpenFeature/src/main/java/dev/openfeature/sdk/EvaluationContext.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package dev.openfeature.sdk

interface EvaluationContext : Structure {
fun getTargetingKey(): String
fun setTargetingKey(targetingKey: String)

// Make sure these are implemented for correct object comparisons
override fun hashCode(): Int
override fun equals(other: Any?): Boolean
}
Loading

0 comments on commit 5a116e9

Please sign in to comment.