diff --git a/.github/workflows/pr-checks.yml b/.github/workflows/pr-checks.yml new file mode 100644 index 0000000..1f13a6c --- /dev/null +++ b/.github/workflows/pr-checks.yml @@ -0,0 +1,51 @@ +name: PR Checks + +on: + pull_request: + +jobs: + validate-and-test: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up Rust + uses: dtolnay/rust-toolchain@stable + with: + toolchain: "1.88.0" + components: rustfmt, clippy + + - name: Rust cache + uses: Swatinem/rust-cache@v2 + + - name: Format check + run: cargo fmt --all --check + + - name: Lint + run: cargo clippy --workspace --all-targets + + - name: Tests + run: cargo test --workspace --all-targets --locked + + docker-build-verify: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Verify multi-arch Docker build + uses: docker/build-push-action@v6 + with: + context: . + file: hulykvs_server/Dockerfile + push: false + platforms: linux/amd64,linux/arm64 diff --git a/hulykvs_server/Dockerfile b/hulykvs_server/Dockerfile index a84cc3b..dbc8715 100644 --- a/hulykvs_server/Dockerfile +++ b/hulykvs_server/Dockerfile @@ -1,4 +1,4 @@ -FROM --platform=$BUILDPLATFORM rust:1.86 AS builder +FROM --platform=$BUILDPLATFORM rust:1.88 AS builder ARG TARGETPLATFORM WORKDIR /tmp/build diff --git a/hulykvs_server/src/main.rs b/hulykvs_server/src/main.rs index fe5651c..51ccfc3 100644 --- a/hulykvs_server/src/main.rs +++ b/hulykvs_server/src/main.rs @@ -147,14 +147,18 @@ async fn main() -> anyhow::Result<()> { info!(?backend, "detected database backend"); let report = match backend { - DbBackend::Cockroach => migrations_crdb::migrations::runner() - .set_migration_table_name("migrations") - .run_async(&mut connection) - .await?, - DbBackend::Postgres => migrations_pg::migrations::runner() - .set_migration_table_name("migrations_pg") - .run_async(&mut connection) - .await?, + DbBackend::Cockroach => { + migrations_crdb::migrations::runner() + .set_migration_table_name("migrations") + .run_async(&mut connection) + .await? + } + DbBackend::Postgres => { + migrations_pg::migrations::runner() + .set_migration_table_name("migrations_pg") + .run_async(&mut connection) + .await? + } }; for m in report.applied_migrations().iter() {