Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: CI

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
build-and-test:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [20.x]

steps:
- uses: actions/checkout@v4

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
cache-dependency-path: |
backend/package-lock.json
frontend/package-lock.json

- name: Install backend dependencies
working-directory: ./backend
run: npm ci

- name: Run backend tests
working-directory: ./backend
run: npm test

- name: Install frontend dependencies
working-directory: ./frontend
run: npm ci

Comment on lines +17 to +40
- name: Build frontend
working-directory: ./frontend
run: npm run build
Comment on lines +41 to +43
2 changes: 1 addition & 1 deletion backend/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ MONGODB_URI=mongodb+srv://<username>:<pass>@cluster0.thi5oil.mongodb.net/<databa
JWT_SECRET=123456789
JWT_REFRESH_SECRET=987654321
FRONTEND_URL=http://localhost:5173
NODE_ENV=development
NODE_ENV=development
4 changes: 4 additions & 0 deletions backend/tests/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ let useMemoryServer = true;
// Setup before all tests
beforeAll(async () => {
try {
// Set test-only JWT secrets so tests relying on auth don't fail
process.env.JWT_SECRET = process.env.JWT_SECRET || 'test-jwt-secret';
process.env.JWT_REFRESH_SECRET = process.env.JWT_REFRESH_SECRET || 'test-refresh-secret';

let mongoUri;

// Check if a test MongoDB URI is provided (for CI/CD or when VC++ redistributable is not available)
Expand Down
2 changes: 0 additions & 2 deletions backend/tests/utils/testApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import errorHandler from '../../src/middleware/errorHandler.js';
import { optionalAuth } from '../../src/middleware/auth.js';
import { userRateLimiter } from '../../src/middleware/rateLimiter.js';
import authRoutes from '../../src/routes/authRoutes.js';
import wikimediaOAuth1Routes from '../../src/routes/wikimediaOAuth1Routes.js';
import submissionRoutes from '../../src/routes/submissionRoutes.js';
import userRoutes from '../../src/routes/userRoutes.js';
import adminRoutes from '../../src/routes/adminRoutes.js';
Expand Down Expand Up @@ -60,7 +59,6 @@ export const createTestApp = () => {

// API routes
app.use('/api/auth', authRoutes);
app.use('/api/auth/wikimedia', wikimediaOAuth1Routes);
app.use('/api/submissions', submissionRoutes);
app.use('/api/users', userRoutes);
app.use('/api/admin', adminRoutes);
Expand Down