Skip to content

Commit 14a2ba0

Browse files
authored
Merge 557fe32 into f82bb5d
2 parents f82bb5d + 557fe32 commit 14a2ba0

File tree

19 files changed

+167
-322
lines changed

19 files changed

+167
-322
lines changed

.github/workflows/test_pack_doc.yml

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,22 +37,14 @@ jobs:
3737
- name: Run tests on Java ${{ matrix.java_version }} and ${{ matrix.os }}
3838
uses: gradle/gradle-build-action@v2
3939
with:
40-
arguments: testReport
41-
- name: Persist **Passing** tests merged report - Java ${{ matrix.java_version }} on ${{ matrix.os }}
42-
uses: actions/upload-artifact@v3
43-
with:
44-
name: Test report - Java ${{ matrix.java_version }} on ${{ matrix.os }}
45-
path: build/reports/allTests/
46-
- name: Persist **Failing** tests unmerged reports - Java ${{ matrix.java_version }} on ${{ matrix.os }}
40+
# We run test aggregation with --continue to make sure all tests run, even if some fail.
41+
arguments: testAggregateTestReport --continue
42+
- name: Persist aggregated test reports on failure - Java ${{ matrix.java_version }} on ${{ matrix.os }}
4743
if: ${{ failure() }}
4844
uses: actions/upload-artifact@v3
4945
with:
5046
name: Test report - Java ${{ matrix.java_version }} on ${{ matrix.os }}
51-
path: |
52-
cli/build/reports/tests/
53-
core/build/reports/tests/
54-
main/build/reports/tests/
55-
processor/build/reports/tests/
47+
path: build/reports/tests/unit-test/aggregated-results/
5648

5749
package:
5850
needs: [test]

app/gui/build.gradle

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,7 @@ plugins {
2020
id 'com.github.johnrengelman.shadow' version '5.2.0'
2121
}
2222

23-
sourceCompatibility = JavaVersion.VERSION_11
2423
mainClassName = 'org.mobilitydata.gtfsvalidator.app.gui.Main'
25-
compileJava.options.encoding = "UTF-8"
26-
27-
repositories {
28-
mavenCentral()
29-
}
3024

3125
dependencies {
3226
implementation project(':core')

app/gui/src/test/java/org/mobilitydata/gtfsvalidator/app/gui/GtfsValidatorAppTest.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@
44
import static com.google.common.truth.Truth8.assertThat;
55
import static org.mockito.Mockito.verify;
66

7+
import java.awt.GraphicsEnvironment;
78
import java.net.URI;
89
import java.net.URISyntaxException;
910
import java.nio.file.Path;
1011
import javax.swing.JButton;
12+
import org.junit.Assume;
1113
import org.junit.Before;
1214
import org.junit.Rule;
1315
import org.junit.Test;
@@ -33,6 +35,10 @@ public class GtfsValidatorAppTest {
3335

3436
@Before
3537
public void before() {
38+
// This test uses Swing and AWT classes that will fail if we are in a headless environment,
39+
// so we skip the test if that's the case.
40+
Assume.assumeFalse(GraphicsEnvironment.isHeadless());
41+
3642
this.app = new GtfsValidatorApp(runner, display);
3743
app.constructUI();
3844
}

app/gui/src/test/java/org/mobilitydata/gtfsvalidator/app/gui/GtfsValidatorPreferencesTest.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22

33
import static com.google.common.truth.Truth.assertThat;
44

5+
import java.awt.GraphicsEnvironment;
56
import java.nio.file.Path;
7+
import org.junit.Assume;
8+
import org.junit.Before;
69
import org.junit.Rule;
710
import org.junit.Test;
811
import org.junit.runner.RunWith;
@@ -20,12 +23,21 @@ public class GtfsValidatorPreferencesTest {
2023
@Mock private MonitoredValidationRunner runner;
2124
@Mock private ValidationDisplay display;
2225

26+
@Before
27+
public void before() {
28+
// This test uses Swing and AWT classes that will fail if we are in a headless environment,
29+
// so we skip the test if that's the case.
30+
Assume.assumeFalse(GraphicsEnvironment.isHeadless());
31+
}
32+
2333
@Test
2434
public void testEndToEnd() {
35+
Path outputDirectory = Path.of("/tmp/gtfs");
36+
2537
{
2638
GtfsValidatorApp source = new GtfsValidatorApp(runner, display);
2739
source.setGtfsSource("http://gtfs.org/gtfs.zip");
28-
source.setOutputDirectory(Path.of("/tmp/gtfs"));
40+
source.setOutputDirectory(outputDirectory);
2941
source.setNumThreads(3);
3042
source.setCountryCode("CA");
3143

@@ -39,7 +51,7 @@ public void testEndToEnd() {
3951
prefs.loadPreferences(dest);
4052

4153
assertThat(dest.getGtfsSource()).isEqualTo("http://gtfs.org/gtfs.zip");
42-
assertThat(dest.getOutputDirectory()).isEqualTo("/tmp/gtfs");
54+
assertThat(dest.getOutputDirectory()).isEqualTo(outputDirectory.toString());
4355
assertThat(dest.getNumThreads()).isEqualTo(3);
4456
assertThat(dest.getCountryCode()).isEqualTo("CA");
4557
}

app/pkg/build.gradle

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,6 @@ plugins {
2222
id "org.beryx.jlink" version "2.24.1"
2323
}
2424

25-
repositories {
26-
mavenCentral()
27-
}
28-
2925
dependencies {
3026
// Note that we depend on the :app:gui shadow jar, which bundles the gui
3127
// application and all its dependencies into a single uber jar.
@@ -63,9 +59,6 @@ extraJavaModuleInfo {
6359
}
6460
}
6561

66-
sourceCompatibility = JavaVersion.VERSION_11
67-
compileJava.options.encoding = "UTF-8"
68-
6962
java {
7063
modularity.inferModulePath = true
7164
}

build.gradle

Lines changed: 39 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -16,54 +16,68 @@
1616

1717
plugins {
1818
id 'java'
19+
id 'test-report-aggregation'
1920
id 'com.github.sherter.google-java-format' version '0.9'
2021
id "io.freefair.aggregate-javadoc-jar" version "6.4.3"
2122
id "pl.allegro.tech.build.axion-release" version "1.13.6"
2223
}
2324

24-
repositories {
25-
mavenCentral()
26-
}
27-
28-
// Setup and configure Javadoc plugin
25+
// Setup and configure properties that are consistent across all projects, including sub-modules.
2926
allprojects {
3027
group 'org.mobilitydata'
28+
3129
// Per the axion-release plugin, this computes the project version based
3230
// on the most recent tag in the repo.
3331
version scmVersion.version
3432

33+
repositories {
34+
mavenCentral()
35+
}
36+
37+
tasks.withType(JavaCompile) {
38+
// All Java projects should target the same compatibility version.
39+
sourceCompatibility = JavaVersion.VERSION_11
40+
targetCompatibility = JavaVersion.VERSION_11
41+
42+
// Our source files should be encoded in UTF-8, regardless of the platform (e.g. Windows).
43+
compileJava.options.encoding = "UTF-8"
44+
compileTestJava.options.encoding = "UTF-8"
45+
}
46+
3547
tasks.withType(Javadoc) {
3648
options.encoding = 'UTF-8'
3749
}
38-
}
3950

40-
// A resolvable configuration to collect test reports data
41-
configurations {
42-
testReportData {
43-
canBeResolved = true
44-
canBeConsumed = false
45-
attributes {
46-
attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category, Category.DOCUMENTATION))
47-
attribute(DocsType.DOCS_TYPE_ATTRIBUTE, objects.named(DocsType, 'test-report-data'))
51+
// All projects that include the 'java` plugin will have a Test task by default.
52+
tasks.withType(Test) {
53+
// Always run tests, even when nothing changed.
54+
dependsOn 'cleanTest'
55+
56+
// Show test results.
57+
testLogging {
58+
events "passed", "skipped", "failed"
4859
}
49-
}
50-
}
5160

52-
dependencies {
53-
testReportData project('main')
54-
testReportData project(':processor')
55-
testReportData project(':core')
61+
// Define a system project for the project version
62+
systemProperty 'gtfsValidatorVersionForTest', project.version
63+
64+
// Any project with a test should be added to test report aggregation in the root project.
65+
rootProject.dependencies.add('testReportAggregation', project)
66+
}
5667
}
5768

58-
tasks.register('testReport', TestReport) {
59-
destinationDir = file("$buildDir/reports/allTests")
60-
// Use test results from testReportData configuration
61-
testResultDirs.from(configurations.testReportData)
69+
reporting {
70+
reports {
71+
// Necessary for unit test result aggregation.
72+
testAggregateTestReport(AggregateTestReport) {
73+
testType = TestSuiteType.UNIT_TEST
74+
}
75+
}
6276
}
6377

6478
task copyRulesToWebClient (type: Copy) {
6579
from "./RULES.md"
6680
into "./web/client/static"
6781
}
6882

69-
build.dependsOn copyRulesToWebClient
83+
build.dependsOn copyRulesToWebClient

cli/build.gradle

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,7 @@ shadowJar {
4545
archiveClassifier = 'cli'
4646
}
4747

48-
sourceCompatibility = JavaVersion.VERSION_11
4948
mainClassName = 'org.mobilitydata.gtfsvalidator.cli.Main'
50-
compileJava.options.encoding = "UTF-8"
51-
52-
repositories {
53-
mavenCentral()
54-
}
5549

5650
dependencies {
5751
implementation project(':core')
@@ -68,27 +62,3 @@ dependencies {
6862
testImplementation 'org.mockito:mockito-core:4.5.1'
6963
}
7064

71-
test {
72-
// Always run tests, even when nothing changed.
73-
dependsOn 'cleanTest'
74-
75-
// Show test results.
76-
testLogging {
77-
events "passed", "skipped", "failed"
78-
}
79-
80-
systemProperty 'gtfsValidatorVersionForTest', project.version
81-
}
82-
83-
// Share the test report data to be aggregated for the whole project
84-
configurations {
85-
binaryTestResultsElements {
86-
canBeResolved = false
87-
canBeConsumed = true
88-
attributes {
89-
attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category, Category.DOCUMENTATION))
90-
attribute(DocsType.DOCS_TYPE_ATTRIBUTE, objects.named(DocsType, 'test-report-data'))
91-
}
92-
outgoing.artifact(test.binaryResultsDirectory)
93-
}
94-
}

core/build.gradle

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,6 @@ plugins {
1919
id 'maven-publish'
2020
}
2121

22-
sourceCompatibility = JavaVersion.VERSION_11
23-
compileTestJava.options.encoding = "UTF-8"
24-
25-
repositories {
26-
mavenCentral()
27-
}
28-
2922
dependencies {
3023
implementation project(':model')
3124
annotationProcessor project(':processor:notices')
@@ -67,33 +60,10 @@ publishing {
6760
}
6861
}
6962

70-
test {
71-
// Always run tests, even when nothing changed.
72-
dependsOn 'cleanTest'
73-
74-
// Show test results.
75-
testLogging {
76-
events "passed", "skipped", "failed"
77-
}
78-
}
79-
8063
compileJava {
8164
options.compilerArgs << '-parameters'
8265
}
8366

8467
compileTestJava {
8568
options.compilerArgs << '-parameters'
8669
}
87-
88-
// Share the test report data to be aggregated for the whole project
89-
configurations {
90-
binaryTestResultsElements {
91-
canBeResolved = false
92-
canBeConsumed = true
93-
attributes {
94-
attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category, Category.DOCUMENTATION))
95-
attribute(DocsType.DOCS_TYPE_ATTRIBUTE, objects.named(DocsType, 'test-report-data'))
96-
}
97-
outgoing.artifact(test.binaryResultsDirectory)
98-
}
99-
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-all.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)