Skip to content

Commit 3567164

Browse files
committed
Avoid yamllint truthy violations with github workflows
Fixes: #3645
1 parent 9d96cfb commit 3567164

File tree

4 files changed

+31
-10
lines changed

4 files changed

+31
-10
lines changed

.github/workflows/tox.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ jobs:
7171
WSLENV: FORCE_COLOR:PYTEST_REQPASS:TOXENV:GITHUB_STEP_SUMMARY
7272
# Number of expected test passes, safety measure for accidental skip of
7373
# tests. Update value if you add/remove tests.
74-
PYTEST_REQPASS: 814
74+
PYTEST_REQPASS: 815
7575
steps:
7676
- name: Activate WSL1
7777
if: "contains(matrix.shell, 'wsl')"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
name: ack
3+
on: # <-- this is invalid by YAML 1.2 spec as it loads as true boolean.
4+
pull_request_target:
5+
types: [opened, labeled, unlabeled, synchronize]
6+
7+
jobs:
8+
ack:
9+
uses: ansible/devtools/.github/workflows/ack.yml@main

src/ansiblelint/rules/yaml_rule.py

+12
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,12 @@ def matchyaml(self, file: Lintable) -> list[MatchError]:
7373
self.severity = "VERY_LOW"
7474
if problem.level == "error":
7575
self.severity = "MEDIUM"
76+
# Ignore truthy violation with github workflows ("on:" keys)
77+
if problem.rule == "truthy" and file.path.parent.parts[-2:] == (
78+
".github",
79+
"workflows",
80+
):
81+
continue
7682
matches.append(
7783
self.create_matcherror(
7884
# yamllint does return lower-case sentences
@@ -180,6 +186,12 @@ def _fetch_skips(data: Any, collector: dict[int, set[str]]) -> dict[int, set[str
180186
[],
181187
id="rule-yaml-pass",
182188
),
189+
pytest.param(
190+
"examples/yamllint/.github/workflows/ci.yml",
191+
"yaml",
192+
[],
193+
id="rule-yaml-github-workflow",
194+
),
183195
),
184196
)
185197
@pytest.mark.filterwarnings("ignore::ansible_compat.runtime.AnsibleWarning")
+9-9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"ansible-lint-config": {
3-
"etag": "786b5e9ad1a19bebdb964840a32b921201a80adcab0a04fcbd4c926fc9e90335",
3+
"etag": "616457d973f4b221d85910086ce1fab520d8a363b1e1e62a62e4d8b57a824976",
44
"url": "https://raw.githubusercontent.com/ansible/ansible-lint/main/src/ansiblelint/schemas/ansible-lint-config.json"
55
},
66
"ansible-navigator-config": {
@@ -12,39 +12,39 @@
1212
"url": "https://raw.githubusercontent.com/ansible/ansible-lint/main/src/ansiblelint/schemas/changelog.json"
1313
},
1414
"execution-environment": {
15-
"etag": "f3abb1716134227ccd667607840dd7bdebfd02a8980603df031282126dc78264",
15+
"etag": "2e1b1d02460fb93892252439e9634d9574dfdd37aea82af32f4622dacd5990b5",
1616
"url": "https://raw.githubusercontent.com/ansible/ansible-lint/main/src/ansiblelint/schemas/execution-environment.json"
1717
},
1818
"galaxy": {
19-
"etag": "61f38feb51dc7eaff43ab22f3759b3a5202776ee75ee4204f07135282817f724",
19+
"etag": "a842f41dee838f4cf19d24d5b056a785fd2ea3449bbd899f82b6ba41ba1068db",
2020
"url": "https://raw.githubusercontent.com/ansible/ansible-lint/main/src/ansiblelint/schemas/galaxy.json"
2121
},
2222
"inventory": {
23-
"etag": "3dcd4890bf31e634a7c4f6138286a42b4985393f210f7ffaa840c2127876aa55",
23+
"etag": "b52c251a121e2e807928db7b4e09338babde9e74a50d0f74e8908f6e230d101d",
2424
"url": "https://raw.githubusercontent.com/ansible/ansible-lint/main/src/ansiblelint/schemas/inventory.json"
2525
},
2626
"meta": {
27-
"etag": "0f376059285181985711b4271a6ff34a8dde662b9fc221d09bdcd64e4fbf86bf",
27+
"etag": "d1f66f20b45ecb814d9be900f01451d8035059b312de4a19edc64e29811a7f39",
2828
"url": "https://raw.githubusercontent.com/ansible/ansible-lint/main/src/ansiblelint/schemas/meta.json"
2929
},
3030
"meta-runtime": {
3131
"etag": "448b614e9d4411b82d220950b7a415c248cc75d5431f9b8058c771a595d40163",
3232
"url": "https://raw.githubusercontent.com/ansible/ansible-lint/main/src/ansiblelint/schemas/meta-runtime.json"
3333
},
3434
"molecule": {
35-
"etag": "3456b2e5aaa02fde359ff147cff81d01a37c07f5e10542b6b8b61aaaf8c756a6",
35+
"etag": "3b625438c28e884ac42a14c09ca542fc3e1b4466abaf47d0c28646e0857d3fb5",
3636
"url": "https://raw.githubusercontent.com/ansible/ansible-lint/main/src/ansiblelint/schemas/molecule.json"
3737
},
3838
"playbook": {
3939
"etag": "48d584b10235804c13de78177dcfeeba433bd4d196ef3872aac7fc26a26303f5",
4040
"url": "https://raw.githubusercontent.com/ansible/ansible-lint/main/src/ansiblelint/schemas/playbook.json"
4141
},
4242
"requirements": {
43-
"etag": "93c6ccd1f79f58134795b85f9b1193d6e18417dd01a9d1f37d9f247562a1e6fe",
43+
"etag": "5ae3a6058ac626a341338c760db7cef7f02a8911c7293c7e129dbc6b0f8bb86d",
4444
"url": "https://raw.githubusercontent.com/ansible/ansible-lint/main/src/ansiblelint/schemas/requirements.json"
4545
},
4646
"role-arg-spec": {
47-
"etag": "498a6f716c7e99bd474ae9e7d34b3f43fbf2aad750f769392fc8e29fa590be6c",
47+
"etag": "5113ade1d42ab250729da4a24772dd8abe8777d91f241388e4bf6033fe91ef98",
4848
"url": "https://raw.githubusercontent.com/ansible/ansible-lint/main/src/ansiblelint/schemas/role-arg-spec.json"
4949
},
5050
"rulebook": {
@@ -56,7 +56,7 @@
5656
"url": "https://raw.githubusercontent.com/ansible/ansible-lint/main/src/ansiblelint/schemas/tasks.json"
5757
},
5858
"vars": {
59-
"etag": "5d6c2c22a58f2b48c2a8d8d129f2516e4f17ffc78a2c9ba045eb5ede0ff749d7",
59+
"etag": "73feaa77561d1d5b0bebe6cd66d499a28d67037055ac6d746139a38c9d28ca04",
6060
"url": "https://raw.githubusercontent.com/ansible/ansible-lint/main/src/ansiblelint/schemas/vars.json"
6161
}
6262
}

0 commit comments

Comments
 (0)