Skip to content

Commit

Permalink
chore: turn on more basic precommit checks
Browse files Browse the repository at this point in the history
In particular this makes our bazelrc presets more compliant with client codebases, ensuring they can copy these files and not trip on their own pre-commit check
  • Loading branch information
alexeagle committed Feb 17, 2023
1 parent fde705b commit d950079
Show file tree
Hide file tree
Showing 40 changed files with 83 additions and 83 deletions.
2 changes: 1 addition & 1 deletion .aspect/bazelrc/correctness.bazelrc
Expand Up @@ -46,7 +46,7 @@ build --incompatible_strict_action_env
# Propagate tags from a target declaration to the actions' execution requirements.
# Ensures that tags applied in your BUILD file, like `tags=["no-remote"]`
# get propagated to actions created by the rule.
# Without this option, you rely on rules authors to manually check the tags you passed
# Without this option, you rely on rules authors to manually check the tags you passed
# and apply relevant ones to the actions they create.
# See https://github.com/bazelbuild/bazel/issues/8830 for details.
# Docs: https://bazel.build/reference/command-line-reference#flag--experimental_allow_tags_propagation
Expand Down
2 changes: 1 addition & 1 deletion .bazelignore
@@ -1 +1 @@
e2e/
e2e/
2 changes: 1 addition & 1 deletion .github/workflows/ci.bazelrc
Expand Up @@ -25,4 +25,4 @@ build:rbe --remote_executor=grpcs://tourmaline.cluster.engflow.com
build:rbe --modify_execution_info=GoCompilePkg=+no-remote-exec

# These files are written during CI setup, using secrets registered with the CI platforms
build:rbe --tls_client_certificate=engflow.crt --tls_client_key=engflow.key
build:rbe --tls_client_certificate=engflow.crt --tls_client_key=engflow.key
12 changes: 12 additions & 0 deletions .pre-commit-config.yaml
Expand Up @@ -24,3 +24,15 @@ repos:
rev: "v2.4.0"
hooks:
- id: prettier
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: check-added-large-files
- id: check-byte-order-marker
- id: check-case-conflict
- id: check-symlinks
- id: destroyed-symlinks
- id: end-of-file-fixer
exclude: &exclude_pattern "^(docs|lib/tests)/"
- id: mixed-line-ending
- id: trailing-whitespace
2 changes: 1 addition & 1 deletion .prettierignore
Expand Up @@ -4,4 +4,4 @@ lib/tests/jq/*.json
lib/tests/yq/empty.yaml
lib/lib/tests/write_source_files/*.js
lib/lib/tests/write_source_files/subdir/*.js
lib/lib/tests/write_source_files/subdir/subsubdir/*.js
lib/lib/tests/write_source_files/subdir/subsubdir/*.js
1 change: 0 additions & 1 deletion LICENSE
Expand Up @@ -175,4 +175,3 @@
of your accepting any such warranty or additional liability.

END OF TERMS AND CONDITIONS

2 changes: 1 addition & 1 deletion docs/copy_to_directory.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/expand_make_vars.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/templates/func_html.vm
Expand Up @@ -46,4 +46,4 @@ ${funcInfo.getReturn().docString}
#[[###]]# **Deprecated**

${funcInfo.getDeprecated().docString}
#end
#end
2 changes: 1 addition & 1 deletion docs/templates/rule_html.vm
Expand Up @@ -34,4 +34,4 @@ ${ruleInfo.docString}
#foreach ($attribute in $ruleInfo.getAttributeList())
| <a id="${ruleName}-${attribute.name}"></a>$attribute.name | #if(!$attribute.docString.isEmpty()) #markdownCellFormatNoEscapeHtml( $attribute.docString ) #else - #end | ${util.attributeTypeString($attribute)} | ${util.mandatoryString($attribute)} | $attribute.defaultValue |
#end
#end
#end
2 changes: 1 addition & 1 deletion e2e/bzlmod/d/1
@@ -1 +1 @@
1
1
3 changes: 0 additions & 3 deletions e2e/bzlmod/docs.md
@@ -1,4 +1 @@
<!-- Generated with Stardoc: http://skydoc.bazel.build -->



1 change: 0 additions & 1 deletion e2e/bzlmod/expected_yq
@@ -1 +0,0 @@

1 change: 0 additions & 1 deletion e2e/bzlmod_write_source_files_external/MODULE.bazel
Expand Up @@ -14,4 +14,3 @@ local_path_override(
test_ext = use_extension("//:test_extension.bzl", "test_ext")

use_repo(test_ext, "test")

2 changes: 1 addition & 1 deletion e2e/copy_to_directory/a
@@ -1 +1 @@
a
a
2 changes: 1 addition & 1 deletion e2e/copy_to_directory/expected1/a
@@ -1 +1 @@
a
a
2 changes: 1 addition & 1 deletion e2e/copy_to_directory/expected1/subpkg/b
@@ -1 +1 @@
b
b
2 changes: 1 addition & 1 deletion e2e/copy_to_directory/expected2/a
@@ -1 +1 @@
a
a
2 changes: 1 addition & 1 deletion e2e/copy_to_directory/expected3/subpkg/b
@@ -1 +1 @@
b
b
2 changes: 1 addition & 1 deletion e2e/copy_to_directory/subpkg/b
@@ -1 +1 @@
b
b
1 change: 0 additions & 1 deletion e2e/run_jq_symlinked_bin.sh
Expand Up @@ -10,4 +10,3 @@ case "$(uname -s)" in
bazel run @jq//:jq -- --null-input .a=5
;;
esac

2 changes: 1 addition & 1 deletion e2e/run_yq_symlinked_bin.sh
Expand Up @@ -9,4 +9,4 @@ case "$(uname -s)" in
*)
bazel run @yq//:yq -- --null-input .a=5
;;
esac
esac
2 changes: 1 addition & 1 deletion e2e/workspace/d/1
@@ -1 +1 @@
1
1
1 change: 0 additions & 1 deletion e2e/workspace/expected_yq
@@ -1 +0,0 @@

2 changes: 1 addition & 1 deletion internal_deps.bzl
Expand Up @@ -4,7 +4,7 @@ Users should *not* need to install these. If users see a load()
statement from these, that's a bug in our distribution.
"""

load("//lib:repositories.bzl", "register_jq_toolchains", "register_yq_toolchains", "register_coreutils_toolchains")
load("//lib:repositories.bzl", "register_coreutils_toolchains", "register_jq_toolchains", "register_yq_toolchains")
load("//lib:utils.bzl", http_archive = "maybe_http_archive")

# buildifier: disable=unnamed-macro
Expand Down
2 changes: 1 addition & 1 deletion lib/glob_match.bzl
Expand Up @@ -3,4 +3,4 @@
load("//lib/private:glob_match.bzl", _glob_match = "glob_match", _is_glob = "is_glob")

glob_match = _glob_match
is_glob = _is_glob
is_glob = _is_glob
2 changes: 1 addition & 1 deletion lib/private/copy_to_directory.bzl
Expand Up @@ -195,7 +195,7 @@ replaced with the dict value for that key. The final path segment
matched can be a partial match of that segment and only the matching portion will
be replaced. If there are multiple keys that match, the longest match wins.
Forward slashes (`/`) should be used as path separators.
Forward slashes (`/`) should be used as path separators.
Replace prefix transformation are the final step in the list of filters and transformations.
The final output path of a file being copied into the output directory
Expand Down
38 changes: 19 additions & 19 deletions lib/private/coreutils_toolchain.bzl
Expand Up @@ -41,24 +41,24 @@ DEFAULT_COREUTILS_VERSION = "0.0.16"
# The integrity hashes can be automatically fetched for the coreutils releases by running
# `tools/coreutils_mirror_release.sh`.
COREUTILS_VERSIONS = {
"0.0.16": {
"linux_arm64": {
"filename": "coreutils-0.0.16-aarch64-unknown-linux-gnu.tar.gz",
"sha256": "sha256-6tExkcMMHe7+59M9Mp9UKeq+g0y+juO7oakZfVOtOqw="
"0.0.16": {
"linux_arm64": {
"filename": "coreutils-0.0.16-aarch64-unknown-linux-gnu.tar.gz",
"sha256": "sha256-6tExkcMMHe7+59M9Mp9UKeq+g0y+juO7oakZfVOtOqw=",
},
"darwin_amd64": {
"filename": "coreutils-0.0.16-x86_64-apple-darwin.tar.gz",
"sha256": "sha256-lQYWAuPOKS6XxwArZdiKIyczwppTVwjF4ml0iKBaB9s=",
},
"windows_amd64": {
"filename": "coreutils-0.0.16-x86_64-pc-windows-msvc.zip",
"sha256": "sha256-z5E1onYAKZoaUt2U1cv1t8UHPsJinYktEd6SpE2u07o=",
},
"linux_amd64": {
"filename": "coreutils-0.0.16-x86_64-unknown-linux-gnu.tar.gz",
"sha256": "sha256-Slf4qKf19sAWoK2pUVluAitmL3N2uz4eWpV4eibIEW0=",
},
},
"darwin_amd64": {
"filename": "coreutils-0.0.16-x86_64-apple-darwin.tar.gz",
"sha256": "sha256-lQYWAuPOKS6XxwArZdiKIyczwppTVwjF4ml0iKBaB9s="
},
"windows_amd64": {
"filename": "coreutils-0.0.16-x86_64-pc-windows-msvc.zip",
"sha256": "sha256-z5E1onYAKZoaUt2U1cv1t8UHPsJinYktEd6SpE2u07o="
},
"linux_amd64": {
"filename": "coreutils-0.0.16-x86_64-unknown-linux-gnu.tar.gz",
"sha256": "sha256-Slf4qKf19sAWoK2pUVluAitmL3N2uz4eWpV4eibIEW0="
}
}
}

CoreUtilsInfo = provider(
Expand Down Expand Up @@ -99,7 +99,7 @@ coreutils_toolchain = rule(
attrs = {
"binary": attr.label(
mandatory = True,
allow_single_file = True
allow_single_file = True,
),
},
)
Expand Down Expand Up @@ -176,7 +176,7 @@ def _coreutils_platform_repo_impl(rctx):
filename = COREUTILS_VERSIONS[rctx.attr.version][platform]["filename"]
url = "https://github.com/uutils/coreutils/releases/download/{}/{}".format(
rctx.attr.version,
filename
filename,
)
rctx.download_and_extract(
url = url,
Expand Down
1 change: 0 additions & 1 deletion lib/private/diff_test_tmpl.sh
Expand Up @@ -57,4 +57,3 @@ else
fail "files \"{file1}\" and \"{file2}\" differ. {fail_msg}"
fi
fi

2 changes: 1 addition & 1 deletion lib/private/expand_template.bzl
Expand Up @@ -19,7 +19,7 @@ def _expand_template_impl(ctx):

expand_template_lib = struct(
doc = """Template expansion
This performs a simple search over the template file for the keys in substitutions,
and replaces them with the corresponding values.
Expand Down
2 changes: 1 addition & 1 deletion lib/private/host_repo.bzl
Expand Up @@ -6,7 +6,7 @@ load(":repo_utils.bzl", "repo_utils")
def _host_repo_impl(rctx):
# Base BUILD file for this repository
rctx.file("BUILD.bazel", """# @generated by @aspect_bazel_lib//lib/private:host_repo.bzl
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
bzl_library(
name = "defs",
srcs = ["defs.bzl"],
Expand Down
2 changes: 1 addition & 1 deletion lib/private/local_config_platform.bzl
Expand Up @@ -32,7 +32,7 @@ exports_files([
local_config_platform = repository_rule(
implementation = _impl,
doc = """Generates a repository in the same shape as the auto-generated @local_config_platform repository with an added bzl_library.
This is useful for rules that want to load `HOST_CONSTRAINTS` from `@local_config_platform//:constraints.bzl` and
also want to use stardoc for generating documentation.
""",
Expand Down
2 changes: 1 addition & 1 deletion lib/private/output_files.bzl
Expand Up @@ -85,4 +85,4 @@ def _find_short_path_in_files_list(files_list, short_path):
for file in files_list:
if file.short_path == short_path:
return file
return None
return None
2 changes: 1 addition & 1 deletion lib/private/parse_status_file.jq
@@ -1,4 +1,4 @@
[
[
split("\n")[] # Convert lines to array
| capture("(?<key>[^\\s]+)\\s+(?<value>.*)"; "x") # capture {"key": [everything before first whitespace], "value": [remainder of line]}
]
Expand Down
3 changes: 1 addition & 2 deletions lib/tests/glob_match_test.bzl
Expand Up @@ -166,7 +166,6 @@ def _mixed_wrapping_globstar(ctx):

mixed_wrapper_globstar_test = unittest.make(_mixed_wrapping_globstar)


def _is_glob(ctx):
env = unittest.begin(ctx)

Expand Down Expand Up @@ -218,5 +217,5 @@ def glob_match_test_suite():

unittest.suite(
"is_glob",
partial.make(is_glob_test, timeout = "short")
partial.make(is_glob_test, timeout = "short"),
)
4 changes: 1 addition & 3 deletions renovate.json
@@ -1,5 +1,3 @@
{
"extends": [
"config:base"
]
"extends": ["config:base"]
}
2 changes: 1 addition & 1 deletion tools/copy_directory/mirror_release.sh
Expand Up @@ -28,4 +28,4 @@ done
echo "}"

printf "\n"
echo "Paste the above into lib/private/copy_directory_toolchain.bzl"
echo "Paste the above into lib/private/copy_directory_toolchain.bzl"
2 changes: 1 addition & 1 deletion tools/copy_to_directory/mirror_release.sh
Expand Up @@ -28,4 +28,4 @@ done
echo "}"

printf "\n"
echo "Paste the above into lib/private/copy_to_directory_toolchain.bzl"
echo "Paste the above into lib/private/copy_to_directory_toolchain.bzl"
44 changes: 22 additions & 22 deletions tools/coreutils_mirror_release.sh
Expand Up @@ -4,50 +4,50 @@ set -o errexit -o nounset -o pipefail

JQ_FILTER=\
'map({
"key": .tag_name,
"value": .assets
| map(select(
(.name | startswith("coreutils-")) and
"key": .tag_name,
"value": .assets
| map(select(
(.name | startswith("coreutils-")) and
((.name | endswith(".tar.gz")) or (.name | endswith(".zip"))) and
(.name | contains("i686") | not) and
(
( (.name | contains("windows")) and (.name | contains("gnu") | not) ) or
( (.name | contains("windows") | not) and (.name | contains("gnu") ) and (.name | contains("gnueabihf") | not) ) or
( (.name | contains("windows")) and (.name | contains("gnu") | not) ) or
( (.name | contains("windows") | not) and (.name | contains("gnu") ) and (.name | contains("gnueabihf") | not) ) or
( .name | contains("darwin") )
)
))
| map({
key: .name |
ltrimstr("coreutils-") |
rtrimstr(".tar.gz") |
rtrimstr(".zip") |
sub("-pc"; "") |
| map({
key: .name |
ltrimstr("coreutils-") |
rtrimstr(".tar.gz") |
rtrimstr(".zip") |
sub("-pc"; "") |
sub("-apple"; "") |
sub("-unknown"; "") |
sub("x86_64"; "amd64") |
sub("aarch64"; "arm64") |
gsub("\\d+.\\d+.\\d+-"; "") |
rtrimstr("-msvc") |
gsub("\\d+.\\d+.\\d+-"; "") |
rtrimstr("-msvc") |
rtrimstr("-gnu") |
split("-") |
reverse |
join("_"),
value: {
filename: .name,
sha256: "sha256-",
}
filename: .name,
sha256: "sha256-",
}
})
| from_entries
| from_entries
}) | from_entries
'


INFO="$(curl --silent -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/uutils/coreutils/releases?per_page=1 | jq "$JQ_FILTER")"


for VERSION in $(jq -r 'keys | join("\n")' <<< $INFO); do
for PLATFORM in $(jq -r ".[\"$VERSION\"] | keys | join(\"\n\")" <<< $INFO); do
FILENAME=$(jq -r ".[\"$VERSION\"][\"$PLATFORM\"].filename" <<< $INFO)
for VERSION in $(jq -r 'keys | join("\n")' <<< $INFO); do
for PLATFORM in $(jq -r ".[\"$VERSION\"] | keys | join(\"\n\")" <<< $INFO); do
FILENAME=$(jq -r ".[\"$VERSION\"][\"$PLATFORM\"].filename" <<< $INFO)
SHA256=$(curl -fLs "https://github.com/uutils/coreutils/releases/download/$VERSION/$FILENAME" | sha256sum | xxd -r -p | base64)
INFO=$(jq ".[\"$VERSION\"][\"$PLATFORM\"].sha256 = \"sha256-$SHA256\"" <<< $INFO)
done
Expand All @@ -57,4 +57,4 @@ echo -n "COREUTILS_VERSIONS = "
echo $INFO | jq -M

echo ""
echo "Copy the version info into lib/private/coreutils_toolchain.bzl"
echo "Copy the version info into lib/private/coreutils_toolchain.bzl"
2 changes: 1 addition & 1 deletion tools/yq_mirror_release.sh
Expand Up @@ -32,4 +32,4 @@ done
echo "},"

printf "\n"
echo "Paste the above into VERSIONS in yq_toolchain.bzl."
echo "Paste the above into VERSIONS in yq_toolchain.bzl."

0 comments on commit d950079

Please sign in to comment.