• Stars
    star
    121
  • Rank 283,310 (Top 6 %)
  • Language
  • License
    GNU General Publi...
  • Created about 8 years ago
  • Updated over 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

โœ… A quick intro to Circle CI (Continuous Integration) for JavaScript developers.

Learn Circle CI (Continuous Integration)

circle-ci-logo

A step-by-step tutorial for using Circle CI for Continuous Integration & Deployment!

Note: This guide/tutorial is a vendor-specific set of instructions for how to enable CI/CD for a Node.js project hosted on GitHub. For a more general introduction to Continuous Integration, please read/follow our "Learn Travis" tutorial first: https://github.com/dwyl/learn-travis

Why?

In a nutshell: the reason you would use Circle-CI is because it's "free"1. see: https://circleci.com/pricing circle-ci-free

If you have a product owner / client who wants/needs their code to remain private and does not want to pay $49/month for one of the other CI/CD services, then Circle-CI is your go-to choice.

1Most of our client private projects that use Circle-CI don't pay a penny. However one of our clients is paying for Circle-CI because tests in their 3 (actively developed) apps take up more than 1500 "free minutes" to build/test per month. So we feel they are "breaking even" on us...

What?

Run your (application/unit/integration/UI) tests using a container on Circle-CI and deploy your app to your choice of environment if they pass.

Who?

This tutorial is aimed at developers who need a way of automatically testing and deploying their private apps/code.

Prerequisites?

  • Basic knowledge of CI concepts. If you are new to (or "rusty") on CI, please read/follow our "Learn Travis" tutorial first: https://github.com/dwyl/learn-travis
  • Basic JavaScript/Node.js knowledge.
  • 10 Minutes of Time.

No other knowledge/skill/experience is assumed or implied.

Stuck? If you have any questions related to getting started with Circle-CI or you are "stuck" deploying using the script(s) we demo here, please open an issue/question and we will try our best to help! https://github.com/dwyl/learn-circleci/issues

How

If you do not already have an App that you want to test and deploy, see:

1. Register

Register using your GitHub account: https://circleci.com (if you haven't already)

circle-login-with-github

2. Add Project

Click the "add project" + button from the left-hand side menu. Then select the project you want Circle-CI to test for you, and click the "Setup Project" button:

circle-add-project

You should see something like this now:

circle-ci-setup-project

3. Setup .circleci/config.yml File

Next, follow the on-screen instructions to create a config.yml folder and setup your .circleci/config.yml file.

mkdir .circleci
vi .circleci/config.yml

Click on the "Copy To Clipboard" button to get the code. paste the sample code into the .circleci/config.yml file you have open in your text editor.

e.g:

image

Save the file, commit it and push to GitHub. e.g: https://github.com/nelsonic/circleci-hello-world-nodejs/commit/ad368321f3fa05686c97a8147f1e5570870bb527

Note: Circle-CI installs Yarn by default. This is NOT required anymore in 2018. It adds a needless step to the build process and sends your package.json to Facebook HQ. I've left it as the default for this example, but we don't use Yarn for any of our Node.js projects, there is zero benefit.

4. Start Building

Once you have created the .circleci/config.yml, scroll down the page and click on "Start building":

circle-start-building

You should be redirected to a build progress/status page:

circle-build-passed

e.g: https://circleci.com/gh/nelsonic/circleci-hello-world-nodejs/1

The build and running the (single unit) test, took 3 seconds and ended in "SUCCESS". (it's a "hello world" example, it should be fast and pass!)

5. Status Badge!

At this point we can add a "Badge" to our project README.md CircleCI

e.g: https://circleci.com/gh/nelsonic/circleci-hello-world-nodejs/edit#badges circle-ci-status-badge

For why this is a good idea, see: https://github.com/dwyl/repo-badges

Part 2 - Continuous Deployment

Continuous Deployment (CD) is the perfect complement to Continuous Integration (CI) and people usually use the same "pipeline" (system) to automate it. It just means that your application is automatically deployed by the CI system (in this case CircleCI) when the PR is merged.

If you are new to Continuous Deployment (CD) in general we wrote an introductory post in: https://github.com/dwyl/learn-devops

1As always, we recommend using Heroku for "MVP" App(s) because it's much easier/faster to get started and traction. see: https://github.com/dwyl/learn-heroku and: https://circleci.com/docs/2.0/deployment-integrations/#heroku once you need "more power" than Heroku (or need to reduce costs), take a look at: https://github.com/dwyl/learn-devops

6. Pre-Deployment Checks

  1. Ensure that you have a "start" script in your package.json. e.g:
{
  "scripts": {
    "start": "node server.js",
    "test": "node hello.test.js"
  }
}
  1. Ensure that your app runs on your localhost before attempting to deploy it to your chosen "cloud" provider.

Run the start command:

npm start

circleci-npm-start-localhost-terminal

Visit: http://localhost:5000 circleci-localhost-app-working

Ok, so it's working on localhost; we have a good "baseline". Onwards!

Note: there are several ways of starting node.js servers, (e.g: PM2, Forever or SystemD) we are using "node server.js" for simplicity. But if you are running your own infrastructure, you will have a well defined system for running/monitoring node.js.

7. Deploy!

For this section we are doing an "advanced" deployment to a DigitalOcean Instance using Dokku (which is an Open Source Heroku "clone"). It's only "advanced" in that there are a few more "steps" than deploying to Heroku, but don't worry, we have documented everything "step-by-step" so it should only take you about 10 minutes to setup.

Note: as always, if you get "stuck", just open an issue and we will try our best to help! https://github.com/dwyl/learn-circleci/issues

7.1 Add RSA Key

In order to deploy the app via SSH, we need to add the SSH (RSA) key to CircleCI. Thankfully this is a lot easier thank on Travis-CI!

In your app's Settings page,

  1. Scroll down to the "Permissions" section.
  2. Click on SSH Permissions
  3. Click on the Add SSH Key button. circleci-add-ssh-key

A "modal" window will appear which allows you to paste your Private Key. circleci-add-ssh-private-key

Note: we do NOT recommend using your personal private key for deployments! rather you should create a key that is specific to the server you are deploying to and is only "known" (used) by your CI/CD system. see: https://github.com/dwyl/learn-devops

circleci-ssh-key-added-success

We have successfully added our SSH Deployment RSA Key!

7.2 Add Deployment Scripts to your Project

Create a /bin directory in your project.

mkdir bin

Copy the deployement scripts from: https://github.com/nelsonic/circleci-hello-world-nodejs/tree/master/bin

You can either do this manually by downloading each file to your project, or ... using a script!

7.3 Add Required Environment Variables

Add any Environment Variables you need to your .circleci/config.yml file. The IP Address of the server is required as is the DOKKU_APP name.

e.g:

environment:
   SERVER_IP_ADDRESS: 138.68.163.126
   DOKKU_APP: circlecidemo
   TRAVIS: "false"

working example: https://github.com/nelsonic/circleci-hello-world-nodejs/blob/ecfab4a49141da87f36519e50ecda593f01aaf48/.circleci/config.yml#L8

Note: if you need your environment variables to not be in Version Control, add them via the CircleCI Web Interface. more details: https://circleci.com/docs/2.0/env-vars

If you are new to Environment Variables, checkout: https://github.com/dwyl/learn-environment-variables

7.4 Add Command to Run Deployment Script

Add the following lines to your .circleci/config.yml file:

# Use BASH instead of DASH! see: https://ubuntuforums.org/showthread.php?t=1932504
- run: ls -al /bin/sh && sudo rm /bin/sh && sudo ln -s /bin/bash /bin/sh && ls -al /bin/sh
# test shell script:
- run: echo ${SERVER_IP_ADDRESS}
- run: echo -e "Host $SERVER_IP_ADDRESS\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config
- run: sh bin/deploy.sh

Working example: https://github.com/nelsonic/circleci-hello-world-nodejs/blob/ecfab4a49141da87f36519e50ecda593f01aaf48/.circleci/config.yml#L43-L48

Push your code to GitHub and let CircleCI do the rest! It usually takes a minute to deploy (depending on your dependencies) image

In the build log you should see something like: circleci-deployed-successfully

e.g: https://circleci.com/gh/nelsonic/circleci-hello-world-nodejs/18

8. Check it Worked!

In our case our DOKKU_APP was defined as circlecidemo (see: section 7.3 above) So the deployed app is available on: https://circlecidemo.ademo.app If we visit this URL in our browser we see:

demo-app

Notice the "Git Hash" value: dc933373388911d9405fb452c9753f0250766bb3

This corresponds to the latest commit on the master branch: https://github.com/nelsonic/circleci-hello-world-nodejs/commits/master (GitHub only shows the first 7 characters of the has in the UI in this case: dc93337)

image

So it worked! (the latest master has been deployed by CircleCI!)

done

Relevant / Background Reading

Official "Getting Started" Video?

The official get started on CircleCI 2.0 video: https://youtu.be/KhjwnTD4oec get-started-on-circle-ci uses a Python example: https://github.com/bellkev/circleci-demo-python-django it's not really "hello world" (beginner friendly) ... So just focus on the UI/navigation, then come back here for a simple example!

More Repositories

1

english-words

๐Ÿ“ A text file containing 479k English words for all your dictionary/word-based projects e.g: auto-completion / autosuggestion
Python
9,337
star
2

learn-json-web-tokens

๐Ÿ” Learn how to use JSON Web Token (JWT) to secure your next Web App! (Tutorial/Example with Tests!!)
JavaScript
4,178
star
3

learn-to-send-email-via-google-script-html-no-server

๐Ÿ“ง An Example of using an HTML form (e.g: "Contact Us" on a website) to send Email without a Backend Server (using a Google Script) perfect for static websites that need to collect data.
HTML
3,047
star
4

repo-badges

โญ Use repo badges (build passing, coverage, etc) in your readme/markdown file to signal code quality in a project.
HTML
2,831
star
5

learn-tdd

โœ… A brief introduction to Test Driven Development (TDD) in JavaScript (Complete Beginner's Step-by-Step Tutorial)
JavaScript
2,698
star
6

start-here

๐Ÿ’ก A Quick-start Guide for People who want to dwyl โค๏ธ โœ…
1,725
star
7

learn-elixir

๐Ÿ’ง Learn the Elixir programming language to build functional, fast, scalable and maintainable web applications!
Elixir
1,586
star
8

learn-travis

๐Ÿ˜Ž A quick Travis CI (Continuous Integration) Tutorial for Node.js developers
JavaScript
1,251
star
9

Javascript-the-Good-Parts-notes

๐Ÿ“– Notes on the seminal "JavaScript the Good Parts: by Douglas Crockford
1,173
star
10

aws-sdk-mock

๐ŸŒˆ AWSomocks for Javascript/Node.js aws-sdk tested, documented & maintained. Contributions welcome!
JavaScript
1,079
star
11

learn-aws-lambda

โœจ Learn how to use AWS Lambda to easily create infinitely scalable web services
JavaScript
1,035
star
12

book

๐Ÿ“— Our Book on Full-Stack Web Application Development covering User Experience (UX) Design, Mobile/Offline/Security First, Progressive Enhancement, Continuous Integration/Deployment, Testing (UX/TDD/BDD), Performance-Driven-Development and much more!
Rust
816
star
13

hapi-auth-jwt2

๐Ÿ”’ Secure Hapi.js authentication plugin using JSON Web Tokens (JWT) in Headers, URL or Cookies
JavaScript
795
star
14

learn-hapi

โ˜€๏ธ Learn to use Hapi.js (Node.js) web framework to build scalable apps in less time
HTML
794
star
15

phoenix-chat-example

๐Ÿ’ฌ The Step-by-Step Beginners Tutorial for Building, Testing & Deploying a Chat app in Phoenix 1.7 [Latest] ๐Ÿš€
Elixir
721
star
16

learn-tachyons

๐Ÿ˜ Learn how to use Tachyons to craft beautiful, responsive and fast UI with functional CSS!
HTML
670
star
17

learn-phoenix-framework

๐Ÿ”ฅ Phoenix is the web framework without compromise on speed, reliability or maintainability! Don't settle for less. ๐Ÿš€
Elixir
639
star
18

learn-nightwatch

๐ŸŒœ Learn how to use Nightwatch.js to easily & automatically test your web apps in *real* web browsers.
JavaScript
585
star
19

javascript-todo-list-tutorial

โœ… A step-by-step complete beginner example/tutorial for building a Todo List App (TodoMVC) from scratch in JavaScript following Test Driven Development (TDD) best practice. ๐ŸŒฑ
JavaScript
565
star
20

learn-elm

๐ŸŒˆ discover the beautiful programming language that makes front-end web apps a joy to build and maintain!
HTML
472
star
21

learn-redux

๐Ÿ’ฅ Comprehensive Notes for Learning (how to use) Redux to manage state in your Web/Mobile (React.js) Apps.
HTML
446
star
22

learn-devops

๐Ÿšง Learn the craft of "DevOps" (Developer Operations) to Deploy your App and Monitor it so it stays "Up"!
Shell
411
star
23

hits

๐Ÿ“ˆ General purpose hits (page views) counter
Elixir
397
star
24

hapi-socketio-redis-chat-example

๐Ÿ’ฌ Real-time Chat using Hapi.js + Socket.io + Redis Pub/Sub (example with tests!!)
Elm
363
star
25

hapi-typescript-example

โšก Hapi.Js + Typescript = Awesomeness
TypeScript
351
star
26

phoenix-liveview-counter-tutorial

๐Ÿคฏ beginners tutorial building a real time counter in Phoenix 1.7.7 + LiveView 0.19 โšก๏ธ Learn the fundamentals from first principals so you can make something amazing! ๐Ÿš€
Elixir
345
star
27

learn-istanbul

๐Ÿ Learn how to use the Istanbul JavaScript Code Coverage Tool
JavaScript
339
star
28

learn-redis

๐Ÿ“• Need to store/access your data as fast as possible? Learn Redis! Beginners Tutorial using Node.js ๐Ÿš€
JavaScript
291
star
29

technology-stack

๐Ÿš€ Detailed description + diagram of the Open Source Technology Stack we use for dwyl projects.
JavaScript
281
star
30

phoenix-ecto-encryption-example

๐Ÿ” A detailed example for how to encrypt data in an Elixir (Phoenix v1.7) App before inserting into a database using Ecto Types
Elixir
269
star
31

learn-elasticsearch

๐Ÿ” Learn how to use ElasticSearch to power a great search experience for your project/product/website.
Elixir
265
star
32

home

๐Ÿก ๐Ÿ‘ฉโ€๐Ÿ’ป ๐Ÿ’ก home is where you can [learn to] build the future surrounded by like-minded creative, friendly and [intrinsically] motivated people focussed on health, fitness and making things people and the world need!
245
star
33

elixir-auth-google

๐Ÿ‘คMinimalist Google OAuth Authentication for Elixir Apps. Tested, Documented & Maintained. Setup in 5 mins. ๐Ÿš€
Elixir
228
star
34

learn-docker

๐Ÿšข Learn how to use docker.io containers to consistently deploy your apps on any infrastructure.
Dockerfile
220
star
35

learn-elm-architecture-in-javascript

๐Ÿฆ„ Learn how to build web apps using the Elm Architecture in "vanilla" JavaScript (step-by-step TDD tutorial)!
JavaScript
207
star
36

learn-environment-variables

๐Ÿ“Learn how to use Environment Variables to keep your passwords and API keys secret. ๐Ÿ”
JavaScript
201
star
37

learn-postgresql

๐Ÿ˜ Learn how to use PostgreSQL and Structured Query Language (SQL) to store and query your relational data. ๐Ÿ”
JavaScript
195
star
38

learn-tape

โœ… Learn how to use Tape for JavaScript/Node.js Test Driven Development (TDD) - Ten-Minute Testing Tutorial
JavaScript
185
star
39

sendemail

๐Ÿ’Œ Simplifies reliably sending emails from your node.js apps using AWS Simple Email Service (SES)
JavaScript
181
star
40

phoenix-todo-list-tutorial

โœ… Complete beginners tutorial building a todo list from scratch in Phoenix 1.7 (latest)
Elixir
171
star
41

decache

:shipit: Delete Cached node_modules useful when you need to "un-require" during testing for a fresh state.
JavaScript
151
star
42

quotes

๐Ÿ’ฌ a curated list of quotes that inspire action + code that returns quotes by tag/author/etc. ๐Ÿ’ก
Elixir
150
star
43

learn-heroku

๐Ÿ Learn how to deploy your web application to Heroku from scratch step-by-step in 7 minutes!
Python
149
star
44

learn-chrome-extensions

๐ŸŒ Discover how to build and deploy a Google Chrome Extension for your Project!
139
star
45

labels

๐Ÿท Sync GitHub Labels from any Source to Target Repositories for Consistency across all your projects!
Elixir
136
star
46

ISO-27001-2013-information-technology-security

๐Ÿ” Probably the most boring-but-necessary repo on GitHub. If you care about the security/privacy of your data...! โœ…
136
star
47

learn-ab-and-multivariate-testing

๐Ÿ†Ž Tutorial on A/B and multivariate testing โœ”๏ธ
135
star
48

web-form-to-google-sheet

A simple example of sending data from an ordinary web form straight to a Google Spreadsheet without a server.
HTML
133
star
49

app

Clear your mind. Organise your life. Ignore distractions. Focus on what matters.
Dart
133
star
50

auth

๐Ÿšช ๐Ÿ” UX-focussed Turnkey Authentication Solution for Web Apps/APIs (Documented, Tested & Maintained)
Elixir
124
star
51

learn-regex

โ‰๏ธ A simple REGular EXpression tutorial in JavaScript
120
star
52

learn-react

"The possibilities are numerous once we decide to act and not react." ~ George Bernard Shaw
HTML
108
star
53

learn-aws-iot

๐Ÿ’ก Learn how to use Amazon Web Services Internet of Things (IoT) service to build connected applications.
JavaScript
101
star
54

env2

๐Ÿ’ป Simple environment variable (from config file) loader for your node.js app
JavaScript
100
star
55

phoenix-liveview-chat-example

๐Ÿ’ฌ Step-by-step tutorial creates a Chat App using Phoenix LiveView including Presence, Authentication and Style with Tailwind CSS
Elixir
98
star
56

how-to-choose-a-database

How to choose the right dabase
93
star
57

imgup

๐ŸŒ… Effortless image uploads to AWS S3 with automatic resizing including REST API.
Elixir
88
star
58

contributing

๐Ÿ“‹ Guidelines & Workflow for people contributing to our project(s) on GitHub. Please โญ to confirm you've read & understood! โœ…
85
star
59

javascript-best-practice

A collection of JavaScript Best Practices
83
star
60

learn-amazon-web-services

โญ Amazing Guide to using Amazon Web Services (AWS)! โ˜๏ธ
83
star
61

range-touch

๐Ÿ“ฑ Use HTML5 range input on touch devices (iPhone, iPad & Android) without bloatware!
JavaScript
83
star
62

learn-pre-commit

โœ… Pre-commit hooks let you run checks before allowing a commit (e.g. JSLint or check Test Coverage).
JavaScript
80
star
63

product-owner-guide

๐Ÿš€ A rough guide for people working with dwyl as Product Owners
78
star
64

phoenix-ecto-append-only-log-example

๐Ÿ“ A step-by-step example/tutorial showing how to build a Phoenix (Elixir) App where all data is immutable (append only). Precursor to Blockchain, IPFS or Solid!
Elixir
78
star
65

mvp

๐Ÿ“ฒ simplest version of the @dwyl app
Elixir
78
star
66

goodparts

๐Ÿ™ˆ An ESLint Style that only allows JavaScript the Good Parts (and "Better Parts") in your code.
JavaScript
77
star
67

hapi-error

โ˜” Intercept errors in your Hapi Web App/API and send a *useful* message to the client OR redirect to the desired endpoint.
JavaScript
76
star
68

flutter-todo-list-tutorial

โœ… A detailed example/tutorial building a cross-platform Todo List App using Flutter ๐Ÿฆ‹
Dart
75
star
69

process-handbook

๐Ÿ“— Contains our processes, questions and journey to creating a team
HTML
75
star
70

dev-setup

โœˆ๏ธ A quick-start guide for new engineers on how to set up their Dev environment
73
star
71

aws-lambda-deploy

โ˜๏ธ ๐Ÿš€ Effortlessly deploy Amazon Web Services Lambda function(s) with a single command. Less to configure. Latest AWS SDK and Node.js v20!
JavaScript
72
star
72

terminate

โ™ป๏ธ Terminate a Node.js Process (and all Child Processes) based on the Process ID
JavaScript
71
star
73

fields

๐ŸŒป fields is a collection of useful field definitions (Custom Ecto Types) that helps you easily define an Ecto Schema with validation, encryption and hashing functions so that you can ship your Elixir/Phoenix App much faster!
Elixir
69
star
74

learn-flutter

๐Ÿฆ‹ Learn how to use Flutter to Build Cross-platform Native Mobile Apps
JavaScript
69
star
75

hapi-login-example-postgres

๐Ÿฐ A simple registration + login form example using hapi-register, hapi-login & hapi-auth-jwt2 with a PostgreSQL DB
JavaScript
69
star
76

phoenix-liveview-todo-list-tutorial

โœ… Beginners tutorial building a Realtime Todo List in Phoenix 1.6.10 + LiveView 0.17.10 โšก๏ธ Feedback very welcome!
Elixir
64
star
77

learn-security

๐Ÿ” For most technology projects Security is an "after thought", it does not have to be that way; let's be proactive!
64
star
78

learn-javascript

A Series of Simple Steps in JavaScript :-)
HTML
63
star
79

chat

๐Ÿ’ฌ Probably the fastest, most reliable/scalable chat system on the internet.
Elixir
62
star
80

learn-jsdoc

๐Ÿ“˜ Use JSDoc and a few carefully crafted comments to document your JavaScript code!
CSS
60
star
81

ampl

๐Ÿ“ฑ โšก Ampl transforms Markdown into AMP-compliant html so it loads super-fast!
JavaScript
57
star
82

aguid

โ„๏ธ A Globally Unique IDentifier (GUID) generator in JS. (deterministic or random - you chose!)
JavaScript
56
star
83

tudo

โœ… Want to see where you could help on an open dwyl issue?
Elixir
56
star
84

learn-apple-watch-development

๐Ÿ“— Learn how to build Native Apple Watch (+iPhone) apps from scratch!
Swift
55
star
85

learn-qunit

โœ… A quick introduction to JavaScript unit testing with QUnit
JavaScript
51
star
86

learn-ngrok

โ˜๏ธ Learn how to use ngrok to share access to a Web App/Site running on your "localhost" with the world!
HTML
50
star
87

hapi-auth-jwt2-example

๐Ÿ”’ A functional example Hapi.js app using hapi-auth-jwt2 & Redis (hosted on Heroku) with tests!
JavaScript
49
star
88

learn-jshint

๐Ÿ’ฉ Learn how to use the ~~jshint~~ code quality/consistency tool.
JavaScript
49
star
89

tachyons-bootstrap

๐Ÿ‘ขBootstrap recreated using tachyons functional css
HTML
49
star
90

esta

๐Ÿ” Simple + Fast ElasticSearch Node.js client. Beginner-friendly defaults & Heroku support โœ… ๐Ÿš€
JavaScript
48
star
91

learn-node-js-by-example

โ˜๏ธ Practical node.js examples.
HTML
47
star
92

product-roadmap

๐ŸŒ Because why wouldn't you make your company's product roadmap Public on GitHub?
46
star
93

redis-connection

โšก Single Redis Connection that can be used anywhere in your node.js app and closed once (e.g in tests)
JavaScript
45
star
94

aws-lambda-test-utils

Mock event and context objects without fluff.
JavaScript
44
star
95

learn-graphQL

โ“Learn to use GraphQL - A query language that allows client applications to specify their data fetching requirements
JavaScript
44
star
96

elixir-pre-commit

โœ… Pre-commit hooks for Elixir projects
Elixir
43
star
97

hapi-login

๐Ÿšช The Simplest Possible (Email + Password) Login for Hapi.js Apps โœ…
JavaScript
43
star
98

learn-riot

๐ŸŽ Riot.js lets you build apps that are simpler and load/run faster than any other JS framework/library.
HTML
43
star
99

github-reference

โญ GitHub reference for *non-technical* people following a project's progress
42
star
100

learn-codeclimate

๐ŸŒˆ Learn how to use CodeClimate to track the quality of your JavaScript/Node.js code.
41
star