Skip to content

Commit 2feb404

Browse files
committed
Renamed rule to galaxy
1 parent 0b0a16d commit 2feb404

File tree

4 files changed

+18
-21
lines changed

4 files changed

+18
-21
lines changed

.github/workflows/tox.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ jobs:
166166
WSLENV: FORCE_COLOR:PYTEST_REQPASS:TOXENV:TOX_PARALLEL_NO_SPINNER
167167
# Number of expected test passes, safety measure for accidental skip of
168168
# tests. Update value if you add/remove tests.
169-
PYTEST_REQPASS: 703
169+
PYTEST_REQPASS: 705
170170

171171
steps:
172172
- name: Activate WSL1

examples/meta/galaxy.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
name: foo
33
namespace: bar
4-
version: 0.2.3
4+
version: 0.2.3 # <-- that version is not valid, should be 1.0.0 or greater
55
authors:
66
- John
77
readme: ../README.md
@@ -11,5 +11,4 @@ dependencies:
1111
other_namespace.collection2: ">=2.0.0,<3.0.0"
1212
anderson55.my_collection: "*" # note: "*" selects the highest version available
1313
license:
14-
- GPL # <-- invalid license values based on galaxy schema
15-
- Apache
14+
- Apache-2.0

src/ansiblelint/rules/galaxy_collection_version.md renamed to src/ansiblelint/rules/galaxy.md

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,23 @@
1-
# galaxy collection version
1+
# galaxy
22

3-
This rule identifies if the collection version mentioned in galaxy.yml is ideal in terms of the version number being greater than or equal to 1.0.0.
3+
This rule identifies if the collection version mentioned in galaxy.yml is ideal in terms of the version number being greater than or equal to `1.0.0`.
44

55
This rule can produce messages such:
66

7-
- `collection-version-missing[galaxy]` - galaxy.yaml should have version tag.
8-
- `collection-version[galaxy]` - collection version should be greater than or equal to 1.0.0
7+
- `galaxy[version-missing]` - `galaxy.yaml` should have version tag.
8+
- `galaxy[version-incorrect]` - collection version should be greater than or equal to `1.0.0`
99

1010
If you want to ignore some of the messages above, you can add any of them to
1111
the `ignore_list`.
1212

1313
## Problematic code
1414

15-
# galaxy.yml
16-
1715
```yaml
16+
# galaxy.yml
1817
---
1918
name: foo
2019
namespace: bar
21-
version: 0.2.3 # <-- collection version should be <= 1.0.0
20+
version: 0.2.3 # <-- collection version should be >= 1.0.0
2221
authors:
2322
- John
2423
readme: ../README.md
@@ -27,9 +26,8 @@ description: "..."
2726
2827
## Correct code
2928
30-
# galaxy.yml
31-
3229
```yaml
30+
# galaxy.yml
3331
---
3432
name: foo
3533
namespace: bar

src/ansiblelint/rules/galaxy_collection_version.py renamed to src/ansiblelint/rules/galaxy.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""Implementation of GalaxyCollectionVersionRule."""
1+
"""Implementation of GalaxyRule."""
22
from __future__ import annotations
33

44
import sys
@@ -16,10 +16,10 @@
1616
from ansiblelint.file_utils import Lintable
1717

1818

19-
class GalaxyCollectionVersionRule(AnsibleLintRule):
19+
class GalaxyRule(AnsibleLintRule):
2020
"""Rule for checking collection version is greater than 1.0.0."""
2121

22-
id = "galaxy-collection-version"
22+
id = "galaxy"
2323
description = "Confirm via galaxy.yml file if collection version is greater than or equal to 1.0.0"
2424
severity = "MEDIUM"
2525
tags = ["metadata"]
@@ -34,7 +34,7 @@ def matchplay(self, file: Lintable, data: odict[str, Any]) -> list[MatchError]:
3434
self.create_matcherror(
3535
message="galaxy.yaml should have version tag.",
3636
linenumber=data[LINE_NUMBER_KEY],
37-
tag="collection-version-missing[galaxy]",
37+
tag="galaxy[version-missing]",
3838
filename=file,
3939
)
4040
]
@@ -43,7 +43,7 @@ def matchplay(self, file: Lintable, data: odict[str, Any]) -> list[MatchError]:
4343
self.create_matcherror(
4444
message="collection version should be greater than or equal to 1.0.0",
4545
linenumber=data[LINE_NUMBER_KEY],
46-
tag="collection-version[galaxy]",
46+
tag="galaxy[version-incorrect]",
4747
filename=file,
4848
)
4949
]
@@ -93,16 +93,16 @@ def _coerce(other: object) -> Version:
9393
def test_galaxy_collection_version_positive() -> None:
9494
"""Positive test for collection version in galaxy."""
9595
collection = RulesCollection()
96-
collection.register(GalaxyCollectionVersionRule())
96+
collection.register(GalaxyRule())
9797
success = "examples/galaxy.yml"
9898
good_runner = Runner(success, rules=collection)
9999
assert [] == good_runner.run()
100100

101101
def test_galaxy_collection_version_negative() -> None:
102102
"""Negative test for collection version in galaxy."""
103103
collection = RulesCollection()
104-
collection.register(GalaxyCollectionVersionRule())
104+
collection.register(GalaxyRule())
105105
failure = "examples/meta/galaxy.yml"
106106
bad_runner = Runner(failure, rules=collection)
107107
errs = bad_runner.run()
108-
assert len(errs) == 3
108+
assert len(errs) == 1

0 commit comments

Comments
 (0)