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
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
#!/usr/bin/env sh
set -eu

COMMON_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
REPO_MAINTENANCE_ROOT=$(CDPATH= cd -- "$COMMON_DIR/.." && pwd)
COMMON_CONTEXT_DIR=${SELF_DIR:-}
[ -n "$COMMON_CONTEXT_DIR" ] || COMMON_CONTEXT_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
if [ -f "$COMMON_CONTEXT_DIR/lib/common.sh" ]; then
REPO_MAINTENANCE_ROOT="$COMMON_CONTEXT_DIR"
else
REPO_MAINTENANCE_ROOT=$(CDPATH= cd -- "$COMMON_CONTEXT_DIR/.." && pwd)
fi
REPO_ROOT=$(CDPATH= cd -- "$REPO_MAINTENANCE_ROOT/../.." && pwd)
REPO_MAINTENANCE_PROFILE="generic"
REPO_MAINTENANCE_PROFILE_DESCRIPTION="Generic repo-maintenance baseline with no Swift or Xcode specialization."
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
#!/usr/bin/env sh
set -eu

COMMON_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
REPO_MAINTENANCE_ROOT=$(CDPATH= cd -- "$COMMON_DIR/.." && pwd)
COMMON_CONTEXT_DIR=${SELF_DIR:-}
[ -n "$COMMON_CONTEXT_DIR" ] || COMMON_CONTEXT_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
if [ -f "$COMMON_CONTEXT_DIR/lib/common.sh" ]; then
REPO_MAINTENANCE_ROOT="$COMMON_CONTEXT_DIR"
else
REPO_MAINTENANCE_ROOT=$(CDPATH= cd -- "$COMMON_CONTEXT_DIR/.." && pwd)
fi
REPO_ROOT=$(CDPATH= cd -- "$REPO_MAINTENANCE_ROOT/../.." && pwd)
REPO_MAINTENANCE_PROFILE="generic"
REPO_MAINTENANCE_PROFILE_DESCRIPTION="Generic repo-maintenance baseline with no Swift or Xcode specialization."
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
#!/usr/bin/env sh
set -eu

COMMON_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
REPO_MAINTENANCE_ROOT=$(CDPATH= cd -- "$COMMON_DIR/.." && pwd)
COMMON_CONTEXT_DIR=${SELF_DIR:-}
[ -n "$COMMON_CONTEXT_DIR" ] || COMMON_CONTEXT_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
if [ -f "$COMMON_CONTEXT_DIR/lib/common.sh" ]; then
REPO_MAINTENANCE_ROOT="$COMMON_CONTEXT_DIR"
else
REPO_MAINTENANCE_ROOT=$(CDPATH= cd -- "$COMMON_CONTEXT_DIR/.." && pwd)
fi
REPO_ROOT=$(CDPATH= cd -- "$REPO_MAINTENANCE_ROOT/../.." && pwd)
REPO_MAINTENANCE_PROFILE="generic"
REPO_MAINTENANCE_PROFILE_DESCRIPTION="Generic repo-maintenance baseline with no Swift or Xcode specialization."
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
#!/usr/bin/env sh
set -eu

COMMON_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
REPO_MAINTENANCE_ROOT=$(CDPATH= cd -- "$COMMON_DIR/.." && pwd)
COMMON_CONTEXT_DIR=${SELF_DIR:-}
[ -n "$COMMON_CONTEXT_DIR" ] || COMMON_CONTEXT_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
if [ -f "$COMMON_CONTEXT_DIR/lib/common.sh" ]; then
REPO_MAINTENANCE_ROOT="$COMMON_CONTEXT_DIR"
else
REPO_MAINTENANCE_ROOT=$(CDPATH= cd -- "$COMMON_CONTEXT_DIR/.." && pwd)
fi
REPO_ROOT=$(CDPATH= cd -- "$REPO_MAINTENANCE_ROOT/../.." && pwd)
REPO_MAINTENANCE_PROFILE="generic"
REPO_MAINTENANCE_PROFILE_DESCRIPTION="Generic repo-maintenance baseline with no Swift or Xcode specialization."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,24 @@ def test_sync_creates_agents_template(self) -> None:
)
self.assertTrue(Path(tmpdir, ".github/workflows/validate-repo-maintenance.yml").is_file())

def test_generated_repo_maintenance_validation_uses_repo_self_dir(self) -> None:
with tempfile.TemporaryDirectory() as tmpdir:
Path(tmpdir, "Package.swift").write_text("// swift-tools-version: 6.0\n", encoding="utf-8")
code, payload = self.run_script("--repo-root", tmpdir)
self.assertEqual(code, 0)
self.assertEqual(payload["status"], "success")

subprocess.run(["git", "init"], cwd=tmpdir, check=True, capture_output=True, text=True)
proc = subprocess.run(
["sh", "scripts/repo-maintenance/validate-all.sh"],
cwd=tmpdir,
capture_output=True,
text=True,
check=False,
)
self.assertEqual(proc.returncode, 0, proc.stderr or proc.stdout)
self.assertIn("Repo-maintenance validation completed successfully.", proc.stdout)

def test_sync_appends_section_to_existing_agents(self) -> None:
with tempfile.TemporaryDirectory() as tmpdir:
Path(tmpdir, "Package.swift").write_text("// swift-tools-version: 6.0\n", encoding="utf-8")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
#!/usr/bin/env sh
set -eu

COMMON_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
REPO_MAINTENANCE_ROOT=$(CDPATH= cd -- "$COMMON_DIR/.." && pwd)
COMMON_CONTEXT_DIR=${SELF_DIR:-}
[ -n "$COMMON_CONTEXT_DIR" ] || COMMON_CONTEXT_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
if [ -f "$COMMON_CONTEXT_DIR/lib/common.sh" ]; then
REPO_MAINTENANCE_ROOT="$COMMON_CONTEXT_DIR"
else
REPO_MAINTENANCE_ROOT=$(CDPATH= cd -- "$COMMON_CONTEXT_DIR/.." && pwd)
fi
REPO_ROOT=$(CDPATH= cd -- "$REPO_MAINTENANCE_ROOT/../.." && pwd)
REPO_MAINTENANCE_PROFILE="generic"
REPO_MAINTENANCE_PROFILE_DESCRIPTION="Generic repo-maintenance baseline with no Swift or Xcode specialization."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,37 @@ def test_install_writes_toolkit_files(self) -> None:
self.assertIn('REPO_MAINTENANCE_PROFILE="swift-package"', Path(tmpdir, "scripts/repo-maintenance/config/profile.env").read_text(encoding="utf-8"))
self.assertTrue(Path(tmpdir, ".github/workflows/validate-repo-maintenance.yml").is_file())

def test_generated_validation_uses_repo_maintenance_self_dir(self) -> None:
with tempfile.TemporaryDirectory() as tmpdir:
code, payload = self.run_script("--repo-root", tmpdir, "--operation", "install")
self.assertEqual(code, 0)
self.assertEqual(payload["status"], "success")

Path(tmpdir, "AGENTS.md").write_text(
"\n".join(
[
"# AGENTS.md",
"",
"- scripts/repo-maintenance/validate-all.sh",
"- scripts/repo-maintenance/sync-shared.sh",
"- scripts/repo-maintenance/release.sh",
"",
]
),
encoding="utf-8",
)
subprocess.run(["git", "init"], cwd=tmpdir, check=True, capture_output=True, text=True)

proc = subprocess.run(
["sh", "scripts/repo-maintenance/validate-all.sh"],
cwd=tmpdir,
capture_output=True,
text=True,
check=False,
)
self.assertEqual(proc.returncode, 0, proc.stderr or proc.stdout)
self.assertIn("Repo-maintenance validation completed successfully.", proc.stdout)

def test_refresh_preserves_repo_specific_extra_script(self) -> None:
with tempfile.TemporaryDirectory() as tmpdir:
code, payload = self.run_script("--repo-root", tmpdir, "--operation", "install")
Expand Down