Fix CI/CD pipeline and CodeQL issues - #83
Conversation
This commit updates all GitHub Actions to their latest versions and fixes deprecated actions: CI/CD Pipeline fixes (ci.yml): - Updated actions/checkout from v3 to v4 - Updated actions/setup-python from v4 to v5 - Updated actions/setup-node from v3 to v4 - Updated actions/cache from v3 to v4 - Updated codecov/codecov-action from v3 to v4 (added required CODECOV_TOKEN) - Updated docker/setup-buildx-action from v2 to v3 - Updated docker/login-action from v2 to v3 - Updated docker/build-push-action from v4 to v5 - Updated github/codeql-action/upload-sarif from v2 to v3 CodeQL Analysis fixes (codeql-analysis.yml): - Updated github/codeql-action/init from v2 to v3 - Updated github/codeql-action/autobuild from v2 to v3 - Updated github/codeql-action/analyze from v2 to v3 Dependency Review fixes (dependency-review.yml): - Updated actions/dependency-review-action from v3 to v4 These updates ensure compatibility with latest GitHub Actions features, improve security, and resolve deprecation warnings.
This commit addresses all failing CI/CD pipeline jobs by adding the missing test infrastructure and configuration files: Frontend fixes: - Added type-check script to package.json (npm run type-check) - Created tsconfig.json for TypeScript configuration - Downgraded TypeScript from 5.2.2 to 4.9.5 for react-scripts compatibility - Generated package-lock.json for reproducible builds - Added @testing-library/react and @testing-library/jest-dom dependencies - Created App.test.tsx with basic render test - Created setupTests.ts for jest-dom configuration Backend fixes: - Created tests directory with __init__.py - Added conftest.py with pytest fixtures for test configuration - Created test_health.py with placeholder tests - Added pytest.ini for pytest configuration - Added .coveragerc for test coverage configuration These changes ensure that: 1. frontend-tests job can run npm ci (needs package-lock.json) 2. frontend-tests job can run npm run type-check (needs script + tsconfig) 3. frontend-tests job can run npm test (needs test files) 4. backend-tests job can run pytest (needs test directory and files) 5. CodeQL analysis can complete successfully 6. Security scans can execute properly All tests are currently placeholders and should be replaced with actual functional tests as the application develops.
| """ | ||
| import pytest | ||
| from typing import Generator | ||
| from fastapi.testclient import TestClient |
Check notice
Code scanning / CodeQL
Unused import Note test
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 9 months ago
To fix this problem, simply delete the unused import statement. Specifically, remove the line from fastapi.testclient import TestClient (line 6) from backend/tests/conftest.py. Do not modify any other code or imports, since no active usage of TestClient is present. This change will resolve the warning without altering any functionality.
| @@ -3,7 +3,6 @@ | ||
| """ | ||
| import pytest | ||
| from typing import Generator | ||
| from fastapi.testclient import TestClient | ||
|
|
||
| # Import your main app when available | ||
| # from api.main import app |
| # with TestClient(app) as test_client: | ||
| # yield test_client |
Check notice
Code scanning / CodeQL
Commented-out code Note test
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 9 months ago
The best way to fix this issue is to remove the commented-out code in the client fixture (lines 27-29). Since the actual code depends on the availability of app (which is currently commented out at line 9), and yield None acts as a placeholder, simply remove the lines containing commented-out code. If you wish to provide instructions, you may leave a descriptive comment indicating that the actual implementation should yield a TestClient(app) when available. Only remove the lines that contain commented-out code (lines 28 and 29), leaving the adjacent guidance comment and placeholder functional implementation intact.
| @@ -25,6 +25,4 @@ | ||
| Create a test client | ||
| """ | ||
| # Uncomment when app is available | ||
| # with TestClient(app) as test_client: | ||
| # yield test_client | ||
| yield None |
| """ | ||
| Health check tests | ||
| """ | ||
| import pytest |
Check notice
Code scanning / CodeQL
Unused import Note test
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 9 months ago
To fix this problem, simply remove the import pytest statement from line 4 in the file backend/tests/test_health.py. This will clean up the file and remove the unnecessary dependency. No other lines or regions of the file need to be changed, as no code relies on pytest being imported directly. No additional imports, methods, or definitions are required for this fix.
| @@ -1,7 +1,6 @@ | ||
| """ | ||
| Health check tests | ||
| """ | ||
| import pytest | ||
|
|
||
|
|
||
| def test_placeholder(): |
| # def test_health_endpoint(client): | ||
| # """ | ||
| # Test health check endpoint | ||
| # """ | ||
| # response = client.get("/health") | ||
| # assert response.status_code == 200 |
Check notice
Code scanning / CodeQL
Commented-out code Note test
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 9 months ago
To fix the problem, we should remove the commented-out code block spanning lines 23 to 28 in backend/tests/test_health.py. The relevant TODO (line 22) provides sufficient instruction to add API tests in the future, so there's no need for a commented-out function stub. Removing these lines improves code clarity and eliminates distractions for future maintainers.
No change to existing functionality will occur, and no imports, methods, or extra definitions are required, since the operation is strictly about removing dead/commented code.
| @@ -20,9 +20,3 @@ | ||
|
|
||
|
|
||
| # TODO: Add actual API tests | ||
| # def test_health_endpoint(client): | ||
| # """ | ||
| # Test health check endpoint | ||
| # """ | ||
| # response = client.get("/health") | ||
| # assert response.status_code == 200 |
There was a problem hiding this comment.
This PR is being reviewed by Cursor Bugbot
Details
You are on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle.
To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.
| def __repr__ | ||
| raise AssertionError | ||
| raise NotImplementedError | ||
| if __name__ == .__main__.: |
There was a problem hiding this comment.
Bug: Incorrect __main__ pattern breaks coverage.
The exclude_lines pattern uses dots instead of quotes around __main__, making it .__main__. instead of "__main__". This won't match the actual Python idiom if __name__ == "__main__": and will fail to exclude these lines from coverage reports as intended.
This commit updates all GitHub Actions to their latest versions and fixes deprecated actions:
CI/CD Pipeline fixes (ci.yml):
CodeQL Analysis fixes (codeql-analysis.yml):
Dependency Review fixes (dependency-review.yml):
These updates ensure compatibility with latest GitHub Actions features, improve security, and resolve deprecation warnings.
Description
Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context.
Fixes # (issue)
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration.
Test Environment:
Checklist:
Screenshots (if applicable)
Add screenshots to help explain your changes.
Additional Notes
Add any other context about the pull request here.
Breaking Changes
If this PR introduces breaking changes, please describe them and provide migration instructions.
Performance Impact
If this PR has performance implications, please describe them.
Security Considerations
If this PR has security implications, please describe them.
Note
Adds frontend testing setup with React Testing Library, introduces a basic App render test, adds tsconfig with strict settings, and pins TypeScript to 4.9.5 with a type-check script.
src/App.test.tsxusing React Testing Library andsrc/setupTests.tswith@testing-library/jest-dom.tsconfig.jsonwith strict settings andbaseUrlset tosrc.typescriptto^4.9.5, addtype-checkscript, and include testing libs indevDependencies.Written by Cursor Bugbot for commit 94c27f8. This will update automatically on new commits. Configure here.