Repository navigation
feat: implement issue #545 — Compliance: non-stub-dependency-audit.yml #548
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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). | ||
|
|
||
| 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 | ||
|
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()) | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.