stages:
  - lint
  - test
  - build

lint-python:
  stage: lint
  image: python:3.11
  script:
    - pip install ruff
    - ruff check .
    - ruff format --check .

lint-frontend:
  stage: lint
  image: node:20
  script:
    - npm ci --prefix saas_portal/frontend
    - npx --prefix saas_portal/frontend prettier --check .
    - npx --prefix saas_portal/frontend eslint .

.test-python:
  stage: test
  image: python:3.11

test-base-platform:
  extends: .test-python
  script:
    - pip install -r base_platform/requirements.txt
    - pytest base_platform/tests/ --tb=short

test-training-center:
  extends: .test-python
  script:
    - pip install -r training_center/backend/requirements.txt
    - pytest training_center/backend/tests/ --tb=short

test-data-center:
  extends: .test-python
  script:
    - pip install -r data_center/backend/requirements.txt
    - pytest data_center/backend/tests/ --tb=short

test-tax-accelerator:
  extends: .test-python
  script:
    - pip install -r industry_accelerator/tax/backend/requirements.txt
    - pytest industry_accelerator/tax/backend/tests/ --tb=short

build-base-platform:
  stage: build
  image: docker:24
  services:
    - docker:24-dind
  script:
    - docker build -f base_platform/Dockerfile.platform -t hellotax/base-platform:$CI_COMMIT_SHORT_SHA base_platform/
  only:
    - main

build-training-center:
  stage: build
  image: docker:24
  services:
    - docker:24-dind
  script:
    - docker build -t hellotax/training-center:$CI_COMMIT_SHORT_SHA training_center/backend/
  only:
    - main

build-data-center:
  stage: build
  image: docker:24
  services:
    - docker:24-dind
  script:
    - docker build -t hellotax/data-center:$CI_COMMIT_SHORT_SHA data_center/backend/
  only:
    - main
