diff --git a/forgetest/forgetest/manifest.py b/forgetest/forgetest/manifest.py index ff17b21..57e517a 100644 --- a/forgetest/forgetest/manifest.py +++ b/forgetest/forgetest/manifest.py @@ -511,9 +511,10 @@ def workflow_steps(text): it; comments, whole lines and from ' #' to the end of a line, are not read. Anything outside a step (a trigger's paths, a job's name) is not a step. A key with one stray quote (`if":`, `"run:`) at the top level, - at a job's name or a job's key, or at a step's key is no key the lint - reads: every step of the workflow then carries "unread" and counts as - no step.""" + at a job's name or a job's key, at a step's key, or as the first key of + any list item (a step's first key is on its dash line: `- run": make`) + is no key the lint reads: every step of the workflow then carries + "unread" and counts as no step.""" lines = _lines(text) steps, i = [], 0 in_jobs, job_at, key_at, job = False, None, None, None @@ -534,6 +535,11 @@ def workflow_steps(text): ind = _indent(lines[i]) stray = stray or ind == 0 or (in_jobs and (job_at is None or ind == job_at or ( ind > job_at and (key_at is None or ind == key_at)))) + # A list item's first key is on its dash line, where _STEP_RX reads no + # key with a stray quote: the dash and the spaces after it become spaces. + item = re.match(r"^\s*-\s+", lines[i]) + if item and _stray_key(" " * item.end() + lines[i][item.end():]): + stray = True m = _STEP_RX.match(lines[i]) if not m: i += 1 diff --git a/forgetest/tests/test_manifest.py b/forgetest/tests/test_manifest.py index 832b85c..ba7df1a 100644 --- a/forgetest/tests/test_manifest.py +++ b/forgetest/tests/test_manifest.py @@ -330,10 +330,11 @@ class CoverageReportTests(unittest.TestCase): # however the step is spelled: more than one space after its dash, or a quoted key self.assertFalse(self._runs("steps:\n - run: ./build/tray_test\n if: false\n", test)) self.assertFalse(self._runs(step % " \"if\": false\n", test)) - # a key with one stray quote is no key the lint reads: at a step's key, a job's key or - # the top level, no step of the workflow counts + # a key with one stray quote is no key the lint reads: at a step's key (its first one on + # its dash line too), a job's key or the top level, no step of the workflow counts self.assertFalse(self._runs(step % " if\": false\n", test)) self.assertFalse(self._runs("steps:\n - name: x\n run\": ./build/tray_test\n", test)) + self.assertFalse(self._runs("steps:\n - run\": make\n - run: ./build/tray_test\n", test)) self.assertFalse(self._runs("jobs:\n t:\n if\": false\n steps:\n - run: ./build/tray_test\n", test)) self.assertFalse(self._runs("jobs\":\n t:\n if: false\n steps:\n - run: ./build/tray_test\n",