Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-docs.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSarah German <sgerman@gitlab.com>2022-09-02 16:45:09 +0300
committerSarah German <sgerman@gitlab.com>2022-09-02 16:45:09 +0300
commita37c78da78a4e7bd06819fd7bdedb01a2213e9e9 (patch)
treea16ac9a4995791f64c4bdf3f4c572a54f667e3e8
parentd64cdeea93db5830016812d75ed0414c0112fd6a (diff)
parent303863edc7b550eca1c3a0d9a16771ae7c08b4c6 (diff)
Merge branch 'eread/roll-global-nav-index-test-into-script' into 'main'
Add check for index.html to global navigation check script See merge request gitlab-org/gitlab-docs!3068
-rw-r--r--.gitlab/ci/test.gitlab-ci.yml23
-rwxr-xr-xscripts/check-navigation.sh24
2 files changed, 25 insertions, 22 deletions
diff --git a/.gitlab/ci/test.gitlab-ci.yml b/.gitlab/ci/test.gitlab-ci.yml
index 100c9c82..e1d8171f 100644
--- a/.gitlab/ci/test.gitlab-ci.yml
+++ b/.gitlab/ci/test.gitlab-ci.yml
@@ -32,28 +32,11 @@ check_duplicate_redirects:
- exit $(cat output.txt | wc -l)
#
-# Check for index.html in navigation.yaml
+# Check global navigation for:
#
-check_index_html:
- image: busybox
- extends:
- - .rules_site_tests
- needs: []
- stage: test
- script:
- # Check for index.html in navigation.yaml and write the output in output.txt
- - grep -Ir "/index.html" content/_data/navigation.yaml | sed -e '/^#/d' | tee output.txt
- - |
- echo "***************************************************************************"
- echo "* If this job failed, it is because a navbar entry is using 'index.html'. *"
- echo "* Link to just '/' instead, For example 'ee/user/' *"
- echo "***************************************************************************"
- - exit $(cat output.txt | wc -l)
-
+# - Identical duplicate entries.
+# - index.html in the entries.
#
-# Check for identical duplicate entries in global navigation
-#
-
check_global_nav_entries:
extends:
- .rules_site_tests
diff --git a/scripts/check-navigation.sh b/scripts/check-navigation.sh
index 69f4a9a6..9274e576 100755
--- a/scripts/check-navigation.sh
+++ b/scripts/check-navigation.sh
@@ -3,17 +3,37 @@
COLOR_RED="\e[31m"
COLOR_GREEN="\e[32m"
COLOR_RESET="\e[39m"
+RETURN_CODE=0
+
DUPLICATED_NAV_ENTRIES=$(sed -n -E "s/.*[section|category|doc|]_url: '(.*)'/\1/p" content/_data/navigation.yaml | sort | uniq -d)
+# shellcheck disable=2059
printf "${COLOR_GREEN}INFO: Checking for identical duplicate global navigation entries...${COLOR_RESET}\n"
if [[ -n $DUPLICATED_NAV_ENTRIES ]]; then
for DUPLICATED_NAV_ENTRY in $DUPLICATED_NAV_ENTRIES; do
printf "${COLOR_RED}ERROR (identical duplicate entry):${COLOR_RESET} %s\n" "${DUPLICATED_NAV_ENTRY}"
done
- exit 1
+ RETURN_CODE=1
else
+ # shellcheck disable=2059
printf "${COLOR_GREEN}INFO: No identical duplicate entries found!${COLOR_RESET}\n"
- exit 0
fi
+
+NAV_ENTRIES_WITH_INDEX=$(sed -n -E "s/.*[section|category|doc|]_url: '(.*)'/\1/p" content/_data/navigation.yaml | grep -e "index.html" | grep -v "index.html.")
+
+# shellcheck disable=2059
+printf "${COLOR_GREEN}INFO: Checking for global navigation entries with index.html...${COLOR_RESET}\n"
+
+if [[ -n $NAV_ENTRIES_WITH_INDEX ]]; then
+ for NAV_ENTRY_WITH_INDEX in $NAV_ENTRIES_WITH_INDEX; do
+ printf "${COLOR_RED}ERROR (entry with index.html):${COLOR_RESET} %s\n" "${NAV_ENTRY_WITH_INDEX}"
+ done
+ RETURN_CODE=1
+else
+ # shellcheck disable=2059
+ printf "${COLOR_GREEN}INFO: No entries with index.html found!${COLOR_RESET}\n"
+fi
+
+if [[ $RETURN_CODE == 1 ]]; then exit 1; else exit 0; fi