test(e2e): add container logs to report (#343)
This commit is contained in:
parent
9754e366c1
commit
583393eb47
4 changed files with 27 additions and 14 deletions
25
.github/workflows/e2e.yml
vendored
25
.github/workflows/e2e.yml
vendored
|
|
@ -44,6 +44,9 @@ jobs:
|
||||||
- name: Prepare environment
|
- name: Prepare environment
|
||||||
run: |
|
run: |
|
||||||
mkdir -p data
|
mkdir -p data
|
||||||
|
mkdir -p playwright/temp
|
||||||
|
mkdir -p playwright/data
|
||||||
|
chmod -R 777 playwright/temp
|
||||||
touch .env.local
|
touch .env.local
|
||||||
echo "SERVER_IP=localhost" >> .env.local
|
echo "SERVER_IP=localhost" >> .env.local
|
||||||
echo "DATABASE_URL=./data/zerobyte.db" >> .env.local
|
echo "DATABASE_URL=./data/zerobyte.db" >> .env.local
|
||||||
|
|
@ -54,21 +57,31 @@ jobs:
|
||||||
- name: Wait for zerobyte to be ready
|
- name: Wait for zerobyte to be ready
|
||||||
run: |
|
run: |
|
||||||
timeout 30s bash -c 'until curl -f http://localhost:4096/healthcheck; do echo "Waiting for server..." && sleep 2; done'
|
timeout 30s bash -c 'until curl -f http://localhost:4096/healthcheck; do echo "Waiting for server..." && sleep 2; done'
|
||||||
continue-on-error: false
|
|
||||||
|
|
||||||
- name: Make playwright directory writable
|
- name: Make playwright directory writable
|
||||||
run: sudo chmod -R 777 playwright
|
run: sudo chmod 777 playwright/data/zerobyte.db
|
||||||
|
|
||||||
- name: Run Playwright tests
|
- name: Run Playwright tests
|
||||||
run: bun run test:e2e
|
run: bun run test:e2e
|
||||||
|
|
||||||
- name: Stop Docker Compose
|
- name: Dump container logs in playwright-report folder
|
||||||
if: always()
|
if: always()
|
||||||
run: docker compose down
|
run: |
|
||||||
|
tree playwright
|
||||||
|
docker logs zerobyte > playwright-report/container-logs.txt || true
|
||||||
|
|
||||||
- uses: actions/upload-artifact@v4
|
- name: Debug - print content of /test-data in container
|
||||||
|
if: failure()
|
||||||
|
run: |
|
||||||
|
docker exec zerobyte /bin/ash -c "ls -la /test-data" || true
|
||||||
|
|
||||||
|
- uses: actions/upload-artifact@v5
|
||||||
if: always()
|
if: always()
|
||||||
with:
|
with:
|
||||||
name: playwright-report
|
name: playwright-report
|
||||||
path: playwright-report/
|
path: playwright-report/
|
||||||
retention-days: 30
|
retention-days: 5
|
||||||
|
|
||||||
|
- name: Stop Docker Compose
|
||||||
|
if: always()
|
||||||
|
run: docker compose down
|
||||||
|
|
|
||||||
|
|
@ -61,9 +61,9 @@ test("user can download recovery key", async ({ page }) => {
|
||||||
const download = await downloadPromise;
|
const download = await downloadPromise;
|
||||||
|
|
||||||
expect(download.suggestedFilename()).toBe("restic.pass");
|
expect(download.suggestedFilename()).toBe("restic.pass");
|
||||||
await download.saveAs("./data/restic.pass");
|
await download.saveAs("./playwright/restic.pass");
|
||||||
|
|
||||||
const fileContent = await fs.promises.readFile("./data/restic.pass", "utf8");
|
const fileContent = await fs.promises.readFile("./playwright/restic.pass", "utf8");
|
||||||
|
|
||||||
expect(fileContent).toHaveLength(64);
|
expect(fileContent).toHaveLength(64);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,11 @@ import fs from "node:fs";
|
||||||
test.beforeAll(() => {
|
test.beforeAll(() => {
|
||||||
const testDataPath = path.join(process.cwd(), "playwright", "temp");
|
const testDataPath = path.join(process.cwd(), "playwright", "temp");
|
||||||
if (fs.existsSync(testDataPath)) {
|
if (fs.existsSync(testDataPath)) {
|
||||||
fs.rmSync(testDataPath, { recursive: true, force: true });
|
for (const file of fs.readdirSync(testDataPath)) {
|
||||||
|
fs.rmSync(path.join(testDataPath, file), { recursive: true, force: true });
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
fs.mkdirSync(testDataPath, { recursive: true });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -15,11 +19,7 @@ test("can backup & restore a file", async ({ page }) => {
|
||||||
|
|
||||||
// 0. Create a test file in /test-data
|
// 0. Create a test file in /test-data
|
||||||
const testDataPath = path.join(process.cwd(), "playwright", "temp");
|
const testDataPath = path.join(process.cwd(), "playwright", "temp");
|
||||||
if (!fs.existsSync(testDataPath)) {
|
|
||||||
fs.mkdirSync(testDataPath);
|
|
||||||
}
|
|
||||||
const filePath = path.join(testDataPath, "test.json");
|
const filePath = path.join(testDataPath, "test.json");
|
||||||
fs.chmodSync(testDataPath, 0o777);
|
|
||||||
fs.writeFileSync(filePath, JSON.stringify({ data: "test file" }));
|
fs.writeFileSync(filePath, JSON.stringify({ data: "test file" }));
|
||||||
|
|
||||||
// 1. Create a local volume on /test-data
|
// 1. Create a local volume on /test-data
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ export default defineConfig({
|
||||||
testDir: "./e2e",
|
testDir: "./e2e",
|
||||||
fullyParallel: true,
|
fullyParallel: true,
|
||||||
forbidOnly: !!process.env.CI,
|
forbidOnly: !!process.env.CI,
|
||||||
retries: process.env.CI ? 2 : 0,
|
retries: 0,
|
||||||
workers: process.env.CI ? 1 : undefined,
|
workers: process.env.CI ? 1 : undefined,
|
||||||
reporter: "html",
|
reporter: "html",
|
||||||
use: {
|
use: {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue