Skip to content

Commit 4cf8c62

Browse files
authored
Merge pull request #32 from mbsantiago/feat/lint_workflow
Feat/lint workflow
2 parents 8d6d66d + 927e251 commit 4cf8c62

39 files changed

+182
-60
lines changed

.github/workflows/build_frontend.yml

+4-1
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,14 @@ jobs:
1717
uses: actions/setup-node@v4
1818
with:
1919
node-version: 22
20+
cache: "npm"
21+
cache-dependency-path: |
22+
front/package-lock.json
2023
2124
- name: Install frontend dependencies
2225
run: |
2326
cd front
24-
npm install
27+
npm ci
2528
2629
- name: Build frontend app
2730
run: |

.github/workflows/lint.yml

+89
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
name: Lint
2+
on:
3+
push:
4+
branches: ["main"]
5+
pull_request:
6+
branches: ["main"]
7+
8+
jobs:
9+
lint-backend:
10+
env:
11+
UV_CACHE_DIR: /tmp/.uv-cache
12+
13+
runs-on: "ubuntu-latest"
14+
15+
steps:
16+
- uses: actions/checkout@v4
17+
18+
- name: Set up uv
19+
run: curl -LsSf https://astral.sh/uv/install.sh | sh
20+
21+
- name: Set up Python 3.12
22+
run: uv python install 3.12
23+
24+
- name: Restore uv cache
25+
uses: actions/cache@v4
26+
with:
27+
path: /tmp/.uv-cache
28+
key: uv-${{ runner.os }}-${{ hashFiles('back/uv.lock') }}
29+
restore-keys: |
30+
uv-${{ runner.os }}-${{ hashFiles('back/uv.lock') }}
31+
uv-${{ runner.os }}
32+
33+
- name: Install dev dependencies
34+
run: |
35+
cd back
36+
uv sync --all-extras --dev
37+
38+
- name: Run Ruff
39+
run: |
40+
cd back
41+
uv run ruff check src tests
42+
43+
- name: Check Formatting
44+
run: |
45+
cd back
46+
uv run ruff format --check src tests
47+
48+
- name: Run pyright
49+
run: |
50+
cd back
51+
uv run pyright src tests
52+
53+
- name: Minimize uv cache
54+
run: uv cache prune --ci
55+
56+
lint-frontend:
57+
runs-on: "ubuntu-latest"
58+
59+
steps:
60+
- name: Checkout source code
61+
uses: actions/checkout@v4
62+
63+
- name: Setup node
64+
uses: actions/setup-node@v4
65+
with:
66+
node-version: 22
67+
cache: "npm"
68+
cache-dependency-path: |
69+
front/package-lock.json
70+
71+
- name: Install frontend dependencies
72+
run: |
73+
cd front
74+
npm ci
75+
76+
- name: Check formatting
77+
run: |
78+
cd front
79+
npm run format-check
80+
81+
- name: Lint with Nextjs
82+
run: |
83+
cd front
84+
npm run lint
85+
86+
- name: Lint with Typescript Compiler
87+
run: |
88+
cd front
89+
npm run lint-tsc

.github/workflows/test.yml

+36-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on:
55
pull_request:
66
branches: ["main"]
77
jobs:
8-
test:
8+
test-backend:
99
env:
1010
UV_CACHE_DIR: /tmp/.uv-cache
1111

@@ -46,6 +46,16 @@ jobs:
4646
uv-${{ runner.os }}-${{ hashFiles('back/uv.lock') }}
4747
uv-${{ runner.os }}
4848
49+
- name: Restore uv cache
50+
uses: actions/cache@v4
51+
if: ${{ matrix.os == 'windows-latest' }}
52+
with:
53+
path: /tmp/.uv-cache
54+
key: uv-${{ runner.os }}-${{ hashFiles('back\uv.lock') }}
55+
restore-keys: |
56+
uv-${{ runner.os }}-${{ hashFiles('back\uv.lock') }}
57+
uv-${{ runner.os }}
58+
4959
- name: Install the project dependencies
5060
run: |
5161
cd back
@@ -81,3 +91,28 @@ jobs:
8191

8292
- name: Minimize uv cache
8393
run: uv cache prune --ci
94+
95+
test-frontend:
96+
runs-on: "ubuntu-latest"
97+
98+
steps:
99+
- name: Checkout source code
100+
uses: actions/checkout@v4
101+
102+
- name: Setup node
103+
uses: actions/setup-node@v4
104+
with:
105+
node-version: 22
106+
cache: "npm"
107+
cache-dependency-path: |
108+
front/package-lock.json
109+
110+
- name: Install frontend dependencies
111+
run: |
112+
cd front
113+
npm ci
114+
115+
- name: Run tests
116+
run: |
117+
cd front
118+
npm run test

back/src/whombat/routes/model_runs.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@ async def get_model_run(
5353
return await api.model_runs.get(session, model_run_uuid)
5454

5555

56-
@model_runs_router.get("/detail/evaluation/", response_model=schemas.Evaluation)
56+
@model_runs_router.get(
57+
"/detail/evaluation/", response_model=schemas.Evaluation
58+
)
5759
async def get_model_run_evaluation(
5860
session: Session,
5961
model_run_uuid: UUID,

back/tests/test_api/test_audio.py

+2
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,10 @@ def test_stream_an_audio_clip(fmt: str, random_wav_factory):
181181
original_data = f.read(8_000)
182182
assert (streamed_data == original_data).all()
183183

184+
184185
CHUNK_SIZE = 1024 * 512
185186

187+
186188
def test_can_stream_a_real_audio_file(data_dir: Path):
187189
path = data_dir / "bats.wav"
188190

front/package.json

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
"coverage": "jest --coverage",
1010
"start": "next start",
1111
"format": "prettier --write .",
12+
"format-check": "prettier --check .",
13+
"lint-tsc": "tsc --noEmit -p .",
1214
"lint": "next lint",
1315
"lint:fix": "eslint --fix --ext .js,.jsx,.ts,.tsx ./src",
1416
"test-ct": "playwright test -c playwright-ct.config.ts",

front/src/app/(auth)/login/page.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { z } from "zod";
88
import api from "@/app/api";
99

1010
import { WhombatIcon } from "@/lib/components/icons";
11-
import { Input, Group } from "@/lib/components/inputs/index";
11+
import { Group, Input } from "@/lib/components/inputs/index";
1212
import Info from "@/lib/components/ui/Info";
1313
import Link from "@/lib/components/ui/Link";
1414

front/src/app/(base)/evaluation/detail/model_run/page.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import toast from "react-hot-toast";
77

88
import ModelRunActions from "@/app/components/model_runs/ModelRunActions";
99
import ModelRunEvaluation from "@/app/components/model_runs/ModelRunEvaluations";
10-
import ModelRunUpdate from "@/app/components/model_runs/ModelRunUpdate";
1110
import ModelRunExplorer from "@/app/components/model_runs/ModelRunExplorer";
11+
import ModelRunUpdate from "@/app/components/model_runs/ModelRunUpdate";
1212

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

front/src/lib/api/annotation_tasks.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,9 @@ export function registerAnnotationTasksAPI(
6363
return Page(schemas.AnnotationTaskSchema).parse(response.data);
6464
}
6565

66-
async function getAnnotationTask(uuid: string): Promise<types.AnnotationTask> {
66+
async function getAnnotationTask(
67+
uuid: string,
68+
): Promise<types.AnnotationTask> {
6769
const response = await instance.get(endpoints.get, {
6870
params: { annotation_task_uuid: uuid },
6971
});

front/src/lib/api/clip_evaluations.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ export function registerClipEvaluationAPI(
4141
return Page(schemas.ClipEvaluationSchema).parse(response.data);
4242
}
4343

44-
async function getClipEvaluation(uuid: string): Promise<types.ClipEvaluation> {
44+
async function getClipEvaluation(
45+
uuid: string,
46+
): Promise<types.ClipEvaluation> {
4547
const response = await instance.get(endpoints.get, {
4648
params: { clip_evaluation_uuid: uuid },
4749
});

front/src/lib/components/annotation_projects/AnnotationProjectCreate.tsx

+1-6
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,7 @@ import { zodResolver } from "@hookform/resolvers/zod";
22
import { useCallback } from "react";
33
import { useForm } from "react-hook-form";
44

5-
import {
6-
Input,
7-
Group,
8-
Submit,
9-
TextArea,
10-
} from "@/lib/components/inputs/index";
5+
import { Group, Input, Submit, TextArea } from "@/lib/components/inputs/index";
116

127
import { AnnotationProjectCreateSchema } from "@/lib/schemas";
138
import type { AnnotationProject, AnnotationProjectCreate } from "@/lib/types";

front/src/lib/components/annotation_projects/AnnotationProjectImport.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { useForm } from "react-hook-form";
44

55
import { UploadIcon } from "@/lib/components/icons";
66
import { Group, Input, Submit } from "@/lib/components/inputs/index";
7+
78
import { AnnotationProjectImportSchema } from "@/lib/schemas";
89
import type { AnnotationProjectImport } from "@/lib/types";
910

front/src/lib/components/annotation_projects/AnnotationProjectList.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import Empty from "@/lib/components/ui/Empty";
21
import AnnotationProjectComponent from "@/lib/components/annotation_projects/AnnotationProject";
32
import { AddIcon, UploadIcon, WarningIcon } from "@/lib/components/icons";
43
import ListLayout from "@/lib/components/layouts/List";
54
import Dialog from "@/lib/components/ui/Dialog";
5+
import Empty from "@/lib/components/ui/Empty";
66

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

front/src/lib/components/annotation_projects/AnnotationProjectNotesSummary.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { type ComponentProps, type FC } from "react";
22

3-
import Empty from "@/lib/components/ui/Empty";
43
import { CheckIcon, IssuesIcon } from "@/lib/components/icons";
54
import Card from "@/lib/components/ui/Card";
5+
import Empty from "@/lib/components/ui/Empty";
66
import { H3 } from "@/lib/components/ui/Headings";
77
import Loading from "@/lib/components/ui/Loading";
88

front/src/lib/components/annotation_projects/AnnotationProjectProgress.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { useMemo } from "react";
22

3-
import Empty from "@/lib/components/ui/Empty";
43
import {
54
AddIcon,
65
CompleteIcon,
@@ -10,6 +9,7 @@ import {
109
} from "@/lib/components/icons";
1110
import Button from "@/lib/components/ui/Button";
1211
import Card from "@/lib/components/ui/Card";
12+
import Empty from "@/lib/components/ui/Empty";
1313
import { H3 } from "@/lib/components/ui/Headings";
1414
import Loading from "@/lib/components/ui/Loading";
1515
import MetricBadge from "@/lib/components/ui/MetricBadge";

front/src/lib/components/clip_annotations/ClipAnnotationNotes.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { ComponentProps } from "react";
22

3-
import Empty from "@/lib/components/ui/Empty";
43
import NotesPanel from "@/lib/components/notes/NotesPanel";
4+
import Empty from "@/lib/components/ui/Empty";
55

66
export default function ClipAnnotationNotes(
77
props: Omit<ComponentProps<typeof NotesPanel>, "title" | "EmptyNotes">,

front/src/lib/components/clip_annotations/ClipAnnotationSoundEvents.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import { type ComponentProps } from "react";
22

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

5-
import Empty from "../ui/Empty";
65
import SelectedSoundEventAnnotation from "../sound_event_annotations/SelectedSoundEventAnnotation";
6+
import Empty from "../ui/Empty";
77

88
export default function ClipAnnotationSoundEvents({
99
selectedSoundEventAnnotation,

front/src/lib/components/clip_annotations/ClipAnnotationTags.tsx

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { type ComponentProps } from "react";
22

3-
import Empty from "@/lib/components/ui/Empty";
43
import Card from "@/lib/components/ui/Card";
4+
import Empty from "@/lib/components/ui/Empty";
55

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

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

1818
function NoTags() {
1919
return (
20-
<Empty outerClassName="p-2">No tags currently registered in this clip.</Empty>
20+
<Empty outerClassName="p-2">
21+
No tags currently registered in this clip.
22+
</Empty>
2123
);
2224
}

front/src/lib/components/clip_predictions/ClipPredictionTags.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import { useMemo } from "react";
22

33
import useStore from "@/app/store";
44

5-
import Empty from "@/lib/components/ui/Empty";
65
import { TagsIcon } from "@/lib/components/icons";
76
import TagComponent from "@/lib/components/tags/Tag";
7+
import Empty from "@/lib/components/ui/Empty";
88
import { H4 } from "@/lib/components/ui/Headings";
99

1010
import type { ClipPrediction, Interval, Tag } from "@/lib/types";

front/src/lib/components/datasets/DatasetCreate.tsx

+1-6
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,7 @@ import { zodResolver } from "@hookform/resolvers/zod";
22
import { useCallback } from "react";
33
import { useForm } from "react-hook-form";
44

5-
import {
6-
Input,
7-
Group,
8-
Submit,
9-
TextArea,
10-
} from "@/lib/components/inputs/index";
5+
import { Group, Input, Submit, TextArea } from "@/lib/components/inputs/index";
116

127
import { DatasetCreateSchema } from "@/lib/schemas";
138
import type { DatasetCreate } from "@/lib/types";

front/src/lib/components/datasets/DatasetImport.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { useCallback } from "react";
33
import { useForm } from "react-hook-form";
44

55
import { UploadIcon } from "@/lib/components/icons";
6-
import { Input, Group, Submit } from "@/lib/components/inputs/index";
6+
import { Group, Input, Submit } from "@/lib/components/inputs/index";
77

88
import { DatasetImportSchema } from "@/lib/schemas";
99
import type { DatasetImport } from "@/lib/types";

front/src/lib/components/datasets/DatasetList.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import Empty from "@/lib/components/ui/Empty";
21
import DatasetComponent from "@/lib/components/datasets/Dataset";
32
import { AddIcon, UploadIcon, WarningIcon } from "@/lib/components/icons";
43
import Dialog from "@/lib/components/ui/Dialog";
4+
import Empty from "@/lib/components/ui/Empty";
55

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

front/src/lib/components/evaluation_sets/EvaluationSetCreate.tsx

+1-6
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,7 @@ import { zodResolver } from "@hookform/resolvers/zod";
22
import { useCallback } from "react";
33
import { Controller, useForm } from "react-hook-form";
44

5-
import {
6-
Input,
7-
Group,
8-
Submit,
9-
TextArea,
10-
} from "@/lib/components/inputs/index";
5+
import { Group, Input, Submit, TextArea } from "@/lib/components/inputs/index";
116

127
import { EvaluationSetCreateSchema } from "@/lib/schemas";
138
import type { EvaluationSetCreate } from "@/lib/types";

front/src/lib/components/evaluation_sets/EvaluationSetImport.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { useCallback } from "react";
33
import { Controller, useForm } from "react-hook-form";
44

55
import { UploadIcon } from "@/lib/components/icons";
6-
import { Input, Group, Submit } from "@/lib/components/inputs/index";
6+
import { Group, Input, Submit } from "@/lib/components/inputs/index";
77

88
import { EvaluationSetImportSchema } from "@/lib/schemas";
99
import { EvaluationSetImport } from "@/lib/types";

0 commit comments

Comments
 (0)