konstantin krivlenia - "continuous integration for frontend"

Post on 21-Jan-2018

211 Views

Category:

Technology

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

goo.gl/2fXwj1

git pull origin master

Как избежатьnpm test

/ci/cool-module.js:3

return myCoolFunction();

^

ReferenceError: myCoolFunction is not defined

...

01.

02.

03.

04.

05.

const coolModule = require('../cool-module')

const assert = require('assert')

describe('test cool module', () => {

it(`Answer to the Ultimate Question of Life,

the Universe, and Everything`, () => {

assert.equal(42, coolModule.doSomething())

})

})

error no-tabs

error

Как избежатьnpm run lint

/ci/cool-module.js

6:2 Unexpected tab character

6:3 Expected indentation of 4 spaces but found 2 tabs

✖ 2 problems (2 errors, 0 warnings)

01.

02.

03.

04.

Размер сборкиИмя файла Размер до Размер после

bundle.js 72.1 kB 340 kB

Измененияconst $ = require('jquery');

$('someId').hide();

01.

02.

Как избежатьnpm run check-file-size

Size of bundle is huge. Expected 100 but actual 102

Git Hooks.git/pre-commit

npm test

npm run lint

npm run check-file-size

01.

02.

03.

nlf/precommit-hook...

"pre-commit": ["lint", "test"]

01.

02.

Отключаем pre-commit hookgit commit --no-verify -m "Я знаю, что я делаю"

Setup CI.travis.yml

language: node_js

node_js:

- "6"

script:

npm run travis

.package.json

{

"scripts": {

"travis": "npm run test && npm run lint && npm run check…"

}

...

env:

matrix:

- TEST_TYPE=test

- TEST_TYPE=lint

- TEST_TYPE=size

script:

- |

if [ "$TEST_TYPE" = test ]; then

npm test

elif [ "$TEST_TYPE" = size ]; then

npm run check-file-size

elif [ "$TEST_TYPE" = lint ]; then

npm run lint

Jenkins

pipeline {

agent {

dockerfile {

filename 'Dockerfile'

}

}

stages {

stage('build') {

steps {

sh 'npm install'

}

}

...

}

docker run -d --name jenkins -p

8080:8080 -v $PWD/jenkins:/var/jenkins_home

-v /var/run/docker.sock:/var/run/docker.sock

-t logimethods/blueocean

Другие CI• https://concourse.ci

• https://circleci.com

• teamcity

Бенефиты

Раннее выявлениебагов

Избежание затяжныхрелизов

Артефакты сборок

Прививаниедисциплины в

команде

Один шаг к непрерывнойдоставке

Снятие метрик длякода

Покрытие кода

Сложность кода

Недостатки

Настройка системы

Не всегда отображаетреальную ситуацию

Долгий отклик

Нестабильностьсистемы

Не информативность

Вопросы?

top related