From dd1a155c59076143696ac383733866bfb0afa420 Mon Sep 17 00:00:00 2001 From: Arctic Ice Studio Date: Sat, 24 Nov 2018 21:08:17 +0100 Subject: [PATCH] Implement the Circle CI configuration file 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 --- .circleci/config.yml | 120 +++++++++++++++++++++++++++++++++++++ content/blog/.gitkeep | 1 + content/docs/.gitkeep | 1 + src/assets/images/.gitkeep | 1 + 4 files changed, 123 insertions(+) create mode 100644 .circleci/config.yml create mode 100644 content/blog/.gitkeep create mode 100644 content/docs/.gitkeep create mode 100644 src/assets/images/.gitkeep diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 00000000..c8f3574f --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,120 @@ +# Copyright (C) 2018-present Arctic Ice Studio +# Copyright (C) 2018-present Sven Greb +# +# 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 +# - https://circleci.com/docs/2.0/contexts + +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/coverage-final.json + flags: unit + 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 diff --git a/content/blog/.gitkeep b/content/blog/.gitkeep new file mode 100644 index 00000000..1cdc14de --- /dev/null +++ b/content/blog/.gitkeep @@ -0,0 +1 @@ +A stub to prevent the "gatsby-source-filesystem" plugin to error on CI builds when this folder doesn't exist. diff --git a/content/docs/.gitkeep b/content/docs/.gitkeep new file mode 100644 index 00000000..1cdc14de --- /dev/null +++ b/content/docs/.gitkeep @@ -0,0 +1 @@ +A stub to prevent the "gatsby-source-filesystem" plugin to error on CI builds when this folder doesn't exist. diff --git a/src/assets/images/.gitkeep b/src/assets/images/.gitkeep new file mode 100644 index 00000000..1cdc14de --- /dev/null +++ b/src/assets/images/.gitkeep @@ -0,0 +1 @@ +A stub to prevent the "gatsby-source-filesystem" plugin to error on CI builds when this folder doesn't exist.