Compare commits

..
Author SHA1 Message Date
Dominik Sokal bbd98f5a42 [turtle-cli] fix generating android keystore 2019-05-15 10:33:26 +02:00
55 changed files with 251 additions and 1640 deletions

No files matched your search

-25
View File
@@ -5,33 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]
### Changed
- Updated Android shell app for SDK33 to remove `expo-face-detector` and `expo-payments-stripe` from standalone builds.
- Updated Android shell app for SDK33 to get rid of `node_modules` for `tools-public`.
- From now on, `turtle-cli` installs dependencies for `tools-public` in shell apps for SDK versions < 33.
### Fixed
- Android builds with turtle-cli by installing all unmodules if `dependencies` is empty.
## [0.8.1] - 2019-06-10
### Changed
- Add expo dependencies when resolving unimodules.
### Fixed
- Support for Android tarballs without `universe-package.json`.
## [0.8.0] - 2019-06-07
### Added
- Turtle CLI logo to the project (created by [@zularizal](https://github.com/zularizal))!
- Shell apps for SDK 33.
- Support for Android App Bundles.
### Changed
- Updated Android shell app for SDK 32 to fix AppAuth issue (https://github.com/expo/expo/pull/4115) and to fix a newer than expected JSC version.
- Default value for build timeout to 15 minutes.
- Added filtering of logs (strips out download progress) when downloading SDK tools.
- `xdl` -> `@expo/xdl`, updated `@expo/xdl`.
### Fixed
- Generating Android keystore in turtle when one is not passed to turtle-cli (https://github.com/expo/turtle/pull/65).
- Upload logs to s3 if build has been canceled or timed out.
- Unhandled exception on asset download (xdl).
## [0.7.2] - 2019-05-09
### Added
+10 -14
View File
@@ -20,7 +20,6 @@ RUN dpkg --add-architecture i386 && \
libc6:i386\
libncurses5:i386\
libstdc++6:i386\
rsync\
unzip\
yarn\
zlib1g:i386\
@@ -58,13 +57,13 @@ RUN yes | sdkmanager \
"platforms;android-25" \
"platforms;android-26" \
"platforms;android-27" \
"platforms;android-28" | grep -v '=' || echo 'no output'
RUN yes | sdkmanager "platform-tools" | grep -v '=' || echo 'no output'
RUN yes | sdkmanager "build-tools;28.0.3" | grep -v '=' || echo 'no output'
"platforms;android-28"
RUN yes | sdkmanager "platform-tools"
RUN yes | sdkmanager "build-tools;28.0.3"
RUN yes | sdkmanager \
"extras;android;m2repository" \
"extras;google;m2repository" \
"extras;google;google_play_services" | grep -v '=' || echo 'no output'
"extras;google;google_play_services"
# Install Android NDK
ENV ANDROID_NDK_VERSION android-ndk-r10e
@@ -100,11 +99,9 @@ RUN rm gradle-4.4-all.zip
ENV GRADLE_HOME /usr/local/gradle-4.4
ENV PATH ${GRADLE_HOME}/bin:$PATH
ADD . /app/turtle
ADD . /app
RUN mv /app/turtle/workingdir /app && \
for SDK_VERSION in `ls /app/workingdir/android/`; do \
echo "preparing $SDK_VERSION shell app" && \
RUN for SDK_VERSION in `ls /app/workingdir/android/`; do \
cd /app/workingdir/android/$SDK_VERSION && \
if [ -f universe-package.json ]; then \
mv package.json exponent-package.json && \
@@ -115,12 +112,11 @@ RUN mv /app/turtle/workingdir /app && \
else \
yarn install; \
fi \
; done && \
mv /app/workingdir /app/turtle
; done
WORKDIR /app
ENV NODE_ENV "production"
ENV TURTLE_WORKING_DIR_PATH /app/turtle/workingdir/
WORKDIR /app/turtle
ENV TURTLE_WORKING_DIR_PATH /app/workingdir/
CMD ["node", "./build/server.js"]
+1 -11
View File
@@ -22,7 +22,7 @@ spec:
environment: ${NAMESPACE}
spec:
restartPolicy: Always
terminationGracePeriodSeconds: 1200 ## wait 20 minutes for any builds to complete
terminationGracePeriodSeconds: 1800 ## wait 30 minutes for any builds to complete
tolerations:
- key: dedicated
operator: Equal
@@ -128,16 +128,6 @@ spec:
secretKeyRef:
name: turtle-js-config
key: api_port
- name: DATADOG_API_KEY
valueFrom:
secretKeyRef:
name: turtle-js-config
key: datadog_api_key
- name: DATADOG_APP_KEY
valueFrom:
secretKeyRef:
name: turtle-js-config
key: datadog_app_key
# other vars
- name: GRADLE_DAEMON_DISABLED
value: "1"
+6 -11
View File
@@ -1,6 +1,6 @@
{
"name": "turtle-cli",
"version": "0.8.1",
"version": "0.7.2",
"description": "The command-line tool for building standalone Expo apps",
"preferGlobal": true,
"scripts": {
@@ -36,11 +36,7 @@
"set-priorities:default": "expenv ts-node -r tsconfig-paths/register --files src/scripts/setConfigurations.ts",
"set-priorities:local": "EXPENV_OVERRIDES=local-common,local,local-queue yarn set-priorities:default",
"set-priorities:staging": "yarn set-priorities:default",
"set-priorities:production": "EXPENV_OVERRIDES=prod yarn set-priorities:default",
"set-replica-count:default": "expenv ts-node -r tsconfig-paths/register --files src/scripts/setReplicaCount.ts | bunyan -o short -l debug",
"set-replica-count:local": "EXPENV_OVERRIDES=local-common,local,local-queue yarn set-replica-count:default",
"set-replica-count:staging": "yarn set-replica-count:default",
"set-replica-count:production": "EXPENV_OVERRIDES=prod yarn set-replica-count:default"
"set-priorities:production": "EXPENV_OVERRIDES=prod yarn set-priorities:default"
},
"husky": {
"hooks": {
@@ -83,7 +79,7 @@
"@types/fs-extra": "^5.0.4",
"@types/jest": "^23.3.9",
"@types/joi": "^13.4.3",
"@types/lodash": "^4.14.129",
"@types/lodash": "^4.14.109",
"@types/progress": "^2.0.1",
"@types/raven": "^2.5.1",
"@types/request": "^2.47.1",
@@ -110,7 +106,6 @@
},
"dependencies": {
"@expo/spawn-async": "^1.4.2",
"@expo/xdl": "54.1.4",
"@google-cloud/logging-bunyan": "^0.9.5",
"async-retry": "^1.2.1",
"aws-sdk": "^2.226.1",
@@ -120,12 +115,11 @@
"commander": "^2.15.1",
"copy": "^0.3.1",
"decompress": "^4.2.0",
"dogapi": "^2.8.3",
"fs-extra": "^6.0.0",
"ioredis": "^3.2.2",
"is-semver": "^1.0.8",
"joi": "^13.2.0",
"lodash": "^4.17.11",
"lodash": "^4.17.10",
"progress": "^2.0.0",
"raven": "^2.6.2",
"request": "^2.88.0",
@@ -135,7 +129,8 @@
"source-map-support": "^0.5.6",
"tar": "^4.4.6",
"uuid": "^3.2.1",
"which": "^1.3.1"
"which": "^1.3.1",
"xdl": "53.5.4"
},
"optionalDependencies": {
"@expo/traveling-fastlane-darwin": "1.9.4"
-4
View File
@@ -61,10 +61,6 @@ setup_remote() {
mv $sdk/package.json $sdk/exponent-package.json
mv $sdk/universe-package.json $sdk/package.json
cd $sdk && yarn
else
if [[ -f "$sdk/package.json" ]]; then
cd $sdk && yarn
fi
fi
done
}
-1
View File
@@ -21,6 +21,5 @@ export API_HOSTNAME="staging.expo.io"
export API_PORT="443"
export REDIS_URL="noop"
export REDIS_CONFIG_URL="noop"
export DATADOG_DISABLED="true"
yarn test:smoke:android
-1
View File
@@ -19,7 +19,6 @@ export API_HOSTNAME="staging.expo.io"
export API_PORT="443"
export REDIS_URL="noop"
export REDIS_CONFIG_URL="noop"
export DATADOG_DISABLED="true"
ROOT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )"/../.. && pwd )"
SDK_VERSION=sdk32 $ROOT_DIR/scripts/ios/fetchRemoteIosTarball.sh
-1
View File
@@ -21,6 +21,5 @@ export API_HOSTNAME="noop"
export API_PORT="443"
export REDIS_URL="noop"
export REDIS_CONFIG_URL="noop"
export DATADOG_DISABLED="true"
yarn test:unit
+1
View File
@@ -0,0 +1 @@
s3://exp-artifacts/android-shell-builder-c19ce0d88a153f481fd790e23bdcd6f2d5ea7fd6.tar.gz
+1 -1
View File
@@ -1 +1 @@
s3://exp-artifacts/android-shell-builder-f796aaffa0b5715079b2950faf26c2ff4e53e4c0.tar.gz
s3://exp-artifacts/android-shell-builder-0cab68670fc50ce1dc16b7d86ca7976870062c39.tar.gz
-1
View File
@@ -1 +0,0 @@
s3://exp-artifacts/android-shell-builder-e244e865ed8cb8e20d29ea00b6373845d1c61068.tar.gz
+1 -1
View File
@@ -1 +1 @@
s3://exp-artifacts/ios-expo-client-a2b1e16f330b36fa0dc627a76caabe4d2ff45f77.tar.gz
s3://exp-artifacts/ios-expo-client-15bb883c22173d5b01df19421580170e776041d0.tar.gz
+1
View File
@@ -0,0 +1 @@
s3://exp-artifacts/ios-shell-builder-sdk-26-db356a09877642d64023af98e4e2e1e632fbe4df.tar.gz
-1
View File
@@ -1 +0,0 @@
s3://exp-artifacts/ios-shell-builder-sdk-latest-a2b1e16f330b36fa0dc627a76caabe4d2ff45f77.tar.gz
-25
View File
@@ -13,28 +13,3 @@ export const TYPE_DIMENSIONS = (type: string) => [
{ Name: 'host', Value: config.hostname },
],
];
export const PRIORITY_DIMENSIONS = (type: string, priority: string) => [
[
{ Name: 'env', Value: config.deploymentEnv },
{ Name: 'platform', Value: config.platform },
{ Name: 'priority', Value: priority },
],
[
{ Name: 'env', Value: config.deploymentEnv },
{ Name: 'platform', Value: config.platform },
{ Name: 'type', Value: type },
],
[
{ Name: 'env', Value: config.deploymentEnv },
{ Name: 'platform', Value: config.platform },
{ Name: 'type', Value: type },
{ Name: 'priority', Value: priority },
],
[
{ Name: 'env', Value: config.deploymentEnv },
{ Name: 'platform', Value: config.platform },
{ Name: 'type', Value: type },
{ Name: 'host', Value: config.hostname },
],
];
+3 -15
View File
@@ -15,18 +15,11 @@ export default (program: any, setCommonCommandOptions: any) => {
.option(
'--keystore-path <app.jks>',
'path to your Keystore (please provide Keystore password and Key password as EXPO_ANDROID_KEYSTORE_PASSWORD'
+ ' and EXPO_ANDROID_KEY_PASSWORD env variables)',
+ 'and EXPO_ANDROID_KEY_PASSWORD env variables)',
)
.option('--keystore-alias <alias>', 'keystore Alias')
.option(
'-t --type <build>',
'type of build: app-bundle|apk',
/^(app-bundle|apk)$/i,
'app-bundle',
)
.description(
'Build a standalone APK or App Bundle for your project, signed and ready for submission to the Google Play'
+ ' Store.',
'Build a standalone APK for your project, signed and ready for submission to the Google Play Store.',
)
.asyncAction(
createBuilderAction({
@@ -41,17 +34,12 @@ export default (program: any, setCommonCommandOptions: any) => {
);
};
const buildJobObject = (
appJSON: any,
{ releaseChannel, username, projectDir, publicUrl, buildType }: any,
credentials: any,
) => ({
const buildJobObject = (appJSON: any, { releaseChannel, username, projectDir, publicUrl }: any, credentials: any) => ({
config: {
..._.get(appJSON, 'expo.android.config', {}),
releaseChannel,
androidPackage: _.get(appJSON, 'expo.android.package'),
publicUrl,
buildType,
},
id: uuid.v4(),
platform: PLATFORMS.ANDROID,
+2 -2
View File
@@ -5,7 +5,7 @@ import uuid from 'uuid';
import { ErrorWithCommandHelp } from 'turtle/bin/commands/ErrorWithCommandHelp';
import { createBuilderAction } from 'turtle/bin/utils/builder';
import builder from 'turtle/builders/ios';
import { IOS_BUILD_TYPES, PLATFORMS } from 'turtle/constants';
import { IOS, PLATFORMS } from 'turtle/constants';
export default (program: any, setCommonCommandOptions: any) => {
const command = program.command('build:ios [project-dir]');
@@ -56,7 +56,7 @@ const buildJobObject = (appJSON: any, { releaseChannel, buildType, username, pub
});
const prepareCredentials = async (cmd: any) => {
if (cmd.type !== IOS_BUILD_TYPES.ARCHIVE) {
if (cmd.type !== IOS.BUILD_TYPES.ARCHIVE) {
return null;
}
+1 -1
View File
@@ -1,8 +1,8 @@
import path from 'path';
import { LoggerDetach, ModuleVersion } from '@expo/xdl';
import program, { Command } from 'commander';
import fs from 'fs-extra';
import { LoggerDetach, ModuleVersion } from 'xdl';
import * as commands from 'turtle/bin/commands';
import logger from 'turtle/logger';
+10 -18
View File
@@ -1,9 +1,9 @@
import path from 'path';
import util from 'util';
import { ExponentTools } from '@expo/xdl';
import fs from 'fs-extra';
import _which from 'which';
import { ExponentTools } from 'xdl';
import ensureAndroidNDKIsPresent from 'turtle/bin/setup/android/ndk';
import ensureAndroidSDKIsPresent from 'turtle/bin/setup/android/sdk';
@@ -67,26 +67,18 @@ function formatShellAppTarballUriPath(sdkMajorVersion: string) {
return path.join(config.directories.shellTarballsDir, PLATFORMS.ANDROID, `sdk${sdkMajorVersion}`);
}
async function _shellAppPostDownloadAction(sdkVersion: string, workingdir: string) {
async function _shellAppPostDownloadAction(workingdir: string) {
const inWorkingdir = (filename: string) => path.join(workingdir, filename);
if (await fs.pathExists(inWorkingdir('universe-package.json'))) {
// legacy shell app built from universe
await fs.move(inWorkingdir('package.json'), inWorkingdir('exponent-package.json'));
await fs.move(inWorkingdir('universe-package.json'), inWorkingdir('package.json'));
await _installNodeModules(workingdir);
await fs.move(inWorkingdir('package.json'), inWorkingdir('universe-package.json'));
await fs.move(inWorkingdir('exponent-package.json'), inWorkingdir('package.json'));
} else {
// new shell app built from expo or not
await _installNodeModules(workingdir);
}
await fs.move(inWorkingdir('package.json'), inWorkingdir('exponent-package.json'));
await fs.move(inWorkingdir('universe-package.json'), inWorkingdir('package.json'));
await _installNodeModules(workingdir);
await fs.move(inWorkingdir('package.json'), inWorkingdir('universe-package.json'));
await fs.move(inWorkingdir('exponent-package.json'), inWorkingdir('package.json'));
// TODO: remove this after making sure that we don't need node_modules in tools-public for older sdks
if (ExponentTools.parseSdkMajorVersion(sdkVersion) < 33) {
const toolsPublicDir = path.join(workingdir, 'tools-public');
await _installNodeModules(toolsPublicDir);
}
// TODO: remove following lines after upgrading android shell app
const toolsPublicDir = path.join(workingdir, 'tools-public');
await _installNodeModules(toolsPublicDir);
}
async function _installNodeModules(cwd: string) {
+1 -1
View File
@@ -1,9 +1,9 @@
import os from 'os';
import path from 'path';
import { ExponentTools } from '@expo/xdl';
import decompress from 'decompress';
import fs from 'fs-extra';
import { ExponentTools } from 'xdl';
import { formatArtifactDownloadPath } from 'turtle/bin/setup/utils/common';
import download from 'turtle/bin/setup/utils/downloader';
+1 -1
View File
@@ -3,7 +3,7 @@ import trim from 'lodash/trim';
import path from 'path';
import semver from 'semver';
import { ExponentTools } from '@expo/xdl';
import { ExponentTools } from 'xdl';
import { checkSystem, ensureShellAppIsPresent } from 'turtle/bin/setup/utils/common';
import { IToolDefinition } from 'turtle/bin/setup/utils/toolsDetector';
+3 -3
View File
@@ -1,8 +1,8 @@
import path from 'path';
import { ExponentTools } from '@expo/xdl';
import fs from 'fs-extra';
import tar from 'tar';
import { ExponentTools } from 'xdl';
import download from 'turtle/bin/setup/utils/downloader';
import { ensureToolsAreInstalled, IToolDefinition } from 'turtle/bin/setup/utils/toolsDetector';
@@ -17,7 +17,7 @@ interface IShellAppFormaters {
formatShellAppTarballUriPath: (sdkMajorVersion: string) => string;
}
type PostDownloadAction = (sdkVersion: string, workingdir: string) => void;
type PostDownloadAction = (workingdir: string) => void;
export async function checkSystem(requiredTools: IToolDefinition[]) {
await ensureToolsAreInstalled(requiredTools);
@@ -35,7 +35,7 @@ export async function ensureShellAppIsPresent(
l.info(`shell app for SDK ${sdkVersion} doesn't exist, downloading...`);
await _downloadShellApp(sdkVersion, workingdir, formatters);
if (postDownloadAction) {
await postDownloadAction(sdkVersion, workingdir);
await postDownloadAction(workingdir);
}
}
+1 -1
View File
@@ -1,4 +1,4 @@
import { User as UserManager } from '@expo/xdl';
import { User as UserManager } from 'xdl';
import { ErrorWithProgramHelp } from 'turtle/bin/commands/ErrorWithProgramHelp';
+6 -12
View File
@@ -1,11 +1,10 @@
import path from 'path';
import { AndroidShellApp, ImageUtils } from '@expo/xdl';
import fs from 'fs-extra';
import _ from 'lodash';
import semver from 'semver';
import { ANDROID_BUILD_TYPES } from 'turtle/constants';
import uuidv4 from 'uuid/v4';
import { AndroidShellApp, ImageUtils } from 'xdl';
import getOrCreateCredentials from 'turtle/builders/utils/android/credentials';
import { formatShellAppDirectory } from 'turtle/builders/utils/android/workingdir';
@@ -21,16 +20,13 @@ import logger from 'turtle/logger';
export default async function buildAndroid(jobData: IJob): Promise<IJobResult> {
await ensureCanBuildSdkVersion(jobData);
const credentials = await getOrCreateCredentials(jobData);
const outputFilePath = await runShellAppBuilder(jobData, credentials);
const apkFilePath = await runShellAppBuilder(jobData, credentials);
const randomHex = uuidv4().replace(/-/g, '');
const s3FileExtension = jobData.config.buildType === ANDROID_BUILD_TYPES.APP_BUNDLE ? 'aab' : 'apk';
const s3Filename = `${jobData.experienceName}-${randomHex}-signed.${s3FileExtension}`;
const s3Filename = `${jobData.experienceName}-${randomHex}-signed.apk`;
const s3FileKey = `android/${s3Filename}`;
const fakeUploadFilename = s3Filename.replace('/', '\\');
const artifactUrl = await uploadBuildToS3({
uploadPath: outputFilePath,
uploadPath: apkFilePath,
s3FileKey,
...config.builder.fakeUpload && {
fakeUploadBuildPath:
@@ -66,8 +62,7 @@ async function runShellAppBuilder(
ImageUtils.setResizeImageFunction(imageHelpers.resizeIconWithSharpAsync);
ImageUtils.setGetImageDimensionsFunction(imageHelpers.getImageDimensionsWithSharpAsync);
const fileExtension = jobData.config.buildType === ANDROID_BUILD_TYPES.APP_BUNDLE ? 'aab' : 'apk';
const outputFilePath = path.join(temporaryFilesRoot, `shell-signed-${jobData.id}.${fileExtension}`);
const outputFilePath = path.join(temporaryFilesRoot, `shell-signed-${jobData.id}.apk`);
const { config: jobConfig, manifest, sdkVersion: sdkVersionFromJob } = jobData;
const sdkVersion = _.get(manifest, 'sdkVersion', sdkVersionFromJob);
@@ -75,7 +70,7 @@ async function runShellAppBuilder(
logger.info({ buildPhase: 'resolve native modules' }, 'Resolving universal modules dependencies');
const enabledModules = semver.satisfies(sdkVersion, '>= 33.0.0')
? await resolveNativeModules(workingDir, manifest && manifest.dependencies)
? await resolveNativeModules(workingDir, manifest.dependencies)
: null;
try {
@@ -92,7 +87,6 @@ async function runShellAppBuilder(
workingDir,
outputFile: outputFilePath,
modules: enabledModules,
buildType: jobData.config.buildType,
});
} catch (err) {
commonUtils.logErrorOnce(err);
+1 -1
View File
@@ -1,5 +1,5 @@
import { IosIPABuilder as createIPABuilder } from '@expo/xdl';
import _ from 'lodash';
import { IosIPABuilder as createIPABuilder } from 'xdl';
import { IContext } from 'turtle/builders/ios/context';
import { logErrorOnce } from 'turtle/builders/utils/common';
+8 -7
View File
@@ -1,11 +1,11 @@
import * as path from 'path';
import { IosShellApp } from '@expo/xdl';
import { v4 as uuidv4 } from 'uuid';
import { IosShellApp } from 'xdl';
import { formatShellAppDirectory } from 'turtle/builders/utils/ios/workingdir';
import config from 'turtle/config';
import { IOS_BUILD_TYPES, PLATFORMS } from 'turtle/constants/index';
import { IOS, PLATFORMS } from 'turtle/constants/index';
import { IJob } from 'turtle/job';
export interface IContext {
@@ -27,6 +27,7 @@ export interface IContext {
}
const { EXPOKIT_APP, EXPONENT_APP } = IosShellApp;
const { BUILD_TYPES } = IOS;
export function createBuilderContext(job: IJob): IContext {
const { join } = path;
@@ -56,7 +57,7 @@ export function createBuilderContext(job: IJob): IContext {
context.tempCertPath = join(context.appDir, 'cert.p12');
context.baseArchiveDir = join(context.appDir, 'archive');
if (buildType === IOS_BUILD_TYPES.CLIENT) {
if (buildType === BUILD_TYPES.CLIENT) {
context.applicationFilesSrc = join(
workingDir,
'expo-client-build',
@@ -73,7 +74,7 @@ export function createBuilderContext(job: IJob): IContext {
);
}
if (buildType === IOS_BUILD_TYPES.ARCHIVE) {
if (buildType === BUILD_TYPES.ARCHIVE) {
context.outputPath = join(context.appDir, 'archive.xcarchive');
context.uploadPath = join(context.buildDir, 'archive.ipa');
context.archiveDir = join(
@@ -91,7 +92,7 @@ export function createBuilderContext(job: IJob): IContext {
'default',
`${EXPOKIT_APP}.xcworkspace`,
);
} else if (buildType === IOS_BUILD_TYPES.CLIENT) {
} else if (buildType === BUILD_TYPES.CLIENT) {
context.outputPath = join(context.appDir, 'archive.xcarchive');
context.uploadPath = join(context.buildDir, 'archive.ipa');
context.archiveDir = join(
@@ -106,7 +107,7 @@ export function createBuilderContext(job: IJob): IContext {
'ios',
`${EXPONENT_APP}.xcworkspace`,
);
} else if (buildType === IOS_BUILD_TYPES.SIMULATOR) {
} else if (buildType === BUILD_TYPES.SIMULATOR) {
context.outputPath = join(context.appDir, 'archive.tar.gz');
context.uploadPath = join(context.appDir, 'archive.tar.gz');
context.archiveDir = join(
@@ -116,7 +117,7 @@ export function createBuilderContext(job: IJob): IContext {
);
}
const s3FileExtension = buildType === IOS_BUILD_TYPES.SIMULATOR ? 'tar.gz' : 'ipa';
const s3FileExtension = buildType === BUILD_TYPES.SIMULATOR ? 'tar.gz' : 'ipa';
const s3Filename = `${job.experienceName}-${appUUID}-${buildType}.${s3FileExtension}`;
if (config.builder.fakeUpload) {
const fakeUploadFilename = s3Filename.replace('/', '\\');
+7 -5
View File
@@ -9,11 +9,13 @@ import prepareAdHocBuildCredentials from 'turtle/builders/utils/ios/adhocBuild';
import { uploadBuildToS3 } from 'turtle/builders/utils/uploader';
import { ensureCanBuildSdkVersion } from 'turtle/builders/utils/version';
import config from 'turtle/config';
import { IOS_BUILD_TYPES } from 'turtle/constants';
import { IOS } from 'turtle/constants/index';
import { IJob, IJobResult } from 'turtle/job';
const { BUILD_TYPES } = IOS;
export default async function iosBuilder(job: IJob): Promise<IJobResult> {
if (job.config.buildType !== IOS_BUILD_TYPES.CLIENT) {
if (job.config.buildType !== BUILD_TYPES.CLIENT) {
await ensureCanBuildSdkVersion(job);
}
@@ -24,13 +26,13 @@ export default async function iosBuilder(job: IJob): Promise<IJobResult> {
const { buildType } = job.config;
if (buildType === IOS_BUILD_TYPES.CLIENT) {
if (buildType === BUILD_TYPES.CLIENT) {
await prepareAdHocBuildCredentials(job);
}
if ([IOS_BUILD_TYPES.ARCHIVE, IOS_BUILD_TYPES.CLIENT].includes(buildType!)) {
if ([BUILD_TYPES.ARCHIVE, BUILD_TYPES.CLIENT].includes(buildType!)) {
await buildArchive(ctx, job);
} else if (buildType === IOS_BUILD_TYPES.SIMULATOR) {
} else if (buildType === BUILD_TYPES.SIMULATOR) {
await buildSimulator(ctx, job);
} else {
throw new Error(`Unsupported iOS build type: ${buildType}`);
+1 -1
View File
@@ -1,9 +1,9 @@
import path from 'path';
import { Credentials } from '@expo/xdl';
import fs from 'fs-extra';
import get from 'lodash/get';
import uuidv4 from 'uuid/v4';
import { Credentials } from 'xdl';
import * as sqs from 'turtle/aws/sqs';
import { UPDATE_CREDENTIALS } from 'turtle/constants/build';
+1 -1
View File
@@ -1,6 +1,6 @@
import path from 'path';
import { ExponentTools } from '@expo/xdl';
import { ExponentTools } from 'xdl';
import { IShellAppDirectoryConfig } from 'turtle/builders/utils/workingdir';
import config from 'turtle/config';
+1 -1
View File
@@ -1,9 +1,9 @@
import path from 'path';
import spawnAsync from '@expo/spawn-async';
import { IosCodeSigning } from '@expo/xdl';
import fs from 'fs-extra';
import isEmpty from 'lodash/isEmpty';
import { IosCodeSigning } from 'xdl';
import * as sqs from 'turtle/aws/sqs';
import BuildError, { BuildErrorReason } from 'turtle/builders/BuildError';
+1 -1
View File
@@ -1,4 +1,4 @@
import { IosKeychain } from '@expo/xdl';
import { IosKeychain } from 'xdl';
import { IContext } from 'turtle/builders/ios/context';
import * as fileUtils from 'turtle/builders/utils/file';
+3 -3
View File
@@ -1,14 +1,14 @@
import path from 'path';
import util from 'util';
import { ImageUtils, IosShellApp } from '@expo/xdl';
import copy from 'copy';
import _ from 'lodash';
import { ImageUtils, IosShellApp } from 'xdl';
import { IContext } from 'turtle/builders/ios/context';
import * as commonUtils from 'turtle/builders/utils/common';
import * as imageHelpers from 'turtle/builders/utils/image';
import { IOS_BUILD_TYPES } from 'turtle/constants/index';
import { IOS } from 'turtle/constants/index';
import { IJob } from 'turtle/job';
import logger from 'turtle/logger/index';
@@ -37,7 +37,7 @@ export default async function runShellAppBuilder(ctx: IContext, job: IJob): Prom
output: ctx.outputPath,
verbose: true,
};
if (buildType === IOS_BUILD_TYPES.CLIENT) {
if (buildType === IOS.BUILD_TYPES.CLIENT) {
Object.assign(shellAppParams, {
workspacePath: path.join(ctx.workingDir, 'ios'),
});
+3 -3
View File
@@ -1,14 +1,14 @@
import path from 'path';
import { ExponentTools } from '@expo/xdl';
import { ExponentTools } from 'xdl';
import { IShellAppDirectoryConfig } from 'turtle/builders/utils/workingdir';
import config from 'turtle/config';
import { IOS_BUILD_TYPES, PLATFORMS } from 'turtle/constants';
import { IOS, PLATFORMS } from 'turtle/constants';
export function formatShellAppDirectory({ sdkVersion, buildType }: IShellAppDirectoryConfig) {
const { workingDir } = config.directories;
if (buildType === IOS_BUILD_TYPES.CLIENT) {
if (buildType === IOS.BUILD_TYPES.CLIENT) {
return path.join(workingDir, PLATFORMS.IOS, 'client');
} else if (config.builder.useLocalWorkingDir) {
return path.join(workingDir, 'local');
+2 -4
View File
@@ -44,11 +44,9 @@ export async function resolveNativeModules(workingdir: string, packages?: string
async function readCorePackages(workingdir: string) {
const pkgJsonPath = path.join(workingdir, 'node_modules', 'react-native-unimodules', 'package.json');
const expoPkgJsonPath = path.join(workingdir, 'packages', 'expo', 'package.json');
if (await fs.pathExists(pkgJsonPath) && await fs.pathExists(expoPkgJsonPath)) {
if (await fs.pathExists(pkgJsonPath)) {
const packageJson = JSON.parse(await fs.readFile(pkgJsonPath, 'utf-8'));
const expoPackageJson = JSON.parse(await fs.readFile(expoPkgJsonPath, 'utf-8'));
return keys(packageJson.dependencies).concat(keys(expoPackageJson.dependencies));
return keys(packageJson.dependencies);
} else {
logger.warn('No core packages detected');
return [];
+1 -1
View File
@@ -1,6 +1,6 @@
import { ExponentTools } from '@expo/xdl';
import fs from 'fs-extra';
import path from 'path';
import { ExponentTools } from 'xdl';
import config from 'turtle/config';
import { IJob } from 'turtle/job';
+2 -2
View File
@@ -1,6 +1,6 @@
import { ANDROID_BUILD_TYPES, IOS_BUILD_TYPES } from 'turtle/constants';
import { IOS } from 'turtle/constants';
export interface IShellAppDirectoryConfig {
sdkVersion: string;
buildType?: IOS_BUILD_TYPES & ANDROID_BUILD_TYPES;
buildType?: IOS.BUILD_TYPES;
}
+2 -8
View File
@@ -2,7 +2,7 @@ import os from 'os';
import path from 'path';
import { PLATFORMS } from 'turtle/constants';
import { env, envBoolean, envNum, envOptional, envTransform } from 'turtle/utils/env';
import { env, envNum, envOptional, envTransform } from 'turtle/utils/env';
export default {
env: env('NODE_ENV'),
@@ -37,12 +37,6 @@ export default {
intervalMs: envNum('AWS_CLOUDWATCH_INTERVAL_MS', 30000),
namespace: env('AWS_CLOUDWATCH_NAMESPACE', 'Turtle'),
},
datadog: {
disabled: envBoolean('DATADOG_DISABLED', false),
apiKey: envOptional('DATADOG_API_KEY'),
appKey: envOptional('DATADOG_APP_KEY'),
intervalMs: env('DATADOG_INTERVAL_MS', 5 * 60 * 1000),
},
redis: {
url: env('REDIS_URL'),
configUrl: env('REDIS_CONFIG_URL'),
@@ -70,7 +64,7 @@ export default {
(val: string) => env('NODE_ENV') === 'development' && val === '1',
),
fakeUpload: envTransform('TURTLE_FAKE_UPLOAD', '0', (val: string) => val === '1'),
maxJobTimeMs: envNum('TURTLE_MAX_JOB_TIME_MS', 15 * 60 * 1000),
maxJobTimeMs: envNum('TURTLE_MAX_JOB_TIME_MS', 60 * 60 * 1000),
useLocalWorkingDir: envTransform('TURTLE_USE_LOCAL_WORKING_DIR', '0', (val: string) => val === '1'),
},
directories: {
+2 -12
View File
@@ -1,19 +1,9 @@
import * as BUILD from './build';
import * as IOS from './ios';
export enum PLATFORMS {
IOS = 'ios',
ANDROID = 'android',
}
export enum IOS_BUILD_TYPES {
ARCHIVE = 'archive',
CLIENT = 'client',
SIMULATOR = 'simulator',
}
export enum ANDROID_BUILD_TYPES {
APK = 'apk',
APP_BUNDLE = 'app-bundle',
}
export { BUILD };
export { IOS, BUILD };
+5
View File
@@ -0,0 +1,5 @@
export enum BUILD_TYPES {
ARCHIVE = 'archive',
CLIENT = 'client',
SIMULATOR = 'simulator',
}
+2 -2
View File
@@ -1,4 +1,4 @@
import { ANDROID_BUILD_TYPES, IOS_BUILD_TYPES } from 'turtle/constants';
import { IOS } from 'turtle/constants';
export interface IJob {
platform: 'android' | 'ios';
@@ -9,8 +9,8 @@ export interface IJob {
config: {
releaseChannel: string;
publicUrl?: string;
buildType: IOS_BUILD_TYPES & ANDROID_BUILD_TYPES;
// ios
buildType?: IOS.BUILD_TYPES;
bundleIdentifier?: string;
// android
androidPackage?: string;
+3 -4
View File
@@ -76,10 +76,10 @@ async function processJob(jobData: any) {
const buildType = _.get(job, 'config.buildType', 'default');
try {
const status = await build(job);
buildStatusMetric.add(buildType, priority, status);
buildStatusMetric.add(buildType, status);
buildFailed = !status;
} catch (err) {
buildStatusMetric.add(buildType, priority, false);
buildStatusMetric.add(buildType, false);
buildFailed = true;
throw err;
} finally {
@@ -113,8 +113,7 @@ function failAfterMaxJobTime(priority: string, receiptHandle: string, job: any)
sqs.sendMessage(job.id, BUILD.JOB_STATES.ERRORED, { turtleVersion });
await deleteMessage(priority, receiptHandle);
} finally {
logger.error('Build timed out. Going to terminate turtle agent.');
await logger.cleanup();
logger.error('Going to terminate turtle agent, just in case...');
process.exit(1);
}
}, config.builder.maxJobTimeMs);
+3 -3
View File
@@ -1,13 +1,13 @@
import Joi from 'joi';
import { IOS_BUILD_TYPES, PLATFORMS } from 'turtle/constants/index';
import { IOS, PLATFORMS } from 'turtle/constants/index';
import baseJobSchema from 'turtle/jobsSchemas/base';
export default baseJobSchema.concat(
Joi.object().keys({
platform: Joi.string().valid(PLATFORMS.IOS),
config: Joi.object().keys({
buildType: Joi.string().default(IOS_BUILD_TYPES.ARCHIVE),
buildType: Joi.string().default(IOS.BUILD_TYPES.ARCHIVE),
bundleIdentifier: Joi.string().regex(/^[a-zA-Z][a-zA-Z0-9\-.]+$/),
}),
credentials: Joi.object()
@@ -21,7 +21,7 @@ export default baseJobSchema.concat(
udids: Joi.array().items(Joi.string()),
})
.when('config.buildType', {
is: IOS_BUILD_TYPES.SIMULATOR,
is: IOS.BUILD_TYPES.SIMULATOR,
then: Joi.optional(),
otherwise: Joi.required(),
}),
+3 -3
View File
@@ -1,5 +1,5 @@
import * as cloudwatch from 'turtle/aws/cloudwatch';
import { PRIORITY_DIMENSIONS } from 'turtle/aws/cloudwatch/dimensions';
import { TYPE_DIMENSIONS } from 'turtle/aws/cloudwatch/dimensions';
import * as reducers from 'turtle/aws/cloudwatch/reducers';
import config from 'turtle/config';
import logger from 'turtle/logger';
@@ -24,11 +24,11 @@ export function register() {
});
}
export function add(type: string, priority: string, success = true) {
export function add(type: string, success = true) {
cloudwatch.addMetricData({
name: BUILD_METRIC_NAME,
value: 1,
success,
extraDimensions: PRIORITY_DIMENSIONS(type, priority),
extraDimensions: TYPE_DIMENSIONS(type),
});
}
-54
View File
@@ -1,54 +0,0 @@
import groupBy from 'lodash/groupBy';
import mapValues from 'lodash/mapValues';
import take from 'lodash/take';
import logger from 'turtle/logger';
import { sendMetric } from 'turtle/metrics/datadog';
import { getReplicaCount } from 'turtle/utils/metadata';
import { getLabeledConfiguration, TurtleModeLabels } from 'turtle/utils/priorities';
const createMetricName = () => `turtle.replicaCount`;
const createModeMetricName = (mode: TurtleModeLabels) => `${createMetricName()}.${mode}`;
const createModeTag = (mode: TurtleModeLabels) => `mode:${mode}`;
export default async function sendConfigToDatadog() {
const configuration = await getLabeledConfiguration();
const replicaCount = await getReplicaCount();
const currentReplicaCount = replicaCount === null ? configuration.length : replicaCount;
const replicaCounts = mapValues(
groupBy<string>(take(configuration, currentReplicaCount)),
(i) => i.length,
);
const metricName = createMetricName();
const normalReplicaCount = replicaCounts[TurtleModeLabels.Normal] || 0;
const highReplicaCount = replicaCounts[TurtleModeLabels.High] || 0;
const highOnlyReplicaCount = replicaCounts[TurtleModeLabels.HighOnly] || 0;
const normalTag = createModeTag(TurtleModeLabels.Normal);
const normalMetricName = createModeMetricName(TurtleModeLabels.Normal);
logger.debug(
`Sending ${metricName}=${normalReplicaCount} (${normalTag}), ${normalMetricName}=${normalReplicaCount} to Datadog`,
);
await sendMetric(metricName, normalReplicaCount, [normalTag]);
await sendMetric(normalMetricName, normalReplicaCount);
const highTag = createModeTag(TurtleModeLabels.High);
const highMetricName = createModeMetricName(TurtleModeLabels.High);
logger.debug(
`Sending ${metricName}=${highReplicaCount} (${highTag}), ${highMetricName}=${highReplicaCount} to Datadog`,
);
await sendMetric(metricName, highReplicaCount, [highTag]);
await sendMetric(highMetricName, highReplicaCount);
const highOnlyTag = createModeTag(TurtleModeLabels.HighOnly);
const highOnlyMetricName = createModeMetricName(TurtleModeLabels.HighOnly);
logger.debug(
`Sending ${metricName}=${highOnlyReplicaCount} (${highOnlyTag}),`
+ ` ${highOnlyMetricName}=${highOnlyReplicaCount} to Datadog`,
);
await sendMetric(metricName, highOnlyReplicaCount, [highOnlyTag]);
await sendMetric(highOnlyMetricName, highOnlyReplicaCount);
}
-24
View File
@@ -1,24 +0,0 @@
import dogapi from 'dogapi';
import util from 'util';
import config from 'turtle/config';
const datadogSendMetric = util.promisify(dogapi.metric.send);
if (!config.datadog.disabled) {
dogapi.initialize({
api_key: config.datadog.apiKey,
app_key: config.datadog.appKey,
});
}
const tags = [
`env:${config.deploymentEnv}`,
`platform:${config.platform}`,
];
export function sendMetric(name: string, value: number, additionalTags?: string[]) {
if (!config.datadog.disabled) {
return datadogSendMetric(name, value, { tags: [...tags, ...(additionalTags || [])] });
}
}
+5 -11
View File
@@ -28,33 +28,27 @@ const TIMEOUT = 3000;
const AVAILABLE_CONFIGURATIONS_IOS = [
HIGH_CONFIGURATION,
HIGH_ONLY_CONFIGURATION,
HIGH_CONFIGURATION,
HIGH_ONLY_CONFIGURATION,
HIGH_ONLY_CONFIGURATION,
HIGH_ONLY_CONFIGURATION,
// there are 5 iOS builders at the moment
HIGH_CONFIGURATION,
HIGH_CONFIGURATION,
HIGH_CONFIGURATION,
];
const AVAILABLE_CONFIGURATIONS_ANDROID = [
HIGH_CONFIGURATION,
HIGH_CONFIGURATION,
HIGH_CONFIGURATION,
HIGH_ONLY_CONFIGURATION,
HIGH_CONFIGURATION,
HIGH_ONLY_CONFIGURATION,
HIGH_CONFIGURATION,
HIGH_ONLY_CONFIGURATION,
HIGH_ONLY_CONFIGURATION,
HIGH_ONLY_CONFIGURATION,
HIGH_ONLY_CONFIGURATION,
HIGH_ONLY_CONFIGURATION,
HIGH_CONFIGURATION,
HIGH_ONLY_CONFIGURATION,
HIGH_CONFIGURATION,
HIGH_CONFIGURATION,
HIGH_CONFIGURATION,
HIGH_CONFIGURATION,
// there are 15 Android builders at the moment
HIGH_CONFIGURATION,
HIGH_CONFIGURATION,
HIGH_CONFIGURATION,
HIGH_CONFIGURATION,
-38
View File
@@ -1,38 +0,0 @@
import isNaN from 'lodash/isNaN';
import { PLATFORMS } from 'turtle/constants';
import logger from 'turtle/logger';
import { setReplicaCount } from 'turtle/utils/metadata';
import { getRedisClient, RedisClient } from 'turtle/utils/redis';
async function run() {
const platform = process.env.SCRIPT_PLATFORM;
const replicaCountRaw = process.env.SCRIPT_REPLICA_COUNT;
const replicaCount = Number(replicaCountRaw);
if (!platform || !replicaCountRaw) {
throw new Error('You must set both SCRIPT_PLATFORM and SCRIPT_REPLICA_COUNT env variables.');
}
if (!Object.values(PLATFORMS).includes(platform)) {
throw new Error(`Unsupported platform: ${platform}`);
}
if (isNaN(replicaCount)) {
throw new Error(`Wrong value for replica count: ${replicaCountRaw}`);
}
const redis = await getRedisClient(RedisClient.Configuration);
logger.info(`[${platform}] Setting replica count in redis to ${replicaCount}`);
await setReplicaCount(platform as PLATFORMS, replicaCount);
redis.disconnect();
}
if (require.main === module) {
run()
.then(() => logger.info('All done'))
.catch((err) => {
logger.error('Error:', err);
process.exit(1);
});
}
+1 -1
View File
@@ -1,4 +1,4 @@
import { LoggerDetach } from '@expo/xdl';
import { LoggerDetach } from 'xdl';
import config from 'turtle/config';
import { doJob } from 'turtle/jobManager';
-13
View File
@@ -1,23 +1,10 @@
import fs from 'fs-extra';
import config from 'turtle/config';
import logger from 'turtle/logger';
import * as metrics from 'turtle/metrics';
import sendConfigToDatadog from 'turtle/metrics/buildersConfig';
export default async function commonSetup() {
announceBuildersConfig();
await metrics.init();
await fs.remove(config.directories.temporaryFilesRoot);
await fs.remove(config.directories.tempS3LogsDir);
}
async function announceBuildersConfig() {
try {
await sendConfigToDatadog();
} catch (err) {
logger.error({ err }, 'Failed to send metrics to Datadog');
} finally {
setTimeout(announceBuildersConfig, config.datadog.intervalMs);
}
}
+4 -5
View File
@@ -1,10 +1,9 @@
declare module 'async-retry';
declare module 'copy';
declare module 'xdl';
declare module 'bunyan';
declare module 'bunyan-sentry-stream';
declare module 'bunyan-debug-stream';
declare module 'copy';
declare module 'dogapi';
declare module 'async-retry';
declare module 'ioredis';
declare module 'is-semver';
declare module 'request-progress';
declare module '@expo/xdl';
declare module 'is-semver';
-11
View File
@@ -16,16 +16,5 @@ export const env = (varName: string, defaultValue?: any) => {
export const envOptional = (varName: string) => env(varName, null);
export const envTransform = (varName: string, defaultValue: any, fn: any) => fn(env(varName, defaultValue));
export const envNum = (varName: string, defaultValue?: number) => parseInt(env(varName, defaultValue), 10);
export const envBoolean = (varName: string, defaultValue?: boolean) => {
let defaultString;
if (defaultValue === true) {
defaultString = 'true';
} else if (defaultValue === false) {
defaultString = 'false';
} else {
defaultString = defaultValue;
}
return env(varName, defaultString) === 'true';
};
const isOffline = () => process.env.TURTLE_MODE === 'offline';
-21
View File
@@ -1,21 +0,0 @@
import config from 'turtle/config';
import { PLATFORMS } from 'turtle/constants';
import { getRedisClient, RedisClient } from 'turtle/utils/redis';
const createKeyPrefix = (platform: PLATFORMS) => `${config.deploymentEnv}:${platform}`;
const createReplicaCountKey = (platform: PLATFORMS) => `${createKeyPrefix(platform)}:replicaCount`;
export async function setReplicaCount(platform: PLATFORMS, replicaCount: number) {
const redis = await getRedisClient(RedisClient.Configuration);
await redis.set(
createReplicaCountKey(platform),
replicaCount,
);
}
export async function getReplicaCount(maybePlatform?: PLATFORMS) {
const platform = maybePlatform || config.platform;
const redis = await getRedisClient(RedisClient.Configuration);
const result = await redis.get(createReplicaCountKey(platform));
return result === null ? null : Number(result);
}
+1 -26
View File
@@ -1,5 +1,4 @@
import Joi from 'joi';
import isEqual from 'lodash/isEqual';
import os from 'os';
import config from 'turtle/config';
@@ -9,12 +8,6 @@ import { getRedisClient, RedisClient } from 'turtle/utils/redis';
export const NORMAL = 'normalPriority';
export const HIGH = 'highPriority';
export enum TurtleModeLabels {
Normal = 'normal',
High = 'high',
HighOnly = 'highOnly',
}
export const NORMAL_CONFIGURATION = [NORMAL, HIGH];
export const HIGH_CONFIGURATION = [HIGH, NORMAL];
export const HIGH_ONLY_CONFIGURATION = [HIGH];
@@ -63,7 +56,7 @@ export async function getPriorities() {
}
try {
const configurations = await getConfiguration(redis);
const configurations = JSON.parse(await redis.get(createConfigurationsKey()));
const configurationsIndex = await redis.getConfig(createConfigurationsKey(), os.hostname());
logger.debug(`Using configuration at index ${configurationsIndex} pulled from redis`);
const { error, value: configValue } = configSchema.validate(configurations[configurationsIndex]);
@@ -92,21 +85,3 @@ export async function getPriorities() {
}
}
}
export async function getConfiguration(currentRedisClient: any) {
const redis = currentRedisClient || await getRedisClient(RedisClient.Configuration);
return JSON.parse(await redis.get(createConfigurationsKey()));
}
export async function getLabeledConfiguration(currentRedisClient?: any) {
const configuration = await getConfiguration(currentRedisClient);
return configuration.map((i: string[]) => {
if (isEqual(i, NORMAL_CONFIGURATION)) {
return TurtleModeLabels.Normal;
} else if (isEqual(i, HIGH_CONFIGURATION)) {
return TurtleModeLabels.High;
} else {
return TurtleModeLabels.HighOnly;
}
});
}
-1
View File
@@ -79,7 +79,6 @@ export async function registerListener(jobId: string, deleteMessage: any) {
if (message === jobId) {
logger.info({ lastBuildLog: true }, 'Job cancelled - killing process');
await deleteMessage();
await logger.cleanup();
setTimeout(() => process.exit(1), MILLIS_TO_UPLOAD_LOGS);
}
});
+140 -1222
View File
File diff suppressed because it is too large. Load diff