Skip to content

Commit 26c95f7

Browse files
committed
CI: add test-docs target to compile Rust code defined in docs
1 parent 234425b commit 26c95f7

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

.github/workflows/ci.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,32 @@ jobs:
115115
run: |
116116
make test-p2p
117117
118+
docs-tests:
119+
runs-on: ubuntu-22.04
120+
steps:
121+
- name: Git checkout
122+
uses: actions/checkout@v4
123+
124+
- name: Setup build dependencies
125+
run: |
126+
sudo apt update
127+
sudo apt install -y protobuf-compiler
128+
129+
- name: Setup Rust
130+
uses: dtolnay/rust-toolchain@stable
131+
with:
132+
components: rustfmt
133+
toolchain: 1.84
134+
135+
- name: Setup Rust Cache
136+
uses: Swatinem/rust-cache@v2
137+
with:
138+
prefix-key: "v0"
139+
140+
- name: Test documentation code examples
141+
run: |
142+
make test-docs
143+
118144
build:
119145
runs-on: ubuntu-22.04
120146
steps:

Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,11 @@ test-release: ## Run tests in release mode
217217
test-vrf: ## Run VRF tests, requires nightly Rust
218218
@cd vrf && cargo +nightly test --release -- -Z unstable-options --report-time
219219

220+
.PHONY: test-docs
221+
test-docs: ## Run documentation tests to verify code examples compile and run
222+
@echo "Testing documentation code examples..."
223+
cargo test --doc
224+
220225
# Docker build targets
221226

222227
.PHONY: docker-build-all

0 commit comments

Comments
 (0)