Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 52 additions & 4 deletions .github/scripts/count_loc.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,38 @@ def count_lines_in_file(filepath):
"""
Count lines in a single file.
Returns tuple: (total_lines, code_lines, comment_lines, blank_lines)

Supports comment detection for multiple languages:
- Python: #
- C/C++/Java/JavaScript/Go/Rust: //, /* */
- HTML/XML: <!-- -->
- Shell: #
- CSS: /* */
"""
total_lines = 0
code_lines = 0
comment_lines = 0
blank_lines = 0

# Get file extension to determine comment style
ext = filepath.suffix.lower()

# Define comment prefixes for different languages
single_line_comments = []
if ext in ['.py', '.sh', '.bash', '.yml', '.yaml', '.toml', '.r', '.rb']:
single_line_comments = ['#']
elif ext in ['.js', '.jsx', '.ts', '.tsx', '.java', '.c', '.cpp', '.cc', '.h', '.hpp',
'.cs', '.go', '.rs', '.swift', '.kt', '.scala', '.php']:
single_line_comments = ['//', '/*', '*/']
elif ext in ['.css', '.scss', '.sass', '.less']:
single_line_comments = ['/*', '*/']
elif ext in ['.html', '.xml', '.svg']:
single_line_comments = ['<!--', '-->']
elif ext in ['.lua']:
single_line_comments = ['--']
elif ext in ['.sql']:
single_line_comments = ['--', '/*', '*/']

try:
with open(filepath, 'r', encoding='utf-8', errors='ignore') as f:
for line in f:
Expand All @@ -27,7 +53,7 @@ def count_lines_in_file(filepath):

if not stripped:
blank_lines += 1
elif stripped.startswith('#'):
elif any(stripped.startswith(comment) for comment in single_line_comments):
comment_lines += 1
else:
code_lines += 1
Expand All @@ -44,12 +70,34 @@ def count_loc(root_dir, extensions=None):
Args:
root_dir: Root directory to search
extensions: List of file extensions to include (e.g., ['.py', '.js'])
If None or 'all', counts all common programming language files.

Returns:
Dictionary with LOC statistics
"""
if extensions is None:
extensions = ['.py']
if extensions is None or (isinstance(extensions, list) and 'all' in extensions):
# Count all common programming language files
extensions = [
'.py', # Python
'.js', '.jsx', '.ts', '.tsx', # JavaScript/TypeScript
'.java', # Java
'.c', '.cpp', '.cc', '.h', '.hpp', # C/C++
'.cs', # C#
'.go', # Go
'.rs', # Rust
'.rb', # Ruby
'.php', # PHP
'.swift', # Swift
'.kt', # Kotlin
'.scala', # Scala
'.r', # R
'.sh', '.bash', # Shell
'.html', '.css', '.scss', '.sass', # Web
'.xml', '.svg', # Markup
'.sql', # SQL
'.lua', # Lua
'.yml', '.yaml', '.toml', '.json', # Config
]

root_path = Path(root_dir)

Expand Down Expand Up @@ -109,7 +157,7 @@ def main():
parser.add_argument('--root', default='.', help='Root directory to scan')
parser.add_argument('--json', help='Output JSON file path')
parser.add_argument('--extensions', nargs='+', default=['.py'],
help='File extensions to count (default: .py)')
help='File extensions to count (default: .py). Use "all" to count all languages.')

args = parser.parse_args()

Expand Down
6 changes: 3 additions & 3 deletions .github/scripts/run_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,9 +249,9 @@ def main():
results.append((file_path, success, duration, error))

if success:
print(f"{Colors.GREEN}{Colors.RESET} ({duration:.2f}s)")
print(f"{Colors.GREEN}[OK]{Colors.RESET} ({duration:.2f}s)")
else:
print(f"{Colors.RED}{Colors.RESET} ({duration:.2f}s)")
print(f"{Colors.RED}[X]{Colors.RESET} ({duration:.2f}s)")
if error:
# Print first line of error
error_line = error.split('\n')[0][:80]
Expand All @@ -277,7 +277,7 @@ def main():
print(f"{Colors.BOLD}{Colors.RED}Failed Examples:{Colors.RESET}")
for file_path, _, duration, error in failed:
rel_path = file_path.relative_to(examples_dir)
print(f" {rel_path} ({duration:.2f}s)")
print(f" [X] {rel_path} ({duration:.2f}s)")
if error:
print(f" {Colors.GRAY}{error[:MAX_ERROR_LENGTH]}{Colors.RESET}")

Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ jobs:

- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools wheel
python -m pip install --upgrade --timeout 120 --retries 5 pip setuptools wheel
# Install core dependencies needed for benchmarks
pip install numpy scipy networkx matplotlib tqdm pandas
pip install pytest pytest-benchmark
pip install --timeout 120 --retries 5 numpy scipy networkx matplotlib tqdm pandas
pip install --timeout 120 --retries 5 pytest pytest-benchmark
timeout-minutes: 10

- name: Add py3plex to PYTHONPATH
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/code-quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ jobs:

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install black ruff isort mypy types-six
python -m pip install --upgrade --timeout 120 --retries 5 pip
pip install --timeout 120 --retries 5 black ruff isort mypy types-six
# Install minimal dependencies for type checking
pip install numpy scipy networkx matplotlib rdflib tqdm bitarray pandas
pip install --timeout 120 --retries 5 numpy scipy networkx matplotlib rdflib tqdm bitarray pandas
timeout-minutes: 8

- name: Run lint checks via Makefile
Expand Down
28 changes: 0 additions & 28 deletions .github/workflows/doc-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ jobs:
timeout-minutes: 10
permissions:
contents: read
pull-requests: write

steps:
- name: Checkout code
Expand Down Expand Up @@ -53,30 +52,3 @@ jobs:
echo "COVERAGE=$COVERAGE" >> $GITHUB_ENV
echo "Documentation coverage: $COVERAGE%"
timeout-minutes: 1

- name: Comment coverage on PR
if: github.event_name == 'pull_request'
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const coverage = JSON.parse(fs.readFileSync('doc-coverage.json', 'utf8'));

const comment = `## 📚 Documentation Coverage Report

| Metric | Count | Coverage |
|--------|-------|----------|
| Functions | ${coverage.documented_functions}/${coverage.total_functions} | ${coverage.function_coverage.toFixed(1)}% |
| Classes | ${coverage.documented_classes}/${coverage.total_classes} | ${coverage.class_coverage.toFixed(1)}% |
| **Overall** | **${coverage.documented_functions + coverage.documented_classes}/${coverage.total_items}** | **${coverage.overall_coverage.toFixed(1)}%** |

![Badge](${coverage.badge_url})
`;

github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: comment
});
timeout-minutes: 2
8 changes: 4 additions & 4 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ jobs:

- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade --timeout 120 --retries 5 pip
# Install Sphinx and extensions
pip install sphinx sphinx-rtd-theme myst-parser m2r2
pip install --timeout 120 --retries 5 sphinx sphinx-rtd-theme myst-parser m2r2
# Install package dependencies for API documentation
pip install numpy scipy networkx matplotlib rdflib tqdm bitarray
pip install --timeout 120 --retries 5 numpy scipy networkx matplotlib rdflib tqdm bitarray
# Install py3plex package itself for autodoc to work
pip install -e .
pip install --timeout 120 --retries 5 -e .
timeout-minutes: 8

- name: Build Sphinx documentation
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ jobs:

- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools wheel
python -m pip install --upgrade --timeout 120 --retries 5 pip setuptools wheel
# Install numpy and scipy first to avoid potential conflicts
pip install --timeout 120 numpy scipy
pip install --timeout 120 -e .
pip install --timeout 120 --retries 5 numpy scipy
pip install --timeout 120 --retries 5 -e .
# Verify key dependencies
python -c "import numpy; print(f'numpy {numpy.__version__}')"
python -c "import scipy; print(f'scipy {scipy.__version__}')"
Expand Down
16 changes: 8 additions & 8 deletions .github/workflows/fuzzing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ jobs:

- name: Install dependencies
run: |
pip install --upgrade pip --timeout 120
pip install --timeout 120 --retries 3 pytest hypothesis
pip install --timeout 120 --retries 3 networkx numpy scipy tqdm || true
pip install -e . || true
pip install --upgrade --timeout 120 --retries 5 pip
pip install --timeout 120 --retries 5 pytest hypothesis
pip install --timeout 120 --retries 5 networkx numpy scipy tqdm || true
pip install --timeout 120 --retries 5 -e . || true
timeout-minutes: 8

- name: Run property-based fuzzing tests
Expand Down Expand Up @@ -67,10 +67,10 @@ jobs:

- name: Install dependencies
run: |
pip install --upgrade pip --timeout 120
pip install --timeout 120 --retries 3 atheris
pip install --timeout 120 --retries 3 networkx numpy scipy tqdm || true
pip install -e . || true
pip install --upgrade --timeout 120 --retries 5 pip
pip install --timeout 120 --retries 5 atheris
pip install --timeout 120 --retries 5 networkx numpy scipy tqdm || true
pip install --timeout 120 --retries 5 -e . || true
timeout-minutes: 5

- name: Run quick fuzzing campaign (60 seconds)
Expand Down
Loading