Skip to content

Commit 2d0000e

Browse files
Merge pull request #45 from arcticicestudio/feature/gh-44-continuous-integration-and-testing
Continuous Integration & Testing
2 parents 7eccff4 + 15a9783 commit 2d0000e

File tree

9 files changed

+205
-31
lines changed

9 files changed

+205
-31
lines changed

.circleci/config.yml

+125
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
# Copyright (C) 2018-present Arctic Ice Studio <[email protected]>
2+
# Copyright (C) 2018-present Sven Greb <[email protected]>
3+
#
4+
# Project: Nord Docs
5+
# Repository: https://github.com/arcticicestudio/nord-docs
6+
# License: MIT
7+
8+
# Configuration for Circle CI.
9+
#
10+
# References:
11+
# - https://circleci.com/docs/2.0
12+
# - https://circleci.com/docs/2.0/circleci-images
13+
# - https://circleci.com/docs/2.0/contexts
14+
15+
version: 2.1
16+
17+
commands:
18+
build:
19+
description: "Build a production bundle with Gatsby"
20+
steps:
21+
- run:
22+
name: Build production bundle
23+
command: npm run build:gatsby
24+
post-process:
25+
description: "Post-process the build"
26+
steps:
27+
- save-npm-cache
28+
- store_artifacts:
29+
path: ./build/reports
30+
- store_artifacts:
31+
path: ./public
32+
- store_artifacts:
33+
path: ./node_modules.tgz
34+
- store_test_results:
35+
path: ./build/reports/junit
36+
- codecov/upload:
37+
file: ./build/reports/coverage/coverage-final.json
38+
flags: unit
39+
pre-process:
40+
description: "Pre-process the build"
41+
steps:
42+
- checkout
43+
- print-env-info
44+
- restore-npm-cache
45+
- run:
46+
name: Install dependencies
47+
command: npm ci
48+
print-env-info:
49+
description: "Print build & environment information"
50+
steps:
51+
- run:
52+
name: NPM and NodeJS Version Information
53+
command: npm version
54+
- run:
55+
name: OS Information
56+
command: uname -a
57+
- run:
58+
name: Git and Build Metadata
59+
command: |
60+
echo $CIRCLE_COMPARE_URL | cut -d/ -f7
61+
echo "Git branch: $CIRCLE_BRANCH"
62+
echo "Git commit: $CIRCLE_SHA1"
63+
echo "Job: $CIRCLE_JOB"
64+
echo "Build: $CIRCLE_BUILD_NUM"
65+
restore-npm-cache:
66+
steps:
67+
- restore_cache:
68+
keys:
69+
- v1-npm-cache--{{ arch }}-{{ .Branch }}-{{ checksum "package-lock.json" }}
70+
- v1-npm-cache--{{ arch }}-{{ .Branch }}
71+
- v1-npm-cache--{{ arch }}
72+
save-npm-cache:
73+
steps:
74+
- save_cache:
75+
key: v1-npm-cache--{{ arch }}-{{ .Branch }}-{{ checksum "package-lock.json" }}
76+
paths:
77+
- node_modules
78+
test:
79+
steps:
80+
- run:
81+
name: Lint
82+
command: npm run lint
83+
- run:
84+
name: Run tests with coverage in CI mode
85+
command: npm run test:ci
86+
87+
jobs:
88+
nodejs-v8:
89+
docker:
90+
- image: node:8
91+
steps:
92+
- pre-process
93+
- test
94+
- build
95+
- post-process
96+
nodejs-v10:
97+
docker:
98+
- image: node:10
99+
steps:
100+
- pre-process
101+
- test
102+
- build
103+
- post-process
104+
nodejs-latest:
105+
docker:
106+
- image: node:latest
107+
steps:
108+
- pre-process
109+
- test
110+
- build
111+
- post-process
112+
113+
orbs:
114+
codecov: codecov/[email protected]
115+
116+
workflows:
117+
version: 2.1
118+
build-multi-version:
119+
jobs:
120+
- nodejs-v8:
121+
context: nord-docs-ctx
122+
- nodejs-v10:
123+
context: nord-docs-ctx
124+
- nodejs-latest:
125+
context: nord-docs-ctx

.codecov.yml

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Copyright (C) 2018-present Arctic Ice Studio <[email protected]>
2+
# Copyright (C) 2018-present Sven Greb <[email protected]>
3+
#
4+
# Project: Nord Docs
5+
# Repository: https://github.com/arcticicestudio/nord-docs
6+
# License: MIT
7+
8+
# Configuration for Codecov.
9+
#
10+
# References:
11+
# - https://docs.codecov.io/docs/codecov-yaml
12+
# - https://docs.codecov.io/docs/node
13+
14+
codecov:
15+
branch: develop
16+
17+
parsers:
18+
javascript:
19+
enable_partials: yes

content/blog/.gitkeep

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
A stub to prevent the "gatsby-source-filesystem" plugin to error on CI builds when this folder doesn't exist.

content/docs/.gitkeep

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
A stub to prevent the "gatsby-source-filesystem" plugin to error on CI builds when this folder doesn't exist.

jest.config.js

+16-1
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@
1313
* @author Sven Greb <[email protected]>
1414
* @see https://jestjs.io/docs/en/configuration
1515
* @see https://www.gatsbyjs.org/docs/testing
16+
* @see https://circleci.com/docs/2.0/collect-test-data/#jest
1617
* @since 0.1.0
1718
*/
1819

19-
const { BASE_DIR_BUILD_REPORTS_COVERAGE } = require("./src/config/internal/constants");
20+
const { BASE_DIR_BUILD_REPORTS_COVERAGE, BASE_DIR_BUILD_REPORTS_JUNIT } = require("./src/config/internal/constants");
2021

2122
module.exports = {
2223
/*
@@ -70,6 +71,20 @@ module.exports = {
7071
*/
7172
modulePaths: ["<rootDir>/test/__utils__"],
7273

74+
/*
75+
* An array of module names to specify which reporters will be used.
76+
*/
77+
reporters: [
78+
"default",
79+
[
80+
"jest-junit",
81+
{
82+
outputDirectory: `${BASE_DIR_BUILD_REPORTS_JUNIT}`,
83+
outputName: "jest.xml"
84+
}
85+
]
86+
],
87+
7388
/*
7489
* The paths to modules that run some code to configure or set up the testing environment before each test.
7590
* The `___loader` shim is a global function used by internal Gatsby APIs.

package-lock.json

+30-30
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+3
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,10 @@
3838
"lint": "npm-run-all lint:*",
3939
"lint:js": "eslint --ext .js,.jsx .",
4040
"lint:md": "remark --no-stdout . \".github/**/*.md\"",
41+
"report:js:junit": "eslint --ext .js,.jsx --format junit -o ./build/reports/junit/eslint.xml .",
4142
"serve": "gatsby serve",
4243
"test": "jest",
44+
"test:ci": "jest --ci --coverage",
4345
"test:cov": "jest --coverage",
4446
"test:watch": "jest --watch"
4547
},
@@ -67,6 +69,7 @@
6769
"identity-obj-proxy": "3.0.0",
6870
"jest": "23.6.0",
6971
"jest-dom": "2.1.1",
72+
"jest-junit": "5.2.0",
7073
"lint-staged": "8.0.5",
7174
"npm-run-all": "4.1.3",
7275
"prettier": "1.15.2",

src/assets/images/.gitkeep

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
A stub to prevent the "gatsby-source-filesystem" plugin to error on CI builds when this folder doesn't exist.

0 commit comments

Comments
 (0)