Skip to content

fix(build): cache-first + token-fallback for native artifact sync (M15)#20

Merged
luisguzman-adfa merged 1 commit into
mainfrom
fix/m15-build-binary-sync-fallback
Jun 19, 2026
Merged

fix(build): cache-first + token-fallback for native artifact sync (M15)#20
luisguzman-adfa merged 1 commit into
mainfrom
fix/m15-build-binary-sync-fallback

Conversation

@luisguzman-adfa

Copy link
Copy Markdown
Collaborator

Summary

Fixes tech-debt M15 (build coupled to the network for native artifacts every preBuild). :app:syncNativeArtifacts queried the GitHub API unauthenticated on every build; since jniLibs/*.so are gitignored, CI always downloads and under load hits GitHub's 60-req/hour unauthenticated limit → intermittent HTTP 403 (mislabeled "tag not found"), failing assembleDebug on unrelated PRs (e.g. #15, #16).

Changes

  • build.gradle — 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.
  • 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 from GITHUB_TOKEN/GH_TOKEN in the environment. The token is purely a rate-limit fallback, never a requirement.
  • build.gradle — clearer error that names rate-limiting and points to GITHUB_TOKEN.
  • .github/workflows/android-sanity-check.yml — job-level env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} so our CI has a token available for the fallback. secrets.GITHUB_TOKEN is provided automatically by Actions (ephemeral, repo-scoped) — nothing to create or store; forks get their own.

Notes

`: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.
@luisguzman-adfa luisguzman-adfa merged commit 4474cd2 into main Jun 19, 2026
1 check passed
@luisguzman-adfa luisguzman-adfa deleted the fix/m15-build-binary-sync-fallback branch June 23, 2026 15:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant