Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .eas/workflows/pr-builds.yml
Original file line number Diff line number Diff line change
@@ -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
10 changes: 10 additions & 0 deletions eas.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@
"preview": {
"distribution": "internal"
},
"pr": {
"distribution": "internal",
"android": {
"buildType": "apk",
"withoutCredentials": true
},
"ios": {
"simulator": true
}
},
"production": {
"autoIncrement": true
}
Expand Down
40 changes: 40 additions & 0 deletions tests/easWorkflows.test.ts
Original file line number Diff line number Diff line change
@@ -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();
});
});
});
Loading