ci: Begin setting up testing CI

This commit is contained in:
April Hall 2025-02-28 02:13:59 -05:00
parent 19bbdce14f
commit db3afe4758
5 changed files with 78 additions and 7 deletions

61
.github/workflows/playwright.yml vendored Normal file
View File

@ -0,0 +1,61 @@
name: Playwright Tests
on: [push, pull_request]
jobs:
test:
name: Tests
runs-on: ubuntu-latest
services:
# Cassandra service container
cassandra:
image: cassandra:latest
ports:
- 9042:9042
options: --health-cmd="nodetool status" --health-interval=10s --health-timeout=5s --health-retries=5
env:
CASSANDRA_USER: admin
CASSANDRA_PASSWORD: admin
# Minio service container
minio:
image: docker.io/bitnami/minio
ports:
- 9000:9000
env:
MINIO_ROOT_USER: minioadmin
MINIO_ROOT_PASSWORD: minioadmin
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: Install dependencies
run: bun install
- name: Install Playwright browsers
run: bunx playwright install --with-deps chromium
- name: Set up users DB
run: bun run migrate
- name: Setup environment
run: |
cp .env.example .env
sudo echo "127.0.0.1 localhost" | sudo tee -a /etc/hosts
- name: Run Playwright tests
run: bun run test
env:
NODE_ENV: testing
- name: Upload test results
uses: actions/upload-artifact@v4
if: always()
with:
name: playwright-report
path: playwright-report/
retention-days: 30

View File

@ -19,15 +19,17 @@ export default defineConfig({
testMatch: /(.+\.)?(test|spec)\.[jt]s/,
},
],
retries: !process.env.CI ? 1 : 0,
reporter: 'list',
webServer: {
command: 'npm run dev',
command: 'npm run dev --host',
port: 5173,
reuseExistingServer: true,
// Reuses webserver only in non-ci enviroments
reuseExistingServer: !process.env.CI,
},
workers: 1,
use: {
baseURL: 'http://localhost:5173',
baseURL: 'http://127.0.0.1:5173',
trace: 'on-first-retry',
},
});

View File

@ -36,8 +36,8 @@ class Db {
try {
await this.client.connect();
break;
} catch {
console.error(`Error communicating with DB. Retrying...`);
} catch (e) {
console.error(`Error communicating with DB (${this.clientUrl}:9042). Retrying.. ${(e as Error).message}`);
await createDelay(1000);
}
}

View File

@ -51,7 +51,11 @@ class MinioClient {
const bucket = 'profile-photos';
if (!(await this.client.bucketExists(bucket))) {
console.log(`\x1b[35m[S3]\x1b[0m Creating bucket '${bucket}', as it is required but does not exist.`);
this.client.makeBucket(bucket);
try {
await this.client.makeBucket(bucket);
} catch (e) {
console.error((e as Error).message);
}
}
const objectId = `${v4()}${this.getFileExtension(mime)}`;
@ -62,7 +66,9 @@ class MinioClient {
etag: upload.etag,
};
} catch (e) {
if ((e as Error).message !== 'Unsupported file type') {
console.error(`Error uploading file: ${(e as Error).message}`);
}
throw e;
}
}

View File

@ -111,6 +111,8 @@ test.describe('Password Update Form', () => {
await newPasswordInput.fill('newPassword123!');
await submitButton.click();
await page.waitForTimeout(1000);
// Undo password change so other tests still pass
await currentPasswordInput.fill('newPassword123!');
await newPasswordInput.fill(currentPassword);