|
| 1 | +name: Build mkl_random documentation |
| 2 | +on: |
| 3 | + pull_request: |
| 4 | + push: |
| 5 | + branches: [master] |
| 6 | + |
| 7 | +permissions: read-all |
| 8 | + |
| 9 | +jobs: |
| 10 | + build-and-deploy: |
| 11 | + name: Build and Deploy Documentation |
| 12 | + runs-on: ubuntu-latest |
| 13 | + permissions: |
| 14 | + contents: write |
| 15 | + pull-requests: write |
| 16 | + steps: |
| 17 | + - name: Cancel Previous Runs |
| 18 | + |
| 19 | + with: |
| 20 | + access_token: ${{ github.token }} |
| 21 | + - name: Add Intel repository |
| 22 | + if: ${{ !github.event.pull_request || github.event.action != 'closed' }} |
| 23 | + run: | |
| 24 | + wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB |
| 25 | + sudo apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB |
| 26 | + rm GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB |
| 27 | + sudo add-apt-repository "deb https://apt.repos.intel.com/oneapi all main" |
| 28 | + sudo apt-get update |
| 29 | + - name: Install Intel OneAPI |
| 30 | + if: ${{ !github.event.pull_request || github.event.action != 'closed' }} |
| 31 | + run: | |
| 32 | + sudo apt-get install intel-oneapi-compiler-dpcpp-cpp intel-oneapi-mkl-devel |
| 33 | + - name: Setup Python |
| 34 | + if: ${{ !github.event.pull_request || github.event.action != 'closed' }} |
| 35 | + uses: actions/setup-python@v5 |
| 36 | + with: |
| 37 | + python-version: '3.11' |
| 38 | + architecture: x64 |
| 39 | + - name: Install sphinx dependencies |
| 40 | + if: ${{ !github.event.pull_request || github.event.action != 'closed' }} |
| 41 | + shell: bash -l {0} |
| 42 | + run: | |
| 43 | + pip install numpy cython setuptools scikit-build cmake sphinx sphinx_rtd_theme furo pydot graphviz sphinxcontrib-programoutput sphinxcontrib-googleanalytics sphinx_design |
| 44 | + - name: Checkout repo |
| 45 | + |
| 46 | + with: |
| 47 | + fetch-depth: 0 |
| 48 | + persist-credentials: false |
| 49 | + - name: Build mkl_random+docs |
| 50 | + if: ${{ !github.event.pull_request || github.event.action != 'closed' }} |
| 51 | + shell: bash -l {0} |
| 52 | + run: | |
| 53 | + # Ensure that SYCL libraries are on LD_LIBRARY_PATH |
| 54 | + source /opt/intel/oneapi/setvars.sh |
| 55 | + python setup.py develop |
| 56 | + python -c "import mkl_random; print(mkl_random.__version__)" || exit 1 |
| 57 | + sphinx-build -M html docs/source docs/build |
| 58 | + mkdir -p ~/rendered_docs |
| 59 | + cp -r docs/build/html/* ~/rendered_docs/ |
| 60 | + git clean -dfx |
| 61 | + - name: Save built docs as an artifact |
| 62 | + if: ${{ github.event.pull_request && github.event.action != 'closed'}} |
| 63 | + uses: actions/upload-artifact@v4 |
| 64 | + with: |
| 65 | + name: ${{ env.PACKAGE_NAME }} rendered documentation |
| 66 | + path: ~/rendered_docs |
| 67 | + - name: Configure git |
| 68 | + if: ${{ !github.event.pull_request && github.event.action != 'closed'}} |
| 69 | + run: | |
| 70 | + git config --local user.email "[email protected]" |
| 71 | + git config --local user.name "mkl_random-doc-bot" |
| 72 | + timeout-minutes: 5 |
| 73 | + - name: Checkout gh-pages |
| 74 | + if: ${{ !github.event.pull_request && github.event.action != 'closed'}} |
| 75 | + run: | |
| 76 | + git fetch --all |
| 77 | + git checkout gh-pages |
| 78 | + - name: 'Copy build to root' |
| 79 | + if: ${{ !github.event.pull_request && github.event.action != 'closed'}} |
| 80 | + run: | |
| 81 | + cp -R ~/rendered_docs/* . |
| 82 | + timeout-minutes: 10 |
| 83 | + - name: 'Commit changes' |
| 84 | + if: ${{ !github.event.pull_request && github.event.action != 'closed'}} |
| 85 | + run: | |
| 86 | + git add . && git commit -m "Deploy: ${{ github.sha }}" |
| 87 | + continue-on-error: true |
| 88 | + timeout-minutes: 10 |
| 89 | + - name: Publish changes |
| 90 | + if: ${{ success() && !github.event.pull_request && github.event.action != 'closed'}} |
| 91 | + run: | |
| 92 | + git push origin gh-pages |
| 93 | + timeout-minutes: 10 |
0 commit comments