Clean up build logic. (#5380)

- Swap the "build" and "gen" terms used in this repo to match
what we do in other repos. "gen" generates a bunch of files, which
is needed by "build". Unlike other repos, the output of "gen" doesn't
need to be checked in to Git however.

- The clean target now cleans the generated directory.

- Makefile.core.mk now defines SOURCE_BRANCH_NAME that decides which
branch we get reference material from. This makes it much simpler to
switch branches.

- Added the "update_all" target which does all the work needed to pull
in the imported content.
This commit is contained in:
Martin Taillefer 2019-11-05 10:24:45 -08:00 committed by GitHub
parent 6c3f5d2e85
commit 3304aceca3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 100 additions and 81 deletions

View File

@ -5,28 +5,28 @@ ifeq ($(CONTEXT),production)
baseurl := "$(URL)"
endif
build:
@scripts/build_site.sh
# Which branch of the Istio source code do we fetch stuff from
SOURCE_BRANCH_NAME ?= release-1.4
gen: build
@scripts/gen_site.sh ""
gen:
@scripts/gen_site.sh
gen_nominify: build
@scripts/gen_site.sh "" -no_minify
build: gen
@scripts/build_site.sh ""
build_nominify: gen
@scripts/build_site.sh "" -no_minify
opt:
@scripts/opt_site.sh
clean_public:
@rm -fr public
clean:
@rm -fr resources .htmlproofer tmp generated public
clean: clean_public
@rm -fr resources .htmlproofer tmp
lint: clean_public gen_nominify lint-copyright-banner lint-python lint-yaml lint-dockerfiles lint-scripts lint-sass lint-typescript lint-go
lint: clean_public build_nominify lint-copyright-banner lint-python lint-yaml lint-dockerfiles lint-scripts lint-sass lint-typescript lint-go
@scripts/lint_site.sh
serve: build
serve: gen
@hugo serve --baseURL "http://${ISTIO_SERVE_DOMAIN}:1313/" --bind 0.0.0.0 --disableFastRender
# used by netlify.com when building the site. The tool versions should correspond
@ -46,21 +46,25 @@ netlify_install:
@babel/polyfill@v7.4.4
netlify: netlify_install
@scripts/build_site.sh
@scripts/gen_site.sh "$(baseurl)"
@scripts/gen_site.sh
@scripts/build_site.sh "$(baseurl)"
netlify_archive: netlify_install archive
archive:
@scripts/gen_archive_site.sh "$(baseurl)"
@scripts/build_archive_site.sh "$(baseurl)"
update_ref_docs:
@scripts/grab_reference_docs.sh
@scripts/grab_reference_docs.sh $(SOURCE_BRANCH_NAME)
update_operator_yamls:
@scripts/grab_operator_yamls.sh
@scripts/grab_operator_yamls.sh $(SOURCE_BRANCH_NAME)
update_examples:
@scripts/grab_examples.sh
@scripts/grab_examples.sh $(SOURCE_BRANCH_NAME)
update_all: update_ref_docs update_operator_yaml update_examples
include common/Makefile.common.mk
.PHONY: gen build build_nominify opt clean_public clean lint serve netlify_install netlify netlify_archive archive update_ref_docs update_operator_yamls update_examples update_all

View File

@ -746,7 +746,7 @@ $ make ISTIO_SERVE_DOMAIN=192.168.7.105 serve
This will build the site and start a web server hosting the site. You can then connect to the web server
at `http://192.168.7.105:1313`.
All English content for the site is located in the `content/en` directory, as well as in sibling translated
All English content for the site is located in the `content/en` directory, and translated content is in sibling
directories such as `content/zh`.
### Linting

View File

@ -26,7 +26,7 @@ archive_date: YYYY-MM-DD
archive_search_refinement: "V1.1"
# GitHub branch names used when the docs have links to GitHub
source_branch_name: master
source_branch_name: release-1.4
doc_branch_name: master
# The list of supported versions described by the docs

View File

@ -16,37 +16,8 @@
set -e
mkdir -p generated/css generated/js generated/img tmp/js
sass src/sass/_all.scss all.css -s compressed --no-source-map
mv all.css* generated/css
tsc
# TODO: We should be passing the `--presets minify` option to Babel for optimal results in both cases below,
# but this just started to fail in Netlify with non-sense errors on 2019/11/05,
# even though all tool and library versions are pinned. So I'm turning this off for
# now. We can try turning it back on later and see what happens.
babel --source-maps --minified --no-comments \
tmp/js/constants.js \
tmp/js/utils.js \
tmp/js/kbdnav.js \
tmp/js/themes.js \
tmp/js/menu.js \
tmp/js/header.js \
tmp/js/sidebar.js \
tmp/js/tabset.js \
tmp/js/prism.js \
tmp/js/codeBlocks.js \
tmp/js/links.js \
tmp/js/scroll.js \
tmp/js/overlays.js \
tmp/js/lang.js \
tmp/js/callToAction.js \
--out-file generated/js/all.min.js
babel --source-maps --minified --no-comments \
tmp/js/themes_init.js \
--out-file generated/js/themes_init.min.js
svgstore -o generated/img/icons.svg src/icons/**/*.svg
if [[ "$2" == "-no_minify" ]]; then
hugo --baseURL "$1"
else
hugo --minify --baseURL "$1"
fi

View File

@ -16,8 +16,37 @@
set -e
if [[ "$2" == "-no_minify" ]]; then
hugo --baseURL "$1"
else
hugo --minify --baseURL "$1"
fi
mkdir -p generated/css generated/js generated/img tmp/js
sass src/sass/_all.scss all.css -s compressed --no-source-map
mv all.css* generated/css
tsc
# TODO: We should be passing the `--presets minify` option to Babel for optimal results in both cases below,
# but this just started to fail in Netlify with non-sense errors on 2019/11/05,
# even though all tool and library versions are pinned. So I'm turning this off for
# now. We can try turning it back on later and see what happens.
babel --source-maps --minified --no-comments \
tmp/js/constants.js \
tmp/js/utils.js \
tmp/js/kbdnav.js \
tmp/js/themes.js \
tmp/js/menu.js \
tmp/js/header.js \
tmp/js/sidebar.js \
tmp/js/tabset.js \
tmp/js/prism.js \
tmp/js/codeBlocks.js \
tmp/js/links.js \
tmp/js/scroll.js \
tmp/js/overlays.js \
tmp/js/lang.js \
tmp/js/callToAction.js \
--out-file generated/js/all.min.js
babel --source-maps --minified --no-comments \
tmp/js/themes_init.js \
--out-file generated/js/themes_init.min.js
svgstore -o generated/img/icons.svg src/icons/**/*.svg

View File

@ -18,16 +18,21 @@
# These snippets are put into the examples directory and referenced from markdown files
# throughout the site.
if [[ "$1" != "" ]]; then
SOURCE_BRANCH_NAME="$1"
else
SOURCE_BRANCH_NAME="master"
fi
SNIPPET_REPO=https://github.com/istio/istio
SNIPPET_BRANCH=master
rm -fr examples/*.snippets.txt
echo Cloning ${SNIPPET_REPO}@${SNIPPET_BRANCH}
echo Cloning "${SNIPPET_REPO}@${SOURCE_BRANCH_NAME}"
WORK_DIR="$(mktemp -d)"
mkdir -p "${WORK_DIR}"
git clone -q -b "${SNIPPET_BRANCH}" "${SNIPPET_REPO}" "${WORK_DIR}"
git clone -q -b """${SOURCE_BRANCH_NAME}""" "${SNIPPET_REPO}" "${WORK_DIR}"
COMMITS=$(git --git-dir="${WORK_DIR}/.git" log --oneline --no-abbrev-commit | cut -d " " -f 1)
rm -fr "${WORK_DIR}"

View File

@ -14,10 +14,16 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# This scripts obtains the operator's yaml files and constructs them into
# This script obtains the operator's yaml files and constructs them into
# one manifest. Additionally IstioControlPlane custom resources are generated
# for each of the profiles for easy switching between deployment modes.
if [[ "$1" != "" ]]; then
SOURCE_BRANCH_NAME="$1"
else
SOURCE_BRANCH_NAME="master"
fi
# Find the output directory
scriptpath="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
rootdir=$(dirname "${scriptpath}")
@ -26,10 +32,8 @@ output_dir="${rootdir}/static"
# Temporary directories securely created
tempdir_operator="$(mktemp -d)"
# Upstream GIT tags or branches used for the operator repo. The operator is
# currently only available as a master version. This will change when
# 1.4 is tagged.
operator_tag="release-1.4"
# Upstream GIT tags or branches used for the operator repo.
operator_tag="${SOURCE_BRANCH_NAME}"
# Add profiles here to have them automatically added to the website.
# It is important to also document these files, which is not done automatically.

View File

@ -23,11 +23,17 @@
# Additionally, this script also builds Istio components and runs them to extract their command-line docs which it
# copies to content/en/docs/reference/commands.
if [[ "$1" != "" ]]; then
SOURCE_BRANCH_NAME="$1"
else
SOURCE_BRANCH_NAME="master"
fi
# The repos to mine for docs, just add new entries here to pull in more repos.
REPOS=(
https://github.com/istio/istio.git@release-1.4
https://github.com/istio/api.git@release-1.4
https://github.com/istio/operator.git@release-1.4
https://github.com/istio/istio.git@"${SOURCE_BRANCH_NAME}"
https://github.com/istio/api.git@"${SOURCE_BRANCH_NAME}"
https://github.com/istio/operator.git@"${SOURCE_BRANCH_NAME}"
https://github.com/apigee/istio-mixer-adapter.git@master
https://github.com/osswangxining/alicloud-istio-grpcadapter.git@master
https://github.com/vmware/wavefront-adapter-for-istio.git@master
@ -38,19 +44,19 @@ REPOS=(
# The components to build and extract usage docs from.
COMPONENTS=(
https://github.com/istio/istio.git@release-1.4@mixer/cmd/mixs@mixs
https://github.com/istio/istio.git@release-1.4@istioctl/cmd/istioctl@istioctl
https://github.com/istio/istio.git@release-1.4@pilot/cmd/pilot-agent@pilot-agent
https://github.com/istio/istio.git@release-1.4@pilot/cmd/pilot-discovery@pilot-discovery
https://github.com/istio/istio.git@release-1.4@sidecar-injector/cmd/sidecar-injector@sidecar-injector
https://github.com/istio/istio.git@release-1.4@security/cmd/istio_ca@istio_ca
https://github.com/istio/istio.git@release-1.4@security/cmd/node_agent@node_agent
https://github.com/istio/istio.git@release-1.4@galley/cmd/galley@galley
https://github.com/istio/operator.git@release-1.4@cmd/manager@operator
https://github.com/istio/istio.git@"${SOURCE_BRANCH_NAME}"@mixer/cmd/mixs@mixs
https://github.com/istio/istio.git@"${SOURCE_BRANCH_NAME}"@istioctl/cmd/istioctl@istioctl
https://github.com/istio/istio.git@"${SOURCE_BRANCH_NAME}"@pilot/cmd/pilot-agent@pilot-agent
https://github.com/istio/istio.git@"${SOURCE_BRANCH_NAME}"@pilot/cmd/pilot-discovery@pilot-discovery
https://github.com/istio/istio.git@"${SOURCE_BRANCH_NAME}"@sidecar-injector/cmd/sidecar-injector@sidecar-injector
https://github.com/istio/istio.git@"${SOURCE_BRANCH_NAME}"@security/cmd/istio_ca@istio_ca
https://github.com/istio/istio.git@"${SOURCE_BRANCH_NAME}"@security/cmd/node_agent@node_agent
https://github.com/istio/istio.git@"${SOURCE_BRANCH_NAME}"@galley/cmd/galley@galley
https://github.com/istio/operator.git@"${SOURCE_BRANCH_NAME}"@cmd/manager@operator
)
# The repo to fetch config analysis message data from
CONFIG_ANALYSIS_MESSAGE_REPO="https://github.com/istio/istio.git@release-1.4@galley/pkg/config/analysis/msg/messages.yaml"
CONFIG_ANALYSIS_MESSAGE_REPO="https://github.com/istio/istio.git@${SOURCE_BRANCH_NAME}@galley/pkg/config/analysis/msg/messages.yaml"
SCRIPTPATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
ROOTDIR=$(dirname "${SCRIPTPATH}")