diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..1852838 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,72 @@ +name: CI + +on: + pull_request: + push: + branches: [main] + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +env: + CARGO_TERM_COLOR: always + # Debug info only slows linking and bloats the cache in CI. + CARGO_PROFILE_DEV_DEBUG: 0 + +jobs: + lint: + name: fmt and clippy + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + with: + components: rustfmt, clippy + - uses: Swatinem/rust-cache@v2 + - run: cargo fmt --all -- --check + - run: cargo clippy --all-targets --locked -- -D warnings + + test: + name: tests + runs-on: ubuntu-latest + services: + # Matches docker-compose.yml; later releases need an auth token. + localstack: + image: localstack/localstack:4.14 + ports: + - 4566:4566 + env: + SERVICES: s3 + options: >- + --health-cmd "curl -sf http://localhost:4566/_localstack/health" + --health-interval 2s + --health-timeout 2s + --health-retries 30 + env: + AWS_ENDPOINT_URL: http://localhost:4566 + AWS_ACCESS_KEY_ID: test + AWS_SECRET_ACCESS_KEY: test + AWS_REGION: us-east-1 + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + - uses: Swatinem/rust-cache@v2 + # The embedding models are large and change rarely. + - uses: actions/cache@v4 + with: + path: .fastembed_cache + key: fastembed-${{ hashFiles('src/embed.rs') }} + restore-keys: fastembed- + - name: Unit tests + run: cargo test --locked + # s3vectors skips itself without TEST_VECTOR_BUCKET. + - name: Integration and e2e tests + run: cargo test --locked -- --ignored + - name: Upload e2e server logs + if: failure() + uses: actions/upload-artifact@v4 + with: + name: e2e-logs + path: target/e2e-logs/ + if-no-files-found: ignore diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 0000000..ace638c --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,32 @@ +name: Docker + +# A release build plus the baked-in model takes many minutes, so PRs only +# build the image when something that affects it changes. +on: + pull_request: + paths: + - Dockerfile + - .dockerignore + - Cargo.toml + - Cargo.lock + - .github/workflows/docker.yml + push: + branches: [main] + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + docker: + name: docker build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: docker/setup-buildx-action@v3 + - uses: docker/build-push-action@v6 + with: + context: . + push: false + cache-from: type=gha + cache-to: type=gha,mode=max