diff --git a/Dockerfile b/Dockerfile index ca3600843..af9338dff 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,10 +5,13 @@ RUN useradd -m -s /bin/bash DEV USER DEV ADD . /code WORKDIR /code +RUN wget -P /tmp https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-5.0.1.3006-linux.zip +RUN unzip /tmp/sonar-scanner-cli-5.0.1.3006-linux.zip -d /tmp RUN python -m venv /tmp/venv RUN . /tmp/venv/bin/activate -ENV PATH="/tmp/venv/bin:${PATH}" +ENV PATH="/tmp/sonar-scanner-5.0.1.3006-linux/bin:/tmp/venv/bin:${PATH}" RUN pip install --upgrade pip RUN pip install --upgrade pip-tools RUN pip install --upgrade setuptools +RUN pip install --upgrade coverage RUN pip install -r requirements/requirements.dev.txt --no-index --find-links ./vendor/ \ No newline at end of file diff --git a/Dockerfile.selenium b/Dockerfile.selenium index a7adb7d17..0acfde1e8 100755 --- a/Dockerfile.selenium +++ b/Dockerfile.selenium @@ -1,17 +1,16 @@ -FROM seleniarm/standalone-chromium - -ENV PYTHONUNBUFFERED 1 -USER root -#RUN apt-get update ; apt-get install -yq git curl libpq-dev libffi-dev -RUN apt-get update ; apt-get install -yq python3 python3-venv -RUN ln -s /usr/bin/python3 /usr/local/bin/python -RUN useradd -m -s /bin/bash DEV -USER DEV -ADD . /code -WORKDIR /code -RUN python -m venv /tmp/venv -RUN . /tmp/venv/bin/activate -ENV PATH="/tmp/venv/bin:${PATH}" -RUN pip3 install --upgrade pip -RUN pip3 install selenium pytest debugpy jsonschema python-dateutil - +FROM seleniarm/standalone-chromium + +ENV PYTHONUNBUFFERED 1 +USER root +#RUN apt-get update ; apt-get install -yq git curl libpq-dev libffi-dev +RUN apt-get update ; apt-get install -yq python3 python3-venv +RUN ln -s /usr/bin/python3 /usr/local/bin/python +RUN useradd -m -s /bin/bash DEV +USER DEV +ADD . /code +WORKDIR /code +RUN python -m venv /tmp/venv +RUN . /tmp/venv/bin/activate +ENV PATH="/tmp/venv/bin:${PATH}" +RUN pip3 install --upgrade pip +RUN pip3 install selenium pytest debugpy jsonschema python-dateutil diff --git a/Jenkinsfiles/Jenkinsfile.cbc-run-multi-pr-checks-w-selenium b/Jenkinsfiles/Jenkinsfile.cbc-run-multi-pr-checks-w-selenium index 0b5189fec..959d3db68 100755 --- a/Jenkinsfiles/Jenkinsfile.cbc-run-multi-pr-checks-w-selenium +++ b/Jenkinsfiles/Jenkinsfile.cbc-run-multi-pr-checks-w-selenium @@ -58,6 +58,7 @@ pipeline { python -m pip install --upgrade pip setuptools wheel cryptography make reqs-download make reqs-install-dev + pip install --upgrade coverage """ } } @@ -75,7 +76,7 @@ pipeline { steps{ sh """ . venv/bin/activate - python runtests.py + coverage run runtests.py && coverage report -m """ } } diff --git a/docker-compose.yml b/docker-compose.yml index 9ae404d3f..5bd60b08a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -49,6 +49,18 @@ services: profiles: - mocksls platform: linux/amd64 + sonarqube: + image: sonarqube:community + environment: + - SONAR_WEB_PORT=9009 + volumes: + - sonarqube_data:/opt/sonarqube/data + - sonarqube_extensions:/opt/sonarqube/extensions + - sonarqube_logs:/opt/sonarqube/logs + ports: + - "9009:9009" + profiles: + - sonarserver unittests: build: . command: python3 -m debugpy --listen 0.0.0.0:6789 --wait-for-client runtests.py @@ -60,3 +72,24 @@ services: - .:/code profiles: - tests + coverage: + build: . + command: bash -c "coverage run runtests.py && coverage xml" + env_file: + - docker-compose/unittests-env-vars.env + volumes: + - .:/code + profiles: + - coverage + sonardemo: + build: . + command: bash -c "sonar-scanner -Dsonar.projectKey=BB2 -Dsonar.sources=. -Dsonar.python.coverage.reportPaths=coverage.xml -Dsonar.host.url=http://sonarqube:9009 -Dsonar.token=sqp_9f1dcd7f83b3b12be28008a6e0a595352a852bec" + volumes: + - .:/code + profiles: + - sonardemo +volumes: + sonarqube_data: + sonarqube_extensions: + sonarqube_logs: + diff --git a/docker-compose/run_integration_tests_local.sh b/docker-compose/run_integration_tests_local.sh index 87bed3e15..bd212a53c 100755 --- a/docker-compose/run_integration_tests_local.sh +++ b/docker-compose/run_integration_tests_local.sh @@ -244,7 +244,8 @@ else pip install -r requirements/requirements.txt \ --no-index --find-links ./vendor/; \ pip install sqlparse; \ - python runtests.py --integration ${INTEGRATION_TESTS_LIST}" + coverage run runtests.py --integration ${INTEGRATION_TESTS_LIST}; \ + coverage report -m" fi fi diff --git a/docker-compose/run_selenium_tests_remote.sh b/docker-compose/run_selenium_tests_remote.sh index 274bc2c81..5c36badf3 100755 --- a/docker-compose/run_selenium_tests_remote.sh +++ b/docker-compose/run_selenium_tests_remote.sh @@ -104,7 +104,7 @@ SYSTEM=$(uname -s) echo "USE_NEW_PERM_SCREEN=" ${USE_NEW_PERM_SCREEN} echo "BB2 Server URL=" ${HOSTNAME_URL} -export USE_NEW_PERM_SCREEN +## export USE_NEW_PERM_SCREEN export USE_MSLSX=false # stop all before run selenium remote tests