Merge pull request #1858 from IntelPython/fix-test-windows-step-in-co… #5141
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Generate documentation | |
on: | |
push: | |
branches: | |
- master | |
pull_request: | |
types: [opened, synchronize, reopened, closed] | |
permissions: read-all | |
jobs: | |
build-and-deploy: | |
name: Build and Deploy Documentation | |
runs-on: ubuntu-latest | |
timeout-minutes: 240 | |
permissions: | |
contents: write | |
pull-requests: write | |
steps: | |
- name: Cancel Previous Runs | |
uses: styfle/cancel-workflow-action@0.12.1 | |
with: | |
access_token: ${{ github.token }} | |
- name: Add Intel repository | |
if: ${{ !github.event.pull_request || github.event.action != 'closed' }} | |
run: | | |
wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB | |
sudo apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB | |
rm GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB | |
sudo add-apt-repository "deb https://apt.repos.intel.com/oneapi all main" | |
sudo apt-get update | |
- name: Install Intel OneAPI | |
if: ${{ !github.event.pull_request || github.event.action != 'closed' }} | |
run: | | |
sudo apt-get install intel-oneapi-compiler-dpcpp-cpp | |
- name: Install Lua | |
if: ${{ !github.event.pull_request || github.event.action != 'closed' }} | |
run: | | |
sudo apt-get install liblua5.2-dev | |
- name: Install Doxygen | |
if: ${{ !github.event.pull_request || github.event.action != 'closed' }} | |
run: | | |
sudo apt-get install doxygen | |
- name: Install Ninja | |
if: ${{ !github.event.pull_request || github.event.action != 'closed' }} | |
run: | | |
sudo apt-get install ninja-build | |
- name: Setup Python | |
if: ${{ !github.event.pull_request || github.event.action != 'closed' }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.10' | |
architecture: x64 | |
- name: Install sphinx dependencies | |
if: ${{ !github.event.pull_request || github.event.action != 'closed' }} | |
shell: bash -l {0} | |
run: | | |
pip install numpy cython setuptools scikit-build cmake sphinx"<7.2" pydot graphviz furo \ | |
sphinxcontrib-programoutput sphinxcontrib-googleanalytics sphinx-design \ | |
sphinxcontrib-jsmath sphinx-copybutton sphinxcontrib-spelling \ | |
versioneer[toml]==0.29 | |
- name: Checkout repo | |
uses: actions/checkout@v4.2.0 | |
with: | |
fetch-depth: 0 | |
persist-credentials: false | |
- name: Build dpctl+docs | |
if: ${{ !github.event.pull_request || github.event.action != 'closed' }} | |
shell: bash -l {0} | |
run: | | |
# Ensure that SYCL libraries are on LD_LIBRARY_PATH | |
source /opt/intel/oneapi/setvars.sh | |
wget https://github.com/vovkos/doxyrest/releases/download/doxyrest-2.1.2/doxyrest-2.1.2-linux-amd64.tar.xz | |
tar xf doxyrest-2.1.2-linux-amd64.tar.xz | |
python setup.py develop -G Ninja --build-type=Release \ | |
-- \ | |
-DCMAKE_C_COMPILER:PATH=$(which icx) \ | |
-DCMAKE_CXX_COMPILER:PATH=$(which icpx) \ | |
-DDPCTL_GENERATE_DOCS=ON \ | |
-DDPCTL_ENABLE_DOXYREST=ON \ | |
-DDoxyrest_DIR=`pwd`/doxyrest-2.1.2-linux-amd64 \ | |
-DCMAKE_VERBOSE_MAKEFILE=ON | |
python -c "import dpctl; print(dpctl.__version__)" || exit 1 | |
pushd "$(find _skbuild -name cmake-build)" || exit 1 | |
cmake --build . --target Sphinx || exit 1 | |
mv ../cmake-install/docs/docs ~/docs | |
git clean -dfx | |
popd | |
git reset --hard | |
- name: Publish docs | |
if: ${{ !github.event.pull_request && github.ref == 'refs/heads/master' }} | |
shell: bash -l {0} | |
run: | | |
git remote add tokened_docs https://IntelPython:${{ secrets.GITHUB_TOKEN }}@github.com/IntelPython/dpctl.git | |
git fetch tokened_docs | |
git checkout --track tokened_docs/gh-pages | |
echo `pwd` | |
cd master | |
git rm -rf * | |
mv ~/docs/* . || exit 1 | |
git add . | |
git config --global user.name 'github-actions[doc-deploy-bot]' | |
git config --global user.email 'github-actions[doc-deploy-bot]@users.noreply.github.com' | |
git commit -m "Latest docs." | |
git push tokened_docs gh-pages | |
- name: Save built docs as an artifact | |
if: ${{ github.event.pull_request && github.event.pull_request.head.repo.fork && github.event.action != 'closed'}} | |
uses: actions/upload-artifact@v4.4.0 | |
with: | |
name: ${{ env.PACKAGE_NAME }} rendered documentation | |
path: ~/docs | |
- name: Publish pull-request docs | |
if: ${{ github.event.pull_request && !github.event.pull_request.head.repo.fork && github.event.action != 'closed' }} | |
env: | |
PR_NUM: ${{ github.event.number }} | |
shell: bash -l {0} | |
run: | | |
git remote add tokened_docs https://IntelPython:${{ secrets.GITHUB_TOKEN }}@github.com/IntelPython/dpctl.git | |
git fetch tokened_docs | |
git checkout --track tokened_docs/gh-pages | |
echo `pwd` | |
[ -d pulls/${PR_NUM} ] && git rm -rf pulls/${PR_NUM} | |
mkdir -p pulls/${PR_NUM} | |
cd pulls/${PR_NUM} | |
mv ~/docs/* . | |
git add . | |
git config --global user.name 'github-actions[doc-deploy-bot]' | |
git config --global user.email 'github-actions[doc-deploy-bot]@users.noreply.github.com' | |
git commit -m "Docs for pull request ${PR_NUM}" | |
git push tokened_docs gh-pages | |
- name: Unpublish pull-request docs | |
if: ${{ github.event.pull_request && !github.event.pull_request.head.repo.fork && github.event.action == 'closed' }} | |
env: | |
PR_NUM: ${{ github.event.number }} | |
shell: bash -l {0} | |
run: | | |
git remote add tokened_docs https://IntelPython:${{ secrets.GITHUB_TOKEN }}@github.com/IntelPython/dpctl.git | |
git fetch tokened_docs | |
git checkout --track tokened_docs/gh-pages | |
echo `pwd` | |
ls | |
[ -d pulls ] && ls pulls && echo "This is pull/${PR_NUM}" | |
[ -d pulls/${PR_NUM} ] && git rm -rf pulls/${PR_NUM} | |
git config --global user.name 'github-actions[doc-deploy-bot]' | |
git config --global user.email 'github-actions[doc-deploy-bot]@users.noreply.github.com' | |
git commit -m "Removing docs for closed pull request ${PR_NUM}" | |
git push tokened_docs gh-pages | |
- name: Comment with URL to published pull-request docs | |
if: ${{ github.event.pull_request && !github.event.pull_request.head.repo.fork && github.event.action != 'closed' }} | |
env: | |
PR_NUM: ${{ github.event.number }} | |
uses: mshick/add-pr-comment@v2 | |
with: | |
message: | | |
View rendered docs @ https://intelpython.github.io/dpctl/pulls/${{ env.PR_NUM }}/index.html | |
repo-token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Comment with URL about removal of PR docs | |
if: ${{ github.event.pull_request && !github.event.pull_request.head.repo.fork && github.event.action == 'closed' }} | |
env: | |
PR_NUM: ${{ github.event.number }} | |
uses: mshick/add-pr-comment@v2 | |
with: | |
message: | | |
Deleted rendered PR docs from intelpython.github.com/dpctl, latest should be updated shortly. :crossed_fingers: | |
repo-token: ${{ secrets.GITHUB_TOKEN }} |