From c332c8256dd32bc26d08e0b2fa186bf639b105c5 Mon Sep 17 00:00:00 2001 From: Martin Schaef Date: Wed, 6 Apr 2022 12:31:00 +0200 Subject: [PATCH 1/7] additional test to run on python diff --- .github/workflows/self-test-and-release.yml | 68 ++++++++++++++++++++- 1 file changed, 66 insertions(+), 2 deletions(-) diff --git a/.github/workflows/self-test-and-release.yml b/.github/workflows/self-test-and-release.yml index 1a1b12c..e98fc96 100644 --- a/.github/workflows/self-test-and-release.yml +++ b/.github/workflows/self-test-and-release.yml @@ -8,7 +8,68 @@ permissions: contents: read jobs: - SelfTest: + SelfTestPython: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, windows-latest] + name: Self Test on ${{ matrix.os }} + steps: + - uses: actions/checkout@v2 + - name: Set up JDK 1.8 + uses: actions/setup-java@v1 + with: + java-version: 1.8 + - name: Build project + run: ./gradlew clean installDist distZip + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v1 + continue-on-error: true + id: iam-role + with: + role-to-assume: arn:aws:iam::048169001733:role/GuruGitHubCICDRole + aws-region: us-west-2 + + - name: Checkout Test Data + if: steps.iam-role.outcome == 'success' + uses: actions/checkout@master + with: + repository: aws-samples/amazon-codeguru-samples + ref: "a574f23f6ea3fe607a6d33cc6c8fe28d81ab37a2" + path: ./python-code + + - name: Build Test Project + if: steps.iam-role.outcome == 'success' + run: | + cd amazon-codeguru-samples + ./gradlew + cd .. + + - name: Run Code Guru + if: steps.iam-role.outcome == 'success' + run: | + ./build/install/aws-codeguru-cli/bin/aws-codeguru-cli --region us-west-2 -r python-code --no-prompt -c "c5f9c93d5605bfe3a4de02896a26b7b91eb7c007:a574f23f6ea3fe607a6d33cc6c8fe28d81ab37a2" + + - name: Validate Findings Linux + if: steps.iam-role.outcome == 'success' + shell: bash + run: | + cat code-guru/recommendations.json + [[ $(grep "filePath" code-guru/recommendations.json | wc -l) -eq 12 ]] || { echo >&2 "Expected 12 recommendations."; exit 1; } + + - name: Create file status_${{ matrix.os }}.txt and write the job status into it + if: always() + run: | + echo ${{ job.status }} > status_${{ matrix.os }}.txt + - name: Upload file status_${{ matrix.os }}.txt as an artifact + if: always() + uses: actions/upload-artifact@v1 + with: + name: pass_status_${{ matrix.os }} + path: status_${{ matrix.os }}.txt + + SelfTestJava: runs-on: ${{ matrix.os }} strategy: matrix: @@ -36,6 +97,7 @@ jobs: uses: actions/checkout@master with: repository: aws-samples/amazon-codeguru-samples + ref: "dd32c6cc40401688e35c5b1ec6800aa0f75f8e77" path: ./amazon-codeguru-samples - name: Build Test Project @@ -71,7 +133,9 @@ jobs: PublishVersion: name: Publish Release runs-on: ubuntu-latest - needs: SelfTest + needs: + - SelfTestJava + - SelfTestPython steps: - name: Download artifact pass_status_ubuntu-latest uses: actions/download-artifact@v1 From b5277779fbe594e28cb21c7acf31156b1bebf315 Mon Sep 17 00:00:00 2001 From: Martin Schaef Date: Wed, 6 Apr 2022 12:35:37 +0200 Subject: [PATCH 2/7] fix remote name --- .github/workflows/self-test-and-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/self-test-and-release.yml b/.github/workflows/self-test-and-release.yml index e98fc96..efa808a 100644 --- a/.github/workflows/self-test-and-release.yml +++ b/.github/workflows/self-test-and-release.yml @@ -35,7 +35,7 @@ jobs: if: steps.iam-role.outcome == 'success' uses: actions/checkout@master with: - repository: aws-samples/amazon-codeguru-samples + repository: aws-samples/amazon-codeguru-reviewer-python-detectors ref: "a574f23f6ea3fe607a6d33cc6c8fe28d81ab37a2" path: ./python-code From ef70b42c339b621f3d39f5b897612cc1b4125414 Mon Sep 17 00:00:00 2001 From: Martin Schaef Date: Wed, 6 Apr 2022 12:45:28 +0200 Subject: [PATCH 3/7] fix yaml --- .github/workflows/self-test-and-release.yml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/.github/workflows/self-test-and-release.yml b/.github/workflows/self-test-and-release.yml index efa808a..195a0b4 100644 --- a/.github/workflows/self-test-and-release.yml +++ b/.github/workflows/self-test-and-release.yml @@ -39,13 +39,6 @@ jobs: ref: "a574f23f6ea3fe607a6d33cc6c8fe28d81ab37a2" path: ./python-code - - name: Build Test Project - if: steps.iam-role.outcome == 'success' - run: | - cd amazon-codeguru-samples - ./gradlew - cd .. - - name: Run Code Guru if: steps.iam-role.outcome == 'success' run: | From b686cbf4b8e65a07867bac5dfe9cdf70571a010c Mon Sep 17 00:00:00 2001 From: Martin Schaef Date: Wed, 6 Apr 2022 12:53:35 +0200 Subject: [PATCH 4/7] fix yaml --- .github/workflows/self-test-and-release.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/self-test-and-release.yml b/.github/workflows/self-test-and-release.yml index 195a0b4..77669de 100644 --- a/.github/workflows/self-test-and-release.yml +++ b/.github/workflows/self-test-and-release.yml @@ -37,6 +37,7 @@ jobs: with: repository: aws-samples/amazon-codeguru-reviewer-python-detectors ref: "a574f23f6ea3fe607a6d33cc6c8fe28d81ab37a2" + fetch-depth: 0 # because we want the history so we can check the diff. path: ./python-code - name: Run Code Guru From 742a21f62609cf6f85926225ecc9d30822d18070 Mon Sep 17 00:00:00 2001 From: Martin Schaef Date: Wed, 6 Apr 2022 13:03:53 +0200 Subject: [PATCH 5/7] fix yaml --- .github/workflows/self-test-and-release.yml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/.github/workflows/self-test-and-release.yml b/.github/workflows/self-test-and-release.yml index 77669de..9a88cd0 100644 --- a/.github/workflows/self-test-and-release.yml +++ b/.github/workflows/self-test-and-release.yml @@ -48,9 +48,10 @@ jobs: - name: Validate Findings Linux if: steps.iam-role.outcome == 'success' shell: bash + env: + EXPECTED=15 run: | - cat code-guru/recommendations.json - [[ $(grep "filePath" code-guru/recommendations.json | wc -l) -eq 12 ]] || { echo >&2 "Expected 12 recommendations."; exit 1; } + [[ $(grep "filePath" code-guru/recommendations.json | wc -l) -eq $EXPECTED ]] || { echo "Expected $EXPECTED recommendations. but got $(grep "filePath" code-guru/recommendations.json | wc -l)."; exit 1; } - name: Create file status_${{ matrix.os }}.txt and write the job status into it if: always() @@ -109,9 +110,10 @@ jobs: - name: Validate Findings Linux if: steps.iam-role.outcome == 'success' shell: bash - run: | - cat code-guru/recommendations.json - [[ $(grep "filePath" code-guru/recommendations.json | wc -l) -eq 12 ]] || { echo >&2 "Expected 12 recommendations."; exit 1; } + env: + EXPECTED=12 + run: | + [[ $(grep "filePath" code-guru/recommendations.json | wc -l) -eq $EXPECTED ]] || { echo "Expected $EXPECTED recommendations but got $(grep "filePath" code-guru/recommendations.json | wc -l)."; exit 1; } - name: Create file status_${{ matrix.os }}.txt and write the job status into it if: always() From 1b6d8230f8c9edf86ae9d94eb38923b21aebefc3 Mon Sep 17 00:00:00 2001 From: Martin Schaef Date: Wed, 6 Apr 2022 13:07:24 +0200 Subject: [PATCH 6/7] fix yaml --- .github/workflows/self-test-and-release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/self-test-and-release.yml b/.github/workflows/self-test-and-release.yml index 9a88cd0..72230f3 100644 --- a/.github/workflows/self-test-and-release.yml +++ b/.github/workflows/self-test-and-release.yml @@ -49,7 +49,7 @@ jobs: if: steps.iam-role.outcome == 'success' shell: bash env: - EXPECTED=15 + EXPECTED: 15 run: | [[ $(grep "filePath" code-guru/recommendations.json | wc -l) -eq $EXPECTED ]] || { echo "Expected $EXPECTED recommendations. but got $(grep "filePath" code-guru/recommendations.json | wc -l)."; exit 1; } @@ -111,7 +111,7 @@ jobs: if: steps.iam-role.outcome == 'success' shell: bash env: - EXPECTED=12 + EXPECTED: 12 run: | [[ $(grep "filePath" code-guru/recommendations.json | wc -l) -eq $EXPECTED ]] || { echo "Expected $EXPECTED recommendations but got $(grep "filePath" code-guru/recommendations.json | wc -l)."; exit 1; } From b09ec5a62b59e2540c23932049158a3050e89d48 Mon Sep 17 00:00:00 2001 From: Martin Schaef Date: Wed, 6 Apr 2022 13:17:21 +0200 Subject: [PATCH 7/7] adjust oracle --- .github/workflows/self-test-and-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/self-test-and-release.yml b/.github/workflows/self-test-and-release.yml index 72230f3..b1b810d 100644 --- a/.github/workflows/self-test-and-release.yml +++ b/.github/workflows/self-test-and-release.yml @@ -49,7 +49,7 @@ jobs: if: steps.iam-role.outcome == 'success' shell: bash env: - EXPECTED: 15 + EXPECTED: 95 run: | [[ $(grep "filePath" code-guru/recommendations.json | wc -l) -eq $EXPECTED ]] || { echo "Expected $EXPECTED recommendations. but got $(grep "filePath" code-guru/recommendations.json | wc -l)."; exit 1; }