-
Notifications
You must be signed in to change notification settings - Fork 77
Feat : gitlab ci support #1061
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
base: main
Are you sure you want to change the base?
Feat : gitlab ci support #1061
Conversation
Signed-off-by: madjidDer <dermelmadjid@gmail.com>
Signed-off-by: madjidDer <dermelmadjid@gmail.com>
This is super exciting! Massive props to doing comprehensive tests for this too :) |
Signed-off-by: madjidDer <dermelmadjid@gmail.com>
@ManilDf are you happy for this to be undrafted? |
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.
This is really, really fantastic folks. Thank you for spending the time to do some proper tests for this and getting this to 99% of the way.
So I just have a few minor nits, mainly that we need to support the subtypes of pipeline
so that users may filter on which kinds of pipeline event. E.g. We like to use .failed
a lot at Element because we can detect failing automations.
Otherwise, keep it up and ping me when ready!
src/Connections/GitlabRepo.ts
Outdated
const { status, ref, duration, id: pipelineId } = event.object_attributes; | ||
|
||
const statusUpper = status.toUpperCase(); | ||
if (!this.notifiedPipelines.has(pipelineId)) { |
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.
Is this likely to trigger multiple times?
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.
Thank you for your comment. You're right — the handler is currently being called multiple times due to the various statuses within a single pipeline.
To address this, we’ll create separate handlers for each pipeline sub-type (e.g., pipeline.success, pipeline.triggered). This will allow us to remove the conditional check currently in place
src/Connections/GitlabRepo.ts
Outdated
@@ -97,7 +98,8 @@ type AllowedEventsNames = | |||
| "wiki" | |||
| `wiki.${string}` | |||
| "release" | |||
| "release.created"; | |||
| "release.created" | |||
| "pipeline"; |
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.
According to the docs we have:
- pipeline.triggered \*
- pipeline.canceled \*
- pipeline.failed \*
- pipeline.success \*
so we should include these here.
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.
Alright, we’ll proceed with the update once the individual handlers have been created
src/Connections/GitlabRepo.ts
Outdated
@@ -971,6 +976,53 @@ ${data.description}`; | |||
}); | |||
} | |||
|
|||
public async onPipelineEvent(event: IGitLabWebhookPipelineEvent) { | |||
if (this.hookFilter.shouldSkip("pipeline")) { |
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.
As per docs, we should properly filter on the subtypes of pipeline.*
?
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.
Yes, it will also be updated when handlers will be created
}; | ||
object_attributes: { | ||
id: number; | ||
status: string; |
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.
Would it be possible to enumerate all the possible values of status here? E.g.
status: string; | |
status: "triggered"|"success"; |
etc etc?
tests/connections/GitlabRepoTest.ts
Outdated
|
||
expect(intent.sentEvents[1].content.body).to.include("SUCCESS"); | ||
expect(intent.sentEvents[1].content.formatted_body).to.include( | ||
'<font color="green"><b>SUCCESS</b></font>', |
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.
N.B. As per the Matrix spec we now prefer a <span>
with data-mx-color
https://spec.matrix.org/latest/client-server-api/#mroommessage-msgtypes
Hi @Half-Shot, Thank you for your encouraging feedback and for un-drafting the PR. We are thrilled to see your positive comments. @ManilDf and @madjidDer are currently occupied with other commitments but plan to address your suggestions next week. We'll notify you once the updates are ready for review. |
Co-authored-by: Will Hunt <github@half-shot.uk> Signed-off-by: Manil Diaf <152652065+ManilDf@users.noreply.github.com>
…x-org#1062) * Add warning for failing to reach HS * Update types * fixup test * tweaks * lint
…ric hooks (matrix-org#1004) * Add an option at the config and state level to disable hook bodies. * add a test * changelog * no fake requried * default to state, then config for data inclusion * default to including webhook state * allow undefined * update new config * update tests * document
…/webhook` (matrix-org#1063) * Refactor and migrate webhook paths forGitHub * changelog * begin moving Gitlab * Test both paths on GitHub * Add tests for GitLab. * Move JIRA webhook handling to router * Update docs with new webhook info. * Use /webhook for path * lint
Signed-off-by: Will Hunt <will@half-shot.uk>
We have to update the codebase when resolving the conflict to use the new |
Signed-off-by: LAKROUT Hakim <99540145+Hakim-Lakrout@users.noreply.github.com>
The docker fails are #1023 and can be ignored. Sorry about the refactor from underneath you. When the linter passes I'll do another review and merge if all good. |
|
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.
Handful of cleanup tasks
); | ||
const { ref, duration } = event.object_attributes; | ||
|
||
const contentText = `Pipeline SUCCESS on branch \`${ref}\` for project ${event.project.name} by ${event.user.username} - Duration: ${duration ?? "?"}s`; |
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.
If duration isn't present, I'd just leave it off entirely. Duration: ?s
reads a bit weird to me.
src/HookFilter.ts
Outdated
@@ -24,6 +24,7 @@ export class HookFilter<T extends string> { | |||
|
|||
public shouldSkip(...hookName: T[]) { | |||
// Should skip if all of the hook names are missing | |||
//console.log("→ shouldSkip called with", hookName, "vs", this.enabledHooks); |
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.
comment :)
<EventHookCheckbox | ||
enabledHooks={enabledHooks} | ||
hookEventName="pipeline" | ||
onChange={toggleEnabledHook} |
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.
N.B. needs to have the subcategories like "Merge requests" does above.
Remove unused type Co-authored-by: Will Hunt <github@half-shot.uk> Signed-off-by: LAKROUT Hakim <99540145+Hakim-Lakrout@users.noreply.github.com>
Fix typo Co-authored-by: Will Hunt <github@half-shot.uk> Signed-off-by: LAKROUT Hakim <99540145+Hakim-Lakrout@users.noreply.github.com>
Update current branch
Hi @Half-Shot , just following up on this pull request, do you have any updates or feedback? |
Hey sorry for the delay, I was off from work some of last week. Catching up now. |
This PR implements the integration of notifying from Gitlab pipelines when triggering and when they finished.