Skip to content

Commit

Permalink
refine tester dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
Bodong-Yang committed May 8, 2024
1 parent 794770c commit cb4bdae
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ jobs:
uses: actions/checkout@v3
- name: Build ota-test_base docker image
run: |
docker-compose -f docker/docker-compose_tests.yml build
docker compose -f docker/docker-compose_tests.yml build
- name: Execute pytest with coverage trace under ota-test_base container
run: |
set -o pipefail
docker-compose -f docker/docker-compose_tests.yml up --no-log-prefix --abort-on-container-exit | tee pytest-coverage.txt
mkdir -p test_result
docker compose -f docker/docker-compose_tests.yml up --abort-on-container-exit
# export the coverage report to the comment!
- name: Add coverage report to PR comment
continue-on-error: true
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -166,3 +166,6 @@ build
# local vscode configs
.devcontainer
.vscode

# local test artifacts
test_result/
2 changes: 1 addition & 1 deletion docker/docker-compose_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ services:
dockerfile: ./docker/test_base/Dockerfile
image: ota-test_base
network_mode: bridge
command: "python3 -m pytest"
container_name: ota-test
volumes:
- ../pyproject.toml:/ota-client/pyproject.toml:ro
- ../.flake8:/ota-client/.flake8:ro
- ../otaclient:/ota-client/otaclient:ro
- ../tests:/ota-client/tests:ro
- ../test_result:/ota-client/test_result:rw
6 changes: 4 additions & 2 deletions docker/test_base/entry_point.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,7 @@ TESTS_DEPENDENCIES="${OTA_CLIENT_DIR}/tests/requirements.txt"
python3 -m pip install --no-cache-dir -q -r $TESTS_DEPENDENCIES

# exec the input params
echo "execute command..."
exec "$@"
echo "execute test with coverage"
cd "${OTA_CLIENT_DIR}"
coverage run -m pytest --junit-xml=test_result/pytest.xml "${@:-}"
coverage xml -o test_result/coverage.xml

0 comments on commit cb4bdae

Please sign in to comment.