From b10c8461de5ad7ababf70f2ccdfc2e968ce047e8 Mon Sep 17 00:00:00 2001 From: Robert Usher <266585+dcchut@users.noreply.github.com> Date: Tue, 20 Sep 2022 18:20:30 +1000 Subject: [PATCH] test example with both postgres and sqlite in CI --- .github/workflows/rust.yml | 78 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 75 insertions(+), 3 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index db3b68b..fdb11f1 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -22,12 +22,12 @@ jobs: components: clippy profile: minimal - - uses: Swatinem/rust-cache@v1 + - uses: Swatinem/rust-cache@v2 - name: Test and clippy (main) run: cargo clippy -- -Dwarnings && cargo test --verbose && cargo check --no-default-features - examples: + example-lint: runs-on: ${{ matrix.os }} strategy: matrix: @@ -44,12 +44,84 @@ jobs: components: clippy profile: minimal - - uses: Swatinem/rust-cache@v1 + - uses: Swatinem/rust-cache@v2 - name: clippy (examples) working-directory: examples run: cargo clippy -- -Dwarnings && cargo check --verbose + example-sqlite: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest] + rust: [stable] + + steps: + - uses: actions/checkout@v2 + + - uses: actions-rs/toolchain@v1 + with: + toolchain: ${{ matrix.rust }} + override: true + profile: minimal + + - uses: Swatinem/rust-cache@v2 + + - name: "Test example server" + working-directory: examples/axum-example + # This should really be a Python script or something, but this is fine for now. + run: | + cargo build + cargo run & + sleep 5 + curl http://localhost:3000 --cookie .cookies --cookie-jar .cookies + curl http://localhost:3000 --cookie .cookies --cookie-jar .cookies > output + test "$(cat output)" -eq "2" + + example-postgres: + # services require linux runner + runs-on: ubuntu-latest + strategy: + matrix: + rust: [stable] + + services: + postgres: + image: postgres + env: + POSTGRES_DB: axum_example + POSTGRES_PASSWORD: postgres + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + ports: + - 5432:5432 + + steps: + - uses: actions/checkout@v2 + + - uses: actions-rs/toolchain@v1 + with: + toolchain: ${{ matrix.rust }} + override: true + profile: minimal + + - uses: Swatinem/rust-cache@v2 + + - name: "Test example server" + working-directory: examples/axum-example + # This should really be a Python script or something, but this is fine for now. + run: | + cargo build --features postgres + DATABASE_URI=postgres://postgres:postgres@localhost/axum_example cargo run --features postgres & + sleep 5 + curl http://localhost:3000 --cookie .cookies --cookie-jar .cookies + curl http://localhost:3000 --cookie .cookies --cookie-jar .cookies > output + test "$(cat output)" -eq "2" + fmt: runs-on: ubuntu-latest