chore(deps): sync uv and conda #114
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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: Scartography | |
| reviewers: ungarj | |
| labels: | | |
| dependencies | |
| automated-pr |