refactor: Wire up ResilientSession for all API calls #46
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Validate R Equivalence | |
| on: | |
| push: | |
| branches: [ main, develop ] | |
| pull_request: | |
| branches: [ main ] | |
| schedule: | |
| # Run weekly on Mondays at 9 AM UTC | |
| - cron: '0 9 * * 1' | |
| jobs: | |
| validate: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.9' | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -e . | |
| pip install pandas numpy requests | |
| - name: Run comprehensive example validator | |
| env: | |
| CANCENSUS_API_KEY: ${{ secrets.CANCENSUS_API_KEY }} | |
| run: | | |
| python3 comprehensive_example_validator.py > validation_output.txt 2>&1 | |
| cat validation_output.txt | |
| - name: Check validation results | |
| run: | | |
| # Extract pass/fail/skip counts from output | |
| PASSED=$(grep "✅ PASSED:" validation_output.txt | awk '{print $3}') | |
| FAILED=$(grep "❌ FAILED:" validation_output.txt | awk '{print $3}') | |
| SKIPPED=$(grep "⏭️ SKIPPED:" validation_output.txt | awk '{print $3}') | |
| TOTAL=$(grep "📝 TOTAL:" validation_output.txt | awk '{print $3}') | |
| echo "Validation Results:" | |
| echo " Passed: $PASSED" | |
| echo " Failed: $FAILED" | |
| echo " Skipped: $SKIPPED" | |
| echo " Total: $TOTAL" | |
| # Fail if there are any actual failures | |
| if [ "$FAILED" -gt 0 ]; then | |
| echo "❌ $FAILED test(s) failed!" | |
| exit 1 | |
| fi | |
| # If all tests passed or were skipped (no failures), success | |
| if [ "$PASSED" -gt 0 ]; then | |
| echo "✅ All $PASSED executed tests passed ($SKIPPED skipped)" | |
| else | |
| echo "⚠️ All tests skipped (R not available) - no failures" | |
| fi | |
| - name: Upload validation report | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: validation-report | |
| path: validation_output.txt | |
| retention-days: 30 | |
| - name: Comment PR with results | |
| if: github.event_name == 'pull_request' | |
| uses: actions/github-script@v6 | |
| with: | |
| script: | | |
| const fs = require('fs'); | |
| const output = fs.readFileSync('validation_output.txt', 'utf8'); | |
| // Extract summary | |
| const summaryMatch = output.match(/VALIDATION SUMMARY[\s\S]*?={70}/); | |
| const summary = summaryMatch ? summaryMatch[0] : 'Summary not found'; | |
| const comment = `## 🧪 R Equivalence Validation Results | |
| \`\`\` | |
| ${summary} | |
| \`\`\` | |
| See full validation report in artifacts.`; | |
| github.rest.issues.createComment({ | |
| issue_number: context.issue.number, | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| body: comment | |
| }); |