Add versioned schemas and PR validation for index.json files#883
Add versioned schemas and PR validation for index.json files#883jormundur00 merged 15 commits intomasterfrom
Conversation
| set -e | ||
|
|
||
| # Treat changed_files as a proper array | ||
| FILES=(${{ steps.filter.outputs.changed_files }}) |
There was a problem hiding this comment.
We should always strive to do this in gradle. That way I can also do it locally to verify everything is OK.
There was a problem hiding this comment.
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).
74b3af7 to
89f8e23
Compare
abda7a2 to
ee85463
Compare
| 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 }} |
There was a problem hiding this comment.
Why do we need a matrix for this? It takes 1 s to do, so we can do it all at once.
There was a problem hiding this comment.
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\\\\..*')." |
There was a problem hiding this comment.
And why do we need these escapes?
There was a problem hiding this comment.
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\\..*" |
There was a problem hiding this comment.
Also here, why do we need these escapes here?
There was a problem hiding this comment.
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" ] |
There was a problem hiding this comment.
I would not put the milestone and CRs here because we don't want to encourage that.
There was a problem hiding this comment.
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." } |
There was a problem hiding this comment.
Usually this is the case because native image does not build due to some parsing issues.
There was a problem hiding this comment.
I've replaced this example with a "real world" example where tests fail due to an un-parsable reflect-config.json.
8fa33b1 to
5968b2e
Compare
This reverts commit bbf7a28.
5968b2e to
4b9a8b8
Compare
docs/DEVELOPING.md
Outdated
| ```console | ||
| ./gradlew pullAllowedDockerImages -Pcoordinates=org.postgresql:postgresql:42.7.3 | ||
| ``` | ||
| 2. Validate index schemas: |
What does this PR do?
This PR introduces versioned schemas for all existing
index.jsonfiles in the repository and adds a workflow to validate any changedindex.jsonfiles in a pull request against their respective schemas.Currently, there are three types of
index.jsonfiles governed by these schemas:index.json- Located atmetadata/index.jsonindex.json- Located atmetadata/<groupId>/<artifactId>/index.jsonfor each library in the repositoryindex.json- Located attests/src/<groupId>/<artifactId>/<version>/index.jsonNew Commands & Tasks
A new Java-based Gradle task
validateIndexFileshas been added to the harness. This task is coordinate-aware (supporting-Pcoordinatesand--coordinates) and handles space-separated lists for batch validation.Validate all index files locally:
./gradlew validateIndexFiles -Pcoordinates=allValidate specific library and its test indexes:
./gradlew validateIndexFiles -Pcoordinates=org.postgresql:postgresql:42.7.3Infrastructure 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
CONTRIBUTING.mdto include specific validation steps within the local testing recipes and a new entry in the Quick Reference section for faster developer onboarding.schemas/metadata-root-index-schema-v1.0.0.jsonschemas/metadata-library-index-schema-v1.0.0.jsonschemas/library-and-framework-list-schema-v1.0.0.jsonFixes: #813