-
Notifications
You must be signed in to change notification settings - Fork 4
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
Implements an intermediate build cache #305
Conversation
I experimented with this by attempting to build Blogifier, a meaty .NET project. I used old versions of the runtime, SDK, and ASP.NET buildpack because this app is impacted by paketo-buildpacks/dotnet-core#670. I built this buildpack locally and used the following build command: pack build blog --env BP_DOTNET_PROJECT_PATH="./Blogifier" \
--env BP_DOTNET_PUBLISH_FLAGS="--verbosity=detailed --self-contained=true" \
--path ./src \
-b paketo-buildpacks/[email protected] \
-b paketo-buildpacks/[email protected] \
-b paketo-buildpacks/[email protected] \
-b paketo-buildpacks/icu \
-b $buildpack_directory/build/buildpackage.cnb \
-b paketo-buildpacks/dotnet-execute \
--verbose The build fails with the following error:
|
There is an underlying issue that causes this to happen https://stackoverflow.com/questions/45575280/msbuild-nuget-restoreoutputpath-how-to-make-it-work. I am not entirely sure what to do about this issue at the exact moment but I will keep looking. It may be as simple as setting the See also this issue thread dotnet/msbuild#1603. |
If/when we get this working, I think it'll be important to make sure we have an integration test fixture that fails without the fix and passes with the right incantation (I suspect this comes down to having NuGet packages). @ForestEckhardt the issues you linked make this seem hacky/subject to change, so I'd like to be sure we catch if they change something under the hood that breaks this. |
@fg-j I did a little bit of looking and it seems that that the approved way to do this is through a |
Update: It took some doing but I am now using a I will update this PR to use this new configuration. |
…fix strange interaction with Nuget and SDK
@ForestEckhardt I was able to repro your success with Blogifier. Then I took this for a spin with a Steeltoe sample app and unfortunately I saw something else go weird. Building this microservice
results in an error:
whereas building with the latest version of the language family succeeds:
I'm going to dig a bit for the cause. Edit: I've done some digging but I can't find anything in the Microsoft docs that link the errors seen above and use of the BaseIntermediateOutputPath directory. Here's some information I have managed to gather:
|
In the latest commit, I've switched our approach to simply copying the whole The tradeoff here is that copying the files around slows things down, but I think this is negligible in the context of a substantial .NET build. |
@ForestEckhardt @fg-j the changes look great, and make sense. Per Frankie's comment:
Can one of y'all add this? |
@sophiewigmore I think that I came to the conclusion to the underlying issue is very opaque and I don't think that this is going to change soon in the future so I am not sure and additional integration test will tell us much. |
@ForestEckhardt I think it's worth adding an integration test that tests rebuilding to make sure the build cache is being loaded correctly I can add one. Edit: @ForestEckhardt , @sophiewigmore I've added an integration test for rebuilds. I've also added more unit test coverage to the cache loading and storing process that helps illuminate why some of the filesystem operations (especially |
for i := 0; i < 2; i++ { | ||
var logs fmt.Stringer | ||
image, logs, err = pack.WithNoColor().Build. | ||
WithBuildpacks( | ||
icuBuildpack, | ||
dotnetCoreRuntimeBuildpack, | ||
dotnetCoreAspNetBuildpack, | ||
dotnetCoreSDKBuildpack, | ||
buildpack, | ||
dotnetExecuteBuildpack, | ||
). | ||
WithEnv(map[string]string{ | ||
"BP_DOTNET_PUBLISH_FLAGS": "--verbosity=normal", | ||
}). | ||
Execute(name, source) | ||
Expect(err).NotTo(HaveOccurred(), logs.String()) | ||
images[image.ID] = "" | ||
|
||
Expect(logs).To(ContainLines( | ||
MatchRegexp(` Running 'dotnet publish .* --verbosity=normal'`), | ||
)) | ||
|
||
container, err = docker.Container.Run. | ||
WithEnv(map[string]string{"PORT": "8080"}). | ||
WithPublish("8080"). | ||
WithPublishAll(). | ||
Execute(image.ID) | ||
Expect(err).NotTo(HaveOccurred()) | ||
containers[container.ID] = "" | ||
|
||
Eventually(container).Should(BeAvailable()) | ||
Eventually(container).Should(Serve(ContainSubstring("source_6_app")).OnPort(8080)) | ||
} |
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.
@fg-j it's not super clear to me from this test how to tell that the cache is being reused on the rebuild. Am I missing something?
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.
So the idea here is to test that loading the cache when it's non-empty and running dotnet publish
works as expected. Since the intermediate build layer is always marked cache
and we always try to load the cache before building, building and then rebuilding tests that a) the cache is saved correctly after the first build and b) the cache is useable during the second build. Analogous to this rebuild test in the go-build buildpack.
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.
Ah ok, the success of the build is enough to know that the cache is used by nature of the code.
I think I was expecting to see an assertion around the cache layer SHA, but I realize we can't do that because it's only a cache
layer, not launch
.
This reverts commit 2e057bb. Due to rebuild bug
Resolves #279
Resolves #94
Checklist