From b1755e541e2c3bda514d39f051da27e57dfefe0e Mon Sep 17 00:00:00 2001 From: Yi Sun Date: Sat, 14 Dec 2024 20:19:54 -0500 Subject: [PATCH] feat: add initial rustdocs workflow (#1042) * feat: add initial rustdocs workflow * chore: add testing trigger * chore: change to fetch with CLI * chore: configure git * chore: replace github config * fix: Vercel env variable names * chore: remove no-deps * chore: fix index page * fix * cargo check for halo2 table * chore: switch to serving on s3 * chore: fix index page * typo --------- Co-authored-by: Jonathan Wang <31040440+jonathanpwang@users.noreply.github.com> --- .github/workflows/docs.yml | 64 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 .github/workflows/docs.yml diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml new file mode 100644 index 0000000000..d1feed19de --- /dev/null +++ b/.github/workflows/docs.yml @@ -0,0 +1,64 @@ +name: Build and Serve Crate Docs + +on: + push: + branches: [main] + tags: + - v*.*.* + pull_request: + branches: [main] + paths: + - ".github/workflows/docs.yml" + +env: + CARGO_NET_GIT_FETCH_WITH_CLI: true + +jobs: + docs: + permissions: + contents: write + packages: read + concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + runs-on: + - runs-on=${{ github.run_id }} + - runner=8cpu-linux-arm64 + steps: + - uses: actions/checkout@v4 + - name: Set up Rust toolchain + uses: dtolnay/rust-toolchain@nightly + + # TEMPORARY + - name: Give GitHub Actions access to private repositories + uses: webfactory/ssh-agent@v0.9.0 + with: + ssh-private-key: | + ${{ secrets.GH_ACTIONS_DEPLOY_PRIVATE_KEY }} + + - name: Cargo check + run: cargo check + + - name: Build documentation + run: cargo doc --workspace + + # We only want the index page to display workspace crates, so we build + # separately and copy over the index as a hack + - name: Build index page + run: | + cargo doc --workspace --no-deps --exclude "openvm-benchmarks" --target-dir target/doc-nodeps + cp target/doc-nodeps/doc/index.html target/doc/ + env: + RUSTDOCFLAGS: --enable-index-page -Zunstable-options + + - name: Install s5cmd + run: | + source ci/scripts/utils.sh + install_s5cmd + + # TODO: store versioned copy of docs when new v*.*.* tag is pushed + - name: Sync static S3 bucket + env: + S3_BUCKET: ${{ vars.CRATE_DOCS_S3_BUCKET }} + run: | + cd target/doc + s5cmd sync . s3://${S3_BUCKET%/}/static/