Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(schema): Fix the JSON schema for the repository configuration #9847

Merged
merged 2 commits into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "https://oss-review-toolkit.org/package-manager-configuration.yml",
"title": "ORT configuration",
"title": "ORT package manager configurations",
"description": "Configurations for package managers for the OSS-Review-Toolkit (ORT). A full list of all available options can be found at https://github.com/oss-review-toolkit/ort/blob/main/model/src/main/kotlin/config/PackageManagerConfiguration.kt.",
"type": "object",
"propertyNames": {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
MarcelBochtler marked this conversation as resolved.
Show resolved Hide resolved
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "https://oss-review-toolkit.org/repository-configurations/analyzer-configuration.yml",
"title": "ORT repository analyzer configurations",
"description": "Configurations for the analyzer of the The OSS-Review-Toolkit (ORT). A full list of all available options can be found at https://github.com/oss-review-toolkit/ort/blob/main/model/src/main/kotlin/config/AnalyzerConfiguration.kt.",
"type": "object",
"additionalProperties": false,
"properties": {
"allow_dynamic_versions": {
"type": "boolean"
},
"enabled_package_managers": {
"type": "array",
"items": {
"$ref": "https://raw.githubusercontent.com/oss-review-toolkit/ort/main/integrations/schemas/package-managers-schema.json"
}
},
"disabled_package_managers": {
"type": "array",
"items": {
"$ref": "https://raw.githubusercontent.com/oss-review-toolkit/ort/main/integrations/schemas/package-managers-schema.json"
}
},
"package_managers": {
"$ref": "https://raw.githubusercontent.com/oss-review-toolkit/ort/main/integrations/schemas/repository-configurations/package-manager-configuration-schema.json"
},
"skip_excluded": {
"type": "boolean"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "https://oss-review-toolkit.org/repository-configurations/package-manager-configuration.yml",
"title": "ORT repository package manager configuration",
"description": "Configurations for package managers for the OSS-Review-Toolkit (ORT). A full list of all available options can be found at https://github.com/oss-review-toolkit/ort/blob/main/model/src/main/kotlin/config/PackageManagerConfiguration.kt.",
"type": "object",
"propertyNames": {
"$ref": "https://raw.githubusercontent.com/oss-review-toolkit/ort/main/integrations/schemas/package-managers-schema.json"
},
"additionalProperties": {
"type": "object",
"$ref": "#/definitions/PackageManagerConfigs"
},
"definitions": {
"PackageManagerConfigs": {
"type": "object",
"additionalProperties": false,
"properties": {
"must_run_after": {
"type": "array",
"items": {
"$ref": "https://raw.githubusercontent.com/oss-review-toolkit/ort/main/integrations/schemas/package-managers-schema.json"
}
},
"options": {
"additionalProperties": {
"type": [
"boolean",
"number",
"string"
]
}
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
analyzer:
allow_dynamic_versions: false
enabled_package_managers:
- Gradle
- Maven
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
analyzer:
package_managers:
Gradle:
must_run_after:
Copy link
Member

Choose a reason for hiding this comment

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

Just to double-check: In my global config.yml I use mustRunAfter and it works. And that's exactly the (confusing) point, that the syntax is different between config.yml and .ort.yml, right?

Copy link
Member Author

Choose a reason for hiding this comment

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

Correct.

Copy link
Member Author

Choose a reason for hiding this comment

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

The tests now also cover the two cases:
allow_dynamic_versions in the added analyzer-repository-configuration.ort.yml file,
and allowDynamicVersions in the reference.yml file.

- Maven
options:
foo: bar
26 changes: 26 additions & 0 deletions model/src/test/kotlin/JsonSchemaTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,26 @@ class JsonSchemaTest : StringSpec({
}
}

"Analyzer configuration within a repository configuration validates successfully" {
val repositoryConfiguration = File("src/test/assets/analyzer-repository-configuration.ort.yml").toJsonNode()
val analyzerConfiguration = repositoryConfiguration.get("analyzer")

val errors = schemaV7.getSchema(repositoryConfigurationAnalyzerConfiguration).validate(analyzerConfiguration)

errors should beEmpty()
}

"Package manager configuration within a repository configuration validates successfully" {
val repositoryConfiguration =
File("src/test/assets/package-manager-repository-configuration.ort.yml").toJsonNode()
val packageManagerConfiguration = repositoryConfiguration.get("analyzer").get("package_managers")

val errors =
schemaV7.getSchema(repositoryConfigurationPackageManagerConfiguration).validate(packageManagerConfiguration)

errors should beEmpty()
}

"The example package curations file validates successfully" {
val curationsSchema = File("../integrations/schemas/curations-schema.json").toURI()
val curationsExample = File("../examples/$ORT_PACKAGE_CURATIONS_FILENAME").toJsonNode()
Expand Down Expand Up @@ -116,4 +136,10 @@ private val schemaV7 = JsonSchemaFactory
private val repositoryConfigurationSchema =
File("../integrations/schemas/repository-configuration-schema.json").toURI()

private val repositoryConfigurationAnalyzerConfiguration =
File("../integrations/schemas/repository-configurations/analyzer-configuration-schema.json").toURI()

private val repositoryConfigurationPackageManagerConfiguration =
File("../integrations/schemas/repository-configurations/package-manager-configuration-schema.json").toURI()

private fun File.toJsonNode() = yamlMapper.readTree(inputStream())
Loading