|
| 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 |
0 commit comments