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

Fixing static analysis issues and creating github pipeline #7

Merged
merged 1 commit into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 24 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Java-SDK
on:
workflow_dispatch:
push:
branches:
- main
pull_request:

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Setup Java 8
uses: actions/setup-java@v3
with:
distribution: "adopt"
java-version: "8"
cache: "gradle"

- name: Build Java SDK
run: |
./gradlew clean build
39 changes: 39 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Publish Java-SDK

on:
push:
branches:
- "main"
tags:
- v*
jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Setup Java 8
uses: actions/setup-java@v3
with:
distribution: "adopt"
java-version: "8"
cache: "gradle"

- name: Publish JavaSDK
env:
ORG_GRADLE_PROJECT_VERSION_NAME: ${{ github.event.inputs.versionName }}
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.GPG_KEY }}
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.GPG_PASSWORD }}
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
GRADLE_PROPERTIES: ${{ secrets.GRADLE_PROPERTIES }}
SECRET_FILE_DATA: ${{ secrets.SECRET_FILE_DATA }}
run: |
export GPG_TTY=$(tty)
mkdir -p ~/.gradle/
ln -s /usr/local/bin/gpg /usr/local/bin/gpg2
echo -n "$SECRET_FILE_DATA" | base64 --decode | gpg --import --passphrase "$ORG_GRADLE_PROJECT_signingInMemoryKeyPassword" --batch
echo "GRADLE_USER_HOME=${HOME}/.gradle" >> $GITHUB_ENV
echo "${GRADLE_PROPERTIES}" > ~/.gradle/gradle.properties
./gradlew clean build publish closeAndReleaseSonatypeStagingRepository -x test
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ plugins {


ext {
VERSION = "1.5.3"
VERSION = "1.6.1"
GROUP_ID = "com.absmartly.sdk"

slf4jVersion = "1.7.30"
Expand Down Expand Up @@ -123,8 +123,8 @@ configure(rootProject) {
nexusUrl = uri("https://s01.oss.sonatype.org/service/local/")
snapshotRepositoryUrl = uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")

username = findProperty("ossrh.username")
password = findProperty("ossrh.password")
username = System.getenv('ORG_GRADLE_PROJECT_mavenCentralUsername')
password = System.getenv('ORG_GRADLE_PROJECT_mavenCentralPassword')
}
}
}
Expand Down
24 changes: 12 additions & 12 deletions core-api/src/main/java/com/absmartly/sdk/Context.java
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ public String[] getCustomFieldKeys() {
for (final Experiment experiment : data_.experiments) {
if (experiment.customFieldValues != null) {
for (final CustomFieldValue customFieldValue : experiment.customFieldValues) {
keys.add(customFieldValue.name);
keys.add(customFieldValue.getName());
}
}
}
Expand Down Expand Up @@ -997,18 +997,18 @@ public int compare(ContextExperiment a, ContextExperiment b) {
if (experiment.customFieldValues != null) {
for (final CustomFieldValue customFieldValue : experiment.customFieldValues) {
final ContextCustomFieldValue value = new ContextCustomFieldValue();
contextExperiment.customFieldValues.put(customFieldValue.name, value);

value.type = customFieldValue.type;
if (customFieldValue.value != null) {
if (customFieldValue.type.startsWith("json")) {
value.value = variableParser_.parse(this, experiment.name, customFieldValue.value);
} else if (customFieldValue.type.equals("boolean")) {
value.value = Boolean.parseBoolean(customFieldValue.value);
} else if (customFieldValue.type.equals("number")) {
value.value = Double.parseDouble(customFieldValue.value);
contextExperiment.customFieldValues.put(customFieldValue.getName(), value);

value.type = customFieldValue.getType();
if (customFieldValue.getValue() != null) {
if (customFieldValue.getType().startsWith("json")) {
value.value = variableParser_.parse(this, experiment.name, customFieldValue.getValue());
} else if (customFieldValue.getType().equals("boolean")) {
value.value = Boolean.parseBoolean(customFieldValue.getValue());
} else if (customFieldValue.getType().equals("number")) {
value.value = Double.parseDouble(customFieldValue.getValue());
} else {
value.value = customFieldValue.value;
value.value = customFieldValue.getValue();
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class CustomFieldValue {
public String name;
public String type;
public String value;
private String name;
private String type;
private String value;

public CustomFieldValue() {}

Expand Down Expand Up @@ -44,4 +44,28 @@ public String toString() {
", value='" + value + '\'' +
'}';
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public String getType() {
return type;
}

public void setType(String type) {
this.type = type;
}

public String getValue() {
return value;
}

public void setValue(String value) {
this.value = value;
}
}