Skip to content

Commit

Permalink
Make dotnet-docker-reviewers an owner of every file
Browse files Browse the repository at this point in the history
  • Loading branch information
ellahathaway committed Aug 7, 2024
1 parent 4c7b8aa commit ef6d7f5
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 34 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/codeowners-validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ jobs:
if: always()
run: ./eng/validate-codeowners.sh ownersAreTeams

- name: Ensure each path has @dotnet/dotnet-docker-reviewers as a CODEOWNER
if: always()
run: ./eng/validate-codeowners.sh ownersIncludeDockerReviewers

- name: Check each Dockerfile for a CODEOWNER
if: always()
run: ./eng/validate-codeowners.sh dockerfilesHaveOwners
Expand Down
57 changes: 30 additions & 27 deletions CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -2,49 +2,52 @@
# See https://help.github.com/articles/about-code-owners/

### General infra ###
# '*' is excluded from the CODEOWNERS validation that runs on PRs
* @dotnet/dotnet-docker-reviewers

### Dockerfiles ###

# common paths
src/**/helix/ @dotnet/dnceng
src/**/cross*/ @dotnet/runtime-infrastructure
src/**/webassembly*/ @dotnet/runtime-infrastructure

# almalinux
src/almalinux/**/source-build/ @dotnet/source-build-internal
src/almalinux/**/source-build/ @dotnet/source-build-internal @dotnet/dotnet-docker-reviewers

# alpine
src/alpine/**/amd64/ @dotnet/source-build-internal
src/alpine/**/amd64/ @dotnet/source-build-internal @dotnet/dotnet-docker-reviewers

# azurelinux
src/azurelinux/**/android/ @dotnet/runtime-infrastructure
src/azurelinux/**/fpm/ @dotnet/runtime-infrastructure
src/azurelinux/**/opt/ @dotnet/runtime-infrastructure
src/azurelinux/**/android/ @dotnet/runtime-infrastructure @dotnet/dotnet-docker-reviewers
src/azurelinux/**/fpm/ @dotnet/runtime-infrastructure @dotnet/dotnet-docker-reviewers
src/azurelinux/**/opt/ @dotnet/runtime-infrastructure @dotnet/dotnet-docker-reviewers

# cbl-mariner
src/cbl-mariner/**/android/ @dotnet/runtime-infrastructure
src/cbl-mariner/**/fpm/ @dotnet/runtime-infrastructure
src/cbl-mariner/**/opt/ @dotnet/runtime-infrastructure
src/cbl-mariner/**/docker-testrunner/ @dotnet/dotnet-docker-reviewers
src/cbl-mariner/2.0/amd64/ @dotnet/runtime-infrastructure
src/cbl-mariner/**/android/ @dotnet/runtime-infrastructure @dotnet/dotnet-docker-reviewers
src/cbl-mariner/**/fpm/ @dotnet/runtime-infrastructure @dotnet/dotnet-docker-reviewers
src/cbl-mariner/**/opt/ @dotnet/runtime-infrastructure @dotnet/dotnet-docker-reviewers
src/cbl-mariner/**/docker-testrunner/ @dotnet/dotnet-docker-reviewers @dotnet/dotnet-docker-reviewers
src/cbl-mariner/2.0/amd64/ @dotnet/runtime-infrastructure @dotnet/dotnet-docker-reviewers

# centos
src/centos/stream9/amd64/ @dotnet/source-build-internal
src/centos/stream9/amd64/ @dotnet/source-build-internal @dotnet/dotnet-docker-reviewers

# debian
src/debian/11/amd64/ @dotnet/source-build-internal
src/debian/11/opt/arm64v8/ @dotnet/runtime-infrastructure
src/debian/12/gcc14/amd64/ @dotnet/runtime-infrastructure
src/debian/11/amd64/ @dotnet/source-build-internal @dotnet/dotnet-docker-reviewers
src/debian/11/opt/arm64v8/ @dotnet/runtime-infrastructure @dotnet/dotnet-docker-reviewers
src/debian/12/gcc14/amd64/ @dotnet/runtime-infrastructure @dotnet/dotnet-docker-reviewers

# fedora
src/fedora/**/amd64/ @dotnet/source-build-internal
src/fedora/**/amd64/ @dotnet/source-build-internal @dotnet/dotnet-docker-reviewers

# ubuntu
src/ubuntu/**/debpkg/ @dotnet/runtime-infrastructure
src/ubuntu/22.04/mlnet/ @dotnet/runtime-infrastructure
src/ubuntu/22.04/opt/arm64v8/ @dotnet/runtime-infrastructure
src/ubuntu/common/coredeps/ @dotnet/runtime-infrastructure
src/ubuntu/20.04/Dockerfile @dotnet/source-build-internal
src/ubuntu/22.04/Dockerfile @dotnet/source-build-internal
src/ubuntu/24.04/Dockerfile @dotnet/source-build-internal
src/ubuntu/**/debpkg/ @dotnet/runtime-infrastructure @dotnet/dotnet-docker-reviewers
src/ubuntu/22.04/mlnet/ @dotnet/runtime-infrastructure @dotnet/dotnet-docker-reviewers
src/ubuntu/22.04/opt/arm64v8/ @dotnet/runtime-infrastructure @dotnet/dotnet-docker-reviewers
src/ubuntu/common/coredeps/ @dotnet/runtime-infrastructure @dotnet/dotnet-docker-reviewers
src/ubuntu/20.04/Dockerfile @dotnet/source-build-internal @dotnet/dotnet-docker-reviewers
src/ubuntu/22.04/Dockerfile @dotnet/source-build-internal @dotnet/dotnet-docker-reviewers
src/ubuntu/24.04/Dockerfile @dotnet/source-build-internal @dotnet/dotnet-docker-reviewers

# common paths
# CODEOWNERS selects the last match as the owner so we list these paths last
# Otherwise these paths will be owned by a different team(s) than the ones listed below
src/**/helix/ @dotnet/dnceng @dotnet/dotnet-docker-reviewers
src/**/cross*/ @dotnet/runtime-infrastructure @dotnet/dotnet-docker-reviewers
src/**/webassembly*/ @dotnet/runtime-infrastructure @dotnet/dotnet-docker-reviewers
30 changes: 23 additions & 7 deletions eng/validate-codeowners.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
set -e

if [ $# -eq 0 ]; then
echo "No function name provided. Usage: ./validate-codeowners.sh <ownersAreTeams|pathsAreUsed|dockerfilesHaveOwners>"
echo "No function name provided. Usage: ./validate-codeowners.sh <ownersAreTeams|ownersIncludeDockerReviewers|pathsAreUsed|dockerfilesHaveOwners>"
exit 1
fi

Expand All @@ -25,7 +25,7 @@ readCodeOwnersFile() {
fi

path=$(echo "$line" | awk '{print $1}' | awk '{$1=$1};1')
owner=$(echo "$line" | awk '{print $2}' | awk '{$1=$1};1')
owners=$(echo "$line" | cut -d' ' -f2- | awk '{$1=$1};1')

# Escape periods
path=$(echo "$path" | sed 's/\./\\./g')
Expand Down Expand Up @@ -56,17 +56,20 @@ readCodeOwnersFile() {

path="^$path$"

codeOwnerEntries["$path"]="$owner"
codeOwnerEntries["$path"]="$owners"
done < "$codeOwnersFilePath"
}

ownersAreTeams() {
nonTeamOwners=()

for codeOwner in "${codeOwnerEntries[@]}"; do
if [[ "$codeOwner" != *"/"* ]]; then
nonTeamOwners+=("$codeOwner")
fi
for owners in "${codeOwnerEntries[@]}"; do
IFS=' ' read -r -a codeOwners <<< "$owners"
for owner in "${owners[@]}"; do
if [[ "$owner" != *"/"* ]]; then
nonTeamOwners+=("$owner")
fi
done
done

if [[ ${#nonTeamOwners[@]} -gt 0 ]]; then
Expand All @@ -78,6 +81,19 @@ ownersAreTeams() {
exit 0
}

ownersIncludeDockerReviewers() {
dotnetDockerReviewersTeam=("@dotnet/dotnet-docker-reviewers")

for owners in "${codeOwnerEntries[@]}"; do
if [[ ! "$owners" =~ "$dotnetDockerReviewersTeam" ]]; then
echo "At least one owner for each path in the CODEOWNERS file should be the @dotnet/dotnet-docker-reviewers team."
exit 1
fi
done

exit 0
}

pathsAreUsed() {
allFiles=$(find . -type f | sed 's/^\.//')
unusedPaths=()
Expand Down

0 comments on commit ef6d7f5

Please sign in to comment.