From c1ccd0e214ad51e3c151a27ccd9dbacb02e4be6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20Kr=C3=BCger?= Date: Thu, 25 Jul 2024 15:15:48 +0200 Subject: [PATCH 01/10] ci: Generate docs for each PR --- .github/workflows/docs.yaml | 52 +++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 .github/workflows/docs.yaml diff --git a/.github/workflows/docs.yaml b/.github/workflows/docs.yaml new file mode 100644 index 0000000000..99101ae6ea --- /dev/null +++ b/.github/workflows/docs.yaml @@ -0,0 +1,52 @@ +name: Docs Preview + +on: + pull_request: + +jobs: + preview_docs: + timeout-minutes: 30 + name: Docs preview + if: "github.event_name == 'pull_request'" + runs-on: ubuntu-latest + env: + RUSTC_WRAPPER: "sccache" + SCCACHE_GHA_ENABLED: "on" + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@master + with: + toolchain: nightly-2024-05-02 + - name: Install sccache + uses: mozilla-actions/sccache-action@v0.0.5 + + - name: Generate Docs + run: cargo doc --workspace --all-features --no-deps --document-private-items + env: + RUSTDOCFLAGS: --cfg docsrs + + - name: Deploy Docs to GitHub Pages + uses: peaceiris/actions-gh-pages@v4 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: ./target/doc + destination_dir: ${{ github.event.pull_request.number }} + + - name: Find Docs Comment + uses: peter-evans/find-comment@v3 + id: fc + with: + issue-number: ${{ github.event.pull_request.number }} + comment-author: 'github-actions[bot]' + body-includes: Documentation for this PR has been generated + + - name: Create or Update Docs Comment + uses: peter-evans/create-or-update-comment@v4 + with: + issue-number: ${{ github.event.pull_request.number }} + comment-id: ${{ steps.fc.outputs.comment-id }} + body: | + Documentation for this PR has been generated and is available at: https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/${{ github.event.pull_request.number }}/ + + Last updated: ${{ github.event.pull_request.updated_at }} + edit-mode: replace From 4a6aa6b2baaba17d57c4b9b0a376788df4766131 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20Kr=C3=BCger?= Date: Thu, 25 Jul 2024 15:23:36 +0200 Subject: [PATCH 02/10] refactor(ci): Deploy to subpath --- .github/workflows/docs.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docs.yaml b/.github/workflows/docs.yaml index 99101ae6ea..51966165f9 100644 --- a/.github/workflows/docs.yaml +++ b/.github/workflows/docs.yaml @@ -30,7 +30,7 @@ jobs: with: github_token: ${{ secrets.GITHUB_TOKEN }} publish_dir: ./target/doc - destination_dir: ${{ github.event.pull_request.number }} + destination_dir: pr/${{ github.event.pull_request.number }}/docs - name: Find Docs Comment uses: peter-evans/find-comment@v3 @@ -46,7 +46,7 @@ jobs: issue-number: ${{ github.event.pull_request.number }} comment-id: ${{ steps.fc.outputs.comment-id }} body: | - Documentation for this PR has been generated and is available at: https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/${{ github.event.pull_request.number }}/ + Documentation for this PR has been generated and is available at: https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/pr/${{ github.event.pull_request.number }}/docs/ Last updated: ${{ github.event.pull_request.updated_at }} edit-mode: replace From 5dd02f79932bb71444691c4612b2ba3c13a3a439 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20Kr=C3=BCger?= Date: Fri, 26 Jul 2024 09:48:47 +0200 Subject: [PATCH 03/10] fix: Avoid overwriting docs from concurrent previews --- .github/workflows/docs.yaml | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/.github/workflows/docs.yaml b/.github/workflows/docs.yaml index 51966165f9..966d30b3e0 100644 --- a/.github/workflows/docs.yaml +++ b/.github/workflows/docs.yaml @@ -12,6 +12,8 @@ jobs: env: RUSTC_WRAPPER: "sccache" SCCACHE_GHA_ENABLED: "on" + PREVIEW_PATH: pr/${{ github.event.pull_request.number }}/docs + steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@master @@ -25,12 +27,18 @@ jobs: env: RUSTDOCFLAGS: --cfg docsrs - - name: Deploy Docs to GitHub Pages + - name: Prepare Docs for Deployment + run: | + mkdir -p ${{ env.PREVIEW_PATH }} + cp -R target/doc/* ${{ env.PREVIEW_PATH }}/ + + - name: Deploy Docs to Preview Branch uses: peaceiris/actions-gh-pages@v4 with: github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: ./target/doc - destination_dir: pr/${{ github.event.pull_request.number }}/docs + publish_dir: . + publish_branch: generated-docs-preview + keep_files: true - name: Find Docs Comment uses: peter-evans/find-comment@v3 @@ -46,7 +54,7 @@ jobs: issue-number: ${{ github.event.pull_request.number }} comment-id: ${{ steps.fc.outputs.comment-id }} body: | - Documentation for this PR has been generated and is available at: https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/pr/${{ github.event.pull_request.number }}/docs/ + Documentation for this PR has been generated and is available at: https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/${{ env.PREVIEW_PATH }}/ Last updated: ${{ github.event.pull_request.updated_at }} edit-mode: replace From 89fc5fb091bfc26d192afc428161de9bb70a15a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20Kr=C3=BCger?= Date: Fri, 26 Jul 2024 09:57:56 +0200 Subject: [PATCH 04/10] fix: Avoid committing the whole PR's branch & use `destination_dir` --- .github/workflows/docs.yaml | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/.github/workflows/docs.yaml b/.github/workflows/docs.yaml index 966d30b3e0..abbe268b86 100644 --- a/.github/workflows/docs.yaml +++ b/.github/workflows/docs.yaml @@ -27,18 +27,13 @@ jobs: env: RUSTDOCFLAGS: --cfg docsrs - - name: Prepare Docs for Deployment - run: | - mkdir -p ${{ env.PREVIEW_PATH }} - cp -R target/doc/* ${{ env.PREVIEW_PATH }}/ - - name: Deploy Docs to Preview Branch uses: peaceiris/actions-gh-pages@v4 with: github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: . + publish_dir: ./target/doc/ + destination_dir: ${{ env.PREVIEW_PATH }} publish_branch: generated-docs-preview - keep_files: true - name: Find Docs Comment uses: peter-evans/find-comment@v3 @@ -57,4 +52,4 @@ jobs: Documentation for this PR has been generated and is available at: https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/${{ env.PREVIEW_PATH }}/ Last updated: ${{ github.event.pull_request.updated_at }} - edit-mode: replace + edit-mode: replace \ No newline at end of file From 6eee30f964d79284a9a2795900755dbf0efdad30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20Kr=C3=BCger?= Date: Fri, 26 Jul 2024 11:17:43 +0200 Subject: [PATCH 05/10] chore: Trigger deploy From 84cb433b0459a0d3987026132274566575658717 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20Kr=C3=BCger?= Date: Fri, 26 Jul 2024 11:23:44 +0200 Subject: [PATCH 06/10] fix: Use the correct link in the generated message --- .github/workflows/docs.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docs.yaml b/.github/workflows/docs.yaml index abbe268b86..c808b148b1 100644 --- a/.github/workflows/docs.yaml +++ b/.github/workflows/docs.yaml @@ -49,7 +49,7 @@ jobs: issue-number: ${{ github.event.pull_request.number }} comment-id: ${{ steps.fc.outputs.comment-id }} body: | - Documentation for this PR has been generated and is available at: https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/${{ env.PREVIEW_PATH }}/ + Documentation for this PR has been generated and is available at: https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/${{ env.PREVIEW_PATH }}/iroh/ Last updated: ${{ github.event.pull_request.updated_at }} - edit-mode: replace \ No newline at end of file + edit-mode: replace From 0206c26eb39a0743ed789739007837b96367a832 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20Kr=C3=BCger?= Date: Fri, 26 Jul 2024 11:25:55 +0200 Subject: [PATCH 07/10] chore: [cr] use stable rust toolchain --- .github/workflows/docs.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docs.yaml b/.github/workflows/docs.yaml index c808b148b1..8ae2fee47a 100644 --- a/.github/workflows/docs.yaml +++ b/.github/workflows/docs.yaml @@ -18,7 +18,7 @@ jobs: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@master with: - toolchain: nightly-2024-05-02 + toolchain: stable - name: Install sccache uses: mozilla-actions/sccache-action@v0.0.5 From cdebba010589106b54671fbed6ca9b3328738a2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20Kr=C3=BCger?= Date: Fri, 26 Jul 2024 11:30:19 +0200 Subject: [PATCH 08/10] Revert "chore: [cr] use stable rust toolchain" This reverts commit 0206c26eb39a0743ed789739007837b96367a832. --- .github/workflows/docs.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docs.yaml b/.github/workflows/docs.yaml index 8ae2fee47a..c808b148b1 100644 --- a/.github/workflows/docs.yaml +++ b/.github/workflows/docs.yaml @@ -18,7 +18,7 @@ jobs: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@master with: - toolchain: stable + toolchain: nightly-2024-05-02 - name: Install sccache uses: mozilla-actions/sccache-action@v0.0.5 From 63b09e7e6a6ad19a7af5b8d770d75bdeaa7cf6df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20Kr=C3=BCger?= Date: Fri, 26 Jul 2024 14:58:31 +0200 Subject: [PATCH 09/10] fix(ci): Explicitly set sscache cache size --- .github/workflows/docs.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/docs.yaml b/.github/workflows/docs.yaml index c808b148b1..c24bdfee44 100644 --- a/.github/workflows/docs.yaml +++ b/.github/workflows/docs.yaml @@ -12,6 +12,7 @@ jobs: env: RUSTC_WRAPPER: "sccache" SCCACHE_GHA_ENABLED: "on" + SCCACHE_CACHE_SIZE: "50G" PREVIEW_PATH: pr/${{ github.event.pull_request.number }}/docs steps: From 98d06ea71f5e11453a4ab0ae5b240617ffcbdd88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20Kr=C3=BCger?= Date: Fri, 26 Jul 2024 14:59:27 +0200 Subject: [PATCH 10/10] refactor(ci): Don't use `--document-private-items` --- .github/workflows/docs.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docs.yaml b/.github/workflows/docs.yaml index c24bdfee44..d9b51ec44f 100644 --- a/.github/workflows/docs.yaml +++ b/.github/workflows/docs.yaml @@ -24,7 +24,7 @@ jobs: uses: mozilla-actions/sccache-action@v0.0.5 - name: Generate Docs - run: cargo doc --workspace --all-features --no-deps --document-private-items + run: cargo doc --workspace --all-features --no-deps env: RUSTDOCFLAGS: --cfg docsrs