@@ -72,6 +72,41 @@ steps:
7272 sudo apt-get install -y dotnet-sdk-8.0
7373 displayName : " Install .NET CORE"
7474
75+ - script : |
76+ set -xe
77+ # Check for directories missing __init__.py under sonic_xcvr
78+ echo "Checking for directories missing __init__.py in sonic_xcvr..."
79+ missing_init_dirs=$(find sonic_platform_base/sonic_xcvr -type d -print | while read d; do \
80+ if [ "$d" = "sonic_platform_base/sonic_xcvr" ]; then continue; fi; \
81+ if [ ! -f "$d/__init__.py" ]; then echo "$d"; fi; \
82+ done)
83+ if [ -n "$missing_init_dirs" ]; then
84+ echo "Error: The following directories are missing __init__.py files:";
85+ echo "$missing_init_dirs";
86+ exit 1;
87+ fi
88+
89+ # Check if all directories with __init__.py are declared in setup.py
90+ echo "Checking if all sonic_xcvr packages are declared in setup.py..."
91+ undeclared_packages=""
92+ for dir in $(find sonic_platform_base/sonic_xcvr -type f -name __init__.py -exec dirname {} \; | sort -u); do
93+ pkg_name=$(echo "$dir" | sed 's/\//./g')
94+ if ! grep -q "'$pkg_name'" setup.py; then
95+ echo "Error: Package '$pkg_name' has __init__.py but is not declared in setup.py"
96+ undeclared_packages="$undeclared_packages $pkg_name"
97+ fi
98+ done
99+
100+ if [ -n "$undeclared_packages" ]; then
101+ echo ""
102+ echo "ERROR: The following packages need to be added to setup.py:"
103+ echo "$undeclared_packages"
104+ exit 1
105+ fi
106+
107+ echo "All sonic_xcvr packages are properly validated"
108+ displayName : ' Validate sonic_xcvr package structure'
109+
75110# Python 3
76111- script : |
77112 set -ex
0 commit comments