Skip to content

Commit

Permalink
More fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ssbarnea committed Dec 17, 2022
1 parent 32f34b5 commit 4e01811
Show file tree
Hide file tree
Showing 18 changed files with 157 additions and 61 deletions.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/ansiblelint/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
{"requirements": "**/requirements.{yaml,yml}"}, # v2 and v1
{"playbook": "**/molecule/*/*.{yaml,yml}"}, # molecule playbooks
{"yaml": "**/{.ansible-lint,.yamllint}"},
{"changelog": "**/changelog.yml"},
{"changelog": "**/changelogs/changelog.yaml"},
{"yaml": "**/*.{yaml,yml}"},
{"yaml": "**/.*.{yaml,yml}"},
]
Expand Down
124 changes: 76 additions & 48 deletions src/ansiblelint/schemas/changelog.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@
{
"$defs": {
"plugin-descriptions": {
"items": {
"properties": {
"description": {
"markdownDescription": "Value of `short_description` from plugin `DOCUMENTATION`.",
"title": "Description",
"type": "string"
},
"name": {
"markdownDescription": "It must not be the FQCN, but the name inside the collection.",
"pattern": "[a-zA-Z0-9_]+",
"title": "Name",
"type": "string"
},
"namespace": {
"type": "null"
}
},
"type": "object"
},
"type": "array"
},
"release": {
"additionalProperties": false,
"properties": {
Expand Down Expand Up @@ -43,6 +65,8 @@
"type": "array"
},
"release_summary": {
"markdownDescription": "This must be valid [reStructuredText](https://en.wikipedia.org/wiki/ReStructuredText).",
"title": "Release Summary",
"type": "string"
},
"removed_features": {
Expand All @@ -69,6 +93,13 @@
"codename": {
"type": "string"
},
"fragments": {
"items": {
"type": "string"
},
"markdownDescription": "List of strings representing filenames of changelog framents.",
"type": "array"
},
"modules": {
"items": {
"properties": {
Expand All @@ -84,9 +115,9 @@
"type": "string"
},
"namespace": {
"markdownDescription": "Must be `null` for plugin and objects. For modules it must be either empty string. The namespace is used to group new modules by their namespace inside the collection.",
"markdownDescription": "Must be `''` for modules directly in `plugins/modules/`, or the dot-separated list of directories the module is in inside the `plugins/modules/` directory. The namespace is used to group new modules by their namespace inside the collection.",
"title": "Namespace",
"type": ["string", "null"]
"type": "string"
}
},
"type": "object"
Expand All @@ -100,7 +131,7 @@
"items": {
"properties": {
"description": {
"markdownDescription": "Value of `short_description` from plugin `DOCUMENTATION`.",
"markdownDescription": "A short description of what the playbook does.",
"title": "Description",
"type": "string"
},
Expand All @@ -122,7 +153,7 @@
"items": {
"properties": {
"description": {
"markdownDescription": "Value of `short_description` from plugin `DOCUMENTATION`.",
"markdownDescription": "Value of `short_description` from role's argument spec.",
"title": "Description",
"type": "string"
},
Expand All @@ -146,49 +177,47 @@
"plugins": {
"additionalProperties": false,
"properties": {
"become": {
"$ref": "#/$defs/plugin-descriptions"
},
"cache": {
"$ref": "#/$defs/plugin-descriptions"
},
"callback": {
"$ref": "#/$defs/plugin-descriptions"
},
"cliconf": {
"$ref": "#/$defs/plugin-descriptions"
},
"connections": {
"$ref": "#/$defs/plugin-descriptions"
},
"filter": {
"$ref": "#/$defs/plugin-descriptions"
},
"httpapi": {
"$ref": "#/$defs/plugin-descriptions"
},
"inventory": {
"items": {
"properties": {
"description": {
"markdownDescription": "Value of `short_description` from plugin `DOCUMENTATION`.",
"title": "Description",
"type": "string"
},
"name": {
"markdownDescription": "It must not be the FQCN, but the name inside the collection.",
"pattern": "[a-zA-Z0-9_]+",
"title": "Inventory name",
"type": "string"
},
"namespace": {
"type": "null"
}
},
"type": "object"
},
"type": "array"
"$ref": "#/$defs/plugin-descriptions"
},
"lookup": {
"items": {
"properties": {
"description": {
"markdownDescription": "Value of `short_description` from plugin `DOCUMENTATION`.",
"title": "Description",
"type": "string"
},
"name": {
"markdownDescription": "It must not be the FQCN, but the name inside the collection.",
"pattern": "[a-zA-Z0-9_]+",
"title": "Lookup name",
"type": "string"
},
"namespace": {
"type": "null"
}
},
"type": "object"
},
"type": "array"
"$ref": "#/$defs/plugin-descriptions"
},
"netconf": {
"$ref": "#/$defs/plugin-descriptions"
},
"shell": {
"$ref": "#/$defs/plugin-descriptions"
},
"strategy": {
"$ref": "#/$defs/plugin-descriptions"
},
"test": {
"$ref": "#/$defs/plugin-descriptions"
},
"vars": {
"$ref": "#/$defs/plugin-descriptions"
}
},
"type": "object"
Expand All @@ -206,15 +235,14 @@
"semver": {
"pattern": "\\d+.\\d+.\\d+.*",
"title": "Version string following SemVer specification.",
"type": "string"
"type": ["string", "null"]
}
},
"$id": "https://raw.githubusercontent.com/ansible-lint/main/src/ansiblelint/schemas/changelog.json",
"$schema": "http://json-schema.org/draft-07/schema",
"additionalProperties": false,
"description": "Antsibull Changelog Schema",
"examples": ["changelog.yml"],
"markdownDescription": "See [Changelog YAML Format](https://github.com/ansible-community/antsibull-changelog/blob/main/docs/changelog.yaml-format.md)",
"examples": ["changelogs/changelog.yaml"],
"markdownDescription": "Antsibull Changelog Schema is based on [changelog.yaml-format.md](https://github.com/ansible-community/antsibull-changelog/blob/main/docs/changelog.yaml-format.md).",
"properties": {
"ancestor": {
"$ref": "#/$defs/semver"
Expand Down
1 change: 1 addition & 0 deletions test/schemas/.mocharc.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
"colors": true,
"extension": ["ts"],
"require": "ts-node/register",
"slow": "500",
"spec": "src/**/*.spec.ts"
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
releases:
1.0.0:
release_date: 01-01-2020 # invalid date format, must be ISO-8601 !
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"params": {
"pattern": "\\d\\d\\d\\d-\\d\\d-\\d\\d"
},
"schemaPath": "#/$defs/release/properties/release_date/pattern"
"schemaPath": "#/properties/release_date/pattern"
}
]
```
Expand All @@ -23,13 +23,13 @@ stdout:
"status": "fail",
"errors": [
{
"filename": "negative_test/changelogs/invalid-date/changelog.yml",
"filename": "negative_test/changelogs/invalid-date/changelogs/changelog.yaml",
"path": "$.releases.1.0.0.release_date",
"message": "'01-01-2020' is not a 'date'",
"has_sub_errors": false
},
{
"filename": "negative_test/changelogs/invalid-date/changelog.yml",
"filename": "negative_test/changelogs/invalid-date/changelogs/changelog.yaml",
"path": "$.releases.1.0.0.release_date",
"message": "'01-01-2020' does not match '\\\\d\\\\d\\\\d\\\\d-\\\\d\\\\d-\\\\d\\\\d'",
"has_sub_errors": false
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
releases:
1.0.0:
plugins:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"params": {
"type": "null"
},
"schemaPath": "#/$defs/release/properties/plugins/properties/lookup/items/properties/namespace/type"
"schemaPath": "#/$defs/plugin-descriptions/items/properties/namespace/type"
}
]
```
Expand All @@ -23,7 +23,7 @@ stdout:
"status": "fail",
"errors": [
{
"filename": "negative_test/changelogs/invalid-plugin-namespace/changelog.yml",
"filename": "negative_test/changelogs/invalid-plugin-namespace/changelogs/changelog.yaml",
"path": "$.releases.1.0.0.plugins.lookup[0].namespace",
"message": "'foo' is not of type 'null'",
"has_sub_errors": false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ stdout:
"status": "fail",
"errors": [
{
"filename": "negative_test/changelogs/list/changelog.yml",
"filename": "negative_test/changelogs/list/changelogs/changelog.yaml",
"path": "$",
"message": "['this is invalid', 'as changelog must be object (mapping)', 'not an array (sequence)'] is not of type 'object'",
"has_sub_errors": false
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
---
releases: foo # <-- not a semver
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ stdout:
"status": "fail",
"errors": [
{
"filename": "negative_test/changelogs/no-semver/changelog.yml",
"filename": "negative_test/changelogs/no-semver/changelogs/changelog.yaml",
"path": "$.releases",
"message": "'foo' is not of type 'object'",
"has_sub_errors": false
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
---
release: {} # <- unknown key, correct would be releases
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ stdout:
"status": "fail",
"errors": [
{
"filename": "negative_test/changelogs/unknown-keys/changelog.yml",
"filename": "negative_test/changelogs/unknown-keys/changelogs/changelog.yaml",
"path": "$",
"message": "Additional properties are not allowed ('release' was unexpected)",
"has_sub_errors": false
Expand Down
59 changes: 59 additions & 0 deletions test/schemas/test/changelogs/maximal/changelog.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
---
# Example of minimal changelogs/changelog.yaml that is considered valid
ancestor: null

releases:
1.0.0-alpha:
release_date: "1980-01-01"
codename: foo
fragments: []
changes:
release_summary: This is the initial White Rabbit release. Enjoy!
major_changes:
- The authentication method handling has been rewritten.
minor_changes:
- foo - Module can now reformat hard disks without asking.
- bob lookup - Makes sure Bob isn't there multiple times.
breaking_changes:
- Due to the security bug in the post module, the module no longer accepts the password
option. Please stop using the option and change any password you ever supplied to the
module.
deprecated_features:
- foo - The bar option has been deprecated. Use the username option instead.
- send_request - The quick option has been deprecated. Use the protocol option instead.
removed_features:
- foo - The baz option has been removed. It has never been used anyway.
security_fixes:
- post - The module accidentally sent your password in plaintext to all servers it could find.
bugfixes:
- post - The module made PUT requests instead of POST requests.
- get - The module will no longer crash if it received invalid JSON data
trivial:
- something that is not included in release notes
known_issues:
- som other
modules:
- name: head
description: Make a HEAD request
namespace: "net_tools.rest"
- name: echo
description: Echo params
namespace: ""
plugins:
lookup:
- name: reverse
description: Reverse magic
namespace: null
inventory:
- name: docker
description: Inventory plugin for docker containers
namespace: null
objects:
role:
- name: install_reqs
description: Install all requirements of this collection
namespace: null
playbook:
- name: wipe_personal_data
description: Wipes all personal data from the database
namespace: null
3 changes: 3 additions & 0 deletions test/schemas/test/changelogs/minimal/changelog.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
# Example of minimal changelogs/changelog.yaml that is considered valid
releases: {}
3 changes: 0 additions & 3 deletions test/schemas/test/changelogs/minimal/changelog.yml

This file was deleted.

6 changes: 5 additions & 1 deletion test/test_schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ def test_refresh_schemas() -> None:

@pytest.mark.parametrize(
("file", "expected_tags"),
(pytest.param("examples/changelog.yml", ["schema[changelog]"], id="changelog"),),
(
pytest.param(
"examples/changelogs/changelog.yaml", ["schema[changelog]"], id="changelog"
),
),
)
def test_schema(
default_rules_collection: RulesCollection,
Expand Down

0 comments on commit 4e01811

Please sign in to comment.