diff --git a/.github/workflows/aw-editor-tests.yml b/.github/workflows/aw-editor-tests.yml index 60e58557f7..27693bd706 100644 --- a/.github/workflows/aw-editor-tests.yml +++ b/.github/workflows/aw-editor-tests.yml @@ -6,6 +6,7 @@ on: paths: - 'tools/aw_editor/**' - 'astraweave-core/**' + - 'astraweave-llm/**' - '.github/workflows/aw-editor-tests.yml' schedule: # Not on pull_request. These editor test legs are optional and must not @@ -26,109 +27,62 @@ jobs: name: Test AW Editor (${{ matrix.os }}) runs-on: ${{ matrix.os }} timeout-minutes: 45 - # Skip if editor has known compilation issues - allows CI to pass while editor is being fixed - continue-on-error: true strategy: fail-fast: false matrix: os: [ubuntu-latest, windows-latest, macos-latest] - - steps: - - name: Checkout Repository - uses: actions/checkout@v7 - - name: Rust CI setup - uses: ./.github/actions/rust-ci-setup - - # Linux-specific: Install dependencies for graphics/windowing - - name: Install Linux Dependencies - if: runner.os == 'Linux' - run: | - sudo apt-get update - sudo apt-get install -y \ - pkg-config \ - libxcb-shape0-dev \ - libxcb-xfixes0-dev \ - libxkbcommon-dev \ - libegl1-mesa-dev \ - libwayland-dev \ - libudev-dev \ - libasound2-dev - - # Build aw_editor (checks compilation) - - name: Build AW Editor - run: cargo build -p aw_editor --lib --all-features - - # Run library unit tests (headless tests work everywhere) - - name: Run Unit Tests - run: cargo test -p aw_editor --lib --all-features -- --nocapture - continue-on-error: true # Don't fail CI on test failures (89% pass rate acceptable) - - # Run integration tests (require headless environment) - - name: Run Integration Tests - if: runner.os != 'macOS' # Skip macOS (no headless X11) - run: cargo test -p aw_editor --test ui_gizmo_smoke --test play_mode --test prefab_workflow - continue-on-error: true - - # Code quality checks - - name: Check Formatting - run: cargo fmt -p aw_editor -- --check - continue-on-error: true # Don't block on format issues - - - name: Run Clippy - run: cargo clippy -p aw_editor --all-features -- -D warnings - continue-on-error: true # Don't block on lints (52 warnings exist) - - # Generate test report - - name: Generate Test Summary - if: always() - run: | - echo "## AW Editor Test Results" >> $GITHUB_STEP_SUMMARY - echo "" >> $GITHUB_STEP_SUMMARY - echo "**Platform**: ${{ matrix.os }}" >> $GITHUB_STEP_SUMMARY - echo "**Rust Version**: $(rustc --version)" >> $GITHUB_STEP_SUMMARY - echo "" >> $GITHUB_STEP_SUMMARY - echo "### Test Coverage" >> $GITHUB_STEP_SUMMARY - echo "- **Unit Tests**: 146/164 passing (89%)" >> $GITHUB_STEP_SUMMARY - echo "- **Integration Tests**: 9 test files (ui_gizmo_smoke, play_mode, prefab_workflow, etc.)" >> $GITHUB_STEP_SUMMARY - echo "" >> $GITHUB_STEP_SUMMARY - echo "### Known Issues" >> $GITHUB_STEP_SUMMARY - echo "- 18 unit test failures (gizmo math, undo stack, scene serialization)" >> $GITHUB_STEP_SUMMARY - echo "- 52 warnings (dead code, unused fields - tracked in Known Issues)" >> $GITHUB_STEP_SUMMARY - - # Coverage job (optional - Linux only for speed) - coverage: - name: Test Coverage - runs-on: ubuntu-latest - timeout-minutes: 45 - steps: - - name: Checkout Repository - uses: actions/checkout@v7 - - - name: Install Rust Toolchain - uses: dtolnay/rust-toolchain@1.89.0 - with: - components: llvm-tools-preview - - - name: Install Linux Dependencies - run: | - sudo apt-get update - sudo apt-get install -y pkg-config libxcb-shape0-dev libxcb-xfixes0-dev libxkbcommon-dev libegl1-mesa-dev libudev-dev libasound2-dev - - - name: Install cargo-llvm-cov - run: cargo install cargo-llvm-cov - - - name: Generate Coverage Report - run: | - cargo llvm-cov --package aw_editor --lib --lcov --output-path lcov.info - continue-on-error: true - - - name: Upload Coverage to Codecov - uses: codecov/codecov-action@v4 - if: success() - with: - files: ./lcov.info - flags: aw_editor - name: aw-editor-coverage - continue-on-error: true # Don't fail if codecov upload fails + - name: Checkout Repository + uses: actions/checkout@v7 + + - name: Rust CI setup + uses: ./.github/actions/rust-ci-setup + + - name: Install Linux Dependencies + if: runner.os == 'Linux' + run: | + sudo apt-get update + sudo apt-get install -y \ + pkg-config \ + libxcb-shape0-dev \ + libxcb-xfixes0-dev \ + libxkbcommon-dev \ + libegl1-mesa-dev \ + libwayland-dev \ + libudev-dev \ + libasound2-dev + + - name: Check Formatting + run: cargo fmt -p aw_editor -- --check + + - name: Clippy (aw_editor) + run: cargo clippy -p aw_editor --all-features --no-deps -- -D warnings + + - name: Clippy (astraweave-llm without ollama) + run: cargo clippy -p astraweave-llm --no-deps -- -D warnings + + - name: Build AW Editor + run: cargo build -p aw_editor --lib --all-features + + - name: Run Unit Tests + run: cargo test -p aw_editor --lib --all-features -- --nocapture + + - name: Run Integration Tests + if: runner.os != 'macOS' + run: > + cargo test -p aw_editor --all-features + --test ui_gizmo_smoke + --test play_mode + --test prefab_workflow + + - name: Generate Test Summary + if: always() + shell: bash + run: | + echo "## AW Editor Test Results" >> "$GITHUB_STEP_SUMMARY" + echo "" >> "$GITHUB_STEP_SUMMARY" + echo "**Platform**: ${{ matrix.os }}" >> "$GITHUB_STEP_SUMMARY" + echo "**Rust Version**: $(rustc --version)" >> "$GITHUB_STEP_SUMMARY" + echo "" >> "$GITHUB_STEP_SUMMARY" + echo "Blocking gate: fmt, clippy, build, unit tests, and integration tests (Linux/Windows)." >> "$GITHUB_STEP_SUMMARY" diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 5ec26ad3fa..67d1b30656 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -13,68 +13,61 @@ concurrency: jobs: coverage: - name: Generate Code Coverage + name: Workspace coverage (non-blocking) runs-on: ubuntu-latest - timeout-minutes: 45 - # Coverage may fail on some configurations - non-blocking + timeout-minutes: 120 continue-on-error: true - + steps: - name: Checkout code uses: actions/checkout@v7 - name: Rust CI setup uses: ./.github/actions/rust-ci-setup - - - name: Install cargo-tarpaulin - run: cargo install cargo-tarpaulin --version 0.35.2 --locked - - - name: Generate coverage + + - name: Install cargo-llvm-cov + uses: taiki-e/install-action@cargo-llvm-cov + + - name: Install Linux dependencies run: | - cd tools/astraweave-assets - cargo tarpaulin --out Xml --output-dir coverage --exclude-files 'src/main.rs' --exclude-files 'tests/*' - + sudo apt-get update + sudo apt-get install -y pkg-config libudev-dev libasound2-dev + + - name: Generate workspace coverage summary + run: | + rm -rf coverage + mkdir -p coverage + cargo llvm-cov --workspace --lib --summary-only --json --output-path coverage/summary.json + + - name: Generate workspace lcov + run: cargo llvm-cov --workspace --lib --lcov --output-path coverage/workspace.lcov + - name: Upload coverage to Codecov uses: codecov/codecov-action@v5 with: - files: ./tools/astraweave-assets/coverage/cobertura.xml - flags: astraweave-assets - name: astraweave-assets-coverage + files: ./coverage/workspace.lcov + flags: workspace + name: workspace-coverage fail_ci_if_error: false env: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} - - - name: Generate HTML report - if: always() - run: | - cd tools/astraweave-assets - cargo tarpaulin --out Html --output-dir coverage-html --exclude-files 'src/main.rs' --exclude-files 'tests/*' - - - name: Upload HTML coverage report - if: always() - uses: actions/upload-artifact@v7 - with: - name: coverage-report - path: tools/astraweave-assets/coverage-html - retention-days: 30 - + - name: Coverage summary if: always() run: | - cd tools/astraweave-assets - echo "## Code Coverage Report" >> $GITHUB_STEP_SUMMARY - echo "" >> $GITHUB_STEP_SUMMARY - if [ -f coverage/cobertura.xml ]; then - COVERAGE=$(grep -oP 'line-rate="\K[0-9.]+' coverage/cobertura.xml | head -1 | awk '{printf "%.1f", $1*100}') - echo "**Overall Coverage:** ${COVERAGE}%" >> $GITHUB_STEP_SUMMARY - echo "" >> $GITHUB_STEP_SUMMARY - echo "Target: 80%+ (Production Ready)" >> $GITHUB_STEP_SUMMARY - - if (( $(echo "$COVERAGE >= 80" | bc -l) )); then - echo "✅ **Status:** PASS (meets target)" >> $GITHUB_STEP_SUMMARY - else - echo "⚠️ **Status:** Below target (needs improvement)" >> $GITHUB_STEP_SUMMARY - fi - else - echo "⚠️ Coverage data not generated" >> $GITHUB_STEP_SUMMARY - fi + python - <<'PY' + import json, os, pathlib, sys + summary_path = pathlib.Path("coverage/summary.json") + with open(os.environ["GITHUB_STEP_SUMMARY"], "a", encoding="utf-8") as fh: + fh.write("## Workspace coverage (non-blocking)\n\n") + if not summary_path.exists(): + fh.write("Coverage summary JSON was not generated.\n") + sys.exit(0) + data = json.loads(summary_path.read_text()) + totals = data["data"][0]["totals"] + for metric in ("lines", "functions", "regions"): + entry = totals[metric] + pct = (entry["percent"] if "percent" in entry else + (entry["covered"] / entry["count"] * 100 if entry["count"] else 0.0)) + fh.write(f"- {metric.title()}: {pct:.2f}% ({entry['covered']}/{entry['count']})\n") + PY diff --git a/astraweave-llm/src/lib.rs b/astraweave-llm/src/lib.rs index 800fd3ade6..b7d9dad2dd 100644 --- a/astraweave-llm/src/lib.rs +++ b/astraweave-llm/src/lib.rs @@ -140,6 +140,7 @@ pub async fn read_capped_text_limited(response: reqwest::Response, limit: usize) } /// How long the next body read may block, and which deadline a timeout is. +#[cfg(feature = "ollama")] struct ReadWait { wait: std::time::Duration, on_timeout: &'static str, diff --git a/scripts/ci/test_workflow_policy.py b/scripts/ci/test_workflow_policy.py index 98a9096a0a..030a6560fe 100644 --- a/scripts/ci/test_workflow_policy.py +++ b/scripts/ci/test_workflow_policy.py @@ -143,6 +143,15 @@ def _broken_action_ref_violation(old: str, new: str): source = inspect.getsource(action_ref_violation).replace(old, new, 1) return _exec_action_ref_violation_from_source(source) +CONTINUE_ON_ERROR = re.compile( + r"continue-on-error\s*:\s*(" + r"true" + r"|['\"]true['\"]" + r"|\$\{\{\s*true\s*\}\}" + r")", + re.IGNORECASE, +) + def workflow_texts() -> dict[str, str]: return {path.name: path.read_text(encoding="utf-8") for path in sorted(WORKFLOWS.glob("*.yml"))} @@ -181,19 +190,41 @@ def nightly_failure_watched_workflows(text: str) -> list[str]: break return watched +def has_continue_on_error(text: str) -> bool: + return bool(CONTINUE_ON_ERROR.search(text)) + + def has_pull_request(text: str) -> bool: # Quoted "on" (scorecard) and bare on: both count. in_on = False for line in text.splitlines(): stripped = line.strip() - if stripped in {"on:", '"on":'}: + if stripped.startswith("on:") or stripped.startswith('"on":'): in_on = True + rest = stripped.split(":", 1)[1].strip() + if rest and not rest.startswith("#"): + if rest.startswith("pull_request:") or rest.startswith( + "pull_request_target:" + ): + return True + if re.search( + r"(?:^|\[|,)\s*pull_request(?:\s|,|\]|$)", rest + ): + return True + if stripped in {"on:", '"on":'}: + continue continue if in_on and line and not line.startswith(" ") and not line.startswith("#"): in_on = False if in_on and stripped.startswith("pull_request:"): return True + if in_on and stripped.startswith("pull_request_target:"): + return True + if in_on and re.search( + r"(?:^|\[|,)\s*pull_request(?:\s|,|\]|$)", stripped + ): + return True return False @@ -291,6 +322,20 @@ def assert_mutation_summary_requires_ai_success(text: str) -> None: ) +AW_EDITOR_TESTS = WORKFLOWS / "aw-editor-tests.yml" + + +def aw_editor_test_job(text: str) -> str: + return text.split(" test:\n", 1)[1] + + +def assert_aw_editor_summary_step_uses_bash(text: str) -> None: + job = aw_editor_test_job(text) + block = job_step_block(job, "Generate Test Summary") + if "shell: bash" not in block: + raise AssertionError("Generate Test Summary must set shell: bash on Windows runners") + + def assert_mutation_ai_outcome_steps_not_softened(text: str) -> None: ai = mutation_ai_job(text) for step_name in ("Verify astraweave-ai shard outcomes", "Generate mutation report"): @@ -606,6 +651,33 @@ def test_nightly_failure_issue_job_skips_fork_and_pull_request_runs(self) -> Non text, ) + def test_continue_on_error_helper_catches_common_bypasses(self) -> None: + samples = ( + "continue-on-error: true", + "continue-on-error: 'true'", + 'continue-on-error: "true"', + "continue-on-error:${{ true }}", + "continue-on-error: true", + ) + for sample in samples: + self.assertTrue(has_continue_on_error(sample), sample) + self.assertFalse( + has_continue_on_error( + "cancel-in-progress: ${{ github.event_name == 'pull_request' }}" + ) + ) + + def test_has_pull_request_catches_target_and_list_forms(self) -> None: + self.assertTrue( + has_pull_request("on:\n pull_request_target:\n branches: [main]\n") + ) + self.assertTrue(has_pull_request('on: [push, pull_request]\n')) + self.assertFalse( + has_pull_request( + "on:\n push:\n branches: [main]\n schedule:\n # Not on pull_request.\n" + ) + ) + def test_allocation_measurement_is_a_real_gate_off_prs(self) -> None: text = (WORKFLOWS / "allocation-measurement.yml").read_text(encoding="utf-8") self.assertIn("schedule:", text) @@ -615,6 +687,43 @@ def test_allocation_measurement_is_a_real_gate_off_prs(self) -> None: self.assertIn("zero_alloc_step", text) self.assertIn("[self-hosted, gpu]", text) self.assertNotIn("continue-on-error: true", text) + self.assertFalse(has_continue_on_error(text)) + self.assertFalse(has_pull_request(text)) + + def test_aw_editor_tests_is_a_real_gate_off_prs(self) -> None: + text = AW_EDITOR_TESTS.read_text(encoding="utf-8") + self.assertIn("schedule:", text) + self.assertIn("astraweave-llm", text) + self.assertIn("cargo fmt -p aw_editor -- --check", text) + self.assertIn("cargo clippy -p aw_editor --all-features --no-deps -- -D warnings", text) + self.assertIn("cargo clippy -p astraweave-llm --no-deps -- -D warnings", text) + self.assertIn("cargo build -p aw_editor --lib --all-features", text) + self.assertIn("cargo test -p aw_editor --lib --all-features", text) + self.assertIn("--test ui_gizmo_smoke", text) + self.assertFalse(has_continue_on_error(text)) + self.assertFalse(has_pull_request(text)) + + def test_aw_editor_summary_step_uses_bash(self) -> None: + text = AW_EDITOR_TESTS.read_text(encoding="utf-8") + assert_aw_editor_summary_step_uses_bash(text) + without_bash = text.replace( + " - name: Generate Test Summary\n if: always()\n shell: bash\n run: |", + " - name: Generate Test Summary\n if: always()\n run: |", + 1, + ) + with self.assertRaises(AssertionError): + assert_aw_editor_summary_step_uses_bash(without_bash) + + def test_editor_and_sdk_ci_stay_non_blocking(self) -> None: + for name in ("editor-ci.yml", "sdk-ci.yml"): + text = (WORKFLOWS / name).read_text(encoding="utf-8") + self.assertTrue(has_continue_on_error(text), msg=name) + + def test_workspace_coverage_stays_non_blocking(self) -> None: + text = (WORKFLOWS / "coverage.yml").read_text(encoding="utf-8") + self.assertTrue(has_continue_on_error(text)) + self.assertIn("cargo llvm-cov --workspace --lib", text) + self.assertNotIn("github.step_summary", text) self.assertFalse(has_pull_request(text)) def test_pinned_nightly_steps_follow_the_experimental_flag(self) -> None: diff --git a/tools/aw_editor/src/panels/navigation_panel.rs b/tools/aw_editor/src/panels/navigation_panel.rs index 37c6484c9d..d570040425 100644 --- a/tools/aw_editor/src/panels/navigation_panel.rs +++ b/tools/aw_editor/src/panels/navigation_panel.rs @@ -2043,15 +2043,10 @@ mod tests { // ============================================================ // NavAreaType tests (7 tests) - // FIXME: Skipped due to Windows emoji encoding issues (U+FFFD replacement character) - // The Road emoji "🛣️" contains variation selector U+FE0F which renders inconsistently - // across Windows console/file IO, causing assertion failures. The Display impl works - // correctly; this is purely a test environment issue. #[test] - #[ignore = "Windows emoji encoding issue"] fn test_nav_area_type_display() { assert_eq!(format!("{}", NavAreaType::Walkable), "🚶 Walkable"); - assert_eq!(format!("{}", NavAreaType::Road), "�️ Road"); + assert_eq!(format!("{}", NavAreaType::Road), "🛣️ Road"); assert_eq!(format!("{}", NavAreaType::Water), "💧 Water"); assert_eq!(format!("{}", NavAreaType::Grass), "[Leaf] Grass"); assert_eq!(format!("{}", NavAreaType::Mud), "🟫 Mud"); @@ -2069,12 +2064,10 @@ mod tests { assert_eq!(NavAreaType::Blocked.name(), "Blocked"); } - // FIXME: Skipped due to Windows emoji encoding issues (U+FFFD replacement character) #[test] - #[ignore = "Windows emoji encoding issue"] fn test_nav_area_type_icon() { assert_eq!(NavAreaType::Walkable.icon(), "🚶"); - assert_eq!(NavAreaType::Road.icon(), "�️"); + assert_eq!(NavAreaType::Road.icon(), "🛣️"); assert_eq!(NavAreaType::Water.icon(), "💧"); assert_eq!(NavAreaType::Blocked.icon(), "🚫"); }