Skip to content

Commit

Permalink
Merge pull request #32 from mbsantiago/feat/lint_workflow
Browse files Browse the repository at this point in the history
Feat/lint workflow
  • Loading branch information
mbsantiago authored Sep 28, 2024
2 parents 8d6d66d + 927e251 commit 4cf8c62
Show file tree
Hide file tree
Showing 39 changed files with 182 additions and 60 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/build_frontend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,14 @@ jobs:
uses: actions/setup-node@v4
with:
node-version: 22
cache: "npm"
cache-dependency-path: |
front/package-lock.json
- name: Install frontend dependencies
run: |
cd front
npm install
npm ci
- name: Build frontend app
run: |
Expand Down
89 changes: 89 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
name: Lint
on:
push:
branches: ["main"]
pull_request:
branches: ["main"]

jobs:
lint-backend:
env:
UV_CACHE_DIR: /tmp/.uv-cache

runs-on: "ubuntu-latest"

steps:
- uses: actions/checkout@v4

- name: Set up uv
run: curl -LsSf https://astral.sh/uv/install.sh | sh

- name: Set up Python 3.12
run: uv python install 3.12

- name: Restore uv cache
uses: actions/cache@v4
with:
path: /tmp/.uv-cache
key: uv-${{ runner.os }}-${{ hashFiles('back/uv.lock') }}
restore-keys: |
uv-${{ runner.os }}-${{ hashFiles('back/uv.lock') }}
uv-${{ runner.os }}
- name: Install dev dependencies
run: |
cd back
uv sync --all-extras --dev
- name: Run Ruff
run: |
cd back
uv run ruff check src tests
- name: Check Formatting
run: |
cd back
uv run ruff format --check src tests
- name: Run pyright
run: |
cd back
uv run pyright src tests
- name: Minimize uv cache
run: uv cache prune --ci

lint-frontend:
runs-on: "ubuntu-latest"

steps:
- name: Checkout source code
uses: actions/checkout@v4

- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 22
cache: "npm"
cache-dependency-path: |
front/package-lock.json
- name: Install frontend dependencies
run: |
cd front
npm ci
- name: Check formatting
run: |
cd front
npm run format-check
- name: Lint with Nextjs
run: |
cd front
npm run lint
- name: Lint with Typescript Compiler
run: |
cd front
npm run lint-tsc
37 changes: 36 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
pull_request:
branches: ["main"]
jobs:
test:
test-backend:
env:
UV_CACHE_DIR: /tmp/.uv-cache

Expand Down Expand Up @@ -46,6 +46,16 @@ jobs:
uv-${{ runner.os }}-${{ hashFiles('back/uv.lock') }}
uv-${{ runner.os }}
- name: Restore uv cache
uses: actions/cache@v4
if: ${{ matrix.os == 'windows-latest' }}
with:
path: /tmp/.uv-cache
key: uv-${{ runner.os }}-${{ hashFiles('back\uv.lock') }}
restore-keys: |
uv-${{ runner.os }}-${{ hashFiles('back\uv.lock') }}
uv-${{ runner.os }}
- name: Install the project dependencies
run: |
cd back
Expand Down Expand Up @@ -81,3 +91,28 @@ jobs:

- name: Minimize uv cache
run: uv cache prune --ci

test-frontend:
runs-on: "ubuntu-latest"

steps:
- name: Checkout source code
uses: actions/checkout@v4

- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 22
cache: "npm"
cache-dependency-path: |
front/package-lock.json
- name: Install frontend dependencies
run: |
cd front
npm ci
- name: Run tests
run: |
cd front
npm run test
4 changes: 3 additions & 1 deletion back/src/whombat/routes/model_runs.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ async def get_model_run(
return await api.model_runs.get(session, model_run_uuid)


@model_runs_router.get("/detail/evaluation/", response_model=schemas.Evaluation)
@model_runs_router.get(
"/detail/evaluation/", response_model=schemas.Evaluation
)
async def get_model_run_evaluation(
session: Session,
model_run_uuid: UUID,
Expand Down
2 changes: 2 additions & 0 deletions back/tests/test_api/test_audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,10 @@ def test_stream_an_audio_clip(fmt: str, random_wav_factory):
original_data = f.read(8_000)
assert (streamed_data == original_data).all()


CHUNK_SIZE = 1024 * 512


def test_can_stream_a_real_audio_file(data_dir: Path):
path = data_dir / "bats.wav"

Expand Down
2 changes: 2 additions & 0 deletions front/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
"coverage": "jest --coverage",
"start": "next start",
"format": "prettier --write .",
"format-check": "prettier --check .",
"lint-tsc": "tsc --noEmit -p .",
"lint": "next lint",
"lint:fix": "eslint --fix --ext .js,.jsx,.ts,.tsx ./src",
"test-ct": "playwright test -c playwright-ct.config.ts",
Expand Down
2 changes: 1 addition & 1 deletion front/src/app/(auth)/login/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { z } from "zod";
import api from "@/app/api";

import { WhombatIcon } from "@/lib/components/icons";
import { Input, Group } from "@/lib/components/inputs/index";
import { Group, Input } from "@/lib/components/inputs/index";
import Info from "@/lib/components/ui/Info";
import Link from "@/lib/components/ui/Link";

Expand Down
2 changes: 1 addition & 1 deletion front/src/app/(base)/evaluation/detail/model_run/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import toast from "react-hot-toast";

import ModelRunActions from "@/app/components/model_runs/ModelRunActions";
import ModelRunEvaluation from "@/app/components/model_runs/ModelRunEvaluations";
import ModelRunUpdate from "@/app/components/model_runs/ModelRunUpdate";
import ModelRunExplorer from "@/app/components/model_runs/ModelRunExplorer";
import ModelRunUpdate from "@/app/components/model_runs/ModelRunUpdate";

import useModelRun from "@/app/hooks/api/useModelRun";

Expand Down
4 changes: 3 additions & 1 deletion front/src/lib/api/annotation_tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ export function registerAnnotationTasksAPI(
return Page(schemas.AnnotationTaskSchema).parse(response.data);
}

async function getAnnotationTask(uuid: string): Promise<types.AnnotationTask> {
async function getAnnotationTask(
uuid: string,
): Promise<types.AnnotationTask> {
const response = await instance.get(endpoints.get, {
params: { annotation_task_uuid: uuid },
});
Expand Down
4 changes: 3 additions & 1 deletion front/src/lib/api/clip_evaluations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ export function registerClipEvaluationAPI(
return Page(schemas.ClipEvaluationSchema).parse(response.data);
}

async function getClipEvaluation(uuid: string): Promise<types.ClipEvaluation> {
async function getClipEvaluation(
uuid: string,
): Promise<types.ClipEvaluation> {
const response = await instance.get(endpoints.get, {
params: { clip_evaluation_uuid: uuid },
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,7 @@ import { zodResolver } from "@hookform/resolvers/zod";
import { useCallback } from "react";
import { useForm } from "react-hook-form";

import {
Input,
Group,
Submit,
TextArea,
} from "@/lib/components/inputs/index";
import { Group, Input, Submit, TextArea } from "@/lib/components/inputs/index";

import { AnnotationProjectCreateSchema } from "@/lib/schemas";
import type { AnnotationProject, AnnotationProjectCreate } from "@/lib/types";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { useForm } from "react-hook-form";

import { UploadIcon } from "@/lib/components/icons";
import { Group, Input, Submit } from "@/lib/components/inputs/index";

import { AnnotationProjectImportSchema } from "@/lib/schemas";
import type { AnnotationProjectImport } from "@/lib/types";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import Empty from "@/lib/components/ui/Empty";
import AnnotationProjectComponent from "@/lib/components/annotation_projects/AnnotationProject";
import { AddIcon, UploadIcon, WarningIcon } from "@/lib/components/icons";
import ListLayout from "@/lib/components/layouts/List";
import Dialog from "@/lib/components/ui/Dialog";
import Empty from "@/lib/components/ui/Empty";

import type { AnnotationProject } from "@/lib/types";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { type ComponentProps, type FC } from "react";

import Empty from "@/lib/components/ui/Empty";
import { CheckIcon, IssuesIcon } from "@/lib/components/icons";
import Card from "@/lib/components/ui/Card";
import Empty from "@/lib/components/ui/Empty";
import { H3 } from "@/lib/components/ui/Headings";
import Loading from "@/lib/components/ui/Loading";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { useMemo } from "react";

import Empty from "@/lib/components/ui/Empty";
import {
AddIcon,
CompleteIcon,
Expand All @@ -10,6 +9,7 @@ import {
} from "@/lib/components/icons";
import Button from "@/lib/components/ui/Button";
import Card from "@/lib/components/ui/Card";
import Empty from "@/lib/components/ui/Empty";
import { H3 } from "@/lib/components/ui/Headings";
import Loading from "@/lib/components/ui/Loading";
import MetricBadge from "@/lib/components/ui/MetricBadge";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ComponentProps } from "react";

import Empty from "@/lib/components/ui/Empty";
import NotesPanel from "@/lib/components/notes/NotesPanel";
import Empty from "@/lib/components/ui/Empty";

export default function ClipAnnotationNotes(
props: Omit<ComponentProps<typeof NotesPanel>, "title" | "EmptyNotes">,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { type ComponentProps } from "react";

import type { SoundEventAnnotation } from "@/lib/types";

import Empty from "../ui/Empty";
import SelectedSoundEventAnnotation from "../sound_event_annotations/SelectedSoundEventAnnotation";
import Empty from "../ui/Empty";

export default function ClipAnnotationSoundEvents({
selectedSoundEventAnnotation,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { type ComponentProps } from "react";

import Empty from "@/lib/components/ui/Empty";
import Card from "@/lib/components/ui/Card";
import Empty from "@/lib/components/ui/Empty";

import TagPanel from "../tags/TagPanel";

Expand All @@ -17,6 +17,8 @@ export default function ClipAnnotationTags(

function NoTags() {
return (
<Empty outerClassName="p-2">No tags currently registered in this clip.</Empty>
<Empty outerClassName="p-2">
No tags currently registered in this clip.
</Empty>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { useMemo } from "react";

import useStore from "@/app/store";

import Empty from "@/lib/components/ui/Empty";
import { TagsIcon } from "@/lib/components/icons";
import TagComponent from "@/lib/components/tags/Tag";
import Empty from "@/lib/components/ui/Empty";
import { H4 } from "@/lib/components/ui/Headings";

import type { ClipPrediction, Interval, Tag } from "@/lib/types";
Expand Down
7 changes: 1 addition & 6 deletions front/src/lib/components/datasets/DatasetCreate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,7 @@ import { zodResolver } from "@hookform/resolvers/zod";
import { useCallback } from "react";
import { useForm } from "react-hook-form";

import {
Input,
Group,
Submit,
TextArea,
} from "@/lib/components/inputs/index";
import { Group, Input, Submit, TextArea } from "@/lib/components/inputs/index";

import { DatasetCreateSchema } from "@/lib/schemas";
import type { DatasetCreate } from "@/lib/types";
Expand Down
2 changes: 1 addition & 1 deletion front/src/lib/components/datasets/DatasetImport.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useCallback } from "react";
import { useForm } from "react-hook-form";

import { UploadIcon } from "@/lib/components/icons";
import { Input, Group, Submit } from "@/lib/components/inputs/index";
import { Group, Input, Submit } from "@/lib/components/inputs/index";

import { DatasetImportSchema } from "@/lib/schemas";
import type { DatasetImport } from "@/lib/types";
Expand Down
2 changes: 1 addition & 1 deletion front/src/lib/components/datasets/DatasetList.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Empty from "@/lib/components/ui/Empty";
import DatasetComponent from "@/lib/components/datasets/Dataset";
import { AddIcon, UploadIcon, WarningIcon } from "@/lib/components/icons";
import Dialog from "@/lib/components/ui/Dialog";
import Empty from "@/lib/components/ui/Empty";

import type { Dataset } from "@/lib/types";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,7 @@ import { zodResolver } from "@hookform/resolvers/zod";
import { useCallback } from "react";
import { Controller, useForm } from "react-hook-form";

import {
Input,
Group,
Submit,
TextArea,
} from "@/lib/components/inputs/index";
import { Group, Input, Submit, TextArea } from "@/lib/components/inputs/index";

import { EvaluationSetCreateSchema } from "@/lib/schemas";
import type { EvaluationSetCreate } from "@/lib/types";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useCallback } from "react";
import { Controller, useForm } from "react-hook-form";

import { UploadIcon } from "@/lib/components/icons";
import { Input, Group, Submit } from "@/lib/components/inputs/index";
import { Group, Input, Submit } from "@/lib/components/inputs/index";

import { EvaluationSetImportSchema } from "@/lib/schemas";
import { EvaluationSetImport } from "@/lib/types";
Expand Down
Loading

0 comments on commit 4cf8c62

Please sign in to comment.