Skip to content

Commit 0cefa70

Browse files
authored
feat: add dashboard for shared dependency version checking (#730)
1 parent 2b1037e commit 0cefa70

File tree

15 files changed

+1341
-0
lines changed

15 files changed

+1341
-0
lines changed

.kokoro/nightly/dashboard.cfg

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Format: //devtools/kokoro/config/proto/build.proto
2+
3+
# Location of the periodic build bash script in git.
4+
build_file: "java-cloud-bom/.kokoro/nightly/dashboard.sh"
5+
6+
action {
7+
define_artifacts {
8+
regex: "**/target/com.google.cloud/**"
9+
strip_prefix: "github/java-cloud-bom/dashboard/target"
10+
}
11+
}

.kokoro/nightly/dashboard.sh

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
3+
# Fail on any error.
4+
set -e
5+
# Display commands being run.
6+
set -x
7+
8+
cd github/java-cloud-bom
9+
# M2_HOME is not used since Maven 3.5.0 https://maven.apache.org/docs/3.5.0/release-notes.html
10+
mvn -B clean install
11+
12+
# Running target of dashboard submodule
13+
# https://stackoverflow.com/questions/3459928/running-a-specific-maven-plugin-goal-from-the-command-line-in-a-sub-module-of-a/26448447#26448447
14+
# https://stackoverflow.com/questions/11091311/maven-execjava-goal-on-a-multi-module-project
15+
cd dashboard
16+
17+
# For all versions available in Maven Central and local repository
18+
mvn -B exec:java -Dexec.mainClass="com.google.cloud.tools.opensource.cloudbomdashboard.DashboardMain" \
19+
-Dexec.arguments="-a com.google.cloud:google-cloud-bom"

dashboard/README.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
To generate the dashboard from the root directory run:
2+
3+
```
4+
$ mvn clean install
5+
$ cd dashboard
6+
$ mvn exec:java -Dexec.arguments="-f ../pom.xml"
7+
```

dashboard/pom.xml

+92
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
<parent>
7+
<groupId>com.google.cloud.tools</groupId>
8+
<artifactId>dependencies-parent</artifactId>
9+
<version>1.4.4-SNAPSHOT</version>
10+
</parent>
11+
<artifactId>google-cloud-bom-dashboard</artifactId>
12+
13+
<name>Cloud Tools Open Source Code Hygiene Dashboard</name>
14+
<url>https://github.com/GoogleCloudPlatform/cloud-opensource-java/dashboard</url>
15+
<organization>
16+
<name>Google LLC.</name>
17+
<url>https://www.google.com</url>
18+
</organization>
19+
20+
<licenses>
21+
<license>
22+
<name>The Apache License, Version 2.0</name>
23+
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
24+
</license>
25+
</licenses>
26+
27+
<properties>
28+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
29+
<maven.compiler.source>1.8</maven.compiler.source>
30+
<maven.compiler.target>1.8</maven.compiler.target>
31+
</properties>
32+
33+
<dependencies>
34+
<dependency>
35+
<groupId>org.freemarker</groupId>
36+
<artifactId>freemarker</artifactId>
37+
<version>2.3.30</version>
38+
</dependency>
39+
<dependency>
40+
<groupId>com.google.guava</groupId>
41+
<artifactId>guava</artifactId>
42+
</dependency>
43+
<dependency>
44+
<groupId>${project.groupId}</groupId>
45+
<artifactId>dependencies</artifactId>
46+
<version>${project.version}</version>
47+
</dependency>
48+
49+
<dependency>
50+
<groupId>xom</groupId>
51+
<artifactId>xom</artifactId>
52+
<version>1.3.5</version>
53+
<scope>test</scope>
54+
</dependency>
55+
<dependency>
56+
<groupId>junit</groupId>
57+
<artifactId>junit</artifactId>
58+
<scope>test</scope>
59+
</dependency>
60+
<dependency>
61+
<groupId>com.google.truth</groupId>
62+
<artifactId>truth</artifactId>
63+
<scope>test</scope>
64+
</dependency>
65+
</dependencies>
66+
67+
<build>
68+
<plugins>
69+
<plugin>
70+
<groupId>org.codehaus.mojo</groupId>
71+
<artifactId>exec-maven-plugin</artifactId>
72+
<configuration>
73+
<skip>false</skip>
74+
<mainClass>com.google.cloud.tools.opensource.cloudbomdashboard.DashboardMain</mainClass>
75+
</configuration>
76+
</plugin>
77+
</plugins>
78+
<resources>
79+
<resource>
80+
<directory>src/main/resources</directory>
81+
<includes>
82+
<include>**/*.css</include>
83+
<include>**/*.js</include>
84+
<include>**/*.xml</include>
85+
<include>**/*.ftl</include>
86+
</includes>
87+
<filtering>false</filtering>
88+
</resource>
89+
</resources>
90+
</build>
91+
92+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
* Copyright 2018 Google LLC.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.google.cloud.tools.opensource.cloudbomdashboard;
18+
19+
import java.util.List;
20+
import java.util.Map;
21+
22+
import org.eclipse.aether.artifact.Artifact;
23+
24+
import com.google.cloud.tools.opensource.dependencies.DependencyGraph;
25+
26+
/**
27+
* Unified return type to bundle a lot of information about multiple artifacts together.
28+
*/
29+
class ArtifactCache {
30+
31+
private Map<Artifact, ArtifactInfo> infoMap;
32+
private List<DependencyGraph> globalDependencies;
33+
34+
void setInfoMap(Map<Artifact, ArtifactInfo> infoMap) {
35+
this.infoMap = infoMap;
36+
}
37+
38+
void setGlobalDependencies(List<DependencyGraph> globalDependencies) {
39+
this.globalDependencies = globalDependencies;
40+
}
41+
42+
Map<Artifact, ArtifactInfo> getInfoMap() {
43+
return infoMap;
44+
}
45+
46+
List<DependencyGraph> getGlobalDependencies() {
47+
return globalDependencies;
48+
}
49+
50+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*
2+
* Copyright 2018 Google LLC.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.google.cloud.tools.opensource.cloudbomdashboard;
18+
19+
import org.eclipse.aether.RepositoryException;
20+
21+
import com.google.cloud.tools.opensource.dependencies.DependencyGraph;
22+
23+
/**
24+
* Cache of info looked up for an artifact.
25+
*/
26+
class ArtifactInfo {
27+
28+
private DependencyGraph completeDependencies;
29+
private DependencyGraph transitiveDependencies;
30+
private RepositoryException exception;
31+
32+
ArtifactInfo(DependencyGraph completeDependencies,
33+
DependencyGraph transitiveDependencies) {
34+
this.completeDependencies = completeDependencies;
35+
this.transitiveDependencies = transitiveDependencies;
36+
}
37+
38+
ArtifactInfo(RepositoryException ex) {
39+
this.exception = ex;
40+
}
41+
42+
DependencyGraph getCompleteDependencies() {
43+
return completeDependencies;
44+
}
45+
46+
DependencyGraph getTransitiveDependencies() {
47+
return transitiveDependencies;
48+
}
49+
50+
RepositoryException getException() {
51+
return exception;
52+
}
53+
54+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
/*
2+
* Copyright 2018 Google LLC.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.google.cloud.tools.opensource.cloudbomdashboard;
18+
19+
import java.util.HashMap;
20+
import java.util.Map;
21+
22+
import javax.annotation.Nullable;
23+
24+
import org.eclipse.aether.artifact.Artifact;
25+
26+
import com.google.cloud.tools.opensource.dependencies.Artifacts;
27+
28+
/**
29+
* Collection of test results for a single artifact.
30+
*/
31+
public final class ArtifactResults {
32+
33+
private final Map<String, Integer> results = new HashMap<>();
34+
private final Artifact artifact;
35+
private String exceptionMessage;
36+
37+
public ArtifactResults(Artifact artifact) {
38+
this.artifact = artifact;
39+
}
40+
41+
public void setExceptionMessage(String exceptionMessage) {
42+
this.exceptionMessage = exceptionMessage;
43+
}
44+
45+
void addResult(String testName, int failures) {
46+
results.put(testName, failures);
47+
}
48+
49+
/**
50+
* @return true for pass, false for fail, null for unknown test
51+
*/
52+
@Nullable
53+
public Boolean getResult(String testName) {
54+
Integer failures = results.get(testName);
55+
if (failures != null) {
56+
return failures == 0;
57+
}
58+
return null;
59+
}
60+
61+
public String getCoordinates() {
62+
return Artifacts.toCoordinates(artifact);
63+
}
64+
65+
/**
66+
* @return message of exception occurred when running test, null for no exception
67+
*/
68+
@Nullable
69+
public String getExceptionMessage() {
70+
return exceptionMessage;
71+
}
72+
73+
/**
74+
*
75+
* @return number of times the specified test failed. Returns 0
76+
* if the test was not run.
77+
*/
78+
public int getFailureCount(String testName) {
79+
Integer failures = results.get(testName);
80+
if (failures == null) {
81+
return 0;
82+
}
83+
return failures;
84+
}
85+
}

0 commit comments

Comments
 (0)