From e8a9f2537dcc87daa672f84a578f1ac3f1e84f49 Mon Sep 17 00:00:00 2001 From: rishav-karanjit Date: Thu, 25 Jul 2024 13:20:22 -0700 Subject: [PATCH 1/8] chore(CI): add smithy diff checker gha --- .github/workflows/smithy-diff.yml | 37 +++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 .github/workflows/smithy-diff.yml diff --git a/.github/workflows/smithy-diff.yml b/.github/workflows/smithy-diff.yml new file mode 100644 index 000000000..d94db78e9 --- /dev/null +++ b/.github/workflows/smithy-diff.yml @@ -0,0 +1,37 @@ +# This workflow checks if specfic files were modified, +# if they were they require more than one approval from CODEOWNERS +name: Check Smithy Files + +on: + pull_request: + +jobs: + require-approvals: + runs-on: ubuntu-latest + permissions: + issues: write + pull-requests: write + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Get Files changed + id: file-changes + shell: bash + run: + # Checks to see if any of the customer facing Models are being updated. + # Doing this check allows us to catch things like, missing @javadoc trait documentation. + echo "FILES=$(git diff --name-only origin/main origin/${GITHUB_HEAD_REF} AwsCryptographicMaterialProviders/dafny/**/Model/*.smithy | tr '\n' ' ')" >> "$GITHUB_OUTPUT" + + - name: Check if FILES is not empty + id: comment + env: + PR_NUMBER: ${{ github.event.number }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + FILES: ${{ steps.file-changes.outputs.FILES }} + if: ${{env.FILES != ''}} + run: | + COMMENT="@${{github.actor}}, I noticed you are updating the smithy model files.\nDoes this update need new or updated javadoc trait documentation?\n Are you adding constraints inside list, map or union? Do you know about this issue: https://github.com/smithy-lang/smithy-dafny/issues/491?" + COMMENT_URL="https://api.github.com/repos/${{ github.repository }}/issues/${PR_NUMBER}/comments" + curl -s -H "Authorization: token ${GITHUB_TOKEN}" -X POST $COMMENT_URL -d "{\"body\":\"$COMMENT\"}" \ No newline at end of file From fcc3442cb91915a4ccfdd6f8f32211da65c53fa0 Mon Sep 17 00:00:00 2001 From: rishav-karanjit Date: Thu, 25 Jul 2024 13:22:35 -0700 Subject: [PATCH 2/8] Test by changing a smithy file --- .../dafny/DynamoDbEncryption/Model/DynamoDbEncryption.smithy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DynamoDbEncryption/dafny/DynamoDbEncryption/Model/DynamoDbEncryption.smithy b/DynamoDbEncryption/dafny/DynamoDbEncryption/Model/DynamoDbEncryption.smithy index b4fa422a0..06da8499b 100644 --- a/DynamoDbEncryption/dafny/DynamoDbEncryption/Model/DynamoDbEncryption.smithy +++ b/DynamoDbEncryption/dafny/DynamoDbEncryption/Model/DynamoDbEncryption.smithy @@ -190,7 +190,7 @@ structure DynamoDbTableEncryptionConfig { allowedUnsignedAttributes: AttributeNameList, @javadoc("A prefix such that, if during decryption any attribute has a name with this prefix, it is treated as unsigned.") allowedUnsignedAttributePrefix: String, - //= specification/dynamodb-encryption-client/ddb-table-encryption-config.md#algorithm-suite + //= specification/dynamodb-encryption-client/ddb-table-encryption-config.md#algorithm-suit //= type=implication //# This algorithm suite MUST be a [Structured Encryption Library Supported algorithm suite](../../submodules/MaterialProviders/aws-encryption-sdk-specification/framework/algorithm-suites.md). @javadoc("An ID for the algorithm suite to use during encryption and decryption.") From e3fc294d537765edd9ddc7b994179bca55953570 Mon Sep 17 00:00:00 2001 From: rishav-karanjit Date: Thu, 25 Jul 2024 13:26:18 -0700 Subject: [PATCH 3/8] Fix dir name --- .github/workflows/smithy-diff.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/smithy-diff.yml b/.github/workflows/smithy-diff.yml index d94db78e9..16d71b214 100644 --- a/.github/workflows/smithy-diff.yml +++ b/.github/workflows/smithy-diff.yml @@ -22,7 +22,7 @@ jobs: run: # Checks to see if any of the customer facing Models are being updated. # Doing this check allows us to catch things like, missing @javadoc trait documentation. - echo "FILES=$(git diff --name-only origin/main origin/${GITHUB_HEAD_REF} AwsCryptographicMaterialProviders/dafny/**/Model/*.smithy | tr '\n' ' ')" >> "$GITHUB_OUTPUT" + echo "FILES=$(git diff --name-only origin/main origin/${GITHUB_HEAD_REF} DynamoDbEncryption/dafny/**/Model/*.smithy | tr '\n' ' ')" >> "$GITHUB_OUTPUT" - name: Check if FILES is not empty id: comment From d899c2f23a683713d41be775a12b42e090864c06 Mon Sep 17 00:00:00 2001 From: rishav-karanjit Date: Thu, 25 Jul 2024 13:27:05 -0700 Subject: [PATCH 4/8] Revert "Test by changing a smithy file" This reverts commit fcc3442cb91915a4ccfdd6f8f32211da65c53fa0. --- .../dafny/DynamoDbEncryption/Model/DynamoDbEncryption.smithy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DynamoDbEncryption/dafny/DynamoDbEncryption/Model/DynamoDbEncryption.smithy b/DynamoDbEncryption/dafny/DynamoDbEncryption/Model/DynamoDbEncryption.smithy index 06da8499b..b4fa422a0 100644 --- a/DynamoDbEncryption/dafny/DynamoDbEncryption/Model/DynamoDbEncryption.smithy +++ b/DynamoDbEncryption/dafny/DynamoDbEncryption/Model/DynamoDbEncryption.smithy @@ -190,7 +190,7 @@ structure DynamoDbTableEncryptionConfig { allowedUnsignedAttributes: AttributeNameList, @javadoc("A prefix such that, if during decryption any attribute has a name with this prefix, it is treated as unsigned.") allowedUnsignedAttributePrefix: String, - //= specification/dynamodb-encryption-client/ddb-table-encryption-config.md#algorithm-suit + //= specification/dynamodb-encryption-client/ddb-table-encryption-config.md#algorithm-suite //= type=implication //# This algorithm suite MUST be a [Structured Encryption Library Supported algorithm suite](../../submodules/MaterialProviders/aws-encryption-sdk-specification/framework/algorithm-suites.md). @javadoc("An ID for the algorithm suite to use during encryption and decryption.") From 53dfc2ce9e4b29974bb6a310be8fe7749078502a Mon Sep 17 00:00:00 2001 From: rishav-karanjit Date: Thu, 25 Jul 2024 13:52:53 -0700 Subject: [PATCH 5/8] Format --- .github/workflows/smithy-diff.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/smithy-diff.yml b/.github/workflows/smithy-diff.yml index 16d71b214..d419b863c 100644 --- a/.github/workflows/smithy-diff.yml +++ b/.github/workflows/smithy-diff.yml @@ -34,4 +34,4 @@ jobs: run: | COMMENT="@${{github.actor}}, I noticed you are updating the smithy model files.\nDoes this update need new or updated javadoc trait documentation?\n Are you adding constraints inside list, map or union? Do you know about this issue: https://github.com/smithy-lang/smithy-dafny/issues/491?" COMMENT_URL="https://api.github.com/repos/${{ github.repository }}/issues/${PR_NUMBER}/comments" - curl -s -H "Authorization: token ${GITHUB_TOKEN}" -X POST $COMMENT_URL -d "{\"body\":\"$COMMENT\"}" \ No newline at end of file + curl -s -H "Authorization: token ${GITHUB_TOKEN}" -X POST $COMMENT_URL -d "{\"body\":\"$COMMENT\"}" From 214e96251850bd6ee33916eafae0cf1f2f34f5c4 Mon Sep 17 00:00:00 2001 From: rishav-karanjit Date: Mon, 29 Jul 2024 17:20:51 -0700 Subject: [PATCH 6/8] changes smithy-diff like mpl --- .github/workflows/smithy-diff.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/smithy-diff.yml b/.github/workflows/smithy-diff.yml index d419b863c..98d7ffda6 100644 --- a/.github/workflows/smithy-diff.yml +++ b/.github/workflows/smithy-diff.yml @@ -21,8 +21,8 @@ jobs: shell: bash run: # Checks to see if any of the customer facing Models are being updated. - # Doing this check allows us to catch things like, missing @javadoc trait documentation. - echo "FILES=$(git diff --name-only origin/main origin/${GITHUB_HEAD_REF} DynamoDbEncryption/dafny/**/Model/*.smithy | tr '\n' ' ')" >> "$GITHUB_OUTPUT" + # Doing this check allows us to catch things like, missing @javadoc trait documentation or bug in smithy dafny that has not be resolved. + echo "FILES=$(git diff --name-only origin/main origin/${GITHUB_HEAD_REF} | grep '\.smithy$' | tr '\n' ' ')" >> "$GITHUB_OUTPUT" - name: Check if FILES is not empty id: comment @@ -32,6 +32,7 @@ jobs: FILES: ${{ steps.file-changes.outputs.FILES }} if: ${{env.FILES != ''}} run: | + # TODO: If https://github.com/smithy-lang/smithy-dafny/issues/491 is resolved, remove comment about this issue. COMMENT="@${{github.actor}}, I noticed you are updating the smithy model files.\nDoes this update need new or updated javadoc trait documentation?\n Are you adding constraints inside list, map or union? Do you know about this issue: https://github.com/smithy-lang/smithy-dafny/issues/491?" COMMENT_URL="https://api.github.com/repos/${{ github.repository }}/issues/${PR_NUMBER}/comments" - curl -s -H "Authorization: token ${GITHUB_TOKEN}" -X POST $COMMENT_URL -d "{\"body\":\"$COMMENT\"}" + curl -s -H "Authorization: token ${GITHUB_TOKEN}" -X POST $COMMENT_URL -d "{\"body\":\"$COMMENT\"}" \ No newline at end of file From 4f28a36914a8212853da76ab220c7fc31b11cb70 Mon Sep 17 00:00:00 2001 From: rishav-karanjit Date: Mon, 29 Jul 2024 17:29:07 -0700 Subject: [PATCH 7/8] format --- .github/workflows/smithy-diff.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/smithy-diff.yml b/.github/workflows/smithy-diff.yml index 98d7ffda6..a666e78cc 100644 --- a/.github/workflows/smithy-diff.yml +++ b/.github/workflows/smithy-diff.yml @@ -35,4 +35,4 @@ jobs: # TODO: If https://github.com/smithy-lang/smithy-dafny/issues/491 is resolved, remove comment about this issue. COMMENT="@${{github.actor}}, I noticed you are updating the smithy model files.\nDoes this update need new or updated javadoc trait documentation?\n Are you adding constraints inside list, map or union? Do you know about this issue: https://github.com/smithy-lang/smithy-dafny/issues/491?" COMMENT_URL="https://api.github.com/repos/${{ github.repository }}/issues/${PR_NUMBER}/comments" - curl -s -H "Authorization: token ${GITHUB_TOKEN}" -X POST $COMMENT_URL -d "{\"body\":\"$COMMENT\"}" \ No newline at end of file + curl -s -H "Authorization: token ${GITHUB_TOKEN}" -X POST $COMMENT_URL -d "{\"body\":\"$COMMENT\"}" From dd36b7370c66029ea8d7c9bc82681e149df8f6ae Mon Sep 17 00:00:00 2001 From: rishav-karanjit Date: Tue, 30 Jul 2024 09:01:09 -0700 Subject: [PATCH 8/8] update comment --- .github/workflows/smithy-diff.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/smithy-diff.yml b/.github/workflows/smithy-diff.yml index a666e78cc..b874861c1 100644 --- a/.github/workflows/smithy-diff.yml +++ b/.github/workflows/smithy-diff.yml @@ -20,7 +20,7 @@ jobs: id: file-changes shell: bash run: - # Checks to see if any of the customer facing Models are being updated. + # Checks to see if any of the smithy Models are being updated. # Doing this check allows us to catch things like, missing @javadoc trait documentation or bug in smithy dafny that has not be resolved. echo "FILES=$(git diff --name-only origin/main origin/${GITHUB_HEAD_REF} | grep '\.smithy$' | tr '\n' ' ')" >> "$GITHUB_OUTPUT"