- 
          
 - 
                Notifications
    
You must be signed in to change notification settings  - Fork 6.2k
 
Implement auto-cancellation of concurrent jobs if the event is push #25716
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
          
     Merged
      
      
    
  
     Merged
                    Changes from 20 commits
      Commits
    
    
            Show all changes
          
          
            28 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      a20c5c3
              
                feat: implement auto-cancellation of concurrent jobs
              
              
                appleboy a1b22e2
              
                refactor: refactor status field to support multiple values
              
              
                appleboy f066eb0
              
                refactor: optimize job cancellation and action run indexing
              
              
                appleboy b64ed17
              
                refactor: refactor job cancellation process
              
              
                appleboy e318f28
              
                Merge branch 'main' into cancel
              
              
                appleboy 251be01
              
                Merge branch 'main' into cancel
              
              
                appleboy edeb7af
              
                Merge branch 'main' into cancel
              
              
                appleboy 2db7378
              
                Update models/actions/run.go
              
              
                appleboy f383d9e
              
                Merge branch 'main' into cancel
              
              
                appleboy 1b16a52
              
                Merge branch 'main' into cancel
              
              
                lunny a7ed008
              
                refactor: refactor code to use `WorkflowID` instead of `WorkflowFileN…
              
              
                appleboy 18cd66f
              
                refactor: refine job cancellation and notification logic
              
              
                appleboy 05f078d
              
                refactor: refactor job cancellation in workflows
              
              
                appleboy 6b6b17c
              
                Merge branch 'main' into cancel
              
              
                appleboy 231e237
              
                refactor: improve code readability and test robustness
              
              
                appleboy c542d1b
              
                feat: implement migration to update actions ref index
              
              
                appleboy d3edc58
              
                Merge branch 'main' into cancel
              
              
                appleboy 2412e84
              
                refactor: refactor notifier helper and improve job handling
              
              
                appleboy 5d78596
              
                refactor: refactor status filter handling in `actions.go`
              
              
                appleboy b0ab570
              
                Merge branch 'main' into cancel
              
              
                appleboy d7b577f
              
                Apply suggestions from code review
              
              
                wolfogre 1af0878
              
                Merge branch 'main' into cancel
              
              
                GiteaBot e767742
              
                Update models/actions/run.go
              
              
                appleboy 9ab6ec4
              
                Update models/actions/run_list.go
              
              
                appleboy d649e95
              
                Update models/migrations/v1_21/v267.go
              
              
                appleboy face538
              
                Update services/actions/notifier_helper.go
              
              
                wolfogre 8a05c67
              
                chore: update migration version and rename file
              
              
                appleboy a79384d
              
                Merge branch 'main' into cancel
              
              
                appleboy File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| // Copyright 2023 The Gitea Authors. All rights reserved. | ||
| // SPDX-License-Identifier: MIT | ||
| 
     | 
||
| package v1_21 //nolint | ||
| 
     | 
||
| import ( | ||
| "code.gitea.io/gitea/models/actions" | ||
| "code.gitea.io/gitea/modules/timeutil" | ||
| webhook_module "code.gitea.io/gitea/modules/webhook" | ||
| 
     | 
||
                
      
                  wolfogre marked this conversation as resolved.
               
              
                Outdated
          
            Show resolved
            Hide resolved
         | 
||
| "xorm.io/xorm" | ||
| ) | ||
| 
     | 
||
| // UpdateActionsRefIndex updates the index of actions ref field | ||
| func UpdateActionsRefIndex(x *xorm.Engine) error { | ||
| type ActionRun struct { | ||
| ID int64 | ||
| Title string | ||
| RepoID int64 `xorm:"index unique(repo_index)"` | ||
| OwnerID int64 `xorm:"index"` | ||
| WorkflowID string `xorm:"index"` // the name of workflow file | ||
| Index int64 `xorm:"index unique(repo_index)"` // a unique number for each run of a repository | ||
| TriggerUserID int64 `xorm:"index"` | ||
| Ref string `xorm:"index"` // the ref of the run | ||
| CommitSHA string | ||
| IsForkPullRequest bool // If this is triggered by a PR from a forked repository or an untrusted user, we need to check if it is approved and limit permissions when running the workflow. | ||
| NeedApproval bool // may need approval if it's a fork pull request | ||
| ApprovedBy int64 `xorm:"index"` // who approved | ||
| Event webhook_module.HookEventType // the webhook event that causes the workflow to run | ||
| EventPayload string `xorm:"LONGTEXT"` | ||
| TriggerEvent string // the trigger event defined in the `on` configuration of the triggered workflow | ||
| Status actions.Status `xorm:"index"` | ||
| Started timeutil.TimeStamp | ||
| Stopped timeutil.TimeStamp | ||
| Created timeutil.TimeStamp `xorm:"created"` | ||
| Updated timeutil.TimeStamp `xorm:"updated"` | ||
                
      
                  wolfogre marked this conversation as resolved.
               
              
                Outdated
          
            Show resolved
            Hide resolved
         | 
||
| } | ||
| return x.Sync(new(ActionRun)) | ||
| } | ||
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
Uh oh!
There was an error while loading. Please reload this page.