SERVER-87001 Added markdown formatting to bazel and commit queue (#19273)

GitOrigin-RevId: ec129b1fb02f9615f32fbfd5784e1bad05f3947b
This commit is contained in:
Alexander Neben
2024-02-28 08:45:08 -08:00
committed by MongoDB Bot
parent a38e166748
commit d11507f608
11 changed files with 98 additions and 36 deletions

View File

@@ -33,3 +33,6 @@ a4f458fe4d7a44eba056f5c150753e73067c8e4d
# SERVER-74787 Prepare jstest corpus for implicit strict mode
43b87324302209cbfa240d6c6b520007669e4ea6
# SERVER-87034 Initally formatted all markdown using prettier
64e388007ec1ac3744537253540995af628bcc00

View File

@@ -1,5 +1,14 @@
# Ignore all formatting in third_party/*
src/third_party
# Ignore everything
# We are making prettier opt in for the moment while we work on the rollout
# !*/ means do not ignore recursive directories
# Together these work togather to make nothing opted-in by default
*
!*/
# Do not ignore markdown
# We are only going to do markdown file formatting for now
# Hopefully we will use prettier for more file types in the future
!*.md
# Ignore all template files
# When we eventually enable prettier on javascript these files are invalid and should be ignored
@@ -8,14 +17,5 @@ src/third_party
# Ignore .yy files since prettier seems to think these are json files
**/*.yy
# Ignore everything
# We are making prettier opt in for the moment while we work on the rollout
*
# Do not ignore markdown
# TODO: DEVPROD-3079 enable markdown formatting
# !*.md
# Do not ignore recursive directories
# TODO: DEVPROD-3079 enable markdown formatting
# !*/
# Ignore all formatting in third_party/*
src/third_party

View File

@@ -46,6 +46,7 @@
"mypy"
],
"mypy-type-checker.importStrategy": "fromEnvironment",
"editor.defaultFormatter": "esbenp.prettier-vscode",
"[c]": {
"editor.defaultFormatter": "xaver.clang-format",
"editor.formatOnSave": true,
@@ -73,7 +74,8 @@
"cs128.cs128-clang-tidy",
"eeyore.yapf",
"ms-python.pylint",
"ms-python.mypy-type-checker"
"ms-python.mypy-type-checker",
"esbenp.prettier-vscode"
]
}
}

View File

@@ -1,6 +1,4 @@
load("@aspect_rules_lint//format:defs.bzl", "multi_formatter_binary")
load("@npm//:defs.bzl", "npm_link_all_packages")
load("@npm//:prettier/package_json.bzl", prettier = "bin")
package(default_visibility = ["//visibility:public"])
@@ -12,18 +10,7 @@ exports_files([
npm_link_all_packages(name = "node_modules")
# TODO: SERVER-82329 eslint binary should almost exactly mirror prettier binary
# To update prettier change the version in package.json
# Run `pnpm install`
# Commit changes
prettier.prettier_binary(
name = "prettier",
# Allow the binary to be run outside bazel
# See more details about this by commenting this out and running `bazel run //:format`
env = {"BAZEL_BINDIR": "."},
)
multi_formatter_binary(
alias(
name = "format",
markdown = ":prettier",
actual = "//bazel/format",
)

View File

@@ -137,15 +137,15 @@ npm_repositories()
# See https://github.com/aspect-build/rules_lint/releases/tag/v0.11.0 for all supported formatters
http_archive(
name = "aspect_rules_lint",
sha256 = "98bed74aff6498ea9b58ff36db27a952c7a1b53764171c5d0d29ef0c61ffc4fb",
strip_prefix = "rules_lint-0.11.0",
sha256 = "41fad363f11ccab46a244f93f8ccb0f442bc235e606d2fad87801987ad0759b1",
strip_prefix = "rules_lint-0.12.0",
urls = [
# Implements retry by relisting each url multiple times to be used as a failover.
# TODO(SERVER-86719): Re-implement http_archive to allow sleeping between retries
"https://github.com/aspect-build/rules_lint/releases/download/v0.11.0/rules_lint-v0.11.0.tar.gz",
"https://github.com/aspect-build/rules_lint/releases/download/v0.11.0/rules_lint-v0.11.0.tar.gz",
"https://github.com/aspect-build/rules_lint/releases/download/v0.11.0/rules_lint-v0.11.0.tar.gz",
"https://github.com/aspect-build/rules_lint/releases/download/v0.11.0/rules_lint-v0.11.0.tar.gz",
"https://github.com/aspect-build/rules_lint/releases/download/v0.11.0/rules_lint-v0.11.0.tar.gz",
"https://github.com/aspect-build/rules_lint/releases/download/v0.12.0/rules_lint-v0.12.0.tar.gz",
"https://github.com/aspect-build/rules_lint/releases/download/v0.12.0/rules_lint-v0.12.0.tar.gz",
"https://github.com/aspect-build/rules_lint/releases/download/v0.12.0/rules_lint-v0.12.0.tar.gz",
"https://github.com/aspect-build/rules_lint/releases/download/v0.12.0/rules_lint-v0.12.0.tar.gz",
"https://github.com/aspect-build/rules_lint/releases/download/v0.12.0/rules_lint-v0.12.0.tar.gz",
],
)

19
bazel/format/BUILD.bazel Normal file
View File

@@ -0,0 +1,19 @@
load("@aspect_rules_lint//format:defs.bzl", "multi_formatter_binary")
load("@npm//:prettier/package_json.bzl", prettier = "bin")
# TODO: SERVER-82329 eslint binary should almost exactly mirror prettier binary
# To update prettier change the version in package.json
# Run `pnpm install`
# Commit changes
prettier.prettier_binary(
name = "prettier",
# Allow the binary to be run outside bazel
# See more details about this by commenting this out and running `bazel run //:format`
env = {"BAZEL_BINDIR": "."},
)
multi_formatter_binary(
name = "format",
markdown = ":prettier",
visibility = ["//visibility:public"],
)

View File

@@ -125,6 +125,7 @@ post:
- func: "cleanup external auth OIDC resources"
- func: "upload npm logs"
- func: "attach local resmoke invocation"
- func: "attach bazel invocation"
- func: "attach multiversion exclude tags"
- func: "attach report"
- func: "attach task errors"

View File

@@ -2386,6 +2386,19 @@ functions:
content_type: text/plain
display_name: Resmoke.py Invocation for Local Usage
"attach bazel invocation":
command: s3.put
params:
optional: true
aws_key: ${aws_key}
aws_secret: ${aws_secret}
local_file: src/bazel-invocation.txt
remote_file: ${project}/${build_variant}/${revision}/bazel-invocation-${task_id}-${execution}.txt
bucket: mciuploads
permissions: public-read
content_type: text/plain
display_name: Bazel invocation for local usage
"attach multiversion download links":
command: s3.put
params:

View File

@@ -394,6 +394,8 @@ tasks:
vars:
target: >-
//src/mongo/platform:visibility_test1
teardown_task:
- func: "attach bazel invocation"
- name: run_bazel_program_windows
tags: ["assigned_to_jira_team_devprod_build", "bazel_check"]
@@ -413,6 +415,8 @@ tasks:
--compilation_mode=dbg
--//bazel/config:build_mode=dbg
--copt /std:c++20
teardown_task:
- func: "attach bazel invocation"
## compile - build all scons targets except unittests ##
- name: compile_dist_test_half

View File

@@ -560,6 +560,35 @@ tasks:
jepsen_storage_engine: --storage-engine wiredTiger
jepsen_test_name: set
# TODO: rename if display_name appears on the evergreen UI
- name: bazel_run_//:format
tags: ["assigned_to_jira_team_devprod_build", "development_critical_single_variant", "lint"]
depends_on:
- name: version_expansions_gen
variant: generate-tasks-for-version
commands:
- command: timeout.update
params:
# 40 minutes
exec_timeout_secs: 2400
- func: "f_expansions_write"
- command: manifest.load
- func: "git get project and add git tag"
- func: "f_expansions_write"
- func: "kill processes"
- func: "cleanup environment"
- func: "set up venv"
- func: "upload pip requirements"
- func: "get engflow creds"
# TODO SERVER-81038: Remove "fetch bazel" once bazelisk is self-hosted.
- func: "fetch bazel"
- func: "bazel run"
vars:
target: >-
//:format -- --mode check
teardown_task:
- func: "attach bazel invocation"
- name: lint_clang_format
tags: ["assigned_to_jira_team_devprod_build", "development_critical_single_variant", "lint"]
commands:

View File

@@ -46,4 +46,8 @@ if [[ $ARCH == "ppc64le" ]]; then
export JAVA_HOME="/usr/lib/jvm/java-11-openjdk-11.0.4.11-2.el8.ppc64le"
fi
# Print command being run to file that can be uploaded
echo "$BAZEL_BINARY run --verbose_failures $LOCAL_ARG ${args} ${target}" > bazel-invocation.txt
# Run bazel command
eval $BAZEL_BINARY run --verbose_failures $LOCAL_ARG ${args} ${target}