Dependency Canary #9
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: Dependency Canary | |
| on: | |
| schedule: | |
| - cron: "0 0 * * *" # Every day at 00:00 UTC | |
| workflow_dispatch: # Allow manual triggering | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| issues: write | |
| jobs: | |
| canary: | |
| name: Upgrade and Validate Dependencies | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout unstable branch | |
| uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1 | |
| with: | |
| ref: unstable | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@d0cc045d04ccac9d8b7881df0226f9e82c39688e # v6.8.0 | |
| with: | |
| version: "0.9.26" | |
| enable-cache: true | |
| - name: Upgrade dependencies | |
| run: | | |
| # 1. Solve the environment and upgrade everything | |
| uv lock --upgrade | |
| # 2. Export the lockfile to requirements formats | |
| # --no-dev gives you the production stack | |
| uv export --no-dev -o requirements.txt | |
| # --all-extras and --dev (or --all-groups) gives you the full stack | |
| uv export --all-extras --dev -o requirements-dev.txt | |
| - name: Install the project | |
| run: uv sync --all-extras --dev | |
| - name: Install Graphviz | |
| run: sudo apt-get update && sudo apt-get install -y graphviz | |
| - name: Run type check (mypy) | |
| run: uv run mypy --config-file=pyproject.toml . | |
| - name: Run tests (pytest) | |
| env: | |
| CI: 1 | |
| run: uv run pytest tests | |
| - name: Alert on Failure | |
| if: failure() | |
| uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7.1.0 | |
| with: | |
| script: | | |
| const { data: issues } = await github.rest.issues.listForRepo({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| state: 'open', | |
| labels: 'dependency-canary' | |
| }); | |
| const issueTitle = '🚨 Dependency Canary Failure'; | |
| const issueBody = `The scheduled dependency canary workflow failed. This likely means an upstream dependency update broke the build. | |
| **Run Details:** | |
| - **Run ID:** [${context.runId}](https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}) | |
| - **Workflow:** ${context.workflow} | |
| - **Event:** ${context.eventName} | |
| Please investigate the logs to identify the breaking package.`; | |
| if (issues.length === 0) { | |
| await github.rest.issues.create({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| title: issueTitle, | |
| body: issueBody, | |
| labels: ['dependency-canary', 'bug'] | |
| }); | |
| } else { | |
| await github.rest.issues.createComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: issues[0].number, | |
| body: `The canary failed again. [See run ${context.runId}](https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId})` | |
| }); | |
| } | |
| - name: Create Pull Request | |
| if: success() | |
| uses: peter-evans/create-pull-request@22a9089034f40e5a961c8808d113e2c98fb63676 # v7.0.11 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| commit-message: "chore: upgrade dependencies (canary)" | |
| branch: dependency-canary-updates | |
| base: unstable | |
| title: "📦 Dependency Canary: Upgrade all packages" | |
| body: | | |
| This PR was automatically generated by the Dependency Canary workflow. | |
| It upgrades all dependencies to their latest compatible versions and validates them with `mypy` and `pytest`. | |
| **Changes:** | |
| - Updated `uv.lock` | |
| - Updated `requirements.txt` | |
| - Updated `requirements-dev.txt` | |
| All checks passed successfully. | |
| labels: | | |
| dependencies | |
| automated-pr |