Add CI tests with GitHub Actions workflow and fix Flask routing issues preventing tests from passing #7
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Tests | |
| on: | |
| push: | |
| branches: [ main ] | |
| pull_request: | |
| branches: [ main ] | |
| jobs: | |
| frontend-tests: | |
| name: Frontend Tests | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '18' | |
| cache: 'npm' | |
| cache-dependency-path: frontend/package-lock.json | |
| - name: Install frontend dependencies | |
| run: | | |
| cd frontend | |
| npm ci | |
| - name: Run frontend tests | |
| run: | | |
| cd frontend | |
| npm run test -- --run | |
| backend-tests: | |
| name: Backend Tests | |
| runs-on: ubuntu-latest | |
| services: | |
| postgres: | |
| image: postgres:16 | |
| env: | |
| POSTGRES_PASSWORD: test | |
| POSTGRES_DB: kernelboard_test | |
| options: >- | |
| --health-cmd pg_isready | |
| --health-interval 10s | |
| --health-timeout 5s | |
| --health-retries 5 | |
| ports: | |
| - 5432:5432 | |
| redis: | |
| image: redis:7-alpine | |
| options: >- | |
| --health-cmd "redis-cli ping" | |
| --health-interval 10s | |
| --health-timeout 5s | |
| --health-retries 5 | |
| ports: | |
| - 6379:6379 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.12' | |
| cache: 'pip' | |
| - name: Install dependencies | |
| run: | | |
| pip install -r requirements.txt | |
| pip install -e . | |
| - name: Run backend tests | |
| env: | |
| CI: true | |
| REDIS_URL: redis://localhost:6379/0 | |
| DATABASE_URL: postgresql://postgres:test@localhost:5432/kernelboard_test | |
| DISCORD_CLIENT_ID: test | |
| DISCORD_CLIENT_SECRET: test | |
| SECRET_KEY: test-secret-key | |
| DISCORD_CLUSTER_MANAGER_API_BASE_URL: http://test.example.com | |
| run: | | |
| pytest -v | |
| - name: Run coverage | |
| env: | |
| CI: true | |
| REDIS_URL: redis://localhost:6379/0 | |
| DATABASE_URL: postgresql://postgres:test@localhost:5432/kernelboard_test | |
| DISCORD_CLIENT_ID: test | |
| DISCORD_CLIENT_SECRET: test | |
| SECRET_KEY: test-secret-key | |
| DISCORD_CLUSTER_MANAGER_API_BASE_URL: http://test.example.com | |
| run: | | |
| coverage run -m pytest | |
| coverage report -m |