|
| 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-lang-rust |
| 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-lang-rust |
| 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: Build Rust documentation |
| 44 | + working-directory: zephyr-lang-rust |
| 45 | + run: | |
| 46 | + # Note that the above build doesn't set Zephyrbase, so we'll need to do that here. |
| 47 | + west build -t rustdoc -b nrf52840dk/nrf52840 docgen |
| 48 | + mkdir rustdocs |
| 49 | + mv build/rust/target/thumbv7em-none-eabi/doc rustdocs/nostd |
| 50 | + cp docs/top-index.html rustdocs/index.html |
| 51 | +
|
| 52 | + - name: Build build documentation |
| 53 | + working-directory: zephyr-lang-rust |
| 54 | + run: | |
| 55 | + cd zephyr-build |
| 56 | + cargo doc |
| 57 | + mv target/doc ../rustdocs/std |
| 58 | +
|
| 59 | + - name: Upload docs artifact |
| 60 | + uses: actions/upload-artifact@v4 |
| 61 | + with: |
| 62 | + name: rustdocs |
| 63 | + path: zephyr-lang-rust/rustdocs |
| 64 | + |
| 65 | + doc-publish: |
| 66 | + name: Publish Rust Documentation |
| 67 | + needs: generate-docs |
| 68 | + runs-on: ubuntu-latest |
| 69 | + if: | |
| 70 | + github.event_name == 'pull_request' && |
| 71 | + github.repository == 'zephyrproject-rtos/zephyr-lang-rust' |
| 72 | +
|
| 73 | + steps: |
| 74 | + # - name: Show github context |
| 75 | + # env: |
| 76 | + # GITHUB_CONTEXT: ${{ toJson(github) }} |
| 77 | + # run: | |
| 78 | + # echo "$GITHUB_CONTEXT" | jq . |
| 79 | + |
| 80 | + - name: Download documentation artifact |
| 81 | + uses: actions/download-artifact@v4 |
| 82 | + with: |
| 83 | + name: rustdocs |
| 84 | + |
| 85 | + # - name: Show our tree |
| 86 | + # run: | |
| 87 | + # find . -ls |
| 88 | + |
| 89 | + - name: Publish to S3 |
| 90 | + env: |
| 91 | + AWS_ACCESS_KEY_ID: ${{ vars.AWS_BUILDS_ZEPHYR_LANG_RUST_PR_ACCESS_KEY_ID }} |
| 92 | + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_BUILDS_ZEPHYR_LANG_RUST_PR_SECRET_ACCESS_KEY }} |
| 93 | + AWS_REGION: us-east-1 |
| 94 | + run: | |
| 95 | + PR_NUM=${{ github.event.number || 'not-a-pr' }} |
| 96 | + aws s3 sync --only-show-errors . s3://builds.zephyrproject.org/zephyr-lang-rust/pr/$PR_NUM/ |
0 commit comments