Skip to content

Add versioned schemas and PR validation for index.json files#883

Merged
jormundur00 merged 15 commits intomasterfrom
jormundur00/gh-813
Dec 22, 2025
Merged

Add versioned schemas and PR validation for index.json files#883
jormundur00 merged 15 commits intomasterfrom
jormundur00/gh-813

Conversation

@jormundur00
Copy link
Copy Markdown
Member

@jormundur00 jormundur00 commented Dec 11, 2025

What does this PR do?

This PR introduces versioned schemas for all existing index.json files in the repository and adds a workflow to validate any changed index.json files in a pull request against their respective schemas.

Currently, there are three types of index.json files governed by these schemas:

  1. Global metadata index.json - Located at metadata/index.json
  2. Library metadata index.json - Located at metadata/<groupId>/<artifactId>/index.json for each library in the repository
  3. Optional test sub-project index.json - Located at tests/src/<groupId>/<artifactId>/<version>/index.json

New Commands & Tasks

A new Java-based Gradle task validateIndexFiles has been added to the harness. This task is coordinate-aware (supporting -Pcoordinates and --coordinates) and handles space-separated lists for batch validation.

Validate all index files locally:

./gradlew validateIndexFiles -Pcoordinates=all

Validate specific library and its test indexes:

./gradlew validateIndexFiles -Pcoordinates=org.postgresql:postgresql:42.7.3

Infrastructure Integration: The validateIndexFiles task is now a core part of the testInfra and testAllInfra verification suites. It runs in parallel with other checks (like checkstyle and spotless) to ensure data integrity without increasing CI runtime significantly.

Additional Changes

  • CI Workflow Update: The GitHub Action now utilizes a space-separated string of changed coordinates. This allows for highly targeted validation on Pull Requests, significantly reducing CI overhead.
  • Documentation Improvements: Updated CONTRIBUTING.md to include specific validation steps within the local testing recipes and a new entry in the Quick Reference section for faster developer onboarding.
  • Release Packaging: To ensure compatibility and detect version mismatches in Native Build Tools, the following schemas are now bundled with all future releases of GraalVM Reachability Metadata:
    • schemas/metadata-root-index-schema-v1.0.0.json
    • schemas/metadata-library-index-schema-v1.0.0.json
    • schemas/library-and-framework-list-schema-v1.0.0.json

Fixes: #813

@jormundur00 jormundur00 self-assigned this Dec 11, 2025
@jormundur00 jormundur00 added the enhancement New feature or request label Dec 11, 2025
@jormundur00 jormundur00 requested a review from kimeta December 11, 2025 14:39
set -e

# Treat changed_files as a proper array
FILES=(${{ steps.filter.outputs.changed_files }})
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should always strive to do this in gradle. That way I can also do it locally to verify everything is OK.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense. I've removed this file-producing part of the GitHub action and created a generateChangedIndexFileMatrix gradle task that will do this in gradle (and is locally test-able). As these tasks require a ci.json entry, I've added it as only tested on java: latest-ea and os: ubuntu-latest as not to produce multiple jobs (because there shouldn't be any change with different jdks for this functionality as we don't run native-image).

@jormundur00 jormundur00 requested a review from a team as a code owner December 12, 2025 09:04
@jormundur00 jormundur00 force-pushed the jormundur00/gh-813 branch 3 times, most recently from abda7a2 to ee85463 Compare December 19, 2025 08:08
id: set-matrix
if: steps.filter.outputs.changed == 'true'
run: |
./gradlew generateChangedIndexFileMatrix -PbaseCommit=${{ github.event.pull_request.base.sha }} -PnewCommit=${{ github.event.pull_request.head.sha }}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need a matrix for this? It takes 1 s to do, so we can do it all at once.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this was a bit misleading, as we generated a one-dimensional matrix (so an array) which we fully parsed in one job. I renamed this to generateChangedIndexFileList (and made it so we generate a list, no longer needing ci.json input either), and we still validate all changed index.json files in one job run (as we don't need parallelism here).

},
"default-for": {
"type": "string",
"description": "Java regular expression describing the version range for which this entry should be used by default (e.g. '7\\\\.1\\\\..*')."
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And why do we need these escapes?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the description, we need four backslashes to 'show' two to the user (and the need for two is explained in the other comment).

The IDE documentation viewer parses this JSON string and 'collapses' the four backslashes into two. This ensures the user sees 7\\.1\\..* in their tooltip, which is exactly what they need to copy-paste into their own index.json to be valid.

"metadata-version": "0.0.1",
"module": "org.example:library",
"tested-versions": [ "0.0.1", "0.0.2" ],
"default-for": "0\\.0\\..*"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also here, why do we need these escapes here?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because this is a Regex inside a JSON string.

In Regex, the dot is a wildcard, so we need \. to match a literal version dot. But in JSON, a backslash is a special character that must be escaped by another backslash.

So, \\. in the file tells the JSON parser to pass \. to the Regex engine, which then correctly matches the literal version number.

"latest": true,
"metadata-version": "1.0.0",
"module": "org.example:library",
"tested-versions": [ "1.0.0", "1.1.0-M1", "1.1.0" ]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would not put the milestone and CRs here because we don't want to encourage that.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, replaced the milestone version with another full release version.

"tested-versions": [ "1.19.0" ],
"override": true,
"skipped-versions": [
{ "version": "1.0.5", "reason": "Known incompatible API change." }
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Usually this is the case because native image does not build due to some parsing issues.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've replaced this example with a "real world" example where tests fail due to an un-parsable reflect-config.json.

@jormundur00 jormundur00 force-pushed the jormundur00/gh-813 branch 2 times, most recently from 8fa33b1 to 5968b2e Compare December 22, 2025 15:22
```console
./gradlew pullAllowedDockerImages -Pcoordinates=org.postgresql:postgresql:42.7.3
```
2. Validate index schemas:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

index.json

@jormundur00 jormundur00 merged commit 712c02c into master Dec 22, 2025
29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature: Introduce a version for the metadata repo structure

3 participants