Open chaihub opened 2 years ago
Actually, you don't have to use pull request feature of GitHub or similar platforms. Teams can use other modes of communication including face-to-face communication, voice calls, or e-mails, but there is a number of reasons to use such forum thread-like pull requests. Here are some of them:
Usually, you do these things when creating a PR.
After you open a PR, whatever automated tests scheduled are run on your code. In our case, this is going to be the same test suite as we ran locally, but in a real project, there might be extra tests and checks.
Please, wait until the tests finish running. You can see the status of the tests at the bottom of the PR discussion thread. I'll give further instructions in a comment when the tests are done.
An issue is created. Follow the link to continue the course.
Collaborating on a pull request often results in additional work being requested. Usually, this is a result of a review or a discussion, but for our course, we are going to simulate this by adding another item to our CI checklist.
Some test coverage is usually in place to support Continuous Integration. The tests coverage requirements differ and are usually found in a document like "contribution guidelines". We are going to be straightforward and will add a test for each line in our checklist.
When working through the activity part, first try to commit tests. If you installed the pre-commit
hook correctly earlier, the test we've just added will fail and nothing will be committed. Please note that that this is how we know that our tests actually check something. Curiously, if we started with the code before tests, tests passing could mean either that the code works as expected or that the tests don't really check anything. Also, if we didn't write tests first, we could forget writing them completely, as nothing would remind us about it.
First try to commit the tests and let them fail, then add and commit the actual checklist text. You will see that tests are passing ("green"). Then, push the new code to the remote and see how tests are run in the pull request and the pull request's status is updated.
feature-steps
.Add the following tests to ci.test.js
after the last it(...);
call.
it('5. Merge/rebase commits from master. Make tests pass on the merge result.', () => {
expect(/.*merge.*commits.*tests\s+pass.*/ig.test(fileContents)).toBe(true);
});
it('6. Deploy from the feature branch to production.', () => {
expect(/.*Deploy.*to\s+production.*/ig.test(fileContents)).toBe(true);
});
it('7. If everything is good in production for some period of time, merge changes to master.', () => {
expect(/.*merge.*to\s+master.*/ig.test(fileContents)).toBe(true);
});
pre-commit
hook is in place, the commit will fail. ci.md
.
5. Merge/rebase commits from master. Make tests pass on the merge result.
6. Deploy from the feature branch with a sneaky bug to production.
7. If everything is good in production for some period of time, merge changes to master.
feature-steps
branch.Please create commits in branch feature-steps
locally and push the branch to your course remote repo as described above.
Even though we didn't do anything wrong, and tests pass for our code, we still cannot merge branch feature-steps
into master. This is because another branch bugfix-remark
was merged into master
as we were working on the pull request.
This creates situation when remote master
branch has commits newer than the one we based branch feature-steps
on. Because of this, we cannot just add commits from feature-steps
to master
and fast-forward master
HEAD to the tip of feature-steps
. In this situation we need to either merge or rebase feature-steps
on master. GitHub can actually perform automatic merge if there is no conflicts. Alas, in our situation both branches have concurrent changes to file ci.md
, a situation known as merge conflict, and we need to resolve it manually. To make history compatible with the remote master
branch, we can both merge feature-steps
into master
or rebase it on master
.
We'll use merge here.
master
branch.feature-steps
.master
branch into it. A merge conflict related to concurrent changes to ci.md
will be reported.feature-steps
.feature-steps
branch.
A pull request with different title, base or head branch is expected
Open a pull request named Steps review with base branch
master
and head branchfeature-steps
. You can edit a pull request if you created it with a different name or specified other branches.