near / nearcore

Reference client for NEAR Protocol
https://near.org
GNU General Public License v3.0
2.32k stars 622 forks source link

Setup rustdoc #7836

Open matklad opened 2 years ago

matklad commented 2 years ago

We already have workflow to generate some static HTML files from data in this repo and publish it to github pages:

https://github.com/near/nearcore/blob/4732a850d4ccb8c53d5573e50f99acc36262997d/.github/workflows/book.yml#L12

https://near.github.io/nearcore/

I think it would be an easy win to generate rustdoc API docs from master as well, some folks find those very useful.

matklad commented 2 years ago

Ok, I gave this a crack, I think this should be as simple as

diff --git a/.github/workflows/book.yml b/.github/workflows/pages.yml
similarity index 61%
rename from .github/workflows/book.yml
rename to .github/workflows/pages.yml
index 0fe9db24f..1ffe8f1ba 100644
--- a/.github/workflows/book.yml
+++ b/.github/workflows/pages.yml
@@ -1,3 +1,8 @@
+# This workflow builds GitHub pages at https://near.github.io/nearcore/
+# Currently, we host two things there:
+#  * mdBook build form `./docs`
+#  * rustdoc build from inline `///` code comments
+
 name: Book

 on:
@@ -27,16 +32,32 @@ jobs:
       with:
         name: book
         path: target/book
+  rustdoc:
+    name: rustdoc
+    runs-on: ubuntu-latest
+    steps:
+    - uses: actions/checkout@v2
+    - name: Build Docs
+      run: |
+        cargo doc --no-deps --document-private-items
+    - uses: actions/upload-artifact@v2
+      with:
+        name: rustdoc
+        path: target/doc

   deploy:
     name: Deploy
     runs-on: ubuntu-latest
-    needs: book
+    needs: [book, rustdoc]
     if: github.event_name == 'push' && github.ref == 'refs/heads/master'
     steps:
     - uses: actions/download-artifact@v2
       with:
         name: book
+    - uses: actions/download-artifact@v2
+      with:
+        name: rustdoc
+        path: ./rustdoc
     - uses: peaceiris/actions-gh-pages@v3
       with:
         github_token: ${{ secrets.GITHUB_TOKEN }}

However, the builds for docs takes >15 minutes, which I think is a non-starter.

I think this is mostly due to the docs trying to build rocks from source. This should be avoidable by apt-get installing rocks and setting ROCKSDB_LIB_DIR=/usr/lib/x86_64-linux-gnu, but that seems brittle enough which for me moves this from "obvious easy win" to "creeping technical debt".

akhi3030 commented 2 years ago

Should we track this issue as "nice to have" under https://github.com/near/nearcore/issues/7670?