1 00:00:00,970 --> 00:00:03,190 We now created a new get hub repository. 2 00:00:03,250 --> 00:00:08,290 We're now going to add in a little bit of code to our GitHub repo itself to make sure that we run our 3 00:00:08,290 --> 00:00:12,730 tests anytime we create a new poll request to merge code into our master branch. 4 00:00:13,450 --> 00:00:14,680 Let's take a look at a quick diagram. 5 00:00:14,740 --> 00:00:16,040 Understand how this is going to work. 6 00:00:17,210 --> 00:00:21,190 So we're going to use a feature on GitHub called GitHub actions on GitHub. 7 00:00:21,240 --> 00:00:25,810 Anytime that you push some code Brady pull requests, all request closed. 8 00:00:25,860 --> 00:00:31,540 Any time a repositories fought in a variety of many other events occur, that's going to trigger a event 9 00:00:31,600 --> 00:00:32,950 internally inside of GitHub. 10 00:00:33,580 --> 00:00:37,740 And when I say event right here, I'm not talking about an event inside of our Kootenays cluster. 11 00:00:37,990 --> 00:00:40,390 I'm talking about an event on GitHub itself. 12 00:00:41,080 --> 00:00:46,420 Whenever one of these events occurs, we can optionally run it, get hub action, a GitHub action as 13 00:00:46,420 --> 00:00:47,170 a little script. 14 00:00:47,530 --> 00:00:52,390 We can put any code inside that script that we want to somehow run commands, run our tests, deploy 15 00:00:52,390 --> 00:00:52,810 our app. 16 00:00:53,140 --> 00:00:55,120 We can do just about anything you can imagine. 17 00:00:55,960 --> 00:01:00,820 So we're going to create a GitHub action that is going to trigger anytime that we create a pull request 18 00:01:00,850 --> 00:01:02,650 to merge into the master branch. 19 00:01:03,220 --> 00:01:07,840 We're also going to make sure that this GitHub action is going to run anytime that we update that Pullo 20 00:01:07,840 --> 00:01:11,090 request as well inside of our GitHub action. 21 00:01:11,320 --> 00:01:15,370 We're going to write out some code to take a look at each of our individual services and run the tests 22 00:01:15,400 --> 00:01:15,910 inside them. 23 00:01:16,780 --> 00:01:21,910 If any of those tests fail for any reason, we're then going to be told on the pull request that we 24 00:01:21,910 --> 00:01:25,000 have created that something is wrong with our code and that we need to fix it. 25 00:01:26,130 --> 00:01:30,870 Now, if you want to read more about GitHub actions on your own, you can take a look at the official 26 00:01:31,140 --> 00:01:37,400 help page on GitHub and help get hub dot com slash, even if you're going for English slash actions. 27 00:01:38,070 --> 00:01:41,070 And you can read a lot of documentation about it, have actions and how they work. 28 00:01:41,970 --> 00:01:45,850 One of the most popular pages you're going to want to read, or most important, I should say, is events 29 00:01:45,850 --> 00:01:50,680 that trigger workflows and this will tell you about all the different things that can occur inside of 30 00:01:50,680 --> 00:01:51,070 GitHub. 31 00:01:51,310 --> 00:01:55,540 That is going to trigger a get hub action or essentially run one these scripts are going to put together. 32 00:01:57,200 --> 00:01:57,390 OK. 33 00:01:57,440 --> 00:01:59,270 So let's put our first script together right now. 34 00:01:59,870 --> 00:02:02,630 Back over on a repository on the very top ago. 35 00:02:02,720 --> 00:02:04,730 Going to go to the tab that says actions. 36 00:02:06,910 --> 00:02:11,030 We then get prompted with a couple of different options here, we can either make use of one that's 37 00:02:11,030 --> 00:02:12,380 already been put together for us. 38 00:02:12,620 --> 00:02:17,780 We're going to write our own from scratch, trying to find simple workflow and just it set up this workflow. 39 00:02:18,470 --> 00:02:22,190 If you do not see something that says simple workflow or something like that, no problem. 40 00:02:22,220 --> 00:02:26,120 You can click on any of the existing workflows on there, just on any of them. 41 00:02:26,180 --> 00:02:26,900 Just hit setup. 42 00:02:27,320 --> 00:02:28,790 You'll be taken to a page like this. 43 00:02:29,180 --> 00:02:32,090 And once here, we're going to highlight everything and delete it. 44 00:02:32,430 --> 00:02:35,390 So, again, it doesn't really matter which of those starting points to use. 45 00:02:35,780 --> 00:02:38,390 Just click on any of them and delete everything inside this file. 46 00:02:39,610 --> 00:02:42,940 The first we're going to do here is rename the file that we are creating. 47 00:02:43,750 --> 00:02:44,850 We're going to rename this too. 48 00:02:45,400 --> 00:02:46,070 S dot. 49 00:02:46,120 --> 00:02:48,520 Yamal because it's going to run the tests inside of our project. 50 00:02:49,760 --> 00:02:53,960 Now, inside this Ed, right here, we are going to write out some amount of code that's going to configure 51 00:02:53,960 --> 00:02:56,000 this GitHub action in particular. 52 00:02:56,030 --> 00:03:00,140 We're going to write out some configuration that says when we want to run this action, then we're going 53 00:03:00,140 --> 00:03:03,590 to also write out the script that is actually going to run our tests. 54 00:03:04,450 --> 00:03:08,300 So in general, there's going to be a little bit of just copy paste writing out what I write. 55 00:03:08,600 --> 00:03:09,860 It's a special little syntax. 56 00:03:09,890 --> 00:03:10,930 It is YAML technically. 57 00:03:10,970 --> 00:03:14,690 But the actual options we write in here is just something you're going to learn over time. 58 00:03:15,380 --> 00:03:19,250 The first day I'm going to do is provide a name for this workflow or this GitHub action. 59 00:03:19,880 --> 00:03:23,210 I'm going to call it tests just to mirror the name of the file. 60 00:03:25,570 --> 00:03:26,770 They're going to put in here. 61 00:03:28,360 --> 00:03:30,810 And this autocomplete is really running me through a loop. 62 00:03:31,020 --> 00:03:31,500 There we go. 63 00:03:32,070 --> 00:03:36,660 We're gonna put in on this on section is going to determine when we are going to run this workflow. 64 00:03:37,260 --> 00:03:39,840 So this would be where we configure, say, let's run this. 65 00:03:39,870 --> 00:03:45,120 You get hub action whenever code is pushed or pull request created or so on, or you and I, we want 66 00:03:45,120 --> 00:03:46,800 to run this workflow. 67 00:03:47,160 --> 00:03:52,020 Anytime a pull request is created, they're going to put in pull request like so. 68 00:03:52,230 --> 00:03:52,710 And that's it. 69 00:03:53,340 --> 00:03:57,420 Now, technically, by putting in a play request right here, we're going to trigger this workflow more 70 00:03:57,510 --> 00:03:57,990 often. 71 00:03:58,210 --> 00:04:02,290 And if we just create a play request, we put in a play request by itself. 72 00:04:02,550 --> 00:04:06,630 We can go back over this documentation page or events that trigger workflows. 73 00:04:08,010 --> 00:04:10,150 I going to search on here for PLR requests. 74 00:04:11,710 --> 00:04:12,250 And there we go. 75 00:04:13,120 --> 00:04:13,680 So we right out. 76 00:04:13,700 --> 00:04:19,490 Just pull request by itself, then technically this workflow is going to run anytime that a player request 77 00:04:19,490 --> 00:04:24,380 is created or updated or re-opened by just running a play request. 78 00:04:24,470 --> 00:04:27,410 That is going to determine when we run the script. 79 00:04:29,830 --> 00:04:33,250 After that section, they're going to put in a jobs. 80 00:04:35,150 --> 00:04:36,110 Then built. 81 00:04:38,490 --> 00:04:41,220 And this autocomplete, again, is really here stating. 82 00:04:42,280 --> 00:04:48,030 Inside this built section, we're going to write out runs on the wound to latest. 83 00:04:49,780 --> 00:04:51,980 Are they going to put in a step section? 84 00:04:53,220 --> 00:04:55,440 Inside of here, we're going to write out uses. 85 00:04:56,730 --> 00:05:01,170 And then actions slash checkout's at the two. 86 00:05:02,270 --> 00:05:06,350 So this job section right here is going to define some number of things that we want to do. 87 00:05:06,470 --> 00:05:13,010 Whenever a pull request is created, reopened or updated in particular, we want to start up some kind 88 00:05:13,010 --> 00:05:15,140 of virtual machine or really it is a container. 89 00:05:16,160 --> 00:05:21,350 We are going to be running on the Ubuntu operating system, and the first thing we want to do inside 90 00:05:21,350 --> 00:05:24,050 of our little script is take all the code out of our project. 91 00:05:24,110 --> 00:05:24,890 That's what this uses. 92 00:05:24,890 --> 00:05:25,480 Step right here. 93 00:05:25,490 --> 00:05:25,940 Does. 94 00:05:27,130 --> 00:05:30,820 We're then going to set up a series of commands to run inside of our project. 95 00:05:31,490 --> 00:05:34,360 So I got to put in another Ouray entry here and say run. 96 00:05:34,950 --> 00:05:40,930 And then I'm going to put in a command that is going to run all the tests inside of just my off service. 97 00:05:41,170 --> 00:05:42,940 We'll start out with just the odd service for right now. 98 00:05:43,930 --> 00:05:47,260 Inside, if you're going to put in c.D into the off directory. 99 00:05:49,400 --> 00:05:54,980 And install all the dependencies inside there and run all of our tests. 100 00:05:55,310 --> 00:05:56,450 And remember to run our tests. 101 00:05:56,480 --> 00:05:58,400 We put in NPM run test. 102 00:05:59,280 --> 00:06:00,260 Now there's a little gotcha. 103 00:06:00,290 --> 00:06:02,030 We cannot just run our tests directly. 104 00:06:02,450 --> 00:06:03,500 I'll tell you why in just a moment. 105 00:06:03,530 --> 00:06:08,270 So we're going to slightly massage that command and change it to npm run test well in S.I. 106 00:06:09,570 --> 00:06:09,990 And that is it. 107 00:06:10,020 --> 00:06:11,310 That's all we're going to do for right now. 108 00:06:12,860 --> 00:06:16,550 Now, the syntax here and understanding what's going on is just a little bit confusing. 109 00:06:16,580 --> 00:06:20,660 This is one of those things where once you see it in action, it really is going to make a lot more 110 00:06:20,660 --> 00:06:21,120 sense. 111 00:06:22,490 --> 00:06:23,540 The changes we have made here. 112 00:06:24,600 --> 00:06:29,850 It's going to make sure that whenever we create updates or re-open a pull request, we are going to 113 00:06:29,850 --> 00:06:33,990 install dependencies into our off project and run this script inside there. 114 00:06:34,830 --> 00:06:36,570 Right now, let's just commit this file. 115 00:06:36,630 --> 00:06:37,950 Let's save it as is. 116 00:06:38,340 --> 00:06:41,520 We're then going to create a new branch inside of our local get repository. 117 00:06:41,850 --> 00:06:47,820 Push it up to this GitHub repo, open a pull request and then just see what happens on the top Right-Hand 118 00:06:47,870 --> 00:06:48,100 side. 119 00:06:48,140 --> 00:06:50,940 I got to find the start commit button and then I'll click on it. 120 00:06:50,940 --> 00:06:51,930 Commit new file. 121 00:06:54,250 --> 00:06:58,870 OK, so we've now created a GitHub action by creating that file and putting a little bit of configuration 122 00:06:58,870 --> 00:06:59,170 in there. 123 00:06:59,920 --> 00:07:00,520 Let's take a pause. 124 00:07:00,520 --> 00:07:01,780 Here we come back the next video. 125 00:07:01,780 --> 00:07:05,470 We're going to make a very small change to our auth project on a branch. 126 00:07:05,800 --> 00:07:07,390 We're then going to commit that do all that stuff. 127 00:07:07,390 --> 00:07:09,140 We just discussed the quick pause. 128 00:07:09,200 --> 00:07:10,420 I'll see you in just a minute.