From 4b0f4ed226305bba61054693fb105505ee68506a Mon Sep 17 00:00:00 2001 From: perf3ct Date: Wed, 18 Jun 2025 21:01:51 +0000 Subject: [PATCH] fix(tests): add step to run server for integration tests --- .github/workflows/test-integration.yml | 34 +++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test-integration.yml b/.github/workflows/test-integration.yml index a2d876d..b825209 100644 --- a/.github/workflows/test-integration.yml +++ b/.github/workflows/test-integration.yml @@ -63,10 +63,42 @@ jobs: restore-keys: | ${{ runner.os }}-cargo- + - name: Build readur binary + run: cargo build --release + + - name: Start readur server + run: | + ./target/release/readur & + echo $! > readur.pid + env: + DATABASE_URL: ${{ env.DATABASE_URL }} + JWT_SECRET: test-secret-key + PORT: 8000 + UPLOAD_PATH: ./uploads + WATCH_PATH: ./watch + + - name: Wait for server to be ready + run: | + for i in {1..30}; do + if curl -f http://localhost:8000/api/health > /dev/null 2>&1; then + echo "Readur server is ready" + break + fi + echo "Waiting for readur server... ($i/30)" + sleep 2 + done - name: Run integration tests run: | cargo test --test '*' -- --test-threads=1 env: TEST_DATABASE_URL: ${{ env.DATABASE_URL }} - RUST_LOG: debug \ No newline at end of file + RUST_LOG: debug + + - name: Stop readur server + if: always() + run: | + if [ -f readur.pid ]; then + kill $(cat readur.pid) || true + rm readur.pid + fi \ No newline at end of file