Skip to content

Commit b4ccdde

Browse files
committed
CI: Add bindings check before release
Also, add a serate check to make sure that the layout tests are still run from CI (since we disabled it from the main build step). Signed-off-by: Siddharth Chandrasekaran <sidcha.dev@gmail.com>
1 parent 2bdccff commit b4ccdde

3 files changed

Lines changed: 50 additions & 2 deletions

File tree

.github/workflows/build-ci.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,32 @@ jobs:
3232
run: sudo apt-get update && sudo apt-get install -y gcc-arm-none-eabi
3333
- name: Cargo check no-std
3434
run: cargo check --package libosdp --target thumbv6m-none-eabi --no-default-features
35+
36+
bindings-check:
37+
name: Regenerate bindings and check on ${{ matrix.target }}
38+
runs-on: ubuntu-latest
39+
strategy:
40+
matrix:
41+
target: [x86_64-unknown-linux-gnu, thumbv6m-none-eabi]
42+
env:
43+
LIBOSDP_SYS_REGENERATE_BINDINGS: "1"
44+
LIBOSDP_SYS_BINDGEN_LAYOUT_TESTS: "1"
45+
CCACHE_DISABLE: "1"
46+
steps:
47+
- name: checkout
48+
uses: actions/checkout@v5
49+
with:
50+
submodules: recursive
51+
- name: Setup rust
52+
uses: actions-rust-lang/setup-rust-toolchain@v1.9.0
53+
with:
54+
toolchain: stable
55+
target: ${{ matrix.target }}
56+
- name: Install gcc-arm-none-eabi
57+
if: matrix.target == 'thumbv6m-none-eabi'
58+
run: sudo apt-get update && sudo apt-get install -y gcc-arm-none-eabi
59+
- name: Regenerate bindings and cargo check
60+
run: cargo check -p libosdp-sys --target ${{ matrix.target }}
3561
test:
3662
runs-on: ubuntu-latest
3763
steps:

.github/workflows/publish-libosdp-sys.yml

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,27 @@ on:
1414
- 'libosdp-sys-v*'
1515

1616
jobs:
17+
bindings_match:
18+
name: Verify checked-in bindings
19+
runs-on: ubuntu-latest
20+
env:
21+
CCACHE_DISABLE: "1"
22+
LIBOSDP_SYS_REGENERATE_BINDINGS: "1"
23+
steps:
24+
- uses: actions/checkout@v5
25+
with:
26+
submodules: recursive
27+
- uses: actions-rust-lang/setup-rust-toolchain@v1.9.0
28+
with:
29+
toolchain: stable
30+
- name: Regenerate bindings
31+
run: cargo build -p libosdp-sys
32+
- name: Check bindings are committed
33+
run: git diff --exit-code -- libosdp-sys/src/bindings.rs
34+
1735
cross_platform_check:
1836
name: Build crate on ${{ matrix.os }}
37+
needs: [bindings_match]
1938
runs-on: ${{ matrix.os }}
2039
strategy:
2140
matrix:
@@ -31,7 +50,7 @@ jobs:
3150

3251
publish:
3352
name: Publish Crate
34-
needs: [cross_platform_check]
53+
needs: [bindings_match, cross_platform_check]
3554
runs-on: ubuntu-latest
3655
steps:
3756
- uses: actions/checkout@v5

libosdp-sys/build.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,14 +192,17 @@ fn main() -> Result<()> {
192192
/* regenerate bindings only when requested by maintainer */
193193
if std::env::var("LIBOSDP_SYS_REGENERATE_BINDINGS").as_deref() == Ok("1") {
194194
let mut args = vec![format!("-I{}", &out_dir)];
195+
let target = std::env::var("TARGET").unwrap();
196+
args.push(format!("--target={target}"));
195197
if short_enums {
196198
args.push("-fshort-enums".to_owned());
197199
} else {
198200
args.push("-fno-short-enums".to_owned());
199201
}
202+
let layout_tests = std::env::var("LIBOSDP_SYS_BINDGEN_LAYOUT_TESTS").as_deref() == Ok("1");
200203
let bindings = bindgen::Builder::default()
201204
.use_core()
202-
.layout_tests(false)
205+
.layout_tests(layout_tests)
203206
.header("vendor/include/osdp.h")
204207
.clang_args(args)
205208
.generate()

0 commit comments

Comments
 (0)