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

notification: store commit status and commit status delivery #432

Merged
merged 1 commit into from
Oct 9, 2023

Conversation

alessandro-sorint
Copy link
Contributor

@alessandro-sorint alessandro-sorint commented Sep 14, 2023

Resolves #430

internal/services/notification/commitstatusdelivery.go Outdated Show resolved Hide resolved
internal/services/notification/db/objects/objects.go Outdated Show resolved Hide resolved
internal/testutil/db.go Outdated Show resolved Hide resolved
services/notification/types/commitstatusdata.go Outdated Show resolved Hide resolved
services/notification/types/commitstatusdata.go Outdated Show resolved Hide resolved
@alessandro-sorint
Copy link
Contributor Author

@sgotti can you do the review please?

Copy link
Member

@sgotti sgotti left a comment

Choose a reason for hiding this comment

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

Can you add some tests like done for the runevents?

@alessandro-sorint
Copy link
Contributor Author

Can you add some tests like done for the runevents?

@sgotti to do the tests like runevents(in notification_test) I need to use also the configstore because the delivery need the gitsource. For the moment I added only the integration test TestCommitStatusDelivery.
Should I start the configstore in notification_test?

@sgotti
Copy link
Member

sgotti commented Oct 3, 2023

@sgotti to do the tests like runevents(in notification_test) I need to use also the configstore because the delivery need the gitsource. For the moment I added only the integration test TestCommitStatusDelivery.
Should I start the configstore in notification_test?

No or it'll become an integration test.

What should be done is to create a stub gitsource and related receiver, use an interface for the a function to get the remotesource (and so the configstore calls) and use a different implementation only for tests.

@alessandro-sorint alessandro-sorint force-pushed the savecommitstatus branch 4 times, most recently from bbb82fd to ef55539 Compare October 5, 2023 13:05
internal/services/notification/commitstatus.go Outdated Show resolved Hide resolved
services/notification/types/commitstatus.go Outdated Show resolved Hide resolved
Status: cs.Status,
TargetURL: targetURLTest,
Description: cs.Description,
Context: cs.Context,
Copy link
Member

Choose a reason for hiding this comment

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

Why don't you just save all the values provided by *types.CommitStatus?

Comment on lines 491 to 496
cs.CommitSHA = commitShaTest
cs.Context = contextTest
cs.Description = commitStatusDescription
cs.ProjectID = projectIDTest
cs.RunCounter = 1
cs.Status = types.CommitStatusSuccess
Copy link
Member

Choose a reason for hiding this comment

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

Why are you generating the same identical commit status?


t.Logf("starting ns")

time.Sleep(1 * time.Second)
Copy link
Member

Choose a reason for hiding this comment

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

why time.Sleep?


t.Logf("starting ns")

time.Sleep(1 * time.Second)
Copy link
Member

Choose a reason for hiding this comment

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

Why time.Sleep?

}
}

func webRunURL(webExposedURL, projectID string, runNumber uint64) (string, error) {
Copy link
Member

Choose a reason for hiding this comment

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

This function has been copied from the notification service. Define it inline inside the test instead of globally and add a comment that it has been copied from the notification service.

ctx, cancel := context.WithCancel(context.Background())
defer cancel()

wr := setupWebhooksReceiver(ctx, t, wrDir)
Copy link
Member

Choose a reason for hiding this comment

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

is this really needed for this test?


err := ns.d.Do(ctx, func(tx *sql.Tx) error {
cs = types.NewCommitStatus(tx)
cs.CommitSHA = commitShaTest + fmt.Sprint(n)
Copy link
Member

Choose a reason for hiding this comment

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

fmt.Sprintf("commitSHA-%d", n)

Comment on lines 491 to 493
cs.Context = contextTest + fmt.Sprint(n)
cs.Description = commitStatusDescription
cs.ProjectID = projectIDTest + fmt.Sprint(n)
Copy link
Member

Choose a reason for hiding this comment

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

Ditto

Comment on lines 479 to 482
projectIDTest = "projectid"
commitShaTest = "commitSha"
contextTest = "context"
commitStatusDescription = "The run finished successfully"
Copy link
Member

Choose a reason for hiding this comment

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

No need for consts since they are used only one time.

}, nil
}

u := &GitSourceCommitStatusUpdater{n: n}
Copy link
Member

Choose a reason for hiding this comment

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

Create it before NotificationService and set it in the struct.


t.Logf("starting ns")

s := &StubCommitStatusUpdater{}
Copy link
Member

Choose a reason for hiding this comment

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

use setupStub... as in the other test.

@@ -40,6 +41,12 @@ type NotificationService struct {

runserviceClient *rsclient.Client
configstoreClient *csclient.Client

u updaterCommitStatus
Copy link
Member

Choose a reason for hiding this comment

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

commitStatusUpdater

u updaterCommitStatus
}

type updaterCommitStatus interface {
Copy link
Member

Choose a reason for hiding this comment

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

commitStatusUpdater

}

type GitSourceCommitStatusUpdater struct {
n *NotificationService
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 set notification service inside status updater. Set the configstore client, config etc....

Comment on lines 5820 to 5829
// it has been copied from the notification service
u, err := url.Parse(sc.config.Notification.WebExposedURL + "/run")
if err != nil {
t.Fatalf("unexpected err: %v", err)
}
q := url.Values{}
q.Set("projectref", project.ID)
q.Set("runnumber", strconv.FormatUint(runs[0].Number, 10))
u.RawQuery = q.Encode()
targetURL := u.String()
Copy link
Member

Choose a reason for hiding this comment

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

outside the tests range but inside the TestFunction define an inline function and use it here.

Copy link
Member

Choose a reason for hiding this comment

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

Why this files has been changed?

Copy link
Member

Choose a reason for hiding this comment

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

Why this files has been changed?

Comment on lines +21 to +41
{"exportMeta":{"kind":"RunWebhookDelivery"},"id":"2e7d8e4f-6614-495f-b5f5-7a3a589c4ee1","creationTime":"2023-04-03T12:07:11.837436311Z","updateTime":"2023-04-03T12:07:11.837436311Z","sequence":1,"delivery_status":"delivered", "run_webhook_id":"0f324898-442d-477c-93df-eb2229b3f922", "delivered_at":"2023-04-03T12:07:11.837436311Z", "status_code":200}
{"exportMeta":{"kind":"RunWebhookDelivery"},"id":"960ba478-b117-490e-9ae2-cb19b8d081e2","creationTime":"2023-04-03T12:07:16.840625135Z","updateTime":"2023-04-03T12:07:16.840625135Z","sequence":2,"delivery_status":"delivered", "run_webhook_id":"11016652-3c7a-4519-9fbf-7422d7c8cbc1", "delivered_at":"2023-04-03T12:07:16.840625135Z", "status_code":200}
{"exportMeta":{"kind":"RunWebhookDelivery"},"id":"2934275f-160c-468c-9c76-b50a411a9712","creationTime":"2023-04-03T12:07:11.835348076Z","updateTime":"2023-04-03T12:07:11.835348076Z","sequence":3,"delivery_status":"delivered", "run_webhook_id":"21a3b09b-f30f-4167-9e1b-516217af58d0", "delivered_at":"2023-04-03T12:07:11.835348076Z", "status_code":200}
{"exportMeta":{"kind":"RunWebhookDelivery"},"id":"2393e6d9-4d43-4078-a2e5-2cfedccb014e","creationTime":"2023-04-03T12:07:11.834466379Z","updateTime":"2023-04-03T12:07:11.834466379Z","sequence":4,"delivery_status":"delivered", "run_webhook_id":"30590789-e1fd-44c5-9cfc-6854ebb8110d", "delivered_at":"2023-04-03T12:07:11.834466379Z", "status_code":200}
{"exportMeta":{"kind":"RunWebhookDelivery"},"id":"1108e91b-bed1-4506-9af5-bf98e9c30153","creationTime":"2023-04-03T12:07:11.835961926Z","updateTime":"2023-04-03T12:07:11.835961926Z","sequence":5,"delivery_status":"delivered", "run_webhook_id":"41bf0d4b-78e8-4ed2-9a1d-a0278c67bf89", "delivered_at":"2023-04-03T12:07:11.835961926Z", "status_code":200}
{"exportMeta":{"kind":"RunWebhookDelivery"},"id":"f13de536-59c6-4057-93d6-d97a3820cf74","creationTime":"2023-04-03T12:07:16.841611527Z","updateTime":"2023-04-03T12:07:16.841611527Z","sequence":6,"delivery_status":"delivered", "run_webhook_id":"439d278c-433e-4268-b98d-769139e83419", "delivered_at":"2023-04-03T12:07:16.841611527Z", "status_code":200}
{"exportMeta":{"kind":"RunWebhookDelivery"},"id":"78065d4d-68ac-4b26-9db1-dac584ef67db","creationTime":"2023-04-03T12:07:16.840050048Z","updateTime":"2023-04-03T12:07:16.840050048Z","sequence":7,"delivery_status":"delivered", "run_webhook_id":"4dd0ff39-8d53-4614-90a4-90ac406c73a9", "delivered_at":"2023-04-03T12:07:16.840050048Z", "status_code":200}
{"exportMeta":{"kind":"RunWebhookDelivery"},"id":"f02ad0fe-db1f-470c-8ab9-31fb82f9a534","creationTime":"2023-04-03T12:07:11.835003681Z","updateTime":"2023-04-03T12:07:11.835003681Z","sequence":8,"delivery_status":"delivered", "run_webhook_id":"4e2c3472-e6c9-4edf-a8ce-1bdeaddc5567", "delivered_at":"2023-04-03T12:07:11.835003681Z", "status_code":200}
{"exportMeta":{"kind":"RunWebhookDelivery"},"id":"375decce-f04b-43e9-8a40-da55629861ac","creationTime":"2023-04-03T12:07:11.836335516Z","updateTime":"2023-04-03T12:07:11.836335516Z","sequence":9,"delivery_status":"delivered", "run_webhook_id":"65571310-6c65-4d5e-a76b-395b59dd71f0", "delivered_at":"2023-04-03T12:07:11.836335516Z", "status_code":200}
{"exportMeta":{"kind":"RunWebhookDelivery"},"id":"301d9c55-1737-4960-8317-2528862d370a","creationTime":"2023-04-03T12:07:16.84037838Z","updateTime":"2023-04-03T12:07:16.84037838Z","sequence":10,"delivery_status":"delivered", "run_webhook_id":"6f5d2a6c-9232-4765-b2ea-943b41f15356", "delivered_at":"2023-04-03T12:07:16.84037838Z", "status_code":200}
{"exportMeta":{"kind":"RunWebhookDelivery"},"id":"db6fbd51-e349-40e0-ba72-39c5459dbd93","creationTime":"2023-04-03T12:07:16.841367077Z","updateTime":"2023-04-03T12:07:16.841367077Z","sequence":11,"delivery_status":"delivered", "run_webhook_id":"71bff3a2-7671-4b97-889d-04b6ef9090f5", "delivered_at":"2023-04-03T12:07:16.841367077Z", "status_code":200}
{"exportMeta":{"kind":"RunWebhookDelivery"},"id":"58c5e7c5-1fad-425e-b8e5-e17fab21220c","creationTime":"2023-04-03T12:07:16.840859039Z","updateTime":"2023-04-03T12:07:16.840859039Z","sequence":12,"delivery_status":"delivered", "run_webhook_id":"79aefd75-f299-4bd8-993c-3dc4d94d97f9", "delivered_at":"2023-04-03T12:07:16.840859039Z", "status_code":200}
{"exportMeta":{"kind":"RunWebhookDelivery"},"id":"4ca49423-6c8b-40b3-91e9-4ea8183d23da","creationTime":"2023-04-03T12:07:11.836894609Z","updateTime":"2023-04-03T12:07:11.836894609Z","sequence":13,"delivery_status":"delivered", "run_webhook_id":"7ee51f5e-5621-405b-a6f9-3fca65f168ee", "delivered_at":"2023-04-03T12:07:11.836894609Z", "status_code":200}
{"exportMeta":{"kind":"RunWebhookDelivery"},"id":"81a2213a-c830-4876-846e-3045337542f6","creationTime":"2023-04-03T12:07:16.838801606Z","updateTime":"2023-04-03T12:07:16.838801606Z","sequence":14,"delivery_status":"delivered", "run_webhook_id":"88d1cb99-b3be-4d40-b463-3e1991b26dd9", "delivered_at":"2023-04-03T12:07:16.838801606Z", "status_code":200}
{"exportMeta":{"kind":"RunWebhookDelivery"},"id":"e00aacd1-e9ba-4bdc-b258-6f014a975e51","creationTime":"2023-04-03T12:07:11.83768104Z","updateTime":"2023-04-03T12:07:11.83768104Z","sequence":15,"delivery_status":"delivered", "run_webhook_id":"9b68e5f8-1606-49f4-ac9f-ce8d86b0fc3c", "delivered_at":"2023-04-03T12:07:11.83768104Z", "status_code":200}
{"exportMeta":{"kind":"RunWebhookDelivery"},"id":"c2166ee0-3e75-4489-8cc1-9f8e493d2e9a","creationTime":"2023-04-03T12:07:11.837169581Z","updateTime":"2023-04-03T12:07:11.837169581Z","sequence":16,"delivery_status":"delivered", "run_webhook_id":"a3945814-5756-4485-90b8-e3b015c1a799", "delivered_at":"2023-04-03T12:07:11.837169581Z", "status_code":200}
{"exportMeta":{"kind":"RunWebhookDelivery"},"id":"d6de8ee9-574d-45da-bb69-b40c1265622b","creationTime":"2023-04-03T12:07:11.836628298Z","updateTime":"2023-04-03T12:07:11.836628298Z","sequence":17,"delivery_status":"delivered", "run_webhook_id":"c2fbf754-f314-43bb-8163-1b4ada575441", "delivered_at":"2023-04-03T12:07:11.836628298Z", "status_code":200}
{"exportMeta":{"kind":"RunWebhookDelivery"},"id":"b7c6f5eb-539c-4616-909c-00fea5f7f713","creationTime":"2023-04-03T12:07:16.839654667Z","updateTime":"2023-04-03T12:07:16.839654667Z","sequence":18,"delivery_status":"delivered", "run_webhook_id":"ce98dd37-b7fd-4d0a-a744-8e1545de3a6c", "delivered_at":"2023-04-03T12:07:16.839654667Z", "status_code":200}
{"exportMeta":{"kind":"RunWebhookDelivery"},"id":"1f2aaf7f-115b-4d31-856e-470d2814bc03","creationTime":"2023-04-03T12:07:16.84108568Z","updateTime":"2023-04-03T12:07:16.84108568Z","sequence":19,"delivery_status":"delivered", "run_webhook_id":"d07ec67f-7a81-48e7-9d94-a87d29ca6ca3", "delivered_at":"2023-04-03T12:07:16.84108568Z", "status_code":200}
{"exportMeta":{"kind":"RunWebhookDelivery"},"id":"196d9e3c-6ed7-49ed-a7fc-46b07ff71903","creationTime":"2023-04-03T12:07:16.839229324Z","updateTime":"2023-04-03T12:07:16.839229324Z","sequence":20,"delivery_status":"delivered", "run_webhook_id":"ed2599f1-3cfc-4d09-afaf-934e2a4e1515", "delivered_at":"2023-04-03T12:07:16.839229324Z", "status_code":200}
{"exportMeta":{"kind":"LastRunEventSequence"},"id":"891f133f-ad98-431d-bed6-6e0db7ab0dd4","creationTime":"2023-04-03T12:07:11.837436311Z","updateTime":"2023-04-03T12:07:11.837436311Z","value":20}
Copy link
Member

Choose a reason for hiding this comment

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

Why the ids of these entries has been changed?

Comment on lines +21 to +41
{"exportMeta":{"kind":"RunWebhookDelivery"},"id":"2e7d8e4f-6614-495f-b5f5-7a3a589c4ee1","creationTime":"2023-04-03T12:07:11.837436311Z","updateTime":"2023-04-03T12:07:11.837436311Z","sequence":1,"delivery_status":"delivered", "run_webhook_id":"0f324898-442d-477c-93df-eb2229b3f922", "delivered_at":"2023-04-03T12:07:11.837436311Z", "status_code":200}
{"exportMeta":{"kind":"RunWebhookDelivery"},"id":"960ba478-b117-490e-9ae2-cb19b8d081e2","creationTime":"2023-04-03T12:07:16.840625135Z","updateTime":"2023-04-03T12:07:16.840625135Z","sequence":2,"delivery_status":"delivered", "run_webhook_id":"11016652-3c7a-4519-9fbf-7422d7c8cbc1", "delivered_at":"2023-04-03T12:07:16.840625135Z", "status_code":200}
{"exportMeta":{"kind":"RunWebhookDelivery"},"id":"2934275f-160c-468c-9c76-b50a411a9712","creationTime":"2023-04-03T12:07:11.835348076Z","updateTime":"2023-04-03T12:07:11.835348076Z","sequence":3,"delivery_status":"delivered", "run_webhook_id":"21a3b09b-f30f-4167-9e1b-516217af58d0", "delivered_at":"2023-04-03T12:07:11.835348076Z", "status_code":200}
{"exportMeta":{"kind":"RunWebhookDelivery"},"id":"2393e6d9-4d43-4078-a2e5-2cfedccb014e","creationTime":"2023-04-03T12:07:11.834466379Z","updateTime":"2023-04-03T12:07:11.834466379Z","sequence":4,"delivery_status":"delivered", "run_webhook_id":"30590789-e1fd-44c5-9cfc-6854ebb8110d", "delivered_at":"2023-04-03T12:07:11.834466379Z", "status_code":200}
{"exportMeta":{"kind":"RunWebhookDelivery"},"id":"1108e91b-bed1-4506-9af5-bf98e9c30153","creationTime":"2023-04-03T12:07:11.835961926Z","updateTime":"2023-04-03T12:07:11.835961926Z","sequence":5,"delivery_status":"delivered", "run_webhook_id":"41bf0d4b-78e8-4ed2-9a1d-a0278c67bf89", "delivered_at":"2023-04-03T12:07:11.835961926Z", "status_code":200}
{"exportMeta":{"kind":"RunWebhookDelivery"},"id":"f13de536-59c6-4057-93d6-d97a3820cf74","creationTime":"2023-04-03T12:07:16.841611527Z","updateTime":"2023-04-03T12:07:16.841611527Z","sequence":6,"delivery_status":"delivered", "run_webhook_id":"439d278c-433e-4268-b98d-769139e83419", "delivered_at":"2023-04-03T12:07:16.841611527Z", "status_code":200}
{"exportMeta":{"kind":"RunWebhookDelivery"},"id":"78065d4d-68ac-4b26-9db1-dac584ef67db","creationTime":"2023-04-03T12:07:16.840050048Z","updateTime":"2023-04-03T12:07:16.840050048Z","sequence":7,"delivery_status":"delivered", "run_webhook_id":"4dd0ff39-8d53-4614-90a4-90ac406c73a9", "delivered_at":"2023-04-03T12:07:16.840050048Z", "status_code":200}
{"exportMeta":{"kind":"RunWebhookDelivery"},"id":"f02ad0fe-db1f-470c-8ab9-31fb82f9a534","creationTime":"2023-04-03T12:07:11.835003681Z","updateTime":"2023-04-03T12:07:11.835003681Z","sequence":8,"delivery_status":"delivered", "run_webhook_id":"4e2c3472-e6c9-4edf-a8ce-1bdeaddc5567", "delivered_at":"2023-04-03T12:07:11.835003681Z", "status_code":200}
{"exportMeta":{"kind":"RunWebhookDelivery"},"id":"375decce-f04b-43e9-8a40-da55629861ac","creationTime":"2023-04-03T12:07:11.836335516Z","updateTime":"2023-04-03T12:07:11.836335516Z","sequence":9,"delivery_status":"delivered", "run_webhook_id":"65571310-6c65-4d5e-a76b-395b59dd71f0", "delivered_at":"2023-04-03T12:07:11.836335516Z", "status_code":200}
{"exportMeta":{"kind":"RunWebhookDelivery"},"id":"301d9c55-1737-4960-8317-2528862d370a","creationTime":"2023-04-03T12:07:16.84037838Z","updateTime":"2023-04-03T12:07:16.84037838Z","sequence":10,"delivery_status":"delivered", "run_webhook_id":"6f5d2a6c-9232-4765-b2ea-943b41f15356", "delivered_at":"2023-04-03T12:07:16.84037838Z", "status_code":200}
{"exportMeta":{"kind":"RunWebhookDelivery"},"id":"db6fbd51-e349-40e0-ba72-39c5459dbd93","creationTime":"2023-04-03T12:07:16.841367077Z","updateTime":"2023-04-03T12:07:16.841367077Z","sequence":11,"delivery_status":"delivered", "run_webhook_id":"71bff3a2-7671-4b97-889d-04b6ef9090f5", "delivered_at":"2023-04-03T12:07:16.841367077Z", "status_code":200}
{"exportMeta":{"kind":"RunWebhookDelivery"},"id":"58c5e7c5-1fad-425e-b8e5-e17fab21220c","creationTime":"2023-04-03T12:07:16.840859039Z","updateTime":"2023-04-03T12:07:16.840859039Z","sequence":12,"delivery_status":"delivered", "run_webhook_id":"79aefd75-f299-4bd8-993c-3dc4d94d97f9", "delivered_at":"2023-04-03T12:07:16.840859039Z", "status_code":200}
{"exportMeta":{"kind":"RunWebhookDelivery"},"id":"4ca49423-6c8b-40b3-91e9-4ea8183d23da","creationTime":"2023-04-03T12:07:11.836894609Z","updateTime":"2023-04-03T12:07:11.836894609Z","sequence":13,"delivery_status":"delivered", "run_webhook_id":"7ee51f5e-5621-405b-a6f9-3fca65f168ee", "delivered_at":"2023-04-03T12:07:11.836894609Z", "status_code":200}
{"exportMeta":{"kind":"RunWebhookDelivery"},"id":"81a2213a-c830-4876-846e-3045337542f6","creationTime":"2023-04-03T12:07:16.838801606Z","updateTime":"2023-04-03T12:07:16.838801606Z","sequence":14,"delivery_status":"delivered", "run_webhook_id":"88d1cb99-b3be-4d40-b463-3e1991b26dd9", "delivered_at":"2023-04-03T12:07:16.838801606Z", "status_code":200}
{"exportMeta":{"kind":"RunWebhookDelivery"},"id":"e00aacd1-e9ba-4bdc-b258-6f014a975e51","creationTime":"2023-04-03T12:07:11.83768104Z","updateTime":"2023-04-03T12:07:11.83768104Z","sequence":15,"delivery_status":"delivered", "run_webhook_id":"9b68e5f8-1606-49f4-ac9f-ce8d86b0fc3c", "delivered_at":"2023-04-03T12:07:11.83768104Z", "status_code":200}
{"exportMeta":{"kind":"RunWebhookDelivery"},"id":"c2166ee0-3e75-4489-8cc1-9f8e493d2e9a","creationTime":"2023-04-03T12:07:11.837169581Z","updateTime":"2023-04-03T12:07:11.837169581Z","sequence":16,"delivery_status":"delivered", "run_webhook_id":"a3945814-5756-4485-90b8-e3b015c1a799", "delivered_at":"2023-04-03T12:07:11.837169581Z", "status_code":200}
{"exportMeta":{"kind":"RunWebhookDelivery"},"id":"d6de8ee9-574d-45da-bb69-b40c1265622b","creationTime":"2023-04-03T12:07:11.836628298Z","updateTime":"2023-04-03T12:07:11.836628298Z","sequence":17,"delivery_status":"delivered", "run_webhook_id":"c2fbf754-f314-43bb-8163-1b4ada575441", "delivered_at":"2023-04-03T12:07:11.836628298Z", "status_code":200}
{"exportMeta":{"kind":"RunWebhookDelivery"},"id":"b7c6f5eb-539c-4616-909c-00fea5f7f713","creationTime":"2023-04-03T12:07:16.839654667Z","updateTime":"2023-04-03T12:07:16.839654667Z","sequence":18,"delivery_status":"delivered", "run_webhook_id":"ce98dd37-b7fd-4d0a-a744-8e1545de3a6c", "delivered_at":"2023-04-03T12:07:16.839654667Z", "status_code":200}
{"exportMeta":{"kind":"RunWebhookDelivery"},"id":"1f2aaf7f-115b-4d31-856e-470d2814bc03","creationTime":"2023-04-03T12:07:16.84108568Z","updateTime":"2023-04-03T12:07:16.84108568Z","sequence":19,"delivery_status":"delivered", "run_webhook_id":"d07ec67f-7a81-48e7-9d94-a87d29ca6ca3", "delivered_at":"2023-04-03T12:07:16.84108568Z", "status_code":200}
{"exportMeta":{"kind":"RunWebhookDelivery"},"id":"196d9e3c-6ed7-49ed-a7fc-46b07ff71903","creationTime":"2023-04-03T12:07:16.839229324Z","updateTime":"2023-04-03T12:07:16.839229324Z","sequence":20,"delivery_status":"delivered", "run_webhook_id":"ed2599f1-3cfc-4d09-afaf-934e2a4e1515", "delivered_at":"2023-04-03T12:07:16.839229324Z", "status_code":200}
{"exportMeta":{"kind":"LastRunEventSequence"},"id":"891f133f-ad98-431d-bed6-6e0db7ab0dd4","creationTime":"2023-04-03T12:07:11.837436311Z","updateTime":"2023-04-03T12:07:11.837436311Z","value":20}
Copy link
Member

Choose a reason for hiding this comment

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

There are also not needed multiple spaces in the json (but these should be cleaned in a different PR)

context := fmt.Sprintf("%s/%s/%s", n.gc.ID, project.Name, run.RunConfig.Name)

if err := gitSource.CreateCommitStatus(project.RepositoryPath, run.Run.Annotations[action.AnnotationCommitSHA], commitStatus, targetURL, description, context); err != nil {
return errors.WithStack(err)
retVal := &CommitStatus{
Copy link
Member

Choose a reason for hiding this comment

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

return &commitStatus ...

State: state,
CommitSHA: run.Run.Annotations[action.AnnotationCommitSHA],
RunCounter: run.Run.Counter,
Description: description,
Copy link
Member

Choose a reason for hiding this comment

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

Description: statusDescription(state),

rstypes "agola.io/agola/services/runservice/types"
)

func (n *NotificationService) updateCommitStatus(ctx context.Context, ev *rstypes.RunEvent) error {
var commitStatus gitsource.CommitStatus
type CommitStatus struct {
Copy link
Member

Choose a reason for hiding this comment

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

this could probably be left unexported.

add CommitStatus and CommitStatusDelivery type
@sgotti sgotti merged commit 6438214 into agola-io:master Oct 9, 2023
1 check was pending
@alessandro-sorint alessandro-sorint deleted the savecommitstatus branch October 17, 2023 07:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

notification service: save commit status and deliveries
2 participants