spark-test commented on code in PR #60449:
URL: https://github.com/apache/spark/pull/60449#discussion_r4579775592
##########
.github/workflows/build_and_test.yml:
##########
@@ -954,7 +954,10 @@ jobs:
run: |
PYTHON_EXECUTABLE=python3.12 ./dev/lint-python
- name: JS linter
- run: ./dev/lint-js
+ env:
+ SKIP_SCALA_BUILD: true
+ SKIP_MIMA: true
+ run: ./dev/run-tests --modules lint-js
Review Comment:
**Non-blocking (P2):** This step now runs ESLint only when module selection
picks `lint-js` or root, and that selection comes from
`identify_changed_files_from_git_commits` in `dev/sparktestsupport/utils.py`,
which runs `git diff --name-only <head> <base>` with git's default rename
detection. That diff lists a file git pairs as a rename only under its old
path, so the path a moved file now has never reaches the `lint-js` patterns.
As a result, a PR that moves a `.js` file into one of the four
`LINT_TARGET_FILES` directories from a path whose modules include neither
`lint-js` nor root, and touches nothing else that selects them, passes this
step without linting the moved file. By this review's reading of the code,
moving `python/docs/source/_static/copy.js` to `docs/js/copy.js` lists only the
old path, which selects `docs`, `pyspark-core`, and `pyspark-periodic`, so
`run-tests` prints "There are no modules to test, exiting without testing." and
the step passes. A move from an ignored direct child of `ui-test/` into
`ui-test/tests/`, or from
`sql/core/src/main/resources/org/apache/spark/sql/execution/ui/` into its
`static/` subdirectory, skips ESLint the same way.
Before this change the step ran `./dev/lint-js` on every build, so lint
errors in the moved file failed the PR that moved it. Now they merge, and the
next PR that selects `lint-js` or root, which any `core/` change does, fails
the JS linter on a file it did not touch. No tracked `.js` file sits at such a
path today, so this needs a future file, and the same gap applies to each
linter that later moves to this pattern.
**Recommended change:** Pass --no-renames to the git diff in
identify_changed_files_from_git_commits so a file that git pairs as a rename is
listed under both its old and its new path, and add sparktestsupport
change-detection tests for a moved file.
**Why this works:** With rename detection off, git reports a move as the
deletion of the old path and the addition of the new one, so the new path
reaches module selection and a .js file moved into an ESLint target matches a
lint-js pattern, while the old path still selects the modules it selects today.
**Scope:** One option on the shared change-detection git diff, plus a
sparktestsupport test for a moved file.
**Compatibility:** For a diff without renames the changed-file list, and so
every job's module selection, stays exactly as it is today.
**Risks:** For a PR that moves files, the module-gated jobs and the
precondition's module groups also select the modules of the new paths, so such
PRs can run more tests than today; the change only adds selections, and
dropping the option rolls it back. Checks that read the changed paths now also
see where a moved file lands: a PR that moves a PySpark test file to a path no
module registers now fails the dangling Python test check, and one that moves a
file to a .jar or .class path now fails is-changed.py's check that rejects such
files; today both checks miss the move because they see only the old path.
**Constraints:** Keep the helper's result a flat list of repository-relative
paths, because every caller matches it against module patterns or path suffixes.
**Success:** For a diff in which git pairs a moved file as a rename, the
changed-file list names both the old and the new path. A change that moves a
.js file into one of ESLint's target directories selects lint-js, so the JS
linter step runs ESLint, whatever path the file came from.
**Verification:**
- **Regression:** A change-detection case over a diff that moves an
unchanged file, so that git pairs it as a rename, lists both the old and the
new path, where today only the old path is listed.
- **Behavior:** Module selection over the changed files of a diff that moves
a .js file from outside the lint targets, such as from
python/docs/source/_static/, into docs/js/ includes lint-js, so a lint-js run
lints the moved file instead of reporting that there are no modules to test.
##########
dev/sparktestsupport/tests/test_utils.py:
##########
@@ -37,6 +37,52 @@ def test_github_files_only_count_in_github_actions(self):
determine_modules_for_files([".github/workflows/build_main.yml"]), expected
)
+ def test_lint_js_inputs_select_lint_js(self):
Review Comment:
**Nit (P3):** These tests check which paths select the module, through the
`modules.lint_js` attribute, but whether CI runs ESLint also rests on three
links that no test reads: the module's name, which the lint job passes as
`--modules lint-js`; its `dev/lint-js` shell goal; and the `LINT_TARGET_FILES`
list in `dev/lint-js`, which the two "Keep in sync" comments tie to the
module's patterns. `run-tests` keeps only the modules whose names match
`--modules` and otherwise prints "There are no modules to test", and a
`lint-js` module without its goal runs nothing, because the step skips the
Scala build and MiMa.
So renaming the module or dropping its goal would stop ESLint on every build
while every sparktestsupport test still passes, and adding a directory to
`LINT_TARGET_FILES` without a matching pattern would skip ESLint for PRs that
touch that directory and nothing else that selects `lint-js` or root, leaving
its lint errors to fail a later, unrelated PR. The other module-gated jobs
already have this signal: `test_sql_dependents` and
`test_core_and_sql_without_deduplication` compare module names, so renaming
`sparkr` or `docker-integration-tests`, whose jobs pass their names to
`dev/run-tests` the same way, fails them, and
`test_root_includes_test_dependencies` fails if the `build` module drops its
`dev/test-dependencies.sh` goal.
**Verification:**
- **Regression:** With the module renamed, or with its dev/lint-js goal
removed, the new test fails, where today every sparktestsupport test still
passes.
- **Regression:** With a directory added to LINT_TARGET_FILES that no
lint-js pattern covers, the new test fails.
- **Behavior:** With the current module definitions and dev/lint-js, the new
test passes for all four LINT_TARGET_FILES entries.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]