diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..8e6fe76 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,54 @@ +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + backend-lint: + name: Backend Lint + runs-on: ubuntu-latest + defaults: + run: + working-directory: ./backend + steps: + - uses: actions/checkout@v4 + + - name: Set up poetry + run: pipx install poetry==2.1.2 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.12' + cache: 'poetry' + cache-dependency-path: ./backend/poetry.lock + + - name: Install dependencies + run: poetry install --only=main,dev + + - name: Run linting + run: poetry run pre-commit run --all-files + + frontend-lint: + name: Frontend Lint + runs-on: ubuntu-latest + defaults: + run: + working-directory: ./frontend + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-node@v4 + with: + node-version: '20.14' + cache: 'npm' + cache-dependency-path: './frontend/package-lock.json' + + - name: Install dependencies + run: npm ci + + - name: Run linting + run: npm run lint diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..277a66c --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,91 @@ +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + backend-tests: + name: Backend Tests + runs-on: ubuntu-latest + defaults: + run: + working-directory: ./backend + services: + postgres: + image: postgres + ports: + - 5432:5432 + env: + POSTGRES_USER: pguser + POSTGRES_PASSWORD: pgpassword + POSTGRES_DB: postgres + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + env: + PG_HOST: localhost + PG_USER: pguser + PG_PASSWORD: pgpassword + PG_DB: postgres + POSTGRES_USER: pguser + POSTGRES_PASSWORD: pgpassword + POSTGRES_DB: postgres + LLM_EVAL_ENCRYPTION_KEY: M2kbagZtWPjxfjeDio2VDH+sVH45BsUHUxHzR+hW3Ps= + steps: + - uses: actions/checkout@v4 + + - name: Set up poetry + run: pipx install poetry==2.1.2 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.12' + cache: 'poetry' + cache-dependency-path: ./backend/poetry.lock + + - name: Install dependencies + run: poetry install --only=main,dev,test + + - name: Running tests + run: poetry run pytest --cov llm_eval --cov-report=xml tests + + - name: Upload backend coverage report + uses: actions/upload-artifact@v4 + with: + name: backend-coverage + path: ./backend/coverage.xml + if-no-files-found: error + + frontend-tests: + name: Frontend Tests + runs-on: ubuntu-latest + defaults: + run: + working-directory: ./frontend + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-node@v4 + with: + node-version: '20.14' + cache: 'npm' + cache-dependency-path: './frontend/package-lock.json' + + - name: Install dependencies + run: npm ci + + - name: Run tests + run: npm run test:coverage -- --reporter=json --outputFile=coverage/coverage-final.json + + - name: Upload frontend coverage report + uses: actions/upload-artifact@v4 + with: + name: frontend-coverage + path: ./frontend/coverage/coverage-final.json + if-no-files-found: error