-
Notifications
You must be signed in to change notification settings - Fork 0
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
creating new webhook for the options-automator #554
Conversation
blocks: failedBlock, | ||
channel: FEED_OPTIONS_AUTOMATOR_CHANNEL_ID, | ||
unfurl_links: false, | ||
}); |
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.
CI tests are yelling bc it says it needs text, but
export interface ChatPostMessageArguments extends WebAPICallOptions, TokenOverridable {
channel: string;
text?: string;
as_user?: boolean;
attachments?: MessageAttachment[];
blocks?: (KnownBlock | Block)[];
icon_emoji?: string;
icon_url?: string;
metadata?: MessageMetadata;
link_names?: boolean;
mrkdwn?: boolean;
parse?: 'full' | 'none';
reply_broadcast?: boolean;
thread_ts?: string;
unfurl_links?: boolean;
unfurl_media?: boolean;
username?: string;
}
Shows that its not necessary, confused
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.
Verify which version of the module you're getting w/ Yarn. It's not showing the ?
in the CI window so you may be tethered to an older version where that wasn't optional.
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.
Looks like we'd need to bump slack/web-api
for this to pick up text as optional parameter:
https://github.com/slackapi/node-slack-sdk/releases/tag/%40slack%2Fweb-api%406.2.0
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.
I faintly recall needing to set text but it being ignored and just the blocks were shown.
]; | ||
|
||
try { | ||
// @ts-ignore |
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 here bc CI tests are yelling?
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.
yeah pretty much
src/blocks/slackBlocks.ts
Outdated
export function section(block: MrkdwnElement): KnownBlock { | ||
return { | ||
type: 'section', | ||
text: block, | ||
}; | ||
} | ||
|
||
export function SectionBlock(fields: MrkdwnElement[]): KnownBlock { |
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 be good to add this to the above section()
function.
export function section(block: MrkdwnElement, fields: MrkdownElement[])
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.
since section is already being used by other functions rewriting it is probably out of scope, spoke with Hubert and trying to make either parameter optional just makes the code too messy and unreadable, so I'm going to keep it as two functions
blocks: failedBlock, | ||
channel: FEED_OPTIONS_AUTOMATOR_CHANNEL_ID, | ||
unfurl_links: false, | ||
}); |
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.
I faintly recall needing to set text but it being ignored and just the blocks were shown.
src/config/index.ts
Outdated
@@ -24,6 +24,8 @@ export const GOCD_ORIGIN = | |||
process.env.GOCD_ORIGIN || 'https://deploy.getsentry.net'; | |||
export const FEED_DEPLOY_CHANNEL_ID = | |||
process.env.FEED_DEPLOY_CHANNEL_ID || 'C051ED5GLN4'; | |||
export const FEED_OPTIONS_AUTOMATOR_CHANNEL_ID = | |||
process.env.FEED_OPTIONS_AUTOMATOR_CHANNEL_ID || 'C05JJ5JNZAB'; |
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.
Where did you pick this channel id?
#proj-options-automator seems to be C04URUC21C5
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 was my test channel id while I was testing locally, will correct it before merging.
src/types/index.ts
Outdated
@@ -65,7 +65,7 @@ export type CheckRun = EmitterWebhookEvent<'check_run'>['payload']['check_run']; | |||
// | |||
// Need to do this as we can't convert a string literal union to an array of literals | |||
export const CHECK_RUN_PROPERTIES = ['id', 'head_sha', 'html_url'] as const; | |||
export type CheckRunProperty = typeof CHECK_RUN_PROPERTIES[number]; | |||
export type CheckRunProperty = (typeof CHECK_RUN_PROPERTIES)[number]; |
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.
Why this change ?
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.
seems like an autoformatting change I didn't make this change
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## main #554 +/- ##
==========================================
+ Coverage 85.15% 85.34% +0.19%
==========================================
Files 98 101 +3
Lines 2445 2539 +94
Branches 479 505 +26
==========================================
+ Hits 2082 2167 +85
- Misses 357 366 +9
Partials 6 6
☔ View full report in Codecov by Sentry. |
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.
lot of codecov warnings, perhaps this could use more coverage?
], | ||
"unregistered_options": [], | ||
"invalid_type_options": [] | ||
} |
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.
nit: newline
src/blocks/slackBlocks.ts
Outdated
}; | ||
} | ||
|
||
export function section(block?: MrkdwnElement, fields?: MrkdwnElement[]): KnownBlock { |
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.
You're passing in undefined a lot to this function. I think it's a bit cleaner if an object is passed in instead, this makes it more readable, especially when this function is called.
export function section(block?: MrkdwnElement, fields?: MrkdwnElement[]): KnownBlock { | |
export function section({ block, fields }): KnownBlock { |
src/blocks/slackBlocks.ts
Outdated
fields: fields, | ||
}; | ||
} else { | ||
throw new Error('Either block or fields must be provided.'); |
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.
Feels like this error should be thrown before undefined is passed in for both block and fields here.
This is a work in progress associated with this pr . The configoptions script runs as part of a kubernetes deployment and I would like to post the logs from that script to slack.
Ideally, that linked script from sentry would send post requests to the webhook defined here, which then pushes it to slack.
todo: figure out env variables and the slack channel I'm pushing to