Skip to content

Commit a340b34

Browse files
chore(java): bring back test against released MPL version (#2226)
1 parent 67ed551 commit a340b34

5 files changed

Lines changed: 210 additions & 4 deletions

File tree

Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
# This workflow is for testing that the latest released version
2+
# of the MPL is compatible with the current DB-ESDK Head
3+
name: Test Latest Released MPL Java with DB-ESDK HEAD
4+
5+
on:
6+
workflow_dispatch:
7+
inputs:
8+
dafny:
9+
description: "The Dafny version to run"
10+
required: true
11+
type: string
12+
regenerate-code:
13+
description: "Regenerate code using smithy-dafny"
14+
required: false
15+
default: false
16+
type: boolean
17+
branch:
18+
description: "Branch to checkout"
19+
required: true
20+
type: string
21+
run_test_vectors:
22+
description: "Run Test Vectors?"
23+
required: false
24+
default: true
25+
type: boolean
26+
strip_snapshot:
27+
description: "Strip -SNAPSHOT suffix from mpl Dependency in project properties?"
28+
required: false
29+
default: false
30+
type: boolean
31+
workflow_call:
32+
inputs:
33+
dafny:
34+
description: "The Dafny version to run"
35+
required: true
36+
type: string
37+
regenerate-code:
38+
description: "Regenerate code using smithy-dafny"
39+
required: false
40+
default: false
41+
type: boolean
42+
branch:
43+
description: "Branch to checkout"
44+
required: true
45+
type: string
46+
run_test_vectors:
47+
description: "Run Test Vectors?"
48+
required: false
49+
default: true
50+
type: boolean
51+
strip_snapshot:
52+
description: "Strip -SNAPSHOT suffix from mpl Dependency in project properties?"
53+
required: false
54+
default: false
55+
type: boolean
56+
57+
permissions:
58+
id-token: write
59+
contents: read
60+
61+
jobs:
62+
getMplDependencyJavaVersion:
63+
if: github.repository_owner == 'aws'
64+
uses: ./.github/workflows/mpl_dependency_java_version.yml
65+
with:
66+
strip_snapshot: ${{ inputs.strip_snapshot == true }}
67+
testJava:
68+
needs: [getMplDependencyJavaVersion]
69+
strategy:
70+
matrix:
71+
java-version: [17]
72+
os: [ubuntu-22.04]
73+
runs-on: ${{ matrix.os }}
74+
permissions:
75+
id-token: write
76+
contents: read
77+
steps:
78+
- name: Configure AWS Credentials
79+
uses: aws-actions/configure-aws-credentials@v5
80+
with:
81+
aws-region: us-west-2
82+
role-to-assume: arn:aws:iam::370957321024:role/GitHub-CI-DDBEC-Dafny-Role-us-west-2
83+
role-session-name: DDBEC-Dafny-Java-Tests
84+
85+
- uses: actions/checkout@v6
86+
with:
87+
ref: ${{ inputs.branch }}
88+
submodules: recursive
89+
90+
- name: Setup Java ${{ matrix.java-version }}
91+
uses: actions/setup-java@v5
92+
with:
93+
distribution: "corretto"
94+
java-version: ${{ matrix.java-version }}
95+
96+
- name: Setup Dafny
97+
uses: ./submodules/MaterialProviders/.github/actions/setup_dafny/
98+
with:
99+
dafny-version: ${{ inputs.dafny }}
100+
101+
- name: Install Smithy-Dafny codegen dependencies
102+
uses: ./.github/actions/install_smithy_dafny_codegen_dependencies
103+
104+
- name: Regenerate code using smithy-dafny if necessary
105+
if: ${{ inputs.regenerate-code }}
106+
uses: ./.github/actions/polymorph_codegen
107+
with:
108+
dafny: ${{ inputs.dafny }}
109+
library: DynamoDbEncryption
110+
diff-generated-code: false
111+
update-and-regenerate-mpl: true
112+
113+
- name: Override MPL dependency version
114+
run: |
115+
sed -i "s/mplDependencyJavaVersion=.*/mplDependencyJavaVersion=${{ needs.getMplDependencyJavaVersion.outputs.version }}/" project.properties
116+
117+
# The following two steps: "Build and deploy to maven local" and "Run Extensive Tests"
118+
# mimic the tests in ./codebuild/staging/release-staging.yml
119+
- name: Build and deploy to maven local
120+
shell: bash
121+
working-directory: ./DynamoDbEncryption
122+
run: |
123+
# Run transpile by itself. We don't want to locally build the MPL because
124+
# we want to verify that the version pulled down from maven works correctly
125+
make transpile_implementation_java
126+
make transpile_test_java
127+
make mvn_local_deploy
128+
make test_java
129+
130+
- name: Run Extensive Tests
131+
working-directory: ./DynamoDbEncryption
132+
run: |
133+
gradle -p runtimes/java clean
134+
gradle -p runtimes/java test
135+
136+
- name: Update project.properties to use the correct MPL version (from project.properties in DB-ESDK)
137+
working-directory: ./submodules/MaterialProviders/
138+
run: |
139+
sed "s/javaMPLVersion=.*/javaMPLVersion=${{needs.getMplDependencyJavaVersion.outputs.version}}/g" project.properties > project.properties2; mv project.properties2 project.properties
140+
141+
# The following three steps: "Transpile MPL Test Vectors without recursively building the MPL",
142+
# "Run Test Vectors", and "Test Examples" mimic the tests in ./codebuild/staging/validate-staging.yml
143+
- name: Transpile MPL Test Vectors without recursively building the MPL
144+
working-directory: ./submodules/MaterialProviders/TestVectorsAwsCryptographicMaterialProviders
145+
run: |
146+
# Run transpile by itself. We don't want to locally build the MPL because
147+
# we want to verify that the version pulled down from maven works correctly
148+
make transpile_implementation_java
149+
make transpile_test_java
150+
make mvn_local_deploy
151+
152+
- name: Run Test Vectors
153+
if: inputs.run_test_vectors
154+
working-directory: ./TestVectors
155+
run: |
156+
# Spin up ddb local
157+
docker run --name dynamodb -d -p 8000:8000 amazon/dynamodb-local -jar DynamoDBLocal.jar -port 8000 -inMemory -cors *
158+
# Run transpile by itself so we don't locally build the MPL.
159+
make transpile_implementation_java
160+
make transpile_test_java
161+
gradle -p runtimes/java runTests
162+
163+
- name: Test Examples
164+
working-directory: ./Examples
165+
run: |
166+
gradle -p runtimes/java/DynamoDbEncryption test
167+
if [[ "${{ inputs.branch }}" == "v3.x-Java" ]]; then
168+
gradle -p runtimes/java/Migration/PlaintextToAWSDBE test
169+
gradle -p runtimes/java/Migration/DDBECToAWSDBE test
170+
else
171+
gradle -p runtimes/java/DDBECwithSDKV2 test
172+
gradle -p runtimes/java/Migration/PlaintextToAWSDBE test
173+
gradle -p runtimes/java/Migration/DDBECv2ToAWSDBE test
174+
fi

.github/workflows/daily_ci.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,21 @@ jobs:
182182
with:
183183
dafny: ${{needs.getVersion.outputs.version}}
184184
branch: ${{ matrix.branch }}
185+
daily-test-with-released-mpl:
186+
permissions:
187+
id-token: write
188+
contents: read
189+
needs: getVersion
190+
strategy:
191+
matrix:
192+
branch: [main, v3.x-Java]
193+
uses: ./.github/workflows/ci_test_latest_released_mpl_java.yml
194+
with:
195+
dafny: ${{needs.getVersion.outputs.version}}
196+
branch: ${{ matrix.branch }}
197+
run_test_vectors: true
198+
strip_snapshot: true
199+
185200
notify:
186201
permissions:
187202
contents: read
@@ -202,6 +217,7 @@ jobs:
202217
daily-ci-rust,
203218
daily-ci-net-test-vectors,
204219
daily-ci-net-examples,
220+
daily-test-with-released-mpl,
205221
]
206222
if: ${{ failure() && github.event_name == 'schedule'}}
207223
uses: aws/aws-cryptographic-material-providers-library/.github/workflows/slack-notification.yml@main

.github/workflows/mpl_dependency_java_version.yml

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ name: MPL Dependency Java Version
55

66
on:
77
workflow_call:
8+
inputs:
9+
strip_snapshot:
10+
description: "Strip -SNAPSHOT suffix from version"
11+
required: false
12+
default: false
13+
type: boolean
814
outputs:
915
version:
1016
description: "The MPL Dependency Java version from project.properties"
@@ -14,11 +20,10 @@ jobs:
1420
getMplDependencyJavaVersion:
1521
permissions:
1622
contents: read
17-
pull-requests: write
1823
id-token: write
1924
runs-on: ubuntu-22.04
2025
outputs:
21-
version: ${{ steps.read_property.outputs.mplDependencyJavaVersion }}
26+
version: ${{ steps.resolve_version.outputs.version }}
2227
steps:
2328
- uses: actions/checkout@v6
2429
- name: Read version from Properties-file
@@ -27,3 +32,14 @@ jobs:
2732
with:
2833
path: "./project.properties"
2934
properties: "mplDependencyJavaVersion"
35+
- name: Resolve version
36+
id: resolve_version
37+
env:
38+
RAW_VERSION: ${{ steps.read_property.outputs.mplDependencyJavaVersion }}
39+
STRIP: ${{ inputs.strip_snapshot }}
40+
run: |
41+
VERSION="$RAW_VERSION"
42+
if [ "$STRIP" == "true" ]; then
43+
VERSION="${VERSION%-SNAPSHOT}"
44+
fi
45+
echo "version=$VERSION" >> "$GITHUB_OUTPUT"

project.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
projectJavaVersion=3.9.1-SNAPSHOT
2-
mplDependencyJavaVersion=1.11.2-SNAPSHOT
2+
mplDependencyJavaVersion=1.11.1-SNAPSHOT
33
mplDependencyNetVersion=2.0.0
44
dafnyVersion=4.9.0
55
dafnyVerifyVersion=4.9.1

submodules/MaterialProviders

0 commit comments

Comments
 (0)