Skip to content

Commit

Permalink
fix publish and test coverage for publish
Browse files Browse the repository at this point in the history
  • Loading branch information
RichiCoder1 committed Sep 4, 2020
1 parent be4aa01 commit 73ac526
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 1 deletion.
69 changes: 69 additions & 0 deletions plugins/docker/__tests__/docker.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,31 @@ describe("Docker Plugin", () => {
`${registry}:1.0.1`,
]);
});

test("should tag latest", async () => {
const sourceImage = "app:sha-123";
const hooks = setup(
{ getLatestTagInBranch: () => "v1.0.0" },
{ registry, image: sourceImage, tagLatest: true }
);
await hooks.version.promise(Auto.SEMVER.patch);
expect(exec).toHaveBeenCalledWith("git", [
"tag",
"1.0.1",
"-m",
'"Update version to 1.0.1"',
]);
expect(exec).toHaveBeenCalledWith("docker", [
"tag",
sourceImage,
`${registry}:1.0.1`,
]);
expect(exec).toHaveBeenCalledWith("docker", [
"tag",
sourceImage,
`${registry}:latest`,
]);
});
});

describe("canary", () => {
Expand Down Expand Up @@ -209,4 +234,48 @@ describe("Docker Plugin", () => {
]);
});
});

describe("publish", () => {
test("should publish next version", async () => {
const sourceImage = "app:sha-123";
const hooks = setup(
{
getLatestTagInBranch: () => "v1.0.0",
getCurrentBranch: () => "master",
remote: "github.com",
},
{ registry, image: sourceImage, tagLatest: false }
);
await hooks.version.promise(Auto.SEMVER.patch);

await hooks.publish.promise(Auto.SEMVER.patch);
expect(exec).toHaveBeenCalledWith("docker", [
"push",
`${registry}:1.0.1`,
]);
});

test("should publish latest", async () => {
const sourceImage = "app:sha-123";
const hooks = setup(
{
getLatestTagInBranch: () => "v1.0.0",
getCurrentBranch: () => "master",
remote: "github.com",
},
{ registry, image: sourceImage, tagLatest: true }
);
await hooks.version.promise(Auto.SEMVER.patch);

await hooks.publish.promise(Auto.SEMVER.patch);
expect(exec).toHaveBeenCalledWith("docker", [
"push",
`${registry}:1.0.1`,
]);
expect(exec).toHaveBeenCalledWith("docker", [
"push",
`${registry}:latest`,
]);
});
});
});
4 changes: 3 additions & 1 deletion plugins/docker/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,9 @@ export default class DockerPlugin implements IPlugin {
auto.logger.log.info("Pushing new tag to GitHub");

await Promise.all(
this.calculatedTags!.map((tag) => execPromise("docker", ["push", tag]))
this.calculatedTags!.map((tag) =>
execPromise("docker", ["push", `${this.options.registry}:${tag}`])
)
);

await execPromise("git", [
Expand Down

0 comments on commit 73ac526

Please sign in to comment.