Commit Graph

26 Commits (064cba2b372fdcfa8e30df304f8881b08c580546)

Author SHA1 Message Date
Jordan 7e547050e8 Updating Revision presubmit to check for valid commit hash
Bug:b/349274008
Change-Id: I6ce8f1993bcf78514111d709b69b109e481d18b7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5652700
Reviewed-by: Jiewei Qian <qjw@chromium.org>
Reviewed-by: Rachael Newitt <renewitt@google.com>
Commit-Queue: Jordan Brown <rop@google.com>
8 months ago
Jiewei Qian bba165a25c metadata: treats CPEPrefix "unknown" as None
This CL changes CPEPrefix field to return None for the validate field
accessor.

There's little reason to return a special "unknown" string in property
accessor (which is used for tooling automation).

We still allow specifying "unknown" in that field.

Bug: b/321154076
Change-Id: Ib4cbc017d6b6df179ccfb008bd5ec9477913764b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5465016
Reviewed-by: Anne Redulla <aredulla@google.com>
Commit-Queue: Jiewei Qian <qjw@chromium.org>
10 months ago
Jiewei Qian b7ed76a09d metadata: define a clear DependencyMetadata interface
This CL adds a typed interface that exposes parsed metadata for
downstream consumption.

Conventionally:
- A validated field should be retrieved by the property of the same name
- A validated field returns "None" if said field is not provided, or is
  clearly invalid (e.g. "Unknown" values)
- Raw values can still be retrieved with get_entries()

When using the properties accessor, fields are normalized and/or coerced to a suitable type (e.g. list of str, str of a particular format).

Bug: b/321154076
Change-Id: Ia56969a838e682a7b7eb1dc0781d48e1e38a2ff0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5446637
Reviewed-by: Rachael Newitt <renewitt@google.com>
Commit-Queue: Jiewei Qian <qjw@chromium.org>
11 months ago
Jiewei Qian 79cfa048c0 metadata: early terminate certain fields to avoid over extraction
This CL adds a "early terminate the field based on field value" parser
mechanism to end the field as soon as the field value provides an
unambiguous answer to the question we care about.

This is to prevent over-extraction over certain fields (specifically,
local modifications) which can either be a definitive answer (e.g. No
modification) or multi-line free-form texts (which may contain unknown
fields that we don't care about at this stage).

This mitigates over extraction of README.chromium files like:

```
Local Modifications:
None

How to Uprev:
Steps...
```

Where the old parser would extract "None\n\nHow to Uprev:\nSteps..."

This CL also refactors single line fields to use the same early
termination mechanism since single line field simply ends as soon as
the line is parsed.

Union[Something, None] is changed to Optional[Something] based on
styleguide.

Bug: b/324149233
Change-Id: I3fca80eaceb071263f8ae8730afda230fff0bbb0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5394917
Reviewed-by: Anne Redulla <aredulla@google.com>
Commit-Queue: Jiewei Qian <qjw@chromium.org>
11 months ago
Jiewei Qian d76c4d6045 metadata: add "structured" field parsing
This CL adds a "structured" concept to the parser. In a structured
field, the parser will proactively look for field-like patterns to
start a new field (even if they aren't known fields).

This mitigates the issue when an unknown field immediately
follows a multi-line text field, such as:

URL: https://example.com
UnknownField: abc

And URL field value parses to
"https://example.com<newline>UnknownField:abc".

Bug: b/324149233
Change-Id: I54807bd7b242fc14c679483453ade83f8fd20225
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5379679
Reviewed-by: Anne Redulla <aredulla@google.com>
Commit-Queue: Jiewei Qian <qjw@chromium.org>
12 months ago
Anne Redulla a83e690662 [ssci] Add condition on license field separator warning
This CL updates the License field validation so that the warning to use
the standard comma separator is only returned if processing the license
value resulted in multiple license types.

Bug: b:309712938
Change-Id: Ic9189b8dd76e60bc3d546dea41fdb36faae8dbb4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5003558
Auto-Submit: Anne Redulla <aredulla@google.com>
Commit-Queue: Anne Redulla <aredulla@google.com>
Reviewed-by: Dan Le Febvre <dlf@google.com>
Commit-Queue: Dan Le Febvre <dlf@google.com>
1 year ago
Anne Redulla 10cd8e406d [ssci] Recognize other date formats for third party metadata
This CL expands on the date format validation for third party
metadata. Now, values that are recognized to be using a different format
from the preferred format of YYYY-MM-DD will only return a warning,
instead of an error.

Bug: b:285453019
Change-Id: I344dc863601b4e03e801cdfb3cc5912cfe13b762
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4961973
Reviewed-by: Rachael Newitt <renewitt@google.com>
Commit-Queue: Anne Redulla <aredulla@google.com>
1 year ago
Anne Redulla 36bd52621f [ssci] Support alias for Shipped field
Bug: b:297823626
Change-Id: Ib4be88567040d147f6cdba4f6c7d2b37a0f3898b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4871939
Reviewed-by: Rachael Newitt <renewitt@google.com>
Commit-Queue: Anne Redulla <aredulla@google.com>
1 year ago
Anne Redulla 80226254ea [ssci] Modify metadata versioning info validation
This CL changes what is considered valid versioning info. Instead of
both Date and Revision being required if Version was unknown, now only
one of Date or Revision has to be specified.

Bug: b:277147404
Change-Id: Iedb06e2d55f0cd0ef0a2931013a2a52b15befd75
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4852699
Reviewed-by: Gavin Mak <gavinmak@google.com>
Commit-Queue: Anne Redulla <aredulla@google.com>
Reviewed-by: Rachael Newitt <renewitt@google.com>
1 year ago
Mike Frysinger 124bb8e53c switch to 4 space indent
Leave the recipes/ code at 2 space to match the rest of the recipes
project in other repos.

Reformatted using:
files=( $(
	git ls-tree -r --name-only HEAD | \
		grep -Ev -e '^(third_party|recipes)/' | \
		grep '\.py$';
	git grep -l '#!/usr/bin/env.*python' | grep -v '\.py$'
) )
parallel ./yapf -i -- "${files[@]}"
~/chromiumos/chromite/contrib/reflow_overlong_comments "${files[@]}"

The files that still had strings that were too long were manually
reformatted because they were easy and only a few issues.
autoninja.py
clang_format.py
download_from_google_storage.py
fix_encoding.py
gclient_utils.py
git_cache.py
git_common.py
git_map_branches.py
git_reparent_branch.py
gn.py
my_activity.py
owners_finder.py
presubmit_canned_checks.py
reclient_helper.py
reclientreport.py
roll_dep.py
rustfmt.py
siso.py
split_cl.py
subcommand.py
subprocess2.py
swift_format.py
upload_to_google_storage.py

These files still had lines (strings) that were too long, so the pylint
warnings were suppressed with a TODO.
auth.py
gclient.py
gclient_eval.py
gclient_paths.py
gclient_scm.py
gerrit_util.py
git_cl.py
presubmit_canned_checks.py
presubmit_support.py
scm.py

Change-Id: Ia6535c4f2c48d46b589ec1e791dde6c6b2ea858f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4836379
Commit-Queue: Josip Sokcevic <sokcevic@chromium.org>
Auto-Submit: Mike Frysinger <vapier@chromium.org>
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
2 years ago
Anne Redulla 6715758ed9 [ssci] PEP8 formatting for metadata directory
All files in metadata/ are new, so they should follow the PEP-8 style.

Change-Id: I5d8424536c3d7b703e6b8087e0e2d70c06a1549c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4834909
Reviewed-by: Rachael Newitt <renewitt@google.com>
Commit-Queue: Rachael Newitt <renewitt@google.com>
2 years ago
Anne Redulla 693e0b3121 [ssci] Check CPE metadata field for both 2.3 and 2.2 formats
Bug: b:277147404
Change-Id: Ib817f374b8a33ab7463d93ccef7ad852b16dd9d1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4834898
Reviewed-by: Rachael Newitt <renewitt@google.com>
Commit-Queue: Anne Redulla <aredulla@google.com>
2 years ago
Anne Redulla 427f0f43ad [ssci] Script to run validation on all metadata files
Adds script metadata/scan.py which can be used to search for and
validate Chromium dependency metadata files, given a repository
root directory.

Bug: b:277147404
Change-Id: Ibde0eeb7babe0b1e3f9c7f887bece629d390974a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4823596
Commit-Queue: Anne Redulla <aredulla@google.com>
Reviewed-by: Rachael Newitt <renewitt@google.com>
2 years ago
Anne Redulla b9d7c85582 [ssci] Added CheckChromiumDependencyMetadata in presubmit_canned_checks
This CL adds a new function `CheckChromiumDependencyMetadata` in
`presubmit_canned_checks.py`. It can be used to check that files satisfy
the format defined by `README.chromium.template`
(https://chromium.googlesource.com/chromium/src/+/main/third_party/README.chromium.template).

The code for metadata validation can be found in `//metadata`. Note that
all metadata validation issues will be returned as warnings only for
now, while the quality of metadata is being uplifted.


Bug: b:277147404
Change-Id: Iacf1b3a11219ab752549f6dc6e882c93c0fbe780
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4812578
Commit-Queue: Anne Redulla <aredulla@google.com>
Reviewed-by: Rachael Newitt <renewitt@google.com>
Reviewed-by: Gavin Mak <gavinmak@google.com>
Reviewed-by: Bruce Dawson <brucedawson@chromium.org>
2 years ago
Anne Redulla c7aca34c8e Define main metadata validation functions
This is a reland of commit a1cfc693af

The original commit was reverted do to `ModuleNotFoundError`s. I believe this was due to not specifying `metadata` to be part of the `depot_tools` recipe bundle. I have updated `.gitattributes` for this, and also added `__init__.py` files.

I will put the changes to `presubmit_canned_checks.py` in a later CL, once I can confirm `metadata` is being bundled.

Original change's description:
> [ssci] Added CheckChromiumMetadataFiles in presubmit_canned_checks
>
> Bug: b:277147404
> Change-Id: I14a2f11b256bc85fdfe225443ef533c38463ca3e
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4796694
> Reviewed-by: Gavin Mak <gavinmak@google.com>
> Reviewed-by: Rachael Newitt <renewitt@google.com>
> Commit-Queue: Anne Redulla <aredulla@google.com>

Bug: b:277147404
Change-Id: Ibd9efd5970a5393c157ca8763f97064d7c167803
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4803385
Reviewed-by: Rachael Newitt <renewitt@google.com>
Reviewed-by: Gavin Mak <gavinmak@google.com>
Commit-Queue: Anne Redulla <aredulla@google.com>
2 years ago
Anne Redulla 760f8bcfb9 Revert "[ssci] Added CheckChromiumMetadataFiles in presubmit_canned_checks"
This reverts commit a1cfc693af.

Reason for revert: causing presubmit errors downstream

Original change's description:
> [ssci] Added CheckChromiumMetadataFiles in presubmit_canned_checks
>
> Bug: b:277147404
> Change-Id: I14a2f11b256bc85fdfe225443ef533c38463ca3e
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4796694
> Reviewed-by: Gavin Mak <gavinmak@google.com>
> Reviewed-by: Rachael Newitt <renewitt@google.com>
> Commit-Queue: Anne Redulla <aredulla@google.com>

Bug: b:277147404
Change-Id: I83f52494bc1a3a786505b8b74b2053269baa6e8e
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4803286
Commit-Queue: Anne Redulla <aredulla@google.com>
Auto-Submit: Anne Redulla <aredulla@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Owners-Override: Anne Redulla <aredulla@google.com>
2 years ago
Anne Redulla a1cfc693af [ssci] Added CheckChromiumMetadataFiles in presubmit_canned_checks
Bug: b:277147404
Change-Id: I14a2f11b256bc85fdfe225443ef533c38463ca3e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4796694
Reviewed-by: Gavin Mak <gavinmak@google.com>
Reviewed-by: Rachael Newitt <renewitt@google.com>
Commit-Queue: Anne Redulla <aredulla@google.com>
2 years ago
Anne Redulla 3aeb682373 [ssci] Added validate method for single dependencies
Bug: b:277147404
Change-Id: I54c9c82d093cb11813e1c224da125b8d555f1b29
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4797050
Reviewed-by: Rachael Newitt <renewitt@google.com>
Commit-Queue: Anne Redulla <aredulla@google.com>
2 years ago
Anne Redulla 2b583af7e1 [ssci] Added parser for README validator
Bug: b:277147404
Change-Id: I7ee0fe35e1017eb477255f12045d00e855f7dfb4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4787830
Reviewed-by: Rachael Newitt <renewitt@google.com>
Auto-Submit: Anne Redulla <aredulla@google.com>
Commit-Queue: Rachael Newitt <renewitt@google.com>
2 years ago
Anne Redulla c7350c496a [ssci] Defined License metadata field
Bug: b:277147404
Change-Id: I498537328c0908417955eda34ad48ca46f4275aa
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4776734
Reviewed-by: Rachael Newitt <renewitt@google.com>
Auto-Submit: Anne Redulla <aredulla@google.com>
Commit-Queue: Rachael Newitt <renewitt@google.com>
2 years ago
Anne Redulla 7d26320c4d [ssci] Defined License File metadata field
Bug: b:277147404
Change-Id: If0a9394a3cac3aa6819ed1ac2ad875564648a8f5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4776733
Commit-Queue: Anne Redulla <aredulla@google.com>
Reviewed-by: Rachael Newitt <renewitt@google.com>
2 years ago
Anne Redulla e95696ff53 [ssci] Defined URL metadata field
Bug: b:277147404
Change-Id: I4e1fb86afb991fd3b6bf59a2a96d620fc7eea469
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4776732
Reviewed-by: Rachael Newitt <renewitt@google.com>
Commit-Queue: Anne Redulla <aredulla@google.com>
2 years ago
Anne Redulla 0f405ea312 [ssci] Defined Version metadata field
Bug: b:277147404
Change-Id: Idcdff48e5ef2052057fa7fdff7204b50a1c3c4d9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4776731
Commit-Queue: Anne Redulla <aredulla@google.com>
Reviewed-by: Rachael Newitt <renewitt@google.com>
2 years ago
Anne Redulla a29922791a [ssci] Defined CPEPrefix metadata field
Bug: b:277147404
Change-Id: I24a0324f707b13d89beaad0c65c06457375a251f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4776730
Reviewed-by: Rachael Newitt <renewitt@google.com>
Commit-Queue: Anne Redulla <aredulla@google.com>
2 years ago
Anne Redulla 378fe5fb91 [ssci] Defined Date metadata field
Bug: b:277147404
Change-Id: I26fbc670ff402c2ba26ba62b344fc3f3ccd61d24
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4776729
Reviewed-by: Rachael Newitt <renewitt@google.com>
Auto-Submit: Anne Redulla <aredulla@google.com>
Commit-Queue: Anne Redulla <aredulla@google.com>
2 years ago
Anne Redulla 51690612da [ssci] Defined basic metadata fields
Bug: b:277147404
Change-Id: Iabba43add61ce5090be50ac8f0245f624028c44b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4776728
Reviewed-by: Rachael Newitt <renewitt@google.com>
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
Commit-Queue: Anne Redulla <aredulla@google.com>
2 years ago