-
Notifications
You must be signed in to change notification settings - Fork 0
Feature/karpathy lab init #101
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
Changes from all commits
07142ab
8abd5c7
593dbcc
518f2ee
68ba6cd
12ae863
98a4e82
1a33328
9a17805
3878de9
2aded84
2f0c512
ed2f661
51cda12
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,61 +1,46 @@ | ||
| name: "CodeQL Analysis" | ||
| name: "CodeQL Security Scan" | ||
|
|
||
| on: | ||
| push: | ||
| branches: [ "main", "feature/karpathy-lab-init" ] | ||
| branches: | ||
| - main | ||
| pull_request: | ||
| branches: [ "main" ] | ||
| branches: | ||
| - main | ||
| schedule: | ||
| # Run CodeQL every Monday at 9:00 AM UTC | ||
| - cron: '0 9 * * 1' | ||
| workflow_dispatch: | ||
|
|
||
| permissions: | ||
| actions: read | ||
| contents: read | ||
| security-events: write | ||
| - cron: "0 3 * * 0" # Opcional: escaneo semanal cada domingo a las 03:00 | ||
|
|
||
| jobs: | ||
| analyze: | ||
| name: Analyze | ||
| name: Analyze code with CodeQL | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 30 | ||
|
|
||
| permissions: | ||
| actions: read | ||
| contents: read | ||
| security-events: write | ||
|
|
||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| language: [ 'python' ] | ||
| language: ["python"] | ||
|
|
||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
| uses: actions/checkout@v6 | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Initialize CodeQL | ||
| uses: github/codeql-action/init@v4 | ||
| with: | ||
| languages: ${{ matrix.language }} | ||
|
|
||
| - name: Autobuild | ||
| uses: github/codeql-action/autobuild@v4 | ||
|
|
||
| - name: Initialize CodeQL | ||
| uses: github/codeql-action/init@v4 | ||
| with: | ||
| languages: ${{ matrix.language }} | ||
| queries: security-extended,security-and-quality | ||
| config: | | ||
| paths-ignore: | ||
| - '**/test/**' | ||
| - '**/tests/**' | ||
| - '**/*_test.py' | ||
| - '**/test_*.py' | ||
|
|
||
| - name: Autobuild | ||
| uses: github/codeql-action/autobuild@v4 | ||
|
|
||
| - name: Perform CodeQL Analysis | ||
| uses: github/codeql-action/analyze@v4 | ||
| with: | ||
| category: "/language:${{matrix.language}}" | ||
| upload: true | ||
| output: sarif-results | ||
|
|
||
| - name: Upload CodeQL results | ||
| uses: actions/upload-artifact@v4 | ||
| if: always() | ||
| with: | ||
| name: codeql-results | ||
| path: sarif-results | ||
| retention-days: 30 | ||
| - name: Perform CodeQL Analysis | ||
| uses: github/codeql-action/analyze@v4 | ||
| with: | ||
| category: "/language:${{ matrix.language }}" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,41 +1,7 @@ | ||
| import os | ||
| import sys | ||
| from pathlib import Path | ||
| from fastapi import APIRouter | ||
|
|
||
| # Add the project root to Python path | ||
| project_root = Path(__file__).parent.parent | ||
| sys.path.insert(0, str(project_root)) | ||
| router = APIRouter() | ||
|
|
||
| # Set environment variables for production | ||
| os.environ.setdefault("ENVIRONMENT", "production") | ||
| os.environ.setdefault( | ||
| "SECRET_KEY", os.environ.get("SECRET_KEY", "vercel-production-key-change-in-env") | ||
| ) | ||
|
|
||
| # Import the FastAPI app | ||
| from app.main import app | ||
|
|
||
| # Vercel expects the app to be named 'app' | ||
| # If your FastAPI app is named differently, change this | ||
| app = app | ||
|
|
||
|
|
||
| # Optional: Add Vercel-specific middleware or configuration | ||
| @app.middleware("http") | ||
| async def add_vercel_headers(request, call_next): | ||
| response = await call_next(request) | ||
| response.headers["X-Vercel-Cache"] = "MISS" | ||
| return response | ||
|
|
||
|
|
||
| # Health check endpoint for Vercel | ||
| @app.get("/api/health") | ||
| async def health_check(): | ||
| return {"status": "healthy", "platform": "vercel", "app": "NeuroBank FastAPI"} | ||
|
|
||
|
|
||
| # For local development | ||
| if __name__ == "__main__": | ||
| import uvicorn | ||
|
|
||
| uvicorn.run(app, host="0.0.0.0", port=int(os.environ.get("PORT", 8000))) | ||
| @router.get("/") | ||
| def root(): | ||
| return {"status": "ok"} | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| #!/bin/bash | ||
| autoflake --in-place --remove-unused-variables --remove-all-unused-imports -r app | ||
|
||
Uh oh!
There was an error while loading. Please reload this page.