Skip to content

Commit 5eed584

Browse files
committed
CI: Check py folders for init files
1 parent 2e89add commit 5eed584

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

.github/workflows/ci-pr.yaml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,34 @@ env:
1111
# but sadly `env` can't be used either in `runs-on`.
1212

1313
jobs:
14+
validate-structure:
15+
name: Validate Python Package Structure
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v4
19+
20+
- name: Check for __init__.py files using counts
21+
run: |
22+
echo "Comparing directory count in proto with __init__.py count in py..."
23+
PROTO_BASE="proto/frequenz/api/common"
24+
PYTHON_BASE="py/frequenz/api/common" # Match the base for comparison
25+
26+
# Count directories in the specific proto path
27+
proto_dirs=$(find "$PROTO_BASE" -type d | wc -l)
28+
echo "Found $proto_dirs directories under $PROTO_BASE"
29+
30+
# Count __init__.py files in the corresponding python path
31+
py_inits=$(find "$PYTHON_BASE" -type f -name "__init__.py" | wc -l)
32+
echo "Found $py_inits '__init__.py' files under $PYTHON_BASE"
33+
34+
if [ "$proto_dirs" -ne "$py_inits" ]; then
35+
echo "Validation failed: Mismatch between proto directory count ($proto_dirs) and python __init__.py count ($py_inits)."
36+
echo "Ensure (manually!) every directory under $PROTO_BASE has a corresponding directory with __init__.py under $PYTHON_BASE."
37+
exit 1
38+
else
39+
echo "Validation successful: Proto directory count matches python __init__.py count ($proto_dirs)."
40+
fi
41+
1442
protolint:
1543
name: Check proto files with protolint
1644
runs-on: ubuntu-24.04

0 commit comments

Comments
 (0)