From fc8174ada6df5f1f104fe6e60eea440ca48a030d Mon Sep 17 00:00:00 2001 From: Jon Gjengset Date: Fri, 27 Dec 2024 15:58:40 +0100 Subject: [PATCH] Fix release build (#193) PR #179 broke release builds by making it necessary for `LiveAskQuestion` and `SEED` to both now be available regardless of whether `debug_assertions` is set. That's unfortunate, since `SEED` in particular would make the binary quite large. So I've instead made it so that in release mode (or rather, without `debug_assertions`), `SEED` is _not_ compiled in, and DynamoDB mode is _always_ used. I've also added a CI job to check `--release --target aarch64-unknown-linux-gnu` so that this can't happen in the future. --- .github/workflows/check.yml | 19 ++++++++++++++++++- server/src/main.rs | 5 ++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index fff3220..7f2dbb9 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -39,8 +39,25 @@ jobs: with: components: rustfmt - name: cargo fmt --check - run: cargo fmt --check --manifest-path server/Cargo.toml run: cargo fmt --check + in_release_mode_on_arm: + runs-on: ubuntu-latest + name: stable / release-arm + defaults: + run: + working-directory: ./server + steps: + - uses: actions/checkout@v4 + with: + submodules: true + - name: Install stable + uses: dtolnay/rust-toolchain@stable + - name: rustup target add aarch64-unknown-linux-gnu + run: rustup target add aarch64-unknown-linux-gnu + - name: Install aarch64-gcc + run: sudo apt-get install gcc-aarch64-linux-gnu + - name: cargo check --release --target aarch64-unknown-linux-gnu + run: cargo check --release --target aarch64-unknown-linux-gnu clippy: runs-on: ubuntu-latest name: ${{ matrix.toolchain }} / clippy diff --git a/server/src/main.rs b/server/src/main.rs index f895bdd..d8ac3ca 100644 --- a/server/src/main.rs +++ b/server/src/main.rs @@ -167,7 +167,10 @@ async fn main() -> Result<(), Error> { .with_env_filter(EnvFilter::from_default_env()) .without_time(/* cloudwatch does that */).init(); - let backend = if !cfg!(debug_assertions) || std::env::var_os("USE_DYNAMODB").is_some() { + #[cfg(not(debug_assertions))] + let backend = Backend::dynamo().await; + #[cfg(debug_assertions)] + let backend = if std::env::var_os("USE_DYNAMODB").is_some() { Backend::dynamo().await } else { use rand::prelude::SliceRandom;