Skip to content

ci: fail CI if coverage is not 100% but still upload to codecov #2624

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 1 commit into from
Jun 7, 2020
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
21 changes: 17 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
name: CI
on: [push, pull_request]
env:
NODE_VERSION_USED_FOR_DEVELOPMENT: 14
jobs:
lint:
name: Lint source files
Expand All @@ -10,6 +12,8 @@ jobs:

- name: Setup Node.js
uses: actions/setup-node@v1
with:
node-version: ${{ env.NODE_VERSION_USED_FOR_DEVELOPMENT }}

- name: Cache Node.js modules
uses: actions/cache@v2
Expand Down Expand Up @@ -57,6 +61,8 @@ jobs:

- name: Setup Node.js
uses: actions/setup-node@v1
with:
node-version: ${{ env.NODE_VERSION_USED_FOR_DEVELOPMENT }}

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

- name: Setup Node.js
uses: actions/setup-node@v1
with:
node-version: ${{ env.NODE_VERSION_USED_FOR_DEVELOPMENT }}

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

- name: Upload coverage to Codecov
if: ${{ always() }}
uses: codecov/codecov-action@v1
with:
file: ./coverage/tests/coverage-final.json
fail_ci_if_error: true

test:
name: Run tests on Node v${{ matrix.node_version }}
name: Run tests on Node v${{ matrix.node_version_to_setup }}
runs-on: ubuntu-latest
strategy:
matrix:
node_version: [10, 12, 14]
node_version_to_setup: [10, 12, 14]
steps:
- name: Checkout repo
uses: actions/checkout@v2

- name: Setup Node.js v${{ matrix.node_version }}
- name: Setup Node.js v${{ matrix.node_version_to_setup }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node_version }}
node-version: ${{ matrix.node_version_to_setup }}

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

- name: Setup Node.js
uses: actions/setup-node@v1
with:
node-version: ${{ env.NODE_VERSION_USED_FOR_DEVELOPMENT }}

- name: Cache Node.js modules
uses: actions/cache@v2
Expand Down Expand Up @@ -171,6 +182,8 @@ jobs:

- name: Setup Node.js
uses: actions/setup-node@v1
with:
node-version: ${{ env.NODE_VERSION_USED_FOR_DEVELOPMENT }}

- name: Cache Node.js modules
uses: actions/cache@v2
Expand Down
5 changes: 5 additions & 0 deletions .nycrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,8 @@ temp-directory: 'coverage/tests'
report-dir: 'coverage/tests'
skip-full: true
reporter: [json, html, text]
check-coverage: true
branches: 100
lines: 100
functions: 100
statements: 100
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
"graphql-js"
],
"engines": {
"node": ">= 14.2"
},
"engines_on_npm": {
"node": ">= 10.x"
},
"scripts": {
Expand Down
3 changes: 3 additions & 0 deletions resources/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ function buildPackageJSON() {
delete packageJSON.scripts;
delete packageJSON.devDependencies;

packageJSON.engines = packageJSON.engines_on_npm;
delete packageJSON.engines_on_npm;

const versionJS = require('../dist/version.js');
assert(
versionJS.version === packageJSON.version,
Expand Down
9 changes: 8 additions & 1 deletion resources/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@ function rmdirRecursive(dirPath) {
}

function readdirRecursive(dirPath, opts = {}) {
console.log('-------');
const result = readdirRecursive2(dirPath, opts);
console.log('+++++++');
return result;
}

function readdirRecursive2(dirPath, opts = {}) {
const { ignoreDir } = opts;
const result = [];
for (const dirent of fs.readdirSync(dirPath, { withFileTypes: true })) {
Expand All @@ -61,7 +68,7 @@ function readdirRecursive(dirPath, opts = {}) {
if (ignoreDir && ignoreDir.test(name)) {
continue;
}
const list = readdirRecursive(path.join(dirPath, name), opts).map((f) =>
const list = readdirRecursive2(path.join(dirPath, name), opts).map((f) =>
path.join(name, f),
);
result.push(...list);
Expand Down
14 changes: 12 additions & 2 deletions src/type/validate.js
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,12 @@ function validateTypeImplementsInterface(
`Interface field ${iface.name}.${fieldName} expects type ` +
`${inspect(ifaceField.type)} but ${type.name}.${fieldName} ` +
`is type ${inspect(typeField.type)}.`,
[ifaceField.astNode?.type, typeField.astNode?.type],
[
// istanbul ignore next (TODO need to write coverage tests)
ifaceField.astNode?.type,
// istanbul ignore next (TODO need to write coverage tests)
typeField.astNode?.type,
],
);
}

Expand All @@ -384,7 +389,12 @@ function validateTypeImplementsInterface(
`expects type ${inspect(ifaceArg.type)} but ` +
`${type.name}.${fieldName}(${argName}:) is type ` +
`${inspect(typeArg.type)}.`,
[ifaceArg.astNode?.type, typeArg.astNode?.type],
[
// istanbul ignore next (TODO need to write coverage tests)
ifaceArg.astNode?.type,
// istanbul ignore next (TODO need to write coverage tests)
typeArg.astNode?.type,
],
);
}

Expand Down