Skip to content

armgit / ente

Public Imported from GitHub
0

💚 End-to-end encrypted cloud for everything.

Add Dependabot follow-up agent

Manav Rathi24d360b60c3c
diff --git a/.github/scripts/dependencies.md b/.github/scripts/dependencies.md
new file mode 100644
index 0000000000..fc11bc9d37
--- /dev/null
+++ b/.github/scripts/dependencies.md
@@ -0,0 +1,13 @@
+Get this Dependabot PR ready to merge while preserving existing application behavior.
+
+Read previous reports and current CI results first.
+
+Investigate the release changes and how we use each dependency. Classify which updates are safe, explain the risks, and flag useful new features.
+
+Fix mechanical problems and make necessary coordinated changes across consumers and platforms. Investigate updates that need adaptation rather than immediately excluding them. Respect deliberate pins and existing exceptions.
+
+Validate the changes with relevant builds and tests. Where existing coverage is insufficient, establish what would give us confidence; for migrations, compare behavior before and after the update.
+
+Keep the updates we can confidently accept. Leave out those requiring a human decision or further work, without blocking independent updates.
+
+The harness commits your changes and posts your final response as a PR comment. Explain what changed, what was verified, and what was withheld and why. If there’s nothing new to do or report, return an empty final response; the harness skips empty responses.
diff --git a/.github/workflows/dependabot-follow-up.yml b/.github/workflows/dependabot-follow-up.yml
new file mode 100644
index 0000000000..5a40718fc8
--- /dev/null
+++ b/.github/workflows/dependabot-follow-up.yml
@@ -0,0 +1,206 @@
+name: Dependabot follow-up
+
+on:
+ schedule:
+ - cron: "30 2-14 * * 1-5"
+ workflow_dispatch:
+
+permissions:
+ contents: read
+ actions: read
+ checks: read
+ pull-requests: read
+
+concurrency:
+ group: dependabot-follow-up
+ cancel-in-progress: false
+
+jobs:
+ find:
+ if: github.repository == 'ente/ente' && github.ref == 'refs/heads/main'
+ runs-on: ubuntu-latest
+ outputs:
+ prs: ${{ steps.find.outputs.result }}
+ steps:
+ - id: find
+ uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
+ with:
+ script: |
+ const repo = context.repo;
+ const { data: { workflow_runs: previous } } = await github.rest.actions.listWorkflowRuns({
+ ...repo, workflow_id: "dependabot-follow-up.yml", branch: "main", status: "success", per_page: 1,
+ });
+ const since = previous[0]?.created_at || "";
+ const selected = [];
+ for (const pr of await github.paginate(github.rest.pulls.list, { ...repo, state: "open", base: "main", per_page: 100 })) {
+ if (pr.draft || pr.user.login !== "dependabot[bot]" ||
+ pr.head.repo?.full_name !== `${repo.owner}/${repo.repo}` || !pr.head.ref.startsWith("dependabot/cargo/")) continue;
+ const runs = await github.paginate(github.rest.actions.listWorkflowRuns, {
+ ...repo, workflow_id: "ci.yml", event: "pull_request", head_sha: pr.head.sha, per_page: 100,
+ });
+ if (!runs.length || runs.some(run => run.status !== "completed")) continue;
+ const comments = await github.paginate(github.rest.issues.listComments, {
+ ...repo, issue_number: pr.number, since: since || undefined, per_page: 100,
+ });
+ if (pr.created_at > since || runs.some(run => run.updated_at > since) ||
+ comments.some(comment => comment.user.login !== "ente-agent[bot]" && comment.created_at > since)) {
+ selected.push({ number: pr.number, head: pr.head.sha });
+ }
+ }
+ return selected;
+
+ work:
+ needs: find
+ if: needs.find.outputs.prs != '[]'
+ runs-on: ubuntu-latest
+ timeout-minutes: 60
+ environment:
+ name: pr-review
+ deployment: false
+ strategy:
+ fail-fast: false
+ matrix:
+ pr: ${{ fromJSON(needs.find.outputs.prs) }}
+ steps:
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
+ with:
+ persist-credentials: false
+
+ - name: Prepare agent
+ env:
+ PR_URL: https://github.com/${{ github.repository }}/pull/${{ matrix.pr.number }}
+ run: |
+ mkdir -p "$RUNNER_TEMP/codex" "$RUNNER_TEMP/result"
+ touch "$RUNNER_TEMP/result/report.md"
+ { printf '%s\n\n' "$PR_URL"; cat .github/scripts/dependencies.md; } > "$RUNNER_TEMP/prompt.md"
+ cat > "$RUNNER_TEMP/codex/config.toml" <<EOF
+ project_doc_max_bytes = 0
+ [skills]
+ include_instructions = false
+ [projects."$GITHUB_WORKSPACE"]
+ trust_level = "untrusted"
+ [permissions.update]
+ extends = ":workspace"
+ [permissions.update.filesystem.":workspace_roots"]
+ ".git" = "write"
+ [permissions.update.network]
+ enabled = true
+ EOF
+ sudo rm -rf /usr/share/dotnet
+ sudo apt-get update
+ sudo apt-get install -y libwebkit2gtk-4.1-dev libssl-dev libayatana-appindicator3-dev librsvg2-dev libvulkan-dev glslc libdbus-1-dev dbus gnome-keyring libglib2.0-bin
+
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
+ with:
+ ref: ${{ matrix.pr.head }}
+ fetch-depth: 0
+ persist-credentials: false
+
+ - name: Prepare dependency update
+ uses: openai/codex-action@86365089eb2b84e0a8fb0717b304f8bdcb13b20e # v1.12
+ env:
+ GH_TOKEN: ${{ github.token }}
+ CARGO_HOME: /tmp/cargo
+ with:
+ codex-home: ${{ runner.temp }}/codex
+ prompt-file: ${{ runner.temp }}/prompt.md
+ output-file: ${{ runner.temp }}/result/report.md
+ openai-api-key: ${{ secrets.OPENAI_API_KEY }}
+ responses-api-endpoint: ${{ format('{0}/responses', vars.OPENAI_BASE_URL) }}
+ model: ${{ vars.CODEX_MODEL }}
+ effort: high
+ permission-profile: update
+ safety-strategy: drop-sudo
+ allow-users: "*"
+
+ - name: Collect changes
+ env:
+ PR_HEAD: ${{ matrix.pr.head }}
+ run: |
+ git add -A
+ git diff --binary --no-ext-diff --no-textconv "$PR_HEAD" > "$RUNNER_TEMP/result/changes.patch"
+
+ - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
+ with:
+ name: dependency-${{ matrix.pr.number }}
+ path: ${{ runner.temp }}/result
+ overwrite: true
+
+ publish:
+ needs: [find, work]
+ if: ${{ !cancelled() && needs.find.result == 'success' && needs.find.outputs.prs != '[]' }}
+ runs-on: ubuntu-latest
+ permissions:
+ contents: read
+ environment:
+ name: pr-review
+ deployment: false
+ strategy:
+ fail-fast: false
+ matrix:
+ pr: ${{ fromJSON(needs.find.outputs.prs) }}
+ steps:
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
+ with:
+ ref: ${{ matrix.pr.head }}
+ persist-credentials: false
+
+ - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
+ with:
+ name: dependency-${{ matrix.pr.number }}
+ path: ${{ runner.temp }}/result
+
+ - uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
+ id: app
+ with:
+ client-id: ${{ secrets.ENTE_AGENT_GH_CLIENT_ID }}
+ private-key: ${{ secrets.ENTE_AGENT_GH_APP_PRIVATE_KEY }}
+ permission-contents: write
+ permission-pull-requests: write
+
+ - name: Publish changes and report
+ uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
+ env:
+ PR_NUMBER: ${{ matrix.pr.number }}
+ PR_HEAD: ${{ matrix.pr.head }}
+ with:
+ github-token: ${{ steps.app.outputs.token }}
+ script: |
+ const { readFileSync } = require("node:fs");
+ const { execFileSync } = require("node:child_process");
+ const git = (...args) => execFileSync("git", args, { maxBuffer: 50 * 1024 * 1024 });
+ const repo = context.repo;
+ const head = process.env.PR_HEAD;
+ const { data: pr } = await github.rest.pulls.get({ ...repo, pull_number: Number(process.env.PR_NUMBER) });
+ if (pr.state !== "open" || pr.draft || pr.head.sha !== head || pr.base.ref !== "main" ||
+ pr.user.login !== "dependabot[bot]" || pr.head.repo?.full_name !== `${repo.owner}/${repo.repo}` ||
+ !pr.head.ref.startsWith("dependabot/cargo/")) return;
+ const result = `${process.env.RUNNER_TEMP}/result`;
+ const report = readFileSync(`${result}/report.md`, "utf8").trim();
+ if (readFileSync(`${result}/changes.patch`).length) {
+ git("apply", "--index", `${result}/changes.patch`);
+ const files = git("diff", "--cached", "--raw", "-z", "--no-renames").toString().split("\0").slice(0, -1);
+ const additions = [], deletions = [];
+ for (let i = 0; i < files.length; i += 2) {
+ const [oldMode, mode, , , status] = files[i].slice(1).split(" ");
+ const path = files[i + 1];
+ if (status === "D") deletions.push({ path });
+ else {
+ if (mode !== "100644" && mode !== "100755" ||
+ mode !== oldMode && !(oldMode === "000000" && mode === "100644"))
+ throw new Error(`Cannot publish file mode change: ${path}`);
+ additions.push({ path, contents: git("show", `:${path}`).toString("base64") });
+ }
+ }
+ await github.graphql(`mutation($input: CreateCommitOnBranchInput!) { createCommitOnBranch(input: $input) { commit { oid } } }`, {
+ input: {
+ branch: { repositoryNameWithOwner: `${repo.owner}/${repo.repo}`, branchName: pr.head.ref },
+ expectedHeadOid: head, message: { headline: "Prepare dependency updates" },
+ fileChanges: { additions, deletions },
+ },
+ });
+ }
+ if (report) await github.rest.issues.createComment({
+ ...repo, issue_number: pr.number,
+ body: `## Dependency update\n\n[Agent run](${context.serverUrl}/${repo.owner}/${repo.repo}/actions/runs/${context.runId}) · Commit ${head.slice(0, 7)}\n\n${report}`,
+ });
diff --git a/.github/workflows/pr-approval.yml b/.github/workflows/pr-approval.yml
index 01ba2fd09a..47a993a192 100644
--- a/.github/workflows/pr-approval.yml
+++ b/.github/workflows/pr-approval.yml
@@ -243,7 +243,7 @@ jobs:
if: steps.quota.outputs.result == 'true'
id: codex
timeout-minutes: 35
- uses: openai/codex-action@86365089eb2b84e0a8fb0717b304f8bdcb13b20e # v1
+ uses: openai/codex-action@86365089eb2b84e0a8fb0717b304f8bdcb13b20e # v1.12
with:
codex-home: ${{ runner.temp }}/pr-review-codex
working-directory: ${{ github.workspace }}/review