diff --git a/.github/workflows/tox.yml b/.github/workflows/tox.yml index 6c2c302d9f..95f8943692 100644 --- a/.github/workflows/tox.yml +++ b/.github/workflows/tox.yml @@ -71,7 +71,7 @@ jobs: env: # Number of expected test passes, safety measure for accidental skip of # tests. Update value if you add/remove tests. - PYTEST_REQPASS: 854 + PYTEST_REQPASS: 855 steps: - uses: actions/checkout@v4 with: diff --git a/src/ansiblelint/rules/__init__.py b/src/ansiblelint/rules/__init__.py index ef507187ff..48fec81fe7 100644 --- a/src/ansiblelint/rules/__init__.py +++ b/src/ansiblelint/rules/__init__.py @@ -503,11 +503,16 @@ def run( or rule.has_dynamic_tags or not set(rule.tags).union([rule.id]).isdisjoint(tags) ): - _logger.debug("Running rule %s", rule.id) - rule_definition = set(rule.tags) - rule_definition.add(rule.id) - if set(rule_definition).isdisjoint(skip_list): - matches.extend(rule.getmatches(file)) + if tags and set(rule.tags).union(list(rule.ids().keys())).isdisjoint( + tags, + ): + _logger.debug("Skipping rule %s", rule.id) + else: + _logger.debug("Running rule %s", rule.id) + rule_definition = set(rule.tags) + rule_definition.add(rule.id) + if set(rule_definition).isdisjoint(skip_list): + matches.extend(rule.getmatches(file)) else: _logger.debug("Skipping rule %s", rule.id) diff --git a/src/ansiblelint/schemas/__store__.json b/src/ansiblelint/schemas/__store__.json index 8387834a37..e563a63b0f 100644 --- a/src/ansiblelint/schemas/__store__.json +++ b/src/ansiblelint/schemas/__store__.json @@ -36,7 +36,7 @@ "url": "https://raw.githubusercontent.com/ansible/ansible-lint/main/src/ansiblelint/schemas/molecule.json" }, "playbook": { - "etag": "b86e7f78281e33eb16de9c5c066da0f88798243b647cc195573441d92e1e78a5", + "etag": "642a03707aadf49b54216f5882d6e91509fccaad7fc105fb83e24f15151bfafa", "url": "https://raw.githubusercontent.com/ansible/ansible-lint/main/src/ansiblelint/schemas/playbook.json" }, "requirements": { @@ -44,7 +44,7 @@ "url": "https://raw.githubusercontent.com/ansible/ansible-lint/main/src/ansiblelint/schemas/requirements.json" }, "role-arg-spec": { - "etag": "e0f25bc37f7b43d55b8e8f41929cab803179550e237d63c1134d51dfdd985ddf", + "etag": "74fc5d429919813f2c977a2e3ed2afee1ca3dba242f6978bded8199895642db6", "url": "https://raw.githubusercontent.com/ansible/ansible-lint/main/src/ansiblelint/schemas/role-arg-spec.json" }, "rulebook": { diff --git a/test/test_with_skip_tagid.py b/test/test_with_skip_tagid.py index 10e9493c26..a2a46c3c1b 100644 --- a/test/test_with_skip_tagid.py +++ b/test/test_with_skip_tagid.py @@ -27,7 +27,7 @@ def test_negative_with_id() -> None: def test_negative_with_tag() -> None: """Negative test with_tag.""" - with_tag = "trailing-spaces" + with_tag = "yaml[trailing-spaces]" bad_runner = Runner(FILE, rules=collection, tags=frozenset([with_tag])) errs = bad_runner.run() assert len(errs) == 1 @@ -40,6 +40,13 @@ def test_positive_skip_id() -> None: assert [] == good_runner.run() +def test_positive_skip_id_2() -> None: + """Positive test skip_id.""" + skip_id = "key-order" + good_runner = Runner(FILE, rules=collection, tags=frozenset([skip_id])) + assert [] == good_runner.run() + + def test_positive_skip_tag() -> None: """Positive test skip_tag.""" skip_tag = "yaml[trailing-spaces]"