-
Notifications
You must be signed in to change notification settings - Fork 29
[local-build-plugin][build-tools][eas-build-job] copy Xcode build logs to target destination on local iOS build failure to simplify debuging #447
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,10 +3,19 @@ import path from 'path'; | |
| import { bunyan } from '@expo/logger'; | ||
| import fs from 'fs-extra'; | ||
| import * as tar from 'tar'; | ||
| import { ManagedArtifactType } from '@expo/eas-build-job'; | ||
|
|
||
| import config from './config'; | ||
|
|
||
| export async function prepareArtifacts(artifactPaths: string[], logger?: bunyan): Promise<string> { | ||
| export async function prepareArtifacts({ | ||
| artifactPaths, | ||
| artifactType, | ||
| logger, | ||
| }: { | ||
| artifactPaths: string[]; | ||
| artifactType: ManagedArtifactType; | ||
| logger?: bunyan; | ||
| }): Promise<string> { | ||
| const l = logger?.child({ phase: 'PREPARE_ARTIFACTS' }); | ||
| l?.info('Preparing artifacts'); | ||
| let suffix; | ||
|
|
@@ -35,10 +44,21 @@ export async function prepareArtifacts(artifactPaths: string[], logger?: bunyan) | |
| suffix = '.tar.gz'; | ||
| localPath = archivePath; | ||
| } | ||
| const artifactName = `build-${Date.now()}${suffix}`; | ||
| const artifactName = | ||
| artifactType === ManagedArtifactType.APPLICATION_ARCHIVE | ||
| ? `build-${Date.now()}${suffix}` | ||
| : artifactType === ManagedArtifactType.BUILD_ARTIFACTS | ||
| ? `artifacts-${Date.now()}${suffix}` | ||
| : `xcode-logs-${Date.now()}${suffix}`; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as below |
||
| const destPath = config.artifactPath ?? path.join(config.artifactsDir, artifactName); | ||
| await fs.copy(localPath, destPath); | ||
| l?.info({ phase: 'PREPARE_ARTIFACTS' }, `Writing artifacts to ${destPath}`); | ||
| if (artifactType === ManagedArtifactType.APPLICATION_ARCHIVE) { | ||
| l?.info({ phase: 'PREPARE_ARTIFACTS' }, `Writing application archive to ${destPath}`); | ||
| } else if (artifactType === ManagedArtifactType.BUILD_ARTIFACTS) { | ||
| l?.info({ phase: 'PREPARE_ARTIFACTS' }, `Writing build artifacts to ${destPath}`); | ||
| } else { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Prefer switch over enums. This way if we add more managed types we won't forget to add handling. |
||
| l?.info({ phase: 'PREPARE_ARTIFACTS' }, `Writing Xcode logs to ${destPath}`); | ||
| } | ||
| return destPath; | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| import { Ios, BuildPhase, Env, ManagedArtifactType } from '@expo/eas-build-job'; | ||
| import { Ios, BuildPhase, Env, isManagedArtifact, ManagedArtifactType } from '@expo/eas-build-job'; | ||
| import { Builders, BuildContext, Artifacts } from '@expo/build-tools'; | ||
| import omit from 'lodash/omit'; | ||
|
|
||
|
|
@@ -23,10 +23,18 @@ export async function buildIosAsync( | |
| logger, | ||
| logBuffer, | ||
| uploadArtifact: async ({ artifact, logger }) => { | ||
| if (artifact.type === ManagedArtifactType.APPLICATION_ARCHIVE) { | ||
| return await prepareArtifacts(artifact.paths, logger); | ||
| } else if (artifact.type === ManagedArtifactType.BUILD_ARTIFACTS) { | ||
| return await prepareArtifacts(artifact.paths, logger); | ||
| if (isManagedArtifact(artifact)) { | ||
| if ( | ||
| artifact.type === ManagedArtifactType.XCODE_BUILD_LOGS && | ||
| artifact.runStatus !== 'errored' | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would it make sense to just always upload Xcode build logs? It would simplify code greatly (no tracking of
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe it would. Would it be ok for you as a user if they were always uploaded for you local builds (copied to project dir) 🤔 |
||
| ) { | ||
| return null; | ||
| } | ||
| return await prepareArtifacts({ | ||
| artifactPaths: artifact.paths, | ||
| logger, | ||
| artifactType: artifact.type, | ||
| }); | ||
| } else { | ||
| return null; | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?