Skip to content

Commit 81796fe

Browse files
authored
Add "skipped-versions" index.json field for the ability to skip testing of broken library versions (#792)
1 parent 7d692d3 commit 81796fe

File tree

8 files changed

+104
-9
lines changed

8 files changed

+104
-9
lines changed

docs/CONTRIBUTING.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,34 @@ a regexp (Java format) matching the version pattern. For example, for the exampl
153153
}
154154
```
155155

156+
The optional `skipped-versions` key can be used to explicitly exclude specific
157+
library versions from being considered as supported metadata. A skipped version
158+
should include both the version and the reason it is excluded. This is useful
159+
when a version exists in Maven but is known to be broken, incompatible, or
160+
should be omitted from testing for any other reason. An example of the library
161+
above using this field:
162+
163+
```json
164+
{
165+
"metadata-version": "1.0.0",
166+
"module": "org.example:library",
167+
"tested-versions": [
168+
"1.0.0",
169+
"1.1.0"
170+
],
171+
"skipped-versions": [
172+
{
173+
"version": "1.0.5",
174+
"reason": "Known incompatible API change."
175+
},
176+
{
177+
"version": "1.0.7",
178+
"reason": "Integrated reflect-config.json does not parse."
179+
}
180+
]
181+
}
182+
```
183+
156184
You can also list each supported version is listed in `tested-versions`, as that value is used in build tools to match
157185
metadata to a specific library, but this is more likely to break when new versions are released.
158186
Every metadata for a specific library version has a `index.json`. For this

metadata/io.opentelemetry/opentelemetry-sdk-metrics/index.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@
2323
"1.31.0",
2424
"1.32.0",
2525
"1.33.0"
26+
],
27+
"skipped-versions": [
28+
{
29+
"version": "1.34.0",
30+
"reason": "Dependency io.opentelemetry:opentelemetry-api:1.34.0 provides reflect-config.json which does not parse."
31+
}
2632
]
2733
}
2834
]

metadata/io.opentelemetry/opentelemetry-sdk-trace/index.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@
2323
"1.31.0",
2424
"1.32.0",
2525
"1.33.0"
26+
],
27+
"skipped-versions": [
28+
{
29+
"version": "1.34.0",
30+
"reason": "Dependency io.opentelemetry:opentelemetry-api:1.34.0 provides reflect-config.json which does not parse."
31+
}
2632
]
2733
}
2834
]

tests/tck-build-logic/src/main/groovy/org/graalvm/internal/tck/harness/tasks/FetchExistingLibrariesWithNewerVersionsTask.groovy

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import com.fasterxml.jackson.databind.ObjectMapper
77
import com.fasterxml.jackson.databind.SerializationFeature
88
import groovy.json.JsonOutput
99
import org.graalvm.internal.tck.model.MetadataVersionsIndexEntry
10+
import org.graalvm.internal.tck.model.SkippedVersionEntry
1011
import org.gradle.api.DefaultTask
1112
import org.gradle.api.provider.ListProperty
1213
import org.gradle.api.tasks.Input
@@ -59,6 +60,11 @@ abstract class FetchExistingLibrariesWithNewerVersionsTask extends DefaultTask {
5960
String libraryName = it
6061
if (INFRASTRUCTURE_TESTS.stream().noneMatch(testName -> libraryName.startsWith(testName))) {
6162
List<String> versions = getNewerVersionsFor(libraryName, getLatestLibraryVersion(libraryName))
63+
List<String> skipped = getSkippedVersions(libraryName)
64+
65+
// filter out skipped versions
66+
versions = versions.findAll { !skipped.contains(it) }
67+
6268
versions.forEach {
6369
newerVersions.add(libraryName.concat(":").concat(it))
6470
}
@@ -164,4 +170,45 @@ abstract class FetchExistingLibrariesWithNewerVersionsTask extends DefaultTask {
164170
}
165171
}
166172

173+
/**
174+
* Returns all versions of a given library that are marked as skipped in the
175+
* metadata index.
176+
* <p>
177+
* For the provided Maven coordinates (in the format {@code <groupId>:<artifactId>}),
178+
* this method reads the corresponding {@code index.json} file located under:
179+
* {@code metadata/<groupId>/<artifactId>/index.json}
180+
* and collects all version entries listed under {@code skipped-versions}.
181+
*/
182+
static List<String> getSkippedVersions(String libraryModule) {
183+
try {
184+
String[] coordinates = libraryModule.split(":");
185+
String group = coordinates[0];
186+
String artifact = coordinates[1];
187+
188+
File coordinatesMetadataIndex = new File("metadata/" + group + "/" + artifact + "/index.json");
189+
ObjectMapper objectMapper = new ObjectMapper()
190+
.enable(SerializationFeature.INDENT_OUTPUT)
191+
.setSerializationInclusion(JsonInclude.Include.NON_NULL);
192+
193+
List<MetadataVersionsIndexEntry> entries = objectMapper.readValue(
194+
coordinatesMetadataIndex,
195+
new TypeReference<List<MetadataVersionsIndexEntry>>() {}
196+
);
197+
198+
List<String> skipped = new ArrayList<>();
199+
for (MetadataVersionsIndexEntry entry : entries) {
200+
if (entry.skippedVersions() != null) {
201+
skipped.addAll(
202+
entry.skippedVersions().stream()
203+
.map(SkippedVersionEntry::version)
204+
.toList()
205+
);
206+
}
207+
}
208+
209+
return skipped;
210+
} catch (IOException e) {
211+
throw new RuntimeException(e);
212+
}
213+
}
167214
}

tests/tck-build-logic/src/main/java/org/graalvm/internal/tck/ScaffoldTask.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -269,12 +269,7 @@ private void updateCoordinatesMetadataRootJson(Path metadataRoot, Coordinates co
269269
List<MetadataVersionsIndexEntry> entries = objectMapper.readValue(metadataIndex, new TypeReference<>() {});
270270

271271
// add new entry
272-
MetadataVersionsIndexEntry newEntry = new MetadataVersionsIndexEntry(null,
273-
null,
274-
coordinates.group() + ":" + coordinates.artifact(),
275-
null,
276-
coordinates.version(),
277-
List.of(coordinates.version()));
272+
MetadataVersionsIndexEntry newEntry = new MetadataVersionsIndexEntry(null, null, coordinates.group() + ":" + coordinates.artifact(), null, coordinates.version(), List.of(coordinates.version()), null);
278273

279274
entries.add(newEntry);
280275

@@ -307,7 +302,7 @@ private void updateCoordinatesMetadataRootJson(Path metadataRoot, Coordinates co
307302

308303
private void setLatest( List<MetadataVersionsIndexEntry> list, int index, Boolean newValue) {
309304
MetadataVersionsIndexEntry oldEntry = list.remove(index);
310-
list.add(new MetadataVersionsIndexEntry(newValue, oldEntry.override(), oldEntry.module(), oldEntry.defaultFor(), oldEntry.metadataVersion(), oldEntry.testedVersions()));
305+
list.add(new MetadataVersionsIndexEntry(newValue, oldEntry.override(), oldEntry.module(), oldEntry.defaultFor(), oldEntry.metadataVersion(), oldEntry.testedVersions(), oldEntry.skippedVersions()));
311306
}
312307

313308
private String getEmptyJsonArray() {

tests/tck-build-logic/src/main/java/org/graalvm/internal/tck/TestedVersionUpdaterTask.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,8 @@ private MetadataVersionsIndexEntry handlePreReleases(MetadataVersionsIndexEntry
162162
entry.module(),
163163
entry.defaultFor(),
164164
newVersion,
165-
entry.testedVersions()
165+
entry.testedVersions(),
166+
entry.skippedVersions()
166167
);
167168
}
168169
}

tests/tck-build-logic/src/main/java/org/graalvm/internal/tck/model/MetadataVersionsIndexEntry.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,7 @@ public record MetadataVersionsIndexEntry (
1313
@JsonProperty("metadata-version")
1414
String metadataVersion,
1515
@JsonProperty("tested-versions")
16-
List<String> testedVersions
16+
List<String> testedVersions,
17+
@JsonProperty("skipped-versions")
18+
List<SkippedVersionEntry> skippedVersions
1719
){}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package org.graalvm.internal.tck.model;
2+
3+
/**
4+
* Represents a version of a library that should be skipped during testing,
5+
* along with the reason why this version is skipped.
6+
*/
7+
public record SkippedVersionEntry(
8+
String version,
9+
String reason
10+
){}

0 commit comments

Comments
 (0)