Skip to content

Commit 98ddfe9

Browse files
authored
chore: add rust support (#1376)
* feat: add rust support
1 parent 562b3ef commit 98ddfe9

File tree

100 files changed

+8524
-73
lines changed

Some content is hidden

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

100 files changed

+8524
-73
lines changed

.github/workflows/daily_ci.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ jobs:
5656
uses: ./.github/workflows/ci_test_net.yml
5757
with:
5858
dafny: ${{needs.getVersion.outputs.version}}
59+
daily-ci-rust:
60+
needs: getVersion
61+
uses: ./.github/workflows/library_rust_tests.yml
62+
with:
63+
dafny: ${{needs.getVersion.outputs.version}}
5964
daily-ci-net-test-vectors:
6065
needs: getVersion
6166
uses: ./.github/workflows/ci_test_vector_net.yml
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
# This workflow performs tests in Rust.
2+
name: Library Rust 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+
testRust:
19+
strategy:
20+
fail-fast: false
21+
matrix:
22+
library: [DynamoDbEncryption, TestVectors]
23+
# removed windows-latest because somehow it can't build aws-lc in CI
24+
os: [ubuntu-latest, macos-13]
25+
runs-on: ${{ matrix.os }}
26+
permissions:
27+
id-token: write
28+
contents: read
29+
env:
30+
RUST_MIN_STACK: 104857600
31+
steps:
32+
- name: Support longpaths on Git checkout
33+
run: |
34+
git config --global core.longpaths true
35+
- uses: actions/checkout@v3
36+
- name: Init Submodules
37+
shell: bash
38+
run: |
39+
git submodule update --init --recursive submodules/smithy-dafny
40+
git submodule update --init --recursive submodules/MaterialProviders
41+
42+
- name: Configure AWS Credentials
43+
uses: aws-actions/configure-aws-credentials@v4
44+
with:
45+
aws-region: us-west-2
46+
role-to-assume: arn:aws:iam::370957321024:role/GitHub-CI-DDBEC-Dafny-Role-us-west-2
47+
role-session-name: DDBEC-Dafny-Rust-Tests
48+
49+
- name: Setup Rust Toolchain for GitHub CI
50+
uses: actions-rust-lang/[email protected]
51+
with:
52+
components: rustfmt
53+
# uncomment this after Rust formatter works
54+
# - name: Rustfmt Check
55+
# uses: actions-rust-lang/rustfmt@v1
56+
57+
- name: Setup Dafny
58+
uses: dafny-lang/[email protected]
59+
with:
60+
dafny-version: nightly-latest
61+
62+
# Remove this after the formatting in Rust starts working
63+
- name: smithy-dafny Rust hacks
64+
shell: bash
65+
run: |
66+
if [ "$RUNNER_OS" == "macOS" ]; then
67+
sed -i '' 's|rustfmt --edition 2021 runtimes/rust/src/implementation_from_dafny.rs|#&|' submodules/smithy-dafny/SmithyDafnyMakefile.mk
68+
else
69+
sed -i 's|rustfmt --edition 2021 runtimes/rust/src/implementation_from_dafny.rs|#&|' submodules/smithy-dafny/SmithyDafnyMakefile.mk
70+
fi
71+
72+
- name: Setup Java 17 for codegen
73+
uses: actions/setup-java@v3
74+
with:
75+
distribution: "corretto"
76+
java-version: "17"
77+
78+
- name: Setup NASM for Windows (aws-lc-sys)
79+
if: matrix.os == 'windows-latest'
80+
uses: ilammy/setup-nasm@v1
81+
82+
- name: Install Smithy-Dafny codegen dependencies
83+
uses: ./.github/actions/install_smithy_dafny_codegen_dependencies
84+
85+
- name: Run make polymorph_rust
86+
shell: bash
87+
working-directory: ./${{ matrix.library }}
88+
run: |
89+
make polymorph_rust
90+
91+
- name: Compile ${{ matrix.library }} implementation
92+
shell: bash
93+
working-directory: ./${{ matrix.library }}
94+
run: |
95+
# This works because `node` is installed by default on GHA runners
96+
CORES=$(node -e 'console.log(os.cpus().length)')
97+
make transpile_rust TRANSPILE_TESTS_IN_RUST=1 CORES=$CORES
98+
99+
- name: Copy ${{ matrix.library }} Vector Files
100+
if: ${{ matrix.library == 'TestVectors' }}
101+
shell: bash
102+
working-directory: ./${{ matrix.library }}
103+
run: |
104+
cp runtimes/java/*.json runtimes/rust/
105+
106+
- name: Test ${{ matrix.library }} Rust
107+
shell: bash
108+
working-directory: ./${{ matrix.library }}
109+
run: |
110+
make test_rust
111+
112+
- name: Test Examples for Rust in ${{ matrix.library }}
113+
if: ${{ matrix.library == 'DynamoDbEncryption' }}
114+
working-directory: ./${{ matrix.library }}/runtimes/rust/
115+
shell: bash
116+
run: |
117+
cargo run --example main

.github/workflows/manual.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ jobs:
5252
with:
5353
dafny: ${{ inputs.dafny }}
5454
regenerate-code: ${{ inputs.regenerate-code }}
55+
manual-ci-rust:
56+
uses: ./.github/workflows/library_rust_tests.yml
57+
with:
58+
dafny: ${{ inputs.dafny }}
59+
regenerate-code: ${{ inputs.regenerate-code }}
5560
manual-ci-net-test-vectors:
5661
uses: ./.github/workflows/ci_test_vector_net.yml
5762
with:

.github/workflows/mpl-head.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@ jobs:
6767
with:
6868
dafny: ${{needs.getVersion.outputs.version}}
6969
mpl-head: true
70+
mpl-head-ci-rust:
71+
needs: getVersion
72+
uses: ./.github/workflows/library_rust_tests.yml
73+
with:
74+
dafny: ${{needs.getVersion.outputs.version}}
75+
mpl-head: true
7076
mpl-head-ci-net-test-vectors:
7177
needs: getVersion
7278
uses: ./.github/workflows/ci_test_vector_net.yml

.github/workflows/nightly.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,12 @@ jobs:
5252
with:
5353
dafny: "nightly-latest"
5454
regenerate-code: true
55+
dafny-nightly-rust:
56+
if: github.event_name != 'schedule' || github.repository_owner == 'aws'
57+
uses: ./.github/workflows/library_rust_tests.yml
58+
with:
59+
dafny: "nightly-latest"
60+
regenerate-code: true
5561
dafny-nightly-test-vectors-net:
5662
if: github.event_name != 'schedule' || github.repository_owner == 'aws'
5763
uses: ./.github/workflows/ci_test_vector_net.yml

.github/workflows/pull.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ jobs:
4949
uses: ./.github/workflows/ci_test_net.yml
5050
with:
5151
dafny: ${{needs.getVersion.outputs.version}}
52+
pr-ci-rust:
53+
needs: getVersion
54+
uses: ./.github/workflows/library_rust_tests.yml
55+
with:
56+
dafny: ${{needs.getVersion.outputs.version}}
5257
pr-ci-net-test-vectors:
5358
needs: getVersion
5459
uses: ./.github/workflows/ci_test_vector_net.yml

.github/workflows/push.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ jobs:
5151
uses: ./.github/workflows/ci_test_net.yml
5252
with:
5353
dafny: ${{needs.getVersion.outputs.version}}
54+
pr-ci-rust:
55+
needs: getVersion
56+
uses: ./.github/workflows/library_rust_tests.yml
57+
with:
58+
dafny: ${{needs.getVersion.outputs.version}}
5459
pr-ci-net-test-vectors:
5560
needs: getVersion
5661
uses: ./.github/workflows/ci_test_vector_net.yml

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
submodules
2+
target

DynamoDbEncryption/.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ ImplementationFromDafny.cs
33
TestsFromDafny.cs
44
ImplementationFromDafny-cs.dtr
55
TestsFromDafny-cs.dtr
6-
**/bin
76
**/obj
87
node_modules
98
project.properties

DynamoDbEncryption/Makefile

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
CORES=2
55

6+
TRANSPILE_TESTS_IN_RUST=1
7+
68
include ../SharedMakefile.mk
79

810
DIR_STRUCTURE_V2=V2
@@ -13,6 +15,28 @@ PROJECT_SERVICES := \
1315
DynamoDbEncryptionTransforms \
1416
StructuredEncryption
1517

18+
MAIN_SERVICE_FOR_RUST := DynamoDbEncryptionTransforms
19+
20+
RUST_OTHER_FILES := \
21+
runtimes/rust/src/aes_gcm.rs \
22+
runtimes/rust/src/aes_kdf_ctr.rs \
23+
runtimes/rust/src/ddb.rs \
24+
runtimes/rust/src/concurrent_call.rs \
25+
runtimes/rust/src/dafny_libraries.rs \
26+
runtimes/rust/src/digest.rs \
27+
runtimes/rust/src/ecdh.rs \
28+
runtimes/rust/src/ecdsa.rs \
29+
runtimes/rust/src/hmac.rs \
30+
runtimes/rust/src/kms.rs \
31+
runtimes/rust/src/local_cmc.rs \
32+
runtimes/rust/src/random.rs \
33+
runtimes/rust/src/rsa.rs \
34+
runtimes/rust/src/sets.rs \
35+
runtimes/rust/src/software_externs.rs \
36+
runtimes/rust/src/storm_tracker.rs \
37+
runtimes/rust/src/time.rs \
38+
runtimes/rust/src/uuid.rs
39+
1640
# Namespace for each local service
1741
# Currently our build relies on local services and namespaces being 1:1
1842
SERVICE_NAMESPACE_StructuredEncryption=aws.cryptography.dbEncryptionSdk.structuredEncryption
@@ -74,8 +98,3 @@ SERVICE_DEPS_DynamoDbEncryptionTransforms := \
7498
DynamoDbEncryption/dafny/DynamoDbEncryption \
7599
DynamoDbEncryption/dafny/StructuredEncryption \
76100
DynamoDbEncryption/dafny/DynamoDbItemEncryptor
77-
78-
polymorph:
79-
export DAFNY_VERSION=4.2
80-
npm i --no-save prettier@3 [email protected]
81-
make polymorph_code_gen PROJECT_DEPENDENCIES=

0 commit comments

Comments
 (0)