diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..6d33a35 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,82 @@ +name: CI + +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + lint-python: + name: Lint Python + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Install uv + uses: astral-sh/setup-uv@v4 + with: + version: "latest" + + - name: Set up Python + run: uv python install 3.12 + + - name: Install dependencies + run: uv sync --dev + + - name: Run ruff check + run: uv run ruff check . + + - name: Run ruff format check + run: uv run ruff format --check . + + lint-frontend: + name: Lint Frontend + runs-on: ubuntu-latest + defaults: + run: + working-directory: frontend + steps: + - uses: actions/checkout@v4 + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: "20" + cache: "npm" + cache-dependency-path: frontend/package-lock.json + + - name: Install dependencies + run: npm ci + + - name: Run ESLint + run: npm run lint + + - name: Run Prettier check + run: npm run format:check + + - name: Run TypeScript check + run: npm run typecheck + + build-frontend: + name: Build Frontend + runs-on: ubuntu-latest + needs: [lint-frontend] + defaults: + run: + working-directory: frontend + steps: + - uses: actions/checkout@v4 + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: "20" + cache: "npm" + cache-dependency-path: frontend/package-lock.json + + - name: Install dependencies + run: npm ci + + - name: Build + run: npm run build diff --git a/README.md b/README.md index 8e86027..0e1e19f 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ ```sh curl -1sLf 'https://dl.cloudsmith.io/public/task/task/setup.deb.sh' | sudo -E bash -task install +task prepare ``` ## Area diff --git a/Taskfile.yml b/Taskfile.yml index a048ce3..1ec6149 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -51,7 +51,51 @@ tasks: - uv run fastapi run server/main.py --port 8001 lint: - desc: Lint and format Python code + desc: Lint all code (Python and TypeScript) + cmds: + - task: lint:python + - task: lint:frontend + + lint:python: + desc: Lint Python code with ruff + cmds: + - uv run ruff check . + + lint:frontend: + desc: Lint frontend TypeScript code + dir: frontend + cmds: + - npm run lint + - npm run format:check + + format: + desc: Format all code (Python and TypeScript) + cmds: + - task: format:python + - task: format:frontend + + format:python: + desc: Format Python code with ruff cmds: - uv run ruff check --fix . - uv run ruff format . + + format:frontend: + desc: Format frontend TypeScript code + dir: frontend + cmds: + - npm run lint:fix + - npm run format + + check: + desc: Run all checks (lint, typecheck, build) + cmds: + - task: lint + - task: typecheck + - task: build + + typecheck: + desc: Type check frontend TypeScript code + dir: frontend + cmds: + - npm run typecheck