feat: project init#29
Open
nazarli-shabnam wants to merge 8 commits into
Open
Conversation
…nv.example template, and expand .gitignore rules
…ce skills lockfile
…local docker compose
There was a problem hiding this comment.
Pull request overview
This PR bootstraps the repository with baseline configuration for local development and CI/CD, plus initial Python API/worker services, a shared “checks” package, Docker/Compose artifacts, and contributor/assistant documentation.
Changes:
- Added CI and release GitHub Actions workflows, plus commitlint + Husky hooks to enforce commit conventions and run local checks.
- Introduced initial FastAPI API, a psycopg-based worker, Alembic migrations, and a shared
packages/checkslibrary for GitHub security checks. - Added Dockerfiles, Compose stack, env examples, and repo hygiene files (.gitignore/.gitattributes/.dockerignore) + docs (README/CONTRIBUTING/CLAUDE).
Reviewed changes
Copilot reviewed 63 out of 67 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| skills-lock.json | Locks AI “skills” metadata. |
| requirements-test.txt | Adds pytest test dependency pin. |
| README.md | Project overview + self-host/CI notes. |
| pytest.ini | Sets pytest discovery paths and pythonpath. |
| packages/checks/src/checks/base.py | Defines Check base + metadata dataclass. |
| packages/checks/src/checks/github_checks.py | Implements GitHub org/repo security checks. |
| packages/checks/src/checks/runner.py | Aggregates and runs all checks. |
| packages/checks/pyproject.toml | Defines build metadata for clevis-checks. |
| package.json | Adds root dev tooling (husky/commitlint). |
| package-lock.json | Locks root Node dev dependencies. |
| docker-compose.yml | Defines db/api/worker/ui services with profiles. |
| CONTRIBUTING.md | Contributor workflow + local/CI parity commands. |
| commitlint.config.cjs | Commitlint configuration + merge commit ignores. |
| CLAUDE.md | Architecture/setup guidance for AI assistants. |
| apps/worker/tests/test_process_job.py | Unit-style tests for worker job processing. |
| apps/worker/src/worker.py | Worker loop + job processing implementation. |
| apps/worker/src/config.py | Worker settings loading via pydantic-settings. |
| apps/worker/src/_crypto.py | Worker token decryption helper. |
| apps/worker/requirements.txt | Worker runtime dependency pins. |
| apps/worker/entrypoint.sh | Worker container entrypoint (builds DATABASE_URL). |
| apps/worker/Dockerfile | Worker image build instructions. |
| apps/worker/.dockerignore | Minimizes worker image build context. |
| apps/api/tests/test_repositories.py | Repository-layer DB tests. |
| apps/api/tests/test_health.py | Health endpoint unit + integration tests. |
| apps/api/tests/conftest.py | SQLAlchemy session/transaction test fixtures. |
| apps/api/src/services/rbac.py | Header-based RBAC dependency. |
| apps/api/src/services/github_client.py | Simple GitHub API client with retries. |
| apps/api/src/services/cache_service.py | Enqueues cache-clear jobs + audit logging. |
| apps/api/src/services/analytics_service.py | Builds an overview score from checks. |
| apps/api/src/schemas/job.py | Pydantic response model for jobs. |
| apps/api/src/schemas/installation.py | Pydantic models for installation sync. |
| apps/api/src/schemas/cache.py | Pydantic models for cache list/clear. |
| apps/api/src/schemas/analytics.py | Pydantic models for analytics overview. |
| apps/api/src/schemas/init.py | Schema package marker. |
| apps/api/src/routers/jobs.py | Jobs listing endpoint. |
| apps/api/src/routers/health.py | Health endpoint. |
| apps/api/src/routers/auth.py | GitHub installation sync endpoint. |
| apps/api/src/routers/analytics.py | Analytics overview endpoint + error mapping. |
| apps/api/src/routers/actions_cache.py | Actions cache list/clear endpoints + RBAC. |
| apps/api/src/repositories/job_repo.py | Job persistence functions. |
| apps/api/src/repositories/installation_repo.py | Installation persistence function. |
| apps/api/src/repositories/audit_repo.py | Audit log persistence function. |
| apps/api/src/repositories/init.py | Repository package marker. |
| apps/api/src/main.py | FastAPI app wiring + middleware/router setup. |
| apps/api/src/core/middleware.py | Request ID middleware. |
| apps/api/src/core/logging.py | Request-id logging filter wiring. |
| apps/api/src/core/db.py | SQLAlchemy models + engine/session factory. |
| apps/api/src/core/config.py | API settings loading via pydantic-settings. |
| apps/api/src/core/_crypto.py | Token encrypt/decrypt helpers for jobs. |
| apps/api/requirements.txt | API runtime dependency pins. |
| apps/api/entrypoint.sh | API entrypoint (builds DATABASE_URL + runs alembic). |
| apps/api/Dockerfile | API image build instructions. |
| apps/api/alembic/versions/0002_add_jobs_index.py | Migration adding composite jobs index. |
| apps/api/alembic/versions/0001_initial_schema.py | Initial DB schema migration. |
| apps/api/alembic/script.py.mako | Alembic revision template. |
| apps/api/alembic/README | Alembic placeholder readme. |
| apps/api/alembic/env.py | Alembic env configuration. |
| apps/api/alembic.ini | Alembic config file. |
| .husky/pre-commit | Local pre-commit hook (UI typecheck). |
| .husky/commit-msg | Local commit-msg hook (commitlint). |
| .gitignore | Updates ignore rules for env, node, data, etc. |
| .github/workflows/release.yml | Builds/pushes images to GHCR on tags. |
| .github/workflows/ci.yml | CI for commitlint, UI checks, Python tests, Docker builds. |
| .gitattributes | Normalizes line endings and marks binaries. |
| .env.example | Sample environment variables for local/CI. |
| .dockerignore | Reduces root Docker build context and excludes secrets. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+4
to
+8
| from unittest.mock import MagicMock, patch | ||
|
|
||
| from _crypto import encrypt_job_token | ||
| from config import settings | ||
| from worker import process_job |
Comment on lines
+8
to
+10
|
|
||
| [tool.setuptools.packages.find] | ||
| where = ["src"] |
Comment on lines
+31
to
+38
| def mark_done(db: Session, job_id: int, result: str) -> None: | ||
| db.query(Job).filter(Job.id == job_id).update({"status": "done", "result": result}) | ||
| db.commit() | ||
|
|
||
|
|
||
| def mark_failed(db: Session, job_id: int, error: str) -> None: | ||
| db.query(Job).filter(Job.id == job_id).update({"status": "failed", "result": error}) | ||
| db.commit() |
Comment on lines
+6
to
+10
| _ROOT = Path(__file__).resolve().parent | ||
| while _ROOT != _ROOT.parent: | ||
| if (_ROOT / ".env").exists(): | ||
| break | ||
| _ROOT = _ROOT.parent |
Comment on lines
+6
to
+10
| _ROOT = Path(__file__).resolve().parent | ||
| while _ROOT != _ROOT.parent: | ||
| if (_ROOT / ".env").exists(): | ||
| break | ||
| _ROOT = _ROOT.parent |
Comment on lines
+10
to
+15
| def require_role(required: str) -> Callable: | ||
| def _check(x_role: str | None = Header(default=None)) -> str: | ||
| role = x_role or settings.default_rbac_role | ||
| if _LEVELS.get(role, 0) < _LEVELS.get(required, 0): | ||
| raise HTTPException(status_code=403, detail="Insufficient role") | ||
| return role |
Comment on lines
+61
to
+72
| def run(self, owner: str, token: str, base_url: str = "https://api.github.com") -> dict: | ||
| repos = _get_all_pages(base_url, f"/orgs/{owner}/repos", token) | ||
| checked = 0 | ||
| protected = 0 | ||
| for repo in repos: | ||
| checked += 1 | ||
| branch = repo.get("default_branch") | ||
| details = _get(f"{base_url}/repos/{owner}/{repo['name']}/branches/{branch}", token) | ||
| if details.get("protected"): | ||
| protected += 1 | ||
| compliant = checked > 0 and checked == protected | ||
| return {"status": "pass" if compliant else "fail", "value": {"checked": checked, "protected": protected}} |
Comment on lines
+86
to
+94
| env: | ||
| DATABASE_URL: postgresql+psycopg://clevis:clevis@localhost:5432/clevis | ||
| JOB_SECRET_KEY: ${{ secrets.JOB_SECRET_KEY }} | ||
| GITHUB_API_BASE: https://api.github.com | ||
| CORS_ORIGINS: '["http://localhost:3000"]' | ||
| DEFAULT_RBAC_ROLE: viewer | ||
| WORKER_POLL_SECONDS: "5" | ||
| DEBUG: "false" | ||
| steps: |
apps/ui was committed as a submodule gitlink (mode 160000) because create-next-app ran git init inside the directory. CI checked out an empty folder, causing the UI typecheck/build and Docker UI build to fail. Removed the nested .git, unstaged the gitlink, and re-added all source files as regular tracked files.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This pull request introduces foundational configuration and documentation to support local development, CI/CD, Docker builds, and contribution guidelines for the project. It adds essential files for environment setup, Docker image creation, Git hooks, and continuous integration workflows, as well as detailed documentation for contributors and AI code assistants. These changes establish a robust baseline for both developer experience and automation.
Key changes include:
CI/CD and Automation:
Development Environment and Tooling:
.dockerignoreto optimize Docker build context, excluding unnecessary files and secrets from images. (.dockerignore).env.examplefor consistent local and CI configuration. (.env.example)alembic.iniand a README for migration scripts. (apps/api/alembic.ini, apps/api/alembic/README) [1] [2]Documentation and Contribution Guidelines:
Git and Commit Hooks:
.gitattributes. (.gitattributes)