Skip to content

Commit

Permalink
Updated cashing and template
Browse files Browse the repository at this point in the history
  • Loading branch information
Farshad DASHTI authored and Farshad DASHTI committed Oct 4, 2024
1 parent 9d10c86 commit efc989c
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 9 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build-test-caching.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ jobs:
project_name: DfE.CoreLibs.Caching
project_path: src/DfE.CoreLibs.Caching
sonar_project_key: DFE-Digital_corelibs-caching
run_tests: false
secrets:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
28 changes: 21 additions & 7 deletions .github/workflows/build-test-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ on:
required: true
type: string
description: "SonarCloud project key"
run_tests:
required: true
type: boolean
default: true
description: "Flag to run or skip tests"
secrets:
SONAR_TOKEN:
required: true
Expand Down Expand Up @@ -70,13 +75,22 @@ jobs:

- name: Build, Test and Analyze
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
ConnectionStrings__DefaultConnection: ${{ env.CONNECTION_STRING }}
CI: true
run: |
dotnet-sonarscanner begin /k:"${{ inputs.sonar_project_key }}" /o:"dfe-digital" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.coverageReportPaths=CoverageReport/SonarQube.xml
if [ ${{ inputs.run_tests }} == "true" ]; then
dotnet-sonarscanner begin /k:"${{ inputs.sonar_project_key }}" /o:"dfe-digital" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.coverageReportPaths=CoverageReport/SonarQube.xml;
else
dotnet-sonarscanner begin /k:"${{ inputs.sonar_project_key }}" /o:"dfe-digital" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io";
fi
dotnet build --no-restore -p:CI=${CI} ${{ inputs.project_path }}
dotnet test --no-build --verbosity normal --collect:"XPlat Code Coverage" ${{ inputs.project_path }}
reportgenerator -reports:./**/coverage.cobertura.xml -targetdir:./CoverageReport -reporttypes:SonarQube
dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}"
- name: Run Tests
if: ${{ inputs.run_tests }} == true
run: dotnet test --no-build --verbosity normal --collect:"XPlat Code Coverage" ${{ inputs.project_path }}

- name: Generate Code Coverage Report
if: ${{ inputs.run_tests }} == true
run: reportgenerator -reports:./**/coverage.cobertura.xml -targetdir:./CoverageReport -reporttypes:SonarQube

- name: Complete Sonar Scan
run: dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}"
3 changes: 1 addition & 2 deletions src/DfE.CoreLibs.Caching/ServiceCollectionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,4 @@ public static IServiceCollection AddServiceCaching(
return services;
}
}
}

}

0 comments on commit efc989c

Please sign in to comment.