Skip to content

Commit 7bf4daf

Browse files
ci: fail CI if coverage is not 100% but still upload to codecov (#2624)
1 parent 20a8f55 commit 7bf4daf

File tree

6 files changed

+48
-7
lines changed

6 files changed

+48
-7
lines changed

.github/workflows/ci.yml

+17-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
name: CI
22
on: [push, pull_request]
3+
env:
4+
NODE_VERSION_USED_FOR_DEVELOPMENT: 14
35
jobs:
46
lint:
57
name: Lint source files
@@ -10,6 +12,8 @@ jobs:
1012

1113
- name: Setup Node.js
1214
uses: actions/setup-node@v1
15+
with:
16+
node-version: ${{ env.NODE_VERSION_USED_FOR_DEVELOPMENT }}
1317

1418
- name: Cache Node.js modules
1519
uses: actions/cache@v2
@@ -57,6 +61,8 @@ jobs:
5761

5862
- name: Setup Node.js
5963
uses: actions/setup-node@v1
64+
with:
65+
node-version: ${{ env.NODE_VERSION_USED_FOR_DEVELOPMENT }}
6066

6167
- name: Cache Node.js modules
6268
uses: actions/cache@v2
@@ -81,6 +87,8 @@ jobs:
8187

8288
- name: Setup Node.js
8389
uses: actions/setup-node@v1
90+
with:
91+
node-version: ${{ env.NODE_VERSION_USED_FOR_DEVELOPMENT }}
8492

8593
- name: Cache Node.js modules
8694
uses: actions/cache@v2
@@ -97,25 +105,26 @@ jobs:
97105
run: npm run testonly:cover
98106

99107
- name: Upload coverage to Codecov
108+
if: ${{ always() }}
100109
uses: codecov/codecov-action@v1
101110
with:
102111
file: ./coverage/tests/coverage-final.json
103112
fail_ci_if_error: true
104113

105114
test:
106-
name: Run tests on Node v${{ matrix.node_version }}
115+
name: Run tests on Node v${{ matrix.node_version_to_setup }}
107116
runs-on: ubuntu-latest
108117
strategy:
109118
matrix:
110-
node_version: [10, 12, 14]
119+
node_version_to_setup: [10, 12, 14]
111120
steps:
112121
- name: Checkout repo
113122
uses: actions/checkout@v2
114123

115-
- name: Setup Node.js v${{ matrix.node_version }}
124+
- name: Setup Node.js v${{ matrix.node_version_to_setup }}
116125
uses: actions/setup-node@v1
117126
with:
118-
node-version: ${{ matrix.node_version }}
127+
node-version: ${{ matrix.node_version_to_setup }}
119128

120129
- name: Cache Node.js modules
121130
uses: actions/cache@v2
@@ -142,6 +151,8 @@ jobs:
142151

143152
- name: Setup Node.js
144153
uses: actions/setup-node@v1
154+
with:
155+
node-version: ${{ env.NODE_VERSION_USED_FOR_DEVELOPMENT }}
145156

146157
- name: Cache Node.js modules
147158
uses: actions/cache@v2
@@ -171,6 +182,8 @@ jobs:
171182

172183
- name: Setup Node.js
173184
uses: actions/setup-node@v1
185+
with:
186+
node-version: ${{ env.NODE_VERSION_USED_FOR_DEVELOPMENT }}
174187

175188
- name: Cache Node.js modules
176189
uses: actions/cache@v2

.nycrc.yml

+5
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,8 @@ temp-directory: 'coverage/tests'
1919
report-dir: 'coverage/tests'
2020
skip-full: true
2121
reporter: [json, html, text]
22+
check-coverage: true
23+
branches: 100
24+
lines: 100
25+
functions: 100
26+
statements: 100

package.json

+3
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
"graphql-js"
2222
],
2323
"engines": {
24+
"node": ">= 14.2"
25+
},
26+
"engines_on_npm": {
2427
"node": ">= 10.x"
2528
},
2629
"scripts": {

resources/build.js

+3
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ function buildPackageJSON() {
5353
delete packageJSON.scripts;
5454
delete packageJSON.devDependencies;
5555

56+
packageJSON.engines = packageJSON.engines_on_npm;
57+
delete packageJSON.engines_on_npm;
58+
5659
const versionJS = require('../dist/version.js');
5760
assert(
5861
versionJS.version === packageJSON.version,

resources/utils.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,13 @@ function rmdirRecursive(dirPath) {
4949
}
5050

5151
function readdirRecursive(dirPath, opts = {}) {
52+
console.log('-------');
53+
const result = readdirRecursive2(dirPath, opts);
54+
console.log('+++++++');
55+
return result;
56+
}
57+
58+
function readdirRecursive2(dirPath, opts = {}) {
5259
const { ignoreDir } = opts;
5360
const result = [];
5461
for (const dirent of fs.readdirSync(dirPath, { withFileTypes: true })) {
@@ -61,7 +68,7 @@ function readdirRecursive(dirPath, opts = {}) {
6168
if (ignoreDir && ignoreDir.test(name)) {
6269
continue;
6370
}
64-
const list = readdirRecursive(path.join(dirPath, name), opts).map((f) =>
71+
const list = readdirRecursive2(path.join(dirPath, name), opts).map((f) =>
6572
path.join(name, f),
6673
);
6774
result.push(...list);

src/type/validate.js

+12-2
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,12 @@ function validateTypeImplementsInterface(
357357
`Interface field ${iface.name}.${fieldName} expects type ` +
358358
`${inspect(ifaceField.type)} but ${type.name}.${fieldName} ` +
359359
`is type ${inspect(typeField.type)}.`,
360-
[ifaceField.astNode?.type, typeField.astNode?.type],
360+
[
361+
// istanbul ignore next (TODO need to write coverage tests)
362+
ifaceField.astNode?.type,
363+
// istanbul ignore next (TODO need to write coverage tests)
364+
typeField.astNode?.type,
365+
],
361366
);
362367
}
363368

@@ -384,7 +389,12 @@ function validateTypeImplementsInterface(
384389
`expects type ${inspect(ifaceArg.type)} but ` +
385390
`${type.name}.${fieldName}(${argName}:) is type ` +
386391
`${inspect(typeArg.type)}.`,
387-
[ifaceArg.astNode?.type, typeArg.astNode?.type],
392+
[
393+
// istanbul ignore next (TODO need to write coverage tests)
394+
ifaceArg.astNode?.type,
395+
// istanbul ignore next (TODO need to write coverage tests)
396+
typeArg.astNode?.type,
397+
],
388398
);
389399
}
390400

0 commit comments

Comments
 (0)