Skip to content
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

Bootstrap OWNERS files for the repository #15454

Merged
merged 2 commits into from Jul 25, 2017

Conversation

stevekuznetsov
Copy link
Contributor

In order to satisfy the blunderbuss and approvers plugins for the k8s CI
systems we are about to adopt, we need to add OWNERS files to
directories in Origin. The files contain reviewers and approvers for the
directory. Reviewers are members that blunderbuss will assign pull
requests to; approvers are members from whom an LGTM is necessary to
merge a pull request that touches files in the directory.

The inital values in these OWNERS files are generated by looking at the
most active contributors to any directory. The top ten most active
contributors to a directory are listed as reviewers; the top five most
active contributors that have merge rights with the current system are
listed as approvers.

Signed-off-by: Steve Kuznetsov skuznets@redhat.com

/cc @smarterclayton @Kargakis @deads2k

PTAL @openshift/team-project-committers

In order to satisfy the blunderbuss and approvers plugins for the k8s CI
systems we are about to adopt, we need to add OWNERS files to
directories in Origin. The files contain reviewers and approvers for the
directory. Reviewers are members that blunderbuss will assign pull
requests to; approvers are members from whom an LGTM is necessary to
merge a pull request that touches files in the directory.

The inital values in these OWNERS files are generated by looking at the
most active contributors to any directory. The top ten most active
contributors to a directory are listed as reviewers; the top five most
active contributors that have merge rights with the current system are
listed as approvers.

Signed-off-by: Steve Kuznetsov <skuznets@redhat.com>
@openshift-merge-robot
Copy link
Contributor

Labelling this PR as size/XXL

@openshift-merge-robot openshift-merge-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. retest-not-required-docs-only labels Jul 25, 2017
@stevekuznetsov
Copy link
Contributor Author

Look at that ... bot is eager to serve.

@stevekuznetsov
Copy link
Contributor Author

I have a local listing of the members of Team Origin Committers (merge rights with Rosie) and a local mapping of e-mail to GitHub handle ... but otherwise the script I used to generate these is below:

generate_owners.sh
#!/bin/bash

set -o errexit
set -o nounset
set -o pipefail

# github_id_for_email returns the GitHub
# username for an e-mail
function github_id_for_email() {
	local email="$1"
	python -c "from json import load; print load(open('/tmp/github_usernames')).get('${email}', '')"
}

mergers=( $( cat /tmp/mergers ) )
# can_merge determines if a user identified
# by their RedHat email can merge to Origin
function can_merge() {
	local email="$1"
	for merger in "${mergers[@]}"; do
		if [[ "${email}" == "${merger}" ]]; then
			return 0
		fi
	done

	return 1
}

# reviewers returns the GitHub username of
# the top 10 committers for a directory
function reviewers() {
	local directory="$1"
	for committer in $( committers "${directory}" 10 ); do
		github_id="$( github_id_for_email "${committer}" )"
		if [[ -n "${github_id}" ]]; then
			echo "${github_id}"
		fi
	done
}

# approvers returns the GitHub username of
# the top 5 committers for a directory that
# have merge rights to Origin using the Rosie
# system
function approvers() {
	local directory="$1"
	local count=0
	for committer in $( committers "${directory}" 20 ); do
		if can_merge "${committer}"; then
			github_id="$( github_id_for_email "${committer}" )"
			if [[ -n "${github_id}" ]]; then
				echo "${github_id}"
				count="$(( count + 1 ))"
			fi
			if [[ "${count}" == "5" ]]; then
				return
			fi
		fi
	done
}

# committers returns the full name of
# the top N committers for a directory
function committers() {
	local directory="$1"
	local amount="$2"
	git log --pretty=%ae -- "${directory}" | \
		grep -v openshiftbot | \
		sort | uniq -c | sort -hr | \
		head -n "${amount}" | awk '{ print $2 }'
}

# generate_owners generates the OWNERS
# file for a given directory
function generate_owners() {
	local directory="$1"
	local owners="${directory}/OWNERS"
	rm -f "${owners}"
	touch "${owners}"
	echo "reviewers:" >> "${owners}"
	for reviewer in $( reviewers "${directory}" ); do
		echo "  - ${reviewer}" >> "${owners}"
	done

	echo "approvers:" >> "${owners}"
	for approver in $( approvers "${directory}" ); do
		echo "  - ${approver}" >> "${owners}"
	done
}

pushd /home/skuznets/Documents/go/src/github.com/openshift/origin
generate_owners '.'

for directory in 'examples' 'hack' 'images' 'tools' 'test' 'pkg' 'cmd'; do
	generate_owners "${directory}"
	for subdirectory in $( find ${directory} -mindepth 1 -maxdepth 1 -type d ); do
		generate_owners "${subdirectory}"
	done
done

popd

@stevekuznetsov
Copy link
Contributor Author

To be clear as well ... I expect team leads will edit the existing files and add more as they see fit. We only require these values as a bootstrap.

Signed-off-by: Steve Kuznetsov <skuznets@redhat.com>
@eparis
Copy link
Member

eparis commented Jul 25, 2017

[merge]

@eparis eparis merged commit 198b66f into openshift:master Jul 25, 2017
@smarterclayton
Copy link
Contributor

Retroactive LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
retest-not-required-docs-only size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants