fix(build): cache-first + token-fallback for native artifact sync (M15)#20
Merged
Merged
Conversation
`:app:syncNativeArtifacts` (a preBuild dependency) queried the GitHub API
UNAUTHENTICATED on every build to resolve the pinned binaries release. Because
jniLibs/*.so are gitignored, CI always downloads, so under load it hit GitHub's
60-requests/hour unauthenticated limit and got HTTP 403 (mislabeled as "tag not
found"), failing assembleDebug on unrelated PRs (tech-debt M15).
- Cache-first: check the local tag tracker + required .so files + manifest
BEFORE any network call. If the pinned binaries are already present, skip the
API and the download entirely (decouples steady-state builds from the network).
- Fallback auth (no token required for forks): fetch the release metadata
UNAUTHENTICATED first; only if that fails retry WITH a token read from
GITHUB_TOKEN/GH_TOKEN in the environment. An independent fork builds fine
without ever defining a token; the token is only a rate-limit fallback.
- Clearer error that names rate-limiting and points to GITHUB_TOKEN.
NOTE: to give CI a token for the fallback, the workflow needs a one-line
job-level env (GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}) on the gradle steps.
That .github/workflows change is delivered separately because the push token
lacks the `workflow` scope.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes tech-debt M15 (build coupled to the network for native artifacts every
preBuild).:app:syncNativeArtifactsqueried the GitHub API unauthenticated on every build; sincejniLibs/*.soare gitignored, CI always downloads and under load hits GitHub's 60-req/hour unauthenticated limit → intermittent HTTP 403 (mislabeled "tag not found"), failingassembleDebugon unrelated PRs (e.g. #15, #16).Changes
build.gradle— cache-first: check the local tag tracker + required.sofiles + manifest before any network call. If the pinned binaries are already present, skip the API and the download entirely.build.gradle— fallback auth (no token required for forks): fetch the release metadata unauthenticated first so an independent fork builds without any token; only if that fails (e.g. 403 rate-limit) retry with a token read fromGITHUB_TOKEN/GH_TOKENin the environment. The token is purely a rate-limit fallback, never a requirement.build.gradle— clearer error that names rate-limiting and points toGITHUB_TOKEN..github/workflows/android-sanity-check.yml— job-levelenv: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}so our CI has a token available for the fallback.secrets.GITHUB_TOKENis provided automatically by Actions (ephemeral, repo-scoped) — nothing to create or store; forks get their own.Notes
ninja_manifest.jsonis unchanged — cache-first only avoids the network call, not the integrity verification.