Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 96 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ on:
push:
branches: ["**"]

permissions:
contents: write
pull-requests: write

jobs:
tests:
runs-on: ubuntu-latest
Expand All @@ -24,5 +28,95 @@ jobs:
- name: Install project (editable)
run: uv pip install -e .

- name: Run pytest
run: uv run pytest -v tests/
- name: Run tests with coverage
run: uv run pytest -v --cov=openhands --cov-report=xml:coverage.xml --cov-report=term-missing tests/

- name: Code Coverage Summary
if: always()
uses: irongut/CodeCoverageSummary@v1.3.0
with:
filename: coverage.xml
badge: true
fail_below_min: false
format: markdown
hide_branch_rate: false
hide_complexity: true
indicators: true
output: both

- name: Add Coverage PR Comment
if: ${{ always() && github.event_name == 'pull_request' }}
continue-on-error: true
uses: marocchino/sticky-pull-request-comment@v2
with:
recreate: true
path: code-coverage-results.md

- name: Upload coverage artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: coverage-artifacts
path: |
coverage.xml
code-coverage-results.md
if-no-files-found: ignore
- name: Parse coverage percent
if: always()
id: parsecov
run: |
python - << 'PY'
import xml.etree.ElementTree as ET
import math
p = 'coverage.xml'
try:
root = ET.parse(p).getroot()
lr = root.attrib.get('line-rate')
pct = int(round(float(lr) * 100)) if lr is not None else 0
except Exception:
pct = 0
print(f"coverage_percent={pct}")
with open("coverage_percent.txt", "w") as f:
f.write(str(pct))
PY

- name: Determine badge color
if: always()
id: color
run: |
PCT=$(cat coverage_percent.txt || echo 0)
if [ "$PCT" -ge 90 ]; then COLOR=brightgreen;
elif [ "$PCT" -ge 75 ]; then COLOR=green;
elif [ "$PCT" -ge 60 ]; then COLOR=yellowgreen;
elif [ "$PCT" -ge 50 ]; then COLOR=yellow;
else COLOR=red; fi
echo "color=$COLOR" >> $GITHUB_OUTPUT
echo "pct=$PCT" >> $GITHUB_OUTPUT

- name: Ensure badges directory
if: always()
run: mkdir -p badges

- name: Generate coverage badge
if: always()
uses: emibcn/badge-action@v2.0.2
with:
label: coverage
status: "${{ steps.color.outputs.pct }}%"
color: "${{ steps.color.outputs.color }}"
path: badges/coverage.svg

- name: Upload badge artifact (PRs)
if: ${{ always() && github.event_name == 'pull_request' }}
uses: actions/upload-artifact@v4
with:
name: coverage-badge
path: badges/coverage.svg

- name: Commit coverage badge (push builds)
if: ${{ always() && github.event_name == 'push' }}
uses: EndBug/add-and-commit@v9
with:
add: "badges/coverage.svg"
message: "docs: update coverage badge [skip ci]"
default_author: github_actions
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Prototype for OpenHands V1

[![Coverage](badges/coverage.svg)](./badges/coverage.svg)

This folder contains my tasks of completely refactor [OpenHands](https://github.com/All-Hands-AI/OpenHands) project V0 into the new V1 version. There's a lot of changes, including (non-exhausive):

- Switching from poetry to uv as package manager
Expand Down
20 changes: 20 additions & 0 deletions badges/coverage.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@ dev = [
"psutil>=7.0.0",
"pyright>=1.1.404",
"pytest>=8.4.1",
"pytest-cov>=5.0.0",
"ruff>=0.12.10",
]
Loading