Skip to content

Commit

Permalink
fix: include provided deps in module cache keys
Browse files Browse the repository at this point in the history
resolveVersion now includes a sorted list of module names (from the
provided dependencies) in the module version cache key.

Fixes: #307
  • Loading branch information
thsig committed Sep 28, 2018
1 parent d5d7baf commit b6652d0
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 28 deletions.
2 changes: 1 addition & 1 deletion garden-cli/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion garden-cli/src/commands/dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ import { STATIC_DIR } from "../constants"
import { processModules } from "../process"
import { readFile } from "fs-extra"
import { Module } from "../types/module"
import { getTestTasks } from "./test"
import { computeAutoReloadDependants, withDependants } from "../watch"
import { getDeployTasks } from "../tasks/deploy"
import { getTestTasks } from "../tasks/test"

const ansiBannerPath = join(STATIC_DIR, "garden-banner-2.txt")

Expand Down
25 changes: 1 addition & 24 deletions garden-cli/src/commands/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@ import {
import { TaskResults } from "../task-graph"
import { processModules } from "../process"
import { Module } from "../types/module"
import { TestTask } from "../tasks/test"
import { getTestTasks } from "../tasks/test"
import { computeAutoReloadDependants, withDependants } from "../watch"
import { Garden } from "../garden"

const testArgs = {
module: new StringsParameter({
Expand Down Expand Up @@ -104,25 +103,3 @@ export class TestCommand extends Command<Args, Opts> {
return handleTaskResults(garden, "test", results)
}
}

export async function getTestTasks(
{ garden, module, name, force = false, forceBuild = false }:
{ garden: Garden, module: Module, name?: string, force?: boolean, forceBuild?: boolean },
) {
const tasks: Promise<TestTask>[] = []

for (const test of module.testConfigs) {
if (name && test.name !== name) {
continue
}
tasks.push(TestTask.factory({
garden,
force,
forceBuild,
testConfig: test,
module,
}))
}

return Bluebird.all(tasks)
}
6 changes: 4 additions & 2 deletions garden-cli/src/garden.ts
Original file line number Diff line number Diff line change
Expand Up @@ -577,8 +577,9 @@ export class Garden {
* and the versions of its dependencies (in sorted order).
*/
async resolveVersion(moduleName: string, moduleDependencies: BuildDependencyConfig[], force = false) {
const config = this.moduleConfigs[moduleName]
const cacheKey = ["moduleVersions", moduleName]
const depModuleNames = moduleDependencies.map(m => m.name)
depModuleNames.sort()
const cacheKey = ["moduleVersions", moduleName, ...depModuleNames]

if (!force) {
const cached = <ModuleVersion>this.cache.get(cacheKey)
Expand All @@ -588,6 +589,7 @@ export class Garden {
}
}

const config = this.moduleConfigs[moduleName]
const dependencyKeys = moduleDependencies.map(dep => getModuleKey(dep.name, dep.plugin))
const dependencies = Object.values(pickKeys(this.moduleConfigs, dependencyKeys, "module config"))
const cacheContexts = dependencies.concat([config]).map(c => getModuleCacheContext(c))
Expand Down
22 changes: 22 additions & 0 deletions garden-cli/src/tasks/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,28 @@ export class TestTask extends Task {
}
}

export async function getTestTasks(
{ garden, module, name, force = false, forceBuild = false }:
{ garden: Garden, module: Module, name?: string, force?: boolean, forceBuild?: boolean },
) {
const tasks: Promise<TestTask>[] = []

for (const test of module.testConfigs) {
if (name && test.name !== name) {
continue
}
tasks.push(TestTask.factory({
garden,
force,
forceBuild,
testConfig: test,
module,
}))
}

return Bluebird.all(tasks)
}

async function getTestDependencies(garden: Garden, testConfig: TestConfig) {
return garden.getServices(testConfig.dependencies)
}
Expand Down

0 comments on commit b6652d0

Please sign in to comment.