Update lint_site to only check languages for files in current PR (#7133)

* Update lint to only check languages for files in current PR

* Default branch to master if undefined, lint fixes

* Fix @ in Makefile.core.mk

* Add pt-br support to language check

* Review comments

* Apply suggestions from code review

Either BRANCH is specified or a language, else it fails.

Co-Authored-By: Frank Budinsky <frankb@ca.ibm.com>

* Update scripts/lint_site.sh

Co-Authored-By: Frank Budinsky <frankb@ca.ibm.com>

* Update Makefile.core.mk

Co-Authored-By: Frank Budinsky <frankb@ca.ibm.com>

* Don't check languages for lint-fast if no languages are found

Co-authored-by: Frank Budinsky <frankb@ca.ibm.com>
This commit is contained in:
Eric Van Norman 2020-04-29 10:18:13 -05:00 committed by GitHub
parent 30ea242d0d
commit d59b390a49
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 4 deletions

View File

@ -96,13 +96,13 @@ clean:
@rm -fr resources .htmlproofer tmp generated public out samples install go tests/integration/
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
@BRANCH=$(SOURCE_BRANCH_NAME) scripts/lint_site.sh
lint-en: 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 en
lint-fast:
@SKIP_LINK_CHECK=true scripts/lint_site.sh en
@BRANCH=$(SOURCE_BRANCH_NAME) SKIP_LINK_CHECK=true scripts/lint_site.sh
serve: site
@hugo serve --baseURL "http://${ISTIO_SERVE_DOMAIN}:1313/" --bind 0.0.0.0 --disableFastRender

View File

@ -18,12 +18,26 @@ set -e
FAILED=0
if [[ "$#" -ne 0 ]]; then
if [[ -n "${BRANCH}" ]]; then
files_changed="$(git diff --name-only --diff-filter=b "$(git merge-base HEAD "$BRANCH")")"
if (echo "${files_changed}" | grep -q /en/); then
LANGS+="en "
fi
if (echo "${files_changed}" | grep -q /zh/); then
LANGS+="zh "
fi
if (echo "${files_changed}" | grep -q /pt-br/); then
LANGS+="pt-br "
fi
elif [[ "$#" -ne 0 ]]; then
LANGS="$*"
else
LANGS="en zh"
echo "ERROR: no languages specified!"
exit 1
fi
echo Testing Langs: "${LANGS}"
# This performs spell checking and style checking over markdown files in a content
# directory. It transforms the shortcode sequences we use to annotate code blocks
# into classic markdown ``` code blocks, so that the linters aren't confused