Compare commits

...
3 changed files with 64 additions and 29 deletions

No files matched your search

@@ -1,11 +1,13 @@
import { Android, BuildPhase, BuildPhaseResult } from '@expo/eas-build-job';
import { Android, BuildPhase, BuildPhaseResult, Workflow } from '@expo/eas-build-job';
import { vol } from 'memfs';
import { createTestAndroidJob } from '../../__tests__/utils/job';
import { createMockLogger } from '../../__tests__/utils/logger';
import { prebuildAsync } from '../../common/prebuild';
import { BuildContext } from '../../context';
import { Datadog } from '../../datadog';
import { restoreCredentials } from '../../android/credentials';
import { resolveRuntimeVersionForExpoUpdatesIfConfiguredAsync } from '../../utils/expoUpdates';
import { uploadEmbeddedBundleAsync } from '../../utils/expoUpdatesEmbedded';
import androidBuilder from '../android';
import { runBuilderWithHooksAsync } from '../common';
@@ -274,6 +276,39 @@ describe(androidBuilder, () => {
expect(runBuilderWithHooksAsync).toHaveBeenCalledWith(ctx, expect.any(Function));
});
it('resolves the Expo Updates runtime version before prebuild', async () => {
const order: string[] = [];
jest
.mocked(resolveRuntimeVersionForExpoUpdatesIfConfiguredAsync)
.mockImplementationOnce(async () => {
order.push('resolve-runtime-version');
return null;
});
jest.mocked(prebuildAsync).mockImplementationOnce(async () => {
order.push('prebuild');
});
const ctx = new BuildContext(
{
...createTestAndroidJob(),
type: Workflow.MANAGED,
},
{
workingdir: '/workingdir',
logBuffer: { getLogs: () => [], getPhaseLogs: () => [] },
logger: createMockLogger(),
env: {
__API_SERVER_URL: 'http://api.expo.test',
},
uploadArtifact: jest.fn(),
}
);
await androidBuilder(ctx);
expect(order).toEqual(['resolve-runtime-version', 'prebuild']);
});
it('runs the embedded bundle upload phase when EAS_UPDATE_EXPERIMENTAL_UPLOAD_EMBEDDED_BUNDLE is set', async () => {
const ctx = new BuildContext(createTestAndroidJob(), {
workingdir: '/workingdir',
+14 -14
View File
@@ -55,6 +55,20 @@ async function buildAsync(ctx: BuildContext<Android.Job>): Promise<void> {
const workingDirectory = ctx.getReactNativeProjectDirectory();
const hasNativeCode = ctx.job.type === Workflow.GENERIC;
const resolvedExpoUpdatesRuntimeVersion = await ctx.runBuildPhase(
BuildPhase.CALCULATE_EXPO_UPDATES_RUNTIME_VERSION,
async () => {
return await resolveRuntimeVersionForExpoUpdatesIfConfiguredAsync({
cwd: ctx.getReactNativeProjectDirectory(),
logger: ctx.logger,
appConfig: await ctx.appConfig,
platform: ctx.job.platform,
workflow: ctx.job.type,
env: ctx.env,
});
}
);
if (hasNativeCode) {
await ctx.runBuildPhase(BuildPhase.FIX_GRADLEW, async () => {
await ensureLFLineEndingsInGradlewScript(ctx);
@@ -100,20 +114,6 @@ async function buildAsync(ctx: BuildContext<Android.Job>): Promise<void> {
await runHookIfPresent(ctx, Hook.POST_INSTALL);
});
const resolvedExpoUpdatesRuntimeVersion = await ctx.runBuildPhase(
BuildPhase.CALCULATE_EXPO_UPDATES_RUNTIME_VERSION,
async () => {
return await resolveRuntimeVersionForExpoUpdatesIfConfiguredAsync({
cwd: ctx.getReactNativeProjectDirectory(),
logger: ctx.logger,
appConfig: await ctx.appConfig,
platform: ctx.job.platform,
workflow: ctx.job.type,
env: ctx.env,
});
}
);
if (
nullthrows(ctx.job.secrets, 'Secrets must be defined for non-custom builds').buildCredentials
) {
+14 -14
View File
@@ -60,6 +60,20 @@ async function buildAsync(ctx: BuildContext<Ios.Job>): Promise<void> {
return await credentialsManager.prepare();
});
const resolvedExpoUpdatesRuntimeVersion = await ctx.runBuildPhase(
BuildPhase.CALCULATE_EXPO_UPDATES_RUNTIME_VERSION,
async () => {
return await resolveRuntimeVersionForExpoUpdatesIfConfiguredAsync({
cwd: ctx.getReactNativeProjectDirectory(),
logger: ctx.logger,
appConfig: await ctx.appConfig,
platform: ctx.job.platform,
workflow: ctx.job.type,
env: ctx.env,
});
}
);
await ctx.runBuildPhase(BuildPhase.PREBUILD, async () => {
if (hasNativeCode) {
ctx.markBuildPhaseSkipped();
@@ -101,20 +115,6 @@ async function buildAsync(ctx: BuildContext<Ios.Job>): Promise<void> {
await runHookIfPresent(ctx, Hook.POST_INSTALL);
});
const resolvedExpoUpdatesRuntimeVersion = await ctx.runBuildPhase(
BuildPhase.CALCULATE_EXPO_UPDATES_RUNTIME_VERSION,
async () => {
return await resolveRuntimeVersionForExpoUpdatesIfConfiguredAsync({
cwd: ctx.getReactNativeProjectDirectory(),
logger: ctx.logger,
appConfig: await ctx.appConfig,
platform: ctx.job.platform,
workflow: ctx.job.type,
env: ctx.env,
});
}
);
const buildConfiguration = resolveBuildConfiguration(ctx);
if (credentials) {
await ctx.runBuildPhase(BuildPhase.CONFIGURE_XCODE_PROJECT, async () => {