From 5958adcb079e3111cf462395b2f80e498b163210 Mon Sep 17 00:00:00 2001 From: Verda Korzeniewski Date: Thu, 27 Mar 2025 15:19:48 -0700 Subject: [PATCH 1/6] add autodoc action --- .github/workflows/docs.yml | 49 +++++++++++++++++++++ .github/workflows/generate-docs.yml | 66 +++++++++++++++++++++++++++++ 2 files changed, 115 insertions(+) create mode 100644 .github/workflows/docs.yml create mode 100644 .github/workflows/generate-docs.yml diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml new file mode 100644 index 0000000..9d73f8b --- /dev/null +++ b/.github/workflows/docs.yml @@ -0,0 +1,49 @@ +name: Generate Documentation + +on: + push: + branches: + - master + +jobs: + generate-docs: + runs-on: ubuntu-latest + + steps: + - name: Checkout kos-sim repository + uses: actions/checkout@v3 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.11' + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install pdoc3 + pip install -e . + + - name: Generate documentation + run: pdoc --html --output-dir ./kos_sim_docs --force kos_sim + + - name: Checkout api-docs repository + uses: actions/checkout@v3 + with: + repository: kscale/api-docs + token: ${{ secrets.API_DOCS_TOKEN }} + path: api-docs + + - name: Copy documentation to api-docs repository + run: | + mkdir -p api-docs/kos_sim + cp -r ./kos_sim_docs/kos_sim/* api-docs/kos_sim/ + + - name: Commit and push changes + run: | + cd api-docs + git config user.name "GitHub Actions Bot" + git config user.email "actions@github.com" + git add kos_sim/ + git commit -m "Update kos_sim documentation" || echo "No changes to commit" + git push \ No newline at end of file diff --git a/.github/workflows/generate-docs.yml b/.github/workflows/generate-docs.yml new file mode 100644 index 0000000..4ce8b24 --- /dev/null +++ b/.github/workflows/generate-docs.yml @@ -0,0 +1,66 @@ +name: Generate Documentation +on: + push: + branches: + - master + - auto-docs + workflow_dispatch: +jobs: + build-docs: + runs-on: ubuntu-latest + steps: + - name: Checkout source repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.11' + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -e . + pip install pdoc black loguru ks_digital_twin + - name: Generate documentation + run: | + export PATH=$pythonLocation/bin:$PATH + pdoc --output-dir ./docs kos_sim + - name: Setup GitHub CLI + run: | + gh auth setup-git + gh auth status + env: + GH_TOKEN: ${{ secrets.API_DOCS_TOKEN }} + - name: Checkout api-docs repository + uses: actions/checkout@v4 + with: + repository: kscalelabs/api-docs + path: api-docs + token: ${{ secrets.API_DOCS_TOKEN }} + - name: Copy documentation to api-docs + run: | + mkdir -p api-docs/kos_sim + cp -r docs/kos_sim/* api-docs/kos_sim/ + - name: Create PR for api-docs + run: | + cd api-docs + git config user.name "GitHub Actions" + git config user.email "actions@github.com" + # Create a new branch + BRANCH_NAME="update-docs-${{ github.sha }}" + git checkout -b $BRANCH_NAME + # Add and commit changes + git add . + git commit -m "Update documentation from ${{ github.sha }}" || { echo "No changes to commit"; exit 0; } + # Push to the repository with token authentication + git remote set-url origin "https://x-access-token:${{ secrets.API_DOCS_TOKEN }}@github.com/kscalelabs/api-docs.git" + git push -u origin $BRANCH_NAME + # Create PR directly in the original repo + gh pr create \ + --repo kscalelabs/api-docs \ + --title "Update documentation" \ + --body "Auto-generated documentation update from commit ${{ github.sha }}" \ + --head $BRANCH_NAME + env: + GH_TOKEN: ${{ secrets.API_DOCS_TOKEN }} From 4bd6e7f51850db9d0f6445bcddf42d8d60c9dab7 Mon Sep 17 00:00:00 2001 From: Verda Korzeniewski Date: Fri, 28 Mar 2025 14:01:10 -0700 Subject: [PATCH 2/6] add support for graphics env so pdoc can import module --- .github/workflows/generate-docs.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/generate-docs.yml b/.github/workflows/generate-docs.yml index 4ce8b24..d528d0a 100644 --- a/.github/workflows/generate-docs.yml +++ b/.github/workflows/generate-docs.yml @@ -17,6 +17,10 @@ jobs: uses: actions/setup-python@v4 with: python-version: '3.11' + - name: install system dependencies required by glfw/mujoco + run: | + sudo apt-get update + sudo apt-get install -y libgl1-mesa-glx libglfw3 libglfw3-dev xvfb - name: Install dependencies run: | python -m pip install --upgrade pip From a9edfec70246ba6fd97f8445aa2f5616e196ad2d Mon Sep 17 00:00:00 2001 From: Verda Korzeniewski Date: Fri, 28 Mar 2025 14:21:55 -0700 Subject: [PATCH 3/6] add opengl supporting libraries so pdoc can import kos_sim.server module --- .github/workflows/generate-docs.yml | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/.github/workflows/generate-docs.yml b/.github/workflows/generate-docs.yml index d528d0a..c67da5a 100644 --- a/.github/workflows/generate-docs.yml +++ b/.github/workflows/generate-docs.yml @@ -17,19 +17,25 @@ jobs: uses: actions/setup-python@v4 with: python-version: '3.11' - - name: install system dependencies required by glfw/mujoco + - name: install dependencies required by glfw/mujoco run: | sudo apt-get update - sudo apt-get install -y libgl1-mesa-glx libglfw3 libglfw3-dev xvfb + sudo apt-get install -y libosmesa6-dev libgl1-mesa-glx libglu1-mesa freeglut3-dev - name: Install dependencies run: | python -m pip install --upgrade pip + pip install PyOpenGL PyOpenGL-accelerate pip install -e . pip install pdoc black loguru ks_digital_twin - name: Generate documentation run: | - export PATH=$pythonLocation/bin:$PATH + export MUJOCO_GL=osmesa + export PYTHONPATH=$PYTHONPATH:$(pwd) + export PDOC_ALLOW_EXEC=1 pdoc --output-dir ./docs kos_sim + env: + MUJOCO_GL: osmesa + PDOC_ALLOW_EXEC: 1 - name: Setup GitHub CLI run: | gh auth setup-git From 04a976962763f768258336bccb8770e07f04ce0e Mon Sep 17 00:00:00 2001 From: Verda Korzeniewski Date: Fri, 28 Mar 2025 14:27:18 -0700 Subject: [PATCH 4/6] change libgl1-mesa-glx to match pckge name in gh actions ubuntu --- .github/workflows/generate-docs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/generate-docs.yml b/.github/workflows/generate-docs.yml index c67da5a..df2efef 100644 --- a/.github/workflows/generate-docs.yml +++ b/.github/workflows/generate-docs.yml @@ -20,7 +20,7 @@ jobs: - name: install dependencies required by glfw/mujoco run: | sudo apt-get update - sudo apt-get install -y libosmesa6-dev libgl1-mesa-glx libglu1-mesa freeglut3-dev + sudo apt-get install -y libosmesa6-dev libgl1 libglu1-mesa freeglut3-dev - name: Install dependencies run: | python -m pip install --upgrade pip From 2a0f1a25d213e05667217c46e260cf52c9f0f01f Mon Sep 17 00:00:00 2001 From: Verda Korzeniewski Date: Fri, 28 Mar 2025 16:22:40 -0700 Subject: [PATCH 5/6] push to master instead of making pr --- .github/workflows/generate-docs.yml | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/.github/workflows/generate-docs.yml b/.github/workflows/generate-docs.yml index df2efef..51a131e 100644 --- a/.github/workflows/generate-docs.yml +++ b/.github/workflows/generate-docs.yml @@ -52,25 +52,16 @@ jobs: run: | mkdir -p api-docs/kos_sim cp -r docs/kos_sim/* api-docs/kos_sim/ - - name: Create PR for api-docs + - name: Push directly to master branch run: | cd api-docs git config user.name "GitHub Actions" git config user.email "actions@github.com" - # Create a new branch - BRANCH_NAME="update-docs-${{ github.sha }}" - git checkout -b $BRANCH_NAME # Add and commit changes git add . git commit -m "Update documentation from ${{ github.sha }}" || { echo "No changes to commit"; exit 0; } # Push to the repository with token authentication git remote set-url origin "https://x-access-token:${{ secrets.API_DOCS_TOKEN }}@github.com/kscalelabs/api-docs.git" - git push -u origin $BRANCH_NAME - # Create PR directly in the original repo - gh pr create \ - --repo kscalelabs/api-docs \ - --title "Update documentation" \ - --body "Auto-generated documentation update from commit ${{ github.sha }}" \ - --head $BRANCH_NAME + git push origin master env: GH_TOKEN: ${{ secrets.API_DOCS_TOKEN }} From a6e6da11b0db7e06eb2d657bca0f6afdd635fca4 Mon Sep 17 00:00:00 2001 From: Verda <107901671+verdakode@users.noreply.github.com> Date: Fri, 28 Mar 2025 16:32:16 -0700 Subject: [PATCH 6/6] delete old workflow --- .github/workflows/docs.yml | 49 -------------------------------------- 1 file changed, 49 deletions(-) delete mode 100644 .github/workflows/docs.yml diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml deleted file mode 100644 index 9d73f8b..0000000 --- a/.github/workflows/docs.yml +++ /dev/null @@ -1,49 +0,0 @@ -name: Generate Documentation - -on: - push: - branches: - - master - -jobs: - generate-docs: - runs-on: ubuntu-latest - - steps: - - name: Checkout kos-sim repository - uses: actions/checkout@v3 - - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: '3.11' - - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install pdoc3 - pip install -e . - - - name: Generate documentation - run: pdoc --html --output-dir ./kos_sim_docs --force kos_sim - - - name: Checkout api-docs repository - uses: actions/checkout@v3 - with: - repository: kscale/api-docs - token: ${{ secrets.API_DOCS_TOKEN }} - path: api-docs - - - name: Copy documentation to api-docs repository - run: | - mkdir -p api-docs/kos_sim - cp -r ./kos_sim_docs/kos_sim/* api-docs/kos_sim/ - - - name: Commit and push changes - run: | - cd api-docs - git config user.name "GitHub Actions Bot" - git config user.email "actions@github.com" - git add kos_sim/ - git commit -m "Update kos_sim documentation" || echo "No changes to commit" - git push \ No newline at end of file