From b589beff6e7b95927c036de15ae9e0a4da7f03ed Mon Sep 17 00:00:00 2001 From: Antoine Toulme Date: Fri, 7 Feb 2025 11:42:07 -0800 Subject: [PATCH] [chore] remove bash script to check codeowners, use githubgen (#37779) #### Description This bash script precedes githubgen. It is now outdated and can be removed in favor of githubgen moving forward. #### Link to tracking issue Fixes #37757 --- .github/workflows/build-and-test.yml | 11 -- .github/workflows/scripts/check-codeowners.sh | 103 ------------------ 2 files changed, 114 deletions(-) delete mode 100755 .github/workflows/scripts/check-codeowners.sh diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index f5a439b7af4d..554a3848d909 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -52,17 +52,6 @@ jobs: - run: make genotelcontribcol - name: Check Collector Module Version run: ./.github/workflows/scripts/check-collector-module-version.sh - check-codeowners: - runs-on: ubuntu-24.04 - needs: [setup-environment] - steps: - - uses: actions/checkout@v4 - - name: Check Code Owner Existence - run: ./.github/workflows/scripts/check-codeowners.sh check_code_owner_existence - - name: Check Component Existence - run: ./.github/workflows/scripts/check-codeowners.sh check_component_existence - - name: Validate Allowlist entries - run: ./.github/workflows/scripts/check-codeowners.sh check_entries_in_allowlist lint-matrix: strategy: fail-fast: false diff --git a/.github/workflows/scripts/check-codeowners.sh b/.github/workflows/scripts/check-codeowners.sh deleted file mode 100755 index 1aee6d5ecc7e..000000000000 --- a/.github/workflows/scripts/check-codeowners.sh +++ /dev/null @@ -1,103 +0,0 @@ -#!/usr/bin/env bash - -# Copyright The OpenTelemetry Authors -# SPDX-License-Identifier: Apache-2.0 - -# -# verifies: -# 1. That vendor components are assigned to owner(s) -# 2. That list of vendor components (in $CODEOWNERS) still exists -# in the project -# -set -eu -o pipefail - -CODEOWNERS=".github/CODEOWNERS" -ALLOWLIST=".github/ALLOWLIST" - -# Get component folders from the project and checks that they have -# an owner in $CODEOWNERS -check_code_owner_existence() { - MODULES=$(find . -type f -name "go.mod" -exec dirname {} \; | sort | grep -E '^./' | cut -c 3-) - MISSING_COMPONENTS=0 - ALLOW_LIST_COMPONENTS=0 - for module in ${MODULES} - do - # For a component path exact match, need to add '/ ' to end of module as - # each line in the CODEOWNERS file is of the format: - # /.. - # This is because the path separator at end is dropped while searching for - # modules and there is at least 1 space separating the path from the owners. - if ! grep -q "^$module/ " "$CODEOWNERS"; then - # If there is not an exact match to component path, there might be a parent folder - # which has an owner and would therefore implicitly include the component - # path as a sub folder e.g. 'internal/aws' is listed in $CODEOWNERS - # which accounts for internal/aws/awsutil, internal/aws/k8s etc. - PREFIX_MODULE_PATH=$(echo $module | cut -d/ -f 1-2) - if ! grep -wq "^$PREFIX_MODULE_PATH/ " "$CODEOWNERS"; then - # Check if it is a known component that is waiting on an owner - if grep -wq "$module" "$ALLOWLIST"; then - ((ALLOW_LIST_COMPONENTS=ALLOW_LIST_COMPONENTS+1)) - echo "pass: \"$module\" not included in CODEOWNERS but in the ALLOWLIST" - else - ((MISSING_COMPONENTS=MISSING_COMPONENTS+1)) - echo "FAIL: \"$module\" not included in CODEOWNERS" - fi - fi - fi - done - if [ "$ALLOW_LIST_COMPONENTS" -gt 0 ]; then - echo "---" - echo "pass: there are $ALLOW_LIST_COMPONENTS components not included in CODEOWNERS but known in the ALLOWLIST" - fi - if [ "$MISSING_COMPONENTS" -gt 0 ]; then - echo "---" - echo "FAIL: there are $MISSING_COMPONENTS components not included in CODEOWNERS and not known in the ALLOWLIST" - exit 1 - fi -} - -# Checks that components specified in $CODEOWNERS still exist in the project -check_component_existence() { - NOT_EXIST_COMPONENTS=0 - while IFS= read -r line - do - if [[ $line =~ ^[^#\*] ]]; then - COMPONENT_PATH=$(echo "$line" | cut -d" " -f1) - if [ ! -e "$COMPONENT_PATH" ]; then - echo "\"$COMPONENT_PATH\" does not exist as specified in CODEOWNERS" - ((NOT_EXIST_COMPONENTS=NOT_EXIST_COMPONENTS+1)) - fi - fi - done <"$CODEOWNERS" - echo "there are $NOT_EXIST_COMPONENTS component(s) that do not exist as specified in CODEOWNERS" - if [ "$NOT_EXIST_COMPONENTS" -gt 0 ]; then - exit 1 - fi -} - -check_entries_in_allowlist() { - NOT_ORPHANED=0 - while IFS= read -r line - do - if [[ $line =~ ^[^#] ]]; then - COMPONENT_PATH=$(echo "$line" | cut -d" " -f1) - if grep -wq "^$COMPONENT_PATH/ " "$CODEOWNERS"; then - echo "\"$COMPONENT_PATH\" has an entry in CODEOWNERS file" - ((NOT_ORPHANED=NOT_ORPHANED+1)) - fi - fi - done <"$ALLOWLIST" - echo "There are $NOT_ORPHANED component(s) that have owners but are present in ALLOWLIST file" - if [ "$NOT_ORPHANED" -gt 0 ]; then - exit 1 - fi -} - -if [[ "$1" == "check_code_owner_existence" ]]; then - check_code_owner_existence -elif [[ "$1" == "check_component_existence" ]]; then - check_component_existence -elif [[ "$1" == "check_entries_in_allowlist" ]]; then - check_entries_in_allowlist -fi -