diff --git a/lint-workflow-v2/src/bitwarden_workflow_linter/rules/pinned_job_runner.py b/lint-workflow-v2/src/bitwarden_workflow_linter/rules/pinned_job_runner.py index 2124c64a..fab50ce6 100644 --- a/lint-workflow-v2/src/bitwarden_workflow_linter/rules/pinned_job_runner.py +++ b/lint-workflow-v2/src/bitwarden_workflow_linter/rules/pinned_job_runner.py @@ -44,8 +44,11 @@ def fn(self, obj: Job) -> Tuple[bool, str]: steps: - run: echo test + call-workflow: + uses: bitwarden/server/.github/workflows/workflow-linter.yml@master + 'runs-on' is pinned to '22.04' instead of 'latest' """ - if "latest" not in obj.runs_on: - return True, "" - return False, self.message + if obj.runs_on is not None and "latest" in obj.runs_on: + return False, self.message + return True, "" diff --git a/lint-workflow-v2/tests/rules/test_pinned_job_runner.py b/lint-workflow-v2/tests/rules/test_pinned_job_runner.py index b2d6553f..07a8a208 100644 --- a/lint-workflow-v2/tests/rules/test_pinned_job_runner.py +++ b/lint-workflow-v2/tests/rules/test_pinned_job_runner.py @@ -24,6 +24,9 @@ def fixture_correct_runner(): runs-on: ubuntu-22.04 steps: - run: echo test + + call-workflow: + uses: bitwarden/server/.github/workflows/workflow-linter.yml@master """ return WorkflowBuilder.build(workflow=yaml.load(workflow), from_file=False) @@ -53,6 +56,8 @@ def test_rule_on_correct_runner(rule, correct_runner): result, _ = rule.fn(correct_runner.jobs["job-key"]) assert result is True + result, _ = rule.fn(correct_runner.jobs["call-workflow"]) + assert result is True def test_rule_on_incorrect_runner(rule, incorrect_runner): result, _ = rule.fn(incorrect_runner.jobs["job-key"])