sutol 2016 - automation is developer's friend
TRANSCRIPT
Automation is
developer’s friend
Martin Přádný
pristo solutions, s.r.o.
Thanks to our sponsors!
8th Sutol Conference, November 2016
Martin Přádný
• Notes/Domino– since 2000
• Java
• IBM BPM
• Sharepoint/K2 workflow
• @mpradny
• http://pradny.com
8th Sutol Conference, November 2016
Warning
• This session is:
– collection of tools that can make you more
productive and your life easier
– personal selection of tools that I like
• (at time of writing)
• This session is NOT:
– best practices session
– web development basics course
4
8th Sutol Conference, November 2016
Agenda
• Motivation
• Dev workstation
– Tools introduction
– Domino Designer integration
• CI server
– Jenkins Pipeline
– Selenium testing
5
8th Sutol Conference, November 2016
Motivation
• Dev toolbox changed
– from
• complex, big
• (expensive) IDEs
– to
• small, open-source
• (free) single-purpose tools
• linked by build tools/process
6
8th Sutol Conference, November 2016
Motivation II
• Application architecture shift
– from
• monolithic
• big and complex
– to
• orchestrated
• single-purpose components
• more complex flexible
7
8th Sutol Conference, November 2016
Motivation III
• IBM Domino is part of the game
– source control enablement
– headless Domino Designer
• Domino works like small PaSS for ages
– provides Directory, Storage, Security, Mail… services
– simple app deployment model
– Domino Billing features
8
8th Sutol Conference, November 2016
Demo application
• Simple TODO app
– React.js frontend
– running in Domino nsf XPages app
– using Domino data via REST calls
• Built automatically
– from GIT repository
– tested by Selenium tests
9
8th Sutol Conference, November 2016
Dev workstation
• Not all developers use same setup
– OS differences
– Projects being worked on
– Personal preference• IDE/editor preference
• Not all developers need to build whole project
• Portable build tools to rescue
• Single place of truth – SCM repository
10
8th Sutol Conference, November 2016
Toolbox
• Transpilers/Pre-processors
– from - syntax you want to write
– to - syntax that machine can work with
– (e.g. XPages to Java source code)
• Linters/Checkers
– analysis of code for potential problems
– ensures coding + formatting standards
11
8th Sutol Conference, November 2016
Toolbox II
• Package managers
– download what you need
– maintain dependencies
• Builder/bundler tools
– take assets you give them
– produce runnable package
12
8th Sutol Conference, November 2016
Toolbox III
• Task runners
– run and organize build workflow steps
• Dev servers
– fast preview of your changes
– integration with dev/debug tools
• Automated test tools
– verifies that all code still works
13
8th Sutol Conference, November 2016
Frameworks/Ecosystems
• Tools that work nicely together
• Specialized for some language or subject domain
• JavaScript
– NPM (runs on Node.js)
• Java
– Maven
– Gradle
14
8th Sutol Conference, November 2016
Transpilers/Pre-processors - JS
• Babel
– ES2015 (== ES6)
– TypeScript
– Cleaner code, full browser compatibility
15
8th Sutol Conference, November 2016
Transpilers/Pre-processors - CSS
• LESS• variables, mixins, functions
– alternative - SASS
16
8th Sutol Conference, November 2016
Linters/Checkers
• Javascript
– ESLint• unused variables, tabs vs. spaces, semicolons …
• rule sets for React.js
– alternatives JSLint, JSHint, JSCS
• Java
– SonarQube Java analyzer
– FindBugs• (not shown today)
17
8th Sutol Conference, November 2016
Builder/bundler tools - JavaScript
• Webpack
– produces bundle.js
• includes CSS
• + resources (e.g. fonts, images)
– provides webpack-dev-server with hot-reload
• alternatives
– Browserify
• and Gulp, Grunt tasks/plugins
18
8th Sutol Conference, November 2016
Never ending list
• Probably 10 new tools were published
during this session
• For beginners
– pick what you like after quick research
– use it and learn it
– change it once you understand differences
19
8th Sutol Conference, November 2016
Demo setup
• One GIT repository
• folder for Front-End project
– React.js, Webpack, json-server
– Bootstrap, LESS
– publishes to WEB-INF folder of NSF ODP
• folder for NSF On-Disk-Project
• Visual Studio Code for Front-End dev
• Separate VM as local Domino Dev server
20
8th Sutol Conference, November 2016
DEMO
21
8th Sutol Conference, November 2016
Summary Dev Machine
• Develop and test React.js app – without Domino Designer or server
• Produce front-end package– using webpack production build
– (installed with npm)
• Import it to Domino Designer– Team synchronization enablement
– WEB-INF/dist folder
• Put it on an XPage
• View from Domino VM
22
8th Sutol Conference, November 2016
CI goal
• Build front-end
• Build NSF, incl. front-end
• Deploy to test Domino server
• Run Selenium tests
– Firefox
– Chrome
23
8th Sutol Conference, November 2016
Headless Domino Designer
• Command line invocation of Domino Designer
• Create NSF from On Disk Project
• Enable/Disable plugins
• New feature in 9.0.1– http://www-
10.lotus.com/ldd/ddwiki.nsf/dx/Headless_Designer_Wiki
– notes.ini parameter -DESIGNER_AUTO_ENABLED=true
– ID without password
24
8th Sutol Conference, November 2016
Headless Designer invocation
• Manually
– Single command command line
• designer -RPARAMS -vmargs -
Dcom.ibm.designer.cmd=[clean],[exit],[file
name],[job name],[file path],[file name]
– Command file
• designer -RPARAMS -vmargs -
Dcom.ibm.designer.cmd.file=[path to command
file]
25
8th Sutol Conference, November 2016
Headless Designer wrappers
• Maven – Christian Güdemann
– Included in public Maven repository
– Options to install Designer plugins
• Ant – Cameron Gregor
– Additional tasks for NSF manipulation
– Uses Java Native Interface
• Gradle - Martin Přádný
– not maintained
26
8th Sutol Conference, November 2016
Headless designer - Maven
<packaging>domino-nsf</packaging>
<properties>
<ddehd.odpdirectory>
${basedir}/on-disk-project
</ddehd.odpdirectory>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.openntf.maven</groupId>
<artifactId>headlessdesigner-maven-plugin</artifactId>
<version>1.3.0</version>
<extensions>true</extensions>
</plugin>
</plugins>
</build>
27
8th Sutol Conference, November 2016
Why Maven
• Standard in XPages community
• OSGi friendly with Tycho plugin
– IBM released Update Site on OpenNTF.org
– IBM Domino Update Site for Build
Management
• Allows building Extension Libraries
28
8th Sutol Conference, November 2016
Automated tests
• Unit testing
– tests minimal runnable units – e.g. methods
– rest of “world” replaced with mocks
• Integration testing
– test run with real subsystems, dbs etc.
• UI testing
– test driven using UI
29
8th Sutol Conference, November 2016
Selenium
• Web browser automation (Firefox,
Chrome, IE,…)
• Selenium IDE (Firefox)
– Record tests
– Replay tests
– Export (Java, C#, ruby, Python, ..)
• Selenium server, grid
– Run tests on remote machines
30
8th Sutol Conference, November 2016
Continuous integration server
• Maintains central place which allows
– anyone build the project
– anyone see current build status
– test application before build is publish
– automatically publish application to production
• Triggered
– manually
– automatically (after commit, periodically)
31
8th Sutol Conference, November 2016
CI software
• Jenkins– free, open-source
– many plugins
– master/slave architecture
• alternatives– TeamCity
– Bamboo
– Travis CI
– (Bitnucket Pipelines, GitLab CI)
32
8th Sutol Conference, November 2016
Jenkins pipeline
• Define build using script
• Groovy based DSL
• Allows
– executor selection
– parallelism
– human interaction/approval
• Pipeline file from SCM
33
8th Sutol Conference, November 2016
DEMO change flow
34
8th Sutol Conference, November 2016
DEMO
+
Let’s break it
35
8th Sutol Conference, November 2016
Jenkins Blue Ocean - Beta
36
8th Sutol Conference, November 2016
CI Summary
• Build front-end
– Webpack
• Build NSF, incl. front-end
– Maven running Domino Designer
• Deploy to test Domino server
– ANT task
• Run Selenium tests
– Firefox and Chrome
– TestNG run with Maven
37
8th Sutol Conference, November 2016
Summary
• Our setup allows
– anyone with commit rights can modify the app
• no need for environment setup
• GIT and text editor are only needed tools
– even notepad or vi
– continually test with latest browsers
– easily build multiple versions
• e.g. stable and nightly
38
8th Sutol Conference, November 2016
Summary
• Our setup guarantees
– nsf is correctly compiled
– code passes tests
– latest version is available for everyone
– in case of problem, people are notified quickly
39
8th Sutol Conference, November 2016
Questions
40
8th Sutol Conference, November 2016
Sample repository
• https://bitbucket.org/pradnik/todoapp_full/b
ranch/develop
41
8th Sutol Conference, November 2016
Resources
• Csaba Kiss – Beyond XPages
– http://xpagexplorer.org/reactjs-workflow/
• Stephan Wissel - Domino, Extlib, GRUNT, JSON and Yeoman
– http://www.wissel.net/blog/d6plinks/SHWL-A3QHEL
• NotesIn9 – Patrick Kwinten – Using Grunt With XPages
– http://www.notesin9.com/2016/10/10/notesin9-202-using-grunt-with-xpages/
42