mirror of
https://github.com/nicotsx/zerobyte.git
synced 2026-02-07 03:51:13 -05:00
test(e2e): add container logs to report (#343)
This commit is contained in:
committed by
Nicolas Meienberger
parent
9754e366c1
commit
583393eb47
25
.github/workflows/e2e.yml
vendored
25
.github/workflows/e2e.yml
vendored
@@ -44,6 +44,9 @@ jobs:
|
||||
- name: Prepare environment
|
||||
run: |
|
||||
mkdir -p data
|
||||
mkdir -p playwright/temp
|
||||
mkdir -p playwright/data
|
||||
chmod -R 777 playwright/temp
|
||||
touch .env.local
|
||||
echo "SERVER_IP=localhost" >> .env.local
|
||||
echo "DATABASE_URL=./data/zerobyte.db" >> .env.local
|
||||
@@ -54,21 +57,31 @@ jobs:
|
||||
- name: Wait for zerobyte to be ready
|
||||
run: |
|
||||
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
|
||||
run: sudo chmod -R 777 playwright
|
||||
run: sudo chmod 777 playwright/data/zerobyte.db
|
||||
|
||||
- name: Run Playwright tests
|
||||
run: bun run test:e2e
|
||||
|
||||
- name: Stop Docker Compose
|
||||
- name: Dump container logs in playwright-report folder
|
||||
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()
|
||||
with:
|
||||
name: 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;
|
||||
|
||||
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);
|
||||
});
|
||||
|
||||
@@ -5,7 +5,11 @@ import fs from "node:fs";
|
||||
test.beforeAll(() => {
|
||||
const testDataPath = path.join(process.cwd(), "playwright", "temp");
|
||||
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
|
||||
const testDataPath = path.join(process.cwd(), "playwright", "temp");
|
||||
if (!fs.existsSync(testDataPath)) {
|
||||
fs.mkdirSync(testDataPath);
|
||||
}
|
||||
const filePath = path.join(testDataPath, "test.json");
|
||||
fs.chmodSync(testDataPath, 0o777);
|
||||
fs.writeFileSync(filePath, JSON.stringify({ data: "test file" }));
|
||||
|
||||
// 1. Create a local volume on /test-data
|
||||
|
||||
@@ -5,7 +5,7 @@ export default defineConfig({
|
||||
testDir: "./e2e",
|
||||
fullyParallel: true,
|
||||
forbidOnly: !!process.env.CI,
|
||||
retries: process.env.CI ? 2 : 0,
|
||||
retries: 0,
|
||||
workers: process.env.CI ? 1 : undefined,
|
||||
reporter: "html",
|
||||
use: {
|
||||
|
||||
Reference in New Issue
Block a user