-
Notifications
You must be signed in to change notification settings - Fork 19
Code Review: Security + Documentation + CI/CD #208
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
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 | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -9,24 +9,82 @@ on: | |||||||||||||||||||||||||||||||||
| jobs: | ||||||||||||||||||||||||||||||||||
| test: | ||||||||||||||||||||||||||||||||||
| runs-on: ubuntu-latest | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| strategy: | ||||||||||||||||||||||||||||||||||
| matrix: | ||||||||||||||||||||||||||||||||||
| python-version: ['3.10', '3.11', '3.12'] | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| steps: | ||||||||||||||||||||||||||||||||||
| - uses: actions/checkout@v3 | ||||||||||||||||||||||||||||||||||
| - name: Set up Python | ||||||||||||||||||||||||||||||||||
| uses: actions/setup-python@v4 | ||||||||||||||||||||||||||||||||||
| - uses: actions/checkout@v4 | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| - name: Set up Python ${{ matrix.python-version }} | ||||||||||||||||||||||||||||||||||
| uses: actions/setup-python@v5 | ||||||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||||||
| python-version: '3.11' | ||||||||||||||||||||||||||||||||||
| python-version: ${{ matrix.python-version }} | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| - name: Install dependencies | ||||||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||||||
| python -m pip install --upgrade pip | ||||||||||||||||||||||||||||||||||
| if [ -f requirements.txt ]; then pip install -r requirements.txt; fi | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| pip install -r requirements.txt | ||||||||||||||||||||||||||||||||||
| pip install pytest pytest-cov pytest-mock | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| - name: Run tests | ||||||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||||||
| if [ -d tests ]; then | ||||||||||||||||||||||||||||||||||
| python -m pytest tests/ || echo "Tests not yet implemented" | ||||||||||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||||||||||
| echo "No tests directory found" | ||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||
| python -m pytest test/ -v --cov=cortex --cov-report=xml --cov-report=term-missing | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| - name: Upload coverage to Codecov | ||||||||||||||||||||||||||||||||||
| uses: codecov/codecov-action@v4 | ||||||||||||||||||||||||||||||||||
| if: matrix.python-version == '3.11' | ||||||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||||||
| file: ./coverage.xml | ||||||||||||||||||||||||||||||||||
| fail_ci_if_error: false | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| lint: | ||||||||||||||||||||||||||||||||||
| runs-on: ubuntu-latest | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| steps: | ||||||||||||||||||||||||||||||||||
| - uses: actions/checkout@v4 | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| - name: Set up Python | ||||||||||||||||||||||||||||||||||
| uses: actions/setup-python@v5 | ||||||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||||||
| python-version: '3.11' | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| - name: Install linting tools | ||||||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||||||
| python -m pip install --upgrade pip | ||||||||||||||||||||||||||||||||||
| pip install black pylint mypy | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| - name: Check formatting with black | ||||||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||||||
| black --check cortex/ || echo "::warning::Code formatting issues found. Run 'black cortex/' to fix." | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| - name: Lint with pylint | ||||||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||||||
| pylint cortex/ --exit-zero --output-format=text | tee pylint-report.txt | ||||||||||||||||||||||||||||||||||
| score=$(tail -n 2 pylint-report.txt | head -n 1 | grep -oP '\d+\.\d+') | ||||||||||||||||||||||||||||||||||
| echo "Pylint score: $score" | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| security: | ||||||||||||||||||||||||||||||||||
| runs-on: ubuntu-latest | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| steps: | ||||||||||||||||||||||||||||||||||
| - uses: actions/checkout@v4 | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| - name: Set up Python | ||||||||||||||||||||||||||||||||||
| uses: actions/setup-python@v5 | ||||||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||||||
| python-version: '3.11' | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| - name: Install security tools | ||||||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||||||
| python -m pip install --upgrade pip | ||||||||||||||||||||||||||||||||||
| pip install bandit safety | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| - name: Run Bandit security linter | ||||||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||||||
| bandit -r cortex/ -ll -ii || echo "::warning::Security issues found. Please review." | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| - name: Check dependencies with safety | ||||||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||||||
| pip install -r requirements.txt | ||||||||||||||||||||||||||||||||||
| safety check --full-report || echo "::warning::Vulnerable dependencies found." | ||||||||||||||||||||||||||||||||||
|
Comment on lines
+83
to
+90
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Security checks don't fail CI, undermining their purpose. Both - name: Run Bandit security linter
run: |
- bandit -r cortex/ -ll -ii || echo "::warning::Security issues found. Please review."
+ bandit -r cortex/ -ll -ii
- name: Check dependencies with safety
run: |
pip install -r requirements.txt
- safety check --full-report || echo "::warning::Vulnerable dependencies found."
+ safety check --full-reportIf you need to allow the workflow to complete for visibility while still marking it as failed, use 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||
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.
Lint job doesn't install project dependencies, and mypy is never run.
The lint job installs
black pylint mypybut doesn't install the project or its dependencies. This will causepylintandmypyto report false positives for missing imports. Additionally,mypyis installed but never executed.- name: Install linting tools run: | python -m pip install --upgrade pip + pip install -r requirements.txt pip install black pylint mypy - name: Check formatting with black run: | black --check cortex/ || echo "::warning::Code formatting issues found. Run 'black cortex/' to fix." - name: Lint with pylint run: | pylint cortex/ --exit-zero --output-format=text | tee pylint-report.txt score=$(tail -n 2 pylint-report.txt | head -n 1 | grep -oP '\d+\.\d+') echo "Pylint score: $score" + + - name: Type check with mypy + run: | + mypy cortex/ --ignore-missing-imports || echo "::warning::Type errors found."📝 Committable suggestion
🤖 Prompt for AI Agents