軟體工程筆記, using Javasript
Linter
ESLint
http://eslint.org/
https://github.com/eslint/eslint
$ npm install eslint -g
(x) or npm install eslint --save-dev
(o)$ cd project-folder
$ eslint --init
Editor package name
Sublime
SublimeLinter
SublimeLinter-contrib-eslint
VS Code
ESLint
My Config
|
|
Style References
https://github.com/feross/standard
https://github.com/airbnb/javascript
https://google.github.io/styleguide/jsguide.html
Unit Test
Mocha
JavaScript Test Framework
https://mochajs.org/
https://github.com/mochajs/mochanpm install mocha -g
(x) or npm install mocha --save-dev
(o)
Assertion Library
choose one
TDD+BDD
http://chaijs.com
https://github.com/chaijs/chainpm install chai --save-dev
npm install chai-as-promised --save-dev
BDD
http://shouldjs.github.io/
https://github.com/shouldjs/should.jsnpm install should --save-dev
BDD
https://github.com/Automattic/expect.js
Continuous Integration
Travis CI
|
|
Jenkins
https://jenkins.io/
https://github.com/jenkinsci/jenkins
Installing Jenkins on Ubuntu
https://wiki.jenkins-ci.org/display/JENKINS/Installing+Jenkins+on+Ubuntu
systemctl status jenkins.service
sudo systemctl start jenkins.service
sudo vim /var/lib/jenkins/secrets/initialAdminPassword
要存起來 之後就不見了
/var/log/jenkins/
Log生很快,容量超大
加入ssh key 到 github & jenkins
讓jenkins可以Clone with SSHsudo su jenkins
ssh-keygen
cat .ssh/id_rsa.pub
to github.comJenkins > Credentials > System > Global credentials (unrestricted)
選 Add Credentials
加入ssh
Proxy
可以收HTTP Request for webhook & 好看的網址sudo a2enmod proxy proxy_http
sudo systemctl restart apache2.service
cd /etc/apache2/sites-available
sudo cp 000-default.conf jenkins.conf
sudo vim jenkins.conf
sudo a2ensite jenkins.conf
|
|
Jenkins > Jenkins Location > Jenkins URL > "YOUR_JENKINS_URL" > Apply
Build On Push (need setup proxy first)
Jenkins > Manage Jenkins > Configure System > 往下拉看到GitHub > Advanced... > Manage additional GitHub actions(Convert login and password to token) -> From login and password -> 拿到persional access token之後點上面 Add GitHub Server -> Credentials輸入剛剛的token -> Apply
似乎要 uncheck “manage hooks” 不然github上的設定會不見
http://jagdeesh1009.blogspot.tw/2016/04/jenkins-github-hooks-problems.html
到github專案網址 > Settings > Integrations & services > Add service > 搜尋Jenkins (GitHub plugin) > 輸入URL(預設http://x.x.x.x/github-webhook/) > 確定
可以點進去按Test
Jenkins > Your Project > Configure > Build Triggers > 勾GitHub hook trigger for GITScm polling
現在可到專案看 GitHub Hook Log
Plugins
embeddable-build-status
https://plugins.jenkins.io/embeddable-build-status
https://wiki.jenkins-ci.org/display/JENKINS/Embeddable+Build+Status+Plugin