diff --git a/.github/workflows/build-api.yml b/.github/workflows/build-api.yml index 1e437c2..e067fdd 100644 --- a/.github/workflows/build-api.yml +++ b/.github/workflows/build-api.yml @@ -13,9 +13,61 @@ env: IMAGE_PREFIX: ${{ github.repository }} jobs: + test-api: + name: Test API + runs-on: ubuntu-latest + services: + postgres: + image: postgres:16 + env: + POSTGRES_USER: sigma + POSTGRES_PASSWORD: sigma + POSTGRES_DB: sigma_test + ports: + - 5432:5432 + options: >- + --health-cmd "pg_isready -U sigma -d sigma_test" + --health-interval 5s + --health-timeout 5s + --health-retries 10 + redis: + image: redis:7 + ports: + - 6379:6379 + options: >- + --health-cmd "redis-cli ping" + --health-interval 5s + --health-timeout 5s + --health-retries 10 + + env: + DATABASE_URL: postgres://sigma:sigma@localhost:5432/sigma_test + REDIS_URL: redis://localhost:6379 + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install Rust toolchain + uses: dtolnay/rust-toolchain@stable + + - name: Cache cargo registry and build + uses: Swatinem/rust-cache@v2 + with: + workspaces: sigma-api + + - name: Build sigma-api (including tests) + working-directory: sigma-api + run: cargo build --tests --locked + + - name: Run sigma-api tests + working-directory: sigma-api + run: cargo test -p sigma-api -- --test-threads=1 + build-api: name: Build API runs-on: ubuntu-latest + needs: test-api permissions: contents: read packages: write