From 95c93d24da41aee611bac2e74f9e216aafdb2684 Mon Sep 17 00:00:00 2001 From: Cameron Diver Date: Tue, 18 Feb 2020 10:21:12 +0700 Subject: [PATCH] Update resin-multibuild and add app and release template vars Change-type: minor Signed-off-by: Cameron Diver --- lib/utils/compose.coffee | 2 +- lib/utils/compose_ts.ts | 10 +++++++++- lib/utils/device/deploy.ts | 18 +++++++++++++++--- npm-shrinkwrap.json | 38 +++++++++++++++++++------------------- package.json | 2 +- 5 files changed, 45 insertions(+), 25 deletions(-) diff --git a/lib/utils/compose.coffee b/lib/utils/compose.coffee index c577f9ea..8baa1719 100644 --- a/lib/utils/compose.coffee +++ b/lib/utils/compose.coffee @@ -195,7 +195,7 @@ exports.buildProject = ( # Tar up the directory, ready for the build stream tarDirectory(projectPath, { convertEol }) .then (tarStream) -> - Promise.resolve(makeBuildTasks(composition, tarStream, { arch, deviceType }, logger)) + Promise.resolve(makeBuildTasks(composition, tarStream, { arch, deviceType }, logger, projectName)) .map (task) -> d = imageDescriptorsByServiceName[task.serviceName] diff --git a/lib/utils/compose_ts.ts b/lib/utils/compose_ts.ts index 0ae5f07f..87351059 100644 --- a/lib/utils/compose_ts.ts +++ b/lib/utils/compose_ts.ts @@ -242,6 +242,8 @@ export async function makeBuildTasks( tarStream: Readable, deviceInfo: DeviceInfo, logger: Logger, + projectName: string, + releaseHash: string = 'unavailable', ): Promise { const buildTasks = await MultiBuild.splitBuildStream(composition, tarStream); @@ -260,7 +262,7 @@ export async function makeBuildTasks( `Resolving services with [${deviceInfo.deviceType}|${deviceInfo.arch}]`, ); - await performResolution(buildTasks, deviceInfo); + await performResolution(buildTasks, deviceInfo, projectName, releaseHash); logger.logDebug('Found project types:'); _.each(buildTasks, task => { @@ -277,6 +279,8 @@ export async function makeBuildTasks( async function performResolution( tasks: MultiBuild.BuildTask[], deviceInfo: DeviceInfo, + appName: string, + releaseHash: string, ): Promise { const { cloneTarStream } = require('tar-utils'); @@ -286,6 +290,10 @@ async function performResolution( deviceInfo.arch, deviceInfo.deviceType, { error: [reject] }, + { + BALENA_RELEASE_HASH: releaseHash, + BALENA_APP_NAME: appName, + }, ); // Do one task at a time (Bluebird.each instead of Bluebird.all) // in order to reduce peak memory usage. Resolves to buildTasks. diff --git a/lib/utils/device/deploy.ts b/lib/utils/device/deploy.ts index c1d42927..4c4ed0af 100644 --- a/lib/utils/device/deploy.ts +++ b/lib/utils/device/deploy.ts @@ -42,6 +42,9 @@ import { DeviceAPIError } from './errors'; import LivepushManager from './live'; import { displayBuildLog } from './logs'; +const LOCAL_APPNAME = 'localapp'; +const LOCAL_RELEASEHASH = 'localrelease'; + // Define the logger here so the debug output // can be used everywhere const globalLogger = Logger.getLogger(); @@ -304,6 +307,8 @@ export async function performBuilds( tarStream, deviceInfo, logger, + LOCAL_APPNAME, + LOCAL_RELEASEHASH, ); logger.logDebug('Probing remote daemon for cache images'); @@ -391,7 +396,14 @@ export async function rebuildSingleTask( const tarStream = await tarDirectory(source); const task = _.find( - await makeBuildTasks(composition, tarStream, deviceInfo, logger), + await makeBuildTasks( + composition, + tarStream, + deviceInfo, + logger, + LOCAL_APPNAME, + LOCAL_RELEASEHASH, + ), { serviceName }, ); @@ -549,8 +561,8 @@ export function generateTargetState( targetState.local.apps = { 1: { - name: 'localapp', - commit: 'localrelease', + name: LOCAL_APPNAME, + commit: LOCAL_RELEASEHASH, releaseId: '1', services, volumes: composition.volumes || {}, diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index e8b88636..fd21f26a 100644 --- a/npm-shrinkwrap.json +++ b/npm-shrinkwrap.json @@ -5702,9 +5702,9 @@ "integrity": "sha1-mMI9qxF1ZXuMBXPozszZGw/xjIQ=" }, "fp-ts": { - "version": "2.4.2", - "resolved": "https://registry.npmjs.org/fp-ts/-/fp-ts-2.4.2.tgz", - "integrity": "sha512-/6dNmbu2CRhwR+/OpjLYT3OAlIlyrnY1qjbGDeyYkisTqQfbIdWL1P4sn28yKhcBLcfIvjo9614sfo0EKscOMA==" + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/fp-ts/-/fp-ts-2.5.0.tgz", + "integrity": "sha512-xkC9ZKl/i2cU+8FAsdyLcTvPRXphp42FcK5WmZpB47VXb4gggC3DHlVDKNLdbC+U8zz6yp1b0bj0mZg0axmZYQ==" }, "fragment-cache": { "version": "0.2.1", @@ -7738,9 +7738,9 @@ "dev": true }, "io-ts": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/io-ts/-/io-ts-2.0.6.tgz", - "integrity": "sha512-WNfGzm4csMVwL4hX6QlpQWu65SV6GmOUtDo259GKlLYH1cC5bpOENgYHqQIRJ9uR3FuU1RQKDke5STwHZAn3KA==" + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/io-ts/-/io-ts-2.1.1.tgz", + "integrity": "sha512-6mDCiTc/0uNtC8M1u/kcNiw5JUTlREFCGV7pjcbrQrUDguLkOpuzb4wbJcU78G74QvkhQdvT3F3dAupycXN95g==" }, "io-ts-reporters": { "version": "1.0.0", @@ -15399,9 +15399,9 @@ "dev": true }, "resin-bundle-resolve": { - "version": "4.1.3", - "resolved": "https://registry.npmjs.org/resin-bundle-resolve/-/resin-bundle-resolve-4.1.3.tgz", - "integrity": "sha512-3/1ZmDQuf/Nmwlqx0fY0kaJV99Kcj+GBP3azwghYvkRGzDgbX7aBnA+C6pMZylIsP+TPu5bcqJDRip1aKq0XVw==", + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/resin-bundle-resolve/-/resin-bundle-resolve-4.2.0.tgz", + "integrity": "sha512-zACrgV73TRqsmeRyMz051yxEC85qqkUH+Fi6NAxcLfFh0LWFiZkEYNhHZmh+qBYyampDF2u7Vwm0oO/Rll8iDg==", "requires": { "@types/tar-stream": "^1.6.0", "bluebird": "^3.5.4", @@ -15424,9 +15424,9 @@ } }, "readable-stream": { - "version": "3.5.0", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.5.0.tgz", - "integrity": "sha512-gSz026xs2LfxBPudDuI41V1lka8cxg64E66SGe78zJlsUofOg/yqwezdIcdfwik6B4h8LFmWPA9ef9X3FiNFLA==", + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", + "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", "requires": { "inherits": "^2.0.3", "string_decoder": "^1.1.1", @@ -15970,9 +15970,9 @@ } }, "resin-multibuild": { - "version": "4.3.4", - "resolved": "https://registry.npmjs.org/resin-multibuild/-/resin-multibuild-4.3.4.tgz", - "integrity": "sha512-9CGuxvnEFP3h3kcBJb2UUr37DwTEEjTf8LduVRLyB9PVSp5sq+aj71/qhSbluvPfAUWodR7KtgnNa4ENYKe/WA==", + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/resin-multibuild/-/resin-multibuild-4.4.0.tgz", + "integrity": "sha512-iC8oMvgsfFn7lCELkDHjavy4Me5MuhDxYkjcQv0P3p0uUbHeZV+XAScOPDpLyR9PTxTLvhXGg4DRPG28tN3SfA==", "requires": { "@types/bluebird": "3.5.20", "@types/dockerode": "2.5.5", @@ -15989,7 +15989,7 @@ "io-ts-reporters": "^1.0.0", "js-yaml": "^3.13.1", "lodash": "^4.17.4", - "resin-bundle-resolve": "^4.1.3", + "resin-bundle-resolve": "^4.2.0", "resin-compose-parse": "^2.0.4", "resin-docker-build": "^1.1.2", "tar-stream": "^2.0.1", @@ -16020,9 +16020,9 @@ } }, "readable-stream": { - "version": "3.5.0", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.5.0.tgz", - "integrity": "sha512-gSz026xs2LfxBPudDuI41V1lka8cxg64E66SGe78zJlsUofOg/yqwezdIcdfwik6B4h8LFmWPA9ef9X3FiNFLA==", + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", + "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", "requires": { "inherits": "^2.0.3", "string_decoder": "^1.1.1", diff --git a/package.json b/package.json index 11318e05..7ac2eefd 100644 --- a/package.json +++ b/package.json @@ -225,7 +225,7 @@ "resin-compose-parse": "^2.1.0", "resin-doodles": "^0.1.1", "resin-image-fs": "^5.0.8", - "resin-multibuild": "^4.3.4", + "resin-multibuild": "^4.4.0", "resin-release": "^1.2.0", "resin-semver": "^1.6.0", "resin-stream-logger": "^0.1.2",