Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: more precommit hooks #1325

Merged
merged 10 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/release_prep.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ TAG=${GITHUB_REF_NAME}
# The prefix is chosen to match what GitHub generates for source archives
PREFIX="rules_foreign_cc-${TAG}"
ARCHIVE="rules_foreign_cc-$TAG.tar.gz"
git archive --format=tar --prefix=${PREFIX}/ ${TAG} | gzip > $ARCHIVE
SHA=$(shasum -a 256 $ARCHIVE | awk '{print $1}')
git archive --format=tar --prefix="${PREFIX}"/ "${TAG}" | gzip > "$ARCHIVE"
SHA="$(shasum -a 256 "$ARCHIVE" | awk '{print $1}')"

cat << EOF
## Using Bzlmod with Bazel 6
Expand All @@ -23,7 +23,7 @@ bazel_dep(name = "rules_foreign_cc", version = "${TAG}")

## Using WORKSPACE

Paste this snippet into your `WORKSPACE.bazel` file:
Paste this snippet into your \`WORKSPACE.bazel\` file:

\`\`\`starlark
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
Expand All @@ -43,4 +43,4 @@ EOF

# TODO: add example of how to configure for bzlmod
# awk 'f;/--SNIP--/{f=1}' e2e/smoke/WORKSPACE.bazel
echo "\`\`\`"
echo "\`\`\`"
31 changes: 25 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
# See CONTRIBUTING.md for instructions.
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
exclude: >-
(?x)^(
bazel-.*/.*
|.*\.patch
|.*\.diff
|test/(expected|.*/expected)/.*\.txt
|examples/(?!.*CMakeLists\.txt$).*\.txt
)$

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: check-merge-conflict
- id: mixed-line-ending
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml

- repo: https://github.com/keith/pre-commit-buildifier
Expand All @@ -21,16 +34,22 @@ repos:
rev: v0.6.0
hooks:
- id: action-validator
files: >-
(?x)^(
.github/workflows/pages.yaml
)$

- repo: https://github.com/rhysd/actionlint
rev: v1.7.4
hooks:
- id: actionlint
files: >-

- repo: https://github.com/mrtazz/checkmake.git
rev: 0.2.2
hooks:
- id: checkmake

- repo: https://github.com/shellcheck-py/shellcheck-py
rev: v0.10.0.1
hooks:
- id: shellcheck
exclude: >-
(?x)^(
.github/workflows/pages.yaml
examples/.*
)$
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
name = "rules_foreign_cc",
# TODO: Get the latest sha256 value from a bazel debug message or the latest
# TODO: Get the latest sha256 value from a bazel debug message or the latest
# release on the releases page: https://github.com/bazel-contrib/rules_foreign_cc/releases
#
# sha256 = "...",
Expand Down
2 changes: 1 addition & 1 deletion docs/tools/workspace_status.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ set -euo pipefail

echo STABLE_SCM_SHORT_VERSION "$(git rev-parse --short HEAD)"
echo STABLE_SCM_VERSION "$(git rev-parse HEAD)"
echo STABLE_RELEASE "$(cat ../version.bzl | grep VERSION | sed 's/VERSION = "//' | sed 's/"//')"
echo STABLE_RELEASE "$(grep VERSION ../version.bzl | sed 's/VERSION = "//' | sed 's/"//')"
2 changes: 1 addition & 1 deletion examples/cmake_android/hello_lib-example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ int main(int argc, char* argv[])
{
hello_func();
return 0;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>
</adaptive-icon>
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>
</adaptive-icon>
2 changes: 1 addition & 1 deletion examples/cmake_android/zlib-example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,4 @@ int main(int argc, char* argv[])
assert(strcmp(a,c)==0);

return 0;
}
}
2 changes: 1 addition & 1 deletion examples/cmake_crosstool/.bazelrc
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
build --crosstool_top=//tools/arm_compiler:toolchain --cpu=armeabi-v7a --spawn_strategy=standalone --experimental_cc_skylark_api_enabled_packages=@rules_foreign_cc//tools/build_defs,tools/build_defs,@foreign_cc_impl
test --crosstool_top=//tools/arm_compiler:toolchain --cpu=armeabi-v7a --spawn_strategy=standalone --experimental_cc_skylark_api_enabled_packages=@rules_foreign_cc//tools/build_defs,tools/build_defs,@foreign_cc_impl
test --crosstool_top=//tools/arm_compiler:toolchain --cpu=armeabi-v7a --spawn_strategy=standalone --experimental_cc_skylark_api_enabled_packages=@rules_foreign_cc//tools/build_defs,tools/build_defs,@foreign_cc_impl
2 changes: 1 addition & 1 deletion examples/cmake_crosstool/static/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ cmake_minimum_required(VERSION 2.8.4)

project(hellolib)

add_subdirectory(src)
add_subdirectory(src)
2 changes: 1 addition & 1 deletion examples/cmake_crosstool/static/hello_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ int main(int argc, char* argv[])
{
hello_func();
return 0;
}
}
2 changes: 1 addition & 1 deletion examples/cmake_crosstool/static/hello_client_version123.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ int main(int argc, char* argv[])
{
hello_func();
return 0;
}
}
2 changes: 1 addition & 1 deletion examples/cmake_crosstool/static/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib)

install(TARGETS hello_static ARCHIVE DESTINATION lib)

install(FILES hello.h DESTINATION include/version123)
install(FILES hello.h DESTINATION include/version123)
2 changes: 1 addition & 1 deletion examples/cmake_crosstool/static/src/hello.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ void hello_func(void) {
printf("Hello World!\n");

return;
}
}
2 changes: 1 addition & 1 deletion examples/cmake_crosstool/static/src/hello.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@

void hello_func(void);

#endif
#endif
2 changes: 1 addition & 1 deletion examples/cmake_crosstool/static/test_hello.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/usr/bin/env bash

$(rlocation rules_foreign_cc/examples/cmake_hello_world_lib/$1)
$(rlocation rules_foreign_cc/examples/cmake_hello_world_lib/$1)
2 changes: 1 addition & 1 deletion examples/cmake_defines/lib_a/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
project(cmake_defines)

add_library(lib_a lib_a.cpp)
install(TARGETS lib_a ARCHIVE DESTINATION lib)
install(TARGETS lib_a ARCHIVE DESTINATION lib)
2 changes: 1 addition & 1 deletion examples/cmake_defines/lib_b/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
project(cmake_defines)

add_library(lib_b lib_b.cpp)
install(TARGETS lib_b ARCHIVE DESTINATION lib)
install(TARGETS lib_b ARCHIVE DESTINATION lib)
2 changes: 1 addition & 1 deletion examples/cmake_hello_world_lib/binary/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ cmake_minimum_required(VERSION 2.8.4)

project(hellolib LANGUAGES C)

add_subdirectory(src)
add_subdirectory(src)
2 changes: 1 addition & 1 deletion examples/cmake_hello_world_lib/binary/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ install(
TARGETS myapp DESTINATION bin
)

install(FILES hello.h DESTINATION include)
install(FILES hello.h DESTINATION include)
2 changes: 1 addition & 1 deletion examples/cmake_hello_world_lib/binary/src/hello.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

void hello_func(char* name) {
printf("Hello, %s!", name);
}
}
2 changes: 1 addition & 1 deletion examples/cmake_hello_world_lib/binary/src/hello.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@

void hello_func(char*);

#endif
#endif
2 changes: 1 addition & 1 deletion examples/cmake_hello_world_lib/binary/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ int main(int argc, char* argv[])
{
hello_func(argv[1]);
return 0;
}
}
2 changes: 1 addition & 1 deletion examples/cmake_hello_world_lib/shared/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)

project(hellolib LANGUAGES C)

add_subdirectory(src)
add_subdirectory(src)
2 changes: 1 addition & 1 deletion examples/cmake_hello_world_lib/shared/hello_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ int main(int argc, char* argv[])
{
hello_func();
return 0;
}
}
2 changes: 1 addition & 1 deletion examples/cmake_hello_world_lib/shared/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ install(
LIBRARY DESTINATION lib
)

install(FILES hello.h DESTINATION include)
install(FILES hello.h DESTINATION include)
2 changes: 1 addition & 1 deletion examples/cmake_hello_world_lib/shared/src/hello.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ void hello_func(void) {
printf("Hello World!\n");

return;
}
}
2 changes: 1 addition & 1 deletion examples/cmake_hello_world_lib/shared/src/hello.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@

void hello_func(void);

#endif
#endif
2 changes: 1 addition & 1 deletion examples/cmake_hello_world_lib/static/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ cmake_minimum_required(VERSION 2.8.4)

project(hellolib)

add_subdirectory(src)
add_subdirectory(src)
2 changes: 1 addition & 1 deletion examples/cmake_hello_world_lib/static/hello_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ int main(int argc, char* argv[])
{
hello_func();
return 0;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ int main(int argc, char* argv[])
{
hello_func();
return 0;
}
}
2 changes: 1 addition & 1 deletion examples/cmake_hello_world_lib/static/src/hello.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ void hello_func(void) {
printf("Hello World!\n");

return;
}
}
2 changes: 1 addition & 1 deletion examples/cmake_synthetic/liba/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ cmake_minimum_required(VERSION 2.8.4)

project(liba)

add_subdirectory(src)
add_subdirectory(src)
2 changes: 1 addition & 1 deletion examples/cmake_synthetic/liba/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ target_include_directories(liba_static INTERFACE

install(EXPORT liba_targets
DESTINATION lib/cmake/liba
FILE liba-config.cmake)
FILE liba-config.cmake)
2 changes: 1 addition & 1 deletion examples/cmake_synthetic/liba/src/liba.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

std::string hello_liba(void) {
return "Hello from LIBA!";
}
}
2 changes: 1 addition & 1 deletion examples/cmake_synthetic/liba/src/liba.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@

std::string hello_liba(void);

#endif
#endif
2 changes: 1 addition & 1 deletion examples/cmake_synthetic/libb/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib)

install(TARGETS libb_static ARCHIVE DESTINATION lib)

install(FILES libb.h DESTINATION include)
install(FILES libb.h DESTINATION include)
2 changes: 1 addition & 1 deletion examples/cmake_synthetic/libb/src/libb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

std::string hello_libb(void) {
return hello_liba() + " Hello from LIBB!";
}
}
2 changes: 1 addition & 1 deletion examples/cmake_synthetic/libb/src/libb.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@

std::string hello_libb(void);

#endif
#endif
2 changes: 1 addition & 1 deletion examples/cmake_synthetic/libc/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib)

install(TARGETS libc_static ARCHIVE DESTINATION lib)

install(FILES libc.h DESTINATION include)
install(FILES libc.h DESTINATION include)
2 changes: 1 addition & 1 deletion examples/cmake_synthetic/libc/src/libc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

std::string hello_libc(void) {
return hello_liba() + " " + hello_libb() + " Hello from LIBC!";
}
}
2 changes: 1 addition & 1 deletion examples/cmake_synthetic/libc/src/libc.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@

std::string hello_libc(void);

#endif
#endif
2 changes: 1 addition & 1 deletion examples/cmake_synthetic/test_libb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ int main(int argc, char* argv[])
throw std::runtime_error("Wrong result: " + result);
}
std::cout << "Everything's fine!";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib)

install(TARGETS libb_static ARCHIVE DESTINATION lib)

install(FILES libb.h DESTINATION include)
install(FILES libb.h DESTINATION include)
2 changes: 1 addition & 1 deletion examples/cmake_with_bazel_transitive/libb/src/libb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

std::string hello_libb(void) {
return hello_liba() + " Hello from LIBB!";
}
}
2 changes: 1 addition & 1 deletion examples/cmake_with_bazel_transitive/libb/src/libb.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@

std::string hello_libb(void);

#endif
#endif
2 changes: 1 addition & 1 deletion examples/cmake_with_bazel_transitive/test_libb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ int main(int argc, char* argv[])
throw std::runtime_error("Wrong result: " + result);
}
std::cout << "Everything's fine!";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ target_include_directories(liba_static INTERFACE

install(EXPORT liba_targets
DESTINATION lib/cmake/liba
FILE liba-config.cmake)
FILE liba-config.cmake)
Loading