Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ENG-10464][eas-cli] throw error if custom build config is gitignored #2123

Merged
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ This is the log of notable changes to EAS CLI and related packages.

### 🧹 Chores

- Throw error if custom build config is gitignored. ([#2123](https://github.com/expo/eas-cli/pull/2123) by [@szdziedzic](https://github.com/szdziedzic))

## [5.9.1](https://github.com/expo/eas-cli/releases/tag/v5.9.1) - 2023-11-20

### 🐛 Bug fixes
Expand Down
6 changes: 5 additions & 1 deletion packages/eas-cli/src/build/runBuildAndSubmit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,11 @@ export async function runBuildAndSubmitAsync(
{};
for (const buildProfile of buildProfiles) {
validateBuildProfileVersionSettings(buildProfile, easJsonCliConfig);
const maybeMetadata = await validateCustomBuildConfigAsync(projectDir, buildProfile.profile);
const maybeMetadata = await validateCustomBuildConfigAsync({
projectDir,
profile: buildProfile.profile,
vcsClient,
});
Comment on lines +146 to +150
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❤️

if (maybeMetadata) {
customBuildConfigMetadataByPlatform[toAppPlatform(buildProfile.platform)] = maybeMetadata;
}
Expand Down
22 changes: 18 additions & 4 deletions packages/eas-cli/src/project/customBuildConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,21 @@ import chalk from 'chalk';
import fs from 'fs-extra';
import path from 'path';

import { Client } from '../vcs/vcs';

export interface CustomBuildConfigMetadata {
workflowName?: string;
}

export async function validateCustomBuildConfigAsync(
projectDir: string,
profile: BuildProfile<Platform>
): Promise<CustomBuildConfigMetadata | undefined> {
export async function validateCustomBuildConfigAsync({
profile,
projectDir,
vcsClient,
}: {
projectDir: string;
profile: BuildProfile<Platform>;
vcsClient: Client;
}): Promise<CustomBuildConfigMetadata | undefined> {
if (!profile.config) {
return undefined;
}
Expand All @@ -24,6 +31,13 @@ export async function validateCustomBuildConfigAsync(
`Custom build configuration file ${chalk.bold(relativeConfigPath)} does not exist.`
);
}
if (await vcsClient.isFileIgnoredAsync(relativeConfigPath)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May a config file reference other files? Maybe not now, but in the future? Or TypeScript functions? Should we make sure whole .eas is committed instead (instead of just the config file)?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May a config file reference other files?

https://docs.expo.dev/custom-builds/schema/#import

Or TypeScript functions?

https://docs.expo.dev/custom-builds/schema/#functionsfunction_namepath

Should we make sure whole .eas is committed instead (instead of just the config file)?

Good question 🤔

I believe that we should fail if the currently used config file is git ignored, but maybe display a warning if other files in .eas are git ignored? Ideally, I feel like we can try to resolve which custom functions will be needed for a given build and which config files will be needed and validate that they are not git ignored, but I think it will require some more changes, and I think that we can merge it as v1 to make it better and not wait with it for other stuff to come along. WDYT?

throw new Error(
`Custom build configuration file ${chalk.bold(
relativeConfigPath
)} is ignored by your version control system. Remove it from the ignore list to successfully create custom build.`
);
}

try {
const config = await readAndValidateBuildConfigAsync(configPath, {
Expand Down
Loading