-
Notifications
You must be signed in to change notification settings - Fork 450
266 lines (224 loc) · 9.82 KB
/
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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
name: Docs
on:
workflow_dispatch:
push:
branches:
- main
- docs
- dev/docs
tags:
- "v*"
pull_request:
branches:
- main
- docs
- dev/docs
jobs:
build:
runs-on: ubuntu-20.04
permissions:
issues: write
pull-requests: write
contents: write
steps:
- name: Checkout Code
uses: actions/checkout@v3
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}
submodules: true
fetch-depth: 0
- uses: dorny/paths-filter@v2
id: changes
with:
filters: |
src:
- 'docs/**'
- name: Setup Java11
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '11'
- uses: actions/setup-node@v3
with:
node-version: 16
- name: Leave a marker
if: ${{ steps.changes.outputs.src == 'true' && github.event_name == 'pull_request' }}
run: |
touch ${GITHUB_WORKSPACE}/preview-the-docs.mark
- name: Leave the comment on pull request when started
if: ${{ steps.changes.outputs.src == 'true' && github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == 'alibaba/GraphScope' }}
uses: actions-cool/maintain-one-comment@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
body: |
⚡️ Deploying PR Preview ${{ github.event.pull_request.head.sha }} to [surge.sh](https://alibaba-graphscope-build-pr-${{ github.event.number }}.surge.sh) ... [Build logs](https://github.com/alibaba/GraphScope/runs/${{ github.run_id }})
<a href="https://github.com/alibaba/GraphScope/actions/runs/${{ github.run_id }}">
<img width="300" src="https://user-images.githubusercontent.com/507615/90240294-8d2abd00-de5b-11ea-8140-4840a0b2d571.gif">
</a>
<sub>🤖 By [surge-preview](https://surge.sh/)</sub>
body-include: '<!-- Sticky Pull Request Comment: Surge Preview build -->'
- name: Cpp Format and Lint Check
run: |
# install clang-format
sudo curl -L https://github.com/muttleyxd/clang-tools-static-binaries/releases/download/master-22538c65/clang-format-8_linux-amd64 --output /usr/bin/clang-format
sudo chmod +x /usr/bin/clang-format
# run format
cd analytical_engine/
find ./apps ./benchmarks ./core ./frame ./misc ./test -name "*.h" | xargs clang-format -i --style=file
find ./apps ./benchmarks ./core ./frame ./misc ./test -name "*.cc" | xargs clang-format -i --style=file
# validate format
function prepend() { while read line; do echo "${1}${line}"; done; }
GIT_DIFF=$(git diff --ignore-submodules)
if [[ -n $GIT_DIFF ]]; then
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
echo "| clang-format failures found!"
echo "|"
echo "$GIT_DIFF" | prepend "| "
echo "|"
echo "| Run: "
echo "|"
echo "| make gsa_clformat"
echo "|"
echo "| to fix this error."
echo "|"
echo "| Ensure you are working with clang-format-8, which can be obtained from"
echo "|"
echo "| https://github.com/muttleyxd/clang-tools-static-binaries/releases"
echo "|"
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
exit -1
fi
- name: Java Format and Lint Check
run: |
wget https://github.com/google/google-java-format/releases/download/v1.13.0/google-java-format-1.13.0-all-deps.jar
files_to_format=$(git ls-files *.java)
# run formatter in-place
java -jar ${GITHUB_WORKSPACE}/google-java-format-1.13.0-all-deps.jar --aosp --skip-javadoc-formatting -i $files_to_format
# validate format
function prepend() { while read line; do echo "${1}${line}"; done; }
GIT_DIFF=$(git diff --ignore-submodules)
if [[ -n $GIT_DIFF ]]; then
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
echo "| google-java-format failures found!"
echo "|"
echo "$GIT_DIFF" | prepend "| "
echo "|"
echo "| Run: "
echo "|"
echo '| java -jar google-java-format-1.13.0-all-deps.jar --aosp --skip-javadoc-formatting -i $(git ls-files **/*.java)'
echo "|"
echo "| to fix this error."
echo "|"
echo "| Ensure you are working with google-java-format-1.13.0, which can be obtained from"
echo "|"
echo "| https://github.com/google/google-java-format/releases/download/v1.13.0/google-java-format-1.13.0-all-deps.jar"
echo "|"
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
exit -1
fi
- name: Python Format and Lint Check
run: |
echo "Checking formatting for $GITHUB_REPOSITORY"
pip3 install -r coordinator/requirements-dev.txt
pip3 install -r python/requirements-dev.txt
pushd python
python3 -m isort --check --diff .
python3 -m black --check --diff .
python3 -m flake8 .
popd
pushd coordinator
python3 -m isort --check --diff .
python3 -m black --check --diff .
python3 -m flake8 .
- name: Generate Docs
shell: bash
run: |
# Install pip dependencies, build builtin gar, and generate proto stuffs.
sudo apt update
sudo apt install -y doxygen graphviz
# generate a taged version
cd ${GITHUB_WORKSPACE}
make graphscope-docs
# generate a stable version
tag=$(git describe --exact-match --tags HEAD 2>/dev/null || true)
if [ ! -z "$tag" ];
then
export TAG_VER=stable
make graphscope-docs
fi
- name: Preview using surge
if: ${{ steps.changes.outputs.src == 'true' && github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == 'alibaba/GraphScope' }}
run: |
npm install -g surge
surge ./docs/_build/latest/html \
alibaba-graphscope-build-pr-${{ github.event.number }}.surge.sh \
--token ${{ secrets.SURGE_TOKEN }}
- name: Leave the comment on pull request when succeed
if: ${{ steps.changes.outputs.src == 'true' && github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == 'alibaba/GraphScope' }}
uses: actions-cool/maintain-one-comment@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
body: |
🎊 PR Preview ${{ github.event.pull_request.head.sha }} has been successfully built and deployed to https://alibaba-graphscope-build-pr-${{ github.event.number }}.surge.sh
<a href="https://github.com/alibaba/GraphScope/actions/runs/${{ github.run_id }}">
<img width="300" src="https://user-images.githubusercontent.com/507615/90250366-88233900-de6e-11ea-95a5-84f0762ffd39.png">
</a>
<sub>🤖 By [surge-preview](https://surge.sh/)</sub>
body-include: '<!-- Sticky Pull Request Comment: Surge Preview build -->'
- name: Check file existence
id: check_files
if: ${{ failure() }}
uses: andstor/file-existence-action@v2
with:
files: "preview-the-docs.mark"
- name: Leave the comment on pull request when failed
if: ${{ failure() && steps.check_files.outputs.files_exists == 'true' && github.event.pull_request.head.repo.full_name == 'alibaba/GraphScope' }}
uses: actions-cool/maintain-one-comment@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
body: |
😭 Deploy PR Preview ${{ github.event.pull_request.head.sha }} failed. [Build logs](https://github.com/alibaba/GraphScope/runs/${{ github.run_id }})
<a href="https://github.com/alibaba/GraphScope/actions/runs/${{ github.run_id }}">
<img width="300" src="https://user-images.githubusercontent.com/507615/90250824-4e066700-de6f-11ea-8230-600ecc3d6a6b.png">
</a>
<sub>🤖 By [surge-preview](https://surge.sh/)</sub>
body-include: '<!-- Sticky Pull Request Comment: Surge Preview build -->'
- name: Setup tmate session
uses: mxschmitt/action-tmate@v3
if: false
- name: Upload Docs
if: ${{ github.event_name == 'push' && github.repository == 'alibaba/GraphScope' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')) }}
shell: bash
run: |
shopt -s extglob
rm google-java-format-1.13.0-all-deps.jar* || true
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
tag=$(git describe --exact-match --tags HEAD 2>/dev/null || true)
git fetch origin gh-pages --no-recurse-submodules
git checkout gh-pages
cd docs/
if [ -d "_build/latest" ];
then
rm -rf latest
cp -R _build/latest/html ./latest
else
rm -rf latest
cp -R _build/${tag}/html ./latest
rm -rf ${tag}
cp -R _build/${tag}/html ./${tag}
fi
if [ -d "_build/stable" ];
then
rm -rf !(_build|latest|stable|v*)
cp -R _build/stable/html/* ./
fi
rm -rf _build/
rm -rf ../flex/ || true
rm -rf ../learning_engine/ || true
rm -rf ../python || true
rm -rf ../analytical_engine/java || true
git add -A
git commit --amend --no-edit -m "Generate latest docs on CI, from commit ${{ github.sha }}." --author "github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>" -s --date="$(date -R)"
git push -f origin gh-pages