swsnu / swppfall2019

31 stars 23 forks source link

CI issues with muli-language repository #191

Open nevivurn opened 4 years ago

nevivurn commented 4 years ago

The way we have set up our repository, we basically have two independent (at least build-wise) projects, one at backend/ and another at frontend/.

This seems to be causing issues, mainly coveralls and sonarcloud, and I am not entirely sure how to set up the CI pipeline.

How should we set up the projects such that

I did a bit of searching, and stuff like this seems to suggest it is difficult. I'd like to know what the other teams have done to solve this issue.

At least one other team seems to only check their javascript code and their python code does not seem to pass through CI at all, which seems dangerous.

ktaebum commented 4 years ago

I think Team 4 integrated both backend & frontend successfully by setting sonar-project.properties as

sonar.projectKey=swsnu_swpp2019-team4
sonar.projectName=swpp2019-team4
sonar.projectVersion=1.0
sonar.sources=backend,frontend/src
sonar.tests=backend,frontend/src

sonar.exclusions=backend/**/migrations/*
sonar.test.inclusions=backend/**/tests.py,frontend/src/**/*.test.js

sonar.python.coverage.reportPaths=backend/coverage.xml
sonar.javascript.lcov.reportPaths=frontend/coverage/lcov.info

in their project root directory. For coverage, we can check that both frontend and backend are reported well in https://sonarcloud.io/component_measures?id=swsnu_swpp2019-team4&metric=new_coverage

I think team 4's setup can be one of the solutions

ktaebum commented 4 years ago

For coveralls, you can just call separately as

matrix:
  include:
    - language: python
      python: 3.6
      cache:
        pip: true
      install:
        - pip install -r backend/requirements.txt
      before_script:
        - cd backend
        - python3 manage.py migrate
      script:
        - coverage run --source="./user/","./free_time/","./best_time/","./room/","./partial_attend_info/" manage.py test 
      after_success:
        - coveralls  # Here
      after_script:
        - cd ..

    - language: node_js
      node_js: 8.8
      addons:
        apt:
          sources:
            - google-chrome
          packages:
            - google-chrome-stable
      cache:
        npm: true
        directories:
          - frontend/node_modules
      before_install:
        - export CHROME_BIN=/usr/bin/google-chrome
        - export DISPLAY=:99.0
        - sh -e /etc/init.d/xvfb start
        - cd frontend
      install:
        - npm install
        - npm install coveralls
        - npm install -g @angular/cli
      script:
        - ng test -sm=false --code-coverage --watch false
        - ng e2e
      after_success:
        - cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js # Here
      after_script:
        - cd ..