-
Notifications
You must be signed in to change notification settings - Fork 31
155 lines (136 loc) · 5.87 KB
/
sync-dependencies.yml
File metadata and controls
155 lines (136 loc) · 5.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
name: sync-dependencies
on:
schedule:
- cron: '0 6 * * 1,4' # Mondays and Thursdays at 6am UTC
push:
branches: [main]
tags: ['*']
paths:
- "pyproject.toml"
- "uv.lock"
pull_request:
paths:
- "pyproject.toml"
- "uv.lock"
workflow_dispatch:
jobs:
sync-and-prepare:
runs-on: ubuntu-latest
outputs:
sync_needed: ${{ steps.check.outputs.changed }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.ref || github.ref }}
- name: ⚡ Setup uv
uses: astral-sh/setup-uv@v5
- name: 🛠️ Upgrade & Sync
run: |
# Robust repair: if the lockfile is out of sync/corrupted, fix it, then upgrade everything
uv lock || (rm uv.lock && uv lock)
uv lock --upgrade
# Sync the conda recipe
uvx pyproject2conda yaml -f pyproject.toml --output conda/meta.yaml --python-include infer
- name: 📋 Check for Changes
id: check
run: |
# 1. Capture ALL changes (for the commit logic)
RAW_STATUS=$(git status --porcelain)
# 2. Filter for USER-FACING changes (for the summary)
# We only care about uv.lock or pyproject.toml for the report
VISIBLE_CHANGES=$(echo "$RAW_STATUS" | grep -E 'uv.lock|pyproject.toml' || true)
if [ -n "$RAW_STATUS" ]; then
# ✅ TRIGGER: We always commit if anything changed (even just conda)
echo "changed=true" >> $GITHUB_OUTPUT
# 📝 SUMMARY LOGIC
if [ -n "$VISIBLE_CHANGES" ]; then
# Case A: Important stuff changed (Lockfile or pyproject)
echo "### ⚠️ Dependencies Updated" >> $GITHUB_STEP_SUMMARY
echo "The following primary files were updated:" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
echo "$VISIBLE_CHANGES" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
echo "*(Conda recipe was automatically synced in the background)*" >> $GITHUB_STEP_SUMMARY
echo "🚀 **Action:** Triggering full test suite and PR generation." >> $GITHUB_STEP_SUMMARY
else
# Case B: Only 'conda/meta.yaml' changed (Noise)
echo "### 🔄 Metadata Sync Only" >> $GITHUB_STEP_SUMMARY
echo "No core dependencies changed, but conda metadata was refreshed." >> $GITHUB_STEP_SUMMARY
echo "🚀 **Action:** Triggering PR to keep repo consistent." >> $GITHUB_STEP_SUMMARY
fi
else
# 💤 CASE 3: Absolutely nothing changed
echo "changed=false" >> $GITHUB_OUTPUT
echo "### ✅ Everything is Up-to-Date" >> $GITHUB_STEP_SUMMARY
echo "No changes detected in \`uv.lock\`." >> $GITHUB_STEP_SUMMARY
if [ "${{ github.event_name }}" == "pull_request" ] || [ "${{ startsWith(github.ref, 'refs/tags/') }}" == "true" ]; then
echo "🚀 **Action:** Standard tests will verify the state." >> $GITHUB_STEP_SUMMARY
else
echo "💤 **Action:** Skipping tests and PR creation." >> $GITHUB_STEP_SUMMARY
fi
fi
- name: 📤 Upload Updated Deps
if: steps.check.outputs.changed == 'true'
uses: actions/upload-artifact@v4
with:
name: updated-deps
retention-days: 1
path: |
uv.lock
conda/meta.yaml
run-tests:
needs: sync-and-prepare
if: needs.sync-and-prepare.outputs.sync_needed == 'true'
uses: ./.github/workflows/python-package.yml
with:
override-deps-artifact: ${{ needs.sync-and-prepare.outputs.sync_needed == 'true' && 'updated-deps' || 'null' }}
secrets: inherit
finalize:
needs: [sync-and-prepare, run-tests]
if: |
always() &&
needs.sync-and-prepare.outputs.sync_needed == 'true' &&
(needs.run-tests.result == 'success' || needs.run-tests.result == 'skipped' )
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.ref || github.ref }}
token: ${{ secrets.MAPCHETE_PAT_CONTAINER_IMAGES_TOKEN }}
- name: 📥 Download Verified Artifacts
uses: actions/download-artifact@v4
with:
name: updated-deps
- name: ⬆️ Push to Existing PR
if: github.event_name == 'pull_request'
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add uv.lock conda/meta.yaml
git commit -m "chore: sync uv.lock and conda (tests passed)" || echo "No changes"
git push origin HEAD:${{ github.event.pull_request.head.ref }}
echo "### 🚀 PR Updated" >> $GITHUB_STEP_SUMMARY
echo "Pushed verified changes to existing PR." >> $GITHUB_STEP_SUMMARY
- name: ➕ Create New Pull Request
if: github.event_name != 'pull_request'
uses: peter-evans/create-pull-request@v7
with:
token: ${{ secrets.MAPCHETE_PAT_CONTAINER_IMAGES_TOKEN }}
commit-message: "chore: update uv.lock and conda recipe"
title: "chore(deps): sync uv and conda"
body: |
## 🤖 Automated Dependency Sync
This PR updates `uv.lock` and `conda/meta.yaml` to match `pyproject.toml`.
✅ **Verification:** The full parallelized test suite passed with these new versions.
branch: "automated-dependency-sync"
delete-branch: true
assignees: ungarj
reviewers: Scartography
labels: |
dependencies
automated-pr