From f459b84f3dabc81c68d2e7e0d4a71b89819aebda Mon Sep 17 00:00:00 2001 From: "Thomas S." Date: Fri, 8 Nov 2024 15:01:18 +0100 Subject: [PATCH] ci: Ensure documentation can be built (#702) Currently, a pull-request on `sphinx/` or `skore/` can break documentation building and be merged without notice. --- ![image](https://github.com/user-attachments/assets/66273013-e0a3-4309-a535-7b6998650658) --- .github/actions/sphinx/build/action.yml | 12 +++++++ .github/actions/sphinx/deploy/action.yml | 18 +++++++++++ .github/workflows/sphinx.yml | 40 +++++++----------------- .gitignore | 3 ++ 4 files changed, 45 insertions(+), 28 deletions(-) create mode 100644 .github/actions/sphinx/build/action.yml create mode 100644 .github/actions/sphinx/deploy/action.yml diff --git a/.github/actions/sphinx/build/action.yml b/.github/actions/sphinx/build/action.yml new file mode 100644 index 000000000..74af5c68c --- /dev/null +++ b/.github/actions/sphinx/build/action.yml @@ -0,0 +1,12 @@ +name: Build sphinx documentation +runs: + using: composite + steps: + - working-directory: skore + shell: bash + run: | + python -m pip install --upgrade pip + python -m pip install '.[sphinx]' + - working-directory: sphinx + shell: bash + run: make html diff --git a/.github/actions/sphinx/deploy/action.yml b/.github/actions/sphinx/deploy/action.yml new file mode 100644 index 000000000..2a8c99a46 --- /dev/null +++ b/.github/actions/sphinx/deploy/action.yml @@ -0,0 +1,18 @@ +name: Deploy sphinx documentation +permissions: + contents: write +runs: + using: composite + steps: + - shell: bash + run: | + rm -rf docs/latest + mv sphinx/build/html docs/latest + - shell: bash + run: | + git config user.name 'github-actions[bot]' + git config user.email 'github-actions[bot]@users.noreply.github.com' + + git add docs/latest + git commit -m 'docs: Build documentation triggered by ${{ github.sha }}' + git push diff --git a/.github/workflows/sphinx.yml b/.github/workflows/sphinx.yml index 0b7216101..b602fc874 100644 --- a/.github/workflows/sphinx.yml +++ b/.github/workflows/sphinx.yml @@ -1,26 +1,27 @@ name: Sphinx on: + pull_request: + paths: + - '.github/actions/sphinx/**' + - '.github/workflows/sphinx.yml' + - 'examples/**' + - 'sphinx/**' + - 'skore/**' push: branches: - main paths: + - '.github/actions/sphinx/**' - '.github/workflows/sphinx.yml' - 'examples/**' - - 'skore/**' - 'sphinx/**' - -permissions: - contents: write + - 'skore/**' concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true -defaults: - run: - shell: bash - jobs: sphinx: runs-on: ubuntu-latest @@ -32,23 +33,6 @@ jobs: with: python-version: '3.12' cache: 'pip' - - name: Build - run: | - python -m pip install --upgrade pip - python -m pip install './skore[sphinx]' - - ( \ - cd sphinx; \ - make html; \ - ) - - rm -rf docs/latest - mv sphinx/build/html docs/latest - - name: Commit - run: | - git config user.name 'github-actions[bot]' - git config user.email 'github-actions[bot]@users.noreply.github.com' - - git add docs/latest - git commit -m 'docs: Build documentation triggered by ${{ github.sha }}' - git push + - uses: ./.github/actions/sphinx/build + - if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} + uses: ./.github/actions/sphinx/deploy diff --git a/.gitignore b/.gitignore index a71a681f5..5dd9dbced 100644 --- a/.gitignore +++ b/.gitignore @@ -183,3 +183,6 @@ sphinx/auto_examples/ sphinx/generated/ sphinx/sg_execution_times.rst examples/plot_*.png + +# Include excluded directories from github-actions +!/.github/**/build/