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

Commit

Permalink
Automate publishing docs on CirclrCI (#2486)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
Jinlin Zhang and buck-bot authored Jun 29, 2020
1 parent 1c31c5b commit da5384f
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 19 deletions.
57 changes: 42 additions & 15 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,13 @@ windows_environment: &windows_environment
BUCK_NUM_THREADS: 3
BUCK_PEX_LOCATION: "./new_buck.pex"

tags_only_filter: &tags_only_filter
filters:
tags:
only: /^v20.*/
branches:
ignore: /.*/

jobs:
linux_build_openjdk8:
environment:
Expand Down Expand Up @@ -1226,6 +1233,36 @@ jobs:
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
shell: bash.exe

publish_docs:
environment:
<<: *linux_environment
working_directory: "/home/circleci/buck"
machine:
image: ubuntu-1604:201903-01
steps:
- checkout
- run:
<<: *install_openjdk8
- run:
# android_sdk needed to build java docs.
<<: *install_android_sdk
- run:
<<: *install_python
- run:
# We do not want to build buck, install the latest release instead.
name: Install Buck
command: |
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}'`
curl -L -O $url
filename=`basename ${url}`
sudo dpkg -i ${filename} || echo "Warning: Buck installed without dependencies."
- run:
name: Publish docs
command: |
export ANDROID_HOME="${ANDROID_SDK}"
cd docs
./publish.sh --start-soyweb
workflows:
version: 2.1
linux_jobs:
Expand Down Expand Up @@ -1260,20 +1297,10 @@ workflows:
publish_jobs:
jobs:
- macos_publish_release:
filters:
tags:
only: /^v20.*/
branches:
ignore: /.*/
<<: *tags_only_filter
- linux_publish_release:
filters:
tags:
only: /^v20.*/
branches:
ignore: /.*/
<<: *tags_only_filter
- windows_publish_release:
filters:
tags:
only: /^v20.*/
branches:
ignore: /.*/
<<: *tags_only_filter
- publish_docs:
<<: *tags_only_filter
6 changes: 5 additions & 1 deletion docs/publish.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ EOF
exit 1
}

GIT_USER="buck-bot"
CNAME="buck.build"
START_SOYWEB=0
KEEP_FILES=0
SOYWEB_PID=0
Expand Down Expand Up @@ -83,7 +85,7 @@ echo "Documentation working directory is ${STATIC_FILES_DIR}"
# Create a clean checkout of the gh-pages branch with no data:
if [ -z "$1" ]
then
git clone git@github.com:facebook/buck.git $STATIC_FILES_DIR
git clone https://${GIT_USER}:${GITHUB_TOKEN}@github.com/facebook/buck.git $STATIC_FILES_DIR
else
cp -r "$1" $STATIC_FILES_DIR
fi
Expand All @@ -101,6 +103,8 @@ cd -

# Commit the new version of the docs:
cd $STATIC_FILES_DIR
echo "${CNAME}" > CNAME
git config --global user.name "${GIT_USER}"
git add .
git commit -m "Updated HTML documentation."

Expand Down
5 changes: 2 additions & 3 deletions docs/soy2html.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def main(output_dir):
):
# Copy the static resource to output_dir.
relative_path = os.path.join(root, file_name)
with open(relative_path) as resource_file:
with open(relative_path, "rb") as resource_file:
resource = resource_file.read()
copy_to_output_dir(relative_path, output_dir, resource)

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

def copy_to_output_dir(path, output_dir, content):
output_file = ensure_dir(path, output_dir)
with open(output_file, "w") as f:
with open(output_file, "wb") as f:
f.write(content)


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


if __name__ == "__main__":
output_dir = sys.argv[1]
pollForServerReady()
Expand Down

0 comments on commit da5384f

Please sign in to comment.