-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Enable testing of compiled models in CI #34111
Conversation
This is an attempt at making the CI hit the same issue as #22901 (comment) Locally I bisected the regression as follows:
|
@@ -1494,38 +1494,28 @@ protected virtual void AddDesignTimeServices(IServiceCollection services) | |||
if (string.IsNullOrEmpty(testDirectory) | |||
|| !Directory.Exists(testDirectory)) | |||
{ | |||
return; | |||
throw new Exception("Test directory not found"); |
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.
the tests in CI fail on this line, aka without this change they are not checking the baselines
e75a48f
to
c233064
Compare
The regression noticed by @ErikEJ and @cincuranet is apparently caused by a bad interaction between the introduction of the
This holds true since #25966 |
c233064
to
3170315
Compare
This PR makes it possible to run the compiled model tests in CI and updates the baselines. |
We don't validate baselines in CI because it uses a different folder structure |
3170315
to
594b426
Compare
594b426
to
40d7aa7
Compare
@AndriySvyryd I see that in some cases the I pushed 40d7aa7 which does not contain the updated baselines (aka it should fail the CI checks) and later I will push the baseline updates on top to fix them. In the meantime, I am marking this as draft, as I believe that some additional requirements/design discussion might be needed before considering this changeset ready 😇 |
The current state of the PR is that:
🚀 I am not 100% happy with the code that handles the mangling by @AndriySvyryd what do you think about this approach? Does it make sense to move in this direction? (and/or do you have any suggestions on how to improve the PR?) |
|
||
foreach (var (path, ex) in exceptions) | ||
{ | ||
throw new Exception($"Difference found in {path}", ex); |
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 should be an AggregateException
and the top-level message should contain the number of files that are different.
@@ -11,7 +11,6 @@ | |||
|
|||
namespace Microsoft.EntityFrameworkCore.Scaffolding; | |||
|
|||
[SpatialiteRequired] |
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.
Why was this removed? The tests still use spatial types
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.
AFAICT no test in this class uses Spatialite: the generated model would, but the test is only compiling it (in fact, if they required it, they would fail on the linux CI).
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 is just a point in time, the corresponding asserts were commented out due to a bug in the runtime.
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 was unable to find the commented-out asserts :(
Note that the tests successfully compile a model containing NTS Point
s
efcore/test/EFCore.Sqlite.FunctionalTests/Scaffolding/CompiledModelSqliteTest.cs
Lines 21 to 39 in 0302bb7
modelBuilder.Entity<Data>( | |
eb => | |
{ | |
eb.Property<int>("Id"); | |
eb.HasKey("Id"); | |
eb.Property<Point>("Point") | |
.HasSrid(1101); | |
}); | |
modelBuilder.Entity<PrincipalBase>( | |
eb => | |
{ | |
eb.Property<Point>("Point") | |
.HasColumnType("geometry") | |
.HasDefaultValue( | |
NtsGeometryServices.Instance.CreateGeometryFactory(srid: 0).CreatePoint(new CoordinateZM(0, 0, 0, 0))) | |
.HasConversion<CastingConverter<Point, Point>, CustomValueComparer<Point>, CustomValueComparer<Point>>(); | |
}); |
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.
// Blocked by dotnet/runtime/issues/89439 |
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 dropped 64a3fef and I will look into re-enabling these (in a separate PR).
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 handle them. The fix is somewhat involved.
It's brittle, but I am not strongly opposed to it. An alternative would be to copy the baselines to the output folder and use different paths for reading and writing. |
I updated the code to throw an Regarding changing the reading/writing of the baselines, I am afraid it would be a more invasive change. |
I agree, that's why I think that the current approach is good enough |
Instead of considering the test passed if no check was done, mark it as failed. Additionally, handle paths mangled by DeterministicSourcePaths.
Instead of throwing the first exception, throw an aggregation of all of them.
bdce444
to
57ecfca
Compare
Thanks for your contribution! |
This changeset enables the testing of compiled models in CI.
Fixes #34139