ci: add e2e workflow (#1422)

* ci: add e2e workflow

* fix: skip showing error

* fix: when e2e skipped, e2e still executed

* fix: job env not accessible in if

* fix: env not accessible at all in job if statement

* fix: wrong env used for step ifs

* ci: add reusable e2e-execution workflow

* fix: e2e trigger fails not supported reusable workflow within steps

* fix: composite e2e-execution action not found

* fix: reference to composite action not working without checkout

* fix: composite action has to be named action.yml

* fix: id for docker should not have spaces

* fix: shell property missing

* fix: typo one dash to much

* ci: add e2e tests

* chore: change node-version to 22

* chore: move e2e tests to code-quality workflow as duration of e2e step is about 4 minutes

* fix: deepsource issues
This commit is contained in:
Meier Lukas
2024-11-05 21:11:14 +01:00
committed by GitHub
parent 319fb47744
commit 9535154128
6 changed files with 85 additions and 6 deletions

18
e2e/health-checks.spec.ts Normal file
View File

@@ -0,0 +1,18 @@
import { describe, expect, test } from "vitest";
import { createHomarrContainer } from "./shared/create-homarr-container";
describe("Health checks", () => {
test("ready and live should return 200 OK", async () => {
// Arrange
const homarrContainer = await createHomarrContainer().start();
// Act
const readyResponse = await fetch(`http://localhost:${homarrContainer.getMappedPort(7575)}/api/health/ready`);
const liveResponse = await fetch(`http://localhost:${homarrContainer.getMappedPort(7575)}/api/health/live`);
// Assert
expect(readyResponse.status).toBe(200);
expect(liveResponse.status).toBe(200);
}, 20_000);
});

16
e2e/home.spec.ts Normal file
View File

@@ -0,0 +1,16 @@
import { describe, expect, test } from "vitest";
import { createHomarrContainer } from "./shared/create-homarr-container";
describe("Home", () => {
test("should open with status code 200", async () => {
// Arrange
const homarrContainer = await createHomarrContainer().start();
// Act
const homeResponse = await fetch(`http://localhost:${homarrContainer.getMappedPort(7575)}/`);
// Assert
expect(homeResponse.status).toBe(200);
}, 20_000);
});

View File

@@ -0,0 +1,14 @@
import { GenericContainer, Wait } from "testcontainers";
export const createHomarrContainer = () => {
if (!process.env.CI) {
throw new Error("This test should only be run in CI or with a homarr image named 'homarr-e2e'");
}
return new GenericContainer("homarr-e2e")
.withEnvironment({
AUTH_SECRET: "secret",
})
.withExposedPorts(7575)
.withWaitStrategy(Wait.forHttp("/api/health/ready", 7575));
};