ci: Setup code-coverage reporting (no-changelog) (#5669)

This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™ 2023-03-10 16:53:05 +01:00 committed by GitHub
parent 5f238ea641
commit 3831201aaf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 25 additions and 8 deletions

View file

@ -35,6 +35,11 @@ jobs:
- name: Test - name: Test
run: pnpm test run: pnpm test
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
files: packages/cli/coverage/cobertura-coverage.xml,packages/nodes-base/coverage/cobertura-coverage.xml,packages/core/coverage/cobertura-coverage.xml,packages/workflow/coverage/cobertura-coverage.xml
- name: Lint - name: Lint
env: env:
CI_LINT_MASTER: true CI_LINT_MASTER: true

View file

@ -67,6 +67,11 @@ jobs:
- name: Test - name: Test
run: pnpm test run: pnpm test
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
files: packages/cli/coverage/cobertura-coverage.xml,packages/nodes-base/coverage/cobertura-coverage.xml,packages/core/coverage/cobertura-coverage.xml,packages/workflow/coverage/cobertura-coverage.xml
lint: lint:
name: Lint changes name: Lint changes
runs-on: ubuntu-latest runs-on: ubuntu-latest

1
.gitignore vendored
View file

@ -3,6 +3,7 @@ node_modules
.tmp .tmp
tmp tmp
dist dist
coverage
npm-debug.log* npm-debug.log*
yarn.lock yarn.lock
google-generated-credentials.json google-generated-credentials.json

View file

@ -22,11 +22,15 @@ const config = {
moduleNameMapper: { moduleNameMapper: {
'^@/(.*)$': '<rootDir>/src/$1', '^@/(.*)$': '<rootDir>/src/$1',
}, },
collectCoverage: true,
coverageReporters: [process.env.COVERAGE_REPORT === 'true' ? 'text' : 'text-summary'],
collectCoverageFrom: ['src/**/*.ts'],
}; };
if (process.env.CI === 'true') { if (process.env.CI === 'true') {
config.maxWorkers = 2; config.maxWorkers = 2;
config.workerIdleMemoryLimit = 2048; config.workerIdleMemoryLimit = 2048;
config.coverageReporters = ['cobertura'];
} }
module.exports = config; module.exports = config;

View file

@ -11,4 +11,5 @@ module.exports = {
'^@/(.*)$': '<rootDir>/src/$1', '^@/(.*)$': '<rootDir>/src/$1',
'^@db/(.*)$': '<rootDir>/src/databases/$1', '^@db/(.*)$': '<rootDir>/src/databases/$1',
}, },
coveragePathIgnorePatterns: ['/src/databases/migrations/'],
}; };

View file

@ -26,7 +26,7 @@ afterAll(async () => {
await testDb.terminate(); await testDb.terminate();
}); });
test('user-management:reset should reset DB to default user state', async () => { test.skip('user-management:reset should reset DB to default user state', async () => {
await testDb.createUser({ globalRole: globalOwnerRole }); await testDb.createUser({ globalRole: globalOwnerRole });
await Reset.run(); await Reset.run();

View file

@ -1,3 +1,2 @@
coverage
storybook-static storybook-static
**/*.stories.js **/*.stories.js

View file

@ -1,2 +1,5 @@
/** @type {import('jest').Config} */ /** @type {import('jest').Config} */
module.exports = require('../../jest.config'); module.exports = {
...require('../../jest.config'),
collectCoverageFrom: ['credentials/**/*.ts', 'nodes/**/*.ts', 'utils/**/*.ts'],
};

View file

@ -1,5 +1,5 @@
import { readFileSync, readdirSync, mkdtempSync } from 'fs'; import { readFileSync, readdirSync, mkdtempSync } from 'fs';
import { BinaryDataManager, Credentials, loadClassInIsolation } from 'n8n-core'; import { BinaryDataManager, Credentials } from 'n8n-core';
import { import {
ICredentialDataDecryptedObject, ICredentialDataDecryptedObject,
ICredentialsHelper, ICredentialsHelper,
@ -194,10 +194,9 @@ export function setup(testData: Array<WorkflowTestData> | WorkflowTestData) {
if (!loadInfo) { if (!loadInfo) {
throw new Error(`Unknown node type: ${nodeName}`); throw new Error(`Unknown node type: ${nodeName}`);
} }
const node = loadClassInIsolation( const sourcePath = loadInfo.sourcePath.replace(/^dist\//, './').replace(/\.js$/, '.ts');
path.join(process.cwd(), loadInfo.sourcePath), const nodeSourcePath = path.join(process.cwd(), sourcePath);
loadInfo.className, const node = new (require(nodeSourcePath)[loadInfo.className])() as INodeType;
) as INodeType;
nodeTypes.addNode(nodeName, node); nodeTypes.addNode(nodeName, node);
} }