diff --git a/.github/workflows/doc_dev.yml b/.github/workflows/doc_dev.yml new file mode 100644 index 0000000..4d2d609 --- /dev/null +++ b/.github/workflows/doc_dev.yml @@ -0,0 +1,50 @@ +name: documentation_dev +on: + pull_request_target: + branches: + - main + types: [closed] + push: + branches: + - main + + +permissions: + contents: write + +jobs: + docs: + runs-on: ubuntu-latest + steps: + - name: Wait for version update + run: | + sleep 60 + - name: Checkout + uses: actions/checkout@v4 + - uses: actions/setup-python@v4 + with: + python-version: '3.10' + + - name: Install dependencies + run: | + pip install . + - name: Sphinx build + run: | + poetry run sphinx-build docs _build + - uses: actions/checkout@v4 + with: + # This is necessary so that we have the tags. + fetch-depth: 0 + ref: gh-pages + path: gh_pages + - name: copy stable and preview version changes + run: | + cp -rv gh_pages/preview_pr _build/preview_pr || echo "Ignoring exit status" + - name: Deploy to GitHub Pages + uses: peaceiris/actions-gh-pages@v3 + if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} + with: + publish_branch: gh-pages + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: _build/ + force_orphan: true diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml new file mode 100644 index 0000000..b027fc4 --- /dev/null +++ b/.github/workflows/preview.yml @@ -0,0 +1,115 @@ +name: "preview" + +on: + workflow_run: + workflows: ["ready_for_review"] + types: + - completed + +concurrency: + group: ${{ github.ref }} + cancel-in-progress: true + +jobs: + docs: + runs-on: ubuntu-latest + if: ${{ github.event.workflow_run.conclusion == 'success' }} + steps: + - name: Download workflow artifact + uses: dawidd6/action-download-artifact@v2.11.0 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + workflow: peek_icons.yml + run_id: ${{ github.event.workflow_run.id }} + + - name: Read the pr_num file + id: pr_num_reader + uses: juliangruber/read-file-action@v1.0.0 + with: + path: ./pr_num/pr_num.txt + + - name: Checkout + uses: actions/checkout@v4 + with: + path: main + - name: Checkout Pull Request + env: + GITHUB_USER: ${{ secrets.GITHUB_USER }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + cd main + gh pr checkout ${{ steps.pr_num_reader.outputs.content }} + cd .. + + - uses: actions/setup-python@v4 + with: + python-version: '3.10' + + - name: Install and configure Poetry + uses: snok/install-poetry@v1 + - name: Install dependencies and build doc + run: | + set +e + cd main + curl -C - https://raw.githubusercontent.com/rlberry-py/rlberry/main/pyproject.toml > pyproject.toml + poetry install --all-extras --with dev --sync + poetry run sphinx-build docs ../_build + echo "exitcode=$?" >> $GITHUB_ENV + cd .. + + - uses: actions/checkout@v4 + with: + # This is necessary so that we have the tags. + fetch-depth: 0 + ref: gh-pages + path: gh_pages + + - name: Commit documentation changes + if: ${{ env.exitcode == 0 }} + run: | + cd gh_pages + rm -r preview_pr || echo "Ignoring exit status" + mkdir preview_pr + cp -rv ../_build/* preview_pr + git config user.name github-actions + git config user.email github-actions@github.com + git add . + git commit -m "Preview documentation" + git push + - name: Comment on the PR about the result + uses: jungwinter/comment@v1 # let us comment on a specific PR + if: ${{ env.exitcode == 0 }} + env: + MESSAGE: | + Hello, + The build of the doc succeeded. The documentation preview is available here: + https://rlberry-py.github.io/rlberry/preview_pr + + with: + type: create + issue_number: ${{ steps.pr_num_reader.outputs.content }} + token: ${{ secrets.GITHUB_TOKEN }} + body: > + ${{ format(env.MESSAGE, + fromJSON(steps.icons_overview_img_step.outputs.markdown_urls)[0], + join(fromJSON(steps.icons_detailed_img_step.outputs.markdown_urls), '')) }} + + - name: Comment on the PR about the result, fail + uses: jungwinter/comment@v1 # let us comment on a specific PR + if: ${{ env.exitcode != 0 }} + env: + MESSAGE: | + Hello, + The build of the doc failed. Look up the reason here: + https://github.com/rlberry-py/rlberry/actions/workflows/preview.yml + + with: + type: create + issue_number: ${{ steps.pr_num_reader.outputs.content }} + token: ${{ secrets.GITHUB_TOKEN }} + body: > + ${{ format(env.MESSAGE, + fromJSON(steps.icons_overview_img_step.outputs.markdown_urls)[0], + join(fromJSON(steps.icons_detailed_img_step.outputs.markdown_urls), '')) }} + - name: Exit + run: exit "$exitcode" diff --git a/.github/workflows/ready_for_review.yml b/.github/workflows/ready_for_review.yml new file mode 100644 index 0000000..ec1e0fd --- /dev/null +++ b/.github/workflows/ready_for_review.yml @@ -0,0 +1,26 @@ +name: ready_for_review + +on: + pull_request: + types: [labeled, opened, reopened, synchronize] + +jobs: + build: + if: contains( github.event.pull_request.labels.*.name, 'ready for review') + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: Run a one-line script + run: echo ready for review! + - name: Save the PR number in an artifact + shell: bash + env: + PR_NUM: ${{ github.event.number }} + run: echo $PR_NUM > pr_num.txt + + - name: Upload the PR number + uses: actions/upload-artifact@v2 + with: + name: pr_num + path: ./pr_num.txt diff --git a/docs/api.rst b/docs/api.rst index 8c9f1aa..8f79eba 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -1,8 +1,8 @@ .. _api: -########### -rlberry API -########### +################# +rlberry-scool API +################# Manager diff --git a/docs/conf.py b/docs/conf.py index b0817fe..32d4b7d 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -26,7 +26,6 @@ copyright = "2023, rlberry team" author = "rlberry team" - ver_file = os.path.join("../rlberry_scool", "_version.py") with open(ver_file) as f: exec(f.read()) diff --git a/docs/requirements.txt b/docs/requirements.txt index f400b95..6aebac9 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -7,4 +7,3 @@ git+https://github.com/sphinx-contrib/video matplotlib nbsphinx sphinx-tabs -rlberry