-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Status-API #1332
Status-API #1332
Conversation
7cfc844
to
ee11e3a
Compare
models/migrations/v24.go
Outdated
"github.com/go-xorm/xorm" | ||
) | ||
|
||
type StatusTable struct { |
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.
Maybe CommitStatus
is better than StatusTable
?
models/migrations/v24.go
Outdated
Index int64 `xorm:"INDEX UNIQUE(repo_sha_index)"` | ||
RepoID int64 `xorm:"INDEX UNIQUE(repo_sha_index)"` | ||
State string `xorm:"TEXT NOT NULL"` | ||
SHA string `xorm:"TEXT NOT NULL INDEX UNIQUE(repo_sha_index)"` |
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.
don't use TEXT
since SHA
has a fixed length.
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.
Since there's talk about replacing SHA1 in git with "something else" we probably shouldn't make assumptions about it's length.
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.
But some databases will be failed if the index column is too long like mysql and mariadb. This happend on #1283 .
models/migrations/v24.go
Outdated
|
||
type StatusTable struct { | ||
ID int64 `xorm:"pk autoincr"` | ||
Index int64 `xorm:"INDEX UNIQUE(repo_sha_index)"` |
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.
what's the Index
meaning?
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.
It is the Counter across Repo and SHA. Each SHA has up to 1000 statuses (I don't actually limit, github api docs specifies it though).
models/status.go
Outdated
"github.com/go-xorm/xorm" | ||
) | ||
|
||
type StatusState string |
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.
lint
models/status.go
Outdated
StatusWarning StatusState = "warning" | ||
) | ||
|
||
type Status struct { |
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.
maybe CommitStatus
is better?
@lunny All things should be fixed 🙂 |
Well, fully working 🎉 |
build failed and conflicted |
d16d6cd
to
7ba765a
Compare
// CommitStatusFailure is for when the Status is Failure | ||
CommitStatusFailure CommitStatusState = "failure" | ||
// CommitStatusWarning is for when the Status is Warning | ||
CommitStatusWarning CommitStatusState = "warning" |
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.
Hm, I never saw that in any other hosting software. From my point of view, this state is not necessary. Warnings are part of the build processes, never the less its still successful.
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.
It's an idea that I got then I have flaky tests/internet. Basically if a test fails I wanna restart it once automatically, if it success on second try mark with 'warning' 🙂 (good for when you're getting rate-limited by Alpines Repo CDN 😂 )
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.
In any case, it's a super-set of GitHub API, so it won't hurt to have it 🙂
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.
Fair point, wasn't sure about the use case. ;-) I never got in touch which such problems since all our company builds run locally without any external dependencies. On the other hand, having such problems in your tests is also not ideal.^^
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.
Well, got the initial idea when I had intermittant race-conditions in my tests. Re-running the tests made 'em pass, but you should obviously fix the race-condition, hence "warning" 😉
The reason I want it thought is mainly for when you're rate-limited. I want it to return "warning" since you should fix the issue, but it might not be critical to fix it now 🙂
You need to have a fixed length for string index (like https://github.com/go-gitea/gitea/pull/1332/files#diff-cbd97f0ad3f0f48c8a314bbcfaf60f0cR19) to be compatible with mysql/mariadb (http://stackoverflow.com/questions/1827063/mysql-error-key-specification-without-a-key-length). If git change the format we only have to upgrade it size or create a sub-object. Trust me, I learned it the hard way ^^ |
conflicts |
Yeah I'm looking forward to see better CI integration too. 👍 Go !!!! |
7ba765a
to
ee1f2c0
Compare
@lunny please re-review :) |
models/status_test.go
Outdated
// Use of this source code is governed by a MIT-style | ||
// license that can be found in the LICENSE file. | ||
|
||
// +build disabled |
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 need build tag?
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.
Because the tests were failing 😂 Thanks for pointing that out
@bkcsoft build failed. the new table affected the tests. |
@lunny now it should build ;) |
But it still conflicts @bkcsoft |
9c1a7ce
to
5f81701
Compare
Rebased, resolved conflicts, squashed, builds and tests passing, ready to go! 🎉 |
Done! |
LGTM |
models/status.go
Outdated
sess.Rollback() | ||
return fmt.Errorf("newCommitStatus[%s, %s]: %v", opts.Repo.RepoPath(), opts.SHA, err) | ||
} | ||
sess.Commit() |
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.
return sess.Commit()
models/migrations/v28.go
Outdated
ID int64 `xorm:"pk autoincr"` | ||
Index int64 `xorm:"INDEX UNIQUE(repo_sha_index)"` | ||
RepoID int64 `xorm:"INDEX UNIQUE(repo_sha_index)"` | ||
State string `xorm:"TEXT NOT NULL"` |
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.
State
should also have a fixed size.
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.
models/migrations/v28.go
Outdated
@@ -0,0 +1,30 @@ | |||
package migrations |
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.
comment head
@bkcsoft conflicts. |
0b8ad58
to
503015a
Compare
@bkcsoft still conflicted |
503015a
to
27990d5
Compare
@lunny Done! 🎉 Merge It! 😂 |
LGTM go go go ! Looking forward to Drone reporting build status of PRs ! :) |
@strk Me too, but I'm not gonna be the one doing that unfortunately. I really don't have any time to spare ATM 😢 |
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.
@lunny Here's the breakage that I can find :)
defer sess.Close() | ||
if err = sess.Begin(); err != nil { | ||
return fmt.Errorf("newCommitStatus[%s, %s]: %v", opts.Repo.RepoPath(), opts.SHA, err) | ||
} |
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 sess
& Begin
isn't required
Can I generate an oauth2 token with limited scope to update the commit status ? (like github or bitbucket does). eg, I could give this token to drone to allow seamless security controlled access |
@JohnTheodore You can generate a Deploy Token for use with this. In your Repository goto |
This seems to have been merged but I don't see any reference to it in swagger and I can't find any other documentation about it. Should the Status API stuff show up in swagger? |
Don't worry. I finally tracked down the new swagger location on try.gitea.io and it looks like a lot of things have been fixed since the v1.2.x release. I look forward to 1.3.x. |
Initial support for Status-API
Closes #357
Depends on go-gitea/go-sdk#49
TODO:
I have no clue