From dd256f0a0e625c08b4fb9a243527c2d56a28e4fe Mon Sep 17 00:00:00 2001 From: Marco Date: Thu, 5 Oct 2023 22:51:12 -0400 Subject: [PATCH 01/10] Missing update on action.yml --- action.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/action.yml b/action.yml index 8a620ac..f580e13 100644 --- a/action.yml +++ b/action.yml @@ -102,6 +102,7 @@ runs: echo "running dotnet tests and code coverage....." dotnet tool update -g dotnet-coverage export PATH=$PATH:$HOME/.dotnet/tools + . ~/.bashrc dotnet-coverage collect 'dotnet test --logger "trx;LogFileName=test-results.trx" --configuration Release --verbosity minimal --collect "Code Coverage" --filter TestCategory!="Smoke" --settings:test/local.runsettings' -f xml -o 'coverage.xml' shell: bash From 19f163a7081002067ea6a7ce817053eb6ea2bc74 Mon Sep 17 00:00:00 2001 From: Marco Date: Fri, 6 Oct 2023 14:11:39 -0400 Subject: [PATCH 02/10] DVO-4340 update action --- action.yml | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/action.yml b/action.yml index f580e13..c610cb6 100644 --- a/action.yml +++ b/action.yml @@ -2,8 +2,8 @@ name: 'Project Validation' description: 'Run Sonar and Tests to Validate Quality' inputs: - sonar-project-name: - description: 'Project name in Sonar' + github-repo-name: + description: 'GitHub repo name' required: true default: '' sonar-tool-version: @@ -13,7 +13,7 @@ inputs: use-dependencies: description: 'Use Docker to run dependencies.' required: false - default: 'false' + default: false docker-compose-file-path: description: 'Path to docker compose file to start dependencies' required: false @@ -37,11 +37,18 @@ inputs: upload-sonar-results: description: 'Whether to upload Sonar results as an artifact' required: false - default: 'false' + default: true runs: using: 'composite' steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Java Install + uses: actions/setup-java@v1 + with: + java-version: '17' - name: Dotnet Sonar Scanner Install run: | @@ -63,15 +70,15 @@ runs: fi shell: bash - - name: Start Containerized Dependencies - if: (inputs.use-dependencies == 'true') && (inputs.path-to-repo-root == '') + - name: Containerized Dependencies + if: ${{ inputs.use-dependencies == true && inputs.path-to-repo-root == ''}} run: | echo "Running docker compose" docker-compose -f ${{inputs.docker-compose-file-path}} up -d shell: bash - - name: Start Containerized Dependencies with Path - if: (inputs.use-dependencies == 'true') && (inputs.path-to-repo-root != '') + - name: Containerized Dependencies with Path + if: ${{ inputs.use-dependencies == true && inputs.path-to-repo-root != ''}} run: | echo "Running docker compose" PATH_TO_REPO_ROOT='${{ inputs.path-to-repo-root }}' docker-compose -f ${{inputs.docker-compose-file-path}} up -d @@ -122,14 +129,14 @@ runs: shell: bash - uses: actions/upload-artifact@v3 - if: (inputs.upload-sonar-results == 'true') + if: ${{ inputs.upload-sonar-results == true }} with: name: sonar-report path: .sonarqube/out/.sonar/report-task.txt - name: Output Docker Container Logs uses: jwalton/gh-docker-logs@v2 - if: inputs.use-dependencies == 'true' && always() + if: ${{ inputs.use-dependencies == true && always() }} - name: Test Report uses: dorny/test-reporter@v1 @@ -140,8 +147,15 @@ runs: reporter: dotnet-trx - name: Stop Containerized Dependencies - if: inputs.use-dependencies == 'true' && always() + if: ${{ inputs.use-dependencies == true && always() }} run: | echo "Stopping Docker Containers" docker-compose -f ${{inputs.docker-compose-file-path}} down -v --remove-orphans shell: bash + + - name: SonarQube Code Coverage Results + run: | + export BRANCH_NAME=${GITHUB_REF#refs/heads/} + export REPO_NAME=${{ env.github-repo-name }} + echo "SonarQube Code Coverage Results: https://sonar.dev-internal.patriotsoftware.com/dashboard?branch=$BRANCH_NAME&id=SynergyDataSystems_$REPO_NAME" + shell: bash From 8e9588cbdb7616c5c7a908878c4f00a01542003a Mon Sep 17 00:00:00 2001 From: Marco Date: Fri, 6 Oct 2023 15:38:24 -0400 Subject: [PATCH 03/10] Update action.yml --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index c610cb6..1503066 100644 --- a/action.yml +++ b/action.yml @@ -89,7 +89,7 @@ runs: GITHUB_TOKEN: ${{ inputs.github-token }} run: | export PATH=$PATH:$HOME/.dotnet/tools - dotnet sonarscanner begin /k:"${{ inputs.sonar-project-name }}" /d:sonar.scm.revision=$GITHUB_SHA /d:sonar.token=${{ inputs.sonar-token }} /d:sonar.host.url=https://sonar.dev-internal.patriotsoftware.com /d:sonar.cs.vscoveragexml.reportsPaths=coverage.xml /d:sonar.verbose=false + dotnet sonarscanner begin /k:"${{ inputs.github-repo-name }}" /d:sonar.scm.revision=$GITHUB_SHA /d:sonar.token=${{ inputs.sonar-token }} /d:sonar.host.url=https://sonar.dev-internal.patriotsoftware.com /d:sonar.cs.vscoveragexml.reportsPaths=coverage.xml /d:sonar.verbose=false shell: bash - name: Project Build From a334de7c1fb9666b1d33bca8af52e2cb4acd01f4 Mon Sep 17 00:00:00 2001 From: Marco Date: Fri, 6 Oct 2023 15:46:37 -0400 Subject: [PATCH 04/10] update repo name --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 1503066..4ce155e 100644 --- a/action.yml +++ b/action.yml @@ -89,7 +89,7 @@ runs: GITHUB_TOKEN: ${{ inputs.github-token }} run: | export PATH=$PATH:$HOME/.dotnet/tools - dotnet sonarscanner begin /k:"${{ inputs.github-repo-name }}" /d:sonar.scm.revision=$GITHUB_SHA /d:sonar.token=${{ inputs.sonar-token }} /d:sonar.host.url=https://sonar.dev-internal.patriotsoftware.com /d:sonar.cs.vscoveragexml.reportsPaths=coverage.xml /d:sonar.verbose=false + dotnet sonarscanner begin /k:"SynergyDataSystems_${{ inputs.github-repo-name }}" /d:sonar.scm.revision=$GITHUB_SHA /d:sonar.token=${{ inputs.sonar-token }} /d:sonar.host.url=https://sonar.dev-internal.patriotsoftware.com /d:sonar.cs.vscoveragexml.reportsPaths=coverage.xml /d:sonar.verbose=false shell: bash - name: Project Build From 72c92f54d33d62b6cb6dbec6ea0d00e954dd80a4 Mon Sep 17 00:00:00 2001 From: Marco Date: Fri, 6 Oct 2023 15:50:29 -0400 Subject: [PATCH 05/10] update sonar project name --- action.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/action.yml b/action.yml index 4ce155e..2ea720c 100644 --- a/action.yml +++ b/action.yml @@ -88,8 +88,9 @@ runs: env: GITHUB_TOKEN: ${{ inputs.github-token }} run: | - export PATH=$PATH:$HOME/.dotnet/tools - dotnet sonarscanner begin /k:"SynergyDataSystems_${{ inputs.github-repo-name }}" /d:sonar.scm.revision=$GITHUB_SHA /d:sonar.token=${{ inputs.sonar-token }} /d:sonar.host.url=https://sonar.dev-internal.patriotsoftware.com /d:sonar.cs.vscoveragexml.reportsPaths=coverage.xml /d:sonar.verbose=false + export PATH=$PATH:$HOME/.dotnet/toolse + export SONAR_PROJECT="SynergyDataSystems_${{ inputs.github-repo-name }}" + dotnet sonarscanner begin /k:$SONAR_PROJECT /d:sonar.scm.revision=$GITHUB_SHA /d:sonar.token=${{ inputs.sonar-token }} /d:sonar.host.url=https://sonar.dev-internal.patriotsoftware.com /d:sonar.cs.vscoveragexml.reportsPaths=coverage.xml /d:sonar.verbose=false shell: bash - name: Project Build From 2feea56f2f7213f64ca0d67b1f26ee0739b47da6 Mon Sep 17 00:00:00 2001 From: Marco Date: Fri, 6 Oct 2023 16:07:03 -0400 Subject: [PATCH 06/10] update repo name on sonar run --- action.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/action.yml b/action.yml index 2ea720c..0fa7663 100644 --- a/action.yml +++ b/action.yml @@ -89,8 +89,7 @@ runs: GITHUB_TOKEN: ${{ inputs.github-token }} run: | export PATH=$PATH:$HOME/.dotnet/toolse - export SONAR_PROJECT="SynergyDataSystems_${{ inputs.github-repo-name }}" - dotnet sonarscanner begin /k:$SONAR_PROJECT /d:sonar.scm.revision=$GITHUB_SHA /d:sonar.token=${{ inputs.sonar-token }} /d:sonar.host.url=https://sonar.dev-internal.patriotsoftware.com /d:sonar.cs.vscoveragexml.reportsPaths=coverage.xml /d:sonar.verbose=false + dotnet sonarscanner begin /k:"SynergyDataSystems_${{ inputs.github-repo-name }}" /d:sonar.scm.revision=$GITHUB_SHA /d:sonar.token=${{ inputs.sonar-token }} /d:sonar.host.url=https://sonar.dev-internal.patriotsoftware.com /d:sonar.cs.vscoveragexml.reportsPaths=coverage.xml /d:sonar.verbose=false shell: bash - name: Project Build From 1a985ee78a10247e40cd05172cdc3a9fca289ecf Mon Sep 17 00:00:00 2001 From: Marco Date: Fri, 6 Oct 2023 16:18:24 -0400 Subject: [PATCH 07/10] fixed mispelling --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 0fa7663..4ce155e 100644 --- a/action.yml +++ b/action.yml @@ -88,7 +88,7 @@ runs: env: GITHUB_TOKEN: ${{ inputs.github-token }} run: | - export PATH=$PATH:$HOME/.dotnet/toolse + export PATH=$PATH:$HOME/.dotnet/tools dotnet sonarscanner begin /k:"SynergyDataSystems_${{ inputs.github-repo-name }}" /d:sonar.scm.revision=$GITHUB_SHA /d:sonar.token=${{ inputs.sonar-token }} /d:sonar.host.url=https://sonar.dev-internal.patriotsoftware.com /d:sonar.cs.vscoveragexml.reportsPaths=coverage.xml /d:sonar.verbose=false shell: bash From ee6833dbea378422de06d92dc54fee07576c4162 Mon Sep 17 00:00:00 2001 From: Marco Date: Fri, 6 Oct 2023 16:27:07 -0400 Subject: [PATCH 08/10] Update action.yml --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 4ce155e..a11e6a7 100644 --- a/action.yml +++ b/action.yml @@ -156,6 +156,6 @@ runs: - name: SonarQube Code Coverage Results run: | export BRANCH_NAME=${GITHUB_REF#refs/heads/} - export REPO_NAME=${{ env.github-repo-name }} + export REPO_NAME=${{ inputs.github-repo-name }} echo "SonarQube Code Coverage Results: https://sonar.dev-internal.patriotsoftware.com/dashboard?branch=$BRANCH_NAME&id=SynergyDataSystems_$REPO_NAME" shell: bash From 06692aa721e2a4ec802e9e6ba9e257577100d07f Mon Sep 17 00:00:00 2001 From: Marco Date: Fri, 6 Oct 2023 16:45:48 -0400 Subject: [PATCH 09/10] Update action.yml --- action.yml | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/action.yml b/action.yml index a11e6a7..a24f138 100644 --- a/action.yml +++ b/action.yml @@ -71,17 +71,17 @@ runs: shell: bash - name: Containerized Dependencies - if: ${{ inputs.use-dependencies == true && inputs.path-to-repo-root == ''}} + if: ${{ inputs.use-dependencies == true && inputs.path-to-repo-root == '' }} run: | echo "Running docker compose" docker-compose -f ${{inputs.docker-compose-file-path}} up -d shell: bash - name: Containerized Dependencies with Path - if: ${{ inputs.use-dependencies == true && inputs.path-to-repo-root != ''}} + if: ${{ inputs.use-dependencies == true && inputs.path-to-repo-root != '' }} run: | echo "Running docker compose" - PATH_TO_REPO_ROOT='${{ inputs.path-to-repo-root }}' docker-compose -f ${{inputs.docker-compose-file-path}} up -d + PATH_TO_REPO_ROOT='${{ inputs.path-to-repo-root }}' docker-compose -f ${{ inputs.docker-compose-file-path }} up -d shell: bash - name: Sonarqube Run @@ -100,24 +100,20 @@ runs: - name: Run Tests and Code Coverage env: - AWS_ACCOUNT_ID: '305628290583' - AWS_REGION: 'us-east-1' - AWS_ACCESS_KEY_ID: ${{ inputs.aws-access-key-id }} - AWS_SECRET_ACCESS_KEY: ${{ inputs.aws-secret-access-key }} GITHUB_TOKEN: ${{ inputs.github-token }} run: | echo "running dotnet tests and code coverage....." dotnet tool update -g dotnet-coverage export PATH=$PATH:$HOME/.dotnet/tools . ~/.bashrc - dotnet-coverage collect 'dotnet test --logger "trx;LogFileName=test-results.trx" --configuration Release --verbosity minimal --collect "Code Coverage" --filter TestCategory!="Smoke" --settings:test/local.runsettings' -f xml -o 'coverage.xml' + dotnet-coverage collect 'dotnet test --logger "trx;LogFileName=test-results.trx" --verbosity minimal --configuration Release --filter TestCategory!="Smoke" --settings:test/local.runsettings' -f xml -o 'coverage.xml' shell: bash - name: Sonarqube end run: | export PATH=$PATH:$HOME/.dotnet/tools . ~/.bashrc - dotnet sonarscanner end /d:sonar.token="${{inputs.sonar-token }}" + dotnet sonarscanner end /d:sonar.token="${{ inputs.sonar-token }}" env: GITHUB_TOKEN: ${{ inputs.github-token }} shell: bash From eccd7a6614c8b6ee8b915d14c7aa14b0aa3f0c95 Mon Sep 17 00:00:00 2001 From: Marco Date: Fri, 6 Oct 2023 16:58:57 -0400 Subject: [PATCH 10/10] Update README.md --- README.md | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 2a91060..9825586 100644 --- a/README.md +++ b/README.md @@ -11,9 +11,8 @@ validate the quality of a project. ## Parameters -#### 'sonar-project-name' (required) -The name of the Sonar project so we can publish -the results to the right place. +#### 'github-repo-name' (required) +The name of the GitHub repo name. #### 'sonar-tool-version' (optional) The Sonar tool version we install for this run. Default @@ -53,17 +52,15 @@ This parameter controls whether to upload Sonar results as an artifact. ## Sample Use ``` -project-validation: - needs: [ alert-action-started ] - name: "Validate Project Quality" - runs-on: psidev-linux - steps: - - uses: patriotsoftware/project-validation-action@v1 - with: - sonar-project-name: SynergyDataSystems_PatriotSoftware.Time - sonar-token: ${{ secrets.SONAR_TOKEN }} - use-dependencies: 'true' - github-token: ${{ secrets.GITHUB_TOKEN }} - aws-access-key-id: ${{ secrets.DEV_AWS_ACCESS_KEY_ID }} - aws-secret-access-key: ${{ secrets.DEV_AWS_SECRET_ACCESS_KEY }} + project-validation: + name: "Sonar Validate Project Quality" + runs-on: psidev-linux + steps: + - uses: patriotsoftware/project-validation-action@v1.1 + with: + sonar-token: ${{ secrets.SONAR_TOKEN }} + github-repo-name: ${{ github.event.repository.name }} + github-token: ${{ secrets.GITHUB_TOKEN }} + aws-access-key-id: ${{ secrets.DEV_AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.DEV_AWS_SECRET_ACCESS_KEY }} ```