Skip to content

Commit

Permalink
ci: taxonomy linter (#10046)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexgarel authored and john-gom committed May 24, 2024
1 parent 0f47bd6 commit fd7c4e7
Show file tree
Hide file tree
Showing 13 changed files with 822 additions and 457 deletions.
14 changes: 10 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -381,17 +381,19 @@ check_critic:
@echo "🥫 Checking with perlcritic"
test -z "${TO_CHECK}" || ${DOCKER_COMPOSE} run --rm --no-deps backend perlcritic ${TO_CHECK}

TAXONOMIES_TO_CHECK := $(shell [ -x "`which git 2>/dev/null`" ] && git diff origin/main --name-only | grep 'taxonomies*/*\.txt$$' | grep -v '\.result.txt' | xargs ls -d 2>/dev/null | grep -v "^.$$")
TAXONOMIES_TO_CHECK := $(shell [ -x "`which git 2>/dev/null`" ] && git diff origin/main --name-only | grep 'taxonomies.*/.*\.txt$$' | grep -v '\.result.txt' | xargs ls -d 2>/dev/null | grep -v "^.$$")

# TODO remove --no-sort as soon as we have sorted taxonomies
check_taxonomies:
@echo "🥫 Checking taxonomies"
test -z "${TAXONOMIES_TO_CHECK}" || \
${DOCKER_COMPOSE} run --rm --no-deps backend scripts/taxonomies/sort_each_taxonomy_entry.sh --check ${TAXONOMIES_TO_CHECK}
${DOCKER_COMPOSE} run --rm --no-deps backend scripts/taxonomies/lint_taxonomy.pl --verbose --check --no-sort ${TAXONOMIES_TO_CHECK}

# TODO remove --no-sort as soon as we have sorted taxonomies
lint_taxonomies:
@echo "🥫 Linting taxonomies"
test -z "${TAXONOMIES_TO_CHECK}" || \
${DOCKER_COMPOSE} run --rm --no-deps backend scripts/taxonomies/sort_each_taxonomy_entry.sh ${TAXONOMIES_TO_CHECK}
${DOCKER_COMPOSE} run --rm --no-deps backend scripts/taxonomies/lint_taxonomy.pl --verbose --no-sort ${TAXONOMIES_TO_CHECK}


check_openapi_v2:
Expand All @@ -415,7 +417,11 @@ build_taxonomies: create_folders
# GITHUB_TOKEN might be empty, but if it's a valid token it enables pushing taxonomies to build cache repository
${DOCKER_COMPOSE} run --no-deps --rm -e GITHUB_TOKEN=${GITHUB_TOKEN} backend /opt/product-opener/scripts/taxonomies/build_tags_taxonomy.pl ${name}

rebuild_taxonomies: build_taxonomies
# a version where we force building without using cache
# use it when you are developing in Tags.pm and want to iterate
# at the end, change the $BUILD_TAGS_VERSION in Tags.pm
rebuild_taxonomies:
${DOCKER_COMPOSE} run --no-deps --rm -e TAXONOMY_NO_GET_FROM_CACHE=1 backend /opt/product-opener/scripts/taxonomies/build_tags_taxonomy.pl ${name}

build_taxonomies_test: create_folders
@echo "🥫 build taxonomies"
Expand Down
2 changes: 2 additions & 0 deletions lib/ProductOpener/Config_obf.pm
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ use ProductOpener::Config2;
# lowercase:
# - useful when the same word appears in lowercase, with a first capital letter, or in all caps.

# IMPORTANT: if you change it, you need to change $BUILD_TAGS_VERSION in Tags.pm

%string_normalization_for_lang = (
# no_language is used for strings that are not in a specific language (e.g. user names)
no_language => {
Expand Down
2 changes: 2 additions & 0 deletions lib/ProductOpener/Config_off.pm
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ use ProductOpener::Config2;
# lowercase:
# - useful when the same word appears in lowercase, with a first capital letter, or in all caps.

# IMPORTANT: if you change it, you need to change $BUILD_TAGS_VERSION in Tags.pm

%string_normalization_for_lang = (
# no_language is used for strings that are not in a specific language (e.g. user names)
no_language => {
Expand Down
2 changes: 2 additions & 0 deletions lib/ProductOpener/Config_opf.pm
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ use ProductOpener::Config2;
# lowercase:
# - useful when the same word appears in lowercase, with a first capital letter, or in all caps.

# IMPORTANT: if you change it, you need to change $BUILD_TAGS_VERSION in Tags.pm

%string_normalization_for_lang = (
# no_language is used for strings that are not in a specific language (e.g. user names)
no_language => {
Expand Down
2 changes: 2 additions & 0 deletions lib/ProductOpener/Config_opff.pm
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ use ProductOpener::Config2;
# lowercase:
# - useful when the same word appears in lowercase, with a first capital letter, or in all caps.

# IMPORTANT: if you change it, you need to change $BUILD_TAGS_VERSION in Tags.pm

%string_normalization_for_lang = (
# no_language is used for strings that are not in a specific language (e.g. user names)
no_language => {
Expand Down
3 changes: 3 additions & 0 deletions lib/ProductOpener/Store.pm
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ sub unac_string_perl ($s) {
# 4. keep other UTF-8 characters (e.g. Chinese, Japanese, Korean, Arabic, Hebrew etc.) untouched
# 5. remove leading and trailing -, turn multiple - to -

# IMPORTANT: if you change the behaviour of this method,
# you need to change $BUILD_TAGS_VERSION in Tags.pm

sub get_string_id_for_lang ($lc, $string) {

defined $lc or die("Undef \$lc in call to get_string_id_for_lang (string: $string)\n");
Expand Down
Loading

0 comments on commit fd7c4e7

Please sign in to comment.