Skip to content

Commit

Permalink
Test that rust generated files do compile
Browse files Browse the repository at this point in the history
  • Loading branch information
hchataing committed Nov 22, 2023
1 parent 2945f45 commit 06da5ed
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,6 @@ jobs:

- name: Run Python generator tests
run: pdl-compiler/tests/run_python_generator_tests.sh

- name: Compile Rust generated files
run: pdl-compiler/tests/compile_rust_generated_files.sh
41 changes: 41 additions & 0 deletions pdl-compiler/tests/compile_rust_generated_files.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/bin/env bash

set -euxo pipefail

mkdir -p out/
OUT_DIR="$(pwd)/out"

# move to `pdl-compiler` directory
cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." &> /dev/null

mkdir -p "$OUT_DIR/generated_test/src"
./tests/generated_files_compile.sh tests/generated/*.rs > "$OUT_DIR/generated_test/src/lib.rs"

cat <<EOT > "$OUT_DIR/generated_test/Cargo.toml"
[package]
name = "generated_test"
version = "0.0.0"
publish = false
edition = "2021"
[features]
default = ["serde"]
[dependencies]
bytes = {version = "1.4.0", features = ["serde"]}
thiserror = "1.0.47"
serde_json = "1.0.86"
[dependencies.serde]
version = "1.0.145"
features = ["default", "derive", "serde_derive", "std", "rc"]
optional = true
[dependencies.pdl-runtime]
path = "../../pdl-runtime"
[workspace]
EOT

cd "$OUT_DIR/generated_test"
RUSTFLAGS=-Awarnings cargo build

0 comments on commit 06da5ed

Please sign in to comment.