Skip to content

Commit 503bc72

Browse files
authored
CI: add diesel print-schema check (#10527)
## Problem We want to check that `diesel print-schema` doesn't generate any changes (`storage_controller/src/schema.rs`) in comparison with the list of migration. ## Summary of changes - Add `diesel_cli` to `build-tools` image - Add `Check diesel schema` step to `build-neon` job, at this stage we have all required binaries, so don't need to compile anything additionally - Check runs only on x86 release builds to be sure we do it at least once per CI run.
1 parent 89cff08 commit 503bc72

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

.github/workflows/_build-and-test-locally.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,26 @@ jobs:
271271
path: /tmp/neon
272272
aws-oicd-role-arn: ${{ vars.DEV_AWS_OIDC_ROLE_ARN }}
273273

274+
- name: Check diesel schema
275+
if: inputs.build-type == 'release' && inputs.arch == 'x64'
276+
env:
277+
DATABASE_URL: postgresql://localhost:1235/storage_controller
278+
POSTGRES_DISTRIB_DIR: /tmp/neon/pg_install
279+
run: |
280+
/tmp/neon/bin/neon_local init
281+
/tmp/neon/bin/neon_local storage_controller start
282+
283+
diesel print-schema > storage_controller/src/schema.rs
284+
285+
if [ -n "$(git diff storage_controller/src/schema.rs)" ]; then
286+
echo >&2 "Uncommitted changes in diesel schema"
287+
288+
git diff .
289+
exit 1
290+
fi
291+
292+
/tmp/neon/bin/neon_local storage_controller stop
293+
274294
# XXX: keep this after the binaries.list is formed, so the coverage can properly work later
275295
- name: Merge and upload coverage data
276296
if: inputs.build-type == 'debug'

.github/workflows/_check-codestyle-rust.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ defaults:
1616
run:
1717
shell: bash -euxo pipefail {0}
1818

19+
# No permission for GITHUB_TOKEN by default; the **minimal required** set of permissions should be granted in each job.
20+
permissions: {}
21+
1922
jobs:
2023
check-codestyle-rust:
2124
strategy:

build-tools.Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ ARG CARGO_HAKARI_VERSION=0.9.33
261261
ARG CARGO_DENY_VERSION=0.16.2
262262
ARG CARGO_HACK_VERSION=0.6.33
263263
ARG CARGO_NEXTEST_VERSION=0.9.85
264+
ARG CARGO_DIESEL_CLI_VERSION=2.2.6
264265
RUN curl -sSO https://static.rust-lang.org/rustup/dist/$(uname -m)-unknown-linux-gnu/rustup-init && whoami && \
265266
chmod +x rustup-init && \
266267
./rustup-init -y --default-toolchain ${RUSTC_VERSION} && \
@@ -274,6 +275,8 @@ RUN curl -sSO https://static.rust-lang.org/rustup/dist/$(uname -m)-unknown-linux
274275
cargo install cargo-deny --locked --version ${CARGO_DENY_VERSION} && \
275276
cargo install cargo-hack --version ${CARGO_HACK_VERSION} && \
276277
cargo install cargo-nextest --version ${CARGO_NEXTEST_VERSION} && \
278+
cargo install diesel_cli --version ${CARGO_DIESEL_CLI_VERSION} \
279+
--features postgres-bundled --no-default-features && \
277280
rm -rf /home/nonroot/.cargo/registry && \
278281
rm -rf /home/nonroot/.cargo/git
279282

0 commit comments

Comments
 (0)