hussainmuzzamil / continuous-integration-team-scenarios Goto Github PK
View Code? Open in Web Editor NEWHome Page: https://lab.github.com/ntaranov/common-continuous-integration-team-scenarios
Home Page: https://lab.github.com/ntaranov/common-continuous-integration-team-scenarios
During the course, you'll practice common continuous integration actions. The course isn't intended to be a click-through wizard-style experience, instead you'll do what developers do during their daily work the way they do it. I'll explain the theory as you reach relevant steps.
As we progress, we will incrementally build a memo with a common CI steps sequence, which is a great way to memorize it. In other words, we will make the list of actions which developers take doing CI doing CI. You can always see current list using the GitHub's ability to render Markdown.
We'll also use some simple test suite to mimic actual CI process.
To complete the course you will need Node.js and a Git client installed. You can use whatever Git client you prefer, but I will provide reference solutions for command line only.
If you don't have a command line client yet, you can find the installation instructions here.
By the way, I will use such collapsible sections like this to provide extra information during the course.
Even though the best way to complete this course is doing everything by your own hands, you potentially might find yourself in trouble.
If you feel, you don't understand what to do and cannot continue, you can refer to solution
branch included in your starting repository. Please, don't merge solution
into master
during the course. You can use the branch to figure out what you need to do, or to compare your code with the reference implementation using all the capabilities Git provides. If you feel completely lost, you can replace your master
branch commits with solution
commits entirely and then reset your working directory to whatever step of the course you desire.
git add .
git commit -m "Backing up my work"
The following commands
git branch -m master master-backup
git branch -m solution master
git checkout master -f
git branch solution
After performing these actions, you can use git log master
to figure out what commit you need.
Then you can reset your working directory to it using
git reset --hard <the SHA you need>
If you are happy with the result, eventually you might want to push the remote. Don't forget to update the remote branch accordingly when you push.
git push --force origin master
Please, note that we use git push --force
. You will rarely ever want to force push to a remote's master, but here we have very specific scenario with only one collaborator who knows what he is doing.
Continuous integration, or CI, is a technical practice when each member of a team integrates their code at least once a day so that the resulting code at least builds without errors.
Another point is that C++ in not the only language used in development for a long time, and just building without errors is a very weak validation requirement. Some set of tests (e.g. unit tests run on a local computer) should be required to pass. Currently, community seems to gravitate towards such requirement, and in the future "build + units tests" will likely be the mainstream, if not already.
Continuous integration is different from continuous deployment or continuous delivery (CD) in that we are not required to have a release candidate after each integration cycle.
master
. Start working.Make sure that GitHub actions are enabled for the course repository. If actions are not enabled, please enable them clicking the button in middle of the screen under the Actions GitHub UI tab. If they are not enabled, automatic tests will not run in pull requests, and you will not be able to complete the course.
Let's start composing our CI steps list. You would commonly start this step with pulling the latest code from the remote repository, but we don't have a local repository set up yet, so we clone it instead.
master
, start workinghttps://github.com/hussainmuzzamil/continuous-integration-team-scenarios
.npm install
in the course repository's directory; we need it to install Jest which we use to run tests.feature-steps
. Check out the branch.ci.test.js
between the comments asking to do so. it('1. pull latest code', () => {
expect(/.*pull.*/ig.test(fileContents)).toBe(true);
});
it('2. add commits', () => {
expect(/.*commit.*/ig.test(fileContents)).toBe(true);
});
it('3. push to the remote branch with the same name', () => {
expect(/.*push.*/ig.test(fileContents)).toBe(true);
});
it('4. open a pull request and continue working', () => {
expect(/.*pull\s+request.*/ig.test(fileContents)).toBe(true);
});
1. Pull in the latest code. Create a branch from `master`. Start working.
2. Create commits on your new branch. Build and test locally.
Pass? Go to the next step. Fail? Fix errors or tests and try again.
3. Push to your remote repository or remote branch.
4. Open a pull request. Discuss the changes, add more commits
as discussion continues. Make tests pass on the feature branch.
# Clone the course repository
git clone https://github.com/hussainmuzzamil/continuous-integration-team-scenarios
cd continuous-integration-team-scenarios
# Run npm install in the course repository's directory; we need it to install Jest which we use to run tests.
npm install
# Create a branch and name it feature-steps. Check out the branch.
git checkout -b feature-steps
# Edit ci.test.js as described above
# Edit ci.md as described above
We are going to set up tests to run on commit and then commit the code.
Locally:
On the build server or build environment:
master
) is tested.Generally, the less time it takes to run a test suite, the more often you can afford to run it. Common arrangement might look like this.
I suggest first running tests manually using npm test
command. After, let's add a git hook to run our tests on commit. There is a catch, Git hooks are not considered a part of repository and thus cannot be cloned from GitHub with the rest of the course materials. To install the hook, you'll need to run install_hook.sh
or copy file repo/hooks/pre-commit
into your local .git/hooks/
directory.
When you commit, you'll see test running and checking if certain keywords are present in the list.
npm test
command in your course repository folder. Make sure test run.install_hook.sh
.# Install the pre-commit hook executing install_hook.sh.
# Commit changes to local repository. Use "Add first CI steps" as the commit message.
git add ci.md ci.test.js
git commit -m "Add first CI steps"
# Make sure the tests run before the commit.
After doing work locally, developers usually make their work publicly available so that it could be eventually merged into a shared codebase. Using GitHub, it's either done publishing the work to a personal fork or a branch.
master
branch "protected". In this scenario individual developers push their work into the remote's branches so that it could be reviewed and, if everything is good, merged to the remote's master
.In this specific course, we will use the branch-based workflow as it's currently supported by the GitHub Labs engine.
Let's now publish our work.
git push --set-upstream origin feature-steps
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.