-
Notifications
You must be signed in to change notification settings - Fork 30
166 lines (163 loc) · 7.41 KB
/
generate-docs.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
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.1
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.3
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 }}