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
2 changes: 1 addition & 1 deletion .github/workflows/dependency-audit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ permissions:

jobs:
dependency-audit:
uses: petry-projects/.github/.github/workflows/dependency-audit-reusable.yml@v2
uses: petry-projects/.github/.github/workflows/dependency-audit-reusable.yml@v1
13 changes: 13 additions & 0 deletions .github/workflows/test-dev-lead.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on:
- '.github/workflows/dev-lead*.yml'
- '.github/workflows/test-dev-lead.yml'
- '.github/workflows/issue-triage-runner.yml'
- '.github/workflows/dependency-audit.yml'
- 'tests/dev-lead/**'
- 'prompts/dev-lead/**'
push:
Expand All @@ -24,6 +25,7 @@ on:
- '.github/workflows/dev-lead*.yml'
- '.github/workflows/test-dev-lead.yml'
- '.github/workflows/issue-triage-runner.yml'
- '.github/workflows/dependency-audit.yml'
workflow_dispatch: {}

permissions:
Expand Down Expand Up @@ -118,3 +120,14 @@ jobs:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
- name: Validate dev-lead.yml is a thin caller stub
run: bash tests/dev-lead/integration/test_dev_lead_stub.sh

dependency-audit-stub:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
- name: Install PyYAML
run: python3 -m pip install --quiet pyyaml
- name: Validate dependency-audit.yml is pinned to the canonical @v1 ref
run: python3 tests/dev-lead/integration/test_dependency_audit_stub.py
68 changes: 68 additions & 0 deletions tests/dev-lead/integration/test_dependency_audit_stub.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#!/usr/bin/env python3
"""Validate that dependency-audit.yml is the canonical org stub pinned to @v1.

The org standard requires dependency-audit.yml to be a thin caller stub that
delegates to the reusable at @v1 (not @v2 or any other ref).
Comment thread
don-petry marked this conversation as resolved.
Resolved

Standard: petry-projects/.github/standards/ci-standards.md#centralization-tiers
Source of truth: petry-projects/.github/standards/workflows/dependency-audit.yml
"""
from __future__ import annotations

import sys

try:
import yaml
except ImportError:
print("FAIL: PyYAML is required (pip install pyyaml)", file=sys.stderr)
sys.exit(2)

WORKFLOW = ".github/workflows/dependency-audit.yml"
EXPECTED_USES = "petry-projects/.github/.github/workflows/dependency-audit-reusable.yml@v1"


def main() -> int:
try:
with open(WORKFLOW, encoding="utf-8") as fh:
doc = yaml.safe_load(fh)
except FileNotFoundError:
print(f"FAIL: {WORKFLOW} not found")
return 1
Comment thread
don-petry marked this conversation as resolved.
Resolved
except yaml.YAMLError as err:
print(f"FAIL: {WORKFLOW} is not valid YAML: {err}")
return 1

if not isinstance(doc, dict):
print(f"FAIL: {WORKFLOW} did not parse as a YAML mapping")
return 1

jobs = doc.get("jobs")
if not isinstance(jobs, dict) or not jobs:
print(f"FAIL: {WORKFLOW} 'jobs' key is missing, empty, or not a mapping")
return 1

for job_key, job in jobs.items():
if not isinstance(job, dict):
continue
uses = job.get("uses")
if isinstance(uses, str) and "dependency-audit-reusable.yml" in uses:
if uses == EXPECTED_USES:
print(f"PASS: {WORKFLOW} job '{job_key}' delegates to {EXPECTED_USES}")
return 0
else:
print(
f"FAIL: {WORKFLOW} job '{job_key}' uses '{uses}'\n"
f" Expected: '{EXPECTED_USES}'\n"
f" Fix: replace the `uses:` value with the canonical @v1 ref."
)
return 1

print(
f"FAIL: {WORKFLOW} has no job calling dependency-audit-reusable.yml\n"
f" Expected a job with: uses: {EXPECTED_USES}"
)
return 1


if __name__ == "__main__":
sys.exit(main())
Loading