0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-11-21 12:39:08 +01:00

SERVER-96047 move linters out of scons (#28323)

GitOrigin-RevId: 23c85b6bc1e0b32a295d7a860e2a5f5da3b9025c
This commit is contained in:
Trevor Guidry 2024-10-22 13:29:07 -04:00 committed by MongoDB Bot
parent 1227efb7db
commit ae750204a5
5 changed files with 70 additions and 81 deletions

View File

@ -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` |

View File

@ -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"

View File

@ -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:

View File

@ -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

View File

@ -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