-
-
Notifications
You must be signed in to change notification settings - Fork 19
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
Silences warning logs and adds additional earlier skip check if no detected BCD updates #909
Silences warning logs and adds additional earlier skip check if no detected BCD updates #909
Conversation
Here's a before-and-after illustration of the changes to the data flow in this PR (just excerpted to the start of the browserMap loop). |
Thanks for putting this together @ChrisC! The overall structure looks good to me, and I'll do a detailed review next week. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few comments. Most importantly, I think we should use defaultStatements
.
scripts/update-bcd.ts
Outdated
shared: {versionMap}, | ||
defaultStatements: [simpleStatement], | ||
}) => { | ||
if (!hasSupportMatrixContradictions(versionMap, simpleStatement)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should pass in defaultStatements
here, so that we can detect contradictions when there are multiple version ranges involved. We aren't able to update all such cases yet, but that should then result in a warning.
@@ -679,6 +684,48 @@ const skipCurrentBeforeSupport = skip("currentBeforeSupport", ({ | |||
} | |||
}); | |||
|
|||
export const hasSupportMatrixContradictions = ( | |||
versionMap: BrowserSupportMap, | |||
simpleStatement?: SimpleSupportStatement, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this would be the signature if we pass in defaultStatements
:
simpleStatement?: SimpleSupportStatement, | |
statements: SimpleSupportStatement[], |
It could be an empty array, but not null. An example of what an array might be:
"support": {
"chrome": [
{
"version_added": "30"
},
{
"version_added": "10",
"version_removed": "20"
}
]
}
If we may have tests result showing support in Chrome 110, and the lack of support in Chrome 29, that is consistent with BCD. But if we have test results showing support in Chrome 9, that is a contradiction.
In my following comments, I'll assume that we iterate over versionMap
, skip any nulls, and inside that loop iterate over statements
, which is usually zero or one item, but possibly more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ChrisC do you plan to address this? If so I'll hold off with review of the recent changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ChrisC do you plan to address this? If so I'll hold off with review of the recent changes.
@foolip I did try to address this and was hoping that with some smart sorting of the statements and versions, this would be simple to implement. Unfortunately, that approach did not work reliably.
Instead, I'm going to add another provide...
method after we get the defaultStatements
to infer supported and unsupported ranges to check each version against. That will be the most robust solution for checking version support against multiple default statements.
I would prefer to do that in a separate PR if possible (since I think it will be quite a bit more code to add), but if you have a strong preference for keeping it in this PR, I can continue with that work here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That sounds great @ChrisC, and fine to do it in a separate PR since it's not as simple as I thought initially.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's untested code of how I thought testing against an array of statements (defaultStatements
) would probably work:
// Test a single version (string) against a BCD statements array.
// Note that order of statements does not matter.
function isSupported(version, statements) {
for (const { version_added, version_removed } of statements) {
if (version_added && compare(version, version_added, '>=') {
if (version_removed && compare(version, version_removed, '>=') {
continue;
}
return true;
}
}
return false;
}
function hasSupportUpdates(versionMap, statements) {
for (const [version, hasSupport] of versionMap.entries()) {
if (hasSupport === null) {
continue;
}
if (hasSupport !=== isSupported(version, statements) {
return true;
}
}
}
In other words, for each true or false test result for a specific version (from collector results), test it against the support statements, once range at a time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is more or less what I tried. However, take the array of statements you provided as an example ☝🏽.
"support": {
"chrome": [
{
"version_added": "30"
},
{
"version_added": "10",
"version_removed": "20"
}
]
}
Let's say you're testing version 10
with a a test result of hasSupport === true
against this set of support statements. This should not show any contradictions. However, when tested for support against each statement individually, it would return false
when tested against the the statement of version_added: 30
and then send out a false positive signal for the need to update the statements. (Note that it would return true
against the other statement.)
I suppose you could collect all the comparisons when iterating through the statements, and assume that as long as there's no inconsistency between the individual statement comparisons, there there's no need to update them. But that seemed a bit brittle and non-specific to me. See another approach where we test against ranges more specifically in #967.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll take a look at your new PR, but for now just want to say that I don't think we should test a version ("10" in your example) against a part of a support statement, only the full array as one test.
If there is a contradiction we do need to figure out how which part of a support statement to update, or if we should add/remove a part, but I consider that a problem of handling more cases correctly, not identifying when an update is needed and logging.
f27f002
to
388dc62
Compare
This is an initial pass at implementing @foolip's suggestion in #899. This:
reason
logger to "quiet" by default.Some General Notes
Before this change, many calls to
update
from running the unit tests reached the final skip check and emitted a "skipped for no known reason" message, which was a bit of a false alarm. For now, I opted to run some simple diffs limited to theversion_added
field. But even with these simple diff checks, we now no longer reach that final "unknown reason" skip check on a unit test run.These initial logs should now be more useful for spotlighting any
update
issues for specific BCD entries. Here's a snippet of log output from a recent manual run:Further work on generating more useful logs will definitely help here. The unit tests should give an accurate summary of all the types of "contradictions" that we're currently checking for.
Suggested Future Improvements
persist...
methods. We may be able to "provide" the results of these checks to theUpdateState
for later use by other methods. For now, we're just checking for the existence of any contradictions and then checking again later when it's time to update.inferredStatements
, but we maybe able to defer or skip other unnecessary steps if we make better use of this diff data from the get-go.cc @mzgoddard