-
Notifications
You must be signed in to change notification settings - Fork 0
Fix CheckYourself org defaults findings #51
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| version: 2 | ||
| updates: | ||
| - package-ecosystem: "github-actions" | ||
| directory: "/" | ||
| schedule: | ||
| interval: "weekly" | ||
| day: "monday" | ||
| labels: | ||
| - "dependencies" | ||
| - "ci" | ||
| commit-message: | ||
| prefix: "ci(deps)" |
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
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,22 @@ | ||
| name: CI | ||
|
|
||
| on: | ||
| pull_request: | ||
| merge_group: | ||
| workflow_dispatch: | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| python-tests: | ||
| name: Python tests | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 | ||
| with: | ||
| persist-credentials: false | ||
|
|
||
| - name: Run unit tests | ||
| run: python3 -m unittest discover -s tests | ||
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,91 @@ | ||
| from __future__ import annotations | ||
|
|
||
| import importlib.util | ||
| import sys | ||
| import tempfile | ||
| import unittest | ||
| from pathlib import Path | ||
|
|
||
|
|
||
| ROOT = Path(__file__).resolve().parents[1] | ||
|
|
||
|
|
||
| def load_script(name: str, path: Path): | ||
| spec = importlib.util.spec_from_file_location(name, path) | ||
| module = importlib.util.module_from_spec(spec) | ||
| assert spec.loader is not None | ||
| sys.modules[name] = module | ||
| spec.loader.exec_module(module) | ||
| return module | ||
|
|
||
|
|
||
| parity = load_script("check_agent_parity", ROOT / "scripts" / "check-agent-parity.py") | ||
| provisioner = load_script("provision_agent_law", ROOT / "scripts" / "provision-agent-law.py") | ||
|
|
||
|
|
||
| class AgentParityTests(unittest.TestCase): | ||
| def test_strip_agent_specific_removes_markers_and_normalizes(self) -> None: | ||
| content = """--- | ||
| title: hidden | ||
| --- | ||
| # Rules | ||
| <!-- private --> | ||
| <agent>ignore</agent> | ||
|
|
||
|
|
||
| Keep this. | ||
| """ | ||
|
|
||
| self.assertEqual(parity.strip_agent_specific(content), "# Rules\n\nignore\n\nKeep this.") | ||
|
|
||
| def test_extract_sections_keeps_nested_section_names(self) -> None: | ||
| sections = parity.extract_sections("# One\nAlpha\n\n## Two\nBeta") | ||
|
|
||
| self.assertEqual(sections["One"], "Alpha") | ||
| self.assertEqual(sections["Two"], "Beta") | ||
|
|
||
| def test_check_repo_fails_when_agents_file_is_missing(self) -> None: | ||
| with tempfile.TemporaryDirectory() as tmp: | ||
| repo = Path(tmp) / "example" | ||
| repo.mkdir() | ||
| (repo / "CLAUDE.md").write_text("# Organization Principles\n\nUseful over flashy.\n") | ||
|
|
||
| result = parity.check_repo(repo) | ||
|
|
||
| self.assertEqual(result.status, "fail") | ||
| self.assertIn("AGENTS.md file is missing", result.content_differences) | ||
|
|
||
|
|
||
| class ProvisionerTests(unittest.TestCase): | ||
| def test_upsert_marker_file_replaces_existing_block(self) -> None: | ||
| with tempfile.TemporaryDirectory() as tmp: | ||
| path = Path(tmp) / "AGENTS.md" | ||
| path.write_text(f"# Rules\n\n{provisioner.START}\nold\n{provisioner.END}\n") | ||
|
|
||
| provisioner.upsert_marker_file(path, f"{provisioner.START}\nnew\n{provisioner.END}", "# Rules") | ||
|
|
||
| text = path.read_text() | ||
|
|
||
| self.assertIn("new", text) | ||
| self.assertNotIn("old", text) | ||
| self.assertEqual(text.count(provisioner.START), 1) | ||
|
|
||
| def test_choose_recipe_path_respects_capitalized_docs_tree(self) -> None: | ||
| with tempfile.TemporaryDirectory() as tmp: | ||
| repo = Path(tmp) | ||
| (repo / "Docs").mkdir() | ||
|
|
||
| path = provisioner.choose_recipe_path(repo) | ||
|
|
||
| self.assertEqual(path, Path(tmp) / "Docs" / "agent-law" / "empower-orchestrator.md") | ||
|
|
||
| def test_generated_workflow_uses_pinned_checkout_without_credentials(self) -> None: | ||
| text = provisioner.workflow_text() | ||
|
|
||
| self.assertIn("actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5", text) | ||
| self.assertIn("persist-credentials: false", text) | ||
| self.assertNotIn("actions/checkout@v4", text) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| unittest.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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This newly added CI job runs on
ubuntu-latest, but the repository instructions in/workspace/.github/AGENTS.mdrequire CI checks to run onblacksmith-2vcpu-ubuntu-2404. Because this workflow is intended to provide the repo's Python test coverage, it will either fail org policy expectations or leave the new required check running on the wrong runner class; please switch this job to the Blacksmith runner.Useful? React with 👍 / 👎.