-
Notifications
You must be signed in to change notification settings - Fork 626
[MISC] Add tox-driven test rig foundation (unit + integration + e2e) #1971
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
hari-kuriakose
wants to merge
11
commits into
main
Choose a base branch
from
feat/test-rig-foundation
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
bdaeed7
[MISC] Add tox-driven test rig foundation (unit + integration + e2e)
hari-kuriakose 1495649
Commit uv.lock changes
hari-kuriakose 8bb49a5
[MISC] Address PR review: rig hardening + self-tests
hari-kuriakose c492099
[MISC] Address round-2 review: scope-aware regressions + baseline int…
hari-kuriakose 2bb118d
[MISC] Address round-3 review: reporting durability + cleanup invariants
hari-kuriakose b926307
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 4030c00
[MISC] Address round-4 review: durable artifact + edge-case test cove…
hari-kuriakose 25cf8ba
Merge branch 'main' into feat/test-rig-foundation
hari-kuriakose 3f79a19
[MISC] Strip leaked VIRTUAL_ENV from rig subprocesses
hari-kuriakose 52e2221
[MISC] Address external review (CodeRabbit/Greptile/human)
hari-kuriakose 4c89989
[MISC] Forward + probe x2text_url (Greptile P1)
hari-kuriakose File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,171 +1,27 @@ | ||
| #!/bin/bash | ||
| # Thin wrapper around `python3 -m tests.rig report combine`. | ||
| # | ||
| # Kept for backward compatibility with any external script or local workflow | ||
| # that still invokes this path. Prefer calling the rig directly. | ||
| set -euo pipefail | ||
|
|
||
| # Script to combine multiple test reports into a single markdown file | ||
| # Usage: ./combine-test-reports.sh | ||
|
|
||
| OUTPUT_FILE="combined-test-report.md" | ||
| REPORTS=() | ||
|
|
||
| # Find all test report files | ||
| for report in runner-report.md sdk1-report.md; do | ||
| if [ -f "$report" ]; then | ||
| REPORTS+=("$report") | ||
| fi | ||
| done | ||
|
|
||
| # Exit if no reports found | ||
| if [ ${#REPORTS[@]} -eq 0 ]; then | ||
| echo "No test reports found. Skipping report generation." | ||
| exit 0 | ||
| REPORTS_DIR="${REPORTS_DIR:-reports}" | ||
|
|
||
| # Stock Ubuntu CI runners only ship `python3`, not `python`. Pick whichever is | ||
| # on PATH; bail loudly if neither. | ||
| if command -v python3 >/dev/null 2>&1; then | ||
| PY=python3 | ||
| elif command -v python >/dev/null 2>&1; then | ||
| PY=python | ||
| else | ||
| echo "combine-test-reports.sh: no python interpreter on PATH" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Function to strip LaTeX formatting from pytest-md-report output | ||
| # Converts $$\textcolor{...}{\tt{VALUE}}$$ to just VALUE | ||
| strip_latex() { | ||
| local text="$1" | ||
| # Extract content between \tt{ and }} | ||
| if [[ "$text" =~ \\tt\{([^}]+)\} ]]; then | ||
| echo "${BASH_REMATCH[1]}" | ||
| else | ||
| echo "$text" | ||
| fi | ||
| } | ||
|
|
||
| # Function to extract test counts from pytest-md-report markdown table | ||
| extract_test_counts() { | ||
| local report_file=$1 | ||
| local passed=0 | ||
| local failed=0 | ||
| local total=0 | ||
|
|
||
| # Find the header row to determine column positions | ||
| local header_line=$(grep -E '^\|.*filepath' "$report_file" | head -1) | ||
|
|
||
| if [ -z "$header_line" ]; then | ||
| echo "0:0:0" | ||
| return | ||
| fi | ||
|
|
||
| # Extract column names and find positions (strip LaTeX from headers) | ||
| IFS='|' read -ra headers <<< "$header_line" | ||
| local passed_col=-1 | ||
| local failed_col=-1 | ||
| local subtotal_col=-1 | ||
|
|
||
| for i in "${!headers[@]}"; do | ||
| local col=$(strip_latex "${headers[$i]}" | tr -d ' ' | tr '[:upper:]' '[:lower:]') | ||
| case "$col" in | ||
| passed) passed_col=$i ;; | ||
| failed) failed_col=$i ;; | ||
| subtotal|sub) subtotal_col=$i ;; | ||
| esac | ||
| done | ||
|
|
||
| # Find the TOTAL row (TOTAL appears in first column, not as SUBTOTAL in header) | ||
| local total_line=$(grep -E '^\|.*\\tt\{TOTAL\}' "$report_file" | head -1) | ||
|
|
||
| if [ -z "$total_line" ]; then | ||
| echo "0:0:0" | ||
| return | ||
| fi | ||
|
|
||
| # Parse the TOTAL row values | ||
| IFS='|' read -ra values <<< "$total_line" | ||
|
|
||
| # Extract passed count (strip LaTeX and get number) | ||
| if [ "$passed_col" -ge 0 ] && [ "$passed_col" -lt "${#values[@]}" ]; then | ||
| local clean_value=$(strip_latex "${values[$passed_col]}") | ||
| passed=$(echo "$clean_value" | tr -d ' ' | grep -oE '[0-9]+' | head -1 || echo "0") | ||
| fi | ||
|
|
||
| # Extract failed count (strip LaTeX and get number) | ||
| if [ "$failed_col" -ge 0 ] && [ "$failed_col" -lt "${#values[@]}" ]; then | ||
| local clean_value=$(strip_latex "${values[$failed_col]}") | ||
| failed=$(echo "$clean_value" | tr -d ' ' | grep -oE '[0-9]+' | head -1 || echo "0") | ||
| fi | ||
|
|
||
| # Extract total from SUBTOTAL column (strip LaTeX and get number) | ||
| if [ "$subtotal_col" -ge 0 ] && [ "$subtotal_col" -lt "${#values[@]}" ]; then | ||
| local clean_value=$(strip_latex "${values[$subtotal_col]}") | ||
| total=$(echo "$clean_value" | tr -d ' ' | grep -oE '[0-9]+' | head -1 || echo "0") | ||
| fi | ||
|
|
||
| # If total is still 0, calculate from passed + failed | ||
| if [ "$total" -eq 0 ]; then | ||
| total=$((passed + failed)) | ||
| fi | ||
|
|
||
| echo "${total}:${passed}:${failed}" | ||
| } | ||
| "$PY" -m tests.rig report combine --reports-dir "$REPORTS_DIR" | ||
|
|
||
| # Initialize the combined report with collapsed summary | ||
| cat > "$OUTPUT_FILE" << 'EOF' | ||
| # Test Results | ||
|
|
||
| <details open> | ||
| <summary><b>Summary</b></summary> | ||
|
|
||
| EOF | ||
|
|
||
| # Extract and display summary for each report | ||
| for report in "${REPORTS[@]}"; do | ||
| report_name=$(basename "$report" .md) | ||
|
|
||
| # Convert report name to title case | ||
| if [ "$report_name" = "runner-report" ]; then | ||
| title="Runner Tests" | ||
| elif [ "$report_name" = "sdk1-report" ]; then | ||
| title="SDK1 Tests" | ||
| else | ||
| title="${report_name}" | ||
| fi | ||
|
|
||
| # Extract counts | ||
| counts=$(extract_test_counts "$report") | ||
| IFS=':' read -r total passed failed <<< "$counts" | ||
|
|
||
| # Determine status icon | ||
| if [ "$failed" -gt 0 ]; then | ||
| status="❌" | ||
| elif [ "$passed" -gt 0 ]; then | ||
| status="✅" | ||
| else | ||
| status="⚠️" | ||
| fi | ||
|
|
||
| echo "- ${status} **${title}**: ${passed} passed, ${failed} failed (${total} total)" >> "$OUTPUT_FILE" | ||
| done | ||
|
|
||
| cat >> "$OUTPUT_FILE" << 'EOF' | ||
|
|
||
| </details> | ||
|
|
||
| --- | ||
|
|
||
| EOF | ||
|
|
||
| # Combine all reports with collapsible sections | ||
| for report in "${REPORTS[@]}"; do | ||
| report_name=$(basename "$report" .md) | ||
|
|
||
| # Convert report name to title case | ||
| if [ "$report_name" = "runner-report" ]; then | ||
| title="Runner Tests" | ||
| elif [ "$report_name" = "sdk1-report" ]; then | ||
| title="SDK1 Tests" | ||
| else | ||
| title="${report_name}" | ||
| fi | ||
|
|
||
| echo "<details>" >> "$OUTPUT_FILE" | ||
| echo "<summary><b>${title} - Full Report</b></summary>" >> "$OUTPUT_FILE" | ||
| echo "" >> "$OUTPUT_FILE" | ||
| cat "$report" >> "$OUTPUT_FILE" | ||
| echo "" >> "$OUTPUT_FILE" | ||
| echo "</details>" >> "$OUTPUT_FILE" | ||
| echo "" >> "$OUTPUT_FILE" | ||
| done | ||
|
|
||
| echo "Combined test report created: $OUTPUT_FILE" | ||
| echo "Included reports: ${REPORTS[*]}" | ||
| # Backward-compatible alias for the existing sticky-comment step which uploads | ||
| # combined-test-report.md from the repo root. | ||
| if [ -f "$REPORTS_DIR/combined-test-report.md" ] && [ ! -f combined-test-report.md ]; then | ||
| cp "$REPORTS_DIR/combined-test-report.md" combined-test-report.md | ||
| fi |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| name: Run e2e tests (rig + docker compose) | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| pull_request: | ||
| types: [labeled, synchronize] | ||
| branches: [main] | ||
| schedule: | ||
| # Nightly at 02:00 UTC. | ||
| - cron: "0 2 * * *" | ||
| workflow_dispatch: | ||
|
|
||
| jobs: | ||
| e2e: | ||
| # Only run on PRs that opt in via the `run-e2e` label, plus main + nightly + manual. | ||
| if: > | ||
| github.event_name != 'pull_request' || | ||
| contains(github.event.pull_request.labels.*.name, 'run-e2e') | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 60 | ||
|
|
||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v6 | ||
| with: | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Install uv | ||
| uses: astral-sh/setup-uv@v7 | ||
| with: | ||
| version: "0.6.14" | ||
| python-version: 3.12.9 | ||
|
|
||
| - name: Install tox with UV | ||
| run: uv tool install tox --with tox-uv | ||
|
|
||
| - name: Validate test manifests | ||
| run: tox -e rig -- validate | ||
|
|
||
| - name: Restore main-branch test baseline | ||
| # See ci-test.yaml for the rationale on namespacing per-workflow. | ||
| uses: actions/cache@v5 | ||
| with: | ||
| path: reports/previous-summary.json | ||
| key: unstract-test-baseline-e2e-main-${{ github.run_id }} | ||
| restore-keys: | | ||
| unstract-test-baseline-e2e-main- | ||
| unstract-test-baseline-e2e- | ||
|
|
||
| - name: Run e2e tier via docker compose | ||
| env: | ||
| UNSTRACT_E2E_RUNTIME: compose | ||
| run: | | ||
| # Use --tier e2e (not `all`) so this workflow runs only e2e groups. | ||
| if [ "${{ github.ref }}" = "refs/heads/main" ]; then | ||
| tox -e e2e -- --fail-on-critical-gap --update-baseline | ||
| else | ||
| tox -e e2e | ||
| fi | ||
|
|
||
| - name: Capture docker compose logs on failure | ||
| if: failure() | ||
| run: | | ||
| mkdir -p reports | ||
| docker compose -p unstract-test \ | ||
| -f docker/docker-compose.yaml \ | ||
| -f tests/compose/docker-compose.test.yaml \ | ||
| logs --no-color > reports/docker-compose-logs.txt || true | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
|
|
||
| - name: Output e2e report to job summary | ||
| if: always() && hashFiles('reports/summary.md') != '' | ||
| shell: bash | ||
| run: | | ||
| cat reports/summary.md >> $GITHUB_STEP_SUMMARY | ||
|
|
||
| - name: Upload e2e reports artifact | ||
| if: always() | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: test-reports-e2e | ||
| path: reports/ | ||
| if-no-files-found: ignore | ||
| retention-days: 30 | ||
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -713,3 +713,7 @@ AGENTS.md | |
|
|
||
| # MCP servers | ||
| .serena | ||
|
|
||
| # Unstract test rig | ||
| reports/ | ||
| .test-selection | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.