-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[QA] Canonical Code Coverage Teams and CODEOWNERS Assignment
Add the first draft of the TEAMS assignments, including defaults for code coverage and teams. After this PR, we will add a CI check to verify all defined paths have CODEOWNERship, and possibly code coverage teams. Resovles #72692
- Loading branch information
1 parent
2e37239
commit 12f2e50
Showing
13 changed files
with
617 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
require('../src/setup_node_env'); | ||
require('../src/dev/code_owners').defineCodeOwners(); |
42 changes: 42 additions & 0 deletions
42
src/dev/code_coverage/ingest_coverage/__tests__/maybe.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
import { fromNullable } from '../maybe'; | ||
|
||
describe(`maybe algebraic datatype functions`, () => { | ||
const pluck = (x) => (obj) => obj[x]; | ||
const attempt = (obj) => fromNullable(obj).map(pluck('detail')); | ||
describe(`helpers`, () => { | ||
it(`'fromNullable' should be a fn`, () => { | ||
expect(typeof fromNullable).toBe('function'); | ||
}); | ||
}); | ||
describe(`'fromNullable`, () => { | ||
it(`should continue processing if a truthy is calculated`, () => { | ||
expect(attempt({ detail: 'x' }).value()).toBe('x'); | ||
}); | ||
it(`should drop processing if a falsey is calculated`, () => { | ||
const obj = { | ||
a: 'abc', | ||
}; | ||
|
||
expect(fromNullable(obj.b).inspect()).toBe('[Nothing]'); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
import expect from '@kbn/expect'; | ||
import { hasPath } from '../'; | ||
|
||
describe(`Code Owners`, () => { | ||
describe(`hasPath predicate fn`, () => { | ||
const iterable = new Map(); | ||
iterable.set('a', 'b'); | ||
it(`should return true if the iterable has the path`, () => { | ||
expect(hasPath('a')(iterable)).to.be(true); | ||
}); | ||
it(`should return false if the iterable does not have the path`, () => { | ||
expect(hasPath('b')(iterable)).to.be(false); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
import { createWriteStream } from 'fs'; | ||
|
||
const preamble = `# GitHub CODEOWNERS definition | ||
# Identify which groups will be pinged by changes to different parts of the codebase. | ||
# For more info, see https://help.github.com/articles/about-codeowners/\n\n`; | ||
|
||
export const flush = (codeOwnersPath) => (log) => (ownersMap) => { | ||
log.info(`\n### Flushing to codeOwnersPath: \n\t${codeOwnersPath}`); | ||
const file = createWriteStream(codeOwnersPath); | ||
|
||
file.write(preamble); | ||
|
||
ownersMap.forEach(({ owners /* review, teams */ }, key) => { | ||
file.write(`${key} ${owners.join(' ')}\n`); | ||
}); | ||
|
||
file.end(); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
import { pretty } from '../code_coverage/ingest_coverage/utils'; | ||
|
||
export function teamName(githubHandle) { | ||
const prefix = /elastic\//; | ||
const dropElastic = dropPrefix(prefix); | ||
const prefixedWithES = prefixed(prefix); | ||
|
||
return prefixedWithES(githubHandle) ? dropElastic(githubHandle) : githubHandle; | ||
} | ||
|
||
export function hasPath(path) { | ||
return (iterable) => !!iterable.has(path); | ||
} | ||
|
||
function prefixed(prefix) { | ||
return (x) => prefix.test(x); | ||
} | ||
|
||
function dropPrefix(prefix) { | ||
return (x) => x.replace(prefix, ''); | ||
} | ||
export function hasOverrides(xs) { | ||
return !!Array.isArray(xs[0]); | ||
} | ||
|
||
export function printMap(map) { | ||
map.forEach((value, key) => console.log(key + ' -> ' + pretty(value))); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
import { resolve } from 'path'; | ||
import { run } from '@kbn/dev-utils'; | ||
import { parseSourceOfTruth } from './parse'; | ||
import { sourceOfTruth as sot } from './owners_source_of_truth'; | ||
import { flush } from './flush'; | ||
|
||
const ROOT = resolve(__dirname, '../../..'); | ||
const resolveFromRoot = resolve.bind(null, ROOT); | ||
const codeownersPath = process.env.CODEOWNERS_PATH || resolveFromRoot('.github/draft_CODEOWNERS'); | ||
const description = ` | ||
Create .github/CODEOWNERS file from authoritative source | ||
`; | ||
|
||
export const defineCodeOwners = () => { | ||
run(({ log }) => flush(codeownersPath)(log)(parseSourceOfTruth(log)(sot)), { description }); | ||
}; |
Oops, something went wrong.