Skip to content
This repository was archived by the owner on Nov 10, 2023. It is now read-only.

Commit da5384f

Browse files
Jinlin Zhangbuck-bot
andauthored
Automate publishing docs on CirclrCI (#2486)
* Automate publishing docs on CirclrCI * Automate publishing docs on CircleCI * Automate publishing docs on CircleCI * Automate publishing docs using linux VM * Fixed Python3 compatible issues * Added code to install android_sdk * Automate docs, installed JDK for java docs * Automate publishing docs on CircleCI, added CNAME * Automate publishing docs deleted an extra line * Automate publishing docs, refactored code * Automate publishing docs, changed a required test name Co-authored-by: buck-bot <66389669+buck-bot@users.noreply.github.com>
1 parent 1c31c5b commit da5384f

File tree

3 files changed

+49
-19
lines changed

3 files changed

+49
-19
lines changed

.circleci/config.yml

Lines changed: 42 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,13 @@ windows_environment: &windows_environment
195195
BUCK_NUM_THREADS: 3
196196
BUCK_PEX_LOCATION: "./new_buck.pex"
197197

198+
tags_only_filter: &tags_only_filter
199+
filters:
200+
tags:
201+
only: /^v20.*/
202+
branches:
203+
ignore: /.*/
204+
198205
jobs:
199206
linux_build_openjdk8:
200207
environment:
@@ -1226,6 +1233,36 @@ jobs:
12261233
python3 ./tools/release/publish_release.py --no-build-deb --no-build-homebrew --github-token ${GITHUB_TOKEN} --chocolatey-token ${CHOCO_TOKEN} --use-existing-release --version ${VERSION} --output-dir artifacts
12271234
shell: bash.exe
12281235

1236+
publish_docs:
1237+
environment:
1238+
<<: *linux_environment
1239+
working_directory: "/home/circleci/buck"
1240+
machine:
1241+
image: ubuntu-1604:201903-01
1242+
steps:
1243+
- checkout
1244+
- run:
1245+
<<: *install_openjdk8
1246+
- run:
1247+
# android_sdk needed to build java docs.
1248+
<<: *install_android_sdk
1249+
- run:
1250+
<<: *install_python
1251+
- run:
1252+
# We do not want to build buck, install the latest release instead.
1253+
name: Install Buck
1254+
command: |
1255+
url=`curl -sH "Authorization: token ${GITHUB_TOKEN}" https://api.github.com/repos/facebook/buck/releases/latest |grep "browser_download_url.*deb" |awk '{gsub("\"", "", $2); print $2}'`
1256+
curl -L -O $url
1257+
filename=`basename ${url}`
1258+
sudo dpkg -i ${filename} || echo "Warning: Buck installed without dependencies."
1259+
- run:
1260+
name: Publish docs
1261+
command: |
1262+
export ANDROID_HOME="${ANDROID_SDK}"
1263+
cd docs
1264+
./publish.sh --start-soyweb
1265+
12291266
workflows:
12301267
version: 2.1
12311268
linux_jobs:
@@ -1260,20 +1297,10 @@ workflows:
12601297
publish_jobs:
12611298
jobs:
12621299
- macos_publish_release:
1263-
filters:
1264-
tags:
1265-
only: /^v20.*/
1266-
branches:
1267-
ignore: /.*/
1300+
<<: *tags_only_filter
12681301
- linux_publish_release:
1269-
filters:
1270-
tags:
1271-
only: /^v20.*/
1272-
branches:
1273-
ignore: /.*/
1302+
<<: *tags_only_filter
12741303
- windows_publish_release:
1275-
filters:
1276-
tags:
1277-
only: /^v20.*/
1278-
branches:
1279-
ignore: /.*/
1304+
<<: *tags_only_filter
1305+
- publish_docs:
1306+
<<: *tags_only_filter

docs/publish.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ EOF
3838
exit 1
3939
}
4040

41+
GIT_USER="buck-bot"
42+
CNAME="buck.build"
4143
START_SOYWEB=0
4244
KEEP_FILES=0
4345
SOYWEB_PID=0
@@ -83,7 +85,7 @@ echo "Documentation working directory is ${STATIC_FILES_DIR}"
8385
# Create a clean checkout of the gh-pages branch with no data:
8486
if [ -z "$1" ]
8587
then
86-
git clone git@github.com:facebook/buck.git $STATIC_FILES_DIR
88+
git clone https://${GIT_USER}:${GITHUB_TOKEN}@github.com/facebook/buck.git $STATIC_FILES_DIR
8789
else
8890
cp -r "$1" $STATIC_FILES_DIR
8991
fi
@@ -101,6 +103,8 @@ cd -
101103

102104
# Commit the new version of the docs:
103105
cd $STATIC_FILES_DIR
106+
echo "${CNAME}" > CNAME
107+
git config --global user.name "${GIT_USER}"
104108
git add .
105109
git commit -m "Updated HTML documentation."
106110

docs/soy2html.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def main(output_dir):
5757
):
5858
# Copy the static resource to output_dir.
5959
relative_path = os.path.join(root, file_name)
60-
with open(relative_path) as resource_file:
60+
with open(relative_path, "rb") as resource_file:
6161
resource = resource_file.read()
6262
copy_to_output_dir(relative_path, output_dir, resource)
6363

@@ -74,7 +74,7 @@ def ensure_dir(path, output_dir):
7474

7575
def copy_to_output_dir(path, output_dir, content):
7676
output_file = ensure_dir(path, output_dir)
77-
with open(output_file, "w") as f:
77+
with open(output_file, "wb") as f:
7878
f.write(content)
7979

8080

@@ -88,7 +88,6 @@ def pollForServerReady():
8888
time.sleep(1)
8989
print("Server failed to start after %s seconds." % SERVER_START_POLL)
9090

91-
9291
if __name__ == "__main__":
9392
output_dir = sys.argv[1]
9493
pollForServerReady()

0 commit comments

Comments
 (0)