Spaces:
Sleeping
Download WORKFLOW_GUIDE.md from neurostack-in/talk2map-test: direct link, hf CLI and curl.
- Browser
- Download file 13 kB
-
https://huggingface.co/spaces/neurostack-in/talk2map-test/resolve/main/WORKFLOW_GUIDE.md
- Command line
-
hf download hf://spaces/neurostack-in/talk2map-test/WORKFLOW_GUIDE.md
-
curl -L -o WORKFLOW_GUIDE.md https://huggingface.co/spaces/neurostack-in/talk2map-test/resolve/main/WORKFLOW_GUIDE.md
Talk2Map CI/CD Workflow Guide
This document explains the complete CI/CD workflow for the Talk2Map FastAPI project, including feature development, testing, and deployment processes.
π Workflow Overview
The workflow implements a fully manual-controlled feature β staging β main β production pipeline where:
- π₯ Developer manually triggers all actions - No automatic testing on feature branches
- π§ͺ Tests run only when developer initiates - Complete manual control
- π Manual promotion at every stage - Developers decide when to advance
Key principle: Developers have complete control over when testing and merging happens.
graph TD
A[Developer creates feature/name branch] --> B[Push code to feature branch]
B --> C[π₯ Developer manually triggers feature testing]
C --> D[Manual Feature Testing workflow]
D --> E[Run tests on feature branch]
E --> F{Tests pass?}
F -->|No| G[β Fix tests and retry]
F -->|Yes| H[Check conflicts with staging]
H --> I{Conflicts detected?}
I -->|Yes| J[β Resolve conflicts and retry]
I -->|No| K[β
Merge to staging]
K --> L[Staging CI triggers automatically]
L --> M[Run tests on staging]
M --> N{Tests pass?}
N -->|No| O[β Create failure issue]
N -->|Yes| P[β
Deploy to HF Test Space]
P --> Q[API Testing workflow triggers]
Q --> R[π₯ Developer manually promotes to main]
R --> S[Manual Promotion workflow]
S --> T[Run tests on staging again]
T --> U{Tests pass?}
U -->|No| V[β Block promotion]
U -->|Yes| W[β
Merge to main]
W --> X[Deploy to Production triggers]
X --> Y[Run final tests on main]
Y --> Z{Tests pass?}
Z -->|No| AA[β Block deployment]
Z -->|Yes| BB[π Deploy to HF Production]
π« STRICT BLOCKING POLICY
The workflow implements a zero-tolerance policy for failures:
β What Blocks Merges:
- Test Failures - Any failing test in
pytest -v - Merge Conflicts - Any conflicts detected between branches
- Workflow Errors - Any step failure in the CI pipeline
π¨ What Happens When Blocked:
- NO MERGE OCCURS - The workflow stops immediately
- GitHub Issue Created - Detailed alert with:
- Exact failure reason
- Step-by-step resolution instructions
- Links to relevant logs and resources
- Labels Applied -
merge-blocked,urgentfor easy filtering - Developer Notification - Issue assignment and team alerts
β Merge Only Happens When:
- β
ALL tests pass (
pytest -vreturns 0) - β NO conflicts detected (clean merge possible)
- β Workflow completes successfully (all steps green)
Remember: Better to block a merge than break the pipeline!
π Workflow Components
1. Manual Feature Testing and Staging Merge (manual-feature-merge.yml)
Triggers: Manual workflow dispatch only Purpose: Test feature branch and merge to staging when developer is ready
Manual Process:
Developer triggers workflow with feature branch name
Run tests on specified feature branch using
pytest -vCheck for merge conflicts with staging branch
ONLY if BOTH conditions are met:
- β All feature tests pass
- β No merge conflicts detected
THEN: Merge feature to staging
If ANY condition fails:
- β NO MERGE OCCURS
- π¨ GitHub issue created with detailed failure information
- π« Developer must fix issues and retry
Key Features:
- β Complete manual control - No automatic testing on feature branches
- β Pre-merge conflict detection
- β Test validation before merge
- β Detailed success/failure notifications
2. Staging Branch CI (staging-ci.yml)
Triggers: Push to staging branch (after manual merge)
Purpose: Test and deploy staging after developer merges
Process:
- Tests run AFTER merge to staging
- If tests pass:
- Deploy to HuggingFace test space
- Create success notification
- Mark as "ready for promotion"
- If tests fail:
- Create failure alert
- Block further progression
Key Features:
- β Post-merge testing - tests run after code is in staging
- β Automatic test space deployment
- β Clear success/failure notifications
- β Ready-for-promotion status
3. API Endpoint Testing (api-testing.yml)
Triggers: After successful Staging Branch CI Purpose: Test deployed API endpoints on HuggingFace
Process:
- Wait for HuggingFace deployment (configurable wait time)
- Validate Postman collection
- Run Newman tests against deployed API
- Generate HTML test reports
- Create success/failure notifications
Environments:
- Test:
https://neurostack-in-talk2map-test.hf.space - Production:
https://neurostack-in-talk2map-prod.hf.space
Manual Trigger Options:
- Custom base URL
- Environment selection (test/production)
- Custom wait time
4. Manual Staging to Main Promotion (promote.yml)
Triggers: Manual workflow dispatch only Purpose: Manually promote staging to main when developer is ready
Manual Process:
Developer triggers the workflow manually
Run tests on staging branch again
Check for merge conflicts with main branch
ONLY if BOTH conditions are met:
- β All staging tests pass
- β No merge conflicts with main
THEN: Merge staging to main and trigger production deployment
If ANY condition fails:
- β NO PROMOTION OCCURS
- π¨ Detailed GitHub issue created with resolution steps
- π« Production deployment blocked
Manual Control:
- β Developer decides when to promote - No automatic promotion
- β Final validation before production
- β Conflict detection and blocking
- β Clear success/failure feedback
5. Production Deployment (sync-to-hf.yml)
Triggers: After successful staging to main promotion Purpose: Deploy main branch to production ONLY with final validation
Strict Blocking Process:
Run final tests on main branch
ONLY if tests pass:
- β Deploy to HuggingFace production space
- β Create deployment success notification
If tests fail:
- β NO DEPLOYMENT OCCURS
- π¨ Production deployment blocked
- π« Create urgent alert for manual intervention
Production Safety:
- β Final gate: Last chance to catch issues before production
- β Zero-downtime protection: No broken code reaches production
- β Emergency procedures documented for failures
- β Deployment success/failure notifications
Production URL: https://neurostack-in-talk2map-prod.hf.space
6. Manual Promotion (manual-promote.yml)
Purpose: Emergency manual promotion from staging to main (alternative method)
Use Cases:
- Resolve complex merge conflicts manually
- Emergency deployments
- Override automatic promotion when needed
π Developer Workflow
Step 1: Create Feature Branch
# Create and switch to feature branch
git checkout -b feature/your-feature-name
# Make your changes
# ... code changes ...
# Commit and push
git add .
git commit -m "Add your feature"
git push origin feature/your-feature-name
Step 2: Manual Feature Testing and Staging Merge
# When ready to test and merge your feature:
# Go to GitHub Actions β Manual Feature Testing and Staging Merge β Run workflow
# Provide:
# - Feature branch name: feature/your-feature-name
# - Reason: "Feature ready for staging"
What happens:
- Manual Feature Testing workflow runs
- Tests execute on your feature branch
- If successful and no conflicts, merges to staging
- No automatic testing - only when you trigger it
Step 3: Staging Validation (Automatic)
- Staging CI runs automatically after merge
- Tests execute on the staging branch
- If successful, deploys to HuggingFace test space
- API Testing runs against the test deployment
Step 4: Manual Promotion to Production
# When ready to go to production:
# Go to Actions β Manual Staging to Main Promotion β Run workflow
# Provide reason for promotion
What happens:
- Manual Promotion workflow runs
- Tests run on staging again
- If successful and no conflicts, promotes to main
- Production deployment triggers automatically
Step 5: Production Deployment (Automatic)
- Production deployment runs after main is updated
- Final tests run on main branch
- Main branch deployed to HuggingFace production
- Production API is live
π§ Configuration
Environment Variables Required
GROQ_API_KEY: For running testsHF_TOKEN: HuggingFace deployment tokenGITHUB_TOKEN: Automatically provided by GitHub
HuggingFace Spaces
- Test Space:
neurostack-in/talk2map-test - Production Space:
neurostack-in/talk2map-prod
Test Configuration
Tests are located in the tests/ directory:
tests/unit/- Unit teststests/integration/- Integration teststests/e2e/- End-to-end tests
Run tests locally: pytest -v
π¨ Error Handling & Alerts
The workflow creates GitHub Issues for various failure scenarios:
Merge Conflicts
- Title: "π¨ Merge Conflict Alert: Feature branch X cannot merge to staging"
- Content: Detailed conflict information and resolution steps
- Labels:
merge-conflict,urgent
Test Failures
- Title: "β Feature Branch CI Failed: branch-name"
- Content: Workflow run links and troubleshooting steps
- Labels:
ci-failure,urgent
API Test Failures
- Title: "β API Tests Failed - Environment"
- Content: Test results and debugging information
- Labels:
api-test-failure,environment,urgent
Deployment Issues
- Title: "β Production Deployment Failed"
- Content: Deployment logs and recovery steps
- Labels:
deployment-failure,production,urgent
π― Best Practices
Branch Naming
- Use
feature/prefix for all feature branches - Example:
feature/add-user-authentication - Example:
feature/fix-map-rendering
Commit Messages
- Use clear, descriptive commit messages
- Reference issues when applicable
- Follow conventional commit format when possible
Testing
- Run tests locally before pushing:
pytest -v - Ensure all tests pass before creating pull requests
- Add tests for new features and bug fixes
Conflict Resolution
- Pull latest staging changes before starting new features
- Resolve conflicts promptly when alerts are created
- Test thoroughly after resolving conflicts
π Monitoring & Debugging
Workflow Status
- Check GitHub Actions tab for workflow status
- Review workflow logs for detailed information
- Monitor GitHub Issues for automated alerts
API Testing
- Download HTML test reports from workflow artifacts
- Use manual API testing workflow for debugging
- Test both environments (test/production) as needed
HuggingFace Deployments
- Check HuggingFace Space logs for deployment issues
- Verify API accessibility after deployments
- Monitor space status and performance
π Troubleshooting
Common Issues
1. Merge Conflicts
Solution: Follow the commands in the automated GitHub issue
git checkout feature/your-branch
git fetch origin
git merge origin/staging
# Resolve conflicts manually
git add .
git commit -m "Resolve merge conflicts with staging"
git push origin feature/your-branch
2. Test Failures
Solution: Check workflow logs and fix failing tests
# Run tests locally
pytest -v
# Fix failing tests
# Commit and push fixes
git add .
git commit -m "Fix failing tests"
git push origin feature/your-branch
3. API Tests Failing
Solution: Check API accessibility and configuration
- Verify GROQ_API_KEY is valid
- Check HuggingFace deployment status
- Review API logs and error messages
4. Deployment Failures
Solution: Check HuggingFace token and space configuration
- Verify HF_TOKEN secret is valid
- Check space permissions and settings
- Review deployment logs
Manual Overrides
Manual Promotion
Use the manual promotion workflow when automatic promotion fails:
- Go to Actions β Manual Promotion (Staging to Main)
- Click "Run workflow"
- Provide reason for manual promotion
- Monitor the workflow execution
Manual API Testing
Test specific environments manually:
- Go to Actions β API Endpoint Testing
- Click "Run workflow"
- Select environment (test/production)
- Optionally customize URL and wait time
- Review test results and reports
π Workflow Metrics
The workflows provide comprehensive reporting:
- β Success/failure notifications
- π Test coverage reports
- π Deployment timing information
- π Detailed error logs and debugging info
- π Direct links to relevant resources
All notifications are created as GitHub Issues with appropriate labels for easy filtering and management.