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

Implement auto-cancellation of concurrent jobs if the event is push #25716

Merged
merged 28 commits into from
Jul 25, 2023

Commits on Jul 6, 2023

  1. feat: implement auto-cancellation of concurrent jobs

    - Add a new function `CancelRunningJobs` to cancel all running jobs of a run
    - Update `FindRunOptions` struct to include `Ref` field and update its condition in `toConds` function
    - Implement auto cancellation of running jobs in the same workflow in `notify` function
    
    Signed-off-by: Bo-Yi Wu <[email protected]>
    appleboy committed Jul 6, 2023
    Configuration menu
    Copy the full SHA
    a20c5c3 View commit details
    Browse the repository at this point in the history
  2. refactor: refactor status field to support multiple values

    - Change the `Status` field in `CancelRunningJobs`, `FindRunOptions`, and `List` functions from a single `Status` to a slice of `Status`.
    - Update the condition in `toConds` function to check the length of `Status` slice instead of comparing a single `Status` value with `StatusUnknown`.
    - Modify the condition to use `builder.In` for matching multiple `Status` values instead of `builder.Eq` for a single `Status` value.
    
    Signed-off-by: Bo-Yi Wu <[email protected]>
    appleboy committed Jul 6, 2023
    Configuration menu
    Copy the full SHA
    a1b22e2 View commit details
    Browse the repository at this point in the history

Commits on Jul 7, 2023

  1. refactor: optimize job cancellation and action run indexing

    - Add an index to the `Ref` field in the `ActionRun` struct
    - Modify the `CancelRunningJobs` function to use `total` instead of `len(runs)` for checking if there are no runs.
    
    Signed-off-by: Bo-Yi Wu <[email protected]>
    appleboy committed Jul 7, 2023
    Configuration menu
    Copy the full SHA
    f066eb0 View commit details
    Browse the repository at this point in the history
  2. refactor: refactor job cancellation process

    - Remove the code that sets the status of a run to cancelled and updates the run in `CancelRunningJobs` function.
    
    Signed-off-by: Bo-Yi Wu <[email protected]>
    appleboy committed Jul 7, 2023
    Configuration menu
    Copy the full SHA
    b64ed17 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    e318f28 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    251be01 View commit details
    Browse the repository at this point in the history

Commits on Jul 8, 2023

  1. Configuration menu
    Copy the full SHA
    edeb7af View commit details
    Browse the repository at this point in the history

Commits on Jul 12, 2023

  1. Update models/actions/run.go

    Co-authored-by: Jason Song <[email protected]>
    appleboy and wolfogre authored Jul 12, 2023
    Configuration menu
    Copy the full SHA
    2db7378 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    f383d9e View commit details
    Browse the repository at this point in the history

Commits on Jul 13, 2023

  1. Configuration menu
    Copy the full SHA
    1b16a52 View commit details
    Browse the repository at this point in the history

Commits on Jul 21, 2023

  1. refactor: refactor code to use WorkflowID instead of `WorkflowFileN…

    …ame`
    
    - Add `WorkflowID` to the `CancelRunningJobs` function in `run.go`
    - Replace `WorkflowFileName` with `WorkflowID` in `FindRunOptions` struct in `run_list.go`
    - Update conditions in `toConds` function to use `WorkflowID` instead of `WorkflowFileName` in `run_list.go`
    - Replace `WorkflowFileName` with `WorkflowID` in `List` function in `actions.go`
    
    Signed-off-by: appleboy <[email protected]>
    appleboy committed Jul 21, 2023
    Configuration menu
    Copy the full SHA
    a7ed008 View commit details
    Browse the repository at this point in the history
  2. refactor: refine job cancellation and notification logic

    - Modify the comment for the `CancelRunningJobs` function to specify that it also marks unstarted jobs as cancelled
    - Change the comment in `notify` function to specify that running jobs are cancelled only if the event is a push
    - Add a condition in `notify` function to cancel running jobs of the same workflow only if the event is a push
    
    Signed-off-by: appleboy <[email protected]>
    appleboy committed Jul 21, 2023
    Configuration menu
    Copy the full SHA
    18cd66f View commit details
    Browse the repository at this point in the history
  3. refactor: refactor job cancellation in workflows

    - Update the `CancelRunningJobs` function to cancel all running and waiting jobs associated with a specific workflow
    - Modify the function parameters to include `repoID`, `ref`, and `workflowID`
    - Add checks and conditions to handle different job states during cancellation
    - Update the call to `CancelRunningJobs` in `notifier_helper.go` to match the new function signature
    
    Signed-off-by: appleboy <[email protected]>
    appleboy committed Jul 21, 2023
    Configuration menu
    Copy the full SHA
    05f078d View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    6b6b17c View commit details
    Browse the repository at this point in the history
  5. refactor: improve code readability and test robustness

    - Refactor the `CancelRunningJobs` function parameters for better readability.
    
    Signed-off-by: appleboy <[email protected]>
    appleboy committed Jul 21, 2023
    Configuration menu
    Copy the full SHA
    231e237 View commit details
    Browse the repository at this point in the history
  6. feat: implement migration to update actions ref index

    - Add a new migration "Update Action Ref" to the migrations list
    - Create a new file `v267.go` in `models/migrations/v1_21` directory
    - Define a new function `UpdateActionsRefIndex` in `v267.go` to update the index of actions ref field
    - The `UpdateActionsRefIndex` function syncs a new instance of `ActionRun` struct which includes fields like `ID`, `Title`, `RepoID`, `OwnerID`, `WorkflowID`, `Index`, `TriggerUserID`, `Ref`, `CommitSHA`, `IsForkPullRequest`, `NeedApproval`, `ApprovedBy`, `Event`, `EventPayload`, `TriggerEvent`, `Status`, `Started`, `Stopped`, `Created`, `Updated`.
    
    Signed-off-by: appleboy <[email protected]>
    appleboy committed Jul 21, 2023
    Configuration menu
    Copy the full SHA
    c542d1b View commit details
    Browse the repository at this point in the history

Commits on Jul 22, 2023

  1. Configuration menu
    Copy the full SHA
    d3edc58 View commit details
    Browse the repository at this point in the history
  2. refactor: refactor notifier helper and improve job handling

    - Refactor the `notify` function in `notifier_helper.go` to separate the job finding and error handling steps.
    - Replace the `jobs` variable with `alljobs` to better reflect its purpose.
    - Remove the else clause and use `continue` for better readability and flow control.
    - Call `CreateCommitStatus` with `alljobs` instead of `jobs`.
    
    Signed-off-by: appleboy <[email protected]>
    appleboy committed Jul 22, 2023
    Configuration menu
    Copy the full SHA
    2412e84 View commit details
    Browse the repository at this point in the history
  3. refactor: refactor status filter handling in actions.go

    - Remove the status filter from the list function in `actions.go`
    - Add a check for `StatusUnknown` before applying the status filter in `actions.go`
    
    Signed-off-by: appleboy <[email protected]>
    appleboy committed Jul 22, 2023
    Configuration menu
    Copy the full SHA
    5d78596 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    b0ab570 View commit details
    Browse the repository at this point in the history

Commits on Jul 24, 2023

  1. Configuration menu
    Copy the full SHA
    d7b577f View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    1af0878 View commit details
    Browse the repository at this point in the history
  3. Update models/actions/run.go

    Co-authored-by: delvh <[email protected]>
    appleboy and delvh authored Jul 24, 2023
    Configuration menu
    Copy the full SHA
    e767742 View commit details
    Browse the repository at this point in the history
  4. Update models/actions/run_list.go

    Co-authored-by: delvh <[email protected]>
    appleboy and delvh authored Jul 24, 2023
    Configuration menu
    Copy the full SHA
    9ab6ec4 View commit details
    Browse the repository at this point in the history
  5. Update models/migrations/v1_21/v267.go

    Co-authored-by: delvh <[email protected]>
    appleboy and delvh authored Jul 24, 2023
    Configuration menu
    Copy the full SHA
    d649e95 View commit details
    Browse the repository at this point in the history

Commits on Jul 25, 2023

  1. Configuration menu
    Copy the full SHA
    face538 View commit details
    Browse the repository at this point in the history
  2. chore: update migration version and rename file

    - Update migration version from `v267` to `v269`
    - Rename migration file from `v267.go` to `v268.go`
    
    Signed-off-by: Bo-Yi Wu <[email protected]>
    appleboy committed Jul 25, 2023
    Configuration menu
    Copy the full SHA
    8a05c67 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    a79384d View commit details
    Browse the repository at this point in the history