mirror of
https://github.com/hoverkraft-tech/compose-action.git
synced 2026-01-14 16:43:07 +08:00
Compare commits
3 Commits
b2d60131ea
...
d3ad8ec3be
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d3ad8ec3be | ||
|
|
49c8cfd612 | ||
|
|
99df94c183 |
@ -41,7 +41,7 @@ Some extra options can be passed to the `docker compose up` command using the `u
|
|||||||
### Post hook
|
### Post hook
|
||||||
|
|
||||||
On post hook, the action will run `docker compose down` to clean up the services.
|
On post hook, the action will run `docker compose down` to clean up the services.
|
||||||
In [debug mode](https://docs.github.com/en/actions/monitoring-and-troubleshooting-workflows/troubleshooting-workflows/enabling-debug-logging), the logs of the running services are printed before the cleanup.
|
In debug mode, the logs of the running services are printed before the cleanup.
|
||||||
|
|
||||||
Some extra options can be passed to the `docker compose down` command using the `down-flags` input.
|
Some extra options can be passed to the `docker compose down` command using the `down-flags` input.
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
name: "Docker Compose Action"
|
name: "Docker Compose Action"
|
||||||
description: "This action runs your compose file(s) and clean up before action finished"
|
description: "This action runs your compose file and clean up before action finished"
|
||||||
author: "Hoverkraft"
|
author: "Hoverkraft"
|
||||||
branding:
|
branding:
|
||||||
icon: anchor
|
icon: anchor
|
||||||
|
|||||||
5
dist/index.js
generated
vendored
5
dist/index.js
generated
vendored
@ -33178,7 +33178,6 @@ async function run() {
|
|||||||
cwd: inputs.cwd,
|
cwd: inputs.cwd,
|
||||||
upFlags: inputs.upFlags,
|
upFlags: inputs.upFlags,
|
||||||
services: inputs.services,
|
services: inputs.services,
|
||||||
debug: loggerService.debug,
|
|
||||||
});
|
});
|
||||||
loggerService.info("docker compose service(s) are up");
|
loggerService.info("docker compose service(s) are up");
|
||||||
}
|
}
|
||||||
@ -33314,12 +33313,12 @@ class DockerComposeService {
|
|||||||
output: out,
|
output: out,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
getCommonOptions({ dockerFlags, composeFiles, composeFlags, cwd, debug, }) {
|
getCommonOptions({ dockerFlags, composeFiles, composeFlags, cwd, }) {
|
||||||
return {
|
return {
|
||||||
config: composeFiles,
|
config: composeFiles,
|
||||||
|
log: true,
|
||||||
composeOptions: composeFlags,
|
composeOptions: composeFlags,
|
||||||
cwd: cwd,
|
cwd: cwd,
|
||||||
callback: (chunk) => debug(chunk.toString()),
|
|
||||||
executable: {
|
executable: {
|
||||||
executablePath: "docker",
|
executablePath: "docker",
|
||||||
options: dockerFlags,
|
options: dockerFlags,
|
||||||
|
|||||||
6
dist/post.js
generated
vendored
6
dist/post.js
generated
vendored
@ -26340,7 +26340,6 @@ async function run() {
|
|||||||
composeFlags: inputs.composeFlags,
|
composeFlags: inputs.composeFlags,
|
||||||
cwd: inputs.cwd,
|
cwd: inputs.cwd,
|
||||||
services: inputs.services,
|
services: inputs.services,
|
||||||
debug: loggerService.debug,
|
|
||||||
});
|
});
|
||||||
if (error) {
|
if (error) {
|
||||||
loggerService.debug("docker compose error:\n" + error);
|
loggerService.debug("docker compose error:\n" + error);
|
||||||
@ -26352,7 +26351,6 @@ async function run() {
|
|||||||
composeFlags: inputs.composeFlags,
|
composeFlags: inputs.composeFlags,
|
||||||
cwd: inputs.cwd,
|
cwd: inputs.cwd,
|
||||||
downFlags: inputs.downFlags,
|
downFlags: inputs.downFlags,
|
||||||
debug: loggerService.debug,
|
|
||||||
});
|
});
|
||||||
loggerService.info("docker compose is down");
|
loggerService.info("docker compose is down");
|
||||||
}
|
}
|
||||||
@ -26403,12 +26401,12 @@ class DockerComposeService {
|
|||||||
output: out,
|
output: out,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
getCommonOptions({ dockerFlags, composeFiles, composeFlags, cwd, debug, }) {
|
getCommonOptions({ dockerFlags, composeFiles, composeFlags, cwd, }) {
|
||||||
return {
|
return {
|
||||||
config: composeFiles,
|
config: composeFiles,
|
||||||
|
log: true,
|
||||||
composeOptions: composeFlags,
|
composeOptions: composeFlags,
|
||||||
cwd: cwd,
|
cwd: cwd,
|
||||||
callback: (chunk) => debug(chunk.toString()),
|
|
||||||
executable: {
|
executable: {
|
||||||
executablePath: "docker",
|
executablePath: "docker",
|
||||||
options: dockerFlags,
|
options: dockerFlags,
|
||||||
|
|||||||
@ -66,7 +66,6 @@ describe("run", () => {
|
|||||||
cwd: "/current/working/dir",
|
cwd: "/current/working/dir",
|
||||||
upFlags: [],
|
upFlags: [],
|
||||||
services: [],
|
services: [],
|
||||||
debug: debugMock,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(setFailedMock).not.toHaveBeenCalled();
|
expect(setFailedMock).not.toHaveBeenCalled();
|
||||||
@ -97,7 +96,6 @@ describe("run", () => {
|
|||||||
cwd: "/current/working/dir",
|
cwd: "/current/working/dir",
|
||||||
upFlags: [],
|
upFlags: [],
|
||||||
services: ["web"],
|
services: ["web"],
|
||||||
debug: debugMock,
|
|
||||||
});
|
});
|
||||||
expect(setFailedMock).not.toHaveBeenCalled();
|
expect(setFailedMock).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|||||||
@ -42,7 +42,6 @@ export async function run(): Promise<void> {
|
|||||||
cwd: inputs.cwd,
|
cwd: inputs.cwd,
|
||||||
upFlags: inputs.upFlags,
|
upFlags: inputs.upFlags,
|
||||||
services: inputs.services,
|
services: inputs.services,
|
||||||
debug: loggerService.debug,
|
|
||||||
});
|
});
|
||||||
loggerService.info("docker compose service(s) are up");
|
loggerService.info("docker compose service(s) are up");
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@ -61,7 +61,6 @@ describe("index", () => {
|
|||||||
composeFlags: [],
|
composeFlags: [],
|
||||||
upFlags: [],
|
upFlags: [],
|
||||||
cwd: "/current/working/dir",
|
cwd: "/current/working/dir",
|
||||||
debug: debugMock,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(setFailedMock).not.toHaveBeenCalled();
|
expect(setFailedMock).not.toHaveBeenCalled();
|
||||||
|
|||||||
@ -52,7 +52,6 @@ describe("run", () => {
|
|||||||
composeFlags: [],
|
composeFlags: [],
|
||||||
cwd: "/current/working/dir",
|
cwd: "/current/working/dir",
|
||||||
services: [],
|
services: [],
|
||||||
debug: debugMock,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(downMock).toHaveBeenCalledWith({
|
expect(downMock).toHaveBeenCalledWith({
|
||||||
@ -61,7 +60,6 @@ describe("run", () => {
|
|||||||
composeFlags: [],
|
composeFlags: [],
|
||||||
cwd: "/current/working/dir",
|
cwd: "/current/working/dir",
|
||||||
downFlags: [],
|
downFlags: [],
|
||||||
debug: debugMock,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(debugMock).toHaveBeenCalledWith("docker compose logs:\ntest logs");
|
expect(debugMock).toHaveBeenCalledWith("docker compose logs:\ntest logs");
|
||||||
@ -102,7 +100,6 @@ describe("run", () => {
|
|||||||
cwd: "/current/working/dir",
|
cwd: "/current/working/dir",
|
||||||
dockerFlags: [],
|
dockerFlags: [],
|
||||||
services: [],
|
services: [],
|
||||||
debug: debugMock,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(downMock).toHaveBeenCalledWith({
|
expect(downMock).toHaveBeenCalledWith({
|
||||||
@ -111,7 +108,6 @@ describe("run", () => {
|
|||||||
cwd: "/current/working/dir",
|
cwd: "/current/working/dir",
|
||||||
dockerFlags: [],
|
dockerFlags: [],
|
||||||
downFlags: [],
|
downFlags: [],
|
||||||
debug: debugMock,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(debugMock).toHaveBeenCalledWith("docker compose error:\ntest logs error");
|
expect(debugMock).toHaveBeenCalledWith("docker compose error:\ntest logs error");
|
||||||
|
|||||||
@ -21,7 +21,6 @@ export async function run(): Promise<void> {
|
|||||||
composeFlags: inputs.composeFlags,
|
composeFlags: inputs.composeFlags,
|
||||||
cwd: inputs.cwd,
|
cwd: inputs.cwd,
|
||||||
services: inputs.services,
|
services: inputs.services,
|
||||||
debug: loggerService.debug,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
@ -36,7 +35,6 @@ export async function run(): Promise<void> {
|
|||||||
composeFlags: inputs.composeFlags,
|
composeFlags: inputs.composeFlags,
|
||||||
cwd: inputs.cwd,
|
cwd: inputs.cwd,
|
||||||
downFlags: inputs.downFlags,
|
downFlags: inputs.downFlags,
|
||||||
debug: loggerService.debug,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
loggerService.info("docker compose is down");
|
loggerService.info("docker compose is down");
|
||||||
|
|||||||
@ -48,7 +48,6 @@ describe("post", () => {
|
|||||||
composeFlags: [],
|
composeFlags: [],
|
||||||
cwd: "/current/working/dir",
|
cwd: "/current/working/dir",
|
||||||
services: [],
|
services: [],
|
||||||
debug: debugMock,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(downMock).toHaveBeenCalledWith({
|
expect(downMock).toHaveBeenCalledWith({
|
||||||
@ -57,7 +56,6 @@ describe("post", () => {
|
|||||||
composeFlags: [],
|
composeFlags: [],
|
||||||
cwd: "/current/working/dir",
|
cwd: "/current/working/dir",
|
||||||
downFlags: [],
|
downFlags: [],
|
||||||
debug: debugMock,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(debugMock).toHaveBeenNthCalledWith(1, "docker compose logs:\ntest logs");
|
expect(debugMock).toHaveBeenNthCalledWith(1, "docker compose logs:\ntest logs");
|
||||||
|
|||||||
@ -31,7 +31,6 @@ describe("DockerComposeService", () => {
|
|||||||
composeFlags: [],
|
composeFlags: [],
|
||||||
upFlags: [],
|
upFlags: [],
|
||||||
cwd: "/current/working/dir",
|
cwd: "/current/working/dir",
|
||||||
debug: jest.fn(),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
await service.up(upInputs);
|
await service.up(upInputs);
|
||||||
@ -44,8 +43,8 @@ describe("DockerComposeService", () => {
|
|||||||
executablePath: "docker",
|
executablePath: "docker",
|
||||||
options: [],
|
options: [],
|
||||||
},
|
},
|
||||||
|
log: true,
|
||||||
cwd: "/current/working/dir",
|
cwd: "/current/working/dir",
|
||||||
callback: expect.any(Function),
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -57,7 +56,6 @@ describe("DockerComposeService", () => {
|
|||||||
composeFlags: [],
|
composeFlags: [],
|
||||||
upFlags: [],
|
upFlags: [],
|
||||||
cwd: "/current/working/dir",
|
cwd: "/current/working/dir",
|
||||||
debug: jest.fn(),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
await service.up(upInputs);
|
await service.up(upInputs);
|
||||||
@ -70,8 +68,8 @@ describe("DockerComposeService", () => {
|
|||||||
executablePath: "docker",
|
executablePath: "docker",
|
||||||
options: ["--context", "dev"],
|
options: ["--context", "dev"],
|
||||||
},
|
},
|
||||||
|
log: true,
|
||||||
cwd: "/current/working/dir",
|
cwd: "/current/working/dir",
|
||||||
callback: expect.any(Function),
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -83,7 +81,6 @@ describe("DockerComposeService", () => {
|
|||||||
composeFlags: [],
|
composeFlags: [],
|
||||||
upFlags: ["--build"],
|
upFlags: ["--build"],
|
||||||
cwd: "/current/working/dir",
|
cwd: "/current/working/dir",
|
||||||
debug: jest.fn(),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
await service.up(upInputs);
|
await service.up(upInputs);
|
||||||
@ -93,11 +90,11 @@ describe("DockerComposeService", () => {
|
|||||||
commandOptions: ["--build"],
|
commandOptions: ["--build"],
|
||||||
config: ["docker-compose.yml"],
|
config: ["docker-compose.yml"],
|
||||||
cwd: "/current/working/dir",
|
cwd: "/current/working/dir",
|
||||||
callback: expect.any(Function),
|
|
||||||
executable: {
|
executable: {
|
||||||
executablePath: "docker",
|
executablePath: "docker",
|
||||||
options: [],
|
options: [],
|
||||||
},
|
},
|
||||||
|
log: true,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -110,7 +107,6 @@ describe("DockerComposeService", () => {
|
|||||||
composeFlags: [],
|
composeFlags: [],
|
||||||
downFlags: ["--volumes", "--remove-orphans"],
|
downFlags: ["--volumes", "--remove-orphans"],
|
||||||
cwd: "/current/working/dir",
|
cwd: "/current/working/dir",
|
||||||
debug: jest.fn(),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
await service.down(downInputs);
|
await service.down(downInputs);
|
||||||
@ -123,22 +119,20 @@ describe("DockerComposeService", () => {
|
|||||||
executablePath: "docker",
|
executablePath: "docker",
|
||||||
options: [],
|
options: [],
|
||||||
},
|
},
|
||||||
|
log: true,
|
||||||
cwd: "/current/working/dir",
|
cwd: "/current/working/dir",
|
||||||
callback: expect.any(Function),
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("logs", () => {
|
describe("logs", () => {
|
||||||
it("should call logs with correct options", async () => {
|
it("should call logs with correct options", async () => {
|
||||||
const debugMock = jest.fn();
|
|
||||||
const logsInputs: LogsInputs = {
|
const logsInputs: LogsInputs = {
|
||||||
dockerFlags: [],
|
dockerFlags: [],
|
||||||
composeFiles: ["docker-compose.yml"],
|
composeFiles: ["docker-compose.yml"],
|
||||||
services: ["helloworld2", "helloworld3"],
|
services: ["helloworld2", "helloworld3"],
|
||||||
composeFlags: [],
|
composeFlags: [],
|
||||||
cwd: "/current/working/dir",
|
cwd: "/current/working/dir",
|
||||||
debug: debugMock,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
logsMock.mockResolvedValue({ exitCode: 0, err: "", out: "logs" });
|
logsMock.mockResolvedValue({ exitCode: 0, err: "", out: "logs" });
|
||||||
@ -148,13 +142,13 @@ describe("DockerComposeService", () => {
|
|||||||
expect(dockerCompose.logs).toHaveBeenCalledWith(["helloworld2", "helloworld3"], {
|
expect(dockerCompose.logs).toHaveBeenCalledWith(["helloworld2", "helloworld3"], {
|
||||||
composeOptions: [],
|
composeOptions: [],
|
||||||
config: ["docker-compose.yml"],
|
config: ["docker-compose.yml"],
|
||||||
|
log: true,
|
||||||
cwd: "/current/working/dir",
|
cwd: "/current/working/dir",
|
||||||
executable: {
|
executable: {
|
||||||
executablePath: "docker",
|
executablePath: "docker",
|
||||||
options: [],
|
options: [],
|
||||||
},
|
},
|
||||||
follow: false,
|
follow: false,
|
||||||
callback: expect.any(Function),
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -13,7 +13,6 @@ type OptionsInputs = {
|
|||||||
composeFiles: Inputs["composeFiles"];
|
composeFiles: Inputs["composeFiles"];
|
||||||
composeFlags: Inputs["composeFlags"];
|
composeFlags: Inputs["composeFlags"];
|
||||||
cwd: Inputs["cwd"];
|
cwd: Inputs["cwd"];
|
||||||
debug: (message: string) => void;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export type UpInputs = OptionsInputs & { upFlags: Inputs["upFlags"]; services: Inputs["services"] };
|
export type UpInputs = OptionsInputs & { upFlags: Inputs["upFlags"]; services: Inputs["services"] };
|
||||||
@ -66,13 +65,12 @@ export class DockerComposeService {
|
|||||||
composeFiles,
|
composeFiles,
|
||||||
composeFlags,
|
composeFlags,
|
||||||
cwd,
|
cwd,
|
||||||
debug,
|
|
||||||
}: OptionsInputs): IDockerComposeOptions {
|
}: OptionsInputs): IDockerComposeOptions {
|
||||||
return {
|
return {
|
||||||
config: composeFiles,
|
config: composeFiles,
|
||||||
|
log: true,
|
||||||
composeOptions: composeFlags,
|
composeOptions: composeFlags,
|
||||||
cwd: cwd,
|
cwd: cwd,
|
||||||
callback: (chunk) => debug(chunk.toString()),
|
|
||||||
executable: {
|
executable: {
|
||||||
executablePath: "docker",
|
executablePath: "docker",
|
||||||
options: dockerFlags,
|
options: dockerFlags,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user