Skip to content

Commit cfb2f7e

Browse files
feat: Python MPL (#805)
1 parent 4f7e715 commit cfb2f7e

File tree

226 files changed

+64994
-12
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

226 files changed

+64994
-12
lines changed

.github/actions/polymorph_codegen/action.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,12 @@ runs:
8282
run: |
8383
make polymorph_dotnet
8484
85+
- name: Regenerate Python code using smithy-dafny
86+
working-directory: ./${{ inputs.library }}
87+
shell: bash
88+
run: |
89+
make polymorph_python
90+
8591
- name: Check regenerated code against commited code
8692
# Composite action inputs seem to not actually support booleans properly for some reason
8793
if: inputs.diff-generated-code == 'true'

.github/workflows/daily_ci.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@ jobs:
4343
uses: ./.github/workflows/library_net_tests.yml
4444
with:
4545
dafny: ${{needs.getVersion.outputs.version}}
46+
daily-ci-python:
47+
needs: getVersion
48+
if: github.event_name != 'schedule' || github.repository_owner == 'aws'
49+
uses: ./.github/workflows/library_python_tests.yml
50+
with:
51+
dafny: ${{needs.getVersion.outputs.version}}
4652
daily-interop-test:
4753
needs: getVersion
4854
if: github.event_name != 'schedule' || github.repository_owner == 'aws'

.github/workflows/library_codegen.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ jobs:
2525
# Note dotnet is only used for formatting generated code
2626
# in this workflow
2727
dotnet-version: ["6.0.x"]
28+
# Note python is only used for formatting generated code
29+
# in this workflow.
30+
# The workflow installs black and docformatter and runs them on generated code.
31+
python-version: [3.11]
2832
os: [ubuntu-latest]
2933
runs-on: ${{ matrix.os }}
3034
defaults:
@@ -66,6 +70,16 @@ jobs:
6670
- name: Install Smithy-Dafny codegen dependencies
6771
uses: ./.github/actions/install_smithy_dafny_codegen_dependencies
6872

73+
- name: Setup Python, black, and docformatter for code formatting
74+
uses: actions/setup-python@v4
75+
with:
76+
python-version: ${{ matrix.python-version }}
77+
architecture: x64
78+
- run: |
79+
python -m pip install --upgrade pip
80+
python -m pip install --upgrade black
81+
python -m pip install --upgrade docformatter
82+
6983
- uses: ./.github/actions/polymorph_codegen
7084
with:
7185
dafny: ${{ env.DAFNY_VERSION }}

.github/workflows/library_interop_tests.yml

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
ubuntu-latest,
2626
macos-12,
2727
]
28-
language: [java, net]
28+
language: [java, net, python]
2929
# https://taskei.amazon.dev/tasks/CrypTool-5284
3030
dotnet-version: ["6.0.x"]
3131
runs-on: ${{ matrix.os }}
@@ -57,6 +57,16 @@ jobs:
5757
distribution: "corretto"
5858
java-version: 17
5959

60+
- name: Setup Python for running tests
61+
uses: actions/setup-python@v4
62+
with:
63+
python-version: 3.11
64+
architecture: x64
65+
- run: |
66+
python -m pip install --upgrade pip
67+
pip install --upgrade tox
68+
pip install poetry
69+
6070
- name: Setup Dafny
6171
uses: dafny-lang/[email protected]
6272
with:
@@ -89,6 +99,15 @@ jobs:
8999
CORES=$(node -e 'console.log(os.cpus().length)')
90100
make transpile_net
91101
102+
- name: Build ${{ matrix.library }} implementation in Python
103+
if: matrix.language == 'python'
104+
shell: bash
105+
working-directory: ./${{ matrix.library }}
106+
run: |
107+
# This works because `node` is installed by default on GHA runners
108+
CORES=$(node -e 'console.log(os.cpus().length)')
109+
make transpile_python
110+
92111
- name: Setup gradle
93112
if: matrix.language == 'java'
94113
uses: gradle/gradle-build-action@v2
@@ -128,8 +147,8 @@ jobs:
128147
ubuntu-latest,
129148
macos-12,
130149
]
131-
encrypting_language: [java, net]
132-
decrypting_language: [java, net]
150+
encrypting_language: [java, net, python]
151+
decrypting_language: [java, net, python]
133152
dotnet-version: ["6.0.x"]
134153
runs-on: ${{ matrix.os }}
135154
permissions:
@@ -167,6 +186,16 @@ jobs:
167186
distribution: "corretto"
168187
java-version: 17
169188

189+
- name: Setup Python for running tests
190+
uses: actions/setup-python@v4
191+
with:
192+
python-version: 3.11
193+
architecture: x64
194+
- run: |
195+
python -m pip install --upgrade pip
196+
pip install --upgrade tox
197+
pip install poetry
198+
170199
- name: Setup Dafny
171200
uses: dafny-lang/[email protected]
172201
with:
@@ -199,6 +228,15 @@ jobs:
199228
CORES=$(node -e 'console.log(os.cpus().length)')
200229
make transpile_net
201230
231+
- name: Build ${{ matrix.library }} implementation in Python
232+
if: matrix.decrypting_language == 'python'
233+
shell: bash
234+
working-directory: ./${{ matrix.library }}
235+
run: |
236+
# This works because `node` is installed by default on GHA runners
237+
CORES=$(node -e 'console.log(os.cpus().length)')
238+
make transpile_python
239+
202240
- name: Download Encrypt Manifest Artifact
203241
uses: actions/download-artifact@v4
204242
with:
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# This workflow performs tests in Python.
2+
name: Library Python tests
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+
17+
jobs:
18+
testPython:
19+
strategy:
20+
fail-fast: false
21+
matrix:
22+
library:
23+
[
24+
StandardLibrary,
25+
AwsCryptographyPrimitives,
26+
ComAmazonawsKms,
27+
ComAmazonawsDynamodb,
28+
AwsCryptographicMaterialProviders,
29+
TestVectorsAwsCryptographicMaterialProviders,
30+
]
31+
python-version: ["3.11"]
32+
os: [
33+
# TODO fix Dafny-generated tests on Windows;
34+
# the sys.path workaround for generated Dafny doesn't work on Windows.
35+
# Note: only tests use the sys.path workaround, not source code.
36+
# Windows source code is tested downstream (ex. ESDK-Python CI).
37+
# windows-latest,
38+
ubuntu-latest,
39+
macos-12,
40+
]
41+
runs-on: ${{ matrix.os }}
42+
defaults:
43+
run:
44+
shell: bash
45+
permissions:
46+
id-token: write
47+
contents: read
48+
steps:
49+
- name: Support longpaths on Git checkout
50+
run: |
51+
git config --global core.longpaths true
52+
53+
- name: Configure AWS Credentials
54+
uses: aws-actions/configure-aws-credentials@v4
55+
with:
56+
aws-region: us-west-2
57+
role-to-assume: arn:aws:iam::370957321024:role/GitHub-CI-MPL-Dafny-Role-us-west-2
58+
role-session-name: PythonTests
59+
60+
- uses: actions/checkout@v4
61+
# The specification submodule is private so we don't have access, but we don't need
62+
# it to verify the Dafny code. Instead we manually pull the submodules we DO need.
63+
- run: git submodule update --init libraries
64+
- run: git submodule update --init smithy-dafny
65+
66+
- name: Setup Dafny
67+
uses: dafny-lang/[email protected]
68+
with:
69+
dafny-version: ${{ inputs.dafny }}
70+
71+
- name: Setup Python ${{ matrix.python-version }} for running tests
72+
uses: actions/setup-python@v4
73+
with:
74+
python-version: ${{ matrix.python-version }}
75+
architecture: x64
76+
- run: |
77+
python -m pip install --upgrade pip
78+
pip install --upgrade tox
79+
pip install poetry
80+
81+
- name: Build ${{ matrix.library }} implementation
82+
working-directory: ./${{ matrix.library }}
83+
run: |
84+
# This works because `node` is installed by default on GHA runners
85+
CORES=$(node -e 'console.log(os.cpus().length)')
86+
make transpile_python CORES=$CORES
87+
88+
- name: Test ${{ matrix.library }}
89+
working-directory: ./${{ matrix.library }}
90+
shell: bash
91+
run: |
92+
make test_python

.github/workflows/manual.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ jobs:
3737
with:
3838
dafny: ${{ inputs.dafny }}
3939
regenerate-code: ${{ inputs.regenerate-code }}
40+
manual-ci-python:
41+
uses: ./.github/workflows/library_python_tests.yml
42+
with:
43+
dafny: ${{needs.getVersion.outputs.version}}
44+
regenerate-code: ${{ inputs.regenerate-code }}
4045
manual-interop-test:
4146
uses: ./.github/workflows/library_interop_tests.yml
4247
with:

.github/workflows/nightly_dafny.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ jobs:
3737
with:
3838
dafny: "nightly-latest"
3939
regenerate-code: true
40+
dafny-nightly-python:
41+
needs: getVersion
42+
uses: ./.github/workflows/library_python_tests.yml
43+
with:
44+
dafny: ${{needs.getVersion.outputs.version}}
4045

4146
cut-issue-on-failure:
4247
runs-on: ubuntu-latest

.github/workflows/pull.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ jobs:
3434
uses: ./.github/workflows/library_net_tests.yml
3535
with:
3636
dafny: ${{needs.getVersion.outputs.version}}
37+
pr-ci-python:
38+
needs: getVersion
39+
uses: ./.github/workflows/library_python_tests.yml
40+
with:
41+
dafny: ${{needs.getVersion.outputs.version}}
3742
pr-interop-test:
3843
needs: getVersion
3944
uses: ./.github/workflows/library_interop_tests.yml

.github/workflows/push.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ jobs:
3636
uses: ./.github/workflows/library_net_tests.yml
3737
with:
3838
dafny: ${{needs.getVersion.outputs.version}}
39+
push-ci-python:
40+
needs: getVersion
41+
uses: ./.github/workflows/library_python_tests.yml
42+
with:
43+
dafny: ${{needs.getVersion.outputs.version}}
3944
pr-interop-test:
4045
needs: getVersion
4146
uses: ./.github/workflows/library_interop_tests.yml

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ test/**/Output/*
77
/package-lock.json
88
/node_modules
99

10+
# Python docs build Artifacts
11+
build
12+
doc/build
13+
AwsCryptographicMaterialProviders/runtimes/python/doc/generated/*
14+
1015
# Duvet output
1116
specification_compliance_report.html
1217

0 commit comments

Comments
 (0)