diff --git a/.github/workflows/ci_test_latest_released_mpl_java.yml b/.github/workflows/ci_test_latest_released_mpl_java.yml new file mode 100644 index 0000000000..398c3f136b --- /dev/null +++ b/.github/workflows/ci_test_latest_released_mpl_java.yml @@ -0,0 +1,174 @@ +# This workflow is for testing that the latest released version +# of the MPL is compatible with the current DB-ESDK Head +name: Test Latest Released MPL Java with DB-ESDK HEAD + +on: + workflow_dispatch: + 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 + branch: + description: "Branch to checkout" + required: true + type: string + run_test_vectors: + description: "Run Test Vectors?" + required: false + default: true + type: boolean + strip_snapshot: + description: "Strip -SNAPSHOT suffix from mpl Dependency in project properties?" + required: false + default: false + type: boolean + 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 + branch: + description: "Branch to checkout" + required: true + type: string + run_test_vectors: + description: "Run Test Vectors?" + required: false + default: true + type: boolean + strip_snapshot: + description: "Strip -SNAPSHOT suffix from mpl Dependency in project properties?" + required: false + default: false + type: boolean + +permissions: + id-token: write + contents: read + +jobs: + getMplDependencyJavaVersion: + if: github.repository_owner == 'aws' + uses: ./.github/workflows/mpl_dependency_java_version.yml + with: + strip_snapshot: ${{ inputs.strip_snapshot == true }} + testJava: + needs: [getMplDependencyJavaVersion] + strategy: + matrix: + java-version: [17] + os: [ubuntu-22.04] + runs-on: ${{ matrix.os }} + permissions: + id-token: write + contents: read + steps: + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v5 + 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-Java-Tests + + - uses: actions/checkout@v6 + with: + ref: ${{ inputs.branch }} + submodules: recursive + + - name: Setup Java ${{ matrix.java-version }} + uses: actions/setup-java@v5 + with: + distribution: "corretto" + java-version: ${{ matrix.java-version }} + + - name: Setup Dafny + uses: ./submodules/MaterialProviders/.github/actions/setup_dafny/ + with: + dafny-version: ${{ inputs.dafny }} + + - 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: ${{ inputs.dafny }} + library: DynamoDbEncryption + diff-generated-code: false + update-and-regenerate-mpl: true + + - name: Override MPL dependency version + run: | + sed -i "s/mplDependencyJavaVersion=.*/mplDependencyJavaVersion=${{ needs.getMplDependencyJavaVersion.outputs.version }}/" project.properties + + # The following two steps: "Build and deploy to maven local" and "Run Extensive Tests" + # mimic the tests in ./codebuild/staging/release-staging.yml + - name: Build and deploy to maven local + shell: bash + working-directory: ./DynamoDbEncryption + run: | + # Run transpile by itself. We don't want to locally build the MPL because + # we want to verify that the version pulled down from maven works correctly + make transpile_implementation_java + make transpile_test_java + make mvn_local_deploy + make test_java + + - name: Run Extensive Tests + working-directory: ./DynamoDbEncryption + run: | + gradle -p runtimes/java clean + gradle -p runtimes/java test + + - name: Update project.properties to use the correct MPL version (from project.properties in DB-ESDK) + working-directory: ./submodules/MaterialProviders/ + run: | + sed "s/javaMPLVersion=.*/javaMPLVersion=${{needs.getMplDependencyJavaVersion.outputs.version}}/g" project.properties > project.properties2; mv project.properties2 project.properties + + # The following three steps: "Transpile MPL Test Vectors without recursively building the MPL", + # "Run Test Vectors", and "Test Examples" mimic the tests in ./codebuild/staging/validate-staging.yml + - name: Transpile MPL Test Vectors without recursively building the MPL + working-directory: ./submodules/MaterialProviders/TestVectorsAwsCryptographicMaterialProviders + run: | + # Run transpile by itself. We don't want to locally build the MPL because + # we want to verify that the version pulled down from maven works correctly + make transpile_implementation_java + make transpile_test_java + make mvn_local_deploy + + - name: Run Test Vectors + if: inputs.run_test_vectors + working-directory: ./TestVectors + run: | + # Spin up ddb local + docker run --name dynamodb -d -p 8000:8000 amazon/dynamodb-local -jar DynamoDBLocal.jar -port 8000 -inMemory -cors * + # Run transpile by itself so we don't locally build the MPL. + make transpile_implementation_java + make transpile_test_java + gradle -p runtimes/java runTests + + - name: Test Examples + working-directory: ./Examples + run: | + gradle -p runtimes/java/DynamoDbEncryption test + if [[ "${{ inputs.branch }}" == "v3.x-Java" ]]; then + gradle -p runtimes/java/Migration/PlaintextToAWSDBE test + gradle -p runtimes/java/Migration/DDBECToAWSDBE test + else + gradle -p runtimes/java/DDBECwithSDKV2 test + gradle -p runtimes/java/Migration/PlaintextToAWSDBE test + gradle -p runtimes/java/Migration/DDBECv2ToAWSDBE test + fi diff --git a/.github/workflows/daily_ci.yml b/.github/workflows/daily_ci.yml index ebb074465e..909a7507ea 100644 --- a/.github/workflows/daily_ci.yml +++ b/.github/workflows/daily_ci.yml @@ -182,6 +182,21 @@ jobs: with: dafny: ${{needs.getVersion.outputs.version}} branch: ${{ matrix.branch }} + daily-test-with-released-mpl: + permissions: + id-token: write + contents: read + needs: getVersion + strategy: + matrix: + branch: [main, v3.x-Java] + uses: ./.github/workflows/ci_test_latest_released_mpl_java.yml + with: + dafny: ${{needs.getVersion.outputs.version}} + branch: ${{ matrix.branch }} + run_test_vectors: true + strip_snapshot: true + notify: permissions: contents: read @@ -202,6 +217,7 @@ jobs: daily-ci-rust, daily-ci-net-test-vectors, daily-ci-net-examples, + daily-test-with-released-mpl, ] if: ${{ failure() && github.event_name == 'schedule'}} uses: aws/aws-cryptographic-material-providers-library/.github/workflows/slack-notification.yml@main diff --git a/.github/workflows/mpl_dependency_java_version.yml b/.github/workflows/mpl_dependency_java_version.yml index da41e7de9b..a0bedb64a2 100644 --- a/.github/workflows/mpl_dependency_java_version.yml +++ b/.github/workflows/mpl_dependency_java_version.yml @@ -5,6 +5,12 @@ name: MPL Dependency Java Version on: workflow_call: + inputs: + strip_snapshot: + description: "Strip -SNAPSHOT suffix from version" + required: false + default: false + type: boolean outputs: version: description: "The MPL Dependency Java version from project.properties" @@ -14,11 +20,10 @@ jobs: getMplDependencyJavaVersion: permissions: contents: read - pull-requests: write id-token: write runs-on: ubuntu-22.04 outputs: - version: ${{ steps.read_property.outputs.mplDependencyJavaVersion }} + version: ${{ steps.resolve_version.outputs.version }} steps: - uses: actions/checkout@v6 - name: Read version from Properties-file @@ -27,3 +32,14 @@ jobs: with: path: "./project.properties" properties: "mplDependencyJavaVersion" + - name: Resolve version + id: resolve_version + env: + RAW_VERSION: ${{ steps.read_property.outputs.mplDependencyJavaVersion }} + STRIP: ${{ inputs.strip_snapshot }} + run: | + VERSION="$RAW_VERSION" + if [ "$STRIP" == "true" ]; then + VERSION="${VERSION%-SNAPSHOT}" + fi + echo "version=$VERSION" >> "$GITHUB_OUTPUT" diff --git a/project.properties b/project.properties index 5e471a9ddd..15fac712e1 100644 --- a/project.properties +++ b/project.properties @@ -1,5 +1,5 @@ projectJavaVersion=3.9.1-SNAPSHOT -mplDependencyJavaVersion=1.11.2-SNAPSHOT +mplDependencyJavaVersion=1.11.1-SNAPSHOT mplDependencyNetVersion=2.0.0 dafnyVersion=4.9.0 dafnyVerifyVersion=4.9.1 diff --git a/submodules/MaterialProviders b/submodules/MaterialProviders index c57f0471be..a4edcd94f8 160000 --- a/submodules/MaterialProviders +++ b/submodules/MaterialProviders @@ -1 +1 @@ -Subproject commit c57f0471be1837a528bfbfdc6aeda59375a63d21 +Subproject commit a4edcd94f8e51c271fa415b0c4d0b152e97c35f7