Skip to content

Commit 77285c4

Browse files
committed
CI: Add workflow for documentation generation
This attempts to build the project documentation, for PRs uploading it to a working directory for the PR. Signed-off-by: David Brown <[email protected]>
1 parent ce42e4b commit 77285c4

File tree

1 file changed

+90
-0
lines changed

1 file changed

+90
-0
lines changed

.github/workflows/docs.yml

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
name: Generate and Preview Rust Docs
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main # Only generate docs for PRs targeting main
7+
push:
8+
branches:
9+
- main
10+
workflow_dispatch:
11+
12+
permissions:
13+
contents: read
14+
15+
jobs:
16+
generate-docs:
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v4
22+
with:
23+
path: zephyr-rust-lang
24+
25+
- name: Set up Python
26+
uses: actions/setup-python@v5
27+
with:
28+
python-version: 3.11
29+
30+
- name: Setup Zephyr project
31+
uses: zephyrproject-rtos/action-zephyr-setup@v1
32+
with:
33+
app-path: zephyr-rust-lang
34+
manifest-file-name: ci-manifest.yml
35+
toolchains: arm-zephyr-eabi:riscv64-zephyr-elf
36+
37+
- name: Install Rust Targets
38+
shell: bash
39+
run: |
40+
rustup target add thumbv7em-none-eabi
41+
rustup target add thumbv7m-none-eabi
42+
43+
- name: Setup cargo build
44+
working-directory: zephyr-rust-lang
45+
run: |
46+
# Must do full build
47+
west build -b nrf52840dk/nrf52840 docgen
48+
49+
- name: Build Rust documentation
50+
working-directory: zephyr-rust-lang/docgen
51+
run: |
52+
rm -rf .cargo
53+
mkdir .cargo
54+
cd .cargo
55+
ln -s ../../build/rust/sample-cargo-config.toml config.toml
56+
cd ..
57+
cargo doc
58+
cd ..
59+
mkdir docout
60+
mv build/rust/target/thumbv7em-none-eabi/doc docout/nostd
61+
cp docs/top-index.html docout/index.html
62+
63+
- name: Build build documentation
64+
working-directory: zephyr-rust-lang
65+
run: |
66+
cd zephyr-build
67+
cargo doc
68+
mv target/doc ../docout/std
69+
70+
- name: Upload artifact
71+
uses: actions/upload-pages-artifact@v3
72+
with:
73+
path: zephyr-rust-lang/docout
74+
75+
deploy:
76+
needs: generate-docs
77+
permissions:
78+
pages: write
79+
id-token: write
80+
81+
environment:
82+
name: github-pages
83+
url: ${{ steps.deployment.outputs.page_url }}
84+
85+
runs-on: ubuntu-latest
86+
87+
steps:
88+
- name: Deploy to GitHub Pages
89+
id: deployment
90+
uses: actions/deploy-pages@v4

0 commit comments

Comments
 (0)