Skip to content

Commit f535e65

Browse files
Copilotpancetta
andcommitted
Add automated dependency lock file management system
- Create automated weekly lock file update workflow - Add scripts for manual lock file generation - Document automated dependency management approach - Update source files with conservative upper bounds - Combine automated lock files with upper bounds for robust dependency management Co-authored-by: pancetta <7158893+pancetta@users.noreply.github.com>
1 parent a9b066a commit f535e65

File tree

30 files changed

+816
-91
lines changed

30 files changed

+816
-91
lines changed
Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
---
2+
name: Update Dependency Lock Files
3+
4+
on:
5+
# Run weekly on Sunday (before Monday CI run)
6+
schedule:
7+
- cron: '0 2 * * 0'
8+
# Allow manual triggering
9+
workflow_dispatch:
10+
# Run when environment files change
11+
push:
12+
paths:
13+
- 'etc/environment-*.yml'
14+
- 'pySDC/projects/*/environment.yml'
15+
- 'pyproject.toml'
16+
17+
jobs:
18+
update-lockfiles:
19+
runs-on: ubuntu-latest
20+
permissions:
21+
contents: write
22+
pull-requests: write
23+
24+
steps:
25+
- name: Checkout repository
26+
uses: actions/checkout@v4
27+
with:
28+
fetch-depth: 0
29+
30+
- name: Set up Micromamba
31+
uses: mamba-org/setup-micromamba@v1
32+
with:
33+
environment-name: lockfile-env
34+
create-args: >-
35+
python=3.11
36+
conda-lock
37+
pip-tools
38+
39+
- name: Generate lock files for etc environments
40+
shell: bash -l {0}
41+
run: |
42+
mkdir -p etc/lockfiles
43+
44+
for env_file in etc/environment-*.yml; do
45+
if [[ -f "$env_file" ]]; then
46+
base_name=$(basename "$env_file" .yml)
47+
echo "Generating lock file for $env_file..."
48+
49+
# Generate unified lock file (works across platforms)
50+
conda-lock lock --file "$env_file" \
51+
--platform linux-64 \
52+
--lockfile "etc/lockfiles/${base_name}-lock.yml" \
53+
|| echo "Warning: Failed to generate lock file for $env_file"
54+
fi
55+
done
56+
57+
- name: Generate lock files for project environments
58+
shell: bash -l {0}
59+
run: |
60+
for env_file in pySDC/projects/*/environment.yml; do
61+
if [[ -f "$env_file" ]]; then
62+
project_dir=$(dirname "$env_file")
63+
project_name=$(basename "$project_dir")
64+
65+
echo "Generating lock file for $project_name..."
66+
67+
# Create lockfiles directory in project
68+
mkdir -p "$project_dir/lockfiles"
69+
70+
# Generate lock file
71+
conda-lock lock --file "$env_file" \
72+
--platform linux-64 \
73+
--lockfile "$project_dir/lockfiles/environment-lock.yml" \
74+
|| echo "Warning: Failed to generate lock file for $project_name"
75+
fi
76+
done
77+
78+
- name: Generate pip lock file from pyproject.toml
79+
shell: bash -l {0}
80+
run: |
81+
# Generate pinned requirements from pyproject.toml
82+
pip-compile pyproject.toml --resolver=backtracking -o requirements-lock.txt \
83+
|| echo "Warning: Failed to generate pip lock file"
84+
85+
- name: Check for changes
86+
id: check_changes
87+
run: |
88+
git add -A
89+
if git diff --staged --quiet; then
90+
echo "has_changes=false" >> $GITHUB_OUTPUT
91+
echo "No lock file changes detected"
92+
else
93+
echo "has_changes=true" >> $GITHUB_OUTPUT
94+
echo "Lock files have been updated"
95+
fi
96+
97+
- name: Create Pull Request
98+
if: steps.check_changes.outputs.has_changes == 'true'
99+
uses: peter-evans/create-pull-request@v5
100+
with:
101+
token: ${{ secrets.GITHUB_TOKEN }}
102+
commit-message: 'chore: Update dependency lock files'
103+
title: '🔒 Automated dependency lock file update'
104+
body: |
105+
## Automated Lock File Update
106+
107+
This PR updates the dependency lock files with the latest compatible versions.
108+
109+
### What changed
110+
111+
Lock files have been regenerated from the source environment files and pyproject.toml.
112+
This ensures we're using the latest compatible versions of all dependencies while
113+
maintaining reproducibility.
114+
115+
### Testing
116+
117+
The CI pipeline will test these lock files to ensure all tests pass with the updated dependencies.
118+
119+
### Action Required
120+
121+
- [ ] Review the lock file changes
122+
- [ ] Check CI test results
123+
- [ ] Merge if all tests pass, or investigate failures
124+
125+
### Related Documentation
126+
127+
See [Dependency Management Guide](./docs/contrib/08_dependency_management.md) for details on our dependency strategy.
128+
129+
---
130+
131+
This PR was automatically created by the `update_lockfiles.yml` workflow.
132+
133+
**Trigger**: ${{ github.event_name }}
134+
**Workflow Run**: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
135+
branch: automated/update-lockfiles
136+
delete-branch: true
137+
labels: |
138+
automated
139+
dependencies
140+
maintenance
141+
draft: false
142+
143+
- name: Summary
144+
run: |
145+
if [[ "${{ steps.check_changes.outputs.has_changes }}" == "true" ]]; then
146+
echo "✅ Lock files updated and PR created"
147+
else
148+
echo "ℹ️ No changes to lock files"
149+
fi

CONTRIBUTING.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,7 @@ for more details. Additional guideline are also given on how to
3434
5. [Custom Implementations](./docs/contrib/04_custom_implementations.md)
3535
6. [Documenting Code](./docs/contrib/05_documenting_code.md)
3636
7. [Adding a project](./docs/contrib/06_new_project.md)
37+
8. [Release Guide](./docs/contrib/07_release_guide.md)
38+
9. [Dependency Management](./docs/contrib/08_dependency_management.md)
3739

3840
:arrow_left: [Back to main page](./README.md)

docs/contrib/02_continuous_integration.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,14 @@ When you receive an automated failure PR:
3636
1. Review the `failure_analysis.md` file attached to the PR
3737
2. Check the linked workflow run and job logs for full details
3838
3. Investigate the root cause (dependency issues, flaky tests, code bugs, etc.)
39-
4. Push fixes directly to the PR branch or close if it's a transient failure
40-
5. Test fixes locally or wait for CI to verify
41-
6. Merge when the issue is confirmed resolved
39+
4. **For dependency-related failures**: See the [dependency management guide](./08_dependency_management.md) for strategies to handle version conflicts
40+
5. Push fixes directly to the PR branch or close if it's a transient failure
41+
6. Test fixes locally or wait for CI to verify
42+
7. Merge when the issue is confirmed resolved
4243

4344
For more details, see the [automated failure handling documentation](../../.github/scripts/README.md).
4445

45-
> :bell: **Note:** These automated PRs are informational and require manual review. They help centralize failure information but don't automatically fix issues. If you can identify and fix the problem, push commits to the auto-generated branch.
46+
> :bell: **Note:** These automated PRs are informational and require manual review. They help centralize failure information but don't automatically fix issues. If you can identify and fix the problem, push commits to the auto-generated branch. Common causes of weekly failures include dependency updates—see the [dependency management guide](./08_dependency_management.md) for how to handle these.
4647
4748
## Code linting
4849

docs/contrib/06_new_project.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ name: pySDC
2323
channels:
2424
- conda-forge
2525
dependencies:
26-
- numpy
26+
- numpy>=1.15.4,<3.0
27+
- scipy>=0.17.1,<2.0
28+
- matplotlib>=3.0,<4.0
29+
- dill>=0.2.6
2730
- pip
2831
- pip:
2932
- qmat>=0.1.8
@@ -34,6 +37,11 @@ The name should stay `pySDC`. The channels cover most of the usual packages.
3437
If a package is needed that cannot be found in those channels by conda (or mamba),
3538
please add the correct channel to the list.
3639

40+
**Important**: Follow the [dependency management guidelines](./08_dependency_management.md) when specifying version constraints:
41+
- Include both **lower** and **upper** bounds for major dependencies (e.g., `numpy>=1.15.4,<3.0`)
42+
- This prevents unexpected breaking changes from major version updates while allowing minor updates
43+
- See the [dependency management guide](./08_dependency_management.md) for detailed recommendations
44+
3745
## Add tests to the project
3846

3947
In order to automatically find the tests of your project, please add the tests to a subdirectory called `tests` in the directory of your project.

0 commit comments

Comments
 (0)