|
| 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 |
0 commit comments