Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion .github/workflows/ci-guards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,13 @@ jobs:

workflow-guard-source-lints:
if: ${{ inputs.linux_guard_source == 'true' }}
# Slow guards run beside workflow-guard-tests so they do not extend it.
name: workflow-guard-source-lints / ${{ matrix.group }}
strategy:
fail-fast: false
matrix:
group: [sidebar-layout, dispatch-ownership]
# These source-policy scans are independent and each dominates wall time;
# run them concurrently and aggregate through the reusable-workflow job.
runs-on: ${{ vars.LINUX_RUNNER || 'blacksmith-4vcpu-ubuntu-2404' }}
timeout-minutes: 15
permissions:
Expand All @@ -582,13 +588,20 @@ jobs:
- name: Install workflow guard Python dependencies
run: python3 -m pip install --disable-pip-version-check --no-input PyYAML==6.0.3 bashlex==0.18

- name: Validate source-lint guard structure
if: ${{ matrix.group == 'sidebar-layout' }}
run: python3 tests/test_ci_source_lint_guard_structure.py

- name: Validate sidebar lazy-layout guard
if: ${{ matrix.group == 'sidebar-layout' }}
run: python3 tests/test_ci_sidebar_lazy_layout_guard.py

- name: Initialize Bonsplit for deferred-work ownership guard
if: ${{ matrix.group == 'dispatch-ownership' }}
run: git submodule update --init --depth 1 vendor/bonsplit

- name: Validate stored DispatchWorkItem ownership
if: ${{ matrix.group == 'dispatch-ownership' }}
run: |
python3 tests/test_lint_stored_dispatch_work_items.py
python3 scripts/lint-stored-dispatch-work-items.py
Expand Down
51 changes: 51 additions & 0 deletions tests/test_ci_source_lint_guard_structure.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/usr/bin/env python3
"""Structural contract for the reusable source-lint guard lane."""

from pathlib import Path


ROOT = Path(__file__).resolve().parents[1]
GUARD_WORKFLOW = ROOT / ".github" / "workflows" / "ci-guards.yml"


def workflow_job_block(job_name: str) -> str:
lines = GUARD_WORKFLOW.read_text(encoding="utf-8").splitlines()
marker = f" {job_name}:"
for index, line in enumerate(lines):
if line != marker:
continue
body = [line]
for following in lines[index + 1 :]:
if (
following.startswith(" ")
and not following.startswith(" ")
and following.strip()
):
break
body.append(following)
return "\n".join(body)
raise AssertionError(f"{job_name} job not found")


def test_source_lint_matrix_runs_independent_slow_scans_in_parallel() -> None:
block = workflow_job_block("workflow-guard-source-lints")

assert "name: workflow-guard-source-lints / ${{ matrix.group }}" in block
assert "group: [sidebar-layout, dispatch-ownership]" in block
assert (
"- name: Validate sidebar lazy-layout guard\n"
" if: ${{ matrix.group == 'sidebar-layout' }}"
) in block
assert (
"- name: Initialize Bonsplit for deferred-work ownership guard\n"
" if: ${{ matrix.group == 'dispatch-ownership' }}"
) in block
assert (
"- name: Validate stored DispatchWorkItem ownership\n"
" if: ${{ matrix.group == 'dispatch-ownership' }}"
) in block


if __name__ == "__main__":
test_source_lint_matrix_runs_independent_slow_scans_in_parallel()
print("PASS: source-lint guard workflow structure")
Loading