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 core functionality #11

Merged
merged 27 commits into from
Sep 17, 2022
Merged

Implement core functionality #11

merged 27 commits into from
Sep 17, 2022

Conversation

namoscato
Copy link
Collaborator

@namoscato namoscato commented Sep 6, 2022

  • cleanup message builder patterns
  • broadcast to channel on error
  • support multiple intermediate stages
  • unit tests
  • readme / documentation
  • status CI badge
  • marketplace branding
  • update duration algorithm
  • update @dev references

@namoscato namoscato marked this pull request as ready for review September 11, 2022 19:28
const eventLink = getEventLink()

const mrkdwn = [
status ? emojiFromStatus(status) : emoji('black_square_button'),
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't personally love the initial / in progress / "unchecked" icon:

Screen Shot 2022-09-11 at 3 22 59 PM

Perhaps we make this configurable at some point.

Choose a reason for hiding this comment

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

That'd be sweet! Big fan of using custom emojis :D

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Tracking via #13.

Comment on lines 78 to 89
const slackRegex = /[^A-Za-z]slack[^A-Za-z]/i
const lastCompletedSlackStep = data.jobs
.flatMap<CompletedJobStep>(({steps}) => {
if (!steps) {
return []
}

return steps
.filter(isCompletedJobStep)
.filter(({name}) => slackRegex.test(` ${name} `))
})
.pop()
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This won't work well with parallel jobs. Something to probably revisit in #12.

Choose a reason for hiding this comment

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

  1. So this grab the last completed slack step, regardless of what job it is?
  2. Do you think taking in the job name as an optional parameter would solve for this?

If one is yes, I'm actually a bit surprised this works. I guess the assumption here is the jobs array returned is "ordered". I wonder however, if I have a job in the middle of my workflow but it runs last, would that break this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

So this grab the last completed slack step, regardless of what job it is?

Correct.

In a sequential workflow (in which jobs depend on each other), this seems to work fine; the listJobsForWorkflowRun response does not return jobs that have not yet started.

Do you think taking in the job name as an optional parameter would solve for this?

Do you mean an optional input specifying the previous / dependent job name? We inherently know which job we are currently in, but we actually need to know which previous job / step to compute duration.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Having given this some more thought, I am leaning towards scoping "stage" duration to its contextual job. We'll still want to support multiple Slack steps per job, but I now see less value in computing this across jobs, especially given the threaded message displays the job's name.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated in c6eb5f9.

It still favors a lastCompletedSlackStep but scoped within the current job, which still allows for scenarios in which multiple slack notifications can be sent within the same job, i.e.

steps:
- name: Post to Slack
- name: Deploy to staging
- name: Post to Slack
- name: Deploy to prod
- name: Post to Slack

Copy link

@johnkoehn johnkoehn left a comment

Choose a reason for hiding this comment

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

This is awesome!

Left a couple questions around last completed

.github/workflows/ci.yml Outdated Show resolved Hide resolved
src/slack/mrkdwn.ts Show resolved Hide resolved
Comment on lines 78 to 89
const slackRegex = /[^A-Za-z]slack[^A-Za-z]/i
const lastCompletedSlackStep = data.jobs
.flatMap<CompletedJobStep>(({steps}) => {
if (!steps) {
return []
}

return steps
.filter(isCompletedJobStep)
.filter(({name}) => slackRegex.test(` ${name} `))
})
.pop()

Choose a reason for hiding this comment

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

  1. So this grab the last completed slack step, regardless of what job it is?
  2. Do you think taking in the job name as an optional parameter would solve for this?

If one is yes, I'm actually a bit surprised this works. I guess the assumption here is the jobs array returned is "ordered". I wonder however, if I have a job in the middle of my workflow but it runs last, would that break this?

const eventLink = getEventLink()

const mrkdwn = [
status ? emojiFromStatus(status) : emoji('black_square_button'),

Choose a reason for hiding this comment

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

That'd be sweet! Big fan of using custom emojis :D

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.

2 participants