-
-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Fix actions skipped commit status indicator #34507
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
Fix actions skipped commit status indicator #34507
Conversation
Seems good, but I wonder whether the other two missing statuses from action model should also be represented in commit status. Currently "blocked" and "unknown" are missing: gitea/models/actions/status.go Lines 15 to 24 in 14bb8f7
|
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.
Change is LGMT but we should review the other two potential missing states later.
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.
For consistency maybe add add
// IsSkipped represents if commit status state is skipped
func (css CommitStatusState) IsSkipped() bool {
return css == CommitStatusSkipped
}
@badhezi Seems like my "regression" was not real This test confirms your PR is fine, skipped never leaks to pull requests func testAPICreateBranchProtectionWithRepo(t *testing.T, owner, repo, branchName string, body *api.BranchProtection, expectedHTTPStatus int) {
token := getUserToken(t, "user2", auth_model.AccessTokenScopeWriteRepository)
req := NewRequestWithJSON(t, "POST", fmt.Sprintf("/api/v1/repos/%s/%s/branch_protections", owner, repo), body).
AddTokenAuth(token)
resp := MakeRequest(t, req, expectedHTTPStatus)
if resp.Code == http.StatusOK {
var branchProtection api.BranchProtection
DecodeJSON(t, resp, &branchProtection)
assert.Equal(t, branchName, branchProtection.RuleName)
}
}
func TestMergePullRequestWithSkippedTest(t *testing.T) {
onGiteaRun(t, func(t *testing.T, u *url.URL) {
// user2 is the owner of the base repo
user2 := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 2})
user2Token := getTokenForLoggedInUser(t, loginUser(t, user2.Name), auth_model.AccessTokenScopeWriteRepository, auth_model.AccessTokenScopeWriteUser)
// create the base repo
apiBaseRepo := createActionsTestRepo(t, user2Token, "merge-pull-request-with-skipped", false)
baseRepo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: apiBaseRepo.ID})
user2APICtx := NewAPITestContext(t, baseRepo.OwnerName, baseRepo.Name, auth_model.AccessTokenScopeWriteRepository)
// init the workflow
wfTreePath := ".gitea/workflows/pull.yml"
wfFileContent := `name: Pull Request
on:
pull_request:
jobs:
echo:
runs-on: ubuntu-latest
if: 'false'
steps:
- run: echo 'Hello World'
`
opts1 := getWorkflowCreateFileOptions(user2, baseRepo.DefaultBranch, "create "+wfTreePath, wfFileContent)
createWorkflowFile(t, user2Token, baseRepo.OwnerName, baseRepo.Name, wfTreePath, opts1)
// user4 creates a pull request to add file "app/main.go"
doAPICreateFile(user2APICtx, "app/main.go", &api.CreateFileOptions{
FileOptions: api.FileOptions{
NewBranchName: "user4/add-main",
Message: "create main.go",
Author: api.Identity{
Name: user2.Name,
Email: user2.Email,
},
Committer: api.Identity{
Name: user2.Name,
Email: user2.Email,
},
Dates: api.CommitDateOptions{
Author: time.Now(),
Committer: time.Now(),
},
},
ContentBase64: base64.StdEncoding.EncodeToString([]byte("// main.go")),
})(t)
apiPull, err := doAPICreatePullRequest(user2APICtx, baseRepo.OwnerName, baseRepo.Name, baseRepo.DefaultBranch, "user4/add-main")(t)
assert.NoError(t, err)
// enable status checks, require the "test1" check to pass
testAPICreateBranchProtectionWithRepo(t, baseRepo.OwnerName, baseRepo.Name, baseRepo.DefaultBranch, &api.BranchProtection{
BlockAdminMergeOverride: true,
RuleName: baseRepo.DefaultBranch,
EnableStatusCheck: true,
StatusCheckContexts: []string{"Pull Request / echo (pull_request)"},
}, http.StatusCreated)
runner := newMockRunner()
runner.registerAsRepoRunner(t, user2.Name, baseRepo.Name, "mock-runner", []string{"ubuntu-latest"}, false)
// TODO remove this once we have a way to skip jobs on Gitea side
task := runner.fetchTask(t)
runner.execTask(t, task, &mockTaskOutcome{
result: runnerv1.Result_RESULT_SKIPPED,
})
doAPIMergePullRequest(user2APICtx, baseRepo.OwnerName, baseRepo.Name, apiPull.Index)(t)
pullRequest := unittest.AssertExistsAndLoadBean(t, &issues_model.PullRequest{ID: apiPull.ID})
_ = pullRequest
})
} |
c35f9e4
to
8d78184
Compare
* giteaofficial/main: Refactor some tests (go-gitea#34580) Do not mutate incoming options to SearchRepositoryByName (go-gitea#34553) Fix/improve avatar sync from LDAP (go-gitea#34573) Fix some trivial problems (go-gitea#34579) Retain issue sort type when a keyword search is introduced (go-gitea#34559) Always use an empty line to separate the commit message and trailer (go-gitea#34512) Fix line-button issue after file selection in file tree (go-gitea#34574) [skip ci] Updated translations via Crowdin Fix doctor deleting orphaned issues attachments (go-gitea#34142) [skip ci] Updated translations via Crowdin Fix actions skipped commit status indicator (go-gitea#34507) Clean up "file-view" related styles (go-gitea#34558) Add "View workflow file" to Actions list page (go-gitea#34538) Do not mutate incoming options to RenderUserSearch and SearchUsers (go-gitea#34544) Add webhook assigning test and fix possible bug (go-gitea#34420) Fix possible nil description of pull request when migrating from CodeCommit (go-gitea#34541) Refactor commit reader (go-gitea#34542)
## Checklist - [x] go to the last cherry-pick PR (forgejo/forgejo#7965) to figure out how far it went: [gitea@9d4ebc1f2c](go-gitea/gitea@9d4ebc1) - [x] cherry-pick and open PR (forgejo/forgejo#8040) - [ ] have the PR pass the CI - end-to-end (specially important if there are actions related changes) - [ ] add `run-end-to-end` label - [ ] check the result - [ ] write release notes - [ ] assign reviewers - [ ] 48h later, last call - merge 1 hour after the last call ## Legend - ❓ - No decision about the commit has been made. - 🍒 - The commit has been cherry picked. - ⏩ - The commit has been skipped. - 💡 - The commit has been skipped, but should be ported to Forgejo. - ✍️ - The commit has been skipped, and a port to Forgejo already exists. ## Commits - 🍒 [`gitea`](go-gitea/gitea@50d9565) -> [`forgejo`](https://codeberg.org/forgejo/forgejo/commit/c3e6eab73235ac189ca3a36ce2b8ea8d8ad82c81) Add sort option recentclose for issues and pulls ([gitea#34525](go-gitea/gitea#34525)) ## TODO - 💡 [`gitea`](go-gitea/gitea@d5bbaee) Retain issue sort type when a keyword search is introduced ([gitea#34559](go-gitea/gitea#34559)) UI: Small bat might be nice. Test needed? Do we've frontend tests covering the search? ------ - 💡 [`gitea`](go-gitea/gitea@82ea238) Always use an empty line to separate the commit message and trailer ([gitea#34512](go-gitea/gitea#34512)) Needs merge ------ - 💡 [`gitea`](go-gitea/gitea@74858dc) Fix line-button issue after file selection in file tree ([gitea#34574](go-gitea/gitea#34574)) Frontend: Makes it sense to pick/port ui logic in *.ts files? ------ - 💡 [`gitea`](go-gitea/gitea@7149c9c) Fix doctor deleting orphaned issues attachments ([gitea#34142](go-gitea/gitea#34142)) Doctor: seems useful. ------ - 💡 [`gitea`](go-gitea/gitea@0cec4b8) Fix actions skipped commit status indicator ([gitea#34507](go-gitea/gitea#34507)) Actions: Might benefit from additional tests. ------ - 💡 [`gitea`](go-gitea/gitea@4cb0c64) Add "View workflow file" to Actions list page ([gitea#34538](go-gitea/gitea#34538)) Actions: Needs tests ------ - 💡 [`gitea`](go-gitea/gitea@b0936f4) Do not mutate incoming options to RenderUserSearch and SearchUsers ([gitea#34544](go-gitea/gitea#34544)) Nice refactoring but needs manual merge. ------ - 💡 [`gitea`](go-gitea/gitea@498088c) Add webhook assigning test and fix possible bug ([gitea#34420](go-gitea/gitea#34420)) Integrationtest has conflicts needs merge. ------ - 💡 [`gitea`](go-gitea/gitea@24a5105) Fix possible nil description of pull request when migrating from CodeCommit ([gitea#34541](go-gitea/gitea#34541)) Is this relevant to forgejo? Did not find the place to apply this small change. ------ - 💡 [`gitea`](go-gitea/gitea@688da55) Split GetLatestCommitStatus as two functions ([gitea#34535](go-gitea/gitea#34535)) Merge required. ------ - 💡 [`gitea`](go-gitea/gitea@ab96912) Don't display error log when .git-blame-ignore-revs doesn't exist ([gitea#34457](go-gitea/gitea#34457)) Unsure wheter this affects forgejo. Tests missing. ------ - 💡 [`gitea`](go-gitea/gitea@11ee7ff) fix: return 201 Created for CreateVariable API responses ([gitea#34517](go-gitea/gitea#34517)) Actions: This is marked as breaking the api. Pls think about whether this breaking change iss needed & how this impact api-version-increase. The corresponding clinet change can be found here: https://gitea.com/gitea/go-sdk/pulls/713/files ------ - 💡 [`gitea`](go-gitea/gitea@9b295e9) Actions list ([gitea#34530](go-gitea/gitea#34530)) Actions: Regression from go-gitea/gitea#34337 Part of https://codeberg.org/forgejo/forgejo/pulls/7909 ------ ## Skipped - ⏩ [`gitea`](go-gitea/gitea@bb6377d) [skip ci] Updated translations via Crowdin ------ - ⏩ [`gitea`](go-gitea/gitea@07d802a) [skip ci] Updated translations via Crowdin ------ - ⏩ [`gitea`](go-gitea/gitea@c6e2093) Clean up "file-view" related styles ([gitea#34558](go-gitea/gitea#34558)) - gitea ui specific specific ------ - ⏩ [`gitea`](go-gitea/gitea@9f10885) Refactor commit reader ([gitea#34542](go-gitea/gitea#34542)) - gitea refactor specific ------ <details> <summary><h2>Stats</h2></summary> <br> Between [`gitea@9d4ebc1f2c`](go-gitea/gitea@9d4ebc1) and [`gitea@d5bbaee64e`](go-gitea/gitea@d5bbaee), **18** commits have been reviewed. We picked **1**, skipped **4**, and decided to port **13**. </details> Co-authored-by: Markus Amshove <scm@amshove.org> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/8040 Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org> Co-authored-by: Michael Jerger <michael.jerger@meissa-gmbh.de> Co-committed-by: Michael Jerger <michael.jerger@meissa-gmbh.de>
Addresses #34500