Instruction file imported from ivana-meshed/mmm-app (
.github/instructions/dev.instructions.md). Copyright stays with the author.
GitHub Copilot Instructions for Development Environment
This file contains development environment-specific instructions for the MMM Trainer application. These instructions supplement the general repository instructions in .github/copilot-instructions.md.
Development Environment Overview
The dev environment is used for testing and validating changes before they reach production. It deploys to a separate Cloud Run service with its own configuration and resources.
Key Differences from Production
- Service Name:
mmm-app-dev(vs.mmm-appin production) - CI/CD Workflow:
.github/workflows/ci-dev.yml(vs.ci.yml) - Terraform Config:
infra/terraform/envs/dev.tfvars(vs.prod.tfvars) - Branch Triggers:
feat-*,copilot/*,devbranches (vs.mainonly) - Queue Name:
default-dev(vs.default) - Scheduler Job:
robyn-queue-tick-dev(vs.robyn-queue-tick)
Development Branch Workflow
Branch Naming Conventions
- Feature branches:
feat-*(e.g.,feat-new-visualization) - Copilot branches:
copilot/*(e.g.,copilot/fix-data-validation) - Dev branch:
dev(integration branch for testing multiple features)
CI/CD Behavior
When you push to any dev branch (feat-*, copilot/*, or dev):
- The
ci-dev.ymlworkflow triggers automatically - Images are built with the commit SHA as the tag
- Deployment targets the
mmm-app-devCloud Run service - Changes are isolated from production
Testing Changes in Dev
Before merging to main:
- Push your feature branch to trigger dev deployment
- Test thoroughly in the dev environment
- Verify Cloud Run logs for any issues
- Check that data flows correctly from Snowflake to GCS
- Ensure R/Robyn training jobs complete successfully
Development-Specific Configuration
Terraform Variables (dev.tfvars)
When modifying infrastructure for dev:
- Edit
infra/terraform/envs/dev.tfvars(NOTprod.tfvars) - Service name must remain
mmm-app-dev - Queue and scheduler names must use
-devsuffix - Test Terraform changes in dev before applying to prod
Environment Variables
Dev-specific environment variables in ci-dev.yml:
SERVICE_NAME: mmm-app-dev
TF_VAR_scheduler_job_name: robyn-queue-tick-dev
TF_VAR_queue_name: default-dev
Always verify these match dev.tfvars configuration.
Cloud Resources
Dev environment resources:
- Cloud Run Service:
mmm-app-dev(ineurope-west1) - GCS Bucket:
mmm-app-output(shared with prod, use prefixes) - Artifact Registry:
mmm-repo(shared, tagged with commit SHA) - Service Accounts: Same as prod (proper IAM separation by service)
Development Best Practices
Local Development
For rapid iteration without deploying:
- Use
streamlit run app/streamlit_app.pylocally - Configure GCP credentials:
gcloud auth application-default login - Set environment variables for local testing:
export PROJECT_ID=datawarehouse-422511 export GCS_BUCKET=mmm-app-output export TRAINING_JOB_NAME=mmm-app-training - Test changes locally before pushing to trigger CI/CD
Docker Testing
Test container builds locally before pushing:
# Build web service
docker build -f docker/Dockerfile.web -t mmm-web-local .
# Build training image
docker build -f docker/Dockerfile.training -t mmm-training-local .
# Run locally
docker run -p 8080:8080 \
-e PORT=8080 \
-e PROJECT_ID=datawarehouse-422511 \
mmm-web-local
Code Quality for Dev Branches
Even in dev branches, maintain code quality:
- Run
make formatbefore committing - Run
make checkto verify linting and type checking - Run
make testto ensure tests pass - Follow the same Python standards (Black, isort, line length 80)
Debugging in Dev
When debugging issues in the dev environment:
- Check Cloud Run logs for the
mmm-app-devservice - Use
gcloud logging readto filter dev service logs:gcloud logging read "resource.labels.service_name=mmm-app-dev" --limit 50 - Verify GCS bucket contents for training artifacts
- Check Snowflake connection and query execution
- Review R script logs in Cloud Logging
Terraform Development Workflow
When making infrastructure changes:
- Edit
infra/terraform/envs/dev.tfvars - Test locally with Terraform:
cd infra/terraform terraform init terraform plan -var-file=envs/dev.tfvars - Push to a
feat-*branch to trigger CI/CD - Review the Terraform plan step in GitHub Actions
- Verify deployment in dev before creating PR to main
Concurrency and Deployment Safety
Dev deployment uses concurrency control:
concurrency:
group: terraform-dev
cancel-in-progress: false
This means:
- Only one dev deployment runs at a time
- New pushes wait for current deployment to finish
- Prevents race conditions in Terraform state
Common Dev Environment Tasks
Adding New Features
- Create a feature branch:
git checkout -b feat-your-feature - Make changes following code standards
- Test locally with Streamlit
- Push to trigger dev deployment:
git push origin feat-your-feature - Monitor CI/CD workflow in GitHub Actions
- Test deployed feature in
mmm-app-devCloud Run service - Iterate as needed
- Create PR to
mainwhen ready
Fixing Bugs
- Create a branch:
git checkout -b feat-fix-bug-nameor use Copilot branch - Reproduce bug locally if possible
- Implement fix with minimal changes
- Add or update tests to prevent regression
- Deploy to dev and verify fix
- Create PR with clear description of bug and fix
Updating Dependencies
When updating Python packages in dev:
- Update
requirements.txtwith new versions - Check compatibility with existing packages
- Test locally:
pip install -r requirements.txt - Test Docker build locally
- Push to dev branch to trigger full CI/CD
- Monitor for any breaking changes in dev deployment
Infrastructure Changes
For changes to Cloud Run, IAM, or other infrastructure:
- Always test in dev first using
dev.tfvars - Review Terraform plan carefully in CI/CD logs
- Verify changes in GCP Console after deployment
- Document changes in PR description
- Get review approval before merging to main
Security Considerations for Dev
- Dev uses the same service accounts as prod (proper IAM scope)
- Never commit secrets to feature branches
- Use Secret Manager for all sensitive data
- Dev environment is not a "free pass" for security issues
- Follow same security best practices as production
Performance Testing
Dev environment is suitable for:
- Functional testing of new features
- Integration testing with Snowflake and GCS
- R/Robyn training job validation
- UI/UX testing with Streamlit
Dev environment is NOT suitable for:
- Load testing (use dedicated load testing infrastructure)
- Large-scale data processing benchmarks
- Production data volumes (use test datasets)
Monitoring and Observability
Monitor dev deployments:
- Cloud Run Metrics: Check request latency, error rates
- Cloud Logging: Filter by
mmm-app-devservice name - GitHub Actions: Monitor CI/CD workflow status
- GCS: Verify training artifacts are created correctly
Good Tasks for Dev Environment
Copilot works well for dev tasks like:
- Implementing new Streamlit UI features
- Adding data validation logic
- Improving error handling
- Writing unit and integration tests
- Refactoring code for better structure
- Updating documentation
- Adding logging and debugging aids
- Performance optimizations
Tasks Requiring Human Review in Dev
Even in dev, be cautious with:
- Terraform infrastructure changes
- IAM role modifications
- Service account permissions
- Database schema changes (Snowflake)
- Major architectural changes
- Workflow modifications (ci-dev.yml)
Verification Checklist for Dev PRs
Before creating a PR from a dev branch to main:
- ✅ All tests pass locally (
make test) - ✅ Code is formatted (
make format) - ✅ Linting passes (
make check) - ✅ Dev deployment successful in CI/CD
- ✅ Feature tested in
mmm-app-devCloud Run service - ✅ No secrets committed
- ✅ Documentation updated if needed
- ✅ Clean commit history (squash if needed)
- ✅ PR description explains changes clearly
Getting Help with Dev Issues
When stuck in dev environment:
- Check
.github/workflows/ci-dev.ymlfor workflow details - Review
infra/terraform/envs/dev.tfvarsfor configuration - Compare with prod configuration to identify differences
- Check Cloud Run logs for runtime errors
- Review Terraform state for infrastructure issues
- Ask for help with infrastructure or deployment problems
Resources
- General repository instructions:
.github/copilot-instructions.md - Development setup guide:
DEVELOPMENT.md - Architecture documentation:
ARCHITECTURE.md - CI/CD workflow:
.github/workflows/ci-dev.yml - Dev Terraform config:
infra/terraform/envs/dev.tfvars