Skip to content

build: ensure only errors are displayed in issue via log file #5751

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

Draft
wants to merge 2 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
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
10 changes: 5 additions & 5 deletions .github/workflows/lint_random_files.yml
Original file line number Diff line number Diff line change
Expand Up @@ -335,31 +335,31 @@ jobs:
done
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest moving this logic to a separate Bash script. This will make refactoring and linting easier.


if [[ -n "${files}" ]]; then
make lint-javascript-files FIX="${FIX}" FAST_FAIL=0 FILES="${files}" 2>&1 | tee -a "$ERR_FILE"
make lint-javascript-files FIX="${FIX}" FAST_FAIL=0 FILES="${files}" ESLINT_ERROR_LOG="$ERR_FILE"
fi

# Lint JavaScript command-line interfaces...
file=$(echo "${{ steps.random-files.outputs.files }}" | tr ',' '\n' | grep '\.js$' | grep -E '/bin/cli$' | tr '\n' ' ')
if [[ -n "${file}" ]]; then
make lint-javascript-files FIX="${FIX}" FAST_FAIL=0 FILES="${file}" 2>&1 | tee -a "$ERR_FILE"
make lint-javascript-files FIX="${FIX}" FAST_FAIL=0 FILES="${file}" ESLINT_ERROR_LOG="$ERR_FILE"
fi

# Lint JavaScript example files:
files=$(echo "${{ steps.random-files.outputs.files }}" | tr ',' '\n' | grep '/examples/.*\.js$' | tr '\n' ' ')
if [[ -n "${files}" ]]; then
make lint-javascript-files FIX="${FIX}" FAST_FAIL=0 FILES="${files}" ESLINT_CONF="${eslint_examples_conf}" 2>&1 | tee -a "$ERR_FILE"
make lint-javascript-files FIX="${FIX}" FAST_FAIL=0 FILES="${files}" ESLINT_CONF="${eslint_examples_conf}" ESLINT_ERROR_LOG="$ERR_FILE"
fi

# Lint JavaScript test files:
files=$(echo "${{ steps.random-files.outputs.files }}" | tr ',' '\n' | grep '/test/.*\.js$' | tr '\n' ' ')
if [[ -n "${files}" ]]; then
make lint-javascript-files FIX="${FIX}" FAST_FAIL=0 FILES="${files}" ESLINT_CONF="${eslint_tests_conf}" 2>&1 | tee -a "$ERR_FILE"
make lint-javascript-files FIX="${FIX}" FAST_FAIL=0 FILES="${files}" ESLINT_CONF="${eslint_tests_conf}" ESLINT_ERROR_LOG="$ERR_FILE"
fi

# Lint JavaScript benchmark files:
files=$(echo "${{ steps.random-files.outputs.files }}" | tr ',' '\n' | grep '/benchmark/.*\.js$' | tr '\n' ' ')
if [[ -n "${files}" ]]; then
make lint-javascript-files FIX="${FIX}" FAST_FAIL=0 FILES="${files}" ESLINT_CONF="${eslint_benchmarks_conf}" 2>&1 | tee -a "$ERR_FILE"
make lint-javascript-files FIX="${FIX}" FAST_FAIL=0 FILES="${files}" ESLINT_CONF="${eslint_benchmarks_conf}" ESLINT_ERROR_LOG="$ERR_FILE"
fi

# Create sub-issue for JavaScript lint failures:
Expand Down
15 changes: 15 additions & 0 deletions tools/make/lib/lint/javascript/eslint.mk
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ ESLINT_CONF_BENCHMARKS ?= $(CONFIG_DIR)/eslint/.eslintrc.benchmarks.js
# Define the path to the ESLint ignore file:
ESLINT_IGNORE ?= $(ROOT_DIR)/.eslintignore

# Define optional path for storing lint failure reports:
ESLINT_ERROR_LOG ?=

# Define the command-line options to use when invoking the ESLint executable:
ESLINT_FLAGS ?= \
--ignore-path $(ESLINT_IGNORE) \
Expand Down Expand Up @@ -251,6 +254,18 @@ ifeq ($(FAIL_FAST), true)
echo "Linting file: $$file"; \
$(ESLINT) $(ESLINT_FLAGS) --config $(ESLINT_CONF) $$file || exit 1; \
done
else ifneq ($(ESLINT_ERROR_LOG),)
$(QUIET) status=0; \
for file in $(FILES); do \
echo ''; \
echo "Linting file: $$file"; \
if ! $(ESLINT) $(ESLINT_FLAGS) --config $(ESLINT_CONF) $$file; then \
echo 'Linting failed.'; \
$(ESLINT) $(ESLINT_FLAGS) --quiet --config $(ESLINT_CONF) $$file >> $(ESLINT_ERROR_LOG); \
status=1; \
fi; \
done; \
exit $$status;
else
$(QUIET) status=0; \
for file in $(FILES); do \
Expand Down
Loading