Skip to content

Commit

Permalink
[ENG-10412] Add metadataLocation to ArchiveSource type
Browse files Browse the repository at this point in the history
It is used to store location of the project archive metadata file
  • Loading branch information
khamilowicz committed Dec 16, 2023
1 parent 911903d commit bf54395
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import assert from 'assert';

import { createLogger } from '@expo/logger';
import { Ios, Workflow, ArchiveSourceType, Platform } from '@expo/eas-build-job';
import { ArchiveSourceType, Ios, Platform, Workflow } from '@expo/eas-build-job';
import { BuildMode, BuildTrigger } from '@expo/eas-build-job/dist/common';
import { createLogger } from '@expo/logger';

import { BuildContext } from '../../../context';
import { distributionCertificate, provisioningProfile } from '../__tests__/fixtures';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import assert from 'assert';

import { createLogger } from '@expo/logger';
import { Ios, Workflow, ArchiveSourceType, Platform } from '@expo/eas-build-job';
import { ArchiveSourceType, Ios, Platform, Workflow } from '@expo/eas-build-job';
import { BuildMode, BuildTrigger } from '@expo/eas-build-job/dist/common';
import { createLogger } from '@expo/logger';

import { distributionCertificate, provisioningProfile } from '../__tests__/fixtures';
import IosCredentialsManager from '../manager';
Expand Down
31 changes: 31 additions & 0 deletions packages/eas-build-job/src/__tests__/android.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,37 @@ describe('Android.JobSchema', () => {
expect(error).toBeFalsy();
});

test('valid generic job with metadataLocation', () => {
const genericJob = {
secrets,
platform: Platform.ANDROID,
type: Workflow.GENERIC,
projectArchive: {
type: ArchiveSourceType.S3,
bucketKey: 'path/to/file',
metadataLocation: 'path/to/metadata',
},
gradleCommand: ':app:bundleRelease',
applicationArchivePath: 'android/app/build/outputs/bundle/release/app-release.aab',
projectRootDirectory: '.',
releaseChannel: 'default',
builderEnvironment: {
image: 'default',
node: '1.2.3',
yarn: '2.3.4',
ndk: '4.5.6',
bun: '1.0.0',
env: {
SOME_ENV: '123',
},
},
};

const { value, error } = Android.JobSchema.validate(genericJob, joiOptions);
expect(value).toMatchObject(genericJob);
expect(error).toBeFalsy();
});

test('invalid generic job', () => {
const genericJob = {
secrets,
Expand Down
23 changes: 22 additions & 1 deletion packages/eas-build-job/src/__tests__/ios.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Joi from 'joi';

import * as Ios from '../ios';
import { ArchiveSourceType, BuildMode, Platform, Workflow } from '../common';
import * as Ios from '../ios';

const joiOptions: Joi.ValidationOptions = {
stripUnknown: true,
Expand Down Expand Up @@ -77,6 +77,27 @@ describe('Ios.JobSchema', () => {
expect(error).toBeFalsy();
});

test('valid custom build job with metadataLocation', () => {
const customBuildJob = {
mode: BuildMode.CUSTOM,
type: Workflow.UNKNOWN,
platform: Platform.IOS,
projectArchive: {
type: ArchiveSourceType.S3,
bucketKey: 'path/to/file',
metadataLocation: 'path/to/metadata',
},
projectRootDirectory: '.',
customBuildConfig: {
path: 'production.ios.yml',
},
};

const { value, error } = Ios.JobSchema.validate(customBuildJob, joiOptions);
expect(value).toMatchObject(customBuildJob);
expect(error).toBeFalsy();
});

test('valid custom build job', () => {
const customBuildJob = {
mode: BuildMode.CUSTOM,
Expand Down
6 changes: 4 additions & 2 deletions packages/eas-build-job/src/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ export enum BuildTrigger {

export type ArchiveSource =
| { type: ArchiveSourceType.NONE }
| { type: ArchiveSourceType.S3; bucketKey: string }
| { type: ArchiveSourceType.GCS; bucketKey: string }
| { type: ArchiveSourceType.S3; bucketKey: string; metadataLocation?: string }
| { type: ArchiveSourceType.GCS; bucketKey: string; metadataLocation?: string }
| { type: ArchiveSourceType.URL; url: string }
| { type: ArchiveSourceType.PATH; path: string }
| {
Expand All @@ -61,12 +61,14 @@ export const ArchiveSourceSchema = Joi.object<ArchiveSource>({
then: Joi.object({
type: Joi.string().valid(ArchiveSourceType.GCS).required(),
bucketKey: Joi.string().required(),
metadataLocation: Joi.string(),
}),
})
.when(Joi.object({ type: ArchiveSourceType.S3 }).unknown(), {
then: Joi.object({
type: Joi.string().valid(ArchiveSourceType.S3).required(),
bucketKey: Joi.string().required(),
metadataLocation: Joi.string(),
}),
})
.when(Joi.object({ type: ArchiveSourceType.URL }).unknown(), {
Expand Down

0 comments on commit bf54395

Please sign in to comment.