From a93db5955a7c512b8edeb1349f439824ee5f9881 Mon Sep 17 00:00:00 2001 From: Alexander Bayandin Date: Mon, 27 Jan 2025 21:17:59 +0000 Subject: [PATCH] check-codestyle-rust: check diesel schema --- .github/workflows/_check-codestyle-rust.yml | 33 +++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/.github/workflows/_check-codestyle-rust.yml b/.github/workflows/_check-codestyle-rust.yml index cbc47c640640..df177d32d5f0 100644 --- a/.github/workflows/_check-codestyle-rust.yml +++ b/.github/workflows/_check-codestyle-rust.yml @@ -30,6 +30,9 @@ jobs: password: ${{ secrets.NEON_DOCKERHUB_PASSWORD }} options: --init + permissions: + id-token: write # .github/actions/download + steps: - name: Checkout uses: actions/checkout@v4 @@ -89,3 +92,33 @@ jobs: - name: Check rust licenses/bans/advisories/sources if: ${{ !cancelled() }} run: cargo deny check --hide-inclusion-graph + + # To check diesel schema, we need any version of Postgres, so get it from build artifacts + - name: Download Latest Neon artifact + if: ${{ !cancelled() }} + uses: ./.github/actions/download + with: + name: neon-${{ runner.os }}-${{ runner.arch }}-release-artifact + path: /tmp/neon/ + prefix: latest + aws-oicd-role-arn: ${{ vars.DEV_AWS_OIDC_ROLE_ARN }} + + - name: Check diesel schema + if: ${{ !cancelled() }} + env: + POSTGRES_DISTRIB_DIR: /tmp/neon/pg_install + DATABASE_URL: postgresql://localhost:1235/storage_controller + run: | + export LD_LIBRARY_PATH=${POSTGRES_DISTRIB_DIR}/v16/lib + + cargo neon init + cargo neon storage_controller start + + diesel print-schema > storage_controller/src/schema.rs + + if [ -n "$(git diff storage_controller/src/schema.rs)" ]; then + echo >&2 "Uncommitted changes in diesel schema" + + git diff . + exit 1 + fi