Skip to content

Continuous Integration & Testing #45

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
125 changes: 125 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
# Copyright (C) 2018-present Arctic Ice Studio <[email protected]>
# Copyright (C) 2018-present Sven Greb <[email protected]>
#
# 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
- store_test_results:
path: ./build/reports/junit
- 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 in CI mode
command: npm run test:ci

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/[email protected]

workflows:
version: 2.1
build-multi-version:
jobs:
- nodejs-v8:
context: nord-docs-ctx
- nodejs-v10:
context: nord-docs-ctx
- nodejs-latest:
context: nord-docs-ctx
19 changes: 19 additions & 0 deletions .codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright (C) 2018-present Arctic Ice Studio <[email protected]>
# Copyright (C) 2018-present Sven Greb <[email protected]>
#
# Project: Nord Docs
# Repository: https://github.com/arcticicestudio/nord-docs
# License: MIT

# Configuration for Codecov.
#
# References:
# - https://docs.codecov.io/docs/codecov-yaml
# - https://docs.codecov.io/docs/node

codecov:
branch: develop

parsers:
javascript:
enable_partials: yes
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.
17 changes: 16 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@
* @author Sven Greb <[email protected]>
* @see https://jestjs.io/docs/en/configuration
* @see https://www.gatsbyjs.org/docs/testing
* @see https://circleci.com/docs/2.0/collect-test-data/#jest
* @since 0.1.0
*/

const { BASE_DIR_BUILD_REPORTS_COVERAGE } = require("./src/config/internal/constants");
const { BASE_DIR_BUILD_REPORTS_COVERAGE, BASE_DIR_BUILD_REPORTS_JUNIT } = require("./src/config/internal/constants");

module.exports = {
/*
Expand Down Expand Up @@ -70,6 +71,20 @@ module.exports = {
*/
modulePaths: ["<rootDir>/test/__utils__"],

/*
* An array of module names to specify which reporters will be used.
*/
reporters: [
"default",
[
"jest-junit",
{
outputDirectory: `${BASE_DIR_BUILD_REPORTS_JUNIT}`,
outputName: "jest.xml"
}
]
],

/*
* The paths to modules that run some code to configure or set up the testing environment before each test.
* The `___loader` shim is a global function used by internal Gatsby APIs.
Expand Down
60 changes: 30 additions & 30 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@
"lint": "npm-run-all lint:*",
"lint:js": "eslint --ext .js,.jsx .",
"lint:md": "remark --no-stdout . \".github/**/*.md\"",
"report:js:junit": "eslint --ext .js,.jsx --format junit -o ./build/reports/junit/eslint.xml .",
"serve": "gatsby serve",
"test": "jest",
"test:ci": "jest --ci --coverage",
"test:cov": "jest --coverage",
"test:watch": "jest --watch"
},
Expand Down Expand Up @@ -67,6 +69,7 @@
"identity-obj-proxy": "3.0.0",
"jest": "23.6.0",
"jest-dom": "2.1.1",
"jest-junit": "5.2.0",
"lint-staged": "8.0.5",
"npm-run-all": "4.1.3",
"prettier": "1.15.2",
Expand Down
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.
Loading