ICTU/quality-time

View on GitHub
.circleci/config.yml

Summary

Maintainability
Test Coverage
version: 2.1

orbs:
  docker: circleci/docker@2.1.2

jobs:
  unittest_backend:
    docker:
      - image: cimg/python:3.12.6
        auth:
          username: $DOCKERHUB_USERNAME
          password: $DOCKERHUB_PASSWORD
    parallelism: 6
    steps:
      - checkout
      - run: |
          case $CIRCLE_NODE_INDEX in
            0) component=components/collector;;
            1) component=components/notifier;;
            2) component=components/api_server;;
            3) component=components/shared_code;;
            4) component=tests/application_tests;;
            5) component=tests/feature_tests;;
          esac
          cd $component
          mkdir -p build
          pip install uv
          uv venv
          ci/pip-install.sh
          ci/unittest.sh
          ci/quality.sh
      - store_artifacts:
          path: components/collector/build
      - store_artifacts:
          path: components/notifier/build
      - store_artifacts:
          path: components/api_server/build
      - store_artifacts:
          path: components/shared_code/build
      - store_artifacts:
          path: components/application_tests/build
      - store_artifacts:
          path: components/feature_tests/build

  unittest_frontend:
    docker:
      - image: cimg/node:22.9.0
        auth:
          username: $DOCKERHUB_USERNAME
          password: $DOCKERHUB_PASSWORD
    steps:
      - checkout
      - run: |
          cd components/frontend
          npm install --ignore-scripts
          ci/unittest.sh
          ci/quality.sh

  unittest_other:
    machine:
      image: default
    steps:
      - checkout
      - run: |
          pip install uv
          cd docs
          npm install --ignore-scripts
          uv venv
          ci/pip-install.sh
          ci/unittest.sh
          ci/quality.sh
      - run: |
          cd release
          uv venv
          ci/pip-install.sh
          ci/quality.sh

  application_tests:
    machine:
      image: default
    parallelism: 1
    steps:
      - checkout
      - run: |
          mkdir -p build
          export ENV=ci
          export PROXY_PORT=8080
          export QUALITY_TIME_VERSION=v5.17.1
          export COMPOSE_PATH_SEPARATOR=':'
          export COMPOSE_FILE=docker/docker-compose.yml:docker/docker-compose.ci.yml
          docker compose build && docker compose up -d
          docker ps
          docker run -it -w `pwd` -v `pwd`:`pwd` --network=container:docker-www-1 ghcr.io/astral-sh/uv:python3.12-bookworm tests/application_tests/ci/test.sh
          docker ps
          docker compose logs > build/containers.log
      - run:
          name: Save container logs on failure
          when: on_fail
          command: docker compose logs > build/containers.log
      - store_artifacts:
          path: build
    # The resource_class feature allows configuring CPU and RAM resources for each job. Different resource classes are available for different executors. https://circleci.com/docs/2.0/configuration-reference/#resourceclass
    resource_class: large

  feature_tests:
    machine:
      image: default
    parallelism: 1
    steps:
      - checkout
      - run: |
          pip install uv
          ./tests/feature_tests/ci/test.sh
      - store_artifacts:
          path: build
    # The resource_class feature allows configuring CPU and RAM resources for each job. Different resource classes are available for different executors. https://circleci.com/docs/2.0/configuration-reference/#resourceclass
    resource_class: large

workflows:
  version: 2
  build_test:
    jobs:
      - application_tests:
          context: QualityTime
      - feature_tests:
          context: QualityTime
      - unittest_backend:
          context: QualityTime
      - unittest_frontend:
          context: QualityTime
      - unittest_other:
          context: QualityTime
      - docker/hadolint:
          context: QualityTime
          dockerfiles: "components/collector/Dockerfile:components/database/Dockerfile:\
            components/api_server/Dockerfile:components/frontend/Dockerfile:\
            components/notifier/Dockerfile:components/proxy/Dockerfile:\
            components/renderer/Dockerfile:components/testdata/Dockerfile"