Skip to content

Commit 2491835

Browse files
SK-2440: integrate code cov to java v3 sdk (#266)
1 parent 39a7faa commit 2491835

5 files changed

Lines changed: 32 additions & 22 deletions

File tree

.github/workflows/pr.yml

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
name: PR CI Checks
22

3-
on: [pull_request]
3+
on:
4+
pull_request:
5+
push:
6+
branches: [ "v3" ]
47

58
jobs:
69
check-commit-message:
@@ -15,14 +18,16 @@ jobs:
1518
excludeDescription: "true"
1619
checkAllCommitMessages: "true"
1720
accessToken: ${{ secrets.PAT_ACTIONS }}
18-
error: "One of your your commit messages is not matching the format with JIRA ID Ex: ( SDK-123 commit message )"
21+
error: "One of your commit messages is not matching the format with JIRA ID Ex: ( SDK-123 commit message )"
22+
1923
Test:
2024
runs-on: ubuntu-latest
2125
steps:
2226
- uses: actions/checkout@v1
27+
2328
- uses: actions/setup-java@v1
2429
with:
25-
java-version: "1.8"
30+
java-version: "11"
2631

2732
- name: create-json
2833
id: create-json
@@ -34,18 +39,21 @@ jobs:
3439
- name: create env
3540
id: create-env
3641
run: |
37-
touch .env
38-
echo SKYFLOW_CREDENTIALS=${{ secrets.SKYFLOW_CREDENTIALS }} >> .env
39-
echo TEST_EXPIRED_TOKEN=${{ secrets.TEST_EXPIRED_TOKEN }} >> .env
40-
echo TEST_REUSABLE_TOKEN=${{ secrets.TEST_REUSABLE_TOKEN }} >> .env
42+
touch v3/.env
43+
echo SKYFLOW_CREDENTIALS=${{ secrets.SKYFLOW_CREDENTIALS }} >> v3/.env
44+
echo TEST_EXPIRED_TOKEN=${{ secrets.TEST_EXPIRED_TOKEN }} >> v3/.env
45+
echo TEST_REUSABLE_TOKEN=${{ secrets.TEST_REUSABLE_TOKEN }} >> v3/.env
4146
4247
- name: Build & Run tests with Maven
43-
run: mvn -B package -f pom.xml -Dmaven.javadoc.skip=true
48+
run: mvn -B -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn clean test jacoco:report -pl v3 -am -Dmaven.javadoc.skip=true
4449

4550
- name: Codecov
46-
uses: codecov/codecov-action@v2.1.0
51+
uses: codecov/codecov-action@v3
4752
with:
4853
token: ${{ secrets.CODECOV_REPO_UPLOAD_TOKEN }}
49-
files: target/site/jacoco/jacoco.xml
54+
files: v3/target/site/jacoco/jacoco.xml
55+
flags: unittests
56+
5057
name: codecov-skyflow-java
51-
verbose: true
58+
fail_ci_if_error: true
59+
verbose: true

pom.xml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@
126126
<dependency>
127127
<groupId>junit</groupId>
128128
<artifactId>junit</artifactId>
129-
<version>${junit-version}</version>
129+
<version>4.13.2</version>
130130
<scope>test</scope>
131131
</dependency>
132132
<dependency>
@@ -141,12 +141,6 @@
141141
<version>2.0.9</version>
142142
<scope>test</scope>
143143
</dependency>
144-
<dependency>
145-
<groupId>org.junit.jupiter</groupId>
146-
<artifactId>junit-jupiter</artifactId>
147-
<version>5.13.2</version>
148-
<scope>compile</scope>
149-
</dependency>
150144
</dependencies>
151145

152146
<build>

v3/src/test/java/com/skyflow/VaultClientTests.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,10 @@ public void testSetBearerTokenWithEnvCredentials() {
116116
vaultClient.setBearerToken();
117117

118118
// Credentials at ENV level should be prioritised
119-
Assert.assertEquals(credentials, getPrivateField(vaultClient, "finalCredentials"));
119+
Assert.assertEquals(
120+
credentials.getCredentialsString(),
121+
((Credentials) getPrivateField(vaultClient, "finalCredentials")).getCredentialsString()
122+
);
120123

121124
} catch (SkyflowException e) {
122125
Assert.assertEquals(ErrorCode.INVALID_INPUT.getCode(), 400);
@@ -278,4 +281,4 @@ private Object getPrivateField(Object obj, String fieldName) throws Exception {
278281
return field.get(obj);
279282
}
280283

281-
}
284+
}

v3/src/test/java/com/skyflow/utils/UtilsTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
import java.util.*;
2020

21-
import static org.junit.jupiter.api.Assertions.assertEquals;
21+
import static org.junit.Assert.assertEquals;
2222

2323
public class UtilsTests {
2424
private static final String INVALID_EXCEPTION_THROWN = "Should not have thrown any exception";
@@ -990,4 +990,4 @@ public void testHandleBatchExceptionWithApiClientApiExceptionCause() {
990990
Assert.assertEquals(400, errors.get(0).getCode());
991991
}
992992

993-
}
993+
}

v3/src/test/java/com/skyflow/vault/controller/VaultControllerTests.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,12 @@
2525

2626
import static org.junit.Assert.*;
2727

28+
import org.junit.runner.RunWith;
29+
import org.powermock.core.classloader.annotations.PowerMockIgnore; // Import this
30+
import org.powermock.modules.junit4.PowerMockRunner;
2831

32+
@RunWith(PowerMockRunner.class)
33+
@PowerMockIgnore({"javax.management.*", "java.nio.*", "com.sun.*", "jdk.internal.reflect.*", "javax.crypto.*"})
2934
public class VaultControllerTests {
3035
private static final String ENV_PATH = "./.env";
3136

0 commit comments

Comments
 (0)