Skip to content

Conversation

@ankitpasayat
Copy link
Contributor

@ankitpasayat ankitpasayat commented Dec 6, 2025

Workflows:

  • Add test.yml for running backend pytest and frontend tests
  • Improve docker-publish.yml with caching and better tagging
  • Add proper OCI labels via metadata-action

DevOps:

  • Add dependabot.yml for automated dependency updates
  • Update docker-compose.yml with test service configuration
  • Improve Dockerfile with better caching layers
  • Expand .gitignore with common patterns

Description

Motivation and Context

FIX #

Screenshots

API Changes

  • This PR includes API changes

Change Type

  • Bug fix
  • New feature
  • Performance improvement
  • Refactoring
  • Documentation
  • Dependency/Build system
  • Breaking change
  • Other (specify):

Testing Performed

  • Tested locally
  • Manual/QA verification

Checklist

  • Follows project coding standards and conventions
  • Documentation updated as needed
  • Dependencies updated as needed
  • No lint/build errors or new warnings
  • All relevant tests are passing

High-level PR Summary

This PR enhances the CI/CD infrastructure by adding automated testing workflows for both backend and frontend, implementing Dependabot for dependency management across multiple ecosystems (Python, npm, Docker, GitHub Actions), improving Docker image publishing with better caching and OCI metadata labels, and expanding the .gitignore with common development patterns. The changes also include a new test service configuration in docker-compose.yml and pytest installation in the backend Dockerfile to support the new test workflows.

⏱️ Estimated Review Time: 15-30 minutes

💡 Review Order Suggestion
Order File Path
1 .github/dependabot.yml
2 .github/workflows/test.yml
3 .github/workflows/docker-publish.yml
4 docker-compose.yml
5 surfsense_backend/Dockerfile
6 .gitignore

Need help? Join our Discord

Analyze latest changes

Workflows:
- Add test.yml for running backend pytest and frontend tests
- Improve docker-publish.yml with caching and better tagging
- Add proper OCI labels via metadata-action

DevOps:
- Add dependabot.yml for automated dependency updates
- Update docker-compose.yml with test service configuration
- Improve Dockerfile with better caching layers
- Expand .gitignore with common patterns
Copilot AI review requested due to automatic review settings December 6, 2025 16:53
@vercel
Copy link

vercel bot commented Dec 6, 2025

@ankitpasayat is attempting to deploy a commit to the Rohan Verma's projects Team on Vercel.

A member of the Team first needs to authorize it.

Copy link

@recurseml recurseml bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review by RecurseML

🔍 Review performed on 601489b..94c5fdb

✨ No bugs found, your code is sparkling clean

✅ Files analyzed, no issues (6)

.github/dependabot.yml
.github/workflows/docker-publish.yml
.github/workflows/test.yml
.gitignore
docker-compose.yml
surfsense_backend/Dockerfile

@ankitpasayat ankitpasayat mentioned this pull request Dec 6, 2025
16 tasks
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces CI/CD infrastructure improvements including automated testing workflows, enhanced Docker publishing, and dependency management automation. However, the changes reference test infrastructure that doesn't yet exist in the repository, which will cause several workflow and service failures.

Key Changes:

  • Added GitHub Actions test workflow for backend (pytest) and frontend tests
  • Enhanced docker-publish.yml with proper metadata, caching, and conditional triggers
  • Added Dependabot configuration for automated dependency updates across Python, npm, Docker, and GitHub Actions
  • Expanded .gitignore with comprehensive Python, IDE, and development patterns
  • Updated Dockerfile to include test dependencies
  • Added backend-test service to docker-compose.yml

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
.github/workflows/test.yml New workflow for running automated tests on backend and frontend with path filtering and caching
.github/workflows/docker-publish.yml Enhanced with workflow_dispatch inputs, GHA caching, proper OCI metadata, and conditional build triggers
.github/dependabot.yml New configuration for automated weekly dependency updates across all package ecosystems
surfsense_backend/Dockerfile Added pytest and coverage dependencies for testing support
docker-compose.yml Removed deprecated version field, added test volumes to backend service, and new backend-test profile service
.gitignore Comprehensive additions for Python artifacts, virtual environments, IDE files, coverage reports, and temporary files

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +138 to +139
- ./surfsense_backend/tests:/app/tests
- ./surfsense_backend/pytest.ini:/app/pytest.ini
Copy link

Copilot AI Dec 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The backend-test service mounts ./surfsense_backend/tests:/app/tests and ./surfsense_backend/pytest.ini:/app/pytest.ini, but these files/directories don't exist in the repository. This will cause the test service to fail when invoked. Remove these volume mounts until the test infrastructure is actually created.

Suggested change
- ./surfsense_backend/tests:/app/tests
- ./surfsense_backend/pytest.ini:/app/pytest.ini

Copilot uses AI. Check for mistakes.
docker compose build backend
# Run tests (pytest is baked into the image)
docker compose run --rm -e TESTING=true backend pytest tests/ -v --tb=short --cov=app --cov-report=xml
Copy link

Copilot AI Dec 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test workflow attempts to run pytest tests/ but the tests/ directory doesn't exist in surfsense_backend/. This will cause the test job to fail. Either create the tests directory with actual tests, or remove/skip this step until tests are implemented.

Suggested change
docker compose run --rm -e TESTING=true backend pytest tests/ -v --tb=short --cov=app --cov-report=xml
# docker compose run --rm -e TESTING=true backend pytest tests/ -v --tb=short --cov=app --cov-report=xml
# (Tests directory does not exist yet; re-enable this line when tests are implemented)

Copilot uses AI. Check for mistakes.
Comment on lines +36 to +43
- name: Cache Docker layers
if: steps.backend-changes.outputs.backend == 'true'
uses: actions/cache@v4
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ hashFiles('surfsense_backend/Dockerfile', 'surfsense_backend/pyproject.toml') }}
restore-keys: |
${{ runner.os }}-buildx-
Copy link

Copilot AI Dec 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Docker layer cache path /tmp/.buildx-cache is configured but never used in the build process. Since docker compose build doesn't utilize this cache configuration, this cache step will have no effect. Either use docker buildx build with proper cache configuration or remove this unused cache step.

Suggested change
- name: Cache Docker layers
if: steps.backend-changes.outputs.backend == 'true'
uses: actions/cache@v4
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ hashFiles('surfsense_backend/Dockerfile', 'surfsense_backend/pyproject.toml') }}
restore-keys: |
${{ runner.os }}-buildx-

Copilot uses AI. Check for mistakes.
with:
images: ${{ env.REGISTRY }}/${{ github.repository_owner }}/surfsense_backend
tags: |
type=sha,prefix=
Copy link

Copilot AI Dec 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The type=sha,prefix= configuration creates a tag with just the SHA and no prefix (e.g., abc123). This is unconventional and may conflict with semantic version tags. Consider using type=sha,prefix=sha- to create tags like sha-abc123 for better clarity and to avoid potential conflicts.

Suggested change
type=sha,prefix=
type=sha,prefix=sha-

Copilot uses AI. Check for mistakes.
with:
images: ${{ env.REGISTRY }}/${{ github.repository_owner }}/surfsense_web
tags: |
type=sha,prefix=
Copy link

Copilot AI Dec 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The type=sha,prefix= configuration creates a tag with just the SHA and no prefix (e.g., abc123). This is unconventional and may conflict with semantic version tags. Consider using type=sha,prefix=sha- to create tags like sha-abc123 for better clarity and to avoid potential conflicts.

Suggested change
type=sha,prefix=
type=sha,prefix=sha-

Copilot uses AI. Check for mistakes.
Comment on lines +82 to +85
if: |
github.event_name == 'release' ||
(github.event_name == 'workflow_dispatch' && inputs.push_frontend) ||
github.event_name == 'push'
Copy link

Copilot AI Dec 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The frontend build job includes a push trigger but the backend build job doesn't. This creates an inconsistency - when Dockerfiles are modified via push to main, only the frontend will be built. Add github.event_name == 'push' to the backend job's condition to ensure both images are built when their Dockerfiles change.

Copilot uses AI. Check for mistakes.
with:
file: surfsense_backend/coverage.xml
flags: backend
fail_ci_if_error: false
Copy link

Copilot AI Dec 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The codecov upload step doesn't include a token parameter. While this may work for public repositories, it's a best practice to explicitly configure the CODECOV_TOKEN secret for reliability. Consider adding token: ${{ secrets.CODECOV_TOKEN }} to ensure consistent uploads.

Suggested change
fail_ci_if_error: false
fail_ci_if_error: false
token: ${{ secrets.CODECOV_TOKEN }}

Copilot uses AI. Check for mistakes.
Comment on lines +136 to +139
- name: Run tests
if: steps.frontend-changes.outputs.frontend == 'true'
working-directory: surfsense_web
run: pnpm test
Copy link

Copilot AI Dec 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The frontend tests are configured to run pnpm test, but this script is not defined in surfsense_web/package.json. This will cause the test job to fail. Either add a test script to package.json or remove/skip this test step if tests don't exist yet.

Suggested change
- name: Run tests
if: steps.frontend-changes.outputs.frontend == 'true'
working-directory: surfsense_web
run: pnpm test
# - name: Run tests
# if: steps.frontend-changes.outputs.frontend == 'true'
# working-directory: surfsense_web
# run: pnpm test

Copilot uses AI. Check for mistakes.
Comment on lines +40 to +41
uv pip install --system --no-cache-dir -e . && \
uv pip install --system --no-cache-dir pytest pytest-asyncio pytest-cov
Copy link

Copilot AI Dec 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Installing test dependencies (pytest, pytest-asyncio, pytest-cov) in the production Docker image increases the image size unnecessarily. Consider using multi-stage builds to create separate production and test images, or add these dependencies only in a development/test-specific stage to keep production images lean.

Suggested change
uv pip install --system --no-cache-dir -e . && \
uv pip install --system --no-cache-dir pytest pytest-asyncio pytest-cov
uv pip install --system --no-cache-dir -e .

Copilot uses AI. Check for mistakes.
Comment on lines +40 to +41
- ./surfsense_backend/tests:/app/tests
- ./surfsense_backend/pytest.ini:/app/pytest.ini
Copy link

Copilot AI Dec 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The backend service mounts ./surfsense_backend/tests:/app/tests and ./surfsense_backend/pytest.ini:/app/pytest.ini, but these files/directories don't exist in the repository. This will cause volume mount failures when starting the backend service. Remove these volume mounts until the test infrastructure is actually created.

Suggested change
- ./surfsense_backend/tests:/app/tests
- ./surfsense_backend/pytest.ini:/app/pytest.ini

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant