Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add workflow_run api + webhook #33964

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

Open
wants to merge 59 commits into
base: main
Choose a base branch
from

Conversation

ChristopherHX
Copy link
Contributor

@ChristopherHX ChristopherHX commented Mar 21, 2025

Implements

Fixes

  • workflow_job webhook url to no longer contain the runs/<run> part to align with api
  • workflow instance does now use it's name inside the file instead of filename if set

Refactoring

  • Moved a lot of logic from workflows/workflow_job into a shared module used by both webhook and api

TODO

  • Verify Keda Compatibility

Closes #23670
Closes #23796
Closes #24898
Replaces #28047 and is much more complete

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Mar 21, 2025
@github-actions github-actions bot added modifies/translation modifies/api This PR adds API routes or modifies them modifies/go Pull requests that update Go code labels Mar 21, 2025
Copy link
Contributor Author

@ChristopherHX ChristopherHX left a comment

Choose a reason for hiding this comment

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

Test cases has been added, so moving out of draft after several weeks.

Now e2e usage case verification with external tools like keda are outstanding.

Comment on lines 88 to 90
if opts.OwnerID > 0 {
cond = cond.And(builder.Eq{"owner_id": opts.OwnerID})
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Previously unused, we need an inner join for this condition

Comment on lines 82 to 84
if opts.OwnerID > 0 {
cond = cond.And(builder.Eq{"owner_id": opts.OwnerID})
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Previously unused, we need an inner join for this condition

func (opts FindRunOptions) ToOrders() string {
return "`id` DESC"
return "`action_run`.`id` DESC"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

inner join requires mentioning the table name

@ChristopherHX ChristopherHX marked this pull request as ready for review May 5, 2025 21:10
@ChristopherHX
Copy link
Contributor Author

Verification update of keda k8s autoscaler (current gitea 1.24-rc works only with modified garm).

Uses these apis

  • runs api
  • jobs of run api

I could change the existing keda github-runner e2e test to pass on my end by manually running gitea and setting up the test repository without changing non test content.

go test -v -tags e2e ./scalers/github_runner
=== RUN   TestScaler
    gitea_runner_test.go:219: --- setting up ---
    helper.go:247: deleting namespace github-runner-test-ns
    helper.go:301: waiting for namespace github-runner-test-ns deletion
    helper.go:301: waiting for namespace github-runner-test-ns deletion
    helper.go:301: waiting for namespace github-runner-test-ns deletion
    helper.go:301: waiting for namespace github-runner-test-ns deletion
    helper.go:234: Creating namespace - github-runner-test-ns
    helper.go:541: Applying template: secretTemplate
    helper.go:541: Applying template: authTemplate
    helper.go:541: Applying template: deploymentTemplate
    helper.go:541: Applying template: scaledObjectTemplate
    helper.go:541: Applying template: scaledJobTemplate
    helper.go:366: Waiting for pods in namespace to hit target. Namespace - github-runner-test-ns, Current  - 0, Target - 0
    helper.go:541: Applying template: scaledJobTemplate
    gitea_runner_test.go:326: --- testing scale out ---
    helper.go:326: Waiting for job count to hit target. Namespace - github-runner-test-ns, Current  - 0, Target - 1
    helper.go:326: Waiting for job count to hit target. Namespace - github-runner-test-ns, Current  - 0, Target - 1
    helper.go:326: Waiting for job count to hit target. Namespace - github-runner-test-ns, Current  - 0, Target - 1
    helper.go:326: Waiting for job count to hit target. Namespace - github-runner-test-ns, Current  - 0, Target - 1
    helper.go:326: Waiting for job count to hit target. Namespace - github-runner-test-ns, Current  - 0, Target - 1
    helper.go:326: Waiting for job count to hit target. Namespace - github-runner-test-ns, Current  - 0, Target - 1
    helper.go:326: Waiting for job count to hit target. Namespace - github-runner-test-ns, Current  - 0, Target - 1
    helper.go:326: Waiting for job count to hit target. Namespace - github-runner-test-ns, Current  - 0, Target - 1
    helper.go:326: Waiting for job count to hit target. Namespace - github-runner-test-ns, Current  - 0, Target - 1
    helper.go:326: Waiting for job count to hit target. Namespace - github-runner-test-ns, Current  - 0, Target - 1
    helper.go:326: Waiting for job count to hit target. Namespace - github-runner-test-ns, Current  - 0, Target - 1
    helper.go:326: Waiting for job count to hit target. Namespace - github-runner-test-ns, Current  - 0, Target - 1
    helper.go:326: Waiting for job count to hit target. Namespace - github-runner-test-ns, Current  - 0, Target - 1
    helper.go:326: Waiting for job count to hit target. Namespace - github-runner-test-ns, Current  - 0, Target - 1
    helper.go:326: Waiting for job count to hit target. Namespace - github-runner-test-ns, Current  - 0, Target - 1
    helper.go:326: Waiting for job count to hit target. Namespace - github-runner-test-ns, Current  - 1, Target - 1
    gitea_runner_test.go:333: --- testing scale in ---
    helper.go:291: all jobs ran successfully!
    helper.go:739: killing all pods in github-runner-test-ns namespace with selector app=github-runner-test-sj
    helper.go:541: Applying template: scaledObjectTemplate
    gitea_runner_test.go:306: --- testing none activation ---
    helper.go:494: Waiting for some time to ensure deployment replica count doesn't change from 0
    helper.go:501: Deployment - github-runner-test-deployment, Current  - 0
    helper.go:501: Deployment - github-runner-test-deployment, Current  - 0
    helper.go:501: Deployment - github-runner-test-deployment, Current  - 0
    helper.go:501: Deployment - github-runner-test-deployment, Current  - 0
    helper.go:501: Deployment - github-runner-test-deployment, Current  - 0
    helper.go:501: Deployment - github-runner-test-deployment, Current  - 0
    helper.go:501: Deployment - github-runner-test-deployment, Current  - 0
    helper.go:501: Deployment - github-runner-test-deployment, Current  - 0
    helper.go:501: Deployment - github-runner-test-deployment, Current  - 0
    helper.go:501: Deployment - github-runner-test-deployment, Current  - 0
    helper.go:501: Deployment - github-runner-test-deployment, Current  - 0
    helper.go:501: Deployment - github-runner-test-deployment, Current  - 0
    helper.go:501: Deployment - github-runner-test-deployment, Current  - 0
    helper.go:501: Deployment - github-runner-test-deployment, Current  - 0
    helper.go:501: Deployment - github-runner-test-deployment, Current  - 0
    helper.go:501: Deployment - github-runner-test-deployment, Current  - 0
    helper.go:501: Deployment - github-runner-test-deployment, Current  - 0
    helper.go:501: Deployment - github-runner-test-deployment, Current  - 0
    helper.go:501: Deployment - github-runner-test-deployment, Current  - 0
    helper.go:501: Deployment - github-runner-test-deployment, Current  - 0
    helper.go:501: Deployment - github-runner-test-deployment, Current  - 0
    helper.go:501: Deployment - github-runner-test-deployment, Current  - 0
    helper.go:501: Deployment - github-runner-test-deployment, Current  - 0
    helper.go:501: Deployment - github-runner-test-deployment, Current  - 0
    helper.go:501: Deployment - github-runner-test-deployment, Current  - 0
    helper.go:501: Deployment - github-runner-test-deployment, Current  - 0
    helper.go:501: Deployment - github-runner-test-deployment, Current  - 0
    helper.go:501: Deployment - github-runner-test-deployment, Current  - 0
    helper.go:501: Deployment - github-runner-test-deployment, Current  - 0
    helper.go:501: Deployment - github-runner-test-deployment, Current  - 0
    helper.go:501: Deployment - github-runner-test-deployment, Current  - 0
    helper.go:501: Deployment - github-runner-test-deployment, Current  - 0
    helper.go:501: Deployment - github-runner-test-deployment, Current  - 0
    helper.go:501: Deployment - github-runner-test-deployment, Current  - 0
    helper.go:501: Deployment - github-runner-test-deployment, Current  - 0
    helper.go:501: Deployment - github-runner-test-deployment, Current  - 0
    helper.go:501: Deployment - github-runner-test-deployment, Current  - 0
    helper.go:501: Deployment - github-runner-test-deployment, Current  - 0
    helper.go:501: Deployment - github-runner-test-deployment, Current  - 0
    helper.go:501: Deployment - github-runner-test-deployment, Current  - 0
    helper.go:501: Deployment - github-runner-test-deployment, Current  - 0
    helper.go:501: Deployment - github-runner-test-deployment, Current  - 0
    helper.go:501: Deployment - github-runner-test-deployment, Current  - 0
    helper.go:501: Deployment - github-runner-test-deployment, Current  - 0
    helper.go:501: Deployment - github-runner-test-deployment, Current  - 0
    helper.go:501: Deployment - github-runner-test-deployment, Current  - 0
    helper.go:501: Deployment - github-runner-test-deployment, Current  - 0
    helper.go:501: Deployment - github-runner-test-deployment, Current  - 0
    helper.go:501: Deployment - github-runner-test-deployment, Current  - 0
    helper.go:501: Deployment - github-runner-test-deployment, Current  - 0
    helper.go:501: Deployment - github-runner-test-deployment, Current  - 0
    helper.go:501: Deployment - github-runner-test-deployment, Current  - 0
    helper.go:501: Deployment - github-runner-test-deployment, Current  - 0
    helper.go:501: Deployment - github-runner-test-deployment, Current  - 0
    helper.go:501: Deployment - github-runner-test-deployment, Current  - 0
    helper.go:501: Deployment - github-runner-test-deployment, Current  - 0
    helper.go:501: Deployment - github-runner-test-deployment, Current  - 0
    helper.go:501: Deployment - github-runner-test-deployment, Current  - 0
    helper.go:501: Deployment - github-runner-test-deployment, Current  - 0
    helper.go:501: Deployment - github-runner-test-deployment, Current  - 0
    gitea_runner_test.go:311: --- testing scale out ---
    helper.go:437: Waiting for deployment replicas to hit target. Deployment - github-runner-test-deployment, Current  - 0, Target - 1
    helper.go:437: Waiting for deployment replicas to hit target. Deployment - github-runner-test-deployment, Current  - 0, Target - 1
    helper.go:437: Waiting for deployment replicas to hit target. Deployment - github-runner-test-deployment, Current  - 0, Target - 1
    helper.go:437: Waiting for deployment replicas to hit target. Deployment - github-runner-test-deployment, Current  - 0, Target - 1
    helper.go:437: Waiting for deployment replicas to hit target. Deployment - github-runner-test-deployment, Current  - 0, Target - 1
    helper.go:437: Waiting for deployment replicas to hit target. Deployment - github-runner-test-deployment, Current  - 0, Target - 1
    helper.go:437: Waiting for deployment replicas to hit target. Deployment - github-runner-test-deployment, Current  - 0, Target - 1
    helper.go:437: Waiting for deployment replicas to hit target. Deployment - github-runner-test-deployment, Current  - 0, Target - 1
    helper.go:437: Waiting for deployment replicas to hit target. Deployment - github-runner-test-deployment, Current  - 0, Target - 1
    helper.go:437: Waiting for deployment replicas to hit target. Deployment - github-runner-test-deployment, Current  - 0, Target - 1
    helper.go:437: Waiting for deployment replicas to hit target. Deployment - github-runner-test-deployment, Current  - 0, Target - 1
    helper.go:437: Waiting for deployment replicas to hit target. Deployment - github-runner-test-deployment, Current  - 1, Target - 1
    gitea_runner_test.go:319: --- testing scale in ---
    helper.go:366: Waiting for pods in namespace to hit target. Namespace - github-runner-test-ns, Current  - 1, Target - 0
    helper.go:366: Waiting for pods in namespace to hit target. Namespace - github-runner-test-ns, Current  - 1, Target - 0
    helper.go:366: Waiting for pods in namespace to hit target. Namespace - github-runner-test-ns, Current  - 1, Target - 0
    helper.go:366: Waiting for pods in namespace to hit target. Namespace - github-runner-test-ns, Current  - 0, Target - 0
    helper.go:610: Deleting template: scaledJobTemplate
    helper.go:610: Deleting template: scaledObjectTemplate
    helper.go:610: Deleting template: deploymentTemplate
    helper.go:610: Deleting template: authTemplate
    helper.go:610: Deleting template: secretTemplate
    helper.go:247: deleting namespace github-runner-test-ns
    helper.go:301: waiting for namespace github-runner-test-ns deletion
    helper.go:301: waiting for namespace github-runner-test-ns deletion
    helper.go:301: waiting for namespace github-runner-test-ns deletion
--- PASS: TestScaler (133.36s)
PASS
ok      github.com/kedacore/keda/v2/tests/scalers/github_runner 133.750s

Maybe we could setup extended e2e test repositories to track external autoscaler compatibility

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. modifies/api This PR adds API routes or modifies them modifies/go Pull requests that update Go code modifies/templates This PR modifies the template files modifies/translation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

workflow_run for action trigger event Webhook trigger for actions (CI) Implement workflow_* webhook event
3 participants