Skip to content

test(Python): GHA and test config files #1917

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

Merged
merged 2 commits into from
Jun 3, 2025
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
98 changes: 98 additions & 0 deletions .github/workflows/ci_examples_python.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# This workflow performs tests in Python.
name: Python Examples

on:
workflow_call:
inputs:
dafny:
description: "The Dafny version to run"
required: true
type: string
regenerate-code:
description: "Regenerate code using smithy-dafny"
required: false
default: false
type: boolean
mpl-version:
description: "MPL version to use"
required: false
type: string
mpl-head:
description: "Running on MPL HEAD"
required: false
default: false
type: boolean

jobs:
testPython:
strategy:
max-parallel: 1
matrix:
python-version: [3.11, 3.12, 3.13]
os: [macos-13]
runs-on: ${{ matrix.os }}
permissions:
id-token: write
contents: read
steps:
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: us-west-2
role-to-assume: arn:aws:iam::370957321024:role/GitHub-CI-DDBEC-Dafny-Role-us-west-2
role-session-name: DDBEC-Dafny-Python-Tests

- uses: actions/checkout@v3
with:
submodules: recursive

- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Setup Python ${{ matrix.python-version }} for running tests
run: |
python -m pip install --upgrade pip
pip install --upgrade tox
pip install poetry

- name: Setup Dafny
uses: ./submodules/MaterialProviders/.github/actions/setup_dafny/
with:
dafny-version: ${{ inputs.dafny }}

- name: Update MPL submodule if using MPL HEAD
if: ${{ inputs.mpl-head == true }}
working-directory: submodules/MaterialProviders
run: |
git checkout main
git pull
git submodule update --init --recursive
git rev-parse HEAD

- name: Install Smithy-Dafny codegen dependencies
uses: ./.github/actions/install_smithy_dafny_codegen_dependencies

- name: Regenerate code using smithy-dafny if necessary
if: ${{ inputs.regenerate-code }}
uses: ./.github/actions/polymorph_codegen
with:
dafny: ${{ env.DAFNY_VERSION }}
library: DynamoDbEncryption
diff-generated-code: false
update-and-regenerate-mpl: true

- name: Build and locally deploy dependencies for examples
shell: bash
working-directory: ./DynamoDbEncryption
run: |
make transpile_python

- name: Test DynamoDbEncryption Examples
working-directory: ./Examples/runtimes/python
run: |
# Run simple examples
tox -e dynamodbencryption
# Run migration examples
# tox -e migration
79 changes: 79 additions & 0 deletions .github/workflows/ci_static_analysis_python.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# This workflow performs static analysis in Python.
name: Python Static Analysis

on:
workflow_call:
inputs:
regenerate-code:
description: "Regenerate code using smithy-dafny"
required: false
default: false
type: boolean
mpl-version:
description: "MPL version to use"
required: false
type: string
mpl-head:
description: "Running on MPL HEAD"
required: false
default: false
type: boolean

jobs:
testPython:
strategy:
matrix:
python-version: [3.11]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
permissions:
id-token: write
contents: read
steps:
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: us-west-2
role-to-assume: arn:aws:iam::370957321024:role/GitHub-CI-DDBEC-Dafny-Role-us-west-2
role-session-name: DDBEC-Dafny-Python-Tests

- uses: actions/checkout@v3
with:
submodules: recursive

- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Setup Python ${{ matrix.python-version }} for running tests
run: |
python -m pip install --upgrade pip
pip install --upgrade tox
pip install poetry

- name: Update MPL submodule if using MPL HEAD
if: ${{ inputs.mpl-head == true }}
working-directory: submodules/MaterialProviders
run: |
git checkout main
git pull
git submodule update --init --recursive
git rev-parse HEAD

- name: Install Smithy-Dafny codegen dependencies
uses: ./.github/actions/install_smithy_dafny_codegen_dependencies

- name: Regenerate code using smithy-dafny if necessary
if: ${{ inputs.regenerate-code }}
uses: ./.github/actions/polymorph_codegen
with:
dafny: ${{ env.DAFNY_VERSION }}
library: DynamoDbEncryption
diff-generated-code: false
update-and-regenerate-mpl: true

- name: Run static analysis
working-directory: ./DynamoDbEncryption/runtimes/python
run: |
tox -e lint-check
131 changes: 131 additions & 0 deletions .github/workflows/ci_test_python.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
# This workflow runs only Dafny-transpiled Python tests.
name: test python

on:
workflow_call:
inputs:
dafny:
description: "The Dafny version to run"
required: true
type: string
regenerate-code:
description: "Regenerate code using smithy-dafny"
required: false
default: false
type: boolean
mpl-head:
description: "Running on MPL HEAD"
required: false
default: false
type: boolean

jobs:
testPython:
strategy:
fail-fast: false
matrix:
library: [DynamoDbEncryption]
python-version: ["3.11", "3.12", "3.13"]
os: [
macos-13,
ubuntu-22.04,
# Dafny-transpiled Python tests use a PYTHONPATH hack that doesn't work on Windows.
# Windows is tested with non-Dafny-transpiled Python tests.
# windows-latest
]
runs-on: ${{ matrix.os }}
permissions:
id-token: write
contents: read
steps:
- name: Support longpaths on Git checkout
run: |
git config --global core.longpaths true
- uses: actions/checkout@v3
with:
submodules: recursive

- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Setup Python ${{ matrix.python-version }} for running tests
run: |
python -m pip install --upgrade pip
pip install --upgrade tox
pip install poetry

- name: Setup Dafny
uses: ./submodules/MaterialProviders/.github/actions/setup_dafny/
with:
dafny-version: ${{ inputs.dafny }}

- name: Update MPL submodule if using MPL HEAD
if: ${{ inputs.mpl-head == true }}
working-directory: submodules/MaterialProviders
run: |
git checkout main
git pull
git submodule update --init --recursive
git rev-parse HEAD

- name: Install Smithy-Dafny codegen dependencies
uses: ./.github/actions/install_smithy_dafny_codegen_dependencies

- name: Regenerate code using smithy-dafny if necessary
if: ${{ inputs.regenerate-code }}
uses: ./.github/actions/polymorph_codegen
with:
dafny: ${{ env.DAFNY_VERSION }}
library: ${{ matrix.library }}
diff-generated-code: false
update-and-regenerate-mpl: true

- name: Download Dependencies
working-directory: ./${{ matrix.library }}
run: make setup_python

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: us-west-2
role-to-assume: arn:aws:iam::370957321024:role/GitHub-CI-DDBEC-Dafny-Role-us-west-2
role-session-name: DDBEC-Dafny-Net-Tests

- name: Compile ${{ matrix.library }} implementation
shell: bash
working-directory: ./${{ matrix.library }}
run: |
# This works because `node` is installed by default on GHA runners
CORES=$(node -e 'console.log(os.cpus().length)')
make transpile_python CORES=$CORES

- name: Test ${{ matrix.library }} Dafny-transpiled Python tests
# Dafny-transpiled Python tests use a PYTHONPATH hack that doesn't work on Windows.
# Windows is tested with non-Dafny-transpiled Python tests.
if: ${{ matrix.os != 'windows-latest' }}
working-directory: ./${{ matrix.library }}/runtimes/python
shell: bash
run: |
tox -e dafnytests

- name: Test ${{ matrix.library }} Python unit tests
working-directory: ./${{ matrix.library }}/runtimes/python
shell: bash
run: |
tox -e unit

- name: Test ${{ matrix.library }} Python integration tests
working-directory: ./${{ matrix.library }}/runtimes/python
shell: bash
run: |
tox -e integ

- name: Test ${{ matrix.library }} Python coverage
working-directory: ./${{ matrix.library }}/runtimes/python
shell: bash
run: |
tox -e encrypted-interface-coverage
tox -e client-to-resource-conversions-coverage
tox -e resource-to-client-conversions-coverage
Loading
Loading