WEBVTT

00:01.000 --> 00:03.520
We are all done with our Google Cloud configuration.

00:03.520 --> 00:08.040
So the next thing we need to do is add in some stuff to log in to our Docker CLI inside of our Travis

00:08.160 --> 00:08.960
YAML file.

00:09.160 --> 00:12.480
We've gone through this process before, and it's going to look identical to what we had previously

00:12.480 --> 00:12.880
done.

00:13.280 --> 00:18.920
So inside of my Travis dot YAML file, I'm going to add in another line to my before install script.

00:19.200 --> 00:24.400
I'm going to say echo dollar sign docker password.

00:25.400 --> 00:28.360
And then I'll pipe that into docker login.

00:28.760 --> 00:37.880
Dash you another double set of quotes with dollar sign docker username, and I'll specify that the password

00:37.880 --> 00:41.480
for this login will come from standard in like so.

00:44.720 --> 00:46.240
And this is a command we've ran before.

00:46.240 --> 00:49.240
Remember we're making use of the Docker login command.

00:49.280 --> 00:53.600
We have access to Docker because we specified it as a service inside of our YAML file.

00:54.080 --> 00:55.160
Running login.

00:55.160 --> 00:57.760
And we're specifying the username right here.

00:57.760 --> 01:02.160
And then we're saying that the password will be emitted over standard in into this command.

01:02.200 --> 01:05.810
And we make sure that happens by echoing Docker password ahead of time.

01:06.250 --> 01:11.370
And this assumes that we've already set up environment variables of Docker username and password on

01:11.370 --> 01:12.650
our Travis dashboard.

01:13.450 --> 01:16.650
We did that in the past, but we did it on a different project.

01:16.650 --> 01:20.970
So we have to go through the same process again for the new project that we just linked up to Travis.

01:21.810 --> 01:25.010
So to do so, I'm going to open up my Travis dashboard again.

01:26.410 --> 01:29.570
I'm going to make sure that I'm inside of the multi project.

01:30.050 --> 01:32.530
This is the same one that we created a couple of videos ago.

01:33.250 --> 01:37.090
I'll go to more options on the right hand side and then go to settings.

01:38.010 --> 01:41.170
Then inside of here I can scroll on down to Environment Variables.

01:41.410 --> 01:44.530
And you'll notice that we've already got some encrypted variables right here.

01:44.610 --> 01:50.130
These are tied to the encrypted service account JSON file that we set up just a couple of videos ago.

01:50.410 --> 01:52.370
So we definitely don't want to touch these at all.

01:52.410 --> 01:58.010
Now as a quick side note, by the way, you might only see two keys inside of here, or two values I

01:58.010 --> 02:02.210
have for the only reason you have two is because I actually recorded that session more than one time,

02:02.210 --> 02:05.970
and I set up these encryption things more than one time.

02:06.010 --> 02:09.300
So that's why I have four in here and you probably only have two.

02:10.500 --> 02:10.740
All right.

02:10.740 --> 02:16.700
So we're going to enter in two new key value pairs for our Docker password and our Docker username.

02:17.060 --> 02:21.460
So I'm going to enter in Docker username and then my Docker ID.

02:23.420 --> 02:27.620
Now please remember to double check your spelling on Docker username right here.

02:27.660 --> 02:28.220
Bar none.

02:28.260 --> 02:33.900
The most common mistake that I see in projects that people make is they change the spelling of the environment

02:33.900 --> 02:39.540
ID right here, or the key for the environment variable, and they don't make it identical to whatever

02:39.540 --> 02:41.540
they put inside of the Travis dot YAML file.

02:41.580 --> 02:43.380
So please check your spelling on that thing.

02:43.420 --> 02:47.340
Make sure that it is identical to whatever you put inside the Travis YAML file.

02:48.180 --> 02:49.340
So then I'll add that.

02:50.300 --> 02:53.780
And then I'll do the same thing for my Docker password as well.

02:53.820 --> 02:56.940
And once again, please double check your spelling on Docker password.

02:56.940 --> 03:00.540
Make sure it is identical to whatever you put over here inside the YAML file.

03:01.060 --> 03:03.980
And then I'm going to get my password here very quickly.

03:05.220 --> 03:07.340
I'm going to copy it off a second screen.

03:07.660 --> 03:13.190
And I'm going to pull this tab onto my second screen very quickly and just enter my password over there,

03:13.430 --> 03:19.230
because as much as I love you all and trust you all, I don't really want you to have my password.

03:19.790 --> 03:25.950
Okay, so I've got my password and my username safely encrypted inside of Travis, and I'm using those

03:25.950 --> 03:28.110
to log into the Docker CLI right here.

03:29.070 --> 03:36.030
So now that we are logged in, the next thing we have to do is build our test version of the Multi-client

03:36.030 --> 03:38.110
image and then run our tests inside of it.

03:38.150 --> 03:41.150
Now this these are two steps we've gone through before as well.

03:41.150 --> 03:42.590
So we'll go through these rather quickly.

03:43.550 --> 03:47.510
So back inside my Travis YAML file I'm going to first build my image.

03:47.910 --> 03:55.510
So I'll do docker build T I'll tag it with essentially a temporary tag of react test.

03:55.950 --> 03:59.550
And I'm going to specify the docker file to use for this with dash f.

03:59.910 --> 04:03.750
Remember we need to provide the relative path to our Docker file.

04:03.990 --> 04:08.070
And that docker file is nested inside of the client directory.

04:09.590 --> 04:15.050
So for dash f I'm going to say dot slash client Docker file.dev.

04:15.090 --> 04:20.290
We specifically want the development version, because only the development version of the docker file

04:20.290 --> 04:23.170
has all the dependencies required to actually run our tests.

04:24.210 --> 04:27.450
And then after that, we'll also specify the build context on the very end.

04:27.650 --> 04:29.890
The build context is the client directory.

04:30.250 --> 04:34.930
So make sure you get the dash f for the docker file and then the build context on the end.

04:38.730 --> 04:39.130
All right.

04:39.130 --> 04:43.690
So after that we're all done with our B4 install section.

04:43.690 --> 04:48.730
So now we're going to define our script section which is going to define how to run the actual tests

04:48.730 --> 04:49.890
for our project.

04:50.490 --> 04:53.570
So our test script is going to be identical to the one we had done previously.

04:53.570 --> 04:56.450
We'll say docker run your Docker ID.

04:58.650 --> 05:01.570
And we're going to specify the image that we just built a second ago.

05:01.930 --> 05:04.170
So the name of that image is react test.

05:05.570 --> 05:08.850
And then I'm going to override the default startup command.

05:08.850 --> 05:13.450
And I'm going to instead run the command to run our tests inside there which is npm run test.

05:13.450 --> 05:19.340
And remember we have to do that little trick of dash, dash, dash dash coverage like so, because by

05:19.340 --> 05:24.700
default npm test is going to enter a watch mode that's never going to exit, and it will not allow Travis

05:24.740 --> 05:27.940
to actually get any feedback from all this stuff.

05:27.940 --> 05:32.540
So by adding on the dash dash with dash dash coverage, it's going to print out a coverage report,

05:32.540 --> 05:37.340
which is going to give Travis a signal that either everything ran successfully or it crashed for some

05:37.340 --> 05:37.900
reason.

05:38.700 --> 05:39.060
Okay.

05:39.100 --> 05:40.380
So that's it for the scripts section.

05:40.380 --> 05:42.780
So we now have our tests running successfully.

05:43.540 --> 05:46.460
Now, as a reminder, we don't actually care about these tests one bit.

05:46.540 --> 05:48.340
They make no difference to our project.

05:48.340 --> 05:53.180
Again I just wanted you to have a reference example right here and understand how you will run your

05:53.180 --> 05:55.020
tests on your own personal project.

05:55.020 --> 06:00.820
So on your personal project, you'll replace this with whatever command you need to run to execute tests

06:00.820 --> 06:01.780
for your project.

06:01.780 --> 06:05.740
And of course, if you're running React Project as well, you'll probably end up doing something similar.

06:06.380 --> 06:08.260
All right, so let's take a quick pause right here.

06:08.260 --> 06:12.940
When we come back to the next section, we're going to start to run a script that's going to deploy

06:12.940 --> 06:15.500
all of the latest images of our project.

06:15.500 --> 06:17.580
So quick pause and I'll see you in just a minute.
