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

Status-API #1332

Merged
merged 1 commit into from
Apr 21, 2017
Merged

Status-API #1332

merged 1 commit into from
Apr 21, 2017

Conversation

bkcsoft
Copy link
Member

@bkcsoft bkcsoft commented Mar 19, 2017

Initial support for Status-API

Closes #357

Depends on go-gitea/go-sdk#49

TODO:

  • Models
  • Model Functions
    • Create
    • Get All
    • Get Combined By Context
  • Routers
    • Create
    • Get All
    • Get Combined By Context
  • Tests
    • I have no clue :trollface:
  • Correct Vendoring

@bkcsoft bkcsoft added modifies/api This PR adds API routes or modifies them type/feature Completely new functionality. Can only be merged if feature freeze is not active. labels Mar 19, 2017
@bkcsoft bkcsoft added this to the 1.2.0 milestone Mar 19, 2017
"github.com/go-xorm/xorm"
)

type StatusTable struct {
Copy link
Member

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?

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)"`
Copy link
Member

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.

Copy link
Member Author

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.

Copy link
Member

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 .


type StatusTable struct {
ID int64 `xorm:"pk autoincr"`
Index int64 `xorm:"INDEX UNIQUE(repo_sha_index)"`
Copy link
Member

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?

Copy link
Member Author

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
Copy link
Member

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 {
Copy link
Member

Choose a reason for hiding this comment

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

maybe CommitStatus is better?

@bkcsoft
Copy link
Member Author

bkcsoft commented Mar 20, 2017

@lunny All things should be fixed 🙂

@tboerger tboerger added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Mar 20, 2017
@bkcsoft
Copy link
Member Author

bkcsoft commented Mar 20, 2017

Well, fully working 🎉

@bkcsoft bkcsoft changed the title WIP: Status-API Status-API Mar 20, 2017
@bkcsoft bkcsoft added the pr/wip This PR is not ready for review label Mar 20, 2017
@lunny
Copy link
Member

lunny commented Mar 20, 2017

build failed and conflicted

// CommitStatusFailure is for when the Status is Failure
CommitStatusFailure CommitStatusState = "failure"
// CommitStatusWarning is for when the Status is Warning
CommitStatusWarning CommitStatusState = "warning"
Copy link

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.

Copy link
Member Author

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 😂 )

Copy link
Member Author

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 🙂

Copy link

@go2sh go2sh Mar 20, 2017

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.^^

Copy link
Member Author

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 🙂

@sapk
Copy link
Member

sapk commented Mar 20, 2017

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 ^^

@lunny lunny mentioned this pull request Mar 29, 2017
20 tasks
@appleboy
Copy link
Member

conflicts

@strk
Copy link
Member

strk commented Apr 6, 2017

Go @bkcsoft go ! :)
I'm looking forward to see better CI integration ... #996

@appleboy
Copy link
Member

appleboy commented Apr 7, 2017

Yeah I'm looking forward to see better CI integration too. 👍 Go !!!!

@bkcsoft
Copy link
Member Author

bkcsoft commented Apr 7, 2017

@lunny please re-review :)

// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.

// +build disabled
Copy link
Member

Choose a reason for hiding this comment

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

Why need build tag?

Copy link
Member Author

@bkcsoft bkcsoft Apr 10, 2017

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

@lunny
Copy link
Member

lunny commented Apr 7, 2017

@bkcsoft build failed. the new table affected the tests.

@bkcsoft
Copy link
Member Author

bkcsoft commented Apr 10, 2017

@lunny now it should build ;)

@strk
Copy link
Member

strk commented Apr 10, 2017

But it still conflicts @bkcsoft

@bkcsoft
Copy link
Member Author

bkcsoft commented Apr 10, 2017

Rebased, resolved conflicts, squashed, builds and tests passing, ready to go! 🎉

@bkcsoft
Copy link
Member Author

bkcsoft commented Apr 10, 2017

Done!

@appleboy
Copy link
Member

LGTM

@tboerger tboerger removed the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Apr 11, 2017
@tboerger tboerger added the lgtm/need 1 This PR needs approval from one additional maintainer to be merged. label Apr 11, 2017
models/status.go Outdated
sess.Rollback()
return fmt.Errorf("newCommitStatus[%s, %s]: %v", opts.Repo.RepoPath(), opts.SHA, err)
}
sess.Commit()
Copy link
Member

Choose a reason for hiding this comment

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

return sess.Commit()

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"`
Copy link
Member

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.

Copy link
Member

Choose a reason for hiding this comment

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

@lunny lunny removed the pr/wip This PR is not ready for review label Apr 11, 2017
@@ -0,0 +1,30 @@
package migrations
Copy link
Member

Choose a reason for hiding this comment

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

comment head

@lunny
Copy link
Member

lunny commented Apr 19, 2017

@bkcsoft conflicts.

@lunny
Copy link
Member

lunny commented Apr 19, 2017

@bkcsoft still conflicted

@bkcsoft
Copy link
Member Author

bkcsoft commented Apr 21, 2017

@lunny Done! 🎉 Merge It! 😂

@strk
Copy link
Member

strk commented Apr 21, 2017

LGTM go go go ! Looking forward to Drone reporting build status of PRs ! :)

@tboerger tboerger added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Apr 21, 2017
@bkcsoft
Copy link
Member Author

bkcsoft commented Apr 21, 2017

@strk Me too, but I'm not gonna be the one doing that unfortunately. I really don't have any time to spare ATM 😢

Copy link
Member Author

@bkcsoft bkcsoft left a 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)
}
Copy link
Member Author

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

@JohnTheodore
Copy link

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

@bkcsoft
Copy link
Member Author

bkcsoft commented May 10, 2017

@JohnTheodore You can generate a Deploy Token for use with this. In your Repository goto Settings then Deploy Keys and press Add Deploy Key 🙂 (We really need to work on documentation 😂 )

@bkcsoft bkcsoft deleted the bkcsoft/status-api branch May 10, 2017 09:26
@jerrykan
Copy link

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?

@jerrykan
Copy link

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.

@go-gitea go-gitea locked and limited conversation to collaborators Nov 23, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. modifies/api This PR adds API routes or modifies them type/feature Completely new functionality. Can only be merged if feature freeze is not active.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Status API
9 participants