This workshop will be retired on May 1, 2025.
Heads up! To view this whole video, sign in with your Courses Plus account or enroll in your free 7-day trial. Sign In Enroll
Well done!
You have completed Continuous Integration with Java using Travis CI!
Preview
Video Player
00:00
00:00
00:00
- 2x 2x
- 1.75x 1.75x
- 1.5x 1.5x
- 1.25x 1.25x
- 1.1x 1.1x
- 1x 1x
- 0.75x 0.75x
- 0.5x 0.5x
Let's walk through how it feels to develop within a CI environment
Make Your Voice Heard
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
All right so our awesome application,
our calculator.
0:00
Somebody figured something
out that's broken.
0:03
If you try to divide 7 by 2, you don't
get a remainder, you don't get a floating
0:06
point, and we want to you know we'd
want to have that returned 3.5.
0:10
What people are finding
it's returning three, and
0:15
that is because let's take a look
really quick at this code here.
0:17
So open up Calculator.
0:21
When you divide 2 integers, you get
the lower half of the number there,
0:22
it should be 3.5 but we're just getting 3.
0:26
So we need to make it so that the floats
are available when you do divide, so
0:28
we can do some really
easy method overloading.
0:32
So let's use this feature going
to add a new feature that allows
0:35
division by floats.
0:39
So let's go over here I'm
gonna make a new branch and
0:40
I'm gonna call this float-on.
0:44
Okay, we got float-on.
0:48
All right, so, now we're on that branch
and we're gonna add public float divide.
0:50
And will divide(float a, float b) and
0:58
we'll just go ahead and we'll return a/b.
1:01
All right, so
1:06
like a good developer we should probably
make a little test for that right.
1:09
So flip over to our test,
I'm pretty sure this is just gonna work.
1:12
So I'm just gonna scroll this up here I'm
1:15
gonna say floatingPointDivisionWorks.
1:20
All right, so we want to say float
1:25
result=calc.divide.
1:30
And we'll go ahead and do (7 ,2) so
that should return 3.5.
1:34
So we go ahead and do that.
1:39
And we will assertEquals(3.5, result).
1:42
And when you're using floats you
need to talk about precision, so
1:51
the difference the delta between the 2,
that's allowed, so we want 0 in between.
1:55
What's allowed there.
2:00
Okay, so
I'm pretty sure this is gonna work.
2:01
I'm gonna go ahead and push this up and
make a new branch as well.
2:05
So let's go ahead.
2:10
We are gonna say Adds floating point
2:12
division ,and we will go ahead and
2:18
Commit and push.
2:23
And we'll go ahead and forget the errors.
2:25
We'll say Commit, and it's gonna go to
the new, our new branch called float on.
2:28
We will push that up there and
let's go take a look.
2:34
Make sure that things
are working over here.
2:38
So if we click on branches
under the Java calculator here.
2:40
Click on these branches over here.
2:45
Now we'll see that there is a new
branch coming here called float-on.
2:47
One thing that I will though maybe we
can look at while this is running over
2:50
here is we click in here under Settings.
2:53
We can see that build pushes and
build pull requests are still happening.
2:55
You can turn this off if you wanted to,
but this pull request is important
3:01
because when you go to merge something
this is what you want to have in place.
3:05
So that the tests run
against the pull request.
3:10
We'll do that here in just a second,
assuming that these tests pass.
3:12
You know what, I am going to just
go ahead and click over the ID and
3:15
make just make sure before
I make that poll requests.
3:19
I'm gonna go ahead and
run my unit tests like we should.
3:23
So I'm gonna go ahead and
run this floating point division.
3:26
No.
3:31
So remember that method overloading
doesn't look at the result back here.
3:32
I actually ran this and
it cast it to a float.
3:36
Right, these aren't floats.
3:40
This is in a match the signatures so
I need 7.0 float and
3:41
2.0 float to make that go and now if
I run the test again that's gonna go.
3:45
Now the thing that's happening though is
my Travis CI is still running and that's
3:50
okay, I can go ahead and I can queue up
another one and it's gonna be all right.
3:55
So let's do that,
let's say that we fix this, oops.
3:58
So I'm wanna go back to my version
control here and say whoops.
4:01
Forgot about method overloading and
signatures.
4:10
All right, so I'm gonna go ahead and
4:17
commit this and
push that up to our float-on branch.
4:19
So I push OK.
4:22
So now if we come back
over here to Travis,
4:24
we take a look we'll see that there
are two builds going and number
4:28
four was created,and it's kind of waiting
and so it's right in the whoops here.
4:33
You'll see here that.
4:38
Here's what a failure looks like right so
the test failed which is good.
4:39
That's what we wanted to have happen
that same test that failed locally is
4:41
failing here.
4:44
I got an e-mail just got a buzz about it,
that we failed.
4:45
If this was attached to slacks,
people be laughing at me and
4:48
pointing, but it's not so here we go.
4:51
This is going now, this is going to pass.
4:53
I'm pretty sure about it.
4:56
So I want to do is I'm going to
flip back over to my GitHub here.
4:57
And you see that I just said you
recently pushed branches flowed
5:01
on to say compare in pull requests.
5:05
So that allows us to build
a new pull request and
5:08
I'm gonna make this to my private repo,
not the actual treehouse project.
5:11
Remember when you're doing that.
5:17
So do that.
5:19
So it does say that it's able to merge,
and what's going to happen,
5:20
let's see,
that's floating point precision and tests.
5:27
Just like a person asked for there.
5:32
So here's the port request,
that looks good.
5:36
I like the way that
everything looks there.
5:39
So I'm gonna go ahead I'm going
to create this pull request.
5:40
And you see here actually,
this shows that it had failed and
5:43
this is it that it's in process.
5:46
Pretty cool, right?
5:48
It's attached there, so
I'm gonna click Create pull request.
5:49
And it says that some
checks haven't passed.
5:53
Right, it's going ahead, it's building
the project there on the poor requests and
5:56
it would make sure that the merge is safe.
6:01
Isn't that awesome?
6:04
And if we look here and and here,
we look at the current pull requests.
6:06
We can see that the PR.
6:12
is running and that will be against
the PR that is going to make the merge.
6:14
Super cool.
6:18
So basically, while this is going here,
6:19
I want to just reiterate,
you want to try to integrate early and
6:20
integrate often and continuous integration
is a wonderful development practice.
6:25
Work together with your team and
getting it implemented and
6:29
as you can see, it's fairly easy to
get up and running and then it's so
6:32
much more powerful as things build.
6:35
And the more you get in the rhythm,
the less problems you're going to have.
6:38
You'll be able to release
your product more frequently.
6:41
That's definitely the concept
behind this pattern.
6:44
So if you'd like more workshops like this,
please let us know.
6:48
We value your feedback.
6:50
Look for instructions in the teacher's
notes on how to do that.
6:51
Thanks for hanging out, and
we'll see you very soon.
6:55
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up