|
1 | | -# Workflow that deploy docs |
| 1 | +name: Documentation |
2 | 2 |
|
3 | | -name: Docs |
4 | | - |
5 | | -# Controls when the action will run. |
6 | 3 | on: |
7 | | - # Triggers the workflow on push or pull request events but only for the master branch |
8 | 4 | push: |
9 | | - branches: [ master ] |
| 5 | + branches: |
| 6 | + - develop # rebuild on every push to develop |
| 7 | + tags: |
| 8 | + - 'v*' # and on every version tag |
| 9 | + pull_request: |
| 10 | + branches: |
| 11 | + - develop # build (but don't deploy) on PRs, to catch breakage early |
| 12 | + workflow_dispatch: # allow manual triggers from the Actions UI |
10 | 13 |
|
11 | | - # Allows you to run this workflow manually from the Actions tab |
12 | | - workflow_dispatch: |
| 14 | +# Allow the workflow to write to the gh-pages branch and deploy Pages |
| 15 | +permissions: |
| 16 | + contents: write |
| 17 | + pages: write |
| 18 | + id-token: write |
13 | 19 |
|
| 20 | +# Only one deployment at a time; cancel in-progress runs on new pushes |
| 21 | +concurrency: |
| 22 | + group: pages |
| 23 | + cancel-in-progress: true |
14 | 24 |
|
15 | | -# A workflow run is made up of one or more jobs that can run sequentially or in parallel |
16 | 25 | jobs: |
17 | | - # This workflow contains a single job called "build" |
18 | | - docs: |
| 26 | + build-docs: |
| 27 | + name: Build Sphinx documentation |
| 28 | + runs-on: ubuntu-latest |
| 29 | + |
| 30 | + steps: |
| 31 | + - name: Checkout repository |
| 32 | + uses: actions/checkout@v4 |
| 33 | + with: |
| 34 | + # Full history lets setuptools-scm compute the version correctly |
| 35 | + fetch-depth: 0 |
| 36 | + |
| 37 | + - name: Set up Python |
| 38 | + uses: actions/setup-python@v5 |
| 39 | + with: |
| 40 | + python-version: '3.11' |
| 41 | + cache: pip |
| 42 | + |
| 43 | + - name: Install documentation dependencies |
| 44 | + run: | |
| 45 | + pip install --upgrade pip setuptools |
| 46 | + pip install -r docs/requirements.txt |
| 47 | +
|
| 48 | + # Install the package itself in "no-deps" mode so that autodoc can |
| 49 | + # import larndsim.* Heavy GPU/CUDA dependencies (numba, cupy, …) |
| 50 | + # are mocked inside conf.py, so we skip them entirely here. |
| 51 | + - name: Install larndsim (no heavy deps) |
| 52 | + run: | |
| 53 | + pip install --no-deps -e . |
| 54 | +
|
| 55 | + - name: Build HTML documentation |
| 56 | + run: | |
| 57 | + cd docs |
| 58 | + make html SPHINXOPTS="-v -W --keep-going -n" |
| 59 | + # -v verbose mode |
| 60 | + # -W turn warnings into errors to keep docs clean |
| 61 | + # -n nitpicky mode to catch broken cross-references |
| 62 | + # --keep-going report all errors, not just the first one |
| 63 | + |
| 64 | + - name: Upload Pages artifact |
| 65 | + # Only upload on pushes to develop / version tags (not on PRs) |
| 66 | + if: github.event_name != 'pull_request' |
| 67 | + uses: actions/upload-pages-artifact@v3 |
| 68 | + with: |
| 69 | + path: docs/build/html |
| 70 | + |
| 71 | + deploy-docs: |
| 72 | + name: Deploy to GitHub Pages |
| 73 | + needs: build-docs |
| 74 | + # Only deploy on pushes to develop / tags, not on PRs |
| 75 | + if: github.event_name != 'pull_request' |
19 | 76 | runs-on: ubuntu-latest |
| 77 | + |
| 78 | + environment: |
| 79 | + name: github-pages |
| 80 | + url: ${{ steps.deployment.outputs.page_url }} |
| 81 | + |
20 | 82 | steps: |
21 | | - - uses: actions/checkout@v2 |
22 | | - - name: Set up Python 3.8 |
23 | | - uses: actions/setup-python@v2 |
24 | | - with: |
25 | | - # Semantic version range syntax or exact version of a Python version |
26 | | - python-version: '3.8' |
27 | | - - uses: ammaraskar/sphinx-action@master |
28 | | - with: |
29 | | - docs-folder: "docs/" |
30 | | - pre-build-command: "sed -i 's/from ROOT/#from ROOT/g' cli/dumpTree.py; sed -i 's/from larndsim.cuda_dict/#from larndsim.cuda_dict/g' cli/simulate_pixels.py; sed -i 's/@cuda/#@cuda/g' larndsim/*.py; sed -i 's/import cupy/#import cupy/g' larndsim/light_sim.py; sed -i 's/import cupy/#import cupy/g' larndsim/fee.py; sed -i 's/import cupy/#import cupy/g' cli/simulate_pixels.py; sed -i 's/from cupy/#from cupy/g' cli/simulate_pixels.py; sed -i 's/from larpix/#from larpix/g' larndsim/fee.py" |
31 | | - - uses: actions/upload-artifact@v1 |
32 | | - with: |
33 | | - name: DocumentationHTML |
34 | | - path: docs/build/html/ |
35 | | - # Publish built docs to gh-pages branch. |
36 | | - # =============================== |
37 | | - - name: Commit documentation changes |
38 | | - run: | |
39 | | - git clone https://github.com/DUNE/larnd-sim.git --branch gh-pages --single-branch gh-pages |
40 | | - cp -r docs/build/html/* gh-pages/ |
41 | | - cd gh-pages |
42 | | - touch .nojekyll |
43 | | - git config --local user.email "action@github.com" |
44 | | - git config --local user.name "GitHub Action" |
45 | | - git add . |
46 | | - git commit -m "Update documentation" -a || true |
47 | | - # The above command will fail if no changes were present, so we ignore |
48 | | - # that. |
49 | | - - name: Push changes |
50 | | - uses: ad-m/github-push-action@master |
51 | | - with: |
52 | | - branch: gh-pages |
53 | | - directory: gh-pages |
54 | | - github_token: ${{ secrets.GITHUB_TOKEN }} |
| 83 | + - name: Deploy to GitHub Pages |
| 84 | + id: deployment |
| 85 | + uses: actions/deploy-pages@v4 |
0 commit comments