Closed cojoj closed 9 years ago
Some great amount of playing with request/response and I've prepared pretty ugly and glued from many sources but valid and showing all possibilities - JSON We'll not be able to use it to record a cassette as it's from many sources but it's a great resource to get familiar with the output.
You can find it in this gist as I don't want to paste here almost 500 lines of code... π
Thanks @pmkowal for helping me with this bad-boy! π
@cojoj always at your service :wink:
Very useful stuff guys! :+1:
I've comparing those JSONs and my current conclusions are as follow:
They'll all inherit from XcodeServerEntity
but eventually they have many similiar properties like:
age
status
message
type
issueType
integrationID
commits
In that case I think of creating a new parent class from which specific issues will inherit... But first thing - name? XcodeServerError
, GenericError
?
Next thing is naming for individual error types (children). We've got a couple of them...
buildServiceErrors
and buildServiceWarnings
are the same objects (have the same properties). Different class
, enum
?
triggerErrors
are special kind of errors and they have nothing in common with other objects so it's obvoius they'll be in class TriggerError
errors
, warnings
, testFailures
and analyzerWarnings
are basically the same object so we're back to the story of different class
for each or enum
?
I'd appreciate some examples from your side... π
Yeah I'd go with Issue
instead of Error
. The way I see it, an Error
is a type of an Issue
, which could also be a Warning
, for instance. I'd name the classes after this.
I agree we should just have Issue
inherit from XcodeServerEntity
and where needed, have specific issues inherit from Issue
.
Sounds good guys.
Btw cancelling an integration when it's running results in a "Build Service Error" :laughing:
Yeah, I've noticed that by:
Hmmm, let me try this scenario... Oh, f**k it,
cancel
,cancel
,cancel
! w00t, here's mybuildServiceError
π
@czechboy0 I've got some mixed feelings about this whole inheritance...
Yeah I'd go with Issue instead of Error. The way I see it, an Error is a type of an Issue, which could also be a Warning, for instance. I'd name the classes after this.
Our basic class isn't an Issue (it has more paramteres than error). This is how I see this inheritance for this specific case:
ββββββββββββββββββββββββ
β Generic Error β
ββββββββββββββββββββββββ
β
same β
ββββββobjectββββββββ«
β β
βΌ β
βββββββββββββββββββββββββ β
β BuildServiceError β inherits
βββββββββββββββββββββββββ β
βββββββββββββββββββββββββ β
β BuildServiceWarining β β
βββββββββββββββββββββββββ β
β
β
βββββββββββββββββββββββββ β
β TriggerError ββββββββ€
βββββββββββββββββββββββββ β
β
β
βββββββββββββββββββββββββ β
ββββ Issue ββββββββ
β βββββββββββββββββββββββββ
inherits
β ββββββββββββββββββββ
ββββββββΆβ Error β
β ββββββββββββββββββββ
β ββββββββββββββββββββ
ββββββββΆβ Warning β
β ββββββββββββββββββββ
β ββββββββββββββββββββ
ββββββββΆβ TestFailure β
β ββββββββββββββββββββ
β ββββββββββββββββββββ
ββββββββΆβ AnalyzerWarning β
ββββββββββββββββββββ
And as I've mentioned before:
buildServiceErrors and buildServiceWarnings are the same objects (have the same properties). Different class, enum? triggerErrors are special kind of errors and they have nothing in common with other objects so it's obvoius they'll be in class TriggerError errors, warnings, testFailures and analyzerWarnings are basically the same object so we're back to the story of different class for each or enum?
Number of properties each class
will have is presented on the graph above (top-down), so BuildServiceError
will only implement basic properties and AnalyzerWarning
s (and equals) will have more properties...
Do you really think that subclassing from class
with more properties is the proper approach? In that scenario we'll ignore some of properties what is weird...
Also, I think we don't need classes like Error
, Warning
, TestFailure
or AnalyzerWarning
(basically those inheriting from Issue
) as in the main object they'll be presented as [Issue]
. TriggerError
will have to stay TriggerError
. And buildServiceErrors
and buildServiceWarnings
will become [GenericError]
.
Hmm this is unnecessarily painful. You know what? Let's simplify this.
Create an enum with all these "error" types, create one Issue
class, which will have
payload
dictionary with its raw contents.If someone cares about the nitty gritty details, they can pull it out themselves. I feel like what we're doing might be beyond the scope of an API wrapper.
Just to check we're on the same track... Do you want to create something like:
class Issue: XcodeServerEntity {
enum IssueType {
case Warning
case Error
...
}
let type: IssueType
let payload: [String: AnyObject]
}
I think we can extract similar values to properties (we already have Commits
and providing easy access to message
would be nice...). Similar properties are as follow:
My proposal is to create something like:
class Issue: XcodeServerEntity {
enum IssueType {
case Warning
case Error
...
}
let payload: [String: AnyObject]
let messge: String?
let type: IssueType
let issueType: String
let commits: [Commit]
let integrationID: String
let age: Int
let status: IssueStatus
}
What do you think?
A bit of a hybrid. Ok, only put the ones that are present in all
variants of the Issue
type, nothing specific to any of them. :+1:
On Tue, Aug 4, 2015 at 8:49 AM Mateusz ZajΔ c notifications@github.com wrote:
Just to check we're on the same track... Do you want to create something like:
class Issue: XcodeServerEntity {
enum IssueType { case Warning case Error ... } let type: IssueType let payload: [String: AnyObject]
}
I think we can extract similar values to properties (we already have Commits and providing easy access to message would be nice...). Similar properties are as follow:
- age
- status
- message
- type
- issueType
- integrationID
- commits
My proposal is to create something like:
class Issue: XcodeServerEntity {
enum IssueType { case Warning case Error ... } let payload: [String: AnyObject] let messge: String? let type: IssueType let issueType: String let commits: [Commit] let integrationID: String let age: Int let status: IssueStatus
}
What do you think?
β Reply to this email directly or view it on GitHub https://github.com/czechboy0/XcodeServerSDK/pull/93#issuecomment-127509866 .
Yeah, I know... Those 7 properties I've mentioned are similar to all Issue
s (No matter if its buildServiceError
or Warning
).
Then I'd say go ahead with it. On Tue, Aug 4, 2015 at 9:32 AM Mateusz ZajΔ c notifications@github.com wrote:
Yeah, I know... Those 7 properties I've mentioned are similar to all Issues (No matter if its buildServiceError or Warning).
β Reply to this email directly or view it on GitHub https://github.com/czechboy0/XcodeServerSDK/pull/93#issuecomment-127526565 .
@czechboy0 if you get any sec, please do me a favour and review this prototype of Issue
class.
In at a time shortage during last couple of days and that's the result - commiting something not even finished... π Please be understanding π
I promise I'll be a better contributor after I get back from vacation π―
I've finished writing init
for Issue
... Cross fingers it'll work!
I'll add some tests tomorrow to check if this is actually working.
To make sure - do we propagate handle every exception like a good person or cut this bastard off and crash it? π Just thinking what approach should I take for Optional
Type(rawValue: json.stringForKey("type"))
. Right now I'm βing it as I assume we won't get other things from JSON...
Yeah I'd prefer to change the parsing initializer to a failable one and just return nil
if we can't find the required keys. For now just !
it, yeah :-/
@cojoj Great stuff, thanks! And please enjoy your holiday, your PR still will be here when you come back :wink:
Duration: 1 minute and 37 seconds Result: Perfect build! All 65 tests passed. :+1: Test Coverage: 55%.
Duration: 1 minute and 27 seconds Result: Perfect build! All 68 tests passed. :+1: Test Coverage: 56%.
I've fixed issues reported by @czechboy0
Also, test cases were added to Issue
and guess what... They're all passing π
Duration: 57 seconds Result: Perfect build! All 68 tests passed. :+1: Test Coverage: 56%.
Updated Type
enum with case BuildServiceWarning = "buildServiceWarning"
.
Maybe this was caused by differences in XCS versions API?
I'm on the latest OS X Server 5 and Xcode 7.
I guess there's no harm in this case
for either API version π
One last comment (I'd suggest you remove your email address from there). Looks great, just please edit the readme to accommodate this new API support? :+1:
... This is not complete, yet π I guess it's a half way.
Now need to implement IntegrationIssues
class and write tests for it.
Duration: 1 minute and 1 second Result: Perfect build! All 68 tests passed. :+1: Test Coverage: 56%.
@czechboy0 looks like we have some issues with new Xcode 7b5... Already created PR in BuildUtils
and DVR
. If you can take a look, merger, change or whatever and update Podspec so I don't have to manually change everything in Pods/
π¬
Duration: 56 seconds Result: Perfect build! All 68 tests passed. :+1: Test Coverage: 56%.
@czechboy0 https://github.com/venmo/DVR/pull/18 has been merged. I suggest you pull changes to your fork so we can keep DVR
up-to-date π
I think we're ready here, pull from swift-2
into this branch.
New Xcode was complaining... That's why I've moved it up. I couldn't call it from test cases...
What was it complaining about?
Don't remeber exactly (don't have access to Xcode right now) but as far as I remeber it was something like: Can't find Issue.Type.Type.BuildServiceError
...
Listen, I probably won't have time today (leaving for ππ·) but I'll look into this ASAP (tomorrow afternoon)... If you want to support Ξ²5 you can merge this PR (works and won't break anything) and I'll still work on this branch.
No rush, I actually fixed Beta 5 in swift-2
branch already (and released a quick update to the spec), so we are Beta 5 compatible. Let's take our time on this PR to do it properly, no need to merge this under pressure :)
Duration: 1 minute and 12 seconds Result: Perfect build! All 68 tests passed. :+1: Test Coverage: 56%.
@czechboy0 regarding keeping Type
internal to Issue
I get this in test cases:
Maybe you've got any idea why this happens...?
Yeah Issue
is a class in both BuildaGitServer
(GitHub) and in XcodeServerSDK
. Just remove import BuildaGitServer
from the purely XcodeServerSDK
classes, so that it's not ambiguous.
But I can't find any BuildGitServer
... Even Xcode can't find anything like this in whole XcodeServerSDK
! π
Oh right, that was in Buildasaur. Hmm, still try to prepend Issue
with XcodeServerSDK
to fully qualify the name. And try to clean and the whole dance. Does that help?
The whole dance thing didn't help... Got to rename this to IssueType
π
Close enough :laughing:
One thing left - test cases. Please check if this structure suits you @czechboy0 π
Issue
class is well tested so I guess there's no need to configure XCS to handle turbo-mode IntegrationIssues
, right? Just to check if it can handle a lot Issues
in one JSON π¦
Duration: 1 minute and 10 seconds Result: Perfect build! All 68 tests passed. :+1: Test Coverage: 56%.
Yup. Looks good.
Sent from my iPhone
On Aug 14, 2015, at 9:24 AM, Mateusz ZajΔ c notifications@github.com wrote:
One thing left - test cases. Please check if this structure suits you @czechboy0 π
β Reply to this email directly or view it on GitHub.
I've added a πΌ for IntegrationIssues
. I've tried to genrate some nice errors.
I still need to remove some private data from this JSON...
Anyway, test case is available, passing but still missing some cool assertion
s. I'll try to write them tomorrow and probably finish this PR.
@czechboy0 please take a π, especially at this:
self.errors = json.dictionaryForKey("errors").allValues.filter { $0 is NSDictionary }.map { Issue(json: $0 as! NSDictionary) }
Maybe we can introduce easier way as this code looks like π
It looks like I've finally managed to finish this Pull Request... π
Thanks @cojoj, I'll take a look tomorrow!
Btw are these cassettes recorded with the latest OS X Server & Xcode betas?
I've started working on the next missing official API support endpoint from our list.
This time, List the build issues produced by an integration, is on a plate π.