diff --git a/docs/linting.md b/docs/linting.md index 94f4b295a4a..d08d7ecfbf2 100644 --- a/docs/linting.md +++ b/docs/linting.md @@ -75,26 +75,3 @@ Ex: `buildscripts/pylinters.py lint` | Linter | Configuration File(s) | Help Command | Documentation | | ------ | --------------------- | ------------- | ------------------------------------------------------------ | | `ruff` | `pyproject.toml` | `ruff --help` | [https://docs.astral.sh/ruff/](https://docs.astral.sh/ruff/) | - -### SCons Linters - -`buildscripts/pylinters.py` lints over the SCons code automatically. - -## Using SCons for linting - -You can use SCons to run most of the linters listed above via their corresponding Python wrapper -script. SCons also provides the ability to run multiple linters in a single command. At this time, -SCons does not support `clang-tidy` or `buildscripts/yamllinters.sh` - -Here are some examples: - -| SCons Target | Linter(s) | Example | -| ------------------- | ----------------------------------------------------------------------------------------------- | ----------------------------------------- | -| `lint` | `clang-format` `errorcodes.py` `quickmongolint.py` `eslint` `pylint` `mypy` `pydocstyle` `yapf` | `buildscripts/scons.py lint` | -| `lint-fast` | `clang-format` `errorcodes.py` `eslint` `pylint` `mypy` `pydocstyle` `yapf` | `buildscripts/scons.py lint-fast` | -| `lint-clang-format` | `clang-format` | `buildscripts/scons.py lint-clang-format` | -| `lint-errorcodes` | `errorcodes.py` | `buildscripts/scons.py lint-errorcodes` | -| `lint-lint.py` | `quickmongolint.py` | `buildscripts/scons.py lint-lint.py` | -| `lint-eslint` | `eslint` | `buildscripts/scons.py lint-eslint` | -| `lint-pylinters` | `pylint` `mypy` `pydocstyle` `yapf` | `buildscripts/scons.py lint-pylinters` | -| `lint-sconslinters` | `yapf` | `buildscripts/scons.py lint-sconslinters` | diff --git a/etc/evergreen_yml_components/definitions.yml b/etc/evergreen_yml_components/definitions.yml index 5590078a18b..7bc0487d510 100644 --- a/etc/evergreen_yml_components/definitions.yml +++ b/etc/evergreen_yml_components/definitions.yml @@ -1223,16 +1223,6 @@ functions: - *check_run_tests_infrastructure_failure - *check_resmoke_failure - "scons lint": - - *f_expansions_write - - command: subprocess.exec - display_name: "scons lint sh" - type: test - params: - binary: bash - args: - - "src/evergreen/scons_lint.sh" - "scons splunk": &scons_splunk command: subprocess.exec display_name: "scons splunk" diff --git a/etc/evergreen_yml_components/tasks/misc_tasks.yml b/etc/evergreen_yml_components/tasks/misc_tasks.yml index 8c39eefc3bf..969f9d95afc 100644 --- a/etc/evergreen_yml_components/tasks/misc_tasks.yml +++ b/etc/evergreen_yml_components/tasks/misc_tasks.yml @@ -773,10 +773,15 @@ tasks: - func: "cleanup environment" - func: "set up venv" - func: "upload pip requirements" - - func: "get engflow creds" - - func: "scons lint" - vars: - targets: lint-clang-format + - command: subprocess.exec + type: test + params: + binary: bash + args: + - "./src/evergreen/run_python_script_with_report.sh" + - "lint-clang-format" + - "buildscripts/clang_format.py" + - "lint-all" - name: lint_cpplint tags: @@ -798,10 +803,15 @@ tasks: - func: "cleanup environment" - func: "set up venv" - func: "upload pip requirements" - - func: "get engflow creds" - - func: "scons lint" - vars: - targets: lint-lint.py + - command: subprocess.exec + type: test + params: + binary: bash + args: + - "./src/evergreen/run_python_script_with_report.sh" + - "lint_cpplint" + - "buildscripts/quickmongolint.py" + - "lint" - name: lint_errorcodes tags: @@ -818,10 +828,15 @@ tasks: - func: "cleanup environment" - func: "set up venv" - func: "upload pip requirements" - - func: "get engflow creds" - - func: "scons lint" - vars: - targets: lint-errorcodes + - command: subprocess.exec + type: test + params: + binary: bash + args: + - "./src/evergreen/run_python_script_with_report.sh" + - "lint-errorcodes" + - "buildscripts/errorcodes.py" + - "--quiet" - name: lint_eslint tags: @@ -843,10 +858,18 @@ tasks: - func: "cleanup environment" - func: "set up venv" - func: "upload pip requirements" - - func: "get engflow creds" - - func: "scons lint" - vars: - targets: lint-eslint + - command: subprocess.exec + type: test + params: + binary: bash + args: + - "./src/evergreen/run_python_script_with_report.sh" + - "lint-eslint" + - "buildscripts/eslint.py" + - "--dirmode" + - "lint" + - "jstests/" + - "src/mongo" # Check that the mutational fuzzer can parse all JS filess. - name: lint_fuzzer_sanity_all @@ -1014,10 +1037,15 @@ tasks: - func: "cleanup environment" - func: "set up venv" - func: "upload pip requirements" - - func: "get engflow creds" - - func: "scons lint" - vars: - targets: lint-pylinters + - command: subprocess.exec + type: test + params: + binary: bash + args: + - "./src/evergreen/run_python_script_with_report.sh" + - "lint-pylinters" + - "buildscripts/pylinters.py" + - "lint" - name: lint_shellscripts tags: diff --git a/evergreen/run_python_script_with_report.sh b/evergreen/run_python_script_with_report.sh new file mode 100644 index 00000000000..9a223e1d975 --- /dev/null +++ b/evergreen/run_python_script_with_report.sh @@ -0,0 +1,22 @@ +unset workdir +DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" > /dev/null 2>&1 && pwd)" +. "$DIR/prelude.sh" + +set -o verbose + +cd src + +# Get the name of the test to be included in the report +report_test_name="$1" +# Shift the args so "$@" will unwind only the args to be passed to the python process +shift + +activate_venv +echo $python $@ +echo $python $@ > python_report.log +$python "$@" &>> python_report.log +exit_code=$? +echo "Finished with exit code: $exit_code" >> python_report.log + +$python ./buildscripts/simple_report.py --test-name "${report_test_name}" --log-file python_report.log --exit-code $exit_code +exit $exit_code diff --git a/evergreen/scons_lint.sh b/evergreen/scons_lint.sh deleted file mode 100755 index 7b53af120e2..00000000000 --- a/evergreen/scons_lint.sh +++ /dev/null @@ -1,28 +0,0 @@ -DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" > /dev/null 2>&1 && pwd)" -. "$DIR/prelude.sh" - -cd src - -set -o pipefail -set -o verbose - -activate_venv -export MYPY="$( - if which cygpath 2> /dev/null; then - PATH+=":$(cypath "${workdir}")/venv_3/Scripts" - else - PATH+=":${workdir}/venv_3/bin" - fi - PATH+=':/opt/mongodbtoolchain/v4/bin' - which mypy -)" -echo "Found mypy executable at '$MYPY'" - -echo "Setting evergreen tmp dir to $TMPDIR" -compile_flags="$compile_flags --evergreen-tmp-dir='${TMPDIR}'" - -eval ${compile_env} python3 ./buildscripts/scons.py ${compile_flags} --separate-debug=${separate_debug} --stack-size=1024 ${targets} | tee scons-lint.log -exit_code=$? - -$python ./buildscripts/simple_report.py --test-name "${targets}" --log-file scons-lint.log --exit-code $exit_code -exit $exit_code