add e2e testing #13
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
| name: CI | |
| on: | |
| pull_request: | |
| push: | |
| branches: | |
| - main | |
| jobs: | |
| verify: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 15 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Node | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| cache: npm | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Static check | |
| run: npm run check | |
| - name: Start server | |
| run: | | |
| node server.js > server.log 2>&1 & | |
| echo $! > server.pid | |
| - name: Wait for health | |
| run: | | |
| for i in {1..20}; do | |
| if curl -fsS http://127.0.0.1:3000/api/health >/dev/null; then | |
| exit 0 | |
| fi | |
| sleep 1 | |
| done | |
| echo "Server did not become healthy in time" | |
| cat server.log || true | |
| exit 1 | |
| - name: API smoke test | |
| run: npm run test:smoke | |
| - name: Stop server | |
| if: always() | |
| run: | | |
| if [ -f server.pid ]; then | |
| kill $(cat server.pid) || true | |
| fi |