This is a reland of d3bfd23c6d
Don't modify cwd for paths other than depot_tools.
Original change's description:
> presubmit_canned_checks: Run pylint on parent directory for depot_tools.
>
> On Windows, scripts on the current directory take precedence over PATH.
> When pylint.bat calls vpython, it executes the vpython of the depot_tools
> under test instead of the one in the bot.
> As a workaround, run the tests from the parent directory instead.
>
> Change-Id: I7fa3f5b268df516194063ff39907ada18f7ef544
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1994216
> Reviewed-by: Anthony Polito <apolito@google.com>
> Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
No-Presubmit: True
Change-Id: I4236ec17b2642ed7f53844af532ec1f5234b80d1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1995783
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
Reviewed-by: Anthony Polito <apolito@google.com>
This reverts commit d3bfd23c6d.
Reason for revert: Breaks non-depot_tools based presubmits that use canned checks that expect the presubmit to be run in the sub-repository (for example, in Catapult where it's hosted in third_party/catapult instead of being directly in chromium).
Original change's description:
> presubmit_canned_checks: Run pylint on parent directory for depot_tools.
>
> On Windows, scripts on the current directory take precedence over PATH.
> When pylint.bat calls vpython, it executes the vpython of the depot_tools
> under test instead of the one in the bot.
> As a workaround, run the tests from the parent directory instead.
>
> Change-Id: I7fa3f5b268df516194063ff39907ada18f7ef544
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1994216
> Reviewed-by: Anthony Polito <apolito@google.com>
> Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
TBR=ehmaldonado@chromium.org,apolito@google.com
# Not skipping CQ checks because original CL landed > 1 day ago.
Change-Id: If989527a53be90e1ae32cb3fa30f5e4777824480
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1994753
Reviewed-by: Dean Berris <dberris@chromium.org>
Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
Commit-Queue: Dean Berris <dberris@chromium.org>
On Windows, scripts on the current directory take precedence over PATH.
When pylint.bat calls vpython, it executes the vpython of the depot_tools
under test instead of the one in the bot.
As a workaround, run the tests from the parent directory instead.
Change-Id: I7fa3f5b268df516194063ff39907ada18f7ef544
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1994216
Reviewed-by: Anthony Polito <apolito@google.com>
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
In repos that are checked out separately from chromium, invoking
"git cl format" on a change that has files that would be formatted using
clang-format causes an error because the depot_tools version of
clang-format looks for a clang-format inside the repo.
This prevents using proto-based properties (the preferred mechanism
going forward) in recipe repos that enforce formatting. The
--no-clang-format flag provides a workaround that can be used to
prevent trying to format any files where clang-format doesn't work.
Bug: 979330
Change-Id: Ice8561d88b29623deb953465253f92c88aa7fc2e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1986111
Commit-Queue: Garrett Beaty <gbeaty@chromium.org>
Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
The problems on crbug.com/1017367 should have been fixed by crrev.com/c/1880013
Bug: 1009814
Change-Id: Ia98304ca983b4e7e293fedb9df1fee589de58ba9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1887714
Reviewed-by: Anthony Polito <apolito@google.com>
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
On windows on Python 2, only strings can be environment variables, but
literals are unicode, so we need to convert to strings before setting
env vars.
Change-Id: I40e8e6ae4f5497d56efa568153eb65392dbd85e6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1875108
Reviewed-by: Dirk Pranke <dpranke@chromium.org>
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
Ran:
vi $(git grep --name-only iteritems | grep -v third_party)
vi $(git grep --name-only itervalues | grep -v third_party)
vi $(git grep --name-only 'print ' | grep -v third_party)
and edited the files quickly with adhoc macros. Then ran in recipes/:
./recipes.py test train
There was only a small subset of files that had been updated to use
six.iteritems() and six.itervalues(). Since the dataset size that is
being used in gclient is small (pretty much always below 200 items),
it's better to just switch to .items() right away and take the temporary
performance hit, so that we don't need to come back to rewrite the code.
Recipe-Nontrivial-Roll: build
Bug: 984182
Change-Id: I5faf11486b66b0d73c9098ab0f2ce1b15a45c53e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1854900
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
Auto-Submit: Marc-Antoine Ruel <maruel@chromium.org>
"Fixed:" is equivalent and the preferred syntax.
Also sets up a more generic mechanism for "unwanted tags",
which BUG= and TBR= may eventually be when we're ready to
move over to git-footers more fully.
Bug: monorail:4470
Change-Id: I2e999d364292447124870b8d3539fde1ac1eb4ec
Recipe-Nontrivial-Roll: chromiumos
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1836607
Auto-Submit: Dan Beam <dbeam@chromium.org>
Commit-Queue: Dan Beam <dbeam@chromium.org>
Reviewed-by: Aaron Gable <agable@chromium.org>
https://chromium-review.googlesource.com/982601 disabled TBR for CLs that
modified OWNERS files. This CL relaxes the restriction to permit TBR for
CLs that have LGTMs for their modifications to OWNERS files.
Bug: 688115
Change-Id: I47fef6b1eb021ca7cdfc003dc57722643b174a6e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1797605
Commit-Queue: Alan Cutter <alancutter@chromium.org>
Auto-Submit: Alan Cutter <alancutter@chromium.org>
Reviewed-by: Aaron Gable <agable@chromium.org>
Add run_on_python2 and run_on_python3 to allow to be tests on
either only python2, only python3 or both.
Bug: 984182
Change-Id: I87d3b67412129cf3a8e627cd6bc97daa81147657
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1758849
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
Reviewed-by: smut <smut@google.com>
Reviewed-by: Robbie Iannucci <iannucci@chromium.org>
This allows people to pin a specific version of pylint when running
it. The default behavior is unchanged: we run pylint-1.5.6 still
as we've created a vpython wheel in cipd for it. But for projects
that want to move to a newer version, they can pick any of the new
1.x wrappers. Having the full set of versions here allows projects
to incrementally move to newer versions as the lint delta between
1.5 & 1.6 tends to be much smaller than 1.5 & 1.9.
We don't include support for the newer 2.x series as those only
support Python 3 which the codebase isn't ready for.
Bug: 866772
Test: `./pylint ...` still works & shows pylint-1.5
Test: `./pylint-1.5 ...` runs the v1.5 version
Test: `./pylint-1.8 ...` runs the v1.8 version
Change-Id: I7c47187493564db81e3eb28c6dbd09e6309ead46
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1752507
Reviewed-by: Robbie Iannucci <iannucci@chromium.org>
Commit-Queue: Mike Frysinger <vapier@chromium.org>
Useful in cases like the green presubmit runs on crrev.com/i/1434617/2
Bug: 925774
Change-Id: I37ce2be843d76ace0615cd3313e5c8421504a1ba
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1687122
Reviewed-by: Nodir Turakulov <nodir@chromium.org>
Commit-Queue: John Budorick <jbudorick@chromium.org>
This is followup from the malformed-json bug which took down
Sheriff-o-Matic on 2019-05-16. This CL just adds the canned check;
future CLs can either add it to PanProjectChecks or add it to
other PRESUBMIT files directly.
Change-Id: I4a445193c1744966a448b12c7eb2915873e484d9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1617941
Commit-Queue: Aaron Gable <agable@chromium.org>
Reviewed-by: Sean McCullough <seanmccullough@chromium.org>
Ran "2to3 -w -n -f print ./" and manually added imports.
Ran "^\s*print " and "\s+print " to find batch/shell scripts, comments and the like with embedded code, and updated them manually.
Also manually added imports to files, which used print as a function, but were missing the import.
The scripts still work with Python 2.
There are no intended behaviour changes.
Bug: 942522
Change-Id: Id777e4d4df4adcdfdab1b18bde89f235ef491b9f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1595684
Reviewed-by: Dirk Pranke <dpranke@chromium.org>
Commit-Queue: Dirk Pranke <dpranke@chromium.org>
Auto-Submit: Raul Tambre <raul@tambre.ee>
The previous implementation of CheckLongLines did not
handle global pylint disable/enable directives properly,
i.e. the difference between:
# pylint: disable=line-too-long
.... checks disabled for all lines here.
# pylint: enable=line-too-long
versus:
# Check only disabled for the line below
some python statements # pylint: disable=line-too-long
This CL changes the implementation to support Python files
properly. Note that in order to not disturb the mock-based
unit-tests, a new function is introduced to be able to
filter the list of affected files based on their file
extension.
BUG=890734
R=mattcary@chromium.org,ehmaldonado@chromium.org,dpranke@chromium.org
Change-Id: Id52deff53913b8d47a4157f42b1fffbd3b103201
Reviewed-on: https://chromium-review.googlesource.com/c/1396094
Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
Commit-Queue: David Turner <digit@chromium.org>
Fix CheckOwnersFormat so that it checks the new OWNERS files instead of the
original ones.
Change-Id: I4abb1cfc847bd28f45b9948fe7775c10dcc8a420
Reviewed-on: https://chromium-review.googlesource.com/c/1382946
Reviewed-by: Andrii Shyshkalov <tandrii@chromium.org>
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
Right now, if clang-format is broken, a CL will still pass CQ.
This adds a flag so that it will fail CQ.
Bug: 911708
Change-Id: I2c71b7bc434fc611d51f688266be6a265b80f4da
Reviewed-on: https://chromium-review.googlesource.com/c/1361560
Reviewed-by: agrieve <agrieve@chromium.org>
Commit-Queue: Ryan Tseng <hinoka@chromium.org>
Enables python formatting in git cl format by default
for all files that have a .style.yapf file in a parent
directory up to the repository root. If no .style.yapf
file is found the --python flag still needs to be
set explicitly for python formatting to be enabled.
Also adds a --no-python to explicitly disable python
formatting on any file even if a .style.yapf file is found.
This allows default formatting to be enabled on a per
project/directory basis by adding a .style.yapf file.
Bug:846432
Change-Id: I40d899ec1a3e0dfca445e04b91befab113416175
Reviewed-on: https://chromium-review.googlesource.com/c/1316415
Commit-Queue: Aiden Benner <abenner@google.com>
Reviewed-by: Nodir Turakulov <nodir@chromium.org>
Reviewed-by: agrieve <agrieve@chromium.org>
Not enabling it yet, since PRESUBMIT.py uses presubmit_canned_checks.py from
depot_tools at HEAD, not from a CL (thus enabling this check in this CL will
make it fail the presubmit).
R=nodir@chromium.org
BUG=870166
Change-Id: I97802ec37f1f7513dfca3950f7f38a5c51ab0350
Reviewed-on: https://chromium-review.googlesource.com/1227432
Reviewed-by: Nodir Turakulov <nodir@chromium.org>
Commit-Queue: Vadim Shtayura <vadimsh@chromium.org>
The message was previously not clear that if the entire CL has any change
to an OWNERS file, TBR will not apply.
Change-Id: Ib30a93f80196f45b02a29701faab7cf581e37f50
Reviewed-on: https://chromium-review.googlesource.com/1176321
Reviewed-by: Marc-Antoine Ruel <maruel@chromium.org>
Commit-Queue: Robert Sesek <rsesek@chromium.org>
Add check_python parameter to CheckPatchFormatted to check that python
files are well formatted.
Change-Id: Ibd20d5ec9d1d5142a26f7f4cd5f05c51223da6ca
Reviewed-on: https://chromium-review.googlesource.com/1081342
Commit-Queue: Nodir Turakulov <nodir@chromium.org>
Reviewed-by: Andrii Shyshkalov <tandrii@chromium.org>
Expansion of the tests to check for this are required.
Change-Id: Iae6294501659738df5097ce5a72da79e72818d98
Reviewed-on: https://chromium-review.googlesource.com/1030956
Reviewed-by: Aaron Gable <agable@chromium.org>
Commit-Queue: Jeremy Roman <jbroman@chromium.org>
Since no one can upload or land changes from Rietveld anymore,
PRESUBMIT and its support files no longer need to be able to
support it.
Bug: 770408
Change-Id: I4ca6391291e7b0755c78af453c3d006ad3666a17
Reviewed-on: https://chromium-review.googlesource.com/991053
Reviewed-by: Robbie Iannucci <iannucci@chromium.org>
Commit-Queue: Aaron Gable <agable@chromium.org>
This reverts commit f3eed0016e.
Reason for revert: Some PRESUBMIT checks still expect
CheckRietveldTryJobExecution to exist.
Original change's description:
> Remove Rietveld support from presubmit
>
> Since no one can upload or land changes from Rietveld anymore,
> PRESUBMIT and its support files no longer need to be able to
> support it.
>
> R=tandrii@chromium.org
>
> Bug: 770408
> Change-Id: I749092b66fdca16d5cef77e8cefc905aa5375b50
> Reviewed-on: https://chromium-review.googlesource.com/693380
> Commit-Queue: Aaron Gable <agable@chromium.org>
> Reviewed-by: Andrii Shyshkalov <tandrii@chromium.org>
TBR=agable@chromium.org,tandrii@chromium.org
Change-Id: I72e29bd8a9739406f29190adbeb7eb7718ed21cd
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 770408
Reviewed-on: https://chromium-review.googlesource.com/991012
Commit-Queue: Aaron Gable <agable@chromium.org>
Reviewed-by: Aaron Gable <agable@chromium.org>
TBRs bypass owners checks, but are also semi-suspicious: a
contributor TBRing many changes in a row to submit code to
a directory they don't own would be seen, frowned upon, and
inquired into. However, a contributor could bypass this by
simply TBRing a single change to add themselves to an OWNERS
file, and then contributing as normal from there. This CL
removes that loophole.
This will not affect sheriffs who TBR reverts for two reasons:
first, it is rare that a chance touches both code and an
OWNERS file, and therefore it is rare that OWNERS changes
get reverted; second, quick reverts (the kind sheriffs do)
bypass PRESUBMIT entirely, and therefore also skip OWNERS
checks.
Bug: 688115
Change-Id: If2b5c9d058c62caf95389287e0bb706aef721baf
Reviewed-on: https://chromium-review.googlesource.com/982601
Commit-Queue: Aaron Gable <agable@chromium.org>
Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
Reviewed-by: Dirk Pranke <dpranke@chromium.org>
Since no one can upload or land changes from Rietveld anymore,
PRESUBMIT and its support files no longer need to be able to
support it.
R=tandrii@chromium.org
Bug: 770408
Change-Id: I749092b66fdca16d5cef77e8cefc905aa5375b50
Reviewed-on: https://chromium-review.googlesource.com/693380
Commit-Queue: Aaron Gable <agable@chromium.org>
Reviewed-by: Andrii Shyshkalov <tandrii@chromium.org>
On buildbot (only), we don't trust PYTHONPATH, so we have set
VPYTHON_CLEAR_PYTHONPATH to make the first invocation of vpython in a
given chain of python invocations clear PYTHONPATH.
This has the unfortunate side-effect that python scripts that set
PYTHONPATH and then call into vpython (like presubmit) end up
having their PYTHONPATH modifications removed.
As a workaround (until I clean up PYTHONPATH in buildbot for real), fix
presubmit_canned_checks so that it clears VPYTHON_CLEAR_PYTHONPATH when it
adjusts PYTHONPATH.
R=charlie@chromium.org, nodir@chromium.org, vadimsh@chromium.org
Bug: 825290,825174
Change-Id: Ib5f73add1726fdf3c335d26fc0af76cfe3b747b2
Reviewed-on: https://chromium-review.googlesource.com/978632
Reviewed-by: Charlie Andrews <charliea@chromium.org>
Commit-Queue: Robbie Iannucci <iannucci@chromium.org>
Currently in LUCI `git cl` is invoked on chromium_presubmit using vpython. This
means that it operates under the depot_tools .vpython environment (which is
blank).
Some features in presubmit_support allow invocation of python subprocesses, and
previously they would use `sys.executable` (especially on windows, but
occasionally on non-windows as well).
In non-vpython environments, this just picks up the system python and whatever
modules happen to be installed there. Some python unittests work around this on
non-windows systems by having a shebang line which explicitly invokes vpython.
This CL changes presubmit_support so that invocations of 'python', or executions
of '.py' scripts will always end up invoking vpython. In the best case, this will
pick up the invoked scripts' vpython environment. In the worst case, this will
invoke the script under an empty vpython environment (aka "stock python").
R=dpranke@chromium.org, jbudorick@chromium.org, tandrii@chromium.org, tikuta@chromium.org
Bug: 821669
Change-Id: I5d2d5dfd0364022d56833c2c8af4983553a29c7a
Reviewed-on: https://chromium-review.googlesource.com/961865
Reviewed-by: Dirk Pranke <dpranke@chromium.org>
Reviewed-by: Andrii Shyshkalov <tandrii@chromium.org>
Commit-Queue: Robbie Iannucci <iannucci@chromium.org>