Skip to content

Commit

Permalink
Drop logging, but keep the "less tests" for now.
Browse files Browse the repository at this point in the history
  • Loading branch information
wayneseymour committed Sep 3, 2020
1 parent 5f566d1 commit 095ed32
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

import expect from '@kbn/expect';
import { ciRunUrl, coveredFilePath, itemizeVcs, prokPrevious, teamAssignment } from '../transforms';
import { ToolingLog } from '@kbn/dev-utils';

describe(`Transform fn`, () => {
describe(`ciRunUrl`, () => {
Expand Down Expand Up @@ -94,15 +93,11 @@ x-pack/plugins/reporting/server/browsers/extract/index.js kibana-reporting
x-pack/plugins/reporting/server/browsers/extract/unzip.js kibana-reporting
x-pack/plugins/reporting/server/browsers/index.ts kibana-reporting
x-pack/plugins/reporting/server/browsers/install.ts kibana-reporting`;
const log = new ToolingLog({
level: 'info',
writeTo: process.stdout,
});

describe(`with a coveredFilePath of ${coveredFilePath}`, () => {
const expected = 'kibana-reporting';
it(`should resolve to ${expected}`, () => {
const actual = teamAssignment(getData)(teamAssignmentsPath)(log)(obj);
const actual = teamAssignment(getData)(teamAssignmentsPath)(obj);
const { team } = actual;
expect(team).to.eql(expected);
});
Expand Down
4 changes: 2 additions & 2 deletions src/dev/code_coverage/ingest_coverage/ingest.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const { Client } = require('@elastic/elasticsearch');
import { createFailError } from '@kbn/dev-utils';
import { RESEARCH_CI_JOB_NAME } from './constants';
import { errMsg, redact, whichIndex } from './ingest_helpers';
import { pretty, green } from './utils';
import { pretty, green, pink } from './utils';
import { right, left } from './either';

const node = process.env.ES_HOST || 'http://localhost:9200';
Expand Down Expand Up @@ -75,7 +75,7 @@ const sendMsg = (actuallySent, redactedEsHostUrl, payload) => {
return `### ${actuallySent ? 'Sent' : 'Fake Sent'}:
${redactedEsHostUrl ? `\t### ES Host: ${redactedEsHostUrl}` : ''}
\t### Index: ${green(index)}
\t### payload.body: ${body}
\t### payload.body: ${pink(body)}
`;
};

Expand Down
2 changes: 1 addition & 1 deletion src/dev/code_coverage/ingest_coverage/process.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const addTestRunnerAndStaticSiteUrl = pipe(testRunner, staticSite(staticSiteUrlB
const transform = (jsonSummaryPath) => (log) => (vcsInfo) => (teamAssignmentsPath) => {
const objStream = jsonStream(jsonSummaryPath).on('done', noop);
const itemizeVcsInfo = itemizeVcs(vcsInfo);
const assignTeams = teamAssignment(getData)(teamAssignmentsPath)(log);
const assignTeams = teamAssignment(getData)(teamAssignmentsPath);

const jsonSummary$ = (_) => objStream.on('node', '!.*', _);

Expand Down
44 changes: 12 additions & 32 deletions src/dev/code_coverage/ingest_coverage/transforms.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
*/

import * as Either from './either';
import { fromNullable } from './maybe';
import { always, id, noop, pink, pretty } from './utils';
import * as Maybe from './maybe';
import { always, id, noop } from './utils';

const maybeTotal = (x) => (x === 'total' ? Either.left(x) : Either.right(x));

Expand Down Expand Up @@ -97,38 +97,18 @@ export const coveredFilePath = (obj) => {
.fold(withoutCoveredFilePath, (coveredFilePath) => ({ ...obj, coveredFilePath }));
};

const globalAndMultiline = 'gm';
const findLine = (x) => (xs) => xs.match(new RegExp(`${x}.*$`, globalAndMultiline));
const findTeam = (x) => x.match(/.+\s{1,3}(.+)$/, globalAndMultiline);
const assign = (getData) => (teamAssignmentsPath) => (x) =>
getData(teamAssignmentsPath)
.match(new RegExp(`${x}.*$`, 'gm'))[0]
.match(/.+\s{1,3}(.+)$/, 'gm')[1];

export const teamAssignment = (getData) => (teamAssignmentsPath) => (log) => (obj) => {
log.debug(`\n### Team Assignment - obj from stream: \n\t${pink(pretty(obj))}`);
export const teamAssignment = (getData) => (teamAssignmentsPath) => (obj) => {
const { coveredFilePath } = obj;
const assignTeams = assign(getData)(teamAssignmentsPath);

const findPath = findLine(coveredFilePath);
log.debug(`\n### Team Assignment - coveredFilePath: \n\t${pink(coveredFilePath)}`);
const data = getData(teamAssignmentsPath);
const size = data.split('\n').length;
log.debug(`\n### Team Assignment - assignments count: \n\t${pink(size)}`);

const found = findPath(data);
log.debug(`\n### Team Assignment - foundLine: \n\t${pink(found)}`);
const line = found[0];
log.debug(`\n### Team Assignment - line: \n\t${pink(line)}`);

const foundTeam = findTeam(line);
log.debug(`\n### Team Assignment - foundTeam: \n\t${pink(foundTeam)}`);
const team = foundTeam[1];
log.debug(`\n### Team Assignment - team: \n\t${pink(team)}`);

// const team = getData(teamAssignmentsPath)
// .match(new RegExp(`${coveredFilePath}.*$`, 'gm'))[0]
// .match(/.+\s{1,3}(.+)$/, 'gm')[1];

return {
team,
...obj,
};
return Either.fromNullable(obj.isTotal).isRight()
? obj
: { team: assignTeams(coveredFilePath), ...obj };
};
export const ciRunUrl = (obj) =>
Either.fromNullable(process.env.CI_RUN_URL).fold(always(obj), (ciRunUrl) => ({
Expand Down Expand Up @@ -159,7 +139,7 @@ export const itemizeVcs = (vcsInfo) => (obj) => {
};

const mutateVcs = (x) => (vcs.commitMsg = truncateMsg(x));
fromNullable(commitMsg).map(mutateVcs);
Maybe.fromNullable(commitMsg).map(mutateVcs);

const vcsCompareUrl = process.env.FETCHED_PREVIOUS
? `${comparePrefix()}/${process.env.FETCHED_PREVIOUS}...${sha}`
Expand Down

0 comments on commit 095ed32

Please sign in to comment.