python: adjust test case for Canonical Event #24
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: VMSDK Python Test | |
on: | |
push: | |
branches: | |
- main | |
paths: | |
- 'src/python/**/*' | |
- 'setupenv.sh' | |
- '.github/workflows/vmsdk-test-python.yaml' | |
pull_request: | |
paths: | |
- 'src/python/**/*' | |
- 'setupenv.sh' | |
- '.github/workflows/vmsdk-test-python.yaml' | |
workflow_dispatch: | |
env: | |
VMSDK_PYTEST_DIR: 'vmsdk_pytest' | |
jobs: | |
vmsdk_pytest: | |
runs-on: [self-hosted, tdx-guest] | |
defaults: | |
run: | |
working-directory: ${{env.VMSDK_PYTEST_DIR}} | |
steps: | |
- name: Clean up intermediate files | |
continue-on-error: true | |
run: | | |
# Remove the intermediate files that could be left | |
# by previous run with sudo. Otherwise, the checkout | |
# will fail with permission issue. | |
sudo rm -fr ./* | |
- name: Checkout repo | |
uses: actions/checkout@v4 | |
with: | |
path: ${{env.VMSDK_PYTEST_DIR}} | |
- name: Run PyTest for VMSDK | |
run: | | |
set -ex | |
# Set the "PYTHONDONTWRITEBYTECODE" and "no:cacheprovider" to prevent | |
# generated some intermediate files by root. Othwerwise, these | |
# files will fail the action/checkout in the next round of running | |
# due to the permission issue. | |
sudo su -c "source setupenv.sh && \ | |
pushd src/python/tests && \ | |
export PYTHONDONTWRITEBYTECODE=1 && \ | |
python3 -m pytest -p no:cacheprovider -v test_sdk.py && \ | |
popd" |