-
Notifications
You must be signed in to change notification settings - Fork 28.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SPARK-50295][INFRA] Add a script to build docs with image #48860
Changes from all commits
d46541f
3a434ec
e9dedf4
4d3cac5
913f525
ddc06ba
eb5b4df
088a8ac
8217ead
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
#!/usr/bin/env bash | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we document this in docs/README.md? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure, let me do it as a follow up pr. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please review: #49013 |
||
|
||
# | ||
# Licensed to the Apache Software Foundation (ASF) under one or more | ||
# contributor license agreements. See the NOTICE file distributed with | ||
# this work for additional information regarding copyright ownership. | ||
# The ASF licenses this file to You under the Apache License, Version 2.0 | ||
# (the "License"); you may not use this file except in compliance with | ||
# the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
if ! [ -x "$(command -v docker)" ]; then | ||
echo "Error: Docker is not installed." >&2 | ||
exit 1 | ||
fi | ||
|
||
DOCKER_CACHE_IMG="ghcr.io/apache/spark/apache-spark-github-action-image-docs-cache:master" | ||
REPO_OWNER="apache/spark" | ||
REPOSITORY="apache-spark-ci-image-docs" | ||
IMG_TAG=$(date +%s) | ||
IMG_NAME="${REPOSITORY}:${IMG_TAG}" | ||
IMG_URL="$REPO_OWNER/$IMG_NAME" | ||
DOCKER_MOUNT_SPARK_HOME="/__w/spark/spark" | ||
BUILD_DOCS_SCRIPT_PATH="${DOCKER_MOUNT_SPARK_HOME}/dev/spark-test-image-util/docs/run-in-container" | ||
|
||
FWDIR="$(cd "`dirname "${BASH_SOURCE[0]}"`"; pwd)" | ||
SPARK_HOME="$(cd "`dirname "${BASH_SOURCE[0]}"`"/../../..; pwd)" | ||
|
||
# 1.Compile spark outside the container to prepare for generating documents inside the container. | ||
build/sbt -Phive -Pkinesis-asl clean unidoc package | ||
|
||
# 2.Build container image. | ||
docker buildx build \ | ||
--cache-from type=registry,ref="${DOCKER_CACHE_IMG}" \ | ||
--tag "${IMG_URL}" "${FWDIR}" \ | ||
--file "${SPARK_HOME}/dev/spark-test-image/docs/Dockerfile" | ||
|
||
# 3.Build docs on container: `error docs`, `scala doc`, `python doc`, `sql doc`. | ||
docker run \ | ||
--mount type=bind,source="${SPARK_HOME}",target="${DOCKER_MOUNT_SPARK_HOME}" \ | ||
--interactive --tty "${IMG_URL}" \ | ||
/bin/bash -c "sh ${BUILD_DOCS_SCRIPT_PATH}" | ||
|
||
# 4.Build docs on host: `r doc`. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Given that SparkR is deprecated and has fewer changes, how about respecting SKIP_RDOC here? So that developers don't need to have an R env installed on the host. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point, I have also thought about this question. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Second thought, we can also passthrough There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is a difference, we do not want to run There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we run |
||
# | ||
# Why does `r` document need to be compiled outside the container? | ||
# Because when compiling inside the container, the permission of the directory | ||
# `/__w/spark/spark/R/pkg/docs` automatically generated by `RScript` is `dr-xr--r-x`, | ||
# and when writing to subsequent files, will throw an error as: | ||
# `! [EACCES] Failed to copy '/usr/local/lib/R/site-library/pkgdown/BS5/assets/katex-auto.js' | ||
# to '/__w/spark/spark/R/pkg/docs/katex-auto.js': permission denied` | ||
export SKIP_ERRORDOC=1 | ||
export SKIP_SCALADOC=1 | ||
export SKIP_PYTHONDOC=1 | ||
export SKIP_SQLDOC=1 | ||
cd docs | ||
bundle exec jekyll build | ||
|
||
# 5.Remove container image. | ||
IMG_ID=$(docker images | grep "${IMG_TAG}" | awk '{print $3}') | ||
docker image rm --force "${IMG_ID}" | ||
|
||
echo "Build doc done." |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# | ||
# Licensed to the Apache Software Foundation (ASF) under one or more | ||
# contributor license agreements. See the NOTICE file distributed with | ||
# this work for additional information regarding copyright ownership. | ||
# The ASF licenses this file to You under the Apache License, Version 2.0 | ||
# (the "License"); you may not use this file except in compliance with | ||
# the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
# 1.Set env variable. | ||
export JAVA_HOME=/usr/lib/jvm/java-17-openjdk-arm64 | ||
export PATH=$JAVA_HOME/bin:$PATH | ||
export SPARK_DOCS_IS_BUILT_ON_HOST=1 | ||
# We expect to compile the R document on the host. | ||
export SKIP_RDOC=1 | ||
|
||
# 2.Install bundler. | ||
gem install bundler -v 2.4.22 | ||
cd /__w/spark/spark/docs | ||
bundle install | ||
|
||
# 3.Build docs, includes: `error docs`, `scala doc`, `python doc`, `sql doc`, excludes: `r doc`. | ||
# We need this link to make sure `python3` points to `python3.9` which contains the prerequisite packages. | ||
ln -s "$(which python3.9)" "/usr/local/bin/python3" | ||
|
||
# Build docs first with SKIP_API to ensure they are buildable without requiring any | ||
# language docs to be built beforehand. | ||
cd /__w/spark/spark/docs | ||
bundle exec jekyll build |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the script seems does not have
x
permission, you can grant it bychmod a+x <path>
and the git will record permissions correctly in UNIX-like OS.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.