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

test: adjust workflow and case for recent change #109

Closed
wants to merge 2 commits into from
Closed
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
12 changes: 0 additions & 12 deletions .github/workflows/pr-check-rust.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,12 @@ on:
- 'common/rust/cctrusted_base/src/**.rs'
- 'common/rust/cctrusted_base/src/tdx/**.rs'
- 'common/rust/cctrusted_base/src/tpm/**.rs'
- 'vmsdk/rust/cctrusted_vm/src/**.rs'
- 'vmsdk/rust/sample/src/**.rs'
- '.github/workflows/pr-check-rust.yaml'
pull_request:
paths:
- 'common/rust/cctrusted_base/src/**.rs'
- 'common/rust/cctrusted_base/src/tdx/**.rs'
- 'common/rust/cctrusted_base/src/tpm/**.rs'
- 'vmsdk/rust/cctrusted_vm/src/**.rs'
- 'vmsdk/rust/sample/src/**.rs'
- '.github/workflows/pr-check-rust.yaml'
workflow_dispatch:

Expand Down Expand Up @@ -45,11 +41,3 @@ jobs:
cargo clippy
cargo install --locked cargo-deny
cargo deny check

- name: Run cargo check for VM SDK
run: |
cd vmsdk/rust/cctrusted_vm/
cargo check
cargo fmt -- --check
cargo clippy
cargo deny check
5 changes: 0 additions & 5 deletions .github/workflows/publish-pypi-packages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,3 @@ jobs:
python3 -m build
python3 -m twine upload -u $PYPI_USERNAME -p $PYPI_PASSWORD --repository pypi dist/*
popd

pushd vmsdk/python/
python3 -m build
python3 -m twine upload -u $PYPI_USERNAME -p $PYPI_PASSWORD --repository pypi dist/*
popd
1 change: 0 additions & 1 deletion .github/workflows/pylicense.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ on:
pull_request:
paths:
- 'common/python/**'
- 'vmsdk/python/**'
workflow_dispatch:

jobs:
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/pylint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@ on:
- main
paths:
- 'common/**/*.py'
- 'vmsdk/**/*.py'
pull_request:
paths:
- 'common/**/*.py'
- 'vmsdk/**/*.py'
workflow_dispatch:

jobs:
Expand All @@ -26,7 +24,6 @@ jobs:
python3 -m pip install --upgrade pip
python3 -m pip install pylint pydocstyle
python3 -m pip install -r ./common/python/requirements.txt
python3 -m pip install -r ./vmsdk/python/requirements.txt
sudo apt update

- name: Analyze python code
Expand Down
48 changes: 36 additions & 12 deletions .github/workflows/vmsdk-test-python.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,52 @@ on:
branches:
- main
paths:
- 'vmsdk/**/*.py'
- 'common/**/*.py'
- 'setupenv.sh'
- '.github/workflows/vmsdk-test-python.yaml'
pull_request:
paths:
- 'vmsdk/**/*.py'
- 'common/**/*.py'
- 'setupenv.sh'
- '.github/workflows/vmsdk-test-python.yaml'
workflow_dispatch:

env:
VMSDK_PYTEST_DIR: 'vmsdk_pytest'
VMSDK_DIR: 'cc-trusted-vmsdk'

jobs:
vmsdk_pytest:
runs-on: [self-hosted, tdx-guest]
defaults:
run:
working-directory: ${{env.VMSDK_PYTEST_DIR}}
steps:
- uses: actions/checkout@v3
- 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 cc-trusted-api repo
uses: actions/checkout@v4
with:
path: ${{env.VMSDK_PYTEST_DIR}}
- name: Checkout cc-trusted-vmsdk repo
uses: actions/checkout@v4
with:
repository: cc-api/cc-trusted-vmsdk
path: ${{env.VMSDK_PYTEST_DIR}}/${{env.VMSDK_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 vmsdk/python/tests && \
export PYTHONDONTWRITEBYTECODE=1 && \
python3 -m pytest -p no:cacheprovider -v test_sdk.py && \
popd"
cd ${{env.VMSDK_DIR}}
# The trick here is that we need to use the local version
# of cctrusted_base instead of the version instaleed by
# setupenv.sh. So uninstall it and reinstall from local.
sudo su -c 'source setupenv.sh && \
python3 -m pip uninstall -y cctrusted_base && \
python3 -m pip install ../common/python && \
cd src/python/tests && \
python3 -m pytest -v test_sdk.py'
49 changes: 49 additions & 0 deletions .github/workflows/vmsdk-test-rust.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: VMSDK Rust Test

on:
push:
branches:
- main
paths:
- '.github/workflows/vmsdk-test-rust.yaml'
pull_request:
paths:
- '.github/workflows/vmsdk-test-rust.yaml'
workflow_dispatch:

env:
CARGO_TERM_COLOR: always
VMSDK_RUST_TEST_DIR: 'vmsdk_rust_test'
VMSDK_DIR: 'cc-trusted-vmsdk'

jobs:
vmsdk_rust_test:
runs-on: [self-hosted, tdx-guest]
defaults:
run:
working-directory: ${{env.VMSDK_RUST_TEST_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 cc-trusted-api repo
uses: actions/checkout@v4
with:
path: ${{env.VMSDK_RUST_TEST_DIR}}
- name: Checkout cc-trusted-vmsdk repo
uses: actions/checkout@v4
with:
repository: cc-api/cc-trusted-vmsdk
path: ${{env.VMSDK_RUST_TEST_DIR}}/${{env.VMSDK_DIR}}
- name: Run tests
run: |
cd ${{env.VMSDK_DIR}}/src/rust/cctrusted_vm
# The trick here is to override the dependencies with local version.
echo "" >> Cargo.toml
echo "[patch.crates-io]" >> Cargo.toml
echo 'cctrusted_base = { path = "../../../../common/rust/cctrusted_base" }' >> Cargo.toml
sudo bash -c "export CARGO_TERM_COLOR=always && cargo test --verbose"
33 changes: 0 additions & 33 deletions .github/workflows/vmsdk-test-rust.yml

This file was deleted.

22 changes: 14 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ Choose correct SDK according to your environment. Installation guide can be foun
| SDK | Deployment Scenarios | Installation Guide |
| --- | --------------- | -- |
| Firmware SDK | Firmware Application | |
| [VM SDK](https://github.com/cc-api/cc-trusted-api/tree/main/vmsdk) | Confidential Virtual Machine | [Guide](vmsdk/README.md) |
| [VM SDK](https://github.com/cc-api/cc-trusted-vmsdk) | Confidential Virtual Machine | [Guide](https://github.com/cc-api/cc-trusted-vmsdk/blob/main/README.md) |
| [Confidential Cloud Native Primitives (CCNP)](https://github.com/cc-api/confidential-cloud-native-primitives) | Confidential Cluster/Container | [Guide](https://github.com/cc-api/confidential-cloud-native-primitives/blob/main/deployment/README.md) |

## 5. How to use the APIs
Expand Down Expand Up @@ -93,12 +93,14 @@ for index in range(CCTrustedVmSdk.inst().get_measurement_count()):
LOG.info("HASH: %s", hash_str)
```

Run [cc_imr_cli.py](vmsdk/python/cc_imr_cli.py) to execute the sample.
Run [cc_imr_cli.py](https://github.com/cc-api/cc-trusted-vmsdk/blob/main/src/python/cc_imr_cli.py) to execute the sample.

```
$ git clone https://github.com/cc-api/cc-trusted-vmsdk.git
$ cd cc-trusted-vmsdk
$ sudo su
# source setupenv.sh
# cd vmsdk/python
# cd src/python
# python3 cc_imr_cli.py
```

Expand Down Expand Up @@ -148,19 +150,21 @@ if quote is not None:
quote.dump(is_raw=True)
```

Run [cc_quote_cli.py](vmsdk/python/cc_quote_cli.py) to execute the sample.
Run [cc_quote_cli.py](https://github.com/cc-api/cc-trusted-vmsdk/blob/main/src/python/cc_quote_cli.py) to execute the sample.

```
$ git clone https://github.com/cc-api/cc-trusted-vmsdk.git
$ cd cc-trusted-vmsdk
$ sudo su
# source setupenv.sh
# cd vmsdk/python
# cd src/python
# python3 cc_quote_cli.py
```

Below is the example output for `get_cc_report` API on Intel® TDX via VM SDK:

```
root@tdx-guest:/home/tdx/cc-trusted-api/vmsdk/python# python3 ./cc_quote_cli.py
root@tdx-guest:/home/tdx/cc-trusted-vmsdk/src/python# python3 ./cc_quote_cli.py
cctrusted.cvm DEBUG Successful open device node /dev/tdx_guest
cctrusted.cvm DEBUG Successful read TDREPORT from /dev/tdx_guest.
cctrusted.cvm DEBUG Successful parse TDREPORT.
Expand Down Expand Up @@ -210,12 +214,14 @@ event_logs = CCTrustedVmSdk.inst().get_cc_eventlog(start, count)
event_logs.dump()
```

Run [cc_event_log_cli.py](vmsdk/python/cc_event_log_cli.py) to execute the sample.
Run [cc_event_log_cli.py](https://github.com/cc-api/cc-trusted-vmsdk/blob/main/src/python/cc_event_log_cli.py) to execute the sample.

```
$ git clone https://github.com/cc-api/cc-trusted-vmsdk.git
$ cd cc-trusted-vmsdk
$ sudo su
# source setupenv.sh
# cd vmsdk/python
# cd src/python
# python3 cc_event_log_cli.py [-s <start_index_of_event_log>] [-c <count_of_event_logs>]
```

Expand Down
2 changes: 1 addition & 1 deletion setupenv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
CURR_DIR=$(pwd)

# setup PYTHONPATH
export PYTHONPATH=$PYTHONPATH:$CURR_DIR/common/python/:$CURR_DIR/vmsdk/python
export PYTHONPATH=$PYTHONPATH:$CURR_DIR/common/python/
75 changes: 0 additions & 75 deletions vmsdk/README.md

This file was deleted.

Loading
Loading