Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: avoid failing if no file to check #7113

Merged
merged 1 commit into from
Jul 21, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -214,18 +214,23 @@ test-int: guard-test # usage: make test-one test=t/test-file.t
# better shutdown, for if we do a modification of the code, we need a restart
${DOCKER_COMPOSE_TEST} stop backend

# stop all docker tests containers
stop_tests:
${DOCKER_COMPOSE_TEST} stop

# check perl compiles, (pattern rule) / but only for newer files
%.pm %.pl: _FORCE
if [ -f $@ ]; then perl -c -CS -Ilib $@; else true; fi


# TO_CHECK look at changed files (compared to main) with extensions .pl, .pm, .t
# the ls at the end is to avoid removed files
TO_CHECK=$(shell git diff origin/main --name-only | grep '.*\.\(pl\|pm\|t\)$$' | xargs ls -d 2>/dev/null )
# the ls at the end is to avoid removed files.
# We have to finally filter out "." as this will the output if we have no file
TO_CHECK=$(shell git diff origin/main --name-only | grep '.*\.\(pl\|pm\|t\)$$' | xargs ls -d 2>/dev/null | grep -v "^.$$" )

check_perl_fast:
@echo "🥫 Checking ${TO_CHECK}"
${DOCKER_COMPOSE} run --rm backend make -j ${CPU_COUNT} ${TO_CHECK}
test -z "${TO_CHECK}" || ${DOCKER_COMPOSE} run --rm backend make -j ${CPU_COUNT} ${TO_CHECK}

check_translations:
@echo "🥫 Checking translations"
Expand All @@ -244,19 +249,19 @@ check_perl:
TO_TIDY_CHECK = $(shell echo ${TO_CHECK}| tr " " "\n" | grep -vFf .perltidy_excludes)
check_perltidy:
@echo "🥫 Checking with perltidy ${TO_TIDY_CHECK}"
${DOCKER_COMPOSE} run --rm --no-deps backend perltidy --assert-tidy -opath=/tmp/ --standard-error-output ${TO_TIDY_CHECK}
test -z "${TO_TIDY_CHECK}" || ${DOCKER_COMPOSE} run --rm --no-deps backend perltidy --assert-tidy -opath=/tmp/ --standard-error-output ${TO_TIDY_CHECK}

# same as check_perltidy, but this time applying changes
lint_perltidy:
@echo "🥫 Linting with perltidy ${TO_TIDY_CHECK}"
${DOCKER_COMPOSE} run --rm --no-deps backend perltidy --standard-error-output -b -bext=/ ${TO_TIDY_CHECK}
test -z "${TO_TIDY_CHECK}" || ${DOCKER_COMPOSE} run --rm --no-deps backend perltidy --standard-error-output -b -bext=/ ${TO_TIDY_CHECK}


#Checking with Perl::Critic
# adding an echo of search.pl in case no files are edited
check_critic:
@echo "🥫 Checking with perlcritic"
${DOCKER_COMPOSE} run --rm --no-deps backend perlcritic ${TO_CHECK}
test -z "${TO_CHECK}" || ${DOCKER_COMPOSE} run --rm --no-deps backend perlcritic ${TO_CHECK}

#-------------#
# Compilation #
Expand Down