Add a Loom to your next pull request
Keep your development team in sync using Loom to detail the purpose behind any pull request.
Transcript
Show Transcript
Hi, I'm Clinton from the devs team in engineering. And I'm going to show how you can use loom to make a pull request.
So, Hey everyone, I've just added a new feature to shuttle our deployment system. I wanna show it off here. Now when you tell it to enable or disable our automatic deploys, it will date a slack channel's topic to reflect that.
So if I were to come in here and tell it to pause, you can now see up here, right? The channel topic has been updated.
It's right there. If I were to do it again, it's not going to keep trying to reset the channel that knows what the current one is.
Right. So great. That that's that. But if I come in here and start it again, then now it's enabled. Cool.
Let's see how this works. So bouncing over the code here there's a new shared thing here in commands. A new shared function called update repo channel with workflow status.
And this is gonna take a web client. That's what we need to talk to slack as well as some info about the repo.
That is the, the, the service that we're trying to update and the current status it's gonna look and make sure that this is a service that we have update channel that we want to update for.
And that it has a topic template. I'll show you that in a minute, how that works. But if it has those, then it's gonna get the channel ID and it's gonna set the channel topic and you can see in shuttle pause.
We now do that as well as in shuttle start and in shuttle status, we go ahead and do it as well.
Once we get that status. Cool. So let's dig in a little bit more to that because it's a little, it gets a little bit more complicated than that.
If we go down here, I have a new service to this called slack, right? We've been using that the whole time, but this is going to do things like get the channel ID for name.
This is a little hard in slack. You can't just look it up by name. You have to get a list of all the channels and look that up.
So I have a map here to cash those in to keep that around. So we don't have to keep querying it.
I'm not gonna walk through every bit of this code, but I will show you here. Basically it goes in a loop over all the different conversations found in slack until it finds the one where they match to set the channel topic.
We do some intelligent things here. The bot needs to be part of a channel before it can set the topic.
So we go ahead and find out if we're in the channel if we're in the channel or if we're not in the channel, then we'll join.
We also look to see what the current topic is. If it's the same as what we would set it to, then we just bail out there.
The last thing I wanna show about this is the templates. So I've moved all of already pull information into our constants file.
Here we are. You can see these here. And each of these has a topic template, this template it's a normal JavaScript string, but you write it like you'd write a template string and it gets evaluated later.
The two, two variables that can go into it right now are status emoji and status. We can add more if that's necessary later, but each of these, we use the same one for each of these right now.
But if I were to update this that way it would update the topic to be what we want the topic to be for that channel.
Cool. That's the whole feature. Let me know if you have any questions and thanks for taking a look at the pull request.
Transcript
Show Transcript
Hi, I'm Clinton from the devs team in engineering. And I'm going to show how you can use loom to make a pull request.
So, Hey everyone, I've just added a new feature to shuttle our deployment system. I wanna show it off here. Now when you tell it to enable or disable our automatic deploys, it will date a slack channel's topic to reflect that.
So if I were to come in here and tell it to pause, you can now see up here, right? The channel topic has been updated.
It's right there. If I were to do it again, it's not going to keep trying to reset the channel that knows what the current one is.
Right. So great. That that's that. But if I come in here and start it again, then now it's enabled. Cool.
Let's see how this works. So bouncing over the code here there's a new shared thing here in commands. A new shared function called update repo channel with workflow status.
And this is gonna take a web client. That's what we need to talk to slack as well as some info about the repo.
That is the, the, the service that we're trying to update and the current status it's gonna look and make sure that this is a service that we have update channel that we want to update for.
And that it has a topic template. I'll show you that in a minute, how that works. But if it has those, then it's gonna get the channel ID and it's gonna set the channel topic and you can see in shuttle pause.
We now do that as well as in shuttle start and in shuttle status, we go ahead and do it as well.
Once we get that status. Cool. So let's dig in a little bit more to that because it's a little, it gets a little bit more complicated than that.
If we go down here, I have a new service to this called slack, right? We've been using that the whole time, but this is going to do things like get the channel ID for name.
This is a little hard in slack. You can't just look it up by name. You have to get a list of all the channels and look that up.
So I have a map here to cash those in to keep that around. So we don't have to keep querying it.
I'm not gonna walk through every bit of this code, but I will show you here. Basically it goes in a loop over all the different conversations found in slack until it finds the one where they match to set the channel topic.
We do some intelligent things here. The bot needs to be part of a channel before it can set the topic.
So we go ahead and find out if we're in the channel if we're in the channel or if we're not in the channel, then we'll join.
We also look to see what the current topic is. If it's the same as what we would set it to, then we just bail out there.
The last thing I wanna show about this is the templates. So I've moved all of already pull information into our constants file.
Here we are. You can see these here. And each of these has a topic template, this template it's a normal JavaScript string, but you write it like you'd write a template string and it gets evaluated later.
The two, two variables that can go into it right now are status emoji and status. We can add more if that's necessary later, but each of these, we use the same one for each of these right now.
But if I were to update this that way it would update the topic to be what we want the topic to be for that channel.
Cool. That's the whole feature. Let me know if you have any questions and thanks for taking a look at the pull request.