Commit 772cab7c authored by Dimitrios Gogos's avatar Dimitrios Gogos
Browse files

feat: enhance CI configuration and Makefile for frontend integration and checks

parent 9d8bcb68
Loading
Loading
Loading
Loading
Loading
+20 −12
Changes for .gitlab-ci.yml: 20 added lines, 12 removed lines.
Original line number Diff line number Diff line
@@ -5,10 +5,15 @@ workflow:
      when: never
    - if: $CI_COMMIT_BRANCH

stages:
  - backend
  - frontend

variables:
  UV_CACHE_DIR: "$CI_PROJECT_DIR/.cache/uv"

.backend:
  stage: backend
  image: python:3.12-slim
  needs: []
  cache:
@@ -30,6 +35,7 @@ variables:
        - .gitlab-ci.yml

.frontend:
  stage: frontend
  image: node:22-slim
  needs: []
  cache:
@@ -47,28 +53,29 @@ variables:
        - portal-gui/**/*
        - .gitlab-ci.yml

backend:type:
backend:format:
  extends: .backend
  script:
    - mypy src/ tests/
    - ruff format --check src/ tests/

backend:architecture:
backend:lint:
  extends: .backend
  script:
    - lint-imports
    - ruff check src/ tests/

backend:lint:
backend:type:
  extends: .backend
  script:
    - ruff check src/ tests/
    - mypy src/ tests/

backend:format:
backend:architecture:
  extends: .backend
  script:
    - ruff format --check src/ tests/
    - lint-imports

backend:test:
  extends: .backend
  needs: [backend:format, backend:lint, backend:type, backend:architecture]
  variables:
    DOCKER_HOST: tcp://docker:2375
    DOCKER_TLS_CERTDIR: ""
@@ -78,22 +85,23 @@ backend:test:
    - pytest --cov=src/portal_service --cov-branch --cov-report=term-missing
  coverage: '/TOTAL.+ ([0-9]{1,3}(?:\.[0-9]+)?%)/'

gui:typecheck:
gui:format:
  extends: .frontend
  script:
    - npm run typecheck
    - npm run format:check

gui:lint:
  extends: .frontend
  script:
    - npm run lint

gui:format:
gui:typecheck:
  extends: .frontend
  script:
    - npm run format:check
    - npm run typecheck

gui:build:
  extends: .frontend
  needs: [gui:format, gui:lint, gui:typecheck]
  script:
    - npm run build
+26 −0
Changes for .pre-commit-config.yaml: 26 added lines, 0 removed lines.
Original line number Diff line number Diff line
default_install_hook_types: [pre-commit, pre-push]
default_stages: [pre-commit]

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
  rev: v6.0.0
@@ -6,7 +9,9 @@ repos:
      exclude: ^deployment/templates/
    - id: check-toml
    - id: end-of-file-fixer
      stages: [pre-commit]
    - id: trailing-whitespace
      stages: [pre-commit]
      args: [--markdown-linebreak-ext=md]

- repo: https://github.com/astral-sh/ruff-pre-commit
@@ -33,3 +38,24 @@ repos:
        "sqlalchemy>=2.0.48",
        "structlog>=25.0.0",
      ]

# portal-gui: run through its own node_modules, so hooks and CI use the same versions.
- repo: local
  hooks:
    - id: gui-prettier
      name: prettier (portal-gui)
      language: system
      entry: bash -c 'cd portal-gui && npx --no-install prettier --write --ignore-unknown "${@#portal-gui/}"' --
      files: ^portal-gui/
    - id: gui-eslint
      name: eslint (portal-gui)
      language: system
      entry: bash -c 'cd portal-gui && npx --no-install eslint --fix --no-warn-ignored "${@#portal-gui/}"' --
      files: ^portal-gui/.*\.(ts|tsx)$
    - id: gui-typecheck
      name: typecheck (portal-gui)
      language: system
      entry: npm --prefix portal-gui run typecheck
      files: ^portal-gui/
      pass_filenames: false
      stages: [pre-push]
+38 −1
Changes for Makefile: 38 added lines, 1 removed line.
Original line number Diff line number Diff line
.PHONY: install clean lint format precommit architecture type test integration coverage run
.PHONY: install clean lint format precommit architecture type test integration coverage run check \
	gui-install gui-lint gui-format gui-typecheck gui-build gui-run

SRC := src/portal_service
TEST := tests
GUI := portal-gui
DEV ?= false

# Trust the OS certificate store (uv does not by default, unlike pip) so
@@ -64,3 +66,38 @@ coverage:
run:
	make install
	.venv/bin/uvicorn "portal_service.main:create_app" --factory --reload --port 8000

## Frontend (portal-gui)
$(GUI)/node_modules: $(GUI)/package-lock.json
	npm --prefix $(GUI) ci
	touch $@

gui-install:
	npm --prefix $(GUI) ci

gui-lint: $(GUI)/node_modules
	npm --prefix $(GUI) run lint

gui-format: $(GUI)/node_modules
	npm --prefix $(GUI) run format

gui-typecheck: $(GUI)/node_modules
	npm --prefix $(GUI) run typecheck

gui-build: $(GUI)/node_modules
	npm --prefix $(GUI) run build

gui-run: $(GUI)/node_modules
	npm --prefix $(GUI) run dev

check: $(GUI)/node_modules
	make install DEV=true
	.venv/bin/ruff format --check $(SRC) $(TEST)
	.venv/bin/ruff check $(SRC) $(TEST)
	.venv/bin/mypy $(SRC) $(TEST)
	.venv/bin/lint-imports --cache-dir .cache/import-linter
	npm --prefix $(GUI) run format:check
	npm --prefix $(GUI) run lint
	npm --prefix $(GUI) run typecheck
	.venv/bin/pytest
	npm --prefix $(GUI) run build
+13 −0
Changes for README.md: 13 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -18,6 +18,19 @@ npm run dev

Open [http://localhost:3000](http://localhost:3000).

## Checks

Install the git hooks once per clone. They format and lint staged files on commit,
and type-check the GUI on push:

```bash
make install DEV=true
make gui-install
.venv/bin/pre-commit install
```

`make check` runs everything the CI pipeline runs, for the backend and the GUI.

## Deploy

See [deployment/README.md](deployment/README.md) for Helm deployment.