Skip to content

Commit 418687f

Browse files
test(Python): GHA and test config files (#1917)
1 parent b1d4ea6 commit 418687f

File tree

13 files changed

+675
-0
lines changed

13 files changed

+675
-0
lines changed
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
# This workflow performs tests in Python.
2+
name: Python Examples
3+
4+
on:
5+
workflow_call:
6+
inputs:
7+
dafny:
8+
description: "The Dafny version to run"
9+
required: true
10+
type: string
11+
regenerate-code:
12+
description: "Regenerate code using smithy-dafny"
13+
required: false
14+
default: false
15+
type: boolean
16+
mpl-version:
17+
description: "MPL version to use"
18+
required: false
19+
type: string
20+
mpl-head:
21+
description: "Running on MPL HEAD"
22+
required: false
23+
default: false
24+
type: boolean
25+
26+
jobs:
27+
testPython:
28+
strategy:
29+
max-parallel: 1
30+
matrix:
31+
python-version: [3.11, 3.12, 3.13]
32+
os: [macos-13]
33+
runs-on: ${{ matrix.os }}
34+
permissions:
35+
id-token: write
36+
contents: read
37+
steps:
38+
- name: Configure AWS Credentials
39+
uses: aws-actions/configure-aws-credentials@v4
40+
with:
41+
aws-region: us-west-2
42+
role-to-assume: arn:aws:iam::370957321024:role/GitHub-CI-DDBEC-Dafny-Role-us-west-2
43+
role-session-name: DDBEC-Dafny-Python-Tests
44+
45+
- uses: actions/checkout@v3
46+
with:
47+
submodules: recursive
48+
49+
- name: Setup Python ${{ matrix.python-version }}
50+
uses: actions/setup-python@v4
51+
with:
52+
python-version: ${{ matrix.python-version }}
53+
54+
- name: Setup Python ${{ matrix.python-version }} for running tests
55+
run: |
56+
python -m pip install --upgrade pip
57+
pip install --upgrade tox
58+
pip install poetry
59+
60+
- name: Setup Dafny
61+
uses: ./submodules/MaterialProviders/.github/actions/setup_dafny/
62+
with:
63+
dafny-version: ${{ inputs.dafny }}
64+
65+
- name: Update MPL submodule if using MPL HEAD
66+
if: ${{ inputs.mpl-head == true }}
67+
working-directory: submodules/MaterialProviders
68+
run: |
69+
git checkout main
70+
git pull
71+
git submodule update --init --recursive
72+
git rev-parse HEAD
73+
74+
- name: Install Smithy-Dafny codegen dependencies
75+
uses: ./.github/actions/install_smithy_dafny_codegen_dependencies
76+
77+
- name: Regenerate code using smithy-dafny if necessary
78+
if: ${{ inputs.regenerate-code }}
79+
uses: ./.github/actions/polymorph_codegen
80+
with:
81+
dafny: ${{ env.DAFNY_VERSION }}
82+
library: DynamoDbEncryption
83+
diff-generated-code: false
84+
update-and-regenerate-mpl: true
85+
86+
- name: Build and locally deploy dependencies for examples
87+
shell: bash
88+
working-directory: ./DynamoDbEncryption
89+
run: |
90+
make transpile_python
91+
92+
- name: Test DynamoDbEncryption Examples
93+
working-directory: ./Examples/runtimes/python
94+
run: |
95+
# Run simple examples
96+
tox -e dynamodbencryption
97+
# Run migration examples
98+
# tox -e migration
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# This workflow performs static analysis in Python.
2+
name: Python Static Analysis
3+
4+
on:
5+
workflow_call:
6+
inputs:
7+
regenerate-code:
8+
description: "Regenerate code using smithy-dafny"
9+
required: false
10+
default: false
11+
type: boolean
12+
mpl-version:
13+
description: "MPL version to use"
14+
required: false
15+
type: string
16+
mpl-head:
17+
description: "Running on MPL HEAD"
18+
required: false
19+
default: false
20+
type: boolean
21+
22+
jobs:
23+
testPython:
24+
strategy:
25+
matrix:
26+
python-version: [3.11]
27+
os: [ubuntu-latest]
28+
runs-on: ${{ matrix.os }}
29+
permissions:
30+
id-token: write
31+
contents: read
32+
steps:
33+
- name: Configure AWS Credentials
34+
uses: aws-actions/configure-aws-credentials@v4
35+
with:
36+
aws-region: us-west-2
37+
role-to-assume: arn:aws:iam::370957321024:role/GitHub-CI-DDBEC-Dafny-Role-us-west-2
38+
role-session-name: DDBEC-Dafny-Python-Tests
39+
40+
- uses: actions/checkout@v3
41+
with:
42+
submodules: recursive
43+
44+
- name: Setup Python ${{ matrix.python-version }}
45+
uses: actions/setup-python@v4
46+
with:
47+
python-version: ${{ matrix.python-version }}
48+
49+
- name: Setup Python ${{ matrix.python-version }} for running tests
50+
run: |
51+
python -m pip install --upgrade pip
52+
pip install --upgrade tox
53+
pip install poetry
54+
55+
- name: Update MPL submodule if using MPL HEAD
56+
if: ${{ inputs.mpl-head == true }}
57+
working-directory: submodules/MaterialProviders
58+
run: |
59+
git checkout main
60+
git pull
61+
git submodule update --init --recursive
62+
git rev-parse HEAD
63+
64+
- name: Install Smithy-Dafny codegen dependencies
65+
uses: ./.github/actions/install_smithy_dafny_codegen_dependencies
66+
67+
- name: Regenerate code using smithy-dafny if necessary
68+
if: ${{ inputs.regenerate-code }}
69+
uses: ./.github/actions/polymorph_codegen
70+
with:
71+
dafny: ${{ env.DAFNY_VERSION }}
72+
library: DynamoDbEncryption
73+
diff-generated-code: false
74+
update-and-regenerate-mpl: true
75+
76+
- name: Run static analysis
77+
working-directory: ./DynamoDbEncryption/runtimes/python
78+
run: |
79+
tox -e lint-check

.github/workflows/ci_test_python.yml

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
# This workflow runs only Dafny-transpiled Python tests.
2+
name: test python
3+
4+
on:
5+
workflow_call:
6+
inputs:
7+
dafny:
8+
description: "The Dafny version to run"
9+
required: true
10+
type: string
11+
regenerate-code:
12+
description: "Regenerate code using smithy-dafny"
13+
required: false
14+
default: false
15+
type: boolean
16+
mpl-head:
17+
description: "Running on MPL HEAD"
18+
required: false
19+
default: false
20+
type: boolean
21+
22+
jobs:
23+
testPython:
24+
strategy:
25+
fail-fast: false
26+
matrix:
27+
library: [DynamoDbEncryption]
28+
python-version: ["3.11", "3.12", "3.13"]
29+
os: [
30+
macos-13,
31+
ubuntu-22.04,
32+
# Dafny-transpiled Python tests use a PYTHONPATH hack that doesn't work on Windows.
33+
# Windows is tested with non-Dafny-transpiled Python tests.
34+
# windows-latest
35+
]
36+
runs-on: ${{ matrix.os }}
37+
permissions:
38+
id-token: write
39+
contents: read
40+
steps:
41+
- name: Support longpaths on Git checkout
42+
run: |
43+
git config --global core.longpaths true
44+
- uses: actions/checkout@v3
45+
with:
46+
submodules: recursive
47+
48+
- name: Setup Python
49+
uses: actions/setup-python@v4
50+
with:
51+
python-version: ${{ matrix.python-version }}
52+
53+
- name: Setup Python ${{ matrix.python-version }} for running tests
54+
run: |
55+
python -m pip install --upgrade pip
56+
pip install --upgrade tox
57+
pip install poetry
58+
59+
- name: Setup Dafny
60+
uses: ./submodules/MaterialProviders/.github/actions/setup_dafny/
61+
with:
62+
dafny-version: ${{ inputs.dafny }}
63+
64+
- name: Update MPL submodule if using MPL HEAD
65+
if: ${{ inputs.mpl-head == true }}
66+
working-directory: submodules/MaterialProviders
67+
run: |
68+
git checkout main
69+
git pull
70+
git submodule update --init --recursive
71+
git rev-parse HEAD
72+
73+
- name: Install Smithy-Dafny codegen dependencies
74+
uses: ./.github/actions/install_smithy_dafny_codegen_dependencies
75+
76+
- name: Regenerate code using smithy-dafny if necessary
77+
if: ${{ inputs.regenerate-code }}
78+
uses: ./.github/actions/polymorph_codegen
79+
with:
80+
dafny: ${{ env.DAFNY_VERSION }}
81+
library: ${{ matrix.library }}
82+
diff-generated-code: false
83+
update-and-regenerate-mpl: true
84+
85+
- name: Download Dependencies
86+
working-directory: ./${{ matrix.library }}
87+
run: make setup_python
88+
89+
- name: Configure AWS Credentials
90+
uses: aws-actions/configure-aws-credentials@v4
91+
with:
92+
aws-region: us-west-2
93+
role-to-assume: arn:aws:iam::370957321024:role/GitHub-CI-DDBEC-Dafny-Role-us-west-2
94+
role-session-name: DDBEC-Dafny-Net-Tests
95+
96+
- name: Compile ${{ matrix.library }} implementation
97+
shell: bash
98+
working-directory: ./${{ matrix.library }}
99+
run: |
100+
# This works because `node` is installed by default on GHA runners
101+
CORES=$(node -e 'console.log(os.cpus().length)')
102+
make transpile_python CORES=$CORES
103+
104+
- name: Test ${{ matrix.library }} Dafny-transpiled Python tests
105+
# Dafny-transpiled Python tests use a PYTHONPATH hack that doesn't work on Windows.
106+
# Windows is tested with non-Dafny-transpiled Python tests.
107+
if: ${{ matrix.os != 'windows-latest' }}
108+
working-directory: ./${{ matrix.library }}/runtimes/python
109+
shell: bash
110+
run: |
111+
tox -e dafnytests
112+
113+
- name: Test ${{ matrix.library }} Python unit tests
114+
working-directory: ./${{ matrix.library }}/runtimes/python
115+
shell: bash
116+
run: |
117+
tox -e unit
118+
119+
- name: Test ${{ matrix.library }} Python integration tests
120+
working-directory: ./${{ matrix.library }}/runtimes/python
121+
shell: bash
122+
run: |
123+
tox -e integ
124+
125+
- name: Test ${{ matrix.library }} Python coverage
126+
working-directory: ./${{ matrix.library }}/runtimes/python
127+
shell: bash
128+
run: |
129+
tox -e encrypted-interface-coverage
130+
tox -e client-to-resource-conversions-coverage
131+
tox -e resource-to-client-conversions-coverage

0 commit comments

Comments
 (0)