Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jimfuqian/BB2-3216 Investigate adding coverage report to tests #1200

Draft
wants to merge 8 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,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/
34 changes: 17 additions & 17 deletions Dockerfile.selenium
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
FROM selenium/standalone-chrome
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 jsonschema
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 jsonschema

3 changes: 2 additions & 1 deletion Jenkinsfiles/Jenkinsfile.cbc-run-multi-pr-checks-w-selenium
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ pipeline {
. venv/bin/activate
make reqs-download
make reqs-install-dev
pip install --upgrade coverage
"""
}
}
Expand All @@ -74,7 +75,7 @@ pipeline {
steps{
sh """
. venv/bin/activate
python runtests.py
coverage run runtests.py && coverage report -m
"""
}
}
Expand Down
33 changes: 33 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,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
Expand All @@ -63,3 +75,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:

3 changes: 2 additions & 1 deletion docker-compose/run_integration_tests_local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion docker-compose/run_selenium_tests_remote.sh
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,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
Expand Down
Loading