diff options
author | Evan Read <eread@gitlab.com> | 2022-08-02 02:02:02 +0300 |
---|---|---|
committer | Evan Read <eread@gitlab.com> | 2022-08-30 03:22:16 +0300 |
commit | 8451aa75732c7a4def64f39f7ab194d21e9aaddf (patch) | |
tree | 27220ed47a61101b7753268f84b3ada27453dcb6 | |
parent | 18121b714288fec6b9cd7a28ffae3bce7a2e4222 (diff) |
Add check for identical duplicate entries in global navigationeread/add-duplicate-nav-entry-check
-rw-r--r-- | .editorconfig | 3 | ||||
-rw-r--r-- | .gitlab/ci/test.gitlab-ci.yml | 12 | ||||
-rw-r--r-- | Makefile | 12 | ||||
-rw-r--r-- | lefthook.yml | 2 | ||||
-rwxr-xr-x | scripts/check-navigation.sh | 19 |
5 files changed, 44 insertions, 4 deletions
diff --git a/.editorconfig b/.editorconfig index 0f178672..0a5e6323 100644 --- a/.editorconfig +++ b/.editorconfig @@ -7,3 +7,6 @@ indent_size = 2 indent_style = space insert_final_newline = true trim_trailing_whitespace = true + +[Makefile] +indent_style = tab diff --git a/.gitlab/ci/test.gitlab-ci.yml b/.gitlab/ci/test.gitlab-ci.yml index fe2ab189..100c9c82 100644 --- a/.gitlab/ci/test.gitlab-ci.yml +++ b/.gitlab/ci/test.gitlab-ci.yml @@ -51,6 +51,18 @@ check_index_html: - exit $(cat output.txt | wc -l) # +# Check for identical duplicate entries in global navigation +# + +check_global_nav_entries: + extends: + - .rules_site_tests + needs: [] + stage: test + script: + - make check-global-navigation + +# # Run rspec tests # rspec: @@ -105,6 +105,10 @@ clean: @printf "\n$(INFO)INFO: Removing tmp and public directories...$(END)\n" @rm -rf tmp public +build-lunr-index: + @printf "\n$(INFO)INFO: Building offline search index..$(INFO_END)\n" + node scripts/lunr/preindex.js + internal-links-check: clone-all-docs-projects compile @printf "\n$(INFO)INFO: Checking all internal links...$(END)\n" @bundle exec nanoc check internal_links @@ -157,8 +161,8 @@ markdownlint-tests: @printf "\n$(INFO)INFO: Running markdownlint tests...$(END)\n" @yarn markdownlint doc/**/*.md -test: setup rspec-tests jest-tests eslint-tests prettier-tests stylelint-tests hadolint-tests yamllint-tests markdownlint-tests +check-global-navigation: + @printf "\n$(INFO)INFO: Checking global navigation...$(END)\n" + @scripts/check-navigation.sh -build-lunr-index: - @printf "\n$(INFO)INFO: Building offline search index..$(INFO_END)\n" - node scripts/lunr/preindex.js
\ No newline at end of file +test: setup rspec-tests jest-tests eslint-tests prettier-tests stylelint-tests hadolint-tests yamllint-tests markdownlint-tests check-global-navigation diff --git a/lefthook.yml b/lefthook.yml index c05fc5f3..73621764 100644 --- a/lefthook.yml +++ b/lefthook.yml @@ -18,3 +18,5 @@ pre-push: run: make yamllint-tests markdownlint-tests: run: make markdownlint-tests + navigation-checks: + run: make check-global-navigation diff --git a/scripts/check-navigation.sh b/scripts/check-navigation.sh new file mode 100755 index 00000000..69f4a9a6 --- /dev/null +++ b/scripts/check-navigation.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash + +COLOR_RED="\e[31m" +COLOR_GREEN="\e[32m" +COLOR_RESET="\e[39m" + +DUPLICATED_NAV_ENTRIES=$(sed -n -E "s/.*[section|category|doc|]_url: '(.*)'/\1/p" content/_data/navigation.yaml | sort | uniq -d) + +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 +else + printf "${COLOR_GREEN}INFO: No identical duplicate entries found!${COLOR_RESET}\n" + exit 0 +fi |