diff --git a/.githooks/pre-push b/.githooks/pre-push new file mode 100755 index 0000000..458f4a9 --- /dev/null +++ b/.githooks/pre-push @@ -0,0 +1,39 @@ +#!/bin/bash + +# Git pre-push hook to run validation pipeline +# This prevents pushing code that fails known tests or linting + +set -e + +echo "๐Ÿ” Running pre-push validation pipeline..." + +# Run formatting check +echo "๐Ÿ“ Checking code formatting..." +if ! mix format --check-formatted; then + echo "โŒ Code formatting check failed. Run 'mix format' to fix." + exit 1 +fi + +# Run regression tests (critical - these should never break) +echo "๐Ÿงช Running regression tests..." +if ! mix test.regression; then + echo "โŒ Regression tests failed. These tests should always pass!" + exit 1 +fi + +# Run static analysis +echo "๐Ÿ” Running static analysis (Credo)..." +if ! mix credo --strict; then + echo "โŒ Credo analysis failed. Fix issues before pushing." + exit 1 +fi + +# Run type checking (optional - can be slow) +# Uncomment if you want type checking in the pre-push hook +# echo "๐Ÿ”ฌ Running type checking (Dialyzer)..." +# if ! mix dialyzer; then +# echo "โŒ Dialyzer type checking failed." +# exit 1 +# fi + +echo "โœ… All validation checks passed! Ready to push." \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fedd31a..e0eaf17 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -205,11 +205,10 @@ jobs: - name: Run Dialyzer run: mix dialyzer - scion-tests: - name: SCION Test Suite + regression-tests: + name: Regression Test Suite runs-on: ubuntu-latest needs: test - continue-on-error: true steps: - name: Checkout code @@ -231,13 +230,11 @@ jobs: restore-keys: | deps-${{ runner.os }}-27.3-1.18.3- - - name: Run SCION basic tests - run: mix test --include spec:basic + - name: Install dependencies + run: mix deps.get - - name: Upload SCION test results - uses: actions/upload-artifact@v4 - if: always() - with: - name: scion-test-results - path: _build/test/lib/sc/test-results.xml - retention-days: 30 + - name: Compile project + run: mix compile + + - name: Run regression tests + run: mix test.regression diff --git a/CLAUDE.md b/CLAUDE.md index c6ae7b2..9be6e47 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -12,15 +12,25 @@ When verifying code changes, always follow this sequence (also automated via pre 4. `mix dialyzer` - Run Dialyzer static analysis for type checking **Git Hooks:** +- `./scripts/setup-git-hooks.sh` - Install pre-push hook for validation pipeline - Pre-push hook automatically runs the validation workflow to catch issues before CI - Located at `.git/hooks/pre-push` (executable) - Blocks push if any validation step fails +**Regression Testing:** +- `test/passing_tests.json` - Registry of tests that should always pass +- Tracks internal tests, SCION tests, and W3C tests separately +- Updated manually when new tests start passing consistently +- Used by CI pipeline to catch regressions early + **Testing:** +- `mix test` - Run all internal tests (excludes SCION/W3C by default) +- `mix test --include scion --include scxml_w3` - Run all tests including SCION and W3C tests +- `mix test.regression` - Run regression tests that should always pass +- `mix test.baseline` - Check which tests are currently passing (for updating regression suite) - `mix test --cover` - Run all tests with coverage reporting (maintain 95%+ coverage) - `mix coveralls` - Alternative coverage command - `mix coveralls.detail` - Run tests with detailed coverage report showing uncovered lines -- `mix test` - Run all tests without coverage - `mix test test/sc/location_test.exs` - Run location tracking tests - `mix test test/sc/parser/scxml_test.exs` - Run specific SCXML parser tests (uses pattern matching) - `mix test test/sc/interpreter/compound_state_test.exs` - Run compound state tests @@ -255,4 +265,5 @@ XML content within triple quotes uses 4-space base indentation. The implementation follows the W3C SCXML specification closely and includes comprehensive test coverage from both W3C and SCION test suites. The current interpreter provides a solid foundation for basic SCXML functionality with clear areas identified for future enhancement. -- Always refer to state machines as state charts \ No newline at end of file +- Always refer to state machines as state charts +- Always run 'mix format' after writing an Elixir file. \ No newline at end of file diff --git a/README.md b/README.md index 45774e2..afef4a7 100644 --- a/README.md +++ b/README.md @@ -11,28 +11,35 @@ An Elixir implementation of SCXML (State Chart XML) state charts with a focus on - โœ… **State Chart Interpreter** - Runtime engine for executing SCXML state charts - โœ… **Comprehensive Validation** - Document validation with detailed error reporting - โœ… **Compound States** - Support for hierarchical states with automatic initial child entry +- โœ… **Parallel States** - Support for concurrent state regions with simultaneous execution - โœ… **O(1) Performance** - Optimized state and transition lookups via Maps - โœ… **Event Processing** - Internal and external event queues per SCXML specification - โœ… **Parse โ†’ Validate โ†’ Optimize Architecture** - Clean separation of concerns -- โœ… **Pre-push Hook** - Automated local validation workflow to catch issues early +- โœ… **Regression Testing** - Automated tracking of passing tests to prevent regressions +- โœ… **Git Hooks** - Pre-push validation workflow to catch issues early - โœ… **Test Infrastructure** - Compatible with SCION and W3C test suites ## Current Status -**SCION Test Results:** 107/225 tests passing (47.6% pass rate) +**SCION Test Results:** 30/127 tests passing (23.6% pass rate) +**W3C Test Results:** 0/59 tests passing (0% pass rate) +**Regression Suite:** 22 tests (all critical functionality) ### Working Features -- Basic state transitions and event-driven changes -- Hierarchical states with optimized O(d) ancestor lookup using parent pointers -- Document validation and error reporting with comprehensive hierarchy checks -- SAX-based XML parsing with accurate location tracking -- Performance-optimized active configuration generation +- โœ… **Basic state transitions** and event-driven changes +- โœ… **Hierarchical states** with optimized O(1) state lookup and automatic initial child entry +- โœ… **Parallel states** with concurrent execution of multiple regions +- โœ… **Document validation** and error reporting with comprehensive structural checks +- โœ… **SAX-based XML parsing** with accurate location tracking for error reporting +- โœ… **Performance optimizations** - O(1) state/transition lookups, optimized active configuration +- โœ… **Source field optimization** - Transitions include source state for faster event processing ### Planned Features -- Parallel states (``) - History states (``) -- Conditional transitions with expression evaluation -- Executable content (`