Intro to Continuous Integration (CI)
Or how to automate the boring parts?
🕕 🕙 🕛 🕞
What Is Continuous Integration?
Why should you care?
Well, have you seen or heard any of these?
Tools of the Trade 🧰

Demo

<span> </span>
Let's see some pipeline results
How did this happen?
Let's look at one example config: .github/workflows/nodejs.yml
nodejs.yml — Github Actions
Code step 1 of 6: nodejs.yml — Github Actionsname: Node CI
on:
- pull_request
- push
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Use Node.js 12.x
uses: actions/setup-node@v1
with:
node-version: 12.x
- name: Install node_modules
run: |
npm ci
- name: Lint the code
run: |
npm run lint
- name: Run tests
run: |
npm test
env:
NODE_ENV: test
- name: Build site
run: |
npm run build
Let's add a new stage
report-coverage: npx codecov
Old File — Github Actions
Code step 1 of 2: Old File — Github Actions - name: Run tests
run: |
npm test
env:
NODE_ENV: test
- name: Build site
run: |
npm run build
Old File
- name: Run tests
run: |
npm test
env:
NODE_ENV: test
- name: Build site
run: |
npm run build
With coverage
- name: Run tests (with coverage)
run: |
npm test -- --coverage
env:
NODE_ENV: test
- name: Upload coverage
run: npx codecov
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
- name: Build site
run: |
npm run build
Some Advanced Usage Patterns
Publishing an npm module
On every release
On every tag — Github Actions
Code step 1 of 2: On every tag — Github Actionson:
push:
tags:
- 'v*'
Publishing docs to Github Pages
On every release
Build Docs — Drone.io
Code step 1 of 2: Build Docs — Drone.io- name: docs
image: node:12
commands:
- yarn docs
when:
event:
- tag
Code Deployments
Using PM2's deploy feature
Deploy the Code — Gitlab CI
deploy:
stage: deploy
script:
- pm2 deploy dev
Trigger Other Pipelines
Perform integration tests across API and frontend
Trigger Downstream Pipelines — Gitlab CI
trigger-consumer:
stage: downstream
trigger: user/api-consumer
trigger-frontend:
stage: downstream
trigger:
project: user/project-frontend
branch: dev
Links
🖼 Presentation
💻 Repository