fix: correct x-project-id header handling and change mutate methods #1
Workflow file for this run
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: coverage-report | |
| on: | |
| pull_request: | |
| branches: | |
| - main | |
| jobs: | |
| coverage: | |
| name: Coverage Report | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install Rye | |
| run: | | |
| curl -sSf https://rye.astral.sh/get | bash | |
| echo "$HOME/.rye/shims" >> $GITHUB_PATH | |
| env: | |
| RYE_VERSION: '0.44.0' | |
| RYE_INSTALL_OPTION: '--yes' | |
| - name: Install dependencies | |
| run: make install-dev | |
| - name: Run tests with coverage | |
| run: make test | |
| - name: Generate coverage report | |
| run: | | |
| echo "## π Test Coverage Report" > coverage_report.md | |
| echo "" >> coverage_report.md | |
| # Extract coverage percentage from the terminal output | |
| COVERAGE_PERCENT=$(rye run pytest tests/ --cov=evolution_openai --cov-report=term-missing | grep "TOTAL" | awk '{print $4}' | sed 's/%//') | |
| # Determine coverage status and emoji | |
| if [ "$COVERAGE_PERCENT" -ge 90 ]; then | |
| COVERAGE_EMOJI="π’" | |
| COVERAGE_STATUS="Excellent" | |
| elif [ "$COVERAGE_PERCENT" -ge 80 ]; then | |
| COVERAGE_EMOJI="π‘" | |
| COVERAGE_STATUS="Good" | |
| elif [ "$COVERAGE_PERCENT" -ge 70 ]; then | |
| COVERAGE_EMOJI="π " | |
| COVERAGE_STATUS="Fair" | |
| else | |
| COVERAGE_EMOJI="π΄" | |
| COVERAGE_STATUS="Needs Improvement" | |
| fi | |
| echo "### $COVERAGE_EMOJI Coverage Summary" >> coverage_report.md | |
| echo "" >> coverage_report.md | |
| echo "| Metric | Value | Status |" >> coverage_report.md | |
| echo "|--------|-------|--------|" >> coverage_report.md | |
| echo "| **Total Coverage** | **$COVERAGE_PERCENT%** | $COVERAGE_STATUS |" >> coverage_report.md | |
| echo "" >> coverage_report.md | |
| # Add coverage details by file | |
| echo "### π File Coverage Details" >> coverage_report.md | |
| echo "" >> coverage_report.md | |
| echo "| File | Statements | Missing | Coverage | Status |" >> coverage_report.md | |
| echo "|------|------------|---------|----------|--------|" >> coverage_report.md | |
| # Process each file's coverage | |
| rye run pytest tests/ --cov=evolution_openai --cov-report=term-missing | grep "evolution_openai" | while read line; do | |
| if [[ $line =~ evolution_openai ]]; then | |
| # Extract file information | |
| FILE_PATH=$(echo "$line" | awk '{print $1}' | sed 's|src/||') | |
| STATEMENTS=$(echo "$line" | awk '{print $2}') | |
| MISSING=$(echo "$line" | awk '{print $3}') | |
| COVERAGE_PCT=$(echo "$line" | awk '{print $4}' | sed 's/%//') | |
| # Determine file status | |
| if [ "$COVERAGE_PCT" -ge 90 ]; then | |
| FILE_STATUS="π’ Excellent" | |
| elif [ "$COVERAGE_PCT" -ge 80 ]; then | |
| FILE_STATUS="π‘ Good" | |
| elif [ "$COVERAGE_PCT" -ge 70 ]; then | |
| FILE_STATUS="π Fair" | |
| else | |
| FILE_STATUS="π΄ Poor" | |
| fi | |
| echo "| \`$FILE_PATH\` | $STATEMENTS | $MISSING | $COVERAGE_PCT% | $FILE_STATUS |" >> coverage_report.md | |
| fi | |
| done | |
| echo "" >> coverage_report.md | |
| echo "---" >> coverage_report.md | |
| echo "*This report was generated automatically by the CI system.*" >> coverage_report.md | |
| - name: Comment PR with coverage report | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const fs = require('fs'); | |
| const report = fs.readFileSync('coverage_report.md', 'utf8'); | |
| // Check if there's already a coverage comment | |
| const { data: comments } = await github.rest.issues.listComments({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.issue.number, | |
| }); | |
| const coverageComment = comments.find(comment => | |
| comment.user.type === 'Bot' && | |
| comment.body.includes('## π Test Coverage Report') | |
| ); | |
| if (coverageComment) { | |
| // Update existing comment | |
| await github.rest.issues.updateComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| comment_id: coverageComment.id, | |
| body: report | |
| }); | |
| } else { | |
| // Create new comment | |
| await github.rest.issues.createComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.issue.number, | |
| body: report | |
| }); | |
| } |