ci: add automated PR for dep upgrades
This commit is contained in:
82
.ci/merge_versions.py
Normal file
82
.ci/merge_versions.py
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
import re
|
||||||
|
import sys
|
||||||
|
|
||||||
|
|
||||||
|
def parse_toml_deps(content):
|
||||||
|
"""Extract dependency versions from TOML content."""
|
||||||
|
deps = {}
|
||||||
|
in_deps = False
|
||||||
|
for line in content.split("\n"):
|
||||||
|
if line.strip() == "[dependencies]":
|
||||||
|
in_deps = True
|
||||||
|
continue
|
||||||
|
if in_deps and line.strip().startswith("["):
|
||||||
|
break
|
||||||
|
if in_deps and "=" in line and not line.strip().startswith("#"):
|
||||||
|
# Parse: package = "version" or package = { version = "version", ... }
|
||||||
|
match = re.match(r'^\s*(\S+)\s*=\s*["{].*version\s*=\s*"([^"]+)"', line)
|
||||||
|
if match:
|
||||||
|
deps[match.group(1)] = match.group(2)
|
||||||
|
else:
|
||||||
|
match = re.match(r'^\s*(\S+)\s*=\s*"([^"]+)"', line)
|
||||||
|
if match:
|
||||||
|
deps[match.group(1)] = match.group(2)
|
||||||
|
return deps
|
||||||
|
|
||||||
|
|
||||||
|
def update_template_versions(template_content, new_versions):
|
||||||
|
"""Update versions in template while preserving Liquid syntax."""
|
||||||
|
lines = template_content.split("\n")
|
||||||
|
result = []
|
||||||
|
|
||||||
|
for line in lines:
|
||||||
|
updated_line = line
|
||||||
|
# Skip Liquid control flow lines
|
||||||
|
if re.match(r"^\s*{%", line):
|
||||||
|
result.append(line)
|
||||||
|
continue
|
||||||
|
|
||||||
|
# Check if this line has a dependency with version
|
||||||
|
for dep_name, new_version in new_versions.items():
|
||||||
|
# Match: package = "version"
|
||||||
|
pattern1 = rf'^(\s*{re.escape(dep_name)}\s*=\s*")([^"]+)(".*)'
|
||||||
|
match = re.match(pattern1, updated_line)
|
||||||
|
if match:
|
||||||
|
updated_line = f"{match.group(1)}{new_version}{match.group(3)}"
|
||||||
|
break
|
||||||
|
|
||||||
|
# Match: package = { version = "version", ... }
|
||||||
|
pattern2 = rf'^(\s*{re.escape(dep_name)}\s*=\s*{{[^}}]*version\s*=\s*")([^"]+)(".*)'
|
||||||
|
match = re.match(pattern2, updated_line)
|
||||||
|
if match:
|
||||||
|
updated_line = f"{match.group(1)}{new_version}{match.group(3)}"
|
||||||
|
break
|
||||||
|
|
||||||
|
result.append(updated_line)
|
||||||
|
|
||||||
|
return "\n".join(result)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
# Read files
|
||||||
|
with open(sys.argv[1], "r") as f:
|
||||||
|
upgraded_content = f.read()
|
||||||
|
|
||||||
|
with open(sys.argv[2], "r") as f:
|
||||||
|
template_content = f.read()
|
||||||
|
|
||||||
|
# Extract new versions from upgraded Cargo.toml
|
||||||
|
new_versions = parse_toml_deps(upgraded_content)
|
||||||
|
|
||||||
|
print(f"Found {len(new_versions)} dependencies:")
|
||||||
|
for dep, version in sorted(new_versions.items()):
|
||||||
|
print(f" {dep} -> {version}")
|
||||||
|
|
||||||
|
# Update template while preserving Liquid syntax
|
||||||
|
updated_template = update_template_versions(template_content, new_versions)
|
||||||
|
|
||||||
|
# Write updated template
|
||||||
|
with open(sys.argv[2], "w") as f:
|
||||||
|
f.write(updated_template)
|
||||||
|
|
||||||
|
print("\n✅ Template updated successfully!")
|
||||||
9
.env.liquid
Normal file
9
.env.liquid
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
# API Configuration
|
||||||
|
{{env_prefix}}_API_KEY=your-secret-api-key-here
|
||||||
|
|
||||||
|
# Server Configuration
|
||||||
|
{{env_prefix}}_HOST=127.0.0.1
|
||||||
|
{{env_prefix}}_PORT={{default_port}}
|
||||||
|
|
||||||
|
# Logging
|
||||||
|
{{env_prefix}}_LOG_LEVEL={{default_log_level}}
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
|
.ci/
|
||||||
|
.github/
|
||||||
target/
|
target/
|
||||||
Cargo.lock
|
Cargo.lock
|
||||||
.env
|
.env
|
||||||
|
|||||||
7
.github/workflows/dependency-check.yml
vendored
7
.github/workflows/dependency-check.yml
vendored
@@ -93,10 +93,11 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
echo "📝 Updating template with new dependency versions..."
|
echo "📝 Updating template with new dependency versions..."
|
||||||
|
|
||||||
# Copy the upgraded Cargo.toml back to template
|
# Run the merge script from .ci directory
|
||||||
cp ../dep-check-test/Cargo.toml Cargo.toml.liquid
|
python3 .ci/merge_versions.py dep-check-test/Cargo.toml Cargo.toml.liquid
|
||||||
|
|
||||||
# Show what changed
|
# Show what changed
|
||||||
|
echo ""
|
||||||
echo "Changes to template:"
|
echo "Changes to template:"
|
||||||
git diff Cargo.toml.liquid
|
git diff Cargo.toml.liquid
|
||||||
working-directory: ${{ github.workspace }}/axum-template
|
working-directory: ${{ github.workspace }}/axum-template
|
||||||
@@ -161,7 +162,7 @@ jobs:
|
|||||||
UPGRADE_SUMMARY=$(cat upgrade-output.txt | grep -A 100 "name.*old req.*compatible.*latest.*new req" | head -n 20)
|
UPGRADE_SUMMARY=$(cat upgrade-output.txt | grep -A 100 "name.*old req.*compatible.*latest.*new req" | head -n 20)
|
||||||
|
|
||||||
cat > pr-body.txt << 'EOF'
|
cat > pr-body.txt << 'EOF'
|
||||||
This PR contains automated dependency upgrades that have been tested and verified.
|
This PR contains automated dependency upgrades that have been tested with `cargo check` and `cargo build`
|
||||||
|
|
||||||
## Changes
|
## Changes
|
||||||
|
|
||||||
|
|||||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,3 +1,4 @@
|
|||||||
/target
|
/target
|
||||||
.env*
|
.env*
|
||||||
!.env.example
|
!.env.example
|
||||||
|
!.env.liquid
|
||||||
|
|||||||
Reference in New Issue
Block a user