From 52a70c95d5a6e87c637c3ee6160a3b0c6ded2489 Mon Sep 17 00:00:00 2001 From: dsatpm Date: Sat, 10 Oct 2026 09:51:16 -0700 Subject: [PATCH] ci(eas): build Android and iOS on every pull request to main .eas/workflows/pr-builds.yml runs two EAS build jobs on pull_request to main, cancelling an in-progress run when the branch gets a new push. They use a new "pr" profile: an Android APK with withoutCredentials (signed by the template debug keystore) and an iOS simulator build, so neither needs signing credentials. Release configuration, so prebuild, config plugins and the native compile are exercised as they ship. tests/easWorkflows.test.ts checks every workflow profile exists in eas.json and pins the pr profile to credential-free settings. `eas workflow:validate` reports the file valid. Co-Authored-By: Claude Opus 5.5 --- .eas/workflows/pr-builds.yml | 31 ++++++++++++++++++++++++++++ eas.json | 10 +++++++++ tests/easWorkflows.test.ts | 40 ++++++++++++++++++++++++++++++++++++ 3 files changed, 81 insertions(+) create mode 100644 .eas/workflows/pr-builds.yml create mode 100644 tests/easWorkflows.test.ts diff --git a/.eas/workflows/pr-builds.yml b/.eas/workflows/pr-builds.yml new file mode 100644 index 0000000..501b355 --- /dev/null +++ b/.eas/workflows/pr-builds.yml @@ -0,0 +1,31 @@ +name: PR builds + +# Builds the release configuration for both platforms on every pull request to +# main, so a change that breaks prebuild or a native compile fails on the PR +# instead of at store-build time. Uses the "pr" profile in eas.json: an Android +# APK signed with the template debug keystore and an iOS simulator build, so it +# needs no signing credentials. JS checks (typecheck, lint, jest) stay in +# .github/workflows/ci.yml. + +on: + pull_request: + branches: ['main'] + +concurrency: + cancel_in_progress: true + group: ${{ workflow.filename }}-${{ github.ref }} + +jobs: + build_android: + name: Build Android (APK) + type: build + params: + platform: android + profile: pr + + build_ios: + name: Build iOS (simulator) + type: build + params: + platform: ios + profile: pr diff --git a/eas.json b/eas.json index f62a4b7..23df4ac 100644 --- a/eas.json +++ b/eas.json @@ -11,6 +11,16 @@ "preview": { "distribution": "internal" }, + "pr": { + "distribution": "internal", + "android": { + "buildType": "apk", + "withoutCredentials": true + }, + "ios": { + "simulator": true + } + }, "production": { "autoIncrement": true } diff --git a/tests/easWorkflows.test.ts b/tests/easWorkflows.test.ts new file mode 100644 index 0000000..4a8a97e --- /dev/null +++ b/tests/easWorkflows.test.ts @@ -0,0 +1,40 @@ +import { readdirSync, readFileSync } from 'fs'; +import { join } from 'path'; + +// EAS workflow build jobs name an eas.json profile. A typo or a renamed profile +// only fails on EAS, after the PR is open. `eas workflow:validate` catches it +// too but needs a login, so this is the offline gate. +const ROOT = join(__dirname, '..'); +const DIR = join(ROOT, '.eas', 'workflows'); +const eas = JSON.parse(readFileSync(join(ROOT, 'eas.json'), 'utf8')); + +const workflows = readdirSync(DIR).filter((f) => /\.ya?ml$/.test(f)); +const profilesIn = (yml: string) => [...yml.matchAll(/^\s+profile:\s*['"]?([\w-]+)/gm)].map((m) => m[1]); + +describe('EAS workflows', () => { + it.each(workflows)('%s: every build profile exists in eas.json', (file) => { + for (const p of profilesIn(readFileSync(join(DIR, file), 'utf8'))) { + expect(Object.keys(eas.build)).toContain(p); + } + }); + + describe('pr-builds.yml', () => { + const yml = readFileSync(join(DIR, 'pr-builds.yml'), 'utf8'); + + it('runs on pull requests to main and builds both platforms with the pr profile', () => { + expect(yml).toMatch(/^on:\n\s+pull_request:\n\s+branches: \['main'\]/m); + expect(yml).toMatch(/platform: android\n\s+profile: pr/); + expect(yml).toMatch(/platform: ios\n\s+profile: pr/); + }); + + // PR builds must not need signing credentials: none are set up for iOS, + // and a store keystore has no business signing throwaway PR artifacts. + it('pr profile needs no signing credentials', () => { + const pr = eas.build.pr; + expect(pr.android).toEqual({ buildType: 'apk', withoutCredentials: true }); + expect(pr.ios).toEqual({ simulator: true }); + expect(pr.developmentClient).toBeUndefined(); + expect(pr.autoIncrement).toBeUndefined(); + }); + }); +});