Skip to content

[ci] Submit Gradle dependency graphs to GitHub - #13600

Merged
jonathanpeppers merged 4 commits into
mainfrom
jonathanpeppers-gradle-dependency-submission
Nov 17, 2026
Merged

jonathanpeppers merged 4 commits into
mainfrom
jonathanpeppers-gradle-dependency-submission

Conversation

@jonathanpeppers

@jonathanpeppers jonathanpeppers commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

GitHub's dependency graph for this repository has no Maven packages. Dependabot version updates read the direct dependencies in our build.gradle files, but Dependabot alerts and security updates use the dependency graph. As a result, we get no alerts for transitive Gradle dependencies, such as Guava, Bouncy Castle, and Commons Lang under com.android.tools.build:manifest-merger.

Add a workflow that uses gradle/actions/dependency-submission to submit a graph for each Gradle project:

  • The project list comes from the gradle entries in .github/dependabot.yml, so there is only one list to maintain.
  • The JDK version and Java source/target versions come from Configuration.props. The Gradle version comes from build-tools/gradle/gradle/wrapper/gradle-wrapper.properties.
  • -PjavaSourceVer and -PjavaTargetVer are required. Without them, src/manifestmerger defaults to Java 8 and its Java 17 manifest-merger dependency is silently left out of the graph.
  • Gradle always runs with a read-only token and uploads the graphs as artifacts. On pushes to main, a separate job with contents: write submits them with download-and-submit. That job never runs Gradle, so build scripts, plugins, and dependencies never see a write token. Pull requests and manual runs only generate the graphs, so build changes are checked before merge.

GitHub's automatic dependency submission also runs on this repository and fails on NuGet restore with NETSDK1139, because the Android workload is not installed. There is no setting to turn it off for one ecosystem only, so it must be disabled in the repository settings. This workflow does not need it.

Validation:

  • Generated graphs locally for all seven Gradle projects with the same Gradle dependency graph plugin, and checked that the dependency reports have no FAILED entries. The src/manifestmerger graph includes manifest-merger:32.5.1, Guava 33.4.0-jre, Bouncy Castle 1.80.2, and Commons Lang 3.16.0.
  • Ran the setup step locally with yq 4.54.3 (the version on ubuntu-latest): it produced the seven directories, JDK 25.0.4.1, Java 17, and Gradle 9.6.0. The | unique filter was added after that run.
  • The pull_request run on this PR exercises the full workflow in generate-and-upload mode. The submit job runs only after merge.

Copilot AI balanced review requested due to automatic review settings November 17, 2026 20:12

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The workflow exposes repository-write credentials to pull-request and manual runs that only generate artifacts, allowing checked-out Gradle build scripts to use unnecessary write access.

1 open issue
What changed in this PR

Adds Gradle dependency submission to GitHub so Dependabot can detect vulnerabilities in transitive Maven dependencies used by .NET for Android.

Changes:

  • Derives the seven Gradle project roots from Dependabot configuration.
  • Reuses repository-defined JDK, Java compatibility, and Gradle versions.
  • Submits graphs on matching pushes to main; pull requests and manual runs generate and upload artifacts only.
File Description
.github/​workflows/​gradle-dependency-submission.yml Adds configuration discovery and per-project dependency graph generation with event-based submission.

Review effort: Balanced

@jonathanpeppers jonathanpeppers added the ready-to-review This PR is ready to review/merge, I think any CI failures are just flaky (ignorable). label Nov 17, 2026
@jonathanpeppers

Copy link
Copy Markdown
Member Author

The pull_request run worked as intended. I checked the logs and the seven uploaded graph artifacts:

  • Versions: Microsoft JDK 25.0.4.1, Gradle 9.6.0, and -PjavaSourceVer=17 -PjavaTargetVer=17, all read from the repository files.
  • Graphs: One graph per Gradle project in .github/dependabot.yml, with 2 to 145 packages each. The src/manifestmerger graph contains manifest-merger 32.5.1, Guava 33.4.0-jre, Bouncy Castle 1.80.2, and Commons Lang 3.16.0.
  • Errors: The logs have no FAILED dependencies, no Could not resolve messages, and no warnings.
  • No submission: The run uploaded the graphs as artifacts and did not submit them, as intended for a PR.

The submission to GitHub runs for the first time on the first push to main after merge.

@jonathanpeppers

Copy link
Copy Markdown
Member Author

@dalexsoto review

@dalexsoto dalexsoto left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 7bc0f671 against main at 0f521ede (1 file). This is a static, read-only review.

The matrix setup is solid. The dependabot.yml, Configuration.props and Gradle wrapper parsing all fail loudly, all seven build roots resolve, and only push submits.

One blocker, about the permissions point raised earlier:

  • The Gradle job still has a write token on pull_request and workflow_dispatch. permissions: contents: write (lines 64-65) applies to the only job that runs Gradle, on every trigger. persist-credentials: false keeps the token out of .git/config, but gradle/actions/dependency-submission takes github-token (default ${{ github.token }}), which the runner exposes as the INPUT_GITHUB-TOKEN environment variable. The action then starts Gradle without overriding the environment, so build scripts, plugins and dependencies evaluated from an unmerged same-repo branch can still read a contents: write token, even in generate-and-upload mode. Fork PRs are fine because GitHub downgrades their token.

Suggested fix: run the matrix with contents: read and dependency-graph: generate-and-upload for every event, and add a separate push-only job (needs: the matrix, contents: write, dependency-graph: download-and-submit) that never runs Gradle.

Non-blocking: once a job holds a write token, consider SHA-pinning gradle/actions/dependency-submission.

@jonathanpeppers

Copy link
Copy Markdown
Member Author

@dalexsoto review

@dalexsoto dalexsoto left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 2017f257 against main at fa31e490 (merge base 5f53a70f; of the 6 newer main commits only an r8 bump touches a Gradle file, and it does not affect the parsed inputs). This is a static, read-only review.

The previous blocker is fixed in 2017f25. Gradle now runs only in the dependency-graph matrix with contents: read and generate-and-upload. The only contents: write job is the push-only dependency-submission job, which has no checkout and uses download-and-submit, a mode that returns before Gradle is provisioned or run in gradle/actions v6. That job downloads the same run's artifacts with the runner's artifact token, so it does not need actions: read. The matrix artifacts get distinct names because the job correlator includes the matrix value. The dependabot.yml roots, the Configuration.props versions and the Gradle wrapper version are unchanged on current main.

Two small non-blocking suggestions: add cache-disabled: true to the submit step, which otherwise uses the action's default proprietary enhanced cache provider, and consider pinning gradle/actions/dependency-submission to a commit SHA in the job that holds the write token.

@jonathanpeppers
jonathanpeppers merged commit 0402b6b into main Nov 17, 2026
13 of 16 checks passed
@jonathanpeppers
jonathanpeppers deleted the jonathanpeppers-gradle-dependency-submission branch November 17, 2026 22:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-to-review This PR is ready to review/merge, I think any CI failures are just flaky (ignorable).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants