From 4c899fddf6a20ee4ce59f82398f6af71225cec5b Mon Sep 17 00:00:00 2001 From: Guillaume Gnaegi <58469901+ggnaegi@users.noreply.github.com> Date: Sat, 21 Oct 2023 16:40:26 +0200 Subject: [PATCH] adding github action --- .github/workflows/code_quality_sonarqube.yml | 47 ++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 .github/workflows/code_quality_sonarqube.yml diff --git a/.github/workflows/code_quality_sonarqube.yml b/.github/workflows/code_quality_sonarqube.yml new file mode 100644 index 0000000000..517bcb80dd --- /dev/null +++ b/.github/workflows/code_quality_sonarqube.yml @@ -0,0 +1,47 @@ +name: Ocelot Code Quality Checks + +on: + workflow_dispatch: + inputs: + logLevel: + description: 'Log level' + required: true + default: 'warning' + push: + branches: [ "develop" ] + pull_request: + branches: [ "develop" ] + +jobs: + CI_Pipeline: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Setup .NET + uses: actions/setup-dotnet@v3 + with: + dotnet-version: 7.0.x + - name: Restore dependencies + run: dotnet restore Ocelot.sln + - name: Build + run: dotnet build --no-restore Ocelot.sln + - name: Acceptance Tests + run: dotnet test test/Ocelot.AcceptanceTests/Ocelot.AcceptanceTests.csproj --no-build /p:CollectCoverage=true /p:CoverletOutput=TestResults/ /p:CoverletOutputFormat=opencover + - name: Rename paths in coverage file (Acceptance Tests) + run: sed -i 's|/home/runner/work/Ocelot/Ocelot|/github/workspace|g' /home/runner/work/Ocelot/Ocelot/test/Ocelot.AcceptanceTests/TestResults/coverage.opencover.xml + - name: Unit Tests + run: dotnet test test/Ocelot.UnitTests/Ocelot.UnitTests.csproj --no-build /p:CollectCoverage=true /p:CoverletOutput=TestResults/ /p:CoverletOutputFormat=opencover + - name: Rename paths in coverage file (Unit Tests) + run: sed -i 's|/home/runner/work/Ocelot/Ocelot|/github/workspace|g' /home/runner/work/Ocelot/Ocelot/test/Ocelot.UnitTests/TestResults/coverage.opencover.xml + - name: SonarScanner for .NET 7 with pull request decoration support + uses: highbyte/sonarscan-dotnet@v2.2.6 + with: + sonarProjectKey: ggnaegi_Ocelot + sonarProjectName: Ocelot + sonarOrganization: ggnaegi + dotnetBuildArguments: Ocelot.sln + dotnetDisableTests: true + sonarBeginArguments: /d:sonar.cs.opencover.reportsPaths="**/*.opencover.xml" /d:sonar.verbose=true /d:sonar.scm.exclusions.disabled=true /d:sonar.coverage.exclusions="**Test*.cs" + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}