-
Notifications
You must be signed in to change notification settings - Fork 273
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf: generic plugin now keeps track of last built version
- Loading branch information
Showing
5 changed files
with
134 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -319,5 +319,3 @@ export class Module< | |
} | ||
} | ||
} | ||
|
||
export type ModuleConfigType<M extends Module> = M["_ConfigType"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import { expect } from "chai" | ||
import { | ||
join, | ||
resolve, | ||
} from "path" | ||
import { Garden } from "../../../src/garden" | ||
import { PluginContext } from "../../../src/plugin-context" | ||
import { | ||
gardenPlugin, | ||
} from "../../../src/plugins/container" | ||
import { | ||
buildVersionFilename, | ||
} from "../../../src/plugins/generic" | ||
import { Environment } from "../../../src/types/common" | ||
import { | ||
readVersionFile, | ||
writeVersionFile, | ||
} from "../../../src/vcs/base" | ||
import { | ||
dataDir, | ||
makeTestGarden, | ||
} from "../../helpers" | ||
|
||
describe("generic plugin", () => { | ||
const projectRoot = resolve(dataDir, "test-project-a") | ||
const moduleName = "module-a" | ||
|
||
let garden: Garden | ||
let ctx: PluginContext | ||
let env: Environment | ||
|
||
beforeEach(async () => { | ||
garden = await makeTestGarden(projectRoot, [gardenPlugin]) | ||
ctx = garden.pluginContext | ||
env = garden.getEnvironment() | ||
await garden.clearBuilds() | ||
}) | ||
|
||
describe("getModuleBuildStatus", () => { | ||
it("should read a build version file if it exists", async () => { | ||
const module = await ctx.getModule(moduleName) | ||
const version = await module.getVersion() | ||
const buildPath = await module.getBuildPath() | ||
const versionFilePath = join(buildPath, buildVersionFilename) | ||
|
||
await writeVersionFile(versionFilePath, { | ||
latestCommit: version.versionString, | ||
dirtyTimestamp: version.dirtyTimestamp, | ||
}) | ||
|
||
const result = await ctx.getModuleBuildStatus({ moduleName }) | ||
|
||
expect(result.ready).to.be.true | ||
}) | ||
}) | ||
|
||
describe("buildModule", () => { | ||
it("should write a build version file after building", async () => { | ||
const module = await ctx.getModule(moduleName) | ||
const version = await module.getVersion() | ||
const buildPath = await module.getBuildPath() | ||
const versionFilePath = join(buildPath, buildVersionFilename) | ||
|
||
await ctx.buildModule({ moduleName }) | ||
|
||
const versionFileContents = await readVersionFile(versionFilePath) | ||
|
||
expect(versionFileContents).to.eql({ | ||
latestCommit: version.versionString, | ||
dirtyTimestamp: version.dirtyTimestamp, | ||
}) | ||
}) | ||
}) | ||
}) |