Skip to content

Commit

Permalink
Add junit tag configuration
Browse files Browse the repository at this point in the history
- Using include/exclude tags was missing so adding
  those into buildSrc.
- Polish it tests workflows
- Relates #1143
  • Loading branch information
jvalkeal committed Mar 14, 2024
1 parent fbb6df4 commit 24a3467
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/mongodb.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
java-version: ${{ matrix.java }}
cache: gradle
- name: Build with Gradle
run: ./gradlew clean build -PstatemachineIncludeTags=mongodb -PstatemachineTestResults=true
run: ./gradlew clean build -PstatemachineIncludeTags=mongodb
- name: Tar Build Logs
if: ${{ failure() }}
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/redis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
java-version: ${{ matrix.java }}
cache: gradle
- name: Build with Gradle
run: ./gradlew clean build -PstatemachineIncludeTags=redis -PstatemachineTestResults=true
run: ./gradlew clean build -PstatemachineIncludeTags=redis
- name: Tar Build Logs
if: ${{ failure() }}
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/smoke.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
java-version: ${{ matrix.java }}
cache: gradle
- name: Build with Gradle
run: ./gradlew clean build -PstatemachineIncludeTags=smoke -PstatemachineTestResults=true
run: ./gradlew clean build -PstatemachineIncludeTags=smoke
- name: Tar Build Logs
if: ${{ failure() }}
run: |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
class JavaConventions {

private static final String SOURCE_AND_TARGET_COMPATIBILITY = "17";
private static final String INCLUDE_TAGS = "statemachineIncludeTags";
private static final String EXCLUDE_TAGS = "statemachineExcludeTags";

void apply(Project project) {
project.getPlugins().withType(JavaBasePlugin.class, java -> {
Expand Down Expand Up @@ -84,7 +86,31 @@ private boolean buildingWithJava17(Project project) {

private void configureTestConventions(Project project) {
project.getTasks().withType(Test.class, test -> {
test.useJUnitPlatform();
boolean hasIncludeTags = project.hasProperty(INCLUDE_TAGS);
boolean hasExcludeTags = project.hasProperty(EXCLUDE_TAGS);
test.useJUnitPlatform(options -> {
if (!hasIncludeTags && !hasExcludeTags) {
options.excludeTags("smoke");
}
else {
if (hasIncludeTags) {
Object includeTagsProperty = project.property(INCLUDE_TAGS);
if (includeTagsProperty instanceof String p) {
if (p.length() > 0) {
options.includeTags(p.split(","));
}
}
}
if (hasExcludeTags) {
Object excludeTagsProperty = project.property(EXCLUDE_TAGS);
if (excludeTagsProperty instanceof String p) {
if (p.length() > 0) {
options.excludeTags(p.split(","));
}
}
}
}
});
});
}

Expand Down

0 comments on commit 24a3467

Please sign in to comment.