We are all done with our Google Cloud configuration.
So the next thing we need to do is add in some stuff to log in to our Docker CLI inside of our Travis
YAML file.
We've gone through this process before, and it's going to look identical to what we had previously
done.
So inside of my Travis dot YAML file, I'm going to add in another line to my before install script.
I'm going to say echo dollar sign docker password.
And then I'll pipe that into docker login.
Dash you another double set of quotes with dollar sign docker username, and I'll specify that the password
for this login will come from standard in like so.
And this is a command we've ran before.
Remember we're making use of the Docker login command.
We have access to Docker because we specified it as a service inside of our YAML file.
Running login.
And we're specifying the username right here.
And then we're saying that the password will be emitted over standard in into this command.
And we make sure that happens by echoing Docker password ahead of time.
And this assumes that we've already set up environment variables of Docker username and password on
our Travis dashboard.
We did that in the past, but we did it on a different project.
So we have to go through the same process again for the new project that we just linked up to Travis.
So to do so, I'm going to open up my Travis dashboard again.
I'm going to make sure that I'm inside of the multi project.
This is the same one that we created a couple of videos ago.
I'll go to more options on the right hand side and then go to settings.
Then inside of here I can scroll on down to Environment Variables.
And you'll notice that we've already got some encrypted variables right here.
These are tied to the encrypted service account JSON file that we set up just a couple of videos ago.
So we definitely don't want to touch these at all.
Now as a quick side note, by the way, you might only see two keys inside of here, or two values I
have for the only reason you have two is because I actually recorded that session more than one time,
and I set up these encryption things more than one time.
So that's why I have four in here and you probably only have two.
All right.
So we're going to enter in two new key value pairs for our Docker password and our Docker username.
So I'm going to enter in Docker username and then my Docker ID.
Now please remember to double check your spelling on Docker username right here.
Bar none.
The most common mistake that I see in projects that people make is they change the spelling of the environment
ID right here, or the key for the environment variable, and they don't make it identical to whatever
they put inside of the Travis dot YAML file.
So please check your spelling on that thing.
Make sure that it is identical to whatever you put inside the Travis YAML file.
So then I'll add that.
And then I'll do the same thing for my Docker password as well.
And once again, please double check your spelling on Docker password.
Make sure it is identical to whatever you put over here inside the YAML file.
And then I'm going to get my password here very quickly.
I'm going to copy it off a second screen.
And I'm going to pull this tab onto my second screen very quickly and just enter my password over there,
because as much as I love you all and trust you all, I don't really want you to have my password.
Okay, so I've got my password and my username safely encrypted inside of Travis, and I'm using those
to log into the Docker CLI right here.
So now that we are logged in, the next thing we have to do is build our test version of the Multi-client
image and then run our tests inside of it.
Now this these are two steps we've gone through before as well.
So we'll go through these rather quickly.
So back inside my Travis YAML file I'm going to first build my image.
So I'll do docker build T I'll tag it with essentially a temporary tag of react test.
And I'm going to specify the docker file to use for this with dash f.
Remember we need to provide the relative path to our Docker file.
And that docker file is nested inside of the client directory.
So for dash f I'm going to say dot slash client Docker file.dev.
We specifically want the development version, because only the development version of the docker file
has all the dependencies required to actually run our tests.
And then after that, we'll also specify the build context on the very end.
The build context is the client directory.
So make sure you get the dash f for the docker file and then the build context on the end.
All right.
So after that we're all done with our B4 install section.
So now we're going to define our script section which is going to define how to run the actual tests
for our project.
So our test script is going to be identical to the one we had done previously.
We'll say docker run your Docker ID.
And we're going to specify the image that we just built a second ago.
So the name of that image is react test.
And then I'm going to override the default startup command.
And I'm going to instead run the command to run our tests inside there which is npm run test.
And remember we have to do that little trick of dash, dash, dash dash coverage like so, because by
default npm test is going to enter a watch mode that's never going to exit, and it will not allow Travis
to actually get any feedback from all this stuff.
So by adding on the dash dash with dash dash coverage, it's going to print out a coverage report,
which is going to give Travis a signal that either everything ran successfully or it crashed for some
reason.
Okay.
So that's it for the scripts section.
So we now have our tests running successfully.
Now, as a reminder, we don't actually care about these tests one bit.
They make no difference to our project.
Again I just wanted you to have a reference example right here and understand how you will run your
tests on your own personal project.
So on your personal project, you'll replace this with whatever command you need to run to execute tests
for your project.
And of course, if you're running React Project as well, you'll probably end up doing something similar.
All right, so let's take a quick pause right here.
When we come back to the next section, we're going to start to run a script that's going to deploy
all of the latest images of our project.
So quick pause and I'll see you in just a minute.