Skip to content
Open
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
152 changes: 152 additions & 0 deletions .github/actions/generate_dependabot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
#!/usr/bin/env python3
import os
import glob
import itertools
import yaml

def find_repo_root(start_path):
"""
Find the repository root by looking for common indicators
like .git directory or spksrc directory
"""
current_path = os.path.abspath(start_path)

while current_path != os.path.dirname(current_path): # Not at filesystem root
# Check for .git directory (most reliable)
if os.path.isdir(os.path.join(current_path, '.git')):
return current_path

# Check for spksrc directory (specific to your project)
if os.path.isdir(os.path.join(current_path, 'spksrc')):
return current_path

# Check for common project files
for indicator in ['.gitignore', 'README.md', 'LICENSE']:
if os.path.isfile(os.path.join(current_path, indicator)):
# Verify spksrc exists at this level
if os.path.isdir(os.path.join(current_path, 'spksrc')):
return current_path

current_path = os.path.dirname(current_path)

raise RuntimeError("Could not find repository root")

# Find absolute directory path of the script
script_dir = os.path.dirname(os.path.abspath(__file__))

# Find the repository root dynamically
repo_root = find_repo_root(script_dir)

# The repository root IS the spksrc root (no subdirectory needed)
spksrc_root = repo_root

# Debug information
# print(f"🔍 Script location: {script_dir}")
# print(f"🔍 Repository root: {repo_root}")
# print(f"🔍 spksrc root: {spksrc_root}")

# Verify key directories exist
# test_dirs = ["spk", "native"]
# for test_dir in test_dirs:
# test_path = os.path.join(spksrc_root, test_dir)
# if os.path.isdir(test_path):
# print(f"✅ Found directory: {test_path}")
# else:
# print(f"❌ Missing directory: {test_path}")

# Configuration
IGNORED_PACKAGES = ["pip", "Cython", "msgpack"]

globs = [
"spk/python*/crossenv/requirements-default.txt",
"spk/python*/src/requirements-abi3.txt",
"spk/python*/src/requirements-crossenv.txt",
"spk/python*/src/requirements-pure.txt",
"native/python*/src/requirements.txt"
]

# Test glob patterns to see what they find
# print(f"\n🔍 Testing glob patterns:")
# for pattern in globs:
# full_pattern = os.path.join(spksrc_root, pattern)
# matches = glob.glob(full_pattern)
# print(f" Pattern: {pattern}")
# print(f" Full path: {full_pattern}")
# print(f" Matches: {len(matches)}")
# if matches:
# for match in matches[:3]: # Show first 3 matches
# print(f" - {match}")
# if len(matches) > 3:
# print(f" ... and {len(matches) - 3} more")
# print()

# Iterate on each glob patterns based on spksrc_root
paths = itertools.chain.from_iterable(
glob.glob(os.path.join(spksrc_root, pattern)) for pattern in globs
)

updates = []
# found_files = [] # For debugging

for req_file in paths:
# found_files.append(req_file)
filename = os.path.basename(req_file)

# Debug: show path calculation
# print(f"🔍 Processing: {req_file}")
# print(f" Relative to repo_root: {os.path.relpath(req_file, repo_root)}")
# print(f" Directory (absolute): {os.path.dirname(req_file)}")
# print(f" Filename: {filename}")

# Créer la liste des packages à ignorer
ignore_list = []
for package in IGNORED_PACKAGES:
ignore_list.append({
"dependency-name": package,
"update-types": ["version-update:semver-major", "version-update:semver-minor", "version-update:semver-patch"]
})

updates.append({
"package-ecosystem": "pip",
"directory": os.path.dirname(req_file),
"requirements-file": filename,
"schedule": {
"interval": "weekly"
},
"groups": {
"all-python-deps": {
"patterns": ["*"]
}
},
"ignore": ignore_list
})

# Debug information
# print(f"🔍 Found {len(found_files)} requirements files:")
# for file in found_files:
# print(f" - {file}")

# print(f"🔍 Generated {len(updates)} dependabot updates")

dependabot_config = {
"version": 2,
"updates": updates
}

# Relative output to .github/dependabot.yml
output_path = os.path.join(repo_root, ".github", "dependabot.yml")
os.makedirs(os.path.dirname(output_path), exist_ok=True)

# Write the configuration
with open(output_path, "w") as f:
yaml.dump(dependabot_config, f, sort_keys=False, default_flow_style=False, indent=2)

print(f"✅ dependabot.yml generated at: {output_path}")

# Show a preview of the generated content
# print("\n📋 Generated content preview:")
# print("=" * 50)
# with open(output_path, "r") as f:
# content = f.read()
# print(content[:500] + ("..." if len(content) > 500 else ""))
# print("=" * 50)
56 changes: 56 additions & 0 deletions .github/workflows/generate-dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Generate Dependabot Config

on:
workflow_dispatch: # allow to manually execute within GitHub
schedule:
- cron: '0 2 * * 1' # Every Monday at 2 AM UTC (optional)
push:
paths:
- 'spk/python*/crossenv/requirements-default.txt'
- 'spk/python*/src/requirements-*.txt'
- 'native/python*/src/requirements.txt'
- '.github/actions/generate_dependabot.py'
- '.github/workflows/generate-dependabot.yml'

jobs:
generate:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install PyYAML

- name: Run generate_dependabot.py
run: |
python .github/actions/generate_dependabot.py

- name: Create Pull Request
uses: peter-evans/create-pull-request@v6
with:
commit-message: "🤖 Auto-generate updated dependabot.yml"
branch: auto/update-dependabot-config
title: "🤖 Auto-update dependabot.yml"
body: |
## Auto-generated Dependabot Configuration Update

This PR updates the `.github/dependabot.yml` configuration file based on the current Python requirements files found in the repository.

### Scanned Files
- `spk/python*/src/requirements-*.txt`
- `native/python*/src/requirements.txt`

### Configuration
- **Schedule**: Weekly updates
- **Grouping**: All Python dependencies grouped together per package

---
*Auto-generated by [generate_dependabot.py](.github/actions/generate_dependabot.py)*
19 changes: 11 additions & 8 deletions native/python310/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,21 @@ PYTHON = $(WORK_DIR)/install/usr/local/bin/python3
PIP = $(WORK_DIR)/install/usr/local/bin/pip
PIP_NATIVE = $(WORK_DIR)/../../../native/$(PKG_NAME)/work-native/install/usr/local/bin/pip

PIP_VERSION = "24.3.1"
PIP_WHEELS = setuptools==80.9.0
PIP_WHEELS += wheel==0.45.1
PIP_WHEELS += crossenv==1.5.0
REQUIREMENTS = src/requirements.txt
PIP_WHEEL = $(shell grep -h -E "(^pip|^)[<>=]=" $(wildcard $(REQUIREMENTS)))

.PHONY: python310_native_post_install
python310_native_post_install: $(WORK_DIR)/python-native.mk
@$(MSG) Installing pip
@$(RUN) wget https://bootstrap.pypa.io/get-pip.py
@$(RUN) $(PYTHON) get-pip.py "pip==$(PIP_VERSION)" --no-setuptools --no-wheel --disable-pip-version-check
@$(MSG) Installing setuptools, wheel, cffi and crossenv
@$(PIP) --disable-pip-version-check install $(PIP_WHEELS)
ifeq ($(PIP_WHEEL),)
@$(MSG) Installing latest pip
@$(RUN) $(PYTHON) get-pip.py --no-setuptools --no-wheel --disable-pip-version-check
else
@$(MSG) Installing $(PIP_WHEEL)
@$(RUN) $(PYTHON) get-pip.py "$(PIP_WHEEL)" --no-setuptools --no-wheel --disable-pip-version-check
endif
@$(MSG) Installing wheels from requirements file
@$(PIP) --disable-pip-version-check install -r $(REQUIREMENTS)

$(WORK_DIR)/python-native.mk:
@echo PIP=$(PIP_NATIVE) >> $@
4 changes: 4 additions & 0 deletions native/python310/src/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
pip==24.3.1
setuptools==80.9.0
wheel==0.45.1
crossenv==1.5.0
19 changes: 11 additions & 8 deletions native/python311/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,21 @@ PYTHON = $(WORK_DIR)/install/usr/local/bin/python3
PIP = $(WORK_DIR)/install/usr/local/bin/pip
PIP_NATIVE = $(WORK_DIR)/../../../native/$(PKG_NAME)/work-native/install/usr/local/bin/pip

PIP_VERSION = "24.3.1"
PIP_WHEELS = setuptools==80.9.0
PIP_WHEELS += wheel==0.45.1
PIP_WHEELS += crossenv==1.5.0
REQUIREMENTS = src/requirements.txt
PIP_WHEEL = $(shell grep -h -E "(^pip|^)[<>=]=" $(wildcard $(REQUIREMENTS)))

.PHONY: python311_native_post_install
python311_native_post_install: $(WORK_DIR)/python-native.mk
@$(MSG) Installing pip
@$(RUN) wget https://bootstrap.pypa.io/get-pip.py
@$(RUN) $(PYTHON) get-pip.py "pip==$(PIP_VERSION)" --no-setuptools --no-wheel --disable-pip-version-check
@$(MSG) Installing setuptools, wheel, cffi and crossenv
@$(PIP) --disable-pip-version-check install $(PIP_WHEELS)
ifeq ($(PIP_WHEEL),)
@$(MSG) Installing latest pip
@$(RUN) $(PYTHON) get-pip.py --no-setuptools --no-wheel --disable-pip-version-check
else
@$(MSG) Installing $(PIP_WHEEL)
@$(RUN) $(PYTHON) get-pip.py "$(PIP_WHEEL)" --no-setuptools --no-wheel --disable-pip-version-check
endif
@$(MSG) Installing wheels from requirements file
@$(PIP) --disable-pip-version-check install -r $(REQUIREMENTS)

$(WORK_DIR)/python-native.mk:
@echo PIP=$(PIP_NATIVE) >> $@
4 changes: 4 additions & 0 deletions native/python311/src/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
pip==24.3.1
setuptools==80.9.0
wheel==0.45.1
crossenv==1.5.0
19 changes: 11 additions & 8 deletions native/python312/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,21 @@ PYTHON = $(WORK_DIR)/install/usr/local/bin/python3
PIP = $(WORK_DIR)/install/usr/local/bin/pip
PIP_NATIVE = $(WORK_DIR)/../../../native/$(PKG_NAME)/work-native/install/usr/local/bin/pip

PIP_VERSION = "24.3.1"
PIP_WHEELS = setuptools==80.9.0
PIP_WHEELS += wheel==0.45.1
PIP_WHEELS += crossenv==1.5.0
REQUIREMENTS = src/requirements.txt
PIP_WHEEL = $(shell grep -h -E "(^pip|^)[<>=]=" $(wildcard $(REQUIREMENTS)))

.PHONY: python312_native_post_install
python312_native_post_install: $(WORK_DIR)/python-native.mk
@$(MSG) Installing pip
@$(RUN) wget https://bootstrap.pypa.io/get-pip.py
@$(RUN) $(PYTHON) get-pip.py "pip==$(PIP_VERSION)" --no-setuptools --no-wheel --disable-pip-version-check
@$(MSG) Installing setuptools, wheel, cffi and crossenv
@$(PIP) --disable-pip-version-check install $(PIP_WHEELS)
ifeq ($(PIP_WHEEL),)
@$(MSG) Installing latest pip
@$(RUN) $(PYTHON) get-pip.py --no-setuptools --no-wheel --disable-pip-version-check
else
@$(MSG) Installing $(PIP_WHEEL)
@$(RUN) $(PYTHON) get-pip.py "$(PIP_WHEEL)" --no-setuptools --no-wheel --disable-pip-version-check
endif
@$(MSG) Installing wheels from requirements file
@$(PIP) --disable-pip-version-check install -r $(REQUIREMENTS)

$(WORK_DIR)/python-native.mk:
@echo PIP=$(PIP_NATIVE) >> $@
4 changes: 4 additions & 0 deletions native/python312/src/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
pip==24.3.1
setuptools==80.9.0
wheel==0.45.1
crossenv==1.5.0
19 changes: 11 additions & 8 deletions native/python313/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,21 @@ PYTHON = $(WORK_DIR)/install/usr/local/bin/python3
PIP = $(WORK_DIR)/install/usr/local/bin/pip
PIP_NATIVE = $(WORK_DIR)/../../../native/$(PKG_NAME)/work-native/install/usr/local/bin/pip

PIP_VERSION = "24.3.1"
PIP_WHEELS = setuptools==80.9.0
PIP_WHEELS += wheel==0.45.1
PIP_WHEELS += crossenv==1.5.0
REQUIREMENTS = src/requirements.txt
PIP_WHEEL = $(shell grep -h -E "(^pip|^)[<>=]=" $(wildcard $(REQUIREMENTS)))

.PHONY: python313_native_post_install
python313_native_post_install: $(WORK_DIR)/python-native.mk
@$(MSG) Installing pip
@$(RUN) wget https://bootstrap.pypa.io/get-pip.py
@$(RUN) $(PYTHON) get-pip.py "pip==$(PIP_VERSION)" --no-setuptools --no-wheel --disable-pip-version-check
@$(MSG) Installing setuptools, wheel, cffi and crossenv
@$(PIP) --disable-pip-version-check install $(PIP_WHEELS)
ifeq ($(PIP_WHEEL),)
@$(MSG) Installing latest pip
@$(RUN) $(PYTHON) get-pip.py --no-setuptools --no-wheel --disable-pip-version-check
else
@$(MSG) Installing $(PIP_WHEEL)
@$(RUN) $(PYTHON) get-pip.py "$(PIP_WHEEL)" --no-setuptools --no-wheel --disable-pip-version-check
endif
@$(MSG) Installing wheels from requirements file
@$(PIP) --disable-pip-version-check install -r $(REQUIREMENTS)

$(WORK_DIR)/python-native.mk:
@echo PIP=$(PIP_NATIVE) >> $@
4 changes: 4 additions & 0 deletions native/python313/src/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
pip==24.3.1
setuptools==80.9.0
wheel==0.45.1
crossenv==1.5.0