diff --git a/.github/workflows/self-test-and-release.yml b/.github/workflows/self-test-and-release.yml index 1a1b12c..b1b810d 100644 --- a/.github/workflows/self-test-and-release.yml +++ b/.github/workflows/self-test-and-release.yml @@ -8,7 +8,63 @@ 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-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 + 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 + env: + 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; } + + - 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 +92,7 @@ jobs: uses: actions/checkout@master with: repository: aws-samples/amazon-codeguru-samples + ref: "dd32c6cc40401688e35c5b1ec6800aa0f75f8e77" path: ./amazon-codeguru-samples - name: Build Test Project @@ -53,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() @@ -71,7 +129,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