Commit Graph

17 Commits

Author SHA1 Message Date
mcfn.feng acccd9cb60 [root]ci: E2E tests only on merge, PR runs lint + UT only
Add `if: github.event_name == 'push'` to e2e-tests job so E2E only runs
on merge to main/release branches. PRs only run lint and unit tests,
reducing CI time and avoiding flaky external-site dependencies in PR checks.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-29 02:37:53 +08:00
mcfn.feng 8203601fae [root]ci: switch test workflow to cli-v2 with path filter
- Only trigger on packages/cli-v2/** changes
- Simplify to lint + unit tests + E2E tests
- Remove actionbook-rs specific jobs (coverage, cargo-deny, allure)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-28 00:49:52 +08:00
Junliang Feng 31ab7a9cda ci: grant checks write in test workflow (#316)
验收通过,合并
2026-03-27 15:29:14 +08:00
Junliang Feng 2d140585b7 feat: add 70% line coverage gate to UT Coverage CI job (#285)
[.github/workflows]feat: add 70% line coverage gate to UT Coverage job

Use cargo-llvm-cov --fail-under-lines 70 on the report step so CI fails
if line coverage drops below the 70% threshold.
2026-03-27 10:47:01 +08:00
Junliang Feng 0e109268c1 fix: E2E hover page-load race and session cleanup escalation (#280)
* [packages/actionbook-rs]fix: E2E hover page-load race and session cleanup escalation

Fix two E2E blockers:

1. int_hover: add wait-for-page-load before hovering to prevent
   "element 'body' not found" caused by DOM not being ready after
   navigation to example.com.

2. ensure_no_sessions(): escalate to `daemon stop` after 2 failed
   graceful close attempts. The daemon auto-restarts on the next CLI
   command, guaranteeing a clean slate even after test panics leave
   browser processes hung.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* [packages/actionbook-rs]fix: correct CLI arg order in select/type E2E tests

Fix CLI argument bugs causing test failures and cascades:

1. int_select_dropdown: add --selector flag and put positional value
   first — was passing selector as positional arg
2. int_type_text: swap text and selector args — was typing the selector
   string into the wrong element
3. ensure_no_sessions: increase post-daemon-stop delay to 1s for CI
   reliability

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* [packages/actionbook-rs]fix: parse list-sessions envelope in e2e cleanup

* [root]fix: serialize E2E test execution with nextest -j 1

nextest's --test-threads=1 only limits threads within a single test
process, but nextest can still launch multiple test processes
concurrently. Since all E2E tests share a single daemon instance
(via HOME/.actionbook/), concurrent processes cause session conflicts.
Adding -j 1 ensures truly sequential execution.

Root cause identified by Dev-Codex (#t19).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* [root]fix: remove duplicate --test-threads flag in E2E nextest command

In nextest, -j and --test-threads are aliases. Remove --test-threads=1
since -j 1 already provides the same serialization.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* [packages/actionbook-rs]fix: correct CLI arg formats for last 4 failing E2E tests

- int_upload: use --selector flag instead of positional for selector
- obs_inspect_point: pass x and y as separate positional args, not "x,y"
- obs_console_logs: use logs-console (single command), not logs console
- obs_error_logs: use logs-errors (single command), not logs errors

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* [packages/actionbook-rs]fix: add timing delays for last 3 E2E test failures

- obs_console_logs/obs_error_logs: add 500ms delay after eval to let
  browser collect console messages before reading logs
- obs_query_nth: wait for page load (document.readyState === 'complete')
  before querying DOM elements

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* [packages/actionbook-rs]fix: add page-load waits to all E2E tests to eliminate flakiness

Add `wait condition "document.readyState === 'complete'"` after every
`browser start --open-url` across all E2E test files. This ensures the
page is fully loaded before any DOM query, eval, or browser action,
preventing intermittent failures from CI network latency.

Also increase console/error log collection delay from 500ms to 1000ms.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* [packages/actionbook-rs]fix: eliminate E2E flakiness with about:blank and polling

Switch 4 flaky tests from example.com to about:blank to remove network
dependency. Add page-load waits after all start commands across all test
files to prevent timing issues.

- obs_eval_dom: use about:blank, set title via eval instead of reading
  example.com's title
- obs_pdf_produces_file: use about:blank, inject minimal HTML for PDF
- obs_console_logs: use about:blank, poll logs-console (up to 3s)
  instead of fixed sleep
- obs_error_logs: use about:blank, poll logs-errors (up to 3s)
  instead of fixed sleep
- All test files: add wait condition "document.readyState === 'complete'"
  after every browser start --open-url

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* [packages/actionbook-rs]fix: add missing set_body_html_js import

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* [packages/actionbook-rs]fix: TrustedTypes try/catch and tab_switch wait

- Wrap TrustedTypes default policy creation in try/catch to handle
  edge cases where the policy check passes but creation still throws
- Add wait for page load on t1 in tab_switch_changes_active to prevent
  Chrome internal URL flake

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* [packages/actionbook-rs]chore: cargo fmt

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* [packages/actionbook-rs]fix: initialize log capture before eval

* [packages/actionbook-rs]fix: update eval UT mock for log capture init

The log capture fix (2fabcaa) added an extra backend call before eval.
Update eval_returns_value mock to provide results for both the log
capture initialization call and the actual eval call.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* [packages/actionbook-rs]fix: robust TrustedTypes handling and tab_switch goto

TrustedHTML fix:
- Replace innerHTML-based approach with setHTMLUnsafe() (Chrome 124+)
  as primary method, which bypasses TrustedTypes entirely
- Fall back to TrustedTypes policy (reuse existing default or create
  new one), then to document.implementation.createHTMLDocument
- Eliminates "Policy 'default' disallowed" errors in shared daemon

tab_switch fix:
- Add explicit goto after open to ensure t1 navigates to example.org
- Chrome sometimes opens internal URLs on new tab; goto forces correct
  navigation before asserting URL

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* [packages/actionbook-rs]fix: add wait for t1 load in int_fill_s1t2_isolation

Wait for page load on t1 after open to ensure the page is ready
before injecting HTML via set_body_html_js.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-27 01:05:02 +08:00
Junliang Feng 4cd3ca41ff [packages/actionbook-rs] feat: add UT coverage reporting (#279)
* [packages/actionbook-rs]feat: add unit test coverage reporting

* [packages/actionbook-rs]fix: preserve coverage exit status
2026-03-26 23:27:54 +08:00
Junliang Feng e65552fe3e ci: add cargo-audit security scan (#t12) (#271)
[packages/actionbook-rs]ci: add cargo-audit security scan

Add security-audit CI job running cargo-audit against the RustSec
Advisory Database. Update quinn-proto (0.11.13->0.11.14) and
rustls-webpki (0.103.9->0.103.10) to resolve RUSTSEC-2026-0037
and RUSTSEC-2026-0049. Integrate audit status into test-summary.

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-26 23:16:26 +08:00
Junliang Feng dac9ffa96c fix: enable E2E and macOS unit tests on pull requests (#277)
[root]fix: enable E2E and macOS unit tests on pull requests

Remove `if: github.event_name == 'push'` from e2e-tests and
unit-tests-macos jobs so they run on both push and pull_request
events. Previously these jobs were skipped on PRs, meaning test
failures were only caught after merge.

Allure report job remains push-only since it deploys to gh-pages.

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-26 23:04:57 +08:00
Junliang Feng d24eeb8eb0 ci: add cargo-deny check (#t11) (#269)
[packages/actionbook-rs]ci: add cargo-deny for license and vulnerability scanning

Add deny.toml with allowed licenses (MIT, Apache-2.0, BSD, ISC, MPL-2.0,
CDLA-Permissive-2.0, Unicode, OpenSSL, Zlib) and advisory ignore for
unmaintained number_prefix (via indicatif). Add cargo-deny CI job to
test workflow with summary integration. Update rustls-webpki to fix
RUSTSEC-2026-0049.

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-26 23:01:42 +08:00
Junliang Feng 2d94447cbe ci: add cargo-machete unused deps check (#t13) (#270)
* [root]feat: add cargo-machete CI check for unused dependency detection

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* [root]fix: handle cargo-machete false positives for anyhow and tower

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-26 17:47:08 +08:00
Junliang Feng 0d3af40bf3 [root]feat: add clippy + fmt lint check to CI (#261)
* [root]feat: add clippy + fmt lint check to CI

Add a new Lint job that runs cargo fmt --check and cargo clippy -D warnings
as a code quality gate. Lint status is included in test summary.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* [packages/actionbook-rs]fix: format all code and fix clippy warnings

- Run cargo fmt --all to enforce consistent formatting
- Fix clippy warnings: use clamp(), if-let, contains_key, unwrap_or_default
- Add targeted #[allow] for structural patterns (too_many_arguments,
  large_enum_variant, result_large_err, never_loop)
- CI clippy config: -D warnings with -A dead_code/unused-imports/deprecated
  to allow TDD-style development while catching real quality issues

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* [packages/actionbook-rs]fix: remove dead depth_cache allocation in benchmark

Remove unused HashMap allocation that was silenced with _ prefix.
Addresses review feedback on PR #261.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-26 16:42:04 +08:00
Junliang Feng a10dadfcb2 [root]feat: switch to Swatinem/rust-cache for faster CI builds (#264)
Replace manual actions/cache with Swatinem/rust-cache@v2 for both
unit-tests and e2e-tests jobs. Swatinem/rust-cache auto-detects
Cargo.lock, caches target dir and registry, and handles cache
invalidation — simpler config and 50-70% build speedup on cache hits.

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-26 16:33:55 +08:00
Junliang Feng b756e6d942 [root]feat: split CI by event type — PR runs lint+UT, push runs full suite (#262)
PR events now only run Unit Tests (fast feedback for developers).
Push events to main/release/** run the full suite: Unit Tests + E2E +
Test Summary + Allure Report.

This follows the agent-browser pattern where PRs get lightweight checks
and push triggers comprehensive verification.

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-26 16:33:32 +08:00
Junliang Feng a86a8cdbd8 [root]feat: add macOS cross-platform unit tests to CI (#263)
Add a macOS runner job that runs unit tests on push events only
(cross-platform testing is expensive, skip on PRs). Results are
included in the test summary with skip/pass/fail status.

Follows agent-browser's pattern of cross-platform testing on push.

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-26 16:30:36 +08:00
Junliang Feng c070146aaa feat: integrate Allure Report for test visualization (#259)
* [root]feat: integrate Allure Report with GitHub Pages deployment

Add Allure Report job to CI pipeline:
- Downloads JUnit XML artifacts from UT and E2E jobs
- Generates interactive HTML report with Allure
- Preserves history across runs for trend charts (up to 20 reports)
- Deploys to GitHub Pages on push events (not PRs)
- Adds report URL to GitHub Actions summary

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* [root]fix: replace deprecated Docker-based Allure action with direct CLI

simple-elf/allure-report-action uses openjdk:8-jre-alpine which was
removed from Docker Hub. Switch to installing Allure CLI directly
via tarball + setup-java. Also add report artifact upload for
preview before GitHub Pages is configured.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* [root]fix: use find for JUnit XML paths and add job timeout

download-artifact preserves the upload directory structure, so
junit.xml is nested deeper than expected. Use find to locate
files regardless of nesting. Add 5-min timeout to allure-report job.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* [root]feat: deploy Allure report to /test-report/ subpath

Deploy to destination_dir: test-report so the Pages root is
available for other content in the future.

Report URL: https://actionbook.github.io/actionbook/test-report/

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* [root]fix: correct Allure history path for /test-report/ subdir

History is deployed under gh-pages/test-report/, not gh-pages/.
Without this fix, trend charts would never populate.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* [root]feat: switch Allure report to artifact-only (no GitHub Pages)

Per mcfeng's preference, remove GitHub Pages deployment and use
CI artifact download instead. Simpler setup, no gh-pages branch
needed. Report available as downloadable artifact with 30-day
retention.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* [root]feat: switch from Allure to xunit-viewer for test report

Allure reports require HTTP server to view (JavaScript CORS
restriction with file:// protocol). Switch to xunit-viewer which
generates a self-contained single HTML file that works when
opened directly in browser — no server needed.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* [root]feat: switch back to Allure Report with GitHub Pages deployment

mcfeng prefers Allure's UI over xunit-viewer. Allure requires HTTP
to work, so deploy to GitHub Pages at /test-report/ subpath.
Report URL: https://actionbook.github.io/actionbook/test-report/

Includes history preservation for trend charts across runs.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-26 13:45:22 +08:00
Junliang Feng 77b1f66f28 [root]feat: CI/CD with UT, E2E and test reports (#257)
* [root]feat: comprehensive CI/CD with UT, E2E, and test reports

Rewrote test.yml to include:
- Unit tests job: lib tests (245), CLI integration tests (131), CDP parsing tests
- E2E tests job: browser tests with headless Chrome
- Test summary job: aggregates results with pass/fail table
- JUnit XML reports via cargo2junit + mikepenz/action-junit-report
- Test artifacts uploaded for debugging
- Parallel execution: UT and E2E jobs run concurrently

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* [root]fix: switch CI from cargo2junit to cargo-nextest for test reports

cargo2junit requires nightly-only --format json flag, which fails on
stable Rust. Switched to cargo-nextest which natively supports JUnit
XML output on stable via profile config.

Changes:
- Replace cargo2junit with cargo-nextest (taiki-e/install-action)
- Add .config/nextest.toml with ci profile for JUnit output
- Simplify test steps using nextest's built-in reporting

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* [root]fix: remove duplicate test run in CI, consolidate into single step

Removed the redundant "Generate JUnit report" step that re-ran all tests.
Consolidated lib + cli_test + cdp_message_parsing into a single nextest
run, which generates junit.xml in one pass.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* [root]feat: add detailed test summary with test counts from JUnit XML

Each job now writes a summary table to GITHUB_STEP_SUMMARY with test
counts (total, passed, failed, errors, time) parsed from JUnit XML.
Test Summary job also shows aggregated results with counts per suite.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* [packages/actionbook-rs]fix: stop_bridge SIGTERM self-kill and CI exit code masking

1. stop_bridge no longer kills unverified processes found via lsof
   fallback — prevents the test from SIGTERMing itself when no PID
   file exists.
2. Add `set -o pipefail` to CI test steps so `| tee` does not
   swallow non-zero exit codes from cargo-nextest.
3. Set nextest CI profile to fail-fast=false for complete JUnit XML.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Actionbook <actionbook@Junliangs-MacBook-Air.local>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-26 11:26:58 +08:00
Junliang Feng 6100fcb3d1 [packages/actionbook-rs]feat: E2E test framework + browser_basic tests (#254)
* [packages/actionbook-rs]feat: add E2E test framework with browser_basic tests

New E2E test infrastructure:
- tests/e2e/main.rs: single binary entry point (avoids per-file link overhead)
- tests/e2e/harness.rs: shared env isolation, CLI runners, assertions
- tests/e2e/browser_basic.rs: 4 tests (open/goto arxiv.org/snapshot/close)
- .github/workflows/test.yml: CI workflow (Ubuntu + headless Chrome)

Gated by RUN_E2E_TESTS=true, run with --test-threads=1.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* [packages/actionbook-rs]fix: address review feedback on E2E tests

1. Remove unnecessary `unsafe impl Sync for IsolatedEnv` — all fields
   already implement Sync automatically.
2. Merge 4 sequential browser_basic tests into a single test function
   to guarantee execution order (Rust does not guarantee test ordering).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* [packages/actionbook-rs]fix: fix E2E harness HOME override breaking Chrome CDP

On macOS, overriding HOME causes Chrome to fail to bind its CDP port.
Changed harness to only override XDG_CONFIG_HOME and XDG_DATA_HOME for
actionbook config isolation, and added --no-daemon flag to avoid daemon
process env inheritance issues.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Actionbook <actionbook@Junliangs-MacBook-Air.local>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-25 23:03:25 +08:00