Skip to content
Snippets Groups Projects
config.yml 3.88 KiB
Newer Older
# Python CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-python/ for more details
#
version: 2.1
executors:
  python:
    docker:
      - image: cimg/python:3.9
      - image: cimg/node:16.14
  with-database:
      - image: cimg/python:3.9
          DATABASE_URL: postgresql://hypha:hypha@localhost/hypha?sslmode=disable
          DJANGO_SETTINGS_MODULE: hypha.settings.test
      - image: cimg/postgres:12.9
          POSTGRES_USER: hypha
          POSTGRES_PASSWORD: hypha
  build-fe:
    executor: node
    resource_class: large
      - run:
          name: set owner on /usr/local
          command: sudo chown -R circleci:circleci /usr/local
            - v5-npm-{{ .Branch }}-{{ checksum "package-lock.json" }}
            - v5-npm-{{ .Branch }}-
            - v5-npm-
          name: builds static assets
            npm run build
            - /usr/local/lib/node_modules
            - /usr/local/bin
          key: v5-npm-{{ .Branch }}-{{ checksum "package-lock.json" }}
      - persist_to_workspace:
          root: ~/repo
          paths:
            - hypha/static_compiled
            - node_modules
  lint-fe:
    executor: node
    working_directory: ~/repo
    steps:
      - checkout
      - attach_workspace:
          at: ~/repo
      - run:
          name: run linting
          command: npm run lint

  test-fe:
    executor: node
    working_directory: ~/repo
    steps:
      - checkout
      - attach_workspace:
          at: ~/repo
          name: Run functional unit test cases [REACT.JS]
          command: npm run test:ci

  build-be:
    executor: python
    working_directory: ~/repo
    steps:
      - checkout
      - run:
          name: set owner on /usr/local
          command: sudo chown -R circleci:circleci /usr/local
      - restore_cache:
          keys:
            - v5-python-{{ .Branch }}-{{ checksum "requirements.txt" }}{{ checksum "requirements-dev.txt" }}
            - v5-python-{{ .Branch }}-
            - v5-python-
      - run:
          name: install python dependencies
          command: |
            python3 -m venv venv
            . venv/bin/activate
            pip install codecov
            pip install -r requirements-dev.txt
      - save_cache:
          paths:
            - ./venv
          key: v5-python-{{ .Branch }}-{{ checksum "requirements.txt" }}{{ checksum "requirements-dev.txt" }}
      - persist_to_workspace:
          root: ~/repo
          paths:
            - venv

  lint-be:
    executor: python
    working_directory: ~/repo
    steps:
      - checkout
      - attach_workspace:
          at: ~/repo
          name: run linting
  test-be:
    executor: with-database
    working_directory: ~/repo
    steps:
      - checkout
      - attach_workspace:
      - run:
          name: run tests
          command: |
            . venv/bin/activate
            python manage.py check
            python manage.py makemigrations --check --noinput --verbosity=1
            python manage.py collectstatic --noinput --no-post-process --verbosity=1
workflows:
    version: 2.1
        - build-fe
        - lint-fe:
vimal1083's avatar
vimal1083 committed
            requires:
            - build-fe
        - test-fe:
            requires:
            - build-fe
        - lint-be:
            requires:
              - build-be
vimal1083's avatar
vimal1083 committed
        - test-be: