by Nadav Sinai,
nadav@misterbit.com
github.com/nadavsinai
June 2015
nadav@misterbit.co.il
github.com/nadavsinai
Nadav Sinai
In StartApp
CI - short for See Eye??
CD - compact disc???
Together
QA
Develop
QA
Production
0
CI
Develop
QA
Production
Git - central code repository
But integrating changes does not let you know for sure things are still working well....
How can we know changes haven't broken anything?
Code Changed
Tests Run
Developer notified
Practice of frequently integrating changed branches & mainline
An automation setup for testing code integrity done by responding to repository change events
Helps discovering bugs more quickly, somewhat incorporate the QA phase in the development process.
Allows for quick rapid deployments whilst keeping stability.
It can be extended in many ways - automatic deployment, docs generation, tests coverage reports,performance testing etc.
module.exports = function(logMessages) {
return function(req, res, next) {
if (res.statusCode && res.statusCode !== 200) {
var matchingMessageCode = _.findKey(logMessages, function (message) {
return message.httpStatus === res.statusCode;
});
if (matchingMessageCode) {
res.reportError(matchingMessageCode);
} else {
res.reportError('SA101');
}
} else {
next();
}
};
};
beforeEach(function(done){
reportErrorSpy = sinon.spy();
res = {
statusCode: 200,
reportError: reportErrorSpy
};
errorHandlerMiddleware = errorHandler(logMessagesMock);
done();
});
it('Should continue on 200 status code', function(done){
var next = sinon.spy();
errorHandlerMiddleware(req, res, next);
next.called.should.be.true;
done();
});
self.shortenTitle = function (title) {
if (title.length > maxTitleLength) {
//trim the string to the maximum length
var trimmedString = title.substr(0, maxTitleLength);
//re-trim if we are in the middle of a word
.........
};
describe('checks for shortenTitle function ', function () {
it('when title is shorter than maxLength', function () {
expect(ctrl.shortenTitle('short')).to.equal('short');
});
it('when title is longer than maxLength', function () {
expect(ctrl.shortenTitle('longlonglong')).to.equal('longl...');
});
it('when title is longer and has space to naturally trim', function () {
expect(ctrl.shortenTitle('long long long')).to.equal('long...');
});
});
script:
- grunt test
- if [ $BRANCH == "master" ]; then grunt build; fi
- if [ $BRANCH == "master" ]; then grunt test-client-production; fi
- if [ $BRANCH == "master" ]; then grunt compress:shippable_artifacts; fi
# deal with tests and coverage reports
after_script:
- mkdir -p ./shippable/testresults
- find . -maxdepth 1 -name "test-result*.xml" -exec cp {} ./shippable/testresults \;
- cd ./shippable/testresults
- python ../../app/cliscripts/merge-test-reports.py $(ls) > results.xml
# notify github of success and if in master upload artifacts
after_success:
- if [ $BRANCH == "master" ]; then sudo pip install awscli; fi
- export APP_VERSION=$(node app/cliscripts/version.js)
- export TARGET_URL=s3://s3.startapp.com/Portal/artifacts/shippable/$APP_VERSION.tar.gz
- if [ $BRANCH == "master" ]; then aws s3 cp ./portal.tar.gz $TARGET_URL --acl private; fi
- eval curl "$GITHUB_HEADER" --data '\{\"state\":\"success\",\"context\":\"ci/shippable\",\"description\":\"$APP_VERSION\"}'
-X POST https://api.github.com/repos/startappdev/portal/statuses/$COMMIT
CD
Develop
Integration
Staging
Production