Skip to content
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

APIApprovals for Core #1608

Closed

Conversation

danielmarbach
Copy link
Contributor

Contributes to #1607

Here is a proposal which we at Particular Software use to make conscious decisions about API breaking changes. It doesn't address all the things raised by @Aaronontheweb but it is one step in the right direction. So basically the idea is the following:

  • Uses ApiApprovals and ApprovalTests to generate a public API of a given assembly.
  • The public API gets approved by a human into a *.approved.txt file.
  • Everytime the API approval test runs the API is generated again into a *.received.txt file. If the two files don't match the test fails on the CI server or locally. Locally on the devs machine the predefined Diff viewer pops up (never happens on CI) and the dev has to approve the API changes (therefore making a conscious decision)
  • Each PR making public API changes will contain the *.approved.txt file in the DIFF and all reviewers can easily see the breaking changes on the public API.

Below a few screenshots for better visualisation:

On local machine

image

Diff viewer pops up

image

Approve changes if consciously made

image

Diff

image

Thoughts? If you like it it can send in more for possibly:

  • Persistence
  • ?? please append

And then later address the additional ideas raised by @Aaronontheweb

But I think this PR would already be a huge win.

@danielmarbach
Copy link
Contributor Author

@Aaronontheweb
Copy link
Member

@danielmarbach build should have been triggered - we follow that process. I'll take a look

@danielmarbach
Copy link
Contributor Author

What do you think about the PR itself?

Am 04.01.2016 um 18:21 schrieb Aaron Stannard notifications@github.com:

@danielmarbach build should have been triggered - we follow that process. I'll take a look


Reply to this email directly or view it on GitHub.

@Aaronontheweb
Copy link
Member

@danielmarbach I'll take a look at it today - and I'm really impressed with how quickly you did this and how thorough you were in documenting your PR :)

@@ -76,6 +88,22 @@
<HintPath>..\..\packages\FSharp.Core.3.1.2.5\lib\net40\FSharp.Core.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Mono.Cecil, Version=0.9.5.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756, processorArchitecture=MSIL">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this referenced 4 times in this .csproj file?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Derp, nevermind - 4 different DLLs inside the same package. silly me.

@Aaronontheweb
Copy link
Member

@rogeralsing I'm torn about including this inside Akka.Tests - think we should move it to its own project?

@rogeralsing
Copy link
Contributor

As a separate project imo, that way, it could run as a separate build step on the CI engine. would make it much easier to spot the reason for the failure, if it is failures in the Akka code or API changes.

@Aaronontheweb
Copy link
Member

@rogeralsing I agree with that

@danielmarbach could you move the API approval tests into their own project? Akka.APIApproval?

@Aaronontheweb
Copy link
Member

Fixed the issue with the build server - apparently our Azure cloud service we use for auto-scaling build agents was permanently faulted by something that occurred at midnight 12/31. Switched to a new cloud service and everything is running correctly again.

@danielmarbach
Copy link
Contributor Author

@rogeralsing @Aaronontheweb Thanks for the feedback. Please bear with me while I try to be the devils advocate here.

The "only" reasoning I heard so far is that you guys want it to be a sep. proj because you want to run it as a sep. build step. If I understand the initial issue and the blog post from @Aaronontheweb correctly you guys want to solve the issue of accidentally breaking the API. I consider the public API of a library an integral part of the library. Therefore when you change the lib (possibly introducing a breaking change) and you only run the tests you immediately get the feedback that you did break the API. Making it a sep. proj makes it again, an afterthought. The costs of running those ApprovalTests is low and the friction introduced by leaving them where they belong, in the corresponding specs/test lib of the corresponding project, is close to non-existant. Thoughts?

But hey, in the end, your project, your rules ;)

@Aaronontheweb
Copy link
Member

I consider the public API of a library an integral part of the library. Therefore when you change the lib (possibly introducing a breaking change) and you only run the tests you immediately get the feedback that you did break the API. Making it a sep. proj makes it again, an afterthought. The costs of running those ApprovalTests is low and the friction introduced by leaving them where they belong, in the corresponding specs/test lib of the corresponding project, is close to non-existant. Thoughts?

This is just a technical thing @danielmarbach - we want to keep those API coverage tests in a separate project so those tests can be run independently on the build server separate from our massive test suite in that project. That's all - our CI process strives to keep things very granular and specific.

Edit: think of it this way - I want to see a red check mark specifically if backwards compat in the API breaks and have that called out by name in our build step list. Right now it's lumped into our "unit tests" bucket, which is used to indicate that a piece of functionality broke.

@danielmarbach
Copy link
Contributor Author

Ok, I'll move it out. How about (of course in sep. PR)

  • Persistence
  • Others?

@Aaronontheweb
Copy link
Member

@danielmarbach Akka.Persistence, Akka.Remote, Akka.Cluster, and Akka.DI.Core are the big ones

@danielmarbach
Copy link
Contributor Author

@Aaronontheweb but in the same proj?

@Aaronontheweb
Copy link
Member

btw, I just realized - you'll need to name the project

Akka.APIApproval.Tests
The F# script scans for the .Tests and uses that it build its list of assemblies that need to be tested

@Aaronontheweb
Copy link
Member

@danielmarbach all in one project is fine

@danielmarbach
Copy link
Contributor Author

How about Akka.API.Tests?

@Aaronontheweb
Copy link
Member

sounds good 👍

@danielmarbach danielmarbach force-pushed the ApproveCoreChanges branch 2 times, most recently from dcb9641 to 239ed93 Compare January 4, 2016 20:21
@danielmarbach
Copy link
Contributor Author

Here we go

@Aaronontheweb
Copy link
Member

Build server is FUBAR at the moment - I'll need to circle back on this once I fix it.

@Aaronontheweb
Copy link
Member

Looks good - just need to "approve" the current API, right @danielmarbach ?

@danielmarbach
Copy link
Contributor Author

Hmmm... I did. is the build failing? Test was green on my machine

Am 05.01.2016 um 21:50 schrieb Aaron Stannard notifications@github.com:

Looks good - just need to "approve" the current API, right @danielmarbach ?


Reply to this email directly or view it on GitHub.

@Aaronontheweb
Copy link
Member

Yes, the API approval is failing.

@Aaronontheweb
Copy link
Member

@danielmarbach do you need to commit the approvals file?

@danielmarbach
Copy link
Contributor Author

Yes, hmm... Did it on the first commit but not on the revamp apparently. i'll fix

Am 05.01.2016 um 22:47 schrieb Aaron Stannard notifications@github.com:

@danielmarbach do you need to commit the approvals file?


Reply to this email directly or view it on GitHub.

@danielmarbach
Copy link
Contributor Author

Hold, on it's here

@danielmarbach
Copy link
Contributor Author

@Aaronontheweb I think this is a classical line ending problem. Force pushed with the following .gitattribute changes:

*.txt text eol=crlf

Need to crash now. Hope that fixes the problem. If it doesn't you might need to diff on the agent.

@danielmarbach
Copy link
Contributor Author

I did a

git rm --cached -r .
git reset --hard

on my machine, seems to be ok

@danielmarbach
Copy link
Contributor Author

@Aaronontheweb can't really fix it since I don't have access to TC agents to verify. Can you check it? Does it run on your machine?

@Aaronontheweb
Copy link
Member

@danielmarbach I'll take a look at this over the weekend - but yeah, looks like build server silliness is responsible

@Aaronontheweb
Copy link
Member

@danielmarbach lol I think I figured out the issue - we may not have a mergetool that ApprovalTests can find installed on the build agents ;)

@Aaronontheweb
Copy link
Member

Yep, fixed it - fired up a custom VM and tried to run the approval tests. Bailed out with a vague NullReferenceException. Appears to be that the issue was not having an appropriate diffing tool installed. Adding WinMerge helped. Re-imaging the VMs now.

@danielmarbach
Copy link
Contributor Author

Thx! There is now way I could have figured that out without spelunking on the agents

Am 13.01.2016 um 01:51 schrieb Aaron Stannard notifications@github.com:

Yep, fixed it - fired up a custom VM and tried to run the approval tests. Bailed out with a vague NullReferenceException. Appears to be that the issue was not having an appropriate diffing tool installed. Adding WinMerge helped. Re-imaging the VMs now.


Reply to this email directly or view it on GitHub.

@Aaronontheweb
Copy link
Member

@danielmarbach yep, absolutely right - the error message captured in the TeamCity log was different somehow. I also believe I've fixed #1622 with some TeamCity configuration changes. Running a bunch of different builds in parallel now to find out.

@danielmarbach
Copy link
Contributor Author

Are you going to pull it in soon then?

Am 13.01.2016 um 06:25 schrieb Aaron Stannard notifications@github.com:

@danielmarbach yep, absolutely right - the error message captured in the TeamCity log was different somehow. I also believe I've fixed #1622 with some TeamCity configuration changes. Running a bunch of different builds in parallel now to find out.


Reply to this email directly or view it on GitHub.

@Aaronontheweb
Copy link
Member

Closed via #1639

@Aaronontheweb
Copy link
Member

@danielmarbach yep, all done! I picked up your commit and included it in #1639

@danielmarbach
Copy link
Contributor Author

Any other API approvals that I should contribute?

Am 14.01.2016 um 04:06 schrieb Aaron Stannard notifications@github.com:

@danielmarbach yep, all done! I picked up your commit and included it in #1639


Reply to this email directly or view it on GitHub.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants