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

ci: refine tester dockerfile #293

Merged
merged 2 commits into from
May 8, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
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
Loading