|
| 1 | +# GitHub Actions CI/CD Workflow |
| 2 | + |
| 3 | +## Overview |
| 4 | + |
| 5 | +This workflow runs automated tests for the datastar-cl SDK on every commit, pull request, and monthly schedule. |
| 6 | + |
| 7 | +## Workflow: `sdk-test.yml` |
| 8 | + |
| 9 | +### What It Does |
| 10 | + |
| 11 | +1. **Installs dependencies** |
| 12 | + - Roswell (Common Lisp implementation manager) |
| 13 | + - SBCL (Steel Bank Common Lisp) |
| 14 | + - libev-dev (required for Woo server) |
| 15 | + - golang-go (required for official Datastar test suite) |
| 16 | + |
| 17 | +2. **Starts test servers** (in background) |
| 18 | + - Port 48331: Hunchentoot backend |
| 19 | + - Port 48332: Clack+Woo backend |
| 20 | + - Port 48333: Clack+Hunchentoot backend |
| 21 | + |
| 22 | +3. **Waits for servers** to be ready (health checks on all 3 ports) |
| 23 | + |
| 24 | +4. **Runs SDK compliance tests** using official Datastar test suite |
| 25 | + |
| 26 | +5. **Runs SSE macro tests** to verify long-lived connections work correctly |
| 27 | + |
| 28 | +6. **Cleans up** (kills SBCL process) |
| 29 | + |
| 30 | +### Triggers |
| 31 | + |
| 32 | +- **Push**: Every commit to any branch |
| 33 | +- **Pull Request**: When PRs are opened or updated |
| 34 | +- **Manual**: Via GitHub Actions UI (`workflow_dispatch`) |
| 35 | +- **Scheduled**: First day of each month at midnight UTC |
| 36 | + |
| 37 | +### How It Works |
| 38 | + |
| 39 | +The workflow uses a **simple sequential approach**: |
| 40 | + |
| 41 | +``` |
| 42 | +Start SBCL with servers → Wait for health checks → Run tests → Cleanup |
| 43 | +``` |
| 44 | + |
| 45 | +This is simpler than previous approaches that used complex third-party actions or Docker containers. |
| 46 | + |
| 47 | +### Key Files |
| 48 | + |
| 49 | +- `.github/workflows/sdk-test.yml` - GitHub Actions workflow definition |
| 50 | +- `tests/run.lisp` - Script that loads the system and starts all servers |
| 51 | +- `tests/run-sdk-tests.sh` - Shell script to run official Datastar SDK tests |
| 52 | +- `tests/run-sse-tests.sh` - Shell script to test SSE connection macros |
| 53 | + |
| 54 | +### Running Locally |
| 55 | + |
| 56 | +To reproduce the CI environment locally: |
| 57 | + |
| 58 | +```bash |
| 59 | +# Start servers (in background) |
| 60 | +sbcl --non-interactive --load tests/run.lisp & |
| 61 | +SBCL_PID=$! |
| 62 | + |
| 63 | +# Wait for servers |
| 64 | +for port in 48331 48332 48333; do |
| 65 | + while ! curl -f -s http://localhost:$port/ > /dev/null 2>&1; do |
| 66 | + echo "Waiting for port $port..." |
| 67 | + sleep 2 |
| 68 | + done |
| 69 | +done |
| 70 | + |
| 71 | +# Run tests |
| 72 | +./tests/run-sdk-tests.sh |
| 73 | +./tests/run-sse-tests.sh |
| 74 | + |
| 75 | +# Cleanup |
| 76 | +kill $SBCL_PID |
| 77 | +``` |
| 78 | + |
| 79 | +### Troubleshooting |
| 80 | + |
| 81 | +**Servers fail to start:** |
| 82 | +- Check SBCL logs in GitHub Actions output |
| 83 | +- Ensure all dependencies are installed (libev-dev for Woo) |
| 84 | +- Verify ports 48331-48333 are not already in use |
| 85 | + |
| 86 | +**Health check timeout:** |
| 87 | +- Default timeout is 60 seconds (30 checks × 2 seconds) |
| 88 | +- Check if `tests/run.lisp` properly calls `start-all-servers` |
| 89 | +- Verify each server has a root endpoint that responds |
| 90 | + |
| 91 | +**SDK tests fail:** |
| 92 | +- Check if Go is properly installed |
| 93 | +- Verify internet connectivity (downloads Datastar test suite) |
| 94 | +- Review test output for specific failures |
| 95 | + |
| 96 | +**SSE tests fail:** |
| 97 | +- Ensure `curl` is available |
| 98 | +- Check timeout settings in `run-sse-tests.sh` |
| 99 | +- Verify servers are properly handling SSE connections |
| 100 | + |
| 101 | +### Design Decision: Why This Approach? |
| 102 | + |
| 103 | +We chose this **simple sequential approach** over alternatives because: |
| 104 | + |
| 105 | +✅ **Simple**: No complex third-party actions or Docker containers |
| 106 | +✅ **Transparent**: Easy to understand and debug |
| 107 | +✅ **Reproducible**: Same commands work locally and in CI |
| 108 | +✅ **Fast**: No image building or complex setup |
| 109 | +✅ **Maintainable**: Standard shell commands, no hidden complexity |
| 110 | + |
| 111 | +Other approaches considered (and rejected): |
| 112 | +- **Docker containers**: Overkill, slower, more complex |
| 113 | +- **Background action**: Third-party dependency, harder to debug |
| 114 | +- **Service containers**: Requires image registry, complex setup |
| 115 | +- **Matrix testing**: Higher CI costs, unnecessary parallelization |
| 116 | + |
| 117 | +### Monitoring |
| 118 | + |
| 119 | +View workflow runs at: `https://github.com/YOUR_ORG/datastar-cl/actions` |
| 120 | + |
| 121 | +Scheduled runs help detect: |
| 122 | +- Breaking changes in dependencies (SBCL, libraries) |
| 123 | +- Breaking changes in Datastar test suite |
| 124 | +- Bit rot or platform issues |
0 commit comments