Skip to content

Commit

Permalink
Implement the Circle CI configuration file
Browse files Browse the repository at this point in the history
Circle CI (1) is one of the most popular and proven CI providers that
allows to automate pipelines from commit to deploy with a quick, safe,
and scaled process. They support many languages and provide great and
unique features like orbs (2), job orchestration, powerful caching, SSH
or local builds for easy debugging and first-class Docker and GitHub
integration (apps, hooks, etc.) support.
The extensive and well-written documentations (3) make it easy to set
up and configure it for the usage in projects.
Circle CI has been used for almost all open source projects of Arctic
Ice Studio and will be used as primary CI provider for _Nord Docs_ too.

Before starting to run builds, Circle CI must be authorized on a per
project basis to access the code on GitHub. After the process has been
authorized (GitHub OAuth) the project will be added to the dashboard and
required webhooks to listen for new Git events will be automatically set
up. See the documentation about how to get started and add a project to
the dashboard (4).
NOTE: The latest config 2.1 features (5) are currently still in Beta
Preview and must be enabled explicitly for each project via Settings ->
Advanced Settings -> "Enable build processing (preview)"! See the
"Enabling Build Processing" (6) documentation for more details.

The Docker image of the CI container (7) will be the currently latest
stable Node.js (8) LTS version `10.x.x` and the previous LTS version
`8`. The `-browsers-legacy` tag suffix (9) can
be used later on for end-to-end tests (GH-38) with Cypress (10). Next to
Node.js these images currently include Chrome, Firefox, Java 8, and
PhantomJS.

To gather and upload all created coverage reports the
"codecov/codecov" (11) Circle CI orb (12) which provides the `upload`
command for easy integration into jobs and workflows.

References:
  (1) https://circleci.com
  (2) https://circleci.com/orbs
  (3) https://circleci.com/docs
  (4) https://circleci.com/docs/2.0/first-steps
  (5) https://github.com/CircleCI-Public/config-preview-sdk/blob/master/docs/README.md
  (6) https://circleci.com/docs/2.0/build-processing
  (7) https://hub.docker.com/r/circleci/node/tags
  (8) https://nodejs.org
  (9) https://circleci.com/docs/2.0/circleci-images/#language-image-variants
  (10) https://www.cypress.io
  (11) https://circleci.com/orbs/registry/orb/codecov/codecov
  (12) https://circleci.com/docs/2.0/orb-intro

GH-44
  • Loading branch information
arcticicestudio committed Nov 24, 2018
1 parent 7eccff4 commit a70876d
Show file tree
Hide file tree
Showing 4 changed files with 121 additions and 0 deletions.
118 changes: 118 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
# Copyright (C) 2018-present Arctic Ice Studio <development@arcticicestudio.com>
# Copyright (C) 2018-present Sven Greb <development@svengreb.de>
#
# Project: Nord Docs
# Repository: https://github.com/arcticicestudio/nord-docs
# License: MIT

# Configuration for Circle CI.
#
# References:
# - https://circleci.com/docs/2.0
# - https://circleci.com/docs/2.0/circleci-images

version: 2.1

commands:
build:
description: "Build a production bundle with Gatsby"
steps:
- run:
name: Build production bundle
command: npm run build:gatsby
post-process:
description: "Post-process the build"
steps:
- save-npm-cache
- store_artifacts:
path: ./build/reports
- store_artifacts:
path: ./public
- store_artifacts:
path: ./node_modules.tgz
- codecov/upload:
file: ./build/reports/coverage
pre-process:
description: "Pre-process the build"
steps:
- checkout
- print-env-info
- restore-npm-cache
- run:
name: Install dependencies
command: npm ci
print-env-info:
description: "Print build & environment information"
steps:
- run:
name: NPM and NodeJS Version Information
command: npm version
- run:
name: OS Information
command: uname -a
- run:
name: Git and Build Metadata
command: |
echo $CIRCLE_COMPARE_URL | cut -d/ -f7
echo "Git branch: $CIRCLE_BRANCH"
echo "Git commit: $CIRCLE_SHA1"
echo "Job: $CIRCLE_JOB"
echo "Build: $CIRCLE_BUILD_NUM"
restore-npm-cache:
steps:
- restore_cache:
keys:
- v1-npm-cache--{{ arch }}-{{ .Branch }}-{{ checksum "package-lock.json" }}
- v1-npm-cache--{{ arch }}-{{ .Branch }}
- v1-npm-cache--{{ arch }}
save-npm-cache:
steps:
- save_cache:
key: v1-npm-cache--{{ arch }}-{{ .Branch }}-{{ checksum "package-lock.json" }}
paths:
- node_modules
test:
steps:
- run:
name: Lint
command: npm run lint
- run:
name: Run tests with coverage
command: npm run test:cov

jobs:
nodejs-v8:
docker:
- image: node:8
steps:
- pre-process
- test
- build
- post-process
nodejs-v10:
docker:
- image: node:10
steps:
- pre-process
- test
- build
- post-process
nodejs-latest:
docker:
- image: node:latest
steps:
- pre-process
- test
- build
- post-process

orbs:
codecov: codecov/codecov@1.0.1

workflows:
version: 2.1
build-multi-version:
jobs:
- nodejs-v8
- nodejs-v10
- nodejs-latest
1 change: 1 addition & 0 deletions content/blog/.gitkeep
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
A stub to prevent the "gatsby-source-filesystem" plugin to error on CI builds when this folder doesn't exist.
1 change: 1 addition & 0 deletions content/docs/.gitkeep
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
A stub to prevent the "gatsby-source-filesystem" plugin to error on CI builds when this folder doesn't exist.
1 change: 1 addition & 0 deletions src/assets/images/.gitkeep
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
A stub to prevent the "gatsby-source-filesystem" plugin to error on CI builds when this folder doesn't exist.

0 comments on commit a70876d

Please sign in to comment.