Commit Graph

11 Commits

Author SHA1 Message Date
Wyatt Hepler
fa70745e1c pw_presubmit: Update a few checks
- Fix Go formatting, which was accidentally using clang-format.
- Update source_is_in_build_files to query the build system rather than
  check build file contents.
- Remove pylint_errors_only check since full pylint is running.
- Add log_run wrapper that logs at debug then calls subprocess.run.

Change-Id: I1a335e2999b5aabcb2a39a2d8bc9fbe43d6dd75b
2019-12-09 19:20:09 +00:00
Wyatt Hepler
9113c9fea2 pw_presubmit: Always init_virtualenv; options
- Remove the path filter for init_virtualenv since the build depends on
  Python.
- Add --clean-py option for cleaning only the Python venv.
- Rename --continue to --keep-going for consistency with Bazel.
- Make updates to Git path handling to correctly handle absolute versus
  relative paths.
- Make the .presubmit directory relative to the root of the repo.

Change-Id: I9b2ce32dd4e1a9c993a10f37c252a685625c46ad
2019-12-06 16:24:11 -08:00
Alexei Frolov
d0b2d48782 Add pw_test_server module
This change adds a pw_test_server module which implements a gRPC server
for queueing and distributing unit tests across multiple test runners.
The server is implemented as a Go library which can be imported and used
by developers to build a custom unit test running infrastructure.

To use the server, a UnitTestRunner interface that processes requests to
run unit tests must be implemented and registered with the server. An
implementation of this interface which runs unit test executables
through an external command is provided alongside the server.

An example program that uses the server library to run a unit test
server is also provided within the module. This program uses the
command-based test runners to run unit tests on a local machine. It is
configurable through a config file, allowing multiple workers to be
registered with the server. The program additionally doubles as a gRPC
client for the server which can be invoked with the path to a unit test
executable to schedule it to be run.

Change-Id: I347d230370620395de09e277f9763d7df1c4abad
2019-12-06 22:55:28 +00:00
Wyatt Hepler
1ea1305312 pw_presubmit: Build file check; fatal pylint
- Check that all C, C++ sources appear in BUILD and BUILD.gn files.
- Check that all .rst files appear in BUILD.gn files.
- Make the pylint check fatal. The full presubmit will fail until some
  issues are fixed. Incremental presubmits (e.g. with the pre-push hook
  or pw presubmit --base master) will pass (unless there are errors).

Change-Id: Id42cc2e06278d0e56017a2008676db8e77ba6c20
2019-12-06 12:54:48 -08:00
Wyatt Hepler
ce14cb227e pw_presubmit: Use logging; UI improvements
- Switch many print statements to log statements.
- Only show command output when commands fail or debug logging is
  enabled.
- Add a wrapper class for check functions to consolidate running
  and logging logic for presubmit checks.

Change-Id: I72e155d602135b60c18f8973a778f40e65bb40da
2019-12-06 12:54:48 -08:00
Wyatt Hepler
b90f341ba5 pw_presubmit: Add new pw format command
- pw format (or pw_presubmit/format_code.py) supports checking and
  fixing the format of Python, C/C++, GN, and Go code.
- Move code format presubmit checks into format_code.py.
- Accept paths not in a Git repository for pw format.
- Add an explicit check that pw presubmit is run from a Git repo.

Change-Id: I74bf54057bd5ace70a90271f7d1343711455792a
2019-12-05 09:31:11 -08:00
Wyatt Hepler
bc292b9152 pw_presubmit: Rename format_cc to format_code
- Rename format_cc.py to format_code.py to make it language-agnostic.
- Exclude non-existing paths in the presubmit to handle deletions.

Change-Id: If07decfd9fe11539bd5ccc74243f00cbf33736b8
2019-12-04 23:50:19 +00:00
Wyatt Hepler
f2278ee6b0 presubmit: Fix invoking script directly
Change-Id: I1dff5a6d91335ecf7213b0c3f9e511cc067318ef
2019-12-03 17:06:14 +00:00
Wyatt Hepler
3767c3a5b2 Script for installing a presubmit pre-push hook
- The install_hook.py script installs a simple presubmit hook that wraps
  another command.
- Add an --install option to Pigweed's presubmit that installs the
  commit hook and exits.

Change-Id: I1b9296b103e0b94e1ff44cc5b274590f56f72831
2019-12-02 14:26:14 -08:00
Wyatt Hepler
c426bdc032 pw_presubmit: Improve final summary
List total, passed, failed, and skipped presubmit checks.

Example:
╔════════╦═══════════════════════════════════════════════════╦════════╗
║ FAILED ║ 14 checks: 8 passed, 1 failed, 5 skipped          ║ 0:01.9 ║
╚════════╩═══════════════════════════════════════════════════╩════════╝

Change-Id: Icccc718ebd194acad1760dadb9f76f81995103ed
2019-12-02 14:25:58 -08:00
Wyatt Hepler
c18f4b28d7 presubmit: Make pw_presubmit a package and plugin
- Organize pw_presubmit as a Python package.
- Move presubmit.py to into the package as pigweed_presubmit.py.
- Set up pigweed_presubmit.py to run whether the pw_presubmit package is
  installed or not.

Change-Id: Id85937971d554332ab7d4adfd668eeafa6379976
2019-12-02 22:00:40 +00:00