Skip to content
Snippets Groups Projects
config.yml 3.74 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: circleci/python:3.8.9
      - image: circleci/node:12
  with-database:
      - image: circleci/python:3.8.9
          DATABASE_URL: postgresql://hypha:hypha@localhost/hypha?sslmode=disable
          DJANGO_SETTINGS_MODULE: hypha.settings.test
      - image: circleci/postgres:12
          POSTGRES_USER: hypha
          POSTGRES_PASSWORD: hypha
jobs:
  build-fe:
    executor: node
      - run:
          name: set owner on /usr/local
          command: sudo chown -R circleci:circleci /usr/local

            - v2-npm-{{ .Branch }}-{{ checksum "package-lock.json" }}
            - v2-npm-{{ .Branch }}-
            - v2-npm-
          name: install node dependencies
            npm install --quiet
            npm install -g gulp-cli
            - /usr/local/lib/node_modules
            - /usr/local/bin
          key: v2-npm-{{ .Branch }}-{{ checksum "package-lock.json" }}

      - run:
          name: builds static assets
          command: gulp deploy
      - persist_to_workspace:
          root: ~/repo
          paths:
            - hypha/static_compiled

  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:
            - v2-python-{{ .Branch }}-{{ checksum "requirements-dev.txt" }}
            - v2-python-{{ .Branch }}-
            - v2-python-

      - run:
          name: install python dependencies
          command: |
            python3 -m venv venv
            . venv/bin/activate
            pip install coverage codecov
            pip install -r requirements-dev.txt

      - save_cache:
          paths:
            - ./venv
          key: v2-python-{{ .Branch }}-{{ checksum "requirements-dev.txt" }}

      - persist_to_workspace:
          root: ~/repo
          paths:
            - venv

vimal1083's avatar
vimal1083 committed
  test-fe:
    executor: node
    working_directory: ~/repo

    steps:
      - checkout

      - run:
          name: set owner on /usr/local
          command: sudo chown -R circleci:circleci /usr/local

      - run:
          name: Run functional unit test cases [REACT.JS]
          command: |
            npm install --quiet
            npm install -g gulp-cli
            npm run test

  test-be:
    executor: with-database
    working_directory: ~/repo
    steps:
      - checkout
      - attach_workspace:
          at: ~/repo
      - run:
          name: run tests
          command: |
            . venv/bin/activate
            python manage.py makemigrations --check --noinput --verbosity=1
            coverage run --source='hypha' manage.py test
    executor: python
    working_directory: ~/repo
    steps:
      - checkout
      - attach_workspace:
      - run:
          name: run tests
          command: |
            . venv/bin/activate
            flake8 ./hypha
            make sort

workflows:
    version: 2.1
vimal1083's avatar
vimal1083 committed
        - test-fe
        - build-fe:
            requires:
            - test-fe
vimal1083's avatar
vimal1083 committed
        - test-be:
            - build-be
        - lint:
            requires:
              - build-be