This project uses GitHub Actions for automated testing and daily simulations.
Trigger: On every push and pull request to main or develop branches
What it does:
- Runs full test suite across Python 3.10, 3.11, and 3.12
- Generates code coverage reports
- Runs linting checks (flake8, black, isort)
- Uploads test artifacts
Status Badge:
Steps:
- Checkout code
- Set up Python (matrix: 3.10, 3.11, 3.12)
- Cache pip dependencies
- Install dependencies
- Run pytest with coverage
- Upload coverage report (artifacts)
- Run linting checks
Expected Duration: ~2-3 minutes
Trigger:
- Scheduled: Every day at 2:00 AM UTC (9:00 PM EST)
- Manual: Via workflow dispatch
What it does:
- Runs conservative strategy simulation with live market data
- Saves results to persistent database (via cache)
- Generates summary report
- Uploads artifacts for 90-day retention
- Alerts on significant losses (>2%)
Status Badge:
Steps:
- Checkout code
- Set up Python 3.11
- Cache dependencies
- Restore previous database from cache
- Run simulation (
scripts/daily_simulation.py) - Save updated database to cache
- Generate summary report
- Upload artifacts
- Check for significant losses
Expected Duration: ~3-5 minutes
Data Persistence:
- Database is stored using GitHub Actions cache
- Cache key:
simulation-db-{run_number} - Artifacts retained for 90 days
You can manually trigger the daily simulation workflow:
- Go to Actions tab in GitHub
- Select Daily Simulation workflow
- Click Run workflow
- Choose branch (default: main)
- Click Run workflow
- Go to Actions tab
- Click on any Tests workflow run
- View test summary in the workflow summary
- Download coverage report from artifacts
- Go to Actions tab
- Click on any Daily Simulation workflow run
- View summary in the workflow summary
- Download
simulation-results-{run_number}artifact for full data
Artifact Contents:
simulations.db- SQLite database with all historical runssimulation_summary.txt- Text summary of recent runs
No secrets are currently required for basic operation. Optional secrets for future enhancements:
SLACK_WEBHOOK- For Slack notificationsEMAIL_ADDRESS- For email alertsDATABASE_URL- For external database (PostgreSQL, etc.)
Ensure GitHub Actions is enabled:
- Go to Settings > Actions > General
- Set Actions permissions to "Allow all actions"
- Enable Read and write permissions for workflows
- ✅ Workflow runs successfully → No notification
⚠️ Small loss (<2%) → Warning in logs, workflow succeeds- 🚨 Significant loss (>2%) → Workflow fails, triggers notify job
To add Slack notifications on failure:
- Add Slack webhook URL as secret:
SLACK_WEBHOOK - Update
daily_simulation.ymlnotify job:
- name: Send Slack notification
uses: slackapi/slack-github-action@v1
with:
webhook: ${{ secrets.SLACK_WEBHOOK }}
payload: |
{
"text": "⚠️ Yield Guard Bot: Daily simulation failed",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*Daily Simulation Alert*\nSimulation failed or detected significant losses.\n<${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|View Workflow>"
}
}
]
}- Test Success Rate: Should be 100%
- Simulation Success Rate: Track over time
- Average Return: Monitor daily returns
- Max Drawdown: Ensure stays under 10%
- Protocol Availability: Check for "No data" errors
- Test failures on main branch
- Simulation failures (API issues, errors)
- Significant losses (>2% daily)
- Unusual patterns (3+ days of losses)
GitHub Actions is free for public repositories with generous limits:
- 2,000 minutes/month for private repos (free tier)
- Unlimited for public repos
Estimated Usage:
- Tests: ~3 min/run × ~10 runs/day = ~30 min/day = ~900 min/month
- Daily simulation: ~5 min/day = ~150 min/month
- Total: ~1,050 min/month (within free tier for public repos)
- Check Python version compatibility
- Verify all dependencies in requirements.txt
- Review test logs in workflow run
- Run tests locally:
pytest tests/ -v
"No market data available":
- Check DefiLlama API status
- Verify protocol names are correct
- Check network connectivity
Database errors:
- Check cache restore/save steps
- Verify data directory exists
- Check disk space (unlikely in GitHub Actions)
Import errors:
- Verify all dependencies installed
- Check requirements.txt is up to date
If database cache gets corrupted:
- Go to Actions > Caches
- Delete
simulation-db-*caches - Re-run workflow (will start fresh)
-
Run tests locally:
pytest tests/ -v
-
Check linting:
flake8 src/ black --check src/ tests/ isort --check src/ tests/
-
Fix issues:
black src/ tests/ isort src/ tests/
Set up branch protection for main:
- Go to Settings > Branches
- Add rule for
main - Enable:
- ✅ Require pull request before merging
- ✅ Require status checks to pass (Tests workflow)
- ✅ Require branches to be up to date
Potential workflow improvements:
- Deploy to production after tests pass
- Create release on version tag
- Build and publish Docker image
- Run security scans (Dependabot, CodeQL)
- Performance benchmarks
- Integration tests with test network
- Multi-strategy comparison
- Weekly/monthly reports
- Automatic issue creation on failures