Skip to content

Commit

Permalink
ci: Ensure documentation can be built (#702)
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
thomass-dev authored Nov 8, 2024
1 parent 07c442d commit f459b84
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 28 deletions.
12 changes: 12 additions & 0 deletions .github/actions/sphinx/build/action.yml
Original file line number Diff line number Diff line change
@@ -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
18 changes: 18 additions & 0 deletions .github/actions/sphinx/deploy/action.yml
Original file line number Diff line number Diff line change
@@ -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
40 changes: 12 additions & 28 deletions .github/workflows/sphinx.yml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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/

0 comments on commit f459b84

Please sign in to comment.